FluidsHaver

class PlasmaCalcs.dimensions.fluids.FluidsHaver(*, fluid=None, fluids=None, **kw)

Bases: FluidHaver, jFluidHaver

class which “has” a FluidDimension and a jFluidDimension.

Most FluidHavers will probably be better off as FluidsHavers,
since having a jFluid enables to calculate stuff like collision frequencies.

Methods

__init_subclass__(*[, dimension, dim_plural])

called when subclassing DimensionHaver; sets some useful attributes related to dimension.

__setup_haver__(dim_cls, **kw_super)

called by dim_cls.setup_haver(cls) when setting up cls so that it "has" dim_cls dimension.

as_single_dimpoint([values, dims])

return DimPoint with values for dims, but raise DimensionValueError if any value is_iterable_dim.

assign_dim_coords(array, *dims[, skip])

assign all dimensions in self as coords for array.

check_pickle([x])

checks that self (or, x, if provided) is pickleable, by pickling then unpickling.

current_n_dimpoints([dims])

return number of points represented by current values of dims.

dim_values([dims])

return dict of current values for dimensions in self.

dims_apply(funcname, *args_func[, dims])

apply funcname to each dimension in self, with args_func and kw_func.

dims_get(attr[, dims])

return dict of {dim: getattr(self.dimensions[dim], attr) for dim in dims}.

enumerate_dimpoints([dims, all])

iterate through values of dims, yielding (idx, DimPoint) pairs.

get_behavior([keys])

return value of self.behavior.

get_first_dimpoint([dims, enumerate])

return DimPoint taking the first value of each dim in self.dimensions.

get_ncpu()

returns ncpu, but if None, return multiprocessing.cpu_count() instead.

get_neutral([var])

returns self(var), but for the neutral fluid.

getj(var, *args__get[, jfluid])

returns self(var), but for jfluid instead of fluid.

iter_dimpoints([dims, all, restore, enumerate])

iterate through values of dims, returning DimPoints and setting dim values during iteration.

load_across_dims(loader, *args_loader[, ...])

return loader(...), iterating & joining across each dimension.

load_across_dims_implied_by(var, loader, ...)

return loader(...), iterating & joining across each dimension implied by var.

maintaining_attrs(*attrs, **attrs_as_flags)

returns context manager which restores attrs of self to their original values, upon exit.

pop_dim_keys(kw)

return ({key: kw.pop(key) for key in self.dimensions if key in kw}, kw).

set_attrs(**attrs)

sets these attrs in self.

set_pop_dim_attrs(kw)

set self.{key} = kw.pop(key) for each key in self.dimensions if key in kw.

using_attrs([attrs_as_dict, _unset_sentinel])

returns context manager which sets attrs of obj upon entry; restores original values upon exit.

using_first_dimpoint([dims])

return context manager which sets dimensions to their first values (when called); restore original on exit.

_as_single_fluid_or_jfluid(fluid_or_jfluid)

return the single fluid or jfluid corresponding to this input.

_as_single_jfluid_or_fluid(jfluid_or_fluid)

return the single jfluid or fluid corresponding to this input.

_assert_fluid_has_no_electron()

assert that there are currently no electrons in self.fluid.

_call_loader0_at_dimpoint(dimpoint, loader0, ...)

return self._call_loader_at_dimpoint(dimpoint, loader0, ...).

_call_loader_at_dimpoint(dimpoint, loader, ...)

with self.using(**dimpoint): return loader(*args_loader, **kw_loader)

_default_ncoarse()

return default for ncoarse during self.load_across_dims.

_default_ncpu()

return default for ncpu during self.load_across_dims.

_default_print_freq()

returns default for print_freq.

_default_timeout()

return default for timeout during self.load_across_dims.

_get_dimensions_dict()

return dict of dimensions in self; {dimension name: Dimension object}

_get_fluid_or_jfluid_like(aliases, *[, ...])

return the fluid or jfluid corresponding to any of the aliases here.

_load_across_dims_postprocess(arrs, dims, *, ...)

postprocessing results from load_across_dims, after all tasks have been completed.

_load_across_dims_postprocess__arrs_to_nparr(...)

returns single numpy array (with the data from arrs, which is an array of arrays).

_load_across_dims_postprocess__broadcast_shapes(...)

handles array broadcasting for _load_across_dims_postprocess.

_repr_contents()

return list of contents to go in repr of self.

_special_dims_shifters(dimnames, _shift_special)

return (dict for self.using(...), dict for result.isel(...)) to _shift_special_dims.

Attributes

array_MBmax

UNSET, None, or number

assign_fluid_along

alias to self.fluid_dim.assign_coord_along

assign_fluid_coord

alias to self.fluid_dim.assign_coord

assign_jfluid_along

alias to self.jfluid_dim.assign_coord_along

assign_jfluid_coord

alias to self.jfluid_dim.assign_coord

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

current_n_fluid

alias to self.fluid_dim.current_n

current_n_jfluid

alias to self.jfluid_dim.current_n

dimensions

dict of dimensions in self; {dimension name: Dimension object}.

dims

return dict of current values for dimensions in self.

enumerate_fluid

alias to self.fluid_dim.enumerate

enumerate_fluids

alias to self.fluid_dim.enumerate_values

enumerate_jfluid

alias to self.jfluid_dim.enumerate

enumerate_jfluids

alias to self.jfluid_dim.enumerate_values

fluid

alias to self.fluid_dim.v

fluid_array_equals

alias to self.fluid_dim.array_equals

fluid_dim

fluid dimension for FluidHaver.

fluid_is_iterable

alias to self.fluid_dim.is_iterable

fluid_list

alias to self.fluid_dim.list

fluid_type

alias to self.fluid_dim.get_type

fluids

alias to self.fluid_dim.values

iter_fluid

alias to self.fluid_dim.iter

iter_fluids

alias to self.fluid_dim.iter_values

iter_fluids_partition

alias to self.fluid_dim.iter_partition

iter_jfluid

alias to self.jfluid_dim.iter

iter_jfluids

alias to self.jfluid_dim.iter_values

iter_jfluids_partition

alias to self.jfluid_dim.iter_partition

jfluid

alias to self.jfluid_dim.v

jfluid_array_equals

alias to self.jfluid_dim.array_equals

jfluid_dim

jfluid dimension for jFluidHaver.

jfluid_is_iterable

alias to self.jfluid_dim.is_iterable

jfluid_list

alias to self.jfluid_dim.list

jfluid_type

alias to self.jfluid_dim.get_type

jfluids

alias to self.jfluid_dim.values

join_fluids

alias to self.fluid_dim.join_along

join_jfluids

alias to self.jfluid_dim.join_along

maintaining

alias to maintaining_attrs

ncoarse

int

ncpu

None or int

nondim_behavior_attrs

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

print_freq

None, or number (possibly negative or 0)

print_freq_explicit

like self.print_freq, but converts UNSET to value based on self.verbose,

take_fluid

alias to self.fluid_dim.take

take_fluids

alias to self.fluid_dim.take_along

take_jfluid

alias to self.jfluid_dim.take

take_jfluids

alias to self.jfluid_dim.take_along

timeout

None or int

using

alias to using_attrs

classmethod __init_subclass__(*, dimension=None, dim_plural=None, **kw_super)

called when subclassing DimensionHaver; sets some useful attributes related to dimension.

dimension: str or None

name of dimension associated with this subclass.
if None, no particular dimension associated with this subclass.
dim_plural: str or None
plural form of dimension. if None, use str(dimension)+’s’.
Sets various attributes in cls:
cls._dimension = dimension,
cls._dim_plural = dim_plural,
cls._dim_types = dict of all {dimension name: Dimension subclass} from cls and cls.__bases__
(note - connecting self._dimension to this dict is not handled here;
it is handled by __setup_haver__ called by Dimension.setup_haver)
classmethod __setup_haver__(dim_cls, **kw_super)

called by dim_cls.setup_haver(cls) when setting up cls so that it “has” dim_cls dimension.

_as_single_fluid_or_jfluid(fluid_or_jfluid)

return the single fluid or jfluid corresponding to this input.

fluid_or_jfluid: Fluid, str, int, or other fluid specifier
attempts self._as_single_fluid(fluid_or_jfluid).
if FluidKeyError, do self._as_single_jfluid(fluid_or_jfluid) instead.
(if both fail, raise FluidKeyError.)
(similar to _as_single_jfluid_or_fluid, but here looks in self.fluids first.)
_as_single_jfluid_or_fluid(jfluid_or_fluid)

return the single jfluid or fluid corresponding to this input.

jfluid_or_fluid: Fluid, str, int, or other fluid specifier
attempts self._as_single_jfluid(jfluid_or_fluid).
if FluidKeyError, do self._as_single_fluid(jfluid_or_fluid) instead.
(if both fail, raise FluidKeyError.)
(similar to _as_single_fluid_or_jfluid, but here looks in self.jfluids first.)
_assert_fluid_has_no_electron()

assert that there are currently no electrons in self.fluid.

_call_loader0_at_dimpoint(dimpoint, loader0, args_loader, *, nload, MBmax, **kw_loader)

return self._call_loader_at_dimpoint(dimpoint, loader0, …).

Also does memory size check based on nload and MBmax.
intended for internal use only, inside load_across_dims.
arr0 is handled differently from other arrays in order to do some checks.
_call_loader_at_dimpoint(dimpoint, loader, args_loader, **kw_loader)

with self.using(**dimpoint): return loader(*args_loader, **kw_loader)

_default_ncoarse()

return default for ncoarse during self.load_across_dims. returns DEFAULTS.LOADING_NCOARSE

_default_ncpu()

return default for ncpu during self.load_across_dims. returns DEFAULTS.LOADING_NCPU

_default_print_freq()

returns default for print_freq. Here, returns UNSET; i.e., infer from self.verbose.

(See self.print_freq_explicit to get the actual value of print_freq.)
_default_timeout()

return default for timeout during self.load_across_dims. returns DEFAULTS.LOADING_TIMEOUT

_get_dimensions_dict()

return dict of dimensions in self; {dimension name: Dimension object}

_get_fluid_or_jfluid_like(aliases, *, as_list=False, check_first='fluids')

return the fluid or jfluid corresponding to any of the aliases here.

aliases: list of str, int, Fluid, or other fluid specifier.
each alias will be checked in self.fluids and self.jfluid.
if any single alias refers to multiple fluids (e.g., is a slice), add all of them.
as_list: bool
whether to return list in case of 0 or 2+ matches.
False –> crash. FluidKeyError if 0 matches; FluidValueError if 2+ matches.
check_first: ‘fluids’ or ‘jfluids’
which to check first: ‘fluids’ or ‘jfluids’.
_load_across_dims_postprocess(arrs, dims, *, it_dimnames, assign_coords, isel=None)

postprocessing results from load_across_dims, after all tasks have been completed.

i.e., after all arrays have been loaded, join them all together.
_load_across_dims_postprocess__arrs_to_nparr(arr0, arrs)

returns single numpy array (with the data from arrs, which is an array of arrays).

_load_across_dims_postprocess__broadcast_shapes(arr0, arrs, it_dimnames)

handles array broadcasting for _load_across_dims_postprocess.

returns (arr0, arrs), but with all arrs having the same shape as arr0. Crash if not possible.
CAUTION: may edit arrs in-place.
(Won’t edit individual arrays’ data; just arrs which contains the arrays.)
NOTE: arr0 in result isn’t necessarily arrs.flat[0].
arr0 in result is the “model array”, used to model coords & dims on.
arr0 = first DataArray with size == max(size) across all arrays.
E.g. if array shapes are [(), (), (7,1), (1,3), (7,3), (7,3) ()],
then use arr0 = the first DataArray with shape (7,3).
if neither array with shape (7,3) is a DataArray (i.e., has coords…)
then crash instead (because we can’t properly assign coords to result.)
it_dimnames: list of names of iterable dimensions; sometimes included in error message.
_repr_contents()

return list of contents to go in repr of self.

_special_dims_shifters(dimnames, _shift_special)

return (dict for self.using(…), dict for result.isel(…)) to _shift_special_dims.

See docs of load_across_dims for more details.
property array_MBmax

UNSET, None, or number

maximum result size allowed, in Megabytes.
will raise a MemorySizeError if result size would be larger than this.
UNSET –> use DEFAULTS.ARRAY_MBYTES_MAX (default: 1000 MB).
None –> no limit.
Assumes that each result (at each dimpoint) will be the same size.
as_single_dimpoint(values=None, *, dims=None, **values_as_kw)

return DimPoint with values for dims, but raise DimensionValueError if any value is_iterable_dim.

values: None or dict
values to use for the dimpoint.
values will be joined with **values_as_kw; provided any of either will be equivalent.
E.g. can use values={‘fluid’: ‘e’} or use fluid=’e’.
if any are provided –> use values corresponding to self.{dim}=values[dim] for dim in dims.
else –> use values of self.{dim} for dim in dims. (equivalent: self.dims_apply(‘_as_single’, dims=dims))
dims: None or iterable of strs appearing in self.dimensions.keys()
dimensions to include.
None –> infer dimensions from keys of values (and values_as_kw).
if no values were provided (values=None, and empty values_as_kw),
use all dimensions from self.dimensions.keys().
additional kwargs provide other {dim: value} items.
Examples:
self.as_single_dimpoint() –> DimPoint({dim: self.{dim} for dim in self.dimensions})
self.as_single_dimpoint({‘fluid’: ‘e’}) –> DimPoint({‘fluid’: ‘e’})
self.as_single_dimpoint(fluid=’e’) –> DimPoint({‘fluid’: ‘e’})
self.as_single_dimpoint({‘fluid’: ‘e’}, snap=0) –> DimPoint({‘fluid’: ‘e’, ‘snap’: 0})
self.as_single_dimpoint(dims=[‘fluid’, ‘snap’]) –> DimPoint({‘fluid’: self.fluid, ‘snap’: self.snap})
assign_dim_coords(array, *dims, skip=[])

assign all dimensions in self as coords for array. (self.assign_{dim}_coord(array))

Assumes array is an xarray and does not have any dimensions in self.
(array is not edited directly; returns result of assigning coords.)
dims: iterable of dimensions in self
assign only these dimensions as coords. (use all dimensions if len(dims)==0)
skip: iterable of dimensions in self
do not assign these dimensions as coords.
property assign_fluid_along

alias to self.fluid_dim.assign_coord_along

property assign_fluid_coord

alias to self.fluid_dim.assign_coord

property assign_jfluid_along

alias to self.jfluid_dim.assign_coord_along

property assign_jfluid_coord

alias to self.jfluid_dim.assign_coord

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.
check_pickle(x=None)

checks that self (or, x, if provided) is pickleable, by pickling then unpickling.

Returns result of unpickling. Useful for debugging.
current_n_dimpoints(dims=None)

return number of points represented by current values of dims.

dims: None or iterable of strs appearing in self.dimensions.keys()
dimensions to consider. None –> use all dimensions.
E.g. current_n_dimpoints(self, dims=[‘fluid’, ‘snap’]) –> number of (fluid, snap) points;
e.g. 3 fluids and 2 snaps –> 6 points.
Note, for classes using maindims, maindims are not included in the number of dimpoints.
Equivalent to len(list(self.iter_dimpoints(dims=dims, current=True)))
property current_n_fluid

alias to self.fluid_dim.current_n

property current_n_jfluid

alias to self.jfluid_dim.current_n

dim_values(dims=None)

return dict of current values for dimensions in self.

dims: None or iterable
if provided, only include these dimensions.
Equivalent: DimRegion(self.dims_get(‘v’, dims=dims))
property dimensions

dict of dimensions in self; {dimension name: Dimension object}.

e.g. {‘fluid’: self.fluid_dim, ‘snap’: self.snap_dim, …}.
property dims

return dict of current values for dimensions in self. Equivalent: self.dim_values()

dims_apply(funcname, *args_func, dims=None, **kw_func)

apply funcname to each dimension in self, with args_func and kw_func.

dims: None or iterable of strs
if provided, only apply to these dimensions.
See also: dims_get
dims_get(attr, dims=None)

return dict of {dim: getattr(self.dimensions[dim], attr) for dim in dims}.

dims: None or iterable
if provided, only include these dimensions.
See also: dims_apply
enumerate_dimpoints(dims=None, *, all=False)

iterate through values of dims, yielding (idx, DimPoint) pairs.

idx is a dict of {dim: i} such that DimPoint values are {dim: dims[i] for dim,i in idx.items()}.
Also, during iteration, set self.{dim} = value, as with self.iter_dim.
Equivalent to self.iter_dimpoints(dims=dims, all=all, enumerate=True)
property enumerate_fluid

alias to self.fluid_dim.enumerate

property enumerate_fluids

alias to self.fluid_dim.enumerate_values

property enumerate_jfluid

alias to self.jfluid_dim.enumerate

property enumerate_jfluids

alias to self.jfluid_dim.enumerate_values

property fluid

alias to self.fluid_dim.v

property fluid_array_equals

alias to self.fluid_dim.array_equals

property fluid_dim

fluid dimension for FluidHaver.

fluid_dim_cls

alias of FluidDimension

property fluid_is_iterable

alias to self.fluid_dim.is_iterable

property fluid_list

alias to self.fluid_dim.list

property fluid_type

alias to self.fluid_dim.get_type

property fluids

alias to self.fluid_dim.values

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_first_dimpoint(dims=None, *, enumerate=False)

return DimPoint taking the first value of each dim in self.dimensions.

dims: None or iterable of strs appearing in self.dimensions.keys()
dimensions to include. None –> use all dimensions.
enumerate: bool
whether to return (idx, DimPoint) instead of just DimPoint.
get_ncpu()

returns ncpu, but if None, return multiprocessing.cpu_count() instead.

(This is for convenience; using None will also work with any methods defined here.)
get_neutral(var=None, *args__get, **kw__get)

returns self(var), but for the neutral fluid.

if var is None, instead returns the neutral fluid itself.
if there is exactly 1 neutral fluid in self.fluids, returns self(var, fluid=neutral_fluid).
otherwise, if there is exactly 1 in self.jfluids, returns self.getj(var, jfluid=neutral_fluid).
otherwise (0 or 2+ neutral fluids), crash:
if 0 neutral fluids anywhere, raise FluidKeyError.
if 2+ neutral fluids, raise FluidValueError.
getj(var, *args__get, jfluid=UNSET, **kw__get)

returns self(var), but for jfluid instead of fluid.

jfluid: UNSET, None, or any jfluid specifier.
if provided, use this instead of self.jfluid.
Example:
m_s = self(‘m’)
with self.using(fluids=self.jfluids, fluid=self.jfluid):
m_j_0 = self(‘m’)
m_j_1 = self.getj(‘m’)
here, the values stored in the variables will be:
m_s = mass of self.fluid
m_j_0 = mass of self.jfluid. But, fluid dimension will be labeled ‘fluid’
m_j_1 = mass of self.jfluid. fluid dimension will be labeled ‘jfluid’.
additional args and kwargs are passed to self(var)
iter_dimpoints(dims=None, *, all=False, restore=True, enumerate=False)

iterate through values of dims, returning DimPoints and setting dim values during iteration.

DimPoints are dicts of {dim: value} for dim in dims, where not is_iterable_dim(value).
Also, during iteration, set self.{dim} = value, as with self.iter_dim.
dims: None or iterable of strs appearing in self.dimensions.keys()
dimensions to consider. None –> use all dimensions.
all: bool
whether to iterate through all possible values, or only the current values.
False –> iterate through current values (e.g., self.snap, self.fluid, …).
similar to itertools.product(self.iter_snap(), self.iter_fluid(), …)
True –> iterate through all possible values (e.g., self.snaps, self.fluid, …)
similar to itertools.product(self.iter_snaps(), self.iter_fluids(), …)
Equivalent to all=False if all dims are set to None, e.g. self.snap=None, …
restore: bool
whether to restore original dim values after iteration.
enumerate: bool, default False
whether to yield indices too, i.e. (idx, DimPoint) instead of just DimPoint.
idx would be a dict of {dim: i} such that DimPoint values are {dim: dims[i] for dim,i in idx.items()}.
property iter_fluid

alias to self.fluid_dim.iter

property iter_fluids

alias to self.fluid_dim.iter_values

property iter_fluids_partition

alias to self.fluid_dim.iter_partition

property iter_jfluid

alias to self.jfluid_dim.iter

property iter_jfluids

alias to self.jfluid_dim.iter_values

property iter_jfluids_partition

alias to self.jfluid_dim.iter_partition

property jfluid

alias to self.jfluid_dim.v

property jfluid_array_equals

alias to self.jfluid_dim.array_equals

property jfluid_dim

jfluid dimension for jFluidHaver.

jfluid_dim_cls

alias of jFluidDimension

property jfluid_is_iterable

alias to self.jfluid_dim.is_iterable

property jfluid_list

alias to self.jfluid_dim.list

property jfluid_type

alias to self.jfluid_dim.get_type

property jfluids

alias to self.jfluid_dim.values

property join_fluids

alias to self.fluid_dim.join_along

property join_jfluids

alias to self.jfluid_dim.join_along

load_across_dims(loader, *args_loader, dims=[], assign_coords=None, loader0=None, _shift_special={}, **kw_loader)

return loader(…), iterating & joining across each dimension.

loader: callable of (*args_loader, **kw_loader) -> xarray.DataArray.

will call loader to get result values at each combination of dims values in self.
(loader will probably depend on dims values from self.)
dims: iterable of strs or Dimension objects
load across these Dimensions.
loads across the current values (when this method was called) of each dimension,
not necessarily “all” values. (e.g., self.snap, not self.snaps)
str values –> use self.dimensions[d] (where d is a str in dims).
len(dims)==0 –> just return loader(var, *args_loader, **kw_loader).
While loading, set dim.loading=True for each dim.
assign_coords: None or bool, default None
whether to dim.assign_coord for each result of loader, for each dimension.
None –> assign coord only if dim.name not already in array.coords.
loader0: None or callable
if provided, use loader0 to get the first array, then use loader for the rest.
Internally the first array’s .coords and .attrs are used to label the result;
however all other arrays do not need to be converted to xarray.
_shift_special: UNSET or dict of (dimstr: list of special values)
workaround to encourage loader0 to be called on a “usual” case, not a special case.
if provided, and dimstr in dims, and d=self.dimensions[dimstr] has multiple values,
with special_value first, and at least one non-special value later, then
internally rearrange dim values order before loading,
then rearrange result back to original order (via indexing).
E.g. _shift_special=dict(snap=[INPUT_SNAP]) –> apply loader0 to the first non-INPUT_SNAP,
if there are any non-INPUT_SNAP snap values in snap, and ‘snap’ in dims.
— MULTIPROCESSING STRATEGY OPTIONS (from self) —
timeout: None or int
max duration, in seconds. Must be None or integer (due to limitations of signal.alarm method)
None –> no time limit.
Note: if time_limit is reached, will raise a TimeoutError and save the result so far.
(in this case, any not-yet-calculated values will each be RESULT_MISSING.)
# [TODO] make this happen, without making self un-picklable:
in case of crash, results so far can be found in self._latest_load_tasks.
Then possibly continued via:
results = self._latest_load_tasks(…, reset=False, skip_done=True)
result = self._load_across_dims_postprocess(results, dims, …)
# [TODO] if crashing and resuming is common, make that easier to do^
if self.timeout has not been set, use DEFAULTS.LOADING_TIMEOUT (default: None).
ncpu: None or int
max number of cpus to use for multiprocessing.
None –> use multiprocessing.cpu_count()
int –> use this value. if 0 or 1, do not use multiprocessing here.
Note: will actually use min(ncpu, number of calls to be made);
e.g. if ncpu=4 but len(arg_kw_tuples)=2, will only use 2 cpus.
if self.ncpu has not been set, use DEFAULTS.LOADING_NCPU (default: 1).
ncoarse: int
if >1, group tasks into groups of size ncoarse before performing them.
if self.ncoarse has not been set, use DEFAULTS.LOADING_NCOARSE (default: 1).
print_freq: None, or number (possibly negative or 0)
>0 –> Minimum number of seconds between progress updates.
=0 –> print every progress update.
<0 –> never print progress updates.
None –> use DEFAULTS.PROGRESS_UPDATES_PRINT_FREQ
if self.print_freq has not been set, infer from self.verbose if it exists,
else use DEFAULTS.PROGRESS_UPDATES_PRINT_FREQ (default: 2).
additional args & kwargs are passed as loader(*args_loader, **kw_loader).
load_across_dims_implied_by(var, loader, *args_loader, assign_coords=None, _min_split=1, **kw_loader)

return loader(…), iterating & joining across each dimension implied by var.

Equivalent to self.load_across_dims(loader, …, dims=self.match_var_loading_dims(var)).
var: str
variable which implies dims to load across, via self.match_var_loading_dims(var).
loader: callable of (*args_loader, **kw_loader) -> xarray.DataArray.
will call loader to get result values at each combination of dims values in self.
(loader will probably depend on dims values from self.)
assign_coords: None or bool, default None
whether to dim.assign_coord for each result of loader, for each dimension.
None –> assign coord only if dim.name not already in array.coords.
_min_split: int, default 1
if an implied dim has current_n() < min_split, don’t load across it.
1 –> no minimum.
additional args & kwargs are passed as loader(*args_loader, **kw_loader).
property maintaining

alias to maintaining_attrs

maintaining_attrs(*attrs, **attrs_as_flags)

returns context manager which restores attrs of self to their original values, upon exit.

E.g. maintaining_attrs(obj, ‘attr1’, ‘attr2’, attr3=True, attr4=False)
–> will restore upon exit, original values of obj.attr1, attr2, and attr3, but not attr4.
property ncoarse

int

if >1, group tasks into groups of size ncoarse before performing them.
property ncpu

None or int

max number of cpus to use for multiprocessing.
None –> use multiprocessing.cpu_count()
int –> use this value. if 0 or 1, do not use multiprocessing here.
Note: will actually use min(ncpu, number of calls to be made);
e.g. if ncpu=4 but len(arg_kw_tuples)=2, will only use 2 cpus.
see also: self.get_ncpu() to read actual number of cpus when self.ncpu is None.
property nondim_behavior_attrs

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

pop_dim_keys(kw)

return ({key: kw.pop(key) for key in self.dimensions if key in kw}, kw).

property print_freq

None, or number (possibly negative or 0)

>0 –> Minimum number of seconds between progress updates.
=0 –> print every progress update.
<0 –> never print progress updates.
None –> use DEFAULTS.PROGRESS_UPDATES_PRINT_FREQ
property print_freq_explicit

like self.print_freq, but converts UNSET to value based on self.verbose,

UNSET –> result depends on self.verbose:
False or <=0 –> -1
True or (>=1 and <5) –> None
>=5 –> 0 (i.e. print every progress update)
if self.verbose doesn’t exist –> None
if result would be None, instead give DEFAULTS.PROGRESS_UPDATES_PRINT_FREQ.
set_attrs(**attrs)

sets these attrs in self.

set_pop_dim_attrs(kw)

set self.{key} = kw.pop(key) for each key in self.dimensions if key in kw.

property take_fluid

alias to self.fluid_dim.take

property take_fluids

alias to self.fluid_dim.take_along

property take_jfluid

alias to self.jfluid_dim.take

property take_jfluids

alias to self.jfluid_dim.take_along

property timeout

None or int

max duration, in seconds. Must be None or integer (due to limitations of signal.alarm method)
None –> no time limit.
Note: if time_limit is reached, will raise a TimeoutError and save the result so far.
(in this case, any not-yet-calculated values will each be RESULT_MISSING.)
property using

alias to using_attrs

using_attrs(attrs_as_dict={}, _unset_sentinel=ATTR_UNSET, **attrs_and_values)

returns context manager which sets attrs of obj upon entry; restores original values upon exit.

_unset_sentinel: any value, default ATTR_UNSET
upon entry, delete any attrs with value _unset_sentinel (compared via ‘is’).
E.g. using_attrs(obj, _unset_sentinel=None, x=None) –> del obj.x upon entry.
using_first_dimpoint(dims=None)

return context manager which sets dimensions to their first values (when called); restore original on exit.

Useful for testing a single code at a single dimpoint without needing to set each dimension individually.
dims: None or iterable of strs appearing in self.dimensions.keys()
dimensions to include. None –> use all dimensions.