[refactoring] removed star imports, renamed cst in U
and applied flake8 guidelines
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
# coding: utf-8
|
||||
|
||||
import astrophysix.units as cst
|
||||
import astrophysix.units as U
|
||||
|
||||
create_unit = cst.Unit.create_unit
|
||||
create_unit = U.Unit.create_unit
|
||||
|
||||
|
||||
def parse_exp_unit(u):
|
||||
splitted = u.split("^")
|
||||
name_u = cst.Unit.from_name(splitted[0]).latex.replace("text", "math")
|
||||
name_u = U.Unit.from_name(splitted[0]).latex.replace("text", "math")
|
||||
exp = ""
|
||||
if len(splitted) > 1:
|
||||
exp = "^{" + str(splitted[1]) + "}"
|
||||
@@ -39,7 +39,7 @@ def unit_str(unit, base=None, prefix="", format=" [{unit}]"):
|
||||
prefix : str to put befor the unit
|
||||
format : str with the {unit} key, to put external decoration
|
||||
"""
|
||||
if unit == cst.none:
|
||||
if unit == U.none:
|
||||
return ""
|
||||
elif not base is None:
|
||||
coeff = unit.express(base)
|
||||
@@ -64,33 +64,31 @@ def unit_str(unit, base=None, prefix="", format=" [{unit}]"):
|
||||
return format.format(unit=u_str)
|
||||
|
||||
|
||||
cst.coldens = create_unit(
|
||||
"Msun.pc^-2", base_unit=cst.Msun / cst.pc ** 2, descr="Column density"
|
||||
U.coldens = create_unit(
|
||||
"Msun.pc^-2", base_unit=U.Msun / U.pc ** 2, descr="Column density"
|
||||
)
|
||||
cst.km_s = create_unit("km.s^-1", base_unit=cst.km / cst.s, descr="Speed")
|
||||
U.km_s = create_unit("km.s^-1", base_unit=U.km / U.s, descr="Speed")
|
||||
|
||||
|
||||
cst.Msun_pc3 = create_unit(
|
||||
"Msun.pc^-3", base_unit=cst.Msun / cst.pc ** 3, descr="Density"
|
||||
)
|
||||
U.Msun_pc3 = create_unit("Msun.pc^-3", base_unit=U.Msun / U.pc ** 3, descr="Density")
|
||||
|
||||
cst.kg_m3 = create_unit("kg.m^-3", base_unit=cst.kg / cst.m ** 3, descr="Density")
|
||||
U.kg_m3 = create_unit("kg.m^-3", base_unit=U.kg / U.m ** 3, descr="Density")
|
||||
|
||||
cst.ssfr = create_unit(
|
||||
U.ssfr = create_unit(
|
||||
"Msun.year^-1.pc^-2",
|
||||
base_unit=cst.Msun / cst.year / cst.pc ** 2,
|
||||
base_unit=U.Msun / U.year / U.pc ** 2,
|
||||
descr="Surfacic SFR",
|
||||
)
|
||||
# latex='M$_{\odot}$.yr$^{-1}$.pc$^{-2}$')
|
||||
|
||||
cst.ssfrG = create_unit(
|
||||
U.ssfrG = create_unit(
|
||||
"Msun.Gyr^-1.pc^-2",
|
||||
base_unit=1e-9 * cst.Msun / cst.year / cst.pc ** 2,
|
||||
base_unit=1e-9 * U.Msun / U.year / U.pc ** 2,
|
||||
descr="Surfacic SFR",
|
||||
latex="\mathrm{M}_{\odot}.\mathrm{Gyr}^{-1}.\mathrm{pc}^{-2}",
|
||||
)
|
||||
|
||||
|
||||
cst.uG = create_unit(
|
||||
"μG", base_unit=1e-10 * cst.T, descr="Micro Gauss", latex="\\mu\\mathrm{G}"
|
||||
U.uG = create_unit(
|
||||
"μG", base_unit=1e-10 * U.T, descr="Micro Gauss", latex="\\mu\\mathrm{G}"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user