pynbody.units.IrreducibleUnit#

class pynbody.units.IrreducibleUnit(st)[source]#

Bases: UnitBase

Methods

dimensionality_as_string()

Returns the dimensionality of the Unit object.

in_units(*a, **kw)

Alias for ratio

irrep()

Return a unit equivalent to this one (may be identical) but expressed in terms of the currently defined IrreducibleUnit instances.

ratio(other, **substitutions)

Get the conversion ratio between this Unit and another specified unit.

is_dimensionless

latex

simplify

__init__(st)[source]#
dimensionality_as_string()#

Returns the dimensionality of the Unit object.

Example

> pynbody.units.Unit(“3e8 m s**-1 yr”).dimensionality_as_string() ‘m^1’

in_units(*a, **kw)#

Alias for ratio

irrep()[source]#

Return a unit equivalent to this one (may be identical) but expressed in terms of the currently defined IrreducibleUnit instances.

ratio(other, **substitutions)#

Get the conversion ratio between this Unit and another specified unit.

Keyword arguments, if specified, give numerical substitutions for the named unit. This is most useful for specifying values for cosmological quantities like ‘a’ and ‘h’, but can also be used for any IrreducibleUnit.

>>> Unit("1 Mpc a").ratio("kpc", a=0.25)
250.0
>>> Unit("1 Mpc").ratio("Msol")
UnitsException: not convertible
>>> Unit("1 Mpc").ratio("Msol", kg=25.0, m=50.0)
3.1028701506345152e-08