pynbody.snapshot.util.ContainerWithPhysicalUnitsOption#
- class pynbody.snapshot.util.ContainerWithPhysicalUnitsOption[source]#
Bases:
object
Defines an abstract class that has properties and arrays that can be converted to physical units.
Methods
physical_units
([distance, velocity, mass, ...])Converts all arrays' units to be consistent with the distance, velocity, mass basis units specified.
- __init__(*args, **kwargs)#
- physical_units(distance='kpc', velocity='km s^-1', mass='Msol', persistent=True, convert_parent=True)[source]#
Converts all arrays’ units to be consistent with the distance, velocity, mass basis units specified.
- Parameters:
distance (string (default = 'kpc')) – The distance unit to convert to.
velocity (string (default = 'km s^-1')) – The velocity unit to convert to.
mass (string (default = 'Msol')) – The mass unit to convert to.
persistent (boolean (default = True)) – Apply units change to future lazy-loaded arrays if True.
convert_parent (boolean (default = True)) – Propagate units change from a halo catalogue to a parent snapshot. See note below.
Note
The option convert_parent is only applicable to
Halo
objects. It is ignored by all other objects, includingpynbody.snapshot.simsnap.SimSnap
,pynbody.snapshot.subsnap.SubSnap
, andpynbody.halo.HaloCatalogue
objects.When
physical_units
is called on apynbody.halo.Halo
and convert_parent is True, no immediate action is taken on thepynbody.halo.Halo
itself; rather the request is passed upwards to thepynbody.halo.HaloCatalogue
.The catalogue object then calls
physical_units
on the parent snapshot and on all cached halos, settingconvert_parent=False
so that the units change is then applied to thepynbody.halo.Halo
object itself.This ensures that unit changes propagate through to properties of all halos. Most users will not need to worry about this subtlety; things should ‘just work’ if you ignore the convert_parent option.