unyt.unit_systems module¶
Unit system class.
-
unyt.unit_systems.
add_symbols
(namespace, registry)[source]¶ Adds the unit symbols from
unyt.unit_symbols
to a namespaceParameters: - namespace (dict) – The dict to insert unit symbols into. The keys will be string unit names and values will be the corresponding unit objects.
- registry (
unyt.unit_registry.UnitRegistry
) – The registry to create units from. Note that if you would like to use a custom unit system, ensure your registry was created using that unit system.
Example
>>> from unyt.unit_registry import UnitRegistry >>> class MyClass(): ... def __init__(self): ... self.reg = UnitRegistry() ... add_symbols(vars(self), self.reg) >>> foo = MyClass() >>> foo.kilometer km >>> foo.joule J
-
unyt.unit_systems.
add_constants
(namespace, registry)[source]¶ Adds the quantities from
unyt.physical_constants
to a namespaceParameters: - namespace (dict) – The dict to insert quantities into. The keys will be string names and values will be the corresponding quantities.
- registry (
unyt.unit_registry.UnitRegistry
) – The registry to create units from. Note that if you would like to use a custom unit system, ensure your registry was created using that unit system.
Example
>>> from unyt.unit_registry import UnitRegistry >>> class MyClass(): ... def __init__(self): ... self.reg = UnitRegistry(unit_system='cgs') ... add_constants(vars(self), self.reg) >>> foo = MyClass() >>> foo.gravitational_constant unyt_quantity(6.67408e-08, 'cm**3/(g*s**2)') >>> foo.speed_of_light unyt_quantity(2.99792458e+10, 'cm/s')
-
class
unyt.unit_systems.
UnitSystem
(name, length_unit, mass_unit, time_unit, temperature_unit='K', angle_unit='rad', current_mks_unit='A', luminous_intensity_unit='cd', logarithmic_unit='Np', registry=None)[source]¶ Bases:
object
Create a UnitSystem for facilitating conversions to a default set of units.
Parameters: - name (string) – The name of the unit system. Will be used as the key in the unit_system_registry dict to reference the unit system by.
- length_unit (string or
unyt.unit_object.Unit
) – The base length unit of this unit system. - mass_unit (string or
unyt.unit_object.Unit
) – The base mass unit of this unit system. - time_unit (string or
unyt.unit_object.Unit
) – The base time unit of this unit system. - temperature_unit (string or
unyt.unit_object.Unit
, optional) – The base temperature unit of this unit system. Defaults to “K”. - angle_unit (string or
unyt.unit_object.Unit
, optional) – The base angle unit of this unit system. Defaults to “rad”. - mks_system (boolean, optional) – Whether or not this unit system has SI-specific units. Default: False
- current_mks_unit (string or
unyt.unit_object.Unit
, optional) – The base current unit of this unit system. Defaults to “A”. - luminous_intensity_unit (string or
unyt.unit_object.Unit
, optional) – The base luminous intensity unit of this unit system. Defaults to “cd”. - registry (
unyt.unit_registry.UnitRegistry
object) – The unit registry associated with this unit system. Only useful for defining unit systems based on code units.
-
has_current_mks
¶ Does this unit system have an MKS current dimension?
-
unyt.unit_systems.
cgs_unit_system
= cgs Unit System Base Units: length: cm mass: g time: s temperature: K angle: rad luminous_intensity: cd logarithmic: Np Other Units: energy: erg specific_energy: erg/g pressure: dyn/cm**2 force: dyn magnetic_field_cgs: G charge_cgs: statC current_cgs: statA power: erg/s¶ The CGS unit system
-
unyt.unit_systems.
mks_unit_system
= mks Unit System Base Units: length: m mass: kg time: s temperature: K angle: rad current_mks: A luminous_intensity: cd logarithmic: Np Other Units: energy: J specific_energy: J/kg pressure: Pa force: N magnetic_field: T charge: C frequency: Hz power: W electric_potential: V capacitance: F inductance: H resistance: Ω magnetic_flux: Wb luminous_flux: lm¶ The MKS unit system
-
unyt.unit_systems.
imperial_unit_system
= imperial Unit System Base Units: length: ft mass: lb time: s temperature: R angle: rad current_mks: A luminous_intensity: cd logarithmic: Np Other Units: force: lbf energy: ft*lbf pressure: lbf/ft**2 power: hp¶ The imperial unit system
-
unyt.unit_systems.
galactic_unit_system
= galactic Unit System Base Units: length: kpc mass: Msun time: Myr temperature: K angle: rad current_mks: A luminous_intensity: cd logarithmic: Np Other Units: energy: keV magnetic_field_cgs: μG¶ The galactic unit system
-
unyt.unit_systems.
solar_unit_system
= solar Unit System Base Units: length: AU mass: Mearth time: yr temperature: K angle: rad current_mks: A luminous_intensity: cd logarithmic: Np Other Units:¶ The solar unit system
-
unyt.unit_systems.
geometrized_unit_system
= geometrized Unit System Base Units: length: l_geom mass: m_geom time: t_geom temperature: K angle: rad current_mks: A luminous_intensity: cd logarithmic: Np Other Units:¶ Geometrized unit system
-
unyt.unit_systems.
planck_unit_system
= planck Unit System Base Units: length: l_pl mass: m_pl time: t_pl temperature: T_pl angle: rad current_mks: A luminous_intensity: cd logarithmic: Np Other Units: energy: E_pl charge_mks: q_pl¶ Planck unit system