Reference on kuibit.unitconv¶
This module provides a class Units representing unit systems or unit conversions.
Units can be used to convert from geometrized units to SI.
For example, assuming a that we are using geometrized units with \(G = c =
M = 1\), where \(M = 65 M_\odot\), we can defined the object CU =
geom_umass(65 * M_SUN_SI)
. CU knows how to convert geometrized quantities to
SI: for instance, to convert the length variable d from geometrized units to SI,
just multiply d times CU.length
. Similarly for all the other quantities.
The module provides convenience functions to define geometrized system of units:
geom_umass_msun()
, geom_umass()
, and
geom_length()
can be used to generate Units
objects
that know how to convert from/to SI and geometrized units where lengthscale or
mass scales were defined.
The following natural constants are defined (in SI units)
C_SI
(Vacuum speed of light)G_SI
(Gravitational constant)M_SOL_SI
(Solar mass)M_SUN_SI
(Solar mass)LIGHTYEAR_SI
(Lightyear)MEGAPARSEC_SI
(Megaparsec)PARSEC_SI
(Parsec)H0_SI
(Hubble constant [1/s])
- class kuibit.unitconv.Units(ulength, utime, umass)[source]¶
Class representing unit conversion. The unit system is specified by length, time, and mass units, from which derived units are computed.
This class can be used to convert units from one system to another.
For example, define
CGS = Units(1.0e-2, 1.0, 1.0e-3)
. If the length d is in SI, thend * CGS.length
will be in CGS.The main use of Units in kuibit is to provide a way to convert from geometrized units to physical units (see,
geom_umass()
).Create a unit system based on length unit ulength, time unit utime, and mass unit umass.
- Parameters
ulength (float) – Unit of length with respect to SI.
utime (float) – Unit of time with respect to SI.
umass (float) – Unit of mass with respect to SI.
- kuibit.unitconv.geom_ulength(ulength)[source]¶
Create a geometric unit system, expressed in SI, based on the given length unit expressed in SI units as well.
- Parameters
ulength (float) – Unit of length with respect to SI.
- Rvalue
Geometrized units with length scale set by
ulength
.- Return type
:py:class :~.Units