DimensionSingleValueSpecifier

class PlasmaCalcs.dimensions.dimension_tools.dimension_value.DimensionSingleValueSpecifier(getter, checker, *args_super, **kw_super)

Bases: DimensionSpecialValueSpecifier

DimensionSpecialValueSpecifier which includes checker, to check if single value matches.

getter gets appropriate single value from list.
checker checks if value is a match for this specifier.
e.g. fluids.py defines ELECTRON,
with getter calling FluidList.get_electron,
and checker calling Fluid.is_electron().
getter: str or callable
self specifies to use the dimension value(s): self.getter(dlist)
callable –> callable of 1 arg; will be passed dlist.
str –> use dlist.{getter}(). E.g. getter=’get_ion’ –> use dlist.get_ion().
internally stored at self.init_getter.
checker: str or callable
when checking value==self (or self==value): use self.checker(value)
callable –> callable of 1 arg; will be passed value.
str –> use value.{checker}(). E.g. checker=’is_electron’ –> use value.is_electron().
internally stored at self.init_checker.
iseler: None, str, or callable
if provided, can use self in calls to PlasmaCalcs’ xarray_isel and xarray_sel,
commonly via array.pc.sel(dim=self) or array.pc.isel(dim=self).
callable –> callable of 1 arg; will be passed list of coord values for dim,
(probably a list of DimensionValue objects, maybe converted to DimensionValueList).
must return index (or indexes) appropriate for xarray.isel.
str –> use dlist.{iseler}(), where dlist=isel_cls(list of coord values for dim).
E.g. iseler=’i_ions’, isel_cls=FluidList –> use FluidList(values).i_ions().
internally stored at self.init_iseler.
isel_cls: None or type
if provided, iseler calls use iseler(isel_cls(list of coord values for dim)),
else, iseler calls use iseler(list of coord values for dim).

Methods

_checker_as_str()

returns str representation of self.checker.

_checker_from_str(value)

check if value is a match for str self.checker.

_getter_as_str()

returns str representation of self.getter.

_getter_from_str(dlist)

get the value from dlist specified by str self.getter.

_iseler_as_str()

returns str representation of self.iseler.

_iseler_from_str(dvals)

get the indexes from dlist specified by str self.iseler.

_iseler_when_none(dvals)

crash, because self was passed to xarray_isel or xarray_sel but self.iseler is None.

_repr_contents()

contents for repr; used by __repr__.

_checker_as_str()

returns str representation of self.checker.

Use self.init_checker if it exists, else self.checker if it exists, else ‘UNKNOWN_CHECKER’.
_checker_from_str(value)

check if value is a match for str self.checker.

_getter_as_str()

returns str representation of self.getter.

Use self.init_getter if it exists, else self.getter if it exists, else ‘UNKNOWN_GETTER’.
_getter_from_str(dlist)

get the value from dlist specified by str self.getter.

_iseler_as_str()

returns str representation of self.iseler.

Use self.init_iseler if it exists, else self.iseler if it exists, else ‘UNKNOWN_ISELER’.
_iseler_from_str(dvals)

get the indexes from dlist specified by str self.iseler.

_iseler_when_none(dvals)

crash, because self was passed to xarray_isel or xarray_sel but self.iseler is None.

_repr_contents()

contents for repr; used by __repr__.