erTabInputManager
- class PlasmaCalcs.mhd.mhd_er_tables.erTabInputManager(filename, *, u=None, ionize_ev='physical', **kw_super)
Bases:
DictlikeFromKeysAndGetitem,UnitsHavermanages tables, based on tab input file.
All tables and table coords here are in ‘raw’ units.self is dict-like, with keys quantity names, values erTable objects.(alternatively, use self.tables for dict like self.)self.elements is an ElementList based on the elements info in tab input file.filename: strpath to tab input file, e.g. tab_param.in. Internally stored as abspath.This should be an idl-like file which includes params for tables:EOSTableFile: str, path to eos table fileRhoEiRadTableFile: str, path to radiation table filenRhoBin: int, number of bins for r (mass density)RhoMin, RhoMax: numbers, r [cgs units] for smallest and largest binsnEiBin: int, number of bins for eperm (internal energy per unit mass)EiMin, EiMax: numbers, eperm [cgs units] for smallest and largest binsnRadBins: int, number of radiation bins in the radiation tables.It should also include params for elements (each as a string separated by spaces):cel: elements names. Internally stored in title case (e.g. ‘H’, ‘He’).abund: abundances of elements: A(elem) = 12 + log10(n(elem) / n(H)).aweight: masses of elements [amu].u: None or UnitsManagerused to calculate scale_quants to convert to ‘raw’ units.None –> all scale quants will be 1.example: if this TabInputManager is associated with a BifrostCalculator,probably will have u = the BifrostUnitsManager from that BifrostCalculator.ionize_ev: str or dictfirst ionization potentials of elements [eV]. E.g., {‘H’: 13.6}.affects self.elements; irrelevant to tables.str –> use ElementList.DEFAULTS[‘ionize_ev’][ionize_ev]Methods
__iter__()raises TypeError; use .keys(), .values(), or .items() instead.
coarsen([step, dim])return self, isel'd with slice(None, None, step) along dim(s).
get(key[, default])return self[key].
get_behavior([keys])return value of self.behavior.
get_coords(*[, for_kw])return dict of eperm coords and r coords, in 'raw' units.
return eperm coords in 'raw' units.
return r coords in 'raw' units.
initialize self.tables and return result
isel([indexers])return new erTableManager containing the tables from self, but isel(...)'d.
items()return tuple of (key, value) pairs corresponding to self.keys() and self.values().
keys()return tuple of keys in self.
make_element_list(*[, ionize_ev, set])set & return self.elements = ElementList based on params in self.
record_units(array)return array.assign_attrs(self.units_meta()).
return dict(units=self.units).
values()return tuple of values corresponding to self.keys().
Attributes
dict of {attr: self.attr} for attr in self.behavior_attrs.
list of attrs in self which control behavior of self.
cls_behavior_attrsdirectory containing tabinputfile.
filepath to eos table file.
extrapolate_kind for all tables in self.
return number of radbins in self.
list of attrs in self which control behavior of self, but which are NOT in self.dimensions.
filepath to radiation table file.
the current units manager for self.
the current unit system for self.
- __iter__()
raises TypeError; use .keys(), .values(), or .items() instead.
- 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.
- coarsen(step=2, dim=None)
return self, isel’d with slice(None, None, step) along dim(s).
dim: None, ‘eperm’, or ‘r’.dim to coarsen along.None –> coarsen along both ‘eperm’ and ‘r’.
- property dirname
directory containing tabinputfile. Equivalent: os.path.dirname(self.filename)
- element_list_cls
alias of
ElementList
- property eosfile
filepath to eos table file.
- er_table_manager_cls
alias of
erTableManager
- property extrapolate_kind
extrapolate_kind for all tables in self.
self.extrapolate_kind tells a dict of {key: extrapolate_kind}.setting self.extrapolate_kind = valuesets self[key].extrapolate_kind = value for all tables in self.None or str specifying how to handle extrapolation when interp() is called.None –> use xarray’s default (makes crash or NaNs if extrapolation needed).‘constant’ –> use nearest neighbor value when extrapolating.
- get(key, default=UNSET)
return self[key]. if default is provided and self[key] doesn’t exist, return default.
- get_behavior(keys=None)
return value of self.behavior.
keys: None or iterableif provided, only include these attrs.from nondim_behavior_attrs, or dims.
- get_coords(*, for_kw=False)
return dict of eperm coords and r coords, in ‘raw’ units.
Assumes params from paramfile are in cgs units.for_kw: boolFalse –> result keys are ‘eperm’, ‘r’.True –> result keys are ‘epermcoords’, ‘rcoords’.
- get_eperm_coords()
return eperm coords in ‘raw’ units. Assumes params from paramfile are in cgs units.
- get_r_coords()
return r coords in ‘raw’ units. Assumes params from paramfile are in cgs units.
- init_tables()
initialize self.tables and return result
- isel(indexers=None, **kw_isel)
return new erTableManager containing the tables from self, but isel(…)’d.
Does not return an erTabInputManager instance; it isn’t directly connected to inputs anymore.E.g., didn’t do the work to adjust get_r_coords() results accordingly.(eventually might return erTabInputManger, but for now using erTableManagerto ensure we crash before ever returning any misleading results.)
- items()
return tuple of (key, value) pairs corresponding to self.keys() and self.values().
- keys()
return tuple of keys in self.
- make_element_list(*, ionize_ev=None, set=True)
set & return self.elements = ElementList based on params in self.
ionize_ev: None, str, or dictfirst ionization potentials of elements [eV]. E.g., {‘H’: 13.6}.str –> use ElementList.DEFAULTS[‘ionize_ev’][ionize_ev]None –> use self.tabin.ionize_ev (default: ‘physical’)set: boolwhether to set self.elements to the result. Default True.
- property n_radbins
return number of radbins in self.
- property nondim_behavior_attrs
list of attrs in self which control behavior of self, but which are NOT in self.dimensions.
- property radfile
filepath to radiation table file.
- 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).
- values()
return tuple of values corresponding to self.keys().