PlasmaCalcs.units.units_haver.CoordsUnitsHaver

class PlasmaCalcs.units.units_haver.CoordsUnitsHaver(u=None, units=None, **kw_super)

Bases: UnitsHaver

UnitsHaver which allows to set separate units systems for coordinates and data.
Expects coordinate-units-getting-calls to supply alt=’coords’ to self.u,
otherwise will default to coords units being the same as self units.
__init__(u=None, units=None, **kw_super)

Methods

__init__([u, units])

get_behavior([keys])

record_units(array)

units_meta()

Attributes

behavior

behavior_attrs

cls_behavior_attrs

coords_units

coords_units_explicit

nondim_behavior_attrs

u

units

property behavior
dict of {attr: self.attr} for attr in self.behavior_attrs. Note dims are separate;
dims go in behavior.dims. E.g. Behavior({‘units’:’si’,…}, dims={‘snap’:0,…}).
property behavior_attrs
list of attrs in self which control behavior of self.
Here, returns self.cls_behavior_attrs.
Subclasses could override if any behavior attrs are not known at the class-level,
e.g. if MySubclass’s list of behavior attrs varies between instances of MySubclass.
property coords_units
None or str telling the current unit system for coordinates, e.g. ‘si’.
None –> “coords_units should match self.units”.
Value stored at self.u.alts.get(‘coords’, None)
See also: coords_units_explicit
property coords_units_explicit
str telling the current unit system for coordinates, e.g. ‘si’.
alias to self.coords_units if not None, else self.units.

equivalent: self.u.alts.get(‘coords’, self.units)

get_behavior(keys=None)
return value of self.behavior.
keys: None or iterable
if provided, only include these attrs.
from nondim_behavior_attrs, or dims.
property nondim_behavior_attrs
list of attrs in self which control behavior of self, but which are NOT in self.dimensions.
record_units(array)
return array.assign_attrs(self.units_meta()).
if array is not an xarray.DataArray, convert it first.
property u
the current units manager for self.
if not yet initialized, getting self.u will create (and store) a new UnitsManager().
property units
the current unit system for self. E.g., ‘si’. (this is an alias to self.u.units)
units_meta()
return dict(units=self.units). Also include coords_units if different.