yt.units package

Submodules

Module contents

class yt.units.UnitContainer(registry)[source]

Bases: object

A container for units and constants to associate with a dataset

This object is usually accessed on a Dataset instance via ds.units.

Parameters:

registry (UnitRegistry instance) – A unit registry to associate with units and constants accessed on this object.

Example

>>> ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> code_mass = ds.units.code_mass
>>> (12 * code_mass).to("Msun")
unyt_quantity(4.89719136e+11, 'Msun')
>>> code_mass.registry is ds.unit_registry
True
>>> ds.units.newtons_constant
unyt_quantity(6.67384e-08, 'cm**3/(g*s**2)')
yt.units.display_ytarray(arr)[source]

Display a YTArray in a Jupyter widget that enables unit switching.

The array returned by this function is read-only, and only works with arrays of size 3 or lower.

Parameters:

arr (YTArray) – The Array to display; must be of size 3 or lower.

Examples

>>> ds = yt.load("IsolatedGalaxy/galaxy0030/galaxy0030")
>>> display_ytarray(ds.domain_width)