Last active
April 13, 2022 22:27
-
-
Save Miladiouss/fb06d9e08efdb24f8c8a45c8b6fea503 to your computer and use it in GitHub Desktop.
Revisions
-
Milad Pourrahmani revised this gist
Apr 13, 2022 . 1 changed file with 13 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,24 +1,30 @@ # Science import numpy as np from astropy.units import Unit # Notebook from IPython.display import Markdown from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" # Handy functions def Qshow(Q, sigfig=2, unit=None, name=None): name = Q.info.name if unit is not None: Q = Q.to(unit) if sigfig is not None: q = Q.round(sigfig - int(np.log10(Q.value))) else: q = Q if name is not None: output = Markdown(f'{name} = {q._repr_latex_()}') else: output = Markdown(f'{q._repr_latex_()}') return output # Parameter density = 1.23456e12 * Unit('g/cm^3') density.info.name = r'$\rho$' # Results Qshow(density) -
Milad Pourrahmani revised this gist
Apr 13, 2022 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,8 +8,10 @@ InteractiveShell.ast_node_interactivity = "all" # Handy functions def Qshow(Q, sigfig=2, unit=None): if unit is not None: Q = Q.to(unit) Q = Q.round(sigfig - int(np.log10(Q.value))) if Q.info.name is not None: output = Markdown(f'{Q.info.name} = {Q._repr_latex_()}') else: -
Milad Pourrahmani created this gist
Apr 13, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,22 @@ # Science from astropy.units import Unit import numpy as np # Notebook from IPython.display import Markdown from IPython.core.interactiveshell import InteractiveShell InteractiveShell.ast_node_interactivity = "all" # Handy functions def Qshow(Q, sigfig=2): Q.round(sigfig - int(np.log10(Q.value))) if Q.info.name is not None: output = Markdown(f'{Q.info.name} = {Q._repr_latex_()}') else: output = Markdown(f'{Q._repr_latex_()}') return output # Parameter density = 2 * Unit('g/cm^3') density.info.name = r'$\rho$' Qshow(density)