yt.frontends.sph.data_structures.ParticleDataset.quan

ParticleDataset.quan

Converts an scalar into a yt.units.yt_array.YTQuantity

The returned YTQuantity will be dimensionless by default, but can be cast to arbitray units using the input_units keyword argument.

Parameters:

input_scalar : an integer or floating point scalar

The scalar to attach units to

input_units : String unit specification, unit symbol object, or astropy

units

The units of the quantity. Powers must be specified using python syntax (cm**3, not cm^3).

dtype : string or NumPy dtype object

The dtype of the array data.

Examples

>>> import yt
>>> ds = yt.load('IsolatedGalaxy/galaxy0030/galaxy0030')
>>> a = ds.quan(1, 'cm')
>>> b = ds.quan(2, 'm')
>>> a + b
201.0 cm
>>> b + a
2.01 m

Quantities created this way automatically know about the unit system of the dataset.

>>> a = ds.quan(5, 'code_length')
>>> a.in_cgs()
1.543e+25 cm