erTabInputManager

class PlasmaCalcs.mhd.mhd_er_tables.erTabInputManager(filename, *, u=None, ionize_ev='physical', **kw_super)

Bases: DictlikeFromKeysAndGetitem, UnitsHaver

manages 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: str
path 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 file
RhoEiRadTableFile: str, path to radiation table file
nRhoBin: int, number of bins for r (mass density)
RhoMin, RhoMax: numbers, r [cgs units] for smallest and largest bins
nEiBin: int, number of bins for eperm (internal energy per unit mass)
EiMin, EiMax: numbers, eperm [cgs units] for smallest and largest bins
nRadBins: 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 UnitsManager
used 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 dict
first 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.

get_eperm_coords()

return eperm coords in 'raw' units.

get_r_coords()

return r coords in 'raw' units.

init_tables()

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()).

units_meta()

return dict(units=self.units).

values()

return tuple of values corresponding to self.keys().

Attributes

behavior

dict of {attr: self.attr} for attr in self.behavior_attrs.

behavior_attrs

list of attrs in self which control behavior of self.

cls_behavior_attrs

dirname

directory containing tabinputfile.

eosfile

filepath to eos table file.

extrapolate_kind

extrapolate_kind for all tables in self.

n_radbins

return number of radbins in self.

nondim_behavior_attrs

list of attrs in self which control behavior of self, but which are NOT in self.dimensions.

radfile

filepath to radiation table file.

u

the current units manager for self.

units

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 = value
sets 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 iterable
if 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: bool
False –> 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 erTableManager
to 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 dict
first 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: bool
whether 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().