UnitsHaver
- class PlasmaCalcs.units.units_haver.UnitsHaver(u=None, units=None, **kw_super)
Bases:
BehaviorHaverhas some unit-related methods. self.u manages the actual units.
u: None or UnitsManager
manages the units.if not None, set self.u = uunits: None or strthe current default unit system for outputs. E.g. ‘si’ or ‘raw’.if not None, set self.units = units.self.units aliases to self.u.units.i.e., setting self.units sets self.u.units; getting self.units gets self.u.units.Methods
get_behavior([keys])return value of self.behavior.
record_units(array)return array.assign_attrs(self.units_meta()).
return dict(units=self.units).
Attributes
dict of {attr: self.attr} for attr in self.behavior_attrs.
list of attrs in self which control behavior of self.
cls_behavior_attrslist of attrs in self which control behavior of self, but which are NOT in self.dimensions.
the current units manager for self.
the current unit system for self.
- 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.
- get_behavior(keys=None)
return value of self.behavior.
keys: None or iterableif 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).