InputUnitsMapManager
- class PlasmaCalcs.units.input_units.InputUnitsMapManager(u=None, units=None, **kw_super)
Bases:
UnitsHavermanages units conversion maps when multiple different maps are possible.
For example, Gamera may have different UnitsID corresponding to different input units maps:‘EARTH’ –> InputUnitsMap(earth-specific output units system)‘heliosphere’ (maybe?) –> InputUnitsMap(…different units from above…)‘CODE’ –> InputUnitsMap(None, maps_to=’raw’) # CODE outputs are already self-consistent.Methods
get_behavior([keys])return value of self.behavior.
record_units(array)return array.assign_attrs(self.units_meta()).
u_from_input(var)return conversion factor from "input units" to self.units for var.
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_attrsthe current input units map being used by self.
the key to use for self.input_units_maps to get the current input units map.
input_units_mapslist 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 input_units_map
the current input units map being used by self.
- property input_units_map_key
the key to use for self.input_units_maps to get the current input units map.
For example, for gamera, this could be an alias to self.units_id,which tells the units system of the input data.
- 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().
- u_from_input(var)
return conversion factor from “input units” to self.units for var.
Example: if self.input_units_map = InputUnitsMap({‘B’: (‘b_field’, 1e-9), …})then self.u_from_input(‘B’) == 1e-9 * si_to_self_unitswhere si_to_self_units = self.u(‘b_field’, units=self.units, convert_from=’si’).Thus, multiplying ‘input’ B values (which are in ‘input units’ of [nT])by self.u_from_input(‘B’) will give values in self.units system.
- 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).