EppicCalculator

class PlasmaCalcs.hookups.eppic.eppic_calculator.EppicCalculator(input_deck, *, snaps_from='parallel', u=None, u_l=None, u_t=None, u_n=None, ne_si=None, kw_units={}, quasineutral=None, _more_init_checks=False, **kw_super)

Bases: EppicBasesLoader, EppicMomentsLoader, EppicRuntimeInfoLoader, EppicSimInfoLoader, EppicSubsamplable, EppicDirectLoader, EppicPlotterManager, EppicAddonQuantityLoader, MultifluidPlasmaCalculator

PlasmaCalculator for Eppic outputs.

To initialize from an eppic.i file, use EppicCalculator.from_here().
Use EppicCalculator.help() for more help.
input_deck: EppicInputDeck
the EppicInputDeck which is being used by this calculator.
snaps_from: ‘parallel’ or ‘timers’
how to determine existing snaps.
‘parallel’ –> from files in directory ‘parallel’ (located adjacent to ‘eppic.i’)
‘timers’ –> from data in ‘domain000/timers.dat’ (‘domain000’ adjacent to ‘eppic.i’)
u: None or UnitsManager
if provided, set self.u = u, and ignore u_l, u_t, u_n, and ne_si.
u_l, u_t, u_n, ne_si: None or value
must provide one of these values in order to fully determine the units.
u_l: length [si] = u_l * length [raw]
u_t: time [si] = u_t * time [raw]
u_n: number density [si] = u_n * number density [raw]
ne_si: electron number density [si]. (ne [raw] will be loaded from input_deck)
kw_units: dict
any additional values used to determine the units.
can also provide u_l, u_t, u_n, or ne_si, here, instead of as direct kwarg.
See help(UnitsManagerPIC.from_pic) for more details.
quasineutral: None or bool
if provided, set self.quasineutral.
otherwise, infer it from self.input_deck.is_quasineutral().
in quasineutral mode, distribution 0 is assumed to be electrons,
and different routines are used to calculate its density & other parameters.
_more_init_checks: bool, default False
if True, perform additional checks during initialization.
False by default for slight efficiency improvement,
and to avoid possibility of init checks failing but object still being usable.
other kwargs are passed to super().__init__.

Methods

__call__(var, *args[, name, item, verbose])

returns value of var from self.

__getitem__(snapi)

sets self.snap, then returns self.

__getstate__()

return state for pickling.

__init_subclass__(*[, dimension, dim_plural])

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

__iter__()

equivalent to self.iter_snaps()

__len__()

equivalent to len(self.snaps)

__setstate__(state)

set state for pickling.

__setup_haver__(dim_cls, **kw_super)

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

angle_xy(A)

return angle between +xhat and A, in the xy plane, in radians.

angle_xy_to_hat(A)

return unit vector u, given angle [radians] between +xhat and u in the xy plane.

apply_mask(arr[, masking])

apply self.mask to arr, using self.masking to determine masking.

as_single_dimpoint([values, dims])

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

assert_QN()

asserts self.quasineutral.

assign_dim_coords(array, *dims[, skip])

assign all dimensions in self as coords for array.

assign_maindims_coords(array)

assign maindims dims and coords, based on self.get_maindims_coords() with slicing=False.

assign_velocity_coords(array[, fluid])

assign velocity dims and coords, based on fluid.get_velocity_coords().

attach_extra_coords(arr)

attach any self.extra_coords to array arr but only if it is an xarray.DataArray or xarray.Dataset

check_pickle([x])

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

choose_params(**kw_init)

returns EppicChooseParams based on self.

clock_times()

return dict of clock times from this run.

cls_help([qstr, only, tree, modules, ...])

prints str for help with quants.

cls_var_tree(var, *[, missing_ok])

return QuantTree of MatchedQuantity objects from matching var and all dependencies,

copy()

returns a deep copy of self.

cross_component(A, B, x, *[, yz, missing_ok])

return x component of A cross B, given A and B which have values for y and z 'component'.

cross_components_needed()

return the components vectors need in order to find all cross product components in self.component_list

cross_product(A, B, *[, components])

return cross product of vectors A and B, along dimension 'component'.

curl_component(v, x, *[, yz])

return x component of curl(v).

current_n_dimpoints([dims])

return number of points represented by current values of dims.

current_n_existing_snaps()

returns number of existing snaps, out of all snaps at self.snap.

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}.

direct_overrides_dynamic()

returns dict of {var: override} for all overrides of self which depend on behavior_attrs of self.

directly_loadable_vars([snap])

return tuple of directly loadable variables.

dot_product(A, B)

return dot product of vectors A and B, assuming vector components along the dimension 'component'.

enumerate_dimpoints([dims, all])

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

existing_snaps()

return list of existing snaps.

fftN(array[, dim, ds, slices])

xarray_fftN with defaults for dim & slices determined by self.fft_dims, self.fft_slices.

fft_dims_for(array)

return the dims over which to apply fft for this array.

from_here([filename, dist_names])

create EppicCalculator from input deck file found here (at filename).

gaussian_filter(array[, dim, sigma])

xarray_gaussian_filter with defaults from self.blur_dims, self.blur_sigma.

get_0()

0, as an xarray.

get_1()

1, as an xarray.

get_B()

magnetic field.

get_E()

electric field.

get_E0S1(*[, _skappa, _n])

E0S1 = sum_s (qs ns skappa_s / (1 + skappa_s^2)),

get_E0S1_and_S2()

dataset containing 'E0S1' and 'E0S2'.

get_E0S2(*[, _skappa, _n])

E0S2 = sum_s (qs ns skappa_s^2/ (1 + skappa_s^2)),

get_E0_etaJ_perpB(*[, _E0S1, _E0S2])

E0_perp_B = E0_etaJ_perpB + ..., where E0_etaJ_perpB = eta0_J * J_perp_B.

get_E0_hall(*[, _E0S1, _E0S2])

E0_perp_B = E0_hall + ..., where E0_hall = eta0_hall * J x Bhat.

get_E0_un0_perpB()

E0_un0_perpB = E0_etaJ_perpB + E0_hall

get_E0_un0_perpmodB()

E0_un0_perpmodB = |E0_un0_perpB|.

get_E0_un0_perpmodB_min()

E0_un0_perpmodB_min = minimum possible value of |E0_un0_perpB|, at each point.

get_E0_un0_perpmodB_simple()

E0_un0_perpmodB_simple = simple estimate of |E0_un0_perpB|, at each point.

get_EBspeed()

speed determined from E_un0 and B: |E_un0 perp to B| / |B|.

get_E_ext()

external electric field.

get_E_phi()

electric field, from phi.

get_E_un0()

E_un0 = electric field in the neutral frame, where u_n=0.

get_E_un0_perpmod_B(**kw_perpmod)

E_un0_perpmod_B == |E_un0 perp to B| == magnitude of E, perp to B, in u_neutral=0 frame.

get_E_un0_type()

string telling method that will be used to get E_un0.

get_Eheat()

Eheat = Eheat_perp + Eheat_par.

get_Eheat_par(*[, _E_un0, _B, _Eheat_par_coeff])

Eheat_par = Eheat_par_coeff * |E_par|^2.

get_Eheat_par_coeff()

Eheat_par = Eheat_par_coeff * |E_par|^2.

get_Eheat_perp(*[, _E_un0, _B, _Eheat_par_coeff])

Eheat_perp = Eheat_perp_coeff * |E_perp|^2.

get_Eheat_perp_coeff(*[, _Eheat_par_coeff])

Eheat_perp = Eheat_perp_coeff * |E_perp|^2.

get_Eheat_perp_rate_n()

zeroth order rate of heating of neutrals due to collisions with all charged species.

get_Eheat_perp_rate_n_s()

zeroth order rate of heating of neutrals due to collisions with s (self.fluid).

get_Epar()

electric field, parallel to B.

get_Eperp()

electric field, perpendicular to B.

get_J()

total current density.

get_JBspeed()

speed determined from J perp to B, and ne: |J_perp to B| / (ne * |qe|).

get_J_from_moment1()

total current density, based on moment1 info: sum_fluids_Jf_from_moment1.

get_Jf()

current density (associated with fluid).

get_Jf_from_moment1()

self.fluid's contribution to current density, based on moment1 info: q * n0 * moment1.

get_P()

pressure ("isotropic/maxwellian").

get_T()

temperature, from nv^2.

get_T_box()

temperature of the entire simulation box, as if full of particles,

get_T_from_Eheat()

T_from_Eheat = T_n + Eheat.

get_T_from_Eheat_perp()

T_from_Eheat_perp = T_n + Eheat_perp.

get_T_from_moment2_or_Tjoule_from_moment2(var, *)

temperature ("isotropic/maxwellian"), from moment2 instead of nvsqr/n.

get_T_indim()

temperature, from nv^2.

get_T_neutral()

temperature of neutrals.

get_T_sj(*[, _m_s, _T_s, _m_j, _T_j])

mass-weighted temperature.

get_Ta_from_moment2_or_Tajoule_from_moment2(var, *)

temperature ("anisotropic"), from moment2 instead of nvsqr/n.

get_Ta_or_Tajoule(var, *[, _match])

temperature ("anisotropic").

get_Tapar(var, *[, _match])

Tapar --> anisotropic temperature, parallel to B.

get_Taperp(var, *[, _match])

Taperp --> anisotropic temperature, perpendicular to B.

get_Tjoule()

temperature ("isotropic/maxwellian"), in energy units.

get__nit_since_prev_simple()

naive implementation of nit_since_prev.

get__nusj_singlej(*, collision_type)

_nusj_singlej = collision frequency between self.fluid and a single jfluid.

get_abs(var, *[, _match])

absolute value.

get_abs_qe()

|electron charge|, in [self.units] units.

get_amu()

1 atomic mass unit, in [self.units] units.

get_angle_xy(var, *[, _match, _val0])

angle between +xhat and var, in the xy plane, in radians.

get_angle_xy_to_hat(var, *[, _match, _val0])

unit vector u, given angle [radians] between +xhat and u in the xy plane.

get_astats(var, *[, _match])

return dataarray of stats for var, reporting stats along new dim: 'stat'.

get_behavior([keys])

return value of self.behavior.

get_best_pow2_subcycle()

largest power of 2 subcycling allowed for each fluid in self.fluid.

get_best_subcycle()

largest subcycling allowed: best_subcycle = min_timescale / minf_timescale.

get_beta()

plasma beta.

get_blur(var, *[, _match])

gaussian_filter(var).

get_blurk(var, *[, _match])

gaussian_filter(var), temporarily using self.blur_dims = ['k_x', 'k_y', 'k_z']

get_blurt(var, *[, _match])

gaussian_filter(var), temporarily using self.blur_dims = ['snap']

get_braced_int_from_parenthesis_memory(var, *)

{i} --> self(mem_var), where mem_var = self.parenthesis_memory_key_to_var[int(i)].

get_cache_var(var, *[, _match])

get var, then save to cache.

get_cached_tfbi_vs_EBspeed()

return a previously-computed tfbi solution across EBspeed grid.

get_cached_var(var, *[, _match])

get var from folder within self.cache_dirname.

get_caches_var(var, *[, _match])

get var, possibly from folder within self.cache_dirname.

get_calc_time()

Wall clock runtime, ignoring time spent writing output files.

get_clock_times()

dataset of clock times from this run.

get_collision_type()

collision type between self.fluid and self.jfluid.

get_collisions_cross_section()

cross section between self.fluid and self.jfluid.

get_collisions_crosstab(fluid1, fluid2, *[, ...])

roughly, returns self.collisions_cross_mapping[(fluid1, fluid2)],

get_collisions_crosstab_default_fluids()

return dict of fluids from self which have any corresponding CROSS_TABLE_DEFAULTS.

get_compare_equals(var, *[, _match])

self('A==B') --> boolean array: self('A') == self('B')

get_compare_greater_than(var, *[, _match])

self('A>B') --> boolean array: self('A') > self('B')

get_compare_greater_than_or_equal(var, *[, ...])

self('A>=B') --> boolean array: self('A') >= self('B')

get_compare_less_than(var, *[, _match])

self('A<B') --> boolean array: self('A') < self('B')

get_compare_less_than_or_equal(var, *[, _match])

self('A<=B') --> boolean array: self('A') <= self('B')

get_compare_not_equals(var, *[, _match])

self('A!=B') --> boolean array: self('A') != self('B')

get_coulomb_logarithm()

Coulomb logarithm, ln(Lambda).

get_cpu_per_each2ct()

conversion factors: cpu_per_each2ct * cpu_per_each == cpu_per_ct.

get_cpu_per_each2timestep()

conversion factors: cpu_per_each2timestep * cpu_per_each == cpu_per_timestep.

get_cpu_seconds_per_ct()

cpu seconds per cell per timestep, for each timer in timers.

get_cpu_seconds_per_each()

cpu seconds per (particle, per) cell, per timestep, as relevant to each timer in timers.

get_cpu_seconds_per_pct()

cpu seconds per particle, per cell, per timestep, for each timer in timers.

get_cpu_seconds_per_timestep()

cpu seconds per timestep, for each timer in timers.

get_cross(var, *[, _match, _val0, _val1])

cross product.

get_csound()

sound speed.

get_csound2()

sound speed squared.

get_curl(var, *[, _match])

curl.

get_dTndt()

rate of heating of neutrals due to collisions with all charged species.

get_dTndt0()

zeroth order rate of heating of neutrals due to collisions with charged species.

get_dTndt0_s()

zeroth order rate of heating of neutrals due to collisions with s.

get_dTndt_s()

rate of heating of neutrals due to collisions with s (self.fluid).

get_dTndt_s_T()

temperature contribution to rate of heating of neutrals due to collisions with s.

get_dTndt_s_ds()

dataset of contributions to rate of heating of neutrals due to collisions with s.

get_dTndt_s_u2()

velocity contribution to rate of heating of neutrals due to collisions with s.

get_dTndt_turb0_s_ds()

dataset of contributions to neutral heating rate, based on 'mean' turbulent values,

get_deg2rad(var, *[, _match])

convert degrees to radians.

get_delta(var, *[, _match])

perturbation.

get_delta_sj()

kronecker delta function between self.fluid and self.jfluid.

get_deltafrac(var, *[, _match])

perturbation.

get_deltafrac_n()

normalized density perturbation.

get_derivative(var, *[, _match])

derivative.

get_div(var, *[, _match])

divergence.

get_divide(var, *[, _match])

division.

get_dot(var, *[, _match, _val0, _val1])

dot product.

get_ds()

grid spacing (of output files).

get_ds_for_timescales()

ds used when calculating timescales.

get_ds_sim()

grid spacing (of simulation).

get_dsmin_for_timescales()

minimum spatial scale used when calculating timescales.

get_dt_sim()

time spacing (of simulation).

get_e()

energy density.

get_eps0()

vacuum permittivity, in [self.units] units.

get_eqperp_ldebye()

Debye length (of self.fluid), using T_from_Eheat_perp instead of T.

get_eqperp_ldebye2()

squared Debye length (of self.fluid), using Eheat_perp instead of T.

get_eqperp_ldebye_total()

total Debye length for all fluids: sqrt(epsilon0 kB / sum_fluids(n q^2 / T)),

get_eqperp_mean_free_path()

collisional mean free path, using eqperp_vtherm instead of vtherm.

get_eqperp_vtherm()

thermal velocity, using T_from_Eheat_perp instead of T.

get_eta0_J(*[, _E0S1, _E0S2])

E0_perp_B = eta0_J * J_perp_B + ..., where eta0_J = E0S1 * |B| / (E0S1^2 + E0S2^2).

get_eta0_hall(*[, _E0S1, _E0S2])

E0_perp_B = eta0_hall J x Bhat + ..., where eta0_hall = - E0S2 * |B| / (E0S1^2 + E0S2^2)

get_exp(var, *[, _match])

exponentiation.

get_fft(var, *[, _match])

N-dimensional fft.

get_fft_with_dims(var, *[, _match])

N-dimensional fft.

get_finite(var, *[, _match])

var, masked with NaN wherever values are not finite.

get_first_dimpoint([dims, enumerate])

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

get_float(var, *[, _match])

any float, as an xarray.

get_flux()

flux.

get_frominputs_value(var, *[, _match])

compute var based on inputs, i.e. when self.snap = INPUT_SNAP.

get_gamma()

adiabatic index.

get_grad(var, *[, _match])

gradient.

get_growthfit(var, *[, _match])

self('growthfit_var') --> linear regression along 't' coord, of ln|var|.

get_growthfitk(var, *[, _match])

self('growthfitk_var') --> linear regression along 't' coord, of ln|radfft_var|.

get_growthk(var, *[, _match])

self('growthk_var') --> exponential growth rate of radfft_var.

get_growthrate(var, *[, _match])

self('growthrate_var') --> exponential growth rate of var.

get_guess_cpu_seconds(var, *[, _match])

guess run cost, in cpu seconds.

get_guess_cpu_seconds_per_each(var, *[, _match])

guess log10(cpu seconds per (particle, per) grid cell, per timestep), for the indicated timer.

get_guess_cpu_seconds_per_timestep_or_ct(var, *)

guess cpu seconds required per (cell, per) timestep, for the indicated timer.

get_guess_node_hours(var, *[, _match])

guess run cost, in node hours.

get_guess_runtime_seconds(var, *[, _match])

guess run cost, in wall clock time [seconds].

get_gyrof()

(unsigned) gyrofrequency.

get_hat(var, *[, _match, _val0])

unit vector in the direction of var.

get_ifft(var, *[, _match])

N-dimensional ifft.

get_imag(var, *[, _match])

imaginary part.

get_inf()

infinity, as an xarray.

get_init_seconds()

time [in seconds] spent initializing the run.

get_inputs_tfbi_vs_EBspeed()

get tfbi_vs_EBspeed at self.set_vars_from_inputs().

get_int(var, *[, _match])

any integer, as an xarray.

get_ionnefrac()

ratio of n_ions / ne.

get_ionnefrac_significant()

boolean array telling whether n_ions/ne >= self.nnefrac_tiny_thresh.

get_ionnefrac_tiny()

boolean array telling whether n_ions/ne < self.nnefrac_tiny_thresh

get_kB()

boltzmann constant, in [self.units] units.

get_kappa()

(unsigned) kappa (magnetization parameter).

get_ldebye()

Debye length (of self.fluid).

get_ldebye2()

squared Debye length (of self.fluid).

get_ldebye_subset()

"total" Debye length; ldebye_subset = sqrt(epsilon0 kB / sum_fluids(n q^2 / (kB T)))

get_ldebye_total()

total Debye length for all fluids; ldebye_total = sqrt(epsilon0 kB / sum_fluids(n q^2 / (kB T)))

get_linregt(var, *[, _match])

linear regression along 't' coord.

get_ln(var, *[, _match])

log base e.

get_load_direct_maindims_var(var, *[, _match])

load maindims var directly (from files, cache, or setvars; see self.load_direct()).

get_log10(var, *[, _match])

log base 10.

get_log2(var, *[, _match])

log base 2.

get_logical_and(var, *[, _match])

logical and.

get_logical_not(var, *[, _match])

logical not.

get_logical_or(var, *[, _match])

logical or.

get_lowpass(var, *[, _match])

lowpass filter across self.fft_dims; keep low frequencies, zero high frequencies.

get_m()

mass, of a "single particle".

get_m_amu()

mass in atomic mass units.

get_m_neutral()

mass, of a "single neutral particle".

get_m_neutral_f()

mass, of a "single neutral particle," varying across fluid.

get_m_sj(*[, _m_s, _m_j])

weighted mass.

get_maindims_coords([units])

return dict of {'x': xcoords, 'y': ycoords}.

get_mask_var(var, *[, _match])

mask_var --> masked version of self(var).

get_max(var, *[, _match])

maximum.

get_mean(var, *[, _match])

mean.

get_mean_free_path()

collisional mean free path.

get_mean_pm_std(var, *[, _match])

return dataset of 'mean+std', 'mean', 'mean-std' for var.

get_meannormed(var, *[, _match])

normalized by mean.

get_meant(var, *[, _match])

mean-across-time of var.

get_median(var, *[, _match])

median.

get_min(var, *[, _match])

minimum.

get_min_n_nodes_given_nsubdomains()

minimum number of nodes, given nsubdomains and tasks_per_node,

get_min_timescale()

minimum timescale across all timescales.

get_min_timescale_type()

tells which timescale has the minimum value (across all timescales).

get_minf_timescale()

minimum timescale across all timescales and fluids.

get_minf_timescale_type()

tells which timescale has the minimum value (across all timescales and fluids).

get_minus(var, *[, _match])

subtraction.

get_mod(var, *[, _match, _val0])

magnitude of var.

get_mod2(var, *[, _match, _val0])

magnitude squared of var.

get_moment1()

1st moment of distribution function, along an axis (vector component).

get_moment2()

2nd moment of distribution function, along an axis (vector component).

get_moment3()

3rd moment of distribution function, along an axis (vector component).

get_moment4()

4th moment of distribution function, along an axis (vector component).

get_n()

number density.

get_n0()

background density.

get_n_neutral()

number density of neutrals.

get_n_nodes()

number of nodes used to run this run.

get_n_processors()

number of MPI processors used to run this run.

get_nan()

NaN, as an xarray.

get_nandelta(var, *[, _match])

perturbation.

get_nandeltafrac(var, *[, _match])

perturbation.

get_nanmax(var, *[, _match])

maximum.

get_nanmean(var, *[, _match])

mean.

get_nanmedian(var, *[, _match])

median.

get_nanmin(var, *[, _match])

minimum.

get_nanrms(var, *[, _match])

root mean square.

get_nanstd(var, *[, _match])

standard deviation.

get_ncells_sim()

number of gridcells from simulation (differs from output when nout_avg != 1).

get_ncpu()

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

get_ndim_space()

number of spatial dimensions in simulation.

get_ne()

electron number density.

get_negation(var, *[, _match])

negation.

get_neutral([var])

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

get_niefrac()

ion-to-electron density ratio.

get_nit_since_prev()

return number of timesteps since previous snapshot in self.

get_nmean(var, *[, _match])

mean of var, weighted by n.

get_nnefrac()

ratio of number density to electron number density: n / ne.

get_nnefrac_significant()

boolean array telling whether n/ne >= self.nnefrac_tiny_thresh.

get_nnefrac_tiny()

boolean array telling whether n/ne < self.nnefrac_tiny_thresh

get_npcelld()

number of PIC particles per simulation cell.

get_npd()

number of PIC particles in each distribution.

get_npow2_processors()

largest power of 2 which evenly divides n_processors.

get_nptotcell()

number of particles per cell for all fluids combined, appropriately weighted considering subcycling.

get_nptotcelld()

number of PIC particles per simulation cell (total across all processors).

get_nptotd()

number of PIC particles (total across all processors).

get_nq()

charge density.

get_nstd(var, *[, _match])

std of var, weighted by n.

get_nsubdomains()

number of subdomains.

get_nuns()

collision frequency.

get_nusj()

collision frequency.

get_nusj_best()

collision frequency, using self.collisions_mode='best'.

get_nusj_coulomb()

coulomb collision frequency.

get_nusj_fromtable()

collision frequency from a table.

get_nusj_maxwell()

maxwell collision frequency.

get_nusn()

collision frequency (of self.fluid) with neutrals.

get_nusn_from_drift(var, *[, _match])

nusn, calculated by assuming u satisfies momentum equation to zeroth order.

get_nvsqr()

n * ({x} component of velocity)^2.

get_p()

momentum density.

get_parallel(var, *[, _match, _val0, _val1])

A_par_B --> the component of A parallel to B.

get_parenthesis(var, *[, _match])

parenthesis.

get_parmod(var, *[, _match, _val0, _val1])

magnitude of the component of A parallel to B.

get_perp(var, *[, _match, _val0, _val1])

A_perp_B --> A after removing the component of A parallel to B.

get_perpmod(var, *[, _match, _val0, _val1])

magnitude of A after removing the component of A parallel to B.

get_phi()

electric potential.

get_pi()

pi.

get_plotter(name[, who])

gets the Plotter associated with this name and who.

get_plotters([who, kind, name, all_whos, ...])

return list of all plotters associated with these inputs.

get_plus(var, *[, _match])

addition.

get_pmstd2werr(var, *[, _match])

convert dataset with 'mean+std' and 'mean-std' into dataset with 'mean' and 'std'.

get_power(var, *[, _match])

power.

get_prod(var, *[, _match])

prod.

get_prod_fluid_var(var, *[, _match])

var prodmed across self.fluid.

get_prod_fluids_var(var, *[, _match])

var prodmed across self.fluids.

get_prod_ions_var(var, *[, _match])

var prodmed across all ions in self.fluids.

get_prod_jfluid_var(var, *[, _match])

var prodmed across self.jfluid.

get_prod_jfluids_var(var, *[, _match])

var prodmed across self.jfluids.

get_prod_neutrals_var(var, *[, _match])

var prodmed across all neutrals in self.fluids.

get_pwl2_var(var, *[, _match])

get pwl2_flatend fit to var across self.snap, evaluated at self.snap.

get_q()

charge, of a "single particle".

get_r()

mass density.

get_rad2deg(var, *[, _match])

convert radians to degrees.

get_real(var, *[, _match])

real part.

get_rms(var, *[, _match])

root mean square.

get_rmscomps(var, *[, _match])

root mean squared of components.

get_rosenberg_multi()

rosenberg criterion for multiple ions: rosenberg_multi = (nusn_multi / wplasma_multi)^2.

get_rosenberg_multi_nusn()

collision frequency for rosenberg criterion with multiple ions.

get_rosenberg_multi_wplasma()

plasma frequency for rosenberg criterion with multiple ions.

get_rosenberg_n()

n such that rosenberg_qn == 1, for each fluid.

get_rosenberg_n_margin()

n / rosenberg_n.

get_rosenberg_qn()

Rosenberg criterion for quasineutrality, for each fluid: rosenberg_qn = (nusn / wplasma)^2.

get_run_time()

Wall clock runtime for each snap.

get_runtimes()

timers_dat info as an xarray.DataArray, at snaps in self.snap.

get_safe_pow2_subcycle(*[, subcycle_safety])

largest "safe" power of 2 subcycling allowed for each fluid in self.fluid.

get_sci_number(var, *[, _match])

any number in scientific notation, as an xarray.

get_seconds2timer()

conversion factor from seconds to timers.dat units.

get_set_or_cached(var)

returns var if found in self.setvars or self.cache, with compatible behavior_attrs.

get_sgyrof()

signed gyrofrequency.

get_skappa()

signed kappa (magnetization parameter).

get_skappa_from_hall(var, *[, _match])

signed kappa (magnetization parameter) that statisfies u_hall = u, in the E x B direction.

get_skappa_from_momE(var, *[, _match])

signed kappa (magnetization parameter) that statisfies momentum equation in the E direction.

get_skappa_from_momExB(var, *[, _match])

signed kappa (magnetization parameter) that statisfies momentum equation in the E x B direction.

get_skappa_from_pederson(var, *[, _match])

signed kappa (magnetization parameter) that statisfies u_pederson = u, in the E direction.

get_slopet(var, *[, _match])

slope calculated from linear regression along 't' coord.

get_slurm_options()

dataset of all slurm options from slurmfiles in self.dirname.

get_sparmod(var, *[, _match, _val0, _val1])

signed "magnitude" of the component of A parallel to B.

get_sqrt(var, *[, _match])

square root.

get_stats(var, *[, _match])

return dataset of stats for var

get_std(var, *[, _match])

standard deviation.

get_steps_seconds()

time [in seconds] spent doing timesteps.

get_subcycle()

subcycling factor (for each fluid in self.fluid).

get_sum(var, *[, _match])

sum.

get_sum_fluid_var(var, *[, _match])

var summed across self.fluid.

get_sum_fluids_var(var, *[, _match])

var summed across self.fluids.

get_sum_ions_var(var, *[, _match])

var summed across all ions in self.fluids.

get_sum_jfluid_var(var, *[, _match])

var summed across self.jfluid.

get_sum_jfluids_var(var, *[, _match])

var summed across self.jfluids.

get_sum_neutrals_var(var, *[, _match])

var summed across all neutrals in self.fluids.

get_surelin_var(var, *[, _match])

values of var between (inclusive) t_surelin_min and t_surelin.

get_sureturb_var(var, *[, _match])

values of var at or after t_sureturb.

get_t_surelin()

time before which, values are definitely in the linear regime.

get_t_surelin_min()

start time of "definitely linear regime".

get_t_sureturb()

time, after which, values are definitely in the turbulent regime.

get_t_turb()

time of turbulent onset.

get_t_turb_from_pwl2_var(var, *[, _match])

t_turb from pwl2_flatend fit to var.

get_tasks_per_node()

number of processors per node.

get_tfbi_EBspeed_grid()

return a 1D grid of EBspeed values with constant logstep.

get_tfbi_EBspeed_thresh()

threshold EBspeed for TFBI to grow.

get_tfbi_E_thresh()

threshold E_un0_perpmag_B for TFBI to grow.

get_tfbi_all(**kw_get_vars)

returns xarray.Dataset of values relevant to TFBI theory.

get_tfbi_extras(**kw_get_vars)

returns xarray.Dataset of values relevant to TFBI theory but not necessary for inputs.

get_tfbi_fscale()

tfbi_fscale = n * kappa

get_tfbi_fscale_rel()

tfbi_fscale_rel = tfbi_fscale(this fluid) / tfbi_fscale(electrons).

get_tfbi_inputs(**kw_get_vars)

returns xarray.Dataset of values to input to the tfbi theory.

get_tfbi_omega(*[, kw_tfbi_solve])

Thermal Farley Buneman Instability roots with largest imaginary part at each point in self.

get_tfbi_omega_ds(*[, kw_tfbi_solve])

Thermal Farley Buneman Instability solution at each point in self.

get_tfbi_vs_EBspeed()

return tfbi solution across EBspeed grid.

get_time_frac(var, *[, _match])

fraction of runtime spent on writing or calculating.

get_time_requested()

time limit for this run.

get_time_requested_numeric(var, *[, _match])

time limit for this run, in hours, minutes, or seconds.

get_timer2seconds()

conversion factor from timers.dat units to seconds.

get_timers()

timers_dat info as an xarray.Dataset, at snaps in self.snap.

get_times(var, *[, _match])

multiplication.

get_timescale_EBdrift()

timescale from drift speed if possible, else from speed using E & B fields.

get_timescale_EBspeed()

timescale from speed using E & B fields.

get_timescale_eqperp_vtherm()

timescale from thermal velocity, using T_from_Eheat_perp instead of T.

get_timescale_gyrof()

timescale for cyclotron motion.

get_timescale_nusn()

timescale for collisions with neutrals.

get_timescale_udrift()

timescale from drift speed.

get_timescale_vtherm()

timescale from thermal velocity.

get_timescale_wplasma()

timescale from plasma oscillations.

get_timescales()

all timescales (from self.TIMESCALE_VARS) as a dataset.

get_timescales_abbrv()

all timescales (from self.TIMESCALE_VARS) as a dataset, abbreviating names.

get_timestep_cost_or_dt_cost(var, *[, _match])

total cpu time per simulated particle, per timestep (or per dt).

get_total_seconds()

duration [in seconds] spent to run the entire run.

get_tturb_var(var, *[, _match])

values of var at or after t_turb.

get_tturbvar00()

var used for t_turb '00' standard: caches_ln_std_blur_deltafrac_n,

get_turblindiff_var(var, *[, _match])

meant_sureturb_var - meant_surelin_var.

get_turblindiffwerr_var(var, *[, _match])

werrmeant_sureturb_var - werrmeant_surelin_var.

get_turblindivwerr_var(var, *[, _match])

werrmeant_sureturb_var / werrmeant_surelin_var.

get_u()

velocity.

get_u_EdotB(*[, _E, _B])

EdotB drift velocity.

get_u_drift()

equilibrium velocity; solution to the momentum equation with collisions,

get_u_hall(*[, _E, _B])

Hall drift velocity.

get_u_neutral()

returns 0, since u_neutral is always 0 in every component, for eppic.

get_u_pederson(*[, _E, _B])

Pederson drift velocity.

get_unwrapt_2pi_var(var, *[, _match])

unwrapt_{A} --> unwrapped self(A) along 't', via np.unwrap with period=2*pi.

get_upar()

velocity vector, parallel to B.

get_uperp()

velocity vector, perpendicular to B.

get_valfven()

Alfven speed.

get_valfven2()

Alfven speed squared.

get_var_at_max_of_ref(var, *[, _match])

var_at_max_of_ref --> self(var) at argmax of self(ref),

get_var_at_min_of_ref(var, *[, _match])

var_at_min_of_ref --> self(var) at argmin of self(ref),

get_var_where_condition(var, *[, _match])

var_where_condition --> self(var).where(self(condition)).

get_vars(vars, *args[, return_type, ...])

returns values of vars from self.

get_vdist()

velocity distribution.

get_vector_N(var, *[, _match])

vector_n --> vector with n in each component.

get_vsqr()

v^2 in each grid cell.

get_vtherm()

thermal velocity.

get_vtherm_n()

thermal velocity for neutrals.

get_weighted_mean(weights_var, *[, _match])

mean, weighted by weights.

get_weighted_std(weights_var, *[, _match])

std, weighted by weights.

get_werr2pmstd(var, *[, _match])

convert dataset with 'mean' and 'std' into dataset with 'mean+std', 'mean', 'mean-std'.

get_werradd(var, *[, _match])

A_werradd_B = A + B, but result is a dataset with 'mean' and 'std'.

get_werrdiv(var, *[, _match])

A_werrdiv_B = A / B, but result is a dataset with 'mean' and 'std'.

get_werrmean(var, *[, _match])

dataset of 'mean' and 'std' of var.

get_werrmeant(var, *[, _match])

dataset of 'mean' and 'std' of var, taking stats across time dimension.

get_werrmul(var, *[, _match])

A_werrmul_B = A * B, but result is a dataset with 'mean' and 'std'.

get_werrsub(var, *[, _match])

A_werrsub_B = A - B, but result is a dataset with 'mean' and 'std'.

get_where_condition_var(var, *[, _match])

where_condition_var --> self(var).where(self(condition)).

get_wplasma()

"plasma frequency".

get_wplasmae()

electron plasma frequency; Langmuir oscillations.

get_write_time()

time spent writing output files.

get_xhat()

unit vector in the x direction.

get_xyz(var, *[, _match])

x, y, and/or z components of var.

get_yhat()

unit vector in the y direction.

get_zhat()

unit vector in the z direction.

getj(var, *args__get[, jfluid])

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

has_var(var)

return whether self can load var.

help([qstr, only, tree, modules, signature, ...])

prints str for help with quants.

help_call_options([search])

prints help for kw_call_options.

help_quants_str([qstr, only, tree, modules, ...])

returns str for help with quants.

help_str([qstr, only])

returns cls.help_quants_str(qstr=qstr, only=only, **kw).

ifftN(array[, dim, df, x0, ds])

xarray_ifftN with defaults for dim determined by self.fft_dims.

ifft_dims_for(array)

return dims over which to apply ifft for this array.

init_fluids()

set self.fluids and self.jfluids based on input_deck.

init_maindims()

set self.maindims based on input_deck.

init_snaps(*[, snaps_from])

set self.snaps based on input_deck AND reading files.

init_units_manager(*[, u, u_l, u_t, u_n, ne_si])

set units manager self.u, based on input_deck.

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

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

jobfiles()

return list of all jobfiles within self.dirname directory.

kw_call_options(*[, sorted])

returns list of kwarg names which can be used to set attrs self during self.__call__.

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.

load_direct(var, *args, **kw)

load var "directly", either from a file, self.setvars, self.direct_overrides,

load_fromfile(fromfile_var, *args[, snap])

return numpy array of fromfile_var, loaded directly from file.

load_input(fromfile_var, *args__None, **kw__None)

load input value -- one of the base quantities (fromfile_var) directly from eppic.i file.

load_maindims_var(var, *args[, u, assign_labels])

return var, formatted as an xarray with proper details for PlasmaCalcs.

load_maindims_var_across_dims(var[, dims, ...])

load maindims var across these dims.

load_subsampling_info()

load subsampling info from {self.dirname}/subsampling_info.

lowpass(array[, dim, keep, keep_r])

xarray_lowpass with defaults for dim & keep determined by self.fft_dims, self.lowpass_keep.

magnitude(A, *[, squared])

return vector magnitude of A, assuming vector components along the dimension 'component'.

maintaining_attrs(*attrs, **attrs_as_flags)

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

match_var(var, *[, check])

match var from cls.KNOWN_VARS or cls.KNOWN_PATTERNS, or raise FormulaMissingError.

match_var_loading_dims(var, **kw_loading_dims)

return dims for loading var across.

match_var_result_dims(var, **kw_result_dims)

return dims which result of cls(var) will vary across.

match_var_result_size(var, *[, maindims])

return size (number of elements) which self(var) will have.

match_var_tree([var])

return QuantTree of MatchedQuantity objects from matching var and all dependencies,

n_existing_snaps()

returns number of existing snaps.

npd_for_fluid(fluid)

return the npd for this fluid.

on_changed_quasineutral(*, old, new)

called when self.quasineutral changes.

plot(name[, who, save, show, close])

makes a single plot using the relevant plotter.

plot_E_mod2_abs_radfft_manytimes(...)

abs_radfft_delta_mod2_E at "many" times (ec.sam_defaults['manytimes']).

plot_E_mod2_blurk_abs_radfft_manytimes(...)

abs_radfft_delta_mod2_E at "many" times (ec.sam_defaults['manytimes']).

plot_E_mod_sometimes(**kw_plot_settings)

mod_E at some times (ec.sam_defaults['sometimes'])

plot_E_mod_stats(**kw_plot_settings)

E-field (mod) stats timelines.

plot_E_stats(**kw_plot_settings)

E-field (vector) stats timelines.

plot_T_box(**kw_plot_settings)

T_box timelines for all fluids.

plot_T_sometimes(**kw_plot_settings)

T at some times (ec.sam_defaults['sometimes'])

plot_Ta_from_moment2(**kw_plot_settings)

Ta_from_moment2 timelines for all fluids.

plot_check_nusn_from_drift(*[, u, drift, ...])

plots PlasmaCalcs.timelines() for comparing nusn to nusn inferred from drifts.

plot_ddt_ln_std_blur_deltafrac_n(...)

ddt_ln_std_blur_deltafrac_n timelines for all fluids, for blur_sigma in [0, 1, 10, 20]

plot_ddt_ln_std_deltafrac_n(**kw_plot_settings)

ddt_ln_std_deltafrac_n timelines for all fluids.

plot_deltafrac_n(**kw_plot_settings)

deltafrac_n movie for all fluids, all current snaps (in self.snap).

plot_deltafrac_n_abs_radfft(**kw_plot_settings)

abs_radfft_deltafrac_n movie for all fluids, all current snaps (in self.snap).

plot_deltafrac_n_abs_radfft_full_sometimes(...)

abs_radfft_deltafrac_n at some times (ec.sam_defaults['sometimes']) for all fluids.

plot_deltafrac_n_abs_radfft_sometimes(...)

abs_radfft_deltafrac_n at some times (ec.sam_defaults['sometimes']) for all fluids.

plot_deltafrac_n_blurk_abs_radfft(...)

blurk_abs_radfft_deltafrac_n movie for all fluids, all current snaps (in self.snap).

plot_deltafrac_n_blurk_abs_radfft_sometimes(...)

blurk_abs_radfft_deltafrac_n at some times (ec.sam_defaults['sometimes']) for all fluids.

plot_deltafrac_n_sometimes(**kw_plot_settings)

deltafrac_n at some times (ec.sam_defaults['sometimes']) for all fluids.

plot_deltafrac_ne_manytimes(**kw_plot_settings)

deltafrac_n for electrons at "many" times (ec.sam_defaults['manytimes']).

plot_ln_std_blur_deltafrac_n(**kw_plot_settings)

ln_std_blur_deltafrac_n timelines for all fluids, for blur_sigma in [0, 1, 10, 20]

plot_ln_std_deltafrac_n(**kw_plot_settings)

ln_std_deltafrac_n timelines for all fluids.

plot_moment1(**kw_plot_settings)

moment1 timelines for all fluids.

plot_moment1_specie0(**kw_plot_settings)

plot the first moment of the simulation for specie0

plot_n_stats(**kw_plot_settings)

number density stats timelines for all fluids.

plot_u_mod_sometimes(**kw_plot_settings)

mod_u at some times (ec.sam_defaults['sometimes'])

plot_u_mod_stats(**kw_plot_settings)

stats of u (mod) timelines for all ions and electrons.

plot_u_std(**kw_plot_settings)

std of u (vector) timelines for all ions and electrons.

plot_u_std_mod(**kw_plot_settings)

std of u (mod) timelines for all ions and electrons.

polyfit(array_or_var, coord, degree[, window])

polyfit along coord.

pop_dim_keys(kw)

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

quant_tree([var])

return QuantTree of MatchedQuantity objects from matching var and all dependencies,

rawvar_load(var, src)

load a single raw var from snap src.

rawvar_load_and_subsample(var, src, info)

returns var loaded and subsampled from src.

rawvar_save(var, data, dst)

saves a single raw var to snap dst.

rawvars_loadable(src)

returns list of all directly loadble vars within snap src.

rawvars_loadable_across([srcs])

returns dict of {src: [vars loadable from src]} for all snap srcs

record_units(array)

return array.assign_attrs(self.units_meta()).

rmscomps(A)

return root mean squared of components of A.

sam_plots_highres(*[, dst, dpi, ...])

save sam's plots in highres mode.

sam_plots_lowres(*[, dst, dpi, bbox_inches, ...])

save sam's plots in lowres mode.

sam_plots_midres(*[, dst, dpi, bbox_inches, ...])

save sam's plots in midres mode.

save_plots([kind, who, name, all_whos, ...])

saves all plots from plotters associated with these inputs.

set_E_un0_perpmod_B(value, **kw)

set E_un0_perpmod_B to this value.

set_T(value, **kw)

set T to this value, by setting all components of 'nvsqr' to the appropriate value.

set_Tj(value, **kw)

set T to this value for the current self.jfluid.

set_attrs(**attrs)

sets these attrs in self.

set_bases(*[, n, u, T, ux, uy, uz, forall, ...])

set n, u, and T to these values (for the relevant current behavior in self..).

set_collisions_crosstab(fluid1, fluid2, ...)

roughly, does self.collisions_cross_mapping[(fluid1, fluid2)] = crosstab,

set_collisions_crosstab_defaults([mode, ...])

set CROSS_TABLE_DEFAULTS cross sections for all relevant fluids in self.

set_den(value, **kw)

set den to this value.

set_flux(value, **kw)

set flux to this value.

set_mask(mask)

sets self.mask = mask, and increments self._mask_cache_state (if checks succeed).

set_mod_B(value, **kw)

set mod_B to this value.

set_n(value, **kw)

set n to this value, by setting 'den' to the appropriate value.

set_nj(value, **kw)

set n to this value for the current self.jfluid.

set_nvsqr(value, **kw)

set nvsqr to this value.

set_phi(value, **kw)

set phi to this value.

set_pop_dim_attrs(kw)

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

set_t_turb_00()

set self.t_turb & return t_turb from '00' standard: t_turb_from_pwl2_ln_std_blur_deltafrac_n,

set_t_turb_10()

set self.t_turb & return t_turb from '10' standard: t_turb_from_pwl2_ln_std_blur_deltafrac_n,

set_u(value, **kw)

set u to this value, by setting 'flux' to the appropriate value.

set_var(var, value[, behavior_attrs, ...])

set var in self.

set_var_internal(var, value, behavior_attrs)

set var in self.

set_vars_from_inputs([snap, _version])

set self.snap to INPUT_SNAP.

set_vtherm(value, **kw)

set thermal velocity, by setting T.

slice_maindims(array, **kw_xarray_isel)

slice maindims of array using self.slices.

slicestr(*[, sep, keep_None])

string representation of self.slices, for use in filenames, titles, etc.

snap_filepath([snap])

convert snap to full file path for this snap.

snap_src_to_filepath(src)

convert snap src to filepath.

solve_tfbi_vs_EBspeed(*[, Mbytes_max, cache])

solve tfbi across EBspeed grid from self('tfbi_EBspeed_grid').

standardized_slices()

returns a copy of self.slices, but calling interprets_fractional_indexing on all slices,

stat_dims_for(array)

return the dims to apply statistics over, for this array.

store_mask(arr)

equivalent: xarray_store_mask(arr, self.mask).

subsample(subsampling_info, *[, ...])

apply subsampling to all data indicated by subsampling_result_info.

subsample_maindims_at_snaps(*[, x, y, z, ...])

subsample same maindims but different snaps for different vars.

subsample_maindims_simple(*[, snap, x, y, z])

self.subsample(subsampling_info corresponding to slicing snaps and maindims, only).

subsampler(subsampling_info)

return self.subsampler_cls instance with self and subsampling_info.

subsampling_info_maindims_at_snaps(*[, x, ...])

SubsamplingInfo corresponding to subsampling maindims at different snaps.

subsampling_info_maindims_simple(*[, snap, ...])

SubsamplingInfo corresponding to slicing snaps and maindims, only.

subsampling_snap_srcs()

list of all snap srcs in self (before applying any subsampling).

take_parallel_to(B, A)

return the component of A parallel to B.

take_perp_to(B, A)

return the component of A perpendicular to B.

tfbi_ds([ions, all, output_mask])

returns Dataset of all the values needed & relevant to TFBI theory.

tfbi_mask(*[, kappae, ionfrac, kappai, set])

set & return self.mask appropriate for TFBI.

tfbi_solver([ions])

return TfbiSolver object for solving TFBI theory based on values in self.

timers_dat(*[, with_snaps, as_array])

return timers.dat as an xarray.Dataset.

timescales(**kw_init)

returns EppicTimescales based on self.

title_with_slices(*[, sep, keep_None])

return self.title with slicestr appended (after sep), if slicestr is not empty.

tree([var])

return QuantTree of MatchedQuantity objects from matching var and all dependencies,

units_meta()

return dict(units=self.units).

unmask(arr, **kw_xarray_unmask)

restore arr to the same shape as unmasked unstacked arrays.

unset_var(var[, behavior_attrs, missing_ok])

remove var from self.setvars (but only at values stored with relevant behavior).

unset_var_internal(var, behavior_attrs[, ...])

unset var from self.setvars.

using_at_call_depth(depth, **attrs_and_values)

context manager for setting attrs_and_values but only while call_depth == depth.

using_at_next_call_depth(**attrs_and_values)

context manager for setting attrs_and_values but only while call_depth == self.call_depth + 1

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.

where_loadable([var, snaps, set])

returns snaps from self.snaps where 'n', 'flux', 'nvsqr', 'vdist', 'phi' values can be loaded,

wheref_loadable([var, snaps, set])

returns snaps from self.snaps where 'n', 'flux', 'nvsqr', 'vdist', 'phi' values can be loaded,

_T_neutral_loader()

load T for neutrals.

_apply_maindims_slices_to_dict(d)

slice entries in dict using self.slices.

_apply_subsampling_to_maindims_coords(coords)

apply subsampling to maindims coords.

_apply_subsampling_to_vdist_coords(vcoords, ...)

apply subsampling to vdist coords for this fluid (a single Fluid)

_apply_toplevel_scale_coords(arr)

apply self.toplevel_scale_coords to arr, if nonempty, else return arr unchanged.

_array_compatible_with_current_behavior(array, *)

returns whether array is compatible with current self.behavior.

_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_array_compatible_with_current_behavior(array)

assert that array is compatible with current self.behavior.

_assert_cache_array_not_too_big(array)

checks that array is not too big for caching.

_battrs_for_set_var_internal(behavior_attrs)

returns behavior_attrs which will be used by set_var_internal, given these inputs.

_battrs_for_unset_var_internal(behavior_attrs)

returns behavior_attrs which will be used by unset_var_internal, given these inputs.

_braced_int_dep(_var, groups)

returns the 'dep' associated with this var for _get_braced_int_from_parenthesis_memory

_cache_dst(array_or_name)

return abspath for cached array, given array (or name of array).

_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)

_call_postprocess(result, *, var[, name, item])

postprocess result from self.__call__.

_call_postprocess_toplevel(result, *, var[, ...])

additional postprocessing for self.__call__ when call_depth=1.

_check_files_readable()

check that all files in self.dirname are readable (checks recursively inside directories too).

_default_cache_dirname()

default for self.cache_dirname.

_default_cross_mapping()

return default CrossMapping object to use as self.collisions_cross_mapping.

_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_sam_defaults()

returns a copy of self.SAM_DEFAULTS.

_default_subsampling_info()

default value for self.subsampling_info: load from {self.dirname}/subsampling_info.

_default_timeout()

return default for timeout during self.load_across_dims.

_default_title()

default title for self.

_delete_cache_dst_if_exists(dst)

delete dst, if it exists, but first ensure it contains '_pc_caches' in the path.

_extra_coords_with_title()

return self.extra_coords with {'title': repr(self.title)} added,

_fluid_is_neutral()

returns True if self.fluid is neutral (either one neutral or multiple).

_get_T_neutral()

get the temperature of self.fluid when it is an EppicNeutral or EppicNeutralList.

_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.

_get_maybe_missing_var(var, *args[, ...])

return value of var, or None if FormulaMissingError and missing_vars 'ignore' or 'warn'.

_get_n_neutral()

get the number density of self.fluid when it is an EppicNeutral or EppicNeutralList.

_get_stat_var(var, statfunc)

returns result of applying statfunc to self(var), possibly one dimpoint at a time then joining results.

_get_stat_var_dimpoint_wise_false(var, statfunc)

returns result of applying statfunc to self(var).

_get_stat_var_dimpoint_wise_true(var, statfunc)

returns result of applying statfunc to self(var).

_get_statfunc_of_var(var, statfunc)

load this stat, for self(var).

_get_subsampling_step(x[, var])

get subsampling step for var along this direction.

_h5_2_directly_loadable_vars(*[, snap])

return tuple of directly loadable variables, for read_mode='h5_2'.

_h5_2_filename(*[, snap])

return name of file from which to load values, for read_mode='h5_2'.

_h5_2_load_fromfile(fromfile_var, *args__None)

return numpy array of var, loaded directly from file, using "h5_2" read_mode.

_handle_missing_collisions_crosstab()

handles the case of a missing collisions cross table between self.fluid & self.jfluid.

_handle_typevar_nan(*[, errmsg])

crash with TypevarNanError if self.typevar_crash_if_nan, else return 'nan'.

_help_matches(qstr, k, v)

returns whether qstr matches k or v, and thus should be displayed during self.help(qstr).

_increment_call_depth()

context manager for incrementing call_depth.

_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.

_load_maindims_var_with_labels(var, *args, **kw)

equivalent to self.load_maindims_var(var, *args, assign_labels=True, **kw)

_load_maindims_var_without_labels(var, ...)

equivalent to self.load_maindims_var(var, *args, assign_labels=False, **kw)

_load_moment(eppic_var, *args__None[, snap])

load moment indicated by eppic_var.

_loadable_moments()

tells eppic_var variable names of loadable moments.

_multi_slices_dims_default()

function to get multi_slices dims, by default.

_new_fft_slices()

Called when self.fft_slices accessed but not yet set; create & return new FFTSlices.

_new_multi_slices(**kw)

called when self.multi_slices accessed but not yet set; create & return new MultiSlices.

_openpmd_directly_loadable_vars(*[, snap])

return tuple of directly loadable variables, for read_mode='openpmd'.

_openpmd_load_fromfile(eppic_var, *args__None)

return numpy array of var, loaded directly from file, using "openpmd" read_mode.

_parenthesis_converted_var(before, here, after)

returns the var after converting it from var like '{before}({here}){after}'.

_parenthesis_dep(_var, groups)

returns the 'dep' associated with this var for get_parenthesis.

_pop_kw_call_options(kw)

pop all self.kw_call_options() from kw, returning dict of popped options.

_pre_and_post_deriv_slices(x)

return slices to apply before & after differentiation.

_print_or_warn(msg[, debug_thresh])

if DEBUG>=debug_thresh, print msg.

_provided_val(var[, _val, _known_vals])

returns the value of var, either from _known_vals or _val.

_qn_direct_den0()

gets den0 in quasineutral case.

_read_all_moments()

read all moments; return result.

_repr_contents()

return list of strings to use inside self.__repr__

_sam_timeline_defaults(*[, title])

sets sam's defaults for timelines plots.

_set_collisions_crosstab_defaults_from([...])

set as many CROSS_TABLE_DEFAULTS cross sections as possible, for provided fluids.

_slice_maindims_numpy(array, *[, h5])

slice first len(maindims) dims of array, using self.slices.

_slices_which_scalarize()

return list of maindims which become scalars when hit by self.slices.

_special_dims_shifters(dimnames, _shift_special)

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

_tfbi_vs_EBspeed_file()

returns expected abspath to file for storing tfbi solution across EBspeed grid.

_var_for_load_fromfile(varname_internal)

return var, suitably adjusted to pass into load_fromfile().

_vdist_loader()

load vdist.

Attributes

COLLISIONS_MODE_OPTIONS

COLLISION_TYPE_TO_VAR

CPU_SECONDS_PER_EACH_INFO

CROSS_TABLE_DEFAULTS

dict of {shorthand: (filename, fc)} with shorthand useable in self.set_collisions_crosstab.

E_un0_mode

mode for calculating E_un0, the electric field in the neutral frame, where u_n=0.

KNOWN_PATTERNS

KNOWN_PLOTTERS

KNOWN_SETTERS

KNOWN_VARS

SAM_DEFAULTS

TFBI_EXTRAS

TFBI_VARS

TIMESCALE_VARS

T_indim_only

whether to consider only components in maindims when getting T from Ta.

UNIQUE_PLOTTERS

array_MBmax

UNSET, None, or number

assert_masking

whether to assert self.masking != False and mask is not None, when getting values.

assign_behavior_attrs

whether to assign self.behavior values as attrs of result when calling self.

assign_behavior_attrs_max_call_depth

max call_depth at which to assign_behavior_attrs to result,

assign_behavior_attrs_skip_xr

whether to use include_xr=False if self.assign_behavior_attrs,

assign_component_along

alias to self.component_dim.assign_coord_along

assign_component_coord

alias to self.component_dim.assign_coord

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

assign_snap_along

alias to self.snap_dim.assign_coord_along

assign_snap_coord

alias to self.snap_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.

blur

alias to gaussian_filter

blur_dims

the dims over which to possibly apply blur (BlurLoader methods).

blur_sigma

the default sigma to use for blurring calculations.

cache_dirname

abspath to directory for containing cached values of this CachesLoader.

caches_behavior_skip_xr

where to skip array-valued behavior attrs when caching arrays (to _pc_caches)

call_depth

depth of the current call to self.

call_depth_manager

stores the value of call_depth, and helps to manage attrs dependent on call_depth value.

cls_behavior_attrs

collisions_cross_mapping

the collisions cross sections mapping to use.

collisions_mode

str, the collisions mode to use when getting nusj.

component

alias to self.component_dim.v

component_dim

component dimension for ComponentHaver.

component_is_iterable

alias to self.component_dim.is_iterable

component_list

alias to self.component_dim.list

component_type

alias to self.component_dim.get_type

components

alias to self.component_dim.values

coords_units

None or str telling the current unit system for coordinates, e.g. 'si'.

coords_units_explicit

str telling the current unit system for coordinates, e.g. 'si'.

cross

alias to cross_product

current_n_component

alias to self.component_dim.current_n

current_n_fluid

alias to self.fluid_dim.current_n

current_n_jfluid

alias to self.jfluid_dim.current_n

current_n_snap

alias to self.snap_dim.current_n

deriv_before_slice

bool or 'step'.

dimensions

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

dims

return dict of current values for dimensions in self.

direct_overrides

dict of {var: override} for all overrides of self which don't depend on behavior_attrs of self.

dirname

alias to self.input_deck.dirname

dot

alias to dot_product

drop

value of 'drop' kwarg for any self('{var}_where_{condition}') calls.

enable_fromfile

bool: whether self.load_fromfile is enabled during self.load_direct.

enumerate_component

alias to self.component_dim.enumerate

enumerate_components

alias to self.component_dim.enumerate_values

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

enumerate_snap

alias to self.snap_dim.enumerate

enumerate_snaps

alias to self.snap_dim.enumerate_values

extra_coords

dict of {coord_name: coord_value} to attach to outputs of self(var).

fft

alias to fftN

fft_dims

the dims over which to possibly apply fft (FFTLoader methods).

fft_half

alias to self.fft_slices.half

fft_keep

alias to self.fft_slices.keep

fft_slices

the dict of indexers to apply to all fft results from self, by default.

fft_step

alias to self.fft_slices.step

filename

alias to self.input_deck.filename

fluid

alias to self.fluid_dim.v

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

full_read_mode

full read_mode, including hdf_output_arrays information.

get

alias to __call__

get_space_coords

alias to get_maindims_coords

ifft

alias to ifftN

input_moments

moments from domain000/moments*.out files.

iter_component

alias to self.component_dim.iter

iter_components

alias to self.component_dim.iter_values

iter_components_partition

alias to self.component_dim.iter_partition

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

iter_snap

alias to self.snap_dim.iter

iter_snaps

alias to self.snap_dim.iter_values

iter_snaps_partition

alias to self.snap_dim.iter_partition

jfluid

alias to self.jfluid_dim.v

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_components

alias to self.component_dim.join_along

join_fluids

alias to self.fluid_dim.join_along

join_jfluids

alias to self.jfluid_dim.join_along

join_snaps

alias to self.snap_dim.join_along

known_pattern

known_plotter

known_setter

known_var

logfiles

alias to jobfiles

lowpass_keep

the default value for "keep" in self.lowpass.

maindims

maindims_full_shape

self.maindims_shape when self.slices=None

maindims_full_size

self.maindims_size when self.slices=None

maindims_full_sizes

self.maindims_sizes when self.slices=None

maindims_means

whether to immediately take means across maindims when loading arrays.

maindims_shape

tuple of (len(self.get_maindims_coords()[dim]) for dim in self.maindims).

maindims_size

product of terms in self.maindims_shape.

maindims_sizes

dict of {dim: size of dim} for dim in self.maindims.

maintaining

alias to maintaining_attrs

mask

None or xarray.DataArray of bools,

masking

how to apply self.mask to results at top level, if mask exists.

multi_slices

dict of {key: slices dict}.

multi_slices_ikeep

int or number between -1 < ikeep < 1

multi_slices_ndim

None or int

nGbytes

number of gigabytes across all files in self.dirname (and subdirectories).

nMbytes

number of megabytes across all files in self.dirname (and subdirectories).

nbytes

number of bytes across all files in self.dirname (and subdirectories)

ncoarse

int

ncpu

None or int

nnefrac_tiny_thresh

threshhold for where_nnefrac_tiny and where_nnefrac_significant.

nondim_behavior_attrs

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

notes_dirname

'abspath to directory containing plots/notes for a DirectLoader.

output_mask

whether to store_mask during xarray_mask calls if self.masking.

parenthesis_memory

polyfit_boundary

alias to self.polyfit_kw['boundary'].

polyfit_cov

alias to self.polyfit_kw['cov'].

polyfit_full

alias to self.polyfit_kw['full'].

polyfit_keep_coord

alias to self.polyfit_kw['keep_coord'].

polyfit_kw

kwargs to pass to self.polyfit(), other than array, coord, degree, and window.

polyfit_kw_key_aliases

polyfit_stddev

alias to self.polyfit_kw['stddev'].

polyfit_window

When polyfitting, tells window size to use for coarsening arrays before fitting.

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,

quasineutral

tells whether self is in quasineutral mode.

read_mode

mode telling which files to read.

sam_defaults

various defaults for sam's plotting.

set

alias to set_var

setvar

alias to set_var

setvars

VarCache of vars set via self.set_var().

slices

slices for maindims when loading arrays & during get_maindims_coords.

slicing

whether to slice maindims when loading arrays & during get_maindims_coords.

snap

alias to self.snap_dim.v

snap_dim

snap dimension for SnapHaver.

snap_is_iterable

alias to self.snap_dim.is_iterable

snap_list

alias to self.snap_dim.list

snap_type

alias to self.snap_dim.get_type

snapdir

directory containing the snapshot files.

snaps

alias to self.snap_dim.values

snaps_from

how existing self.snaps were determined.

stat_dims

the dims over which to possibly apply statistics (StatsLoader methods).

stats_dimpoint_wise

whether to apply stat calculations at each DimPoint, or after loading the full array.

subsampling_info

SubsamplingInfo telling how existing data was subsampled from prior data.

surelin_min_quantile

fraction of t_turb which tells start time of "definitely linear regime".

surelin_quantile

fraction of t_turb which tells t_surelin.

t_turb

None, or time of turbulent onset.

take_component

alias to self.component_dim.take

take_components

alias to self.component_dim.take_along

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

take_snap

alias to self.snap_dim.take

take_snaps

alias to self.snap_dim.take_along

tfbi_EBspeed_grid_size

(logmin, logmax, logstep) for self('tfbi_EBspeed_grid'); log is base 10.

tfbi_growth_thresh

threshold for confirming "yes there is tfbi growth predicted here", during self('tfbi_E_thresh').

timeout

None or int

title

title to help distinguish this calculator from others.

toplevel_scale_coords

dict of {coord_name: coord_scaling} to apply to top-level outputs of self(var).

typevar_crash_if_nan

bool.

u

the current units manager for self.

unique_notes_dirname

abspath to directory containing plots/notes for a DirectLoader,

units

the current unit system for self.

unset

alias to unset_var

using

alias to using_attrs

werrmath_require_std

whether to require 'std' data var appear in at least 1 input for all werrmath operations.

window

alias to polyfit_window

property CROSS_TABLE_DEFAULTS

dict of {shorthand: (filename, fc)} with shorthand useable in self.set_collisions_crosstab.

property E_un0_mode

mode for calculating E_un0, the electric field in the neutral frame, where u_n=0.

None, ‘un=u’, ‘un=0’, ‘E0_perpB’, ‘E0_perpmodB’, or ‘E0_perpmodB_min’.
None –> E_un0 = E + u_n x B. (i.e., E & u_n in “lab frame” then transform to u_n=0 frame.)
‘un=u’ –> E_un0 = E + u x B. (i.e., assume un==u; transform to the u=0 frame.)
[EFF] if self.has_var(‘E_u0’), use E_un0 = self(‘E_u0’) directly, without getting u;
assumes self(‘E_u0’) provides “E without the u x B contribution”.
If E_u0 not available, this mode requires ‘u’ to not vary with fluid.
‘un=0’ –> E_un0 = E. (i.e., assume un==0 already; no need to shift frames.)
‘E0_perpB’ –> E_un0 = E0_un0_perpB. (i.e., E perp to B in u_n=0 frame,
assuming zeroth order equilibrium velocities from multifluid equations,
including only collisions with neutrals,
and considering only E (& J) perp to B; ignoring E0 (& J) parallel to B.)
‘E0_perpmodB’ –> |E_un0 perp to B| = E0_un0_perpmodB (== |E0_un0_perpB|). E_un0 = E0_un0_perpB.
[EFF] equivalent to using E0_perpB, except that, when getting |E_un0 perp to B|,
will use the more efficient formula for E0_un0_perpmodB.
‘E0_perpmodB_min’ –> |E_un0 perp to B| = E0_un0_perpmodB_min. E_un0 = crash; cannot get E_un0 directly.
(i.e., minimum possible value of |E_un0 perp to B|, regardless of collision frequencies;
E0_un0_perpmodB_min = (1/sqrt(2)) * |B| |J_perp_B| / (ne |qe|).
See help(self.get_E0_un0_perpmodB_min) for details.)
property T_indim_only

whether to consider only components in maindims when getting T from Ta.

Irrelevant in 3D; 3D always has self(‘T’) == sqrt((1/3)*(Ta_x^2 + Ta_y^2 + Ta_z^2)).
In 2D x-y sim, True –> self(‘T’) == self(‘T_indim’) == sqrt((1/2)*(Ta_x^2 + Ta_y^2)).
2D & False –> self(‘T’) = same formula as in 3D sim.
_T_neutral_loader()

load T for neutrals. Helper function for self._get_T_neutral.

gets T from vth and m. vth = sqrt(kB * T / m) –> T = m * vth^2 / (kB)
__call__(var, *args, name=UNSET, item=False, verbose=UNSET, **kw)

returns value of var from self.

result is probably an xarray.DataArray, but not guaranteed.
var: str or iterable of strs.
Name of the var(s) to load. E.g. ‘n’ for number density, or [‘n’, ‘u’] for number density & velocity.
If multiple vars: returns an xarray.Dataset of all vars, via self.get_vars.

Determine how to load each var, as follows:
- (caching) if var in self.cache, with matching self.behavior_attrs, use value from cache.
[TODO] - caching not yet implemented. May allow for better efficiency.
- (setvars) if var in self.setvars, with matching self.behavior_attrs, use value from setvars.
[TODO] - improve set_var functionality.
set_var will allow user to apply PlasmaCalcs calculations to arbitrary values,
not just values from one of the hookups. Useful for testing & quick calculations.
- (KNOWN_VARS) if var in self.KNOWN_VARS,
use the corresponding function to get it.
- (KNOWN_PATTERNS) if var matches a pattern from self.KNOWN_PATTERNS,
use the corresponding function to get it.
- (direct) attempt to load var “directly”, via self.load_direct.
load_direct will almost always end up loading values directly from a file (e.g., “data”).
However, there is one more chance for it to get intercepted: via direct_overrides.
- (direct_overrides) if var in self.direct_overrides, attempts self.direct_overrides[var].
The idea is to use direct_overrides when requiring alternate instructions for
what would otherwise be a “base” var.
E.g., ‘n’ may be a “base” var, but if quasineutral then ‘ne’ is not saved in a file;
so, base_overrides[<key for density>] may tell how to get ‘ne’.
Note: for overrides which depend on current state, use direct_overrides_dynamic.
For overrides which are “always” implemented (not toggled by other things), use direct_overrides.
- (fromfile) load_direct uses self.load_fromfile whenever direct_overrides is not applicable.

Those are checked in the order listed.
If none of those work, raise FormulaMissingError.
name: UNSET, None, or str
try to set result.name = name.
UNSET –> use name = var.
item: bool
if True, convert result to single value (e.g., python float) via result.item().
This will cause crash if result is not a single value;
it will also cause all metadata stored in the result to be lost.
verbose: UNSET, bool, or int
set self.verbose during this call to self.
UNSET –> use self.verbose (unchanged)
kw may additionally contain any keys from self.kw_call_options().
if it does, pop those values, and temporarily set the corresponding attr.
E.g.: self(‘n’, units=’si’, fluid=1)
–> temporarily set units=’si’, fluid=1, while getting ‘n’.
See self.help_call_options() for more details.
[EFF] passes _match=re.fullmatch(pattern, var) to the getter function,
if the match is from KNOWN_PATTERNS (but not if it is from KNOWN_VARS).
__getitem__(snapi)

sets self.snap, then returns self.

Examples:
self[4] –> self.snap = 4
self[:5] –> self.snap = slice(0, 5)
self[-1] –> self.snap = -1
self[‘2’] –> self.snap = ‘2’
self[self.snaps[7]] –> self.snap = self.snaps[7]
self[[0,4,7,3]] –> self.snap = [0,4,7,3]
Note this is ‘smart’ in the same way that setting self.snap is ‘smart’;
will attempt self.snaps.get(snapi).
See help(self.snaps.get) for more details.
This enables “shorthand” syntax, e.g. self[3](‘n’) gets ‘n’ at self.snap=3.
__getstate__()

return state for pickling. pickle default ignores class attr (parenthesis_memory) but we need it.

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

equivalent to self.iter_snaps()

__len__()

equivalent to len(self.snaps)

__setstate__(state)

set state for pickling. pickle default ignores class attr (parenthesis_memory) but we need it.

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.

_apply_maindims_slices_to_dict(d)

slice entries in dict using self.slices. returns d. (Note: d will be directly altered.)

_apply_subsampling_to_maindims_coords(coords)

apply subsampling to maindims coords.

coords is a dict of {‘x’: xcoords, ‘y’: ycoords} possibly also ‘z’: zcoords.
[TODO] check that vars actually all have the same maindims, else, crash?
implementation now just assumes ‘den0’ exists and has same maindims as other vars.
_apply_subsampling_to_vdist_coords(vcoords, fluid)

apply subsampling to vdist coords for this fluid (a single Fluid)

_apply_toplevel_scale_coords(arr)

apply self.toplevel_scale_coords to arr, if nonempty, else return arr unchanged.

_array_compatible_with_current_behavior(array, *, return_info=False)

returns whether array is compatible with current self.behavior.

Compatible if all of the following are true:

(1) All attrs appearing in array.attrs & self.behavior must be equal.
E.g., if ‘units’ in both, need array.attrs[‘units’] == self.behavior[‘units’].
(2) All attrs appearing in self.behavior.nondefault(include_xr=False) must appear in array.attrs.
E.g., if ‘blur_sigma’ in self.behavior.nondefault(), need ‘blur_sigma’ in array.attrs.
(3) [TODO] If self.behavior.nondefault(include_xr=’only’) has any values,
they must match values saved to arrays in os.path.join(array.attrs[‘filepath’], ‘behavior_arrays’)
E.g., if ‘tfbi_grid1_zeros’ appears, need self.behavior[‘tfbi_grid1_zeros’].equals(behavarr),
where behavarr = xarray_load(… the array at ‘behavior_arrays/tfbi_grid1_zeros.pcxarr’))
[TODO] currently, caching behavior array values is not implemented;
see type(self).caches_behavior_skip_xr for details.
(4) All appearing in array and self.behavior.dims must be equal.
E.g., if ‘fluid’ in both, need array_equal(array[‘fluid’].values, self.behavior.dims[‘fluid’])
(5) If array.attrs has ‘pc__version__’ and/or ‘pc__commit_hash’,
they must match the current PlasmaCalcs version and commit hash, if known.
return_info: bool
whether to instead return (result, reason of mismatch, key, array value, behavior value).
(reason will be ‘version’, ‘attrs’, ‘dims’, or ‘array_attrs’)
(if result is True, all other values are None)
_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_array_compatible_with_current_behavior(array)

assert that array is compatible with current self.behavior.

(if not, crash with CacheNotApplicableError)
_assert_cache_array_not_too_big(array)

checks that array is not too big for caching. If too big, crash with MemorySizeError.

_battrs_for_set_var_internal(behavior_attrs, forall=[], *, ukey=None)

returns behavior_attrs which will be used by set_var_internal, given these inputs.

see help(self.set_var_internal) for details.
_battrs_for_unset_var_internal(behavior_attrs, forall=[], *, ukey=None)

returns behavior_attrs which will be used by unset_var_internal, given these inputs.

see help(self.unset_var_internal) for details.
_braced_int_dep(_var, groups)

returns the ‘dep’ associated with this var for _get_braced_int_from_parenthesis_memory

_cache_dst(array_or_name)

return abspath for cached array, given array (or name of array).

(if DataArray, uses array.name; if Dataset, must provide name as str instead.)
result will include .pcxarr extension.
if inferred name includes ‘/’, crash (and suggest to use ÷ character instead).
_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)

_call_postprocess(result, *, var, name=UNSET, item=UNSET)

postprocess result from self.__call__. Called during self.__call__.

(self.call_depth inside here will tell depth of the current call; depth=1 for top level.)
result: any value, probably an xarray.DataArray
result from self.__call__, before postprocessing.
var, name, item: UNSET or value
passed directly from self.__call__.
The implementation here does the following (subclasses might override / add to this):
(1) if self.verbose >= 4, print a message about getting var.
(2) result = self.attach_extra_coords(result).
(3) if name was provided, set result.name = name, if possible.
(4) if self.assign_behavior_attrs at this call depth, do so now.
(5) if self.call_depth == 1, call self._call_postprocess_toplevel.
(6) if item, convert result to single value via result.item().
_call_postprocess_toplevel(result, *, var, name=UNSET, item=UNSET)

additional postprocessing for self.__call__ when call_depth=1.

called from self._call_postprocess, after doing other postprocessing, when call_depth=1.
result: any value, probably an xarray.DataArray
result from self.__call__, after other postprocessing.
var, name, item: UNSET or value
passed directly from self.__call__.
Don’t need to handle these here because self._call_postprocess will handle it.
The implementation here applies masking, if applicable.
see help(type(self).mask)
_check_files_readable()

check that all files in self.dirname are readable (checks recursively inside directories too).

return number of files checked, number of files readable, and number of files not readable.
print exceptions along the way if any files are not readable!
_default_cache_dirname()

default for self.cache_dirname.

{self.dirname}/_pc_caches if self.dirname exists, else raise InputMissingError.
_default_cross_mapping()

return default CrossMapping object to use as self.collisions_cross_mapping.

Called when accessing self.collisions_cross_mapping when no value has been set yet.
_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_sam_defaults()

returns a copy of self.SAM_DEFAULTS.

Uses a somewhat hacky deepcopy for dicts - copies down 1 layer of dicts.
E.g. ec.sam_defaults[‘fft_calcs’] is a copy of ec.SAM_DEFAULTS[‘fft_calcs’],
but ec.sam_defaults[‘sometimes_style’][‘title_kw’] is the same object
as ec.SAM_DEFAULTS[‘sometimes_style’][‘title_kw’], so, e.g.,
ec.sam_defaults[‘sometimes_style’][‘title_kw’][‘fontsize’] = ‘large’
would affect all instances, while
ec.sam_defaults[‘sometimes_style’][‘title_kw’] = {‘fontsize’: ‘large’}
would affect only the current instance, ec.
_default_subsampling_info()

default value for self.subsampling_info: load from {self.dirname}/subsampling_info.

_default_timeout()

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

_default_title()

default title for self. Here, just returns os.path.basename(self.notes_dirname)

_delete_cache_dst_if_exists(dst)

delete dst, if it exists, but first ensure it contains ‘_pc_caches’ in the path.

Never deletes files which don’t contain ‘_pc_caches’ in the path.
_extra_coords_with_title()

return self.extra_coords with {‘title’: repr(self.title)} added,

if self.title exists and ‘title’ not in self.extra_coords yet.
else, just return self.extra_coords.
_fft_slices_cls

alias of FFTSlices

_fluid_is_neutral()

returns True if self.fluid is neutral (either one neutral or multiple).

True if self.fluid is an EppicNeutral, or iterable with only EppicNeutrals.
_get_T_neutral()

get the temperature of self.fluid when it is an EppicNeutral or EppicNeutralList.

_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), results are unspecified.
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’.
_get_maybe_missing_var(var, *args, missing_vars=UNSET, **kw)

return value of var, or None if FormulaMissingError and missing_vars ‘ignore’ or ‘warn’.

missing_vars: UNSET, ‘ignore’, ‘warn’, or ‘raise’
what to do if any var causes FormulaMissingError.
UNSET –> use self.missing_vars if it exists, else ‘raise’.
‘ignore’ –> return None.
‘warn’ –> return None, but also print a warning.
‘raise’ –> raise FormulaMissingError.
_get_n_neutral()

get the number density of self.fluid when it is an EppicNeutral or EppicNeutralList.

(Or, crash with a helpful FormulaMissingError error message.)
_get_stat_var(var, statfunc)

returns result of applying statfunc to self(var), possibly one dimpoint at a time then joining results.

see help(type(self).stats_dimpoint_wise) for details.
_get_stat_var_dimpoint_wise_false(var, statfunc)

returns result of applying statfunc to self(var). (Used when self.stats_dimpoint_wise=False.)

_get_stat_var_dimpoint_wise_true(var, statfunc, min_split=UNSET)

returns result of applying statfunc to self(var). (Used when self.stats_dimpoint_wise=True.)

min_split: UNSET or int
[EFF] min length of dimension before actually applying dimpointwise stats along it.
1 –> no minimum. If MemorySizeError when min_split > 1, try again but with min_split=1.
UNSET –> use DEFAULTS.STATS_DIMPOINT_WISE_MIN_SPLIT.
_get_statfunc_of_var(var, statfunc)

load this stat, for self(var).

_get_subsampling_step(x, var='den0')

get subsampling step for var along this direction.

Crash with SubsamplingFormatError if subsampling mode for var exists but is not ‘slice’.
_h5_2_directly_loadable_vars(*, snap=None)

return tuple of directly loadable variables, for read_mode=’h5_2’.

_h5_2_filename(*, snap=None)

return name of file from which to load values, for read_mode=’h5_2’.

snap: None, str, int, or Snap
the snapshot number to load.
if None, use self.snap.
_h5_2_load_fromfile(fromfile_var, *args__None, snap=None, **kw__None)

return numpy array of var, loaded directly from file, using “h5_2” read_mode.

This corresponds to h5 read mode with hdf_output_arrays=2.
fromfile_var: str
the name of the variable as stored in the snapshot.
snap: None, str, int, or Snap
the snapshot number to load.
if None, use self.snap.
Example:
fromfile_var=’fluxx1’, snap=7
–> h5py.File(‘parallel/parallel000007.h5’)[‘fluxx1’][:]
_handle_missing_collisions_crosstab()

handles the case of a missing collisions cross table between self.fluid & self.jfluid.

depending on self.collisions_mode, this either returns 0, or raises a QuantInfoMissingError
see self.COLLISIONS_MODE_OPTIONS for details.
_handle_typevar_nan(*, errmsg='')

crash with TypevarNanError if self.typevar_crash_if_nan, else return ‘nan’.

if crashing, use error message:
errmsg + “nTo return ‘nan’ instead of crashing, set self.typevar_crash_if_nan=False.”
classmethod _help_matches(qstr, k, v)

returns whether qstr matches k or v, and thus should be displayed during self.help(qstr).

qstr: str
the str to match; from self.help(qstr)
k: varname
the varname to test for matches.
key from self.KNOWN_VARS.keys(), or key.str from self.KNOWN_PATTERNS.keys().
v: LoadableQuantity
the LoadableQuantity to test for matches.
value from self.KNOWN_VARS.values() or self.KNOWN_PATTERNS.values().
matches if any of these are true:
qstr == ‘’
qstr in k.split(‘_’) # size limitation and split(‘_’) because, e.g. during help(‘n’),
len(qstr)>=3 and qstr in k # want vars related to number density, not all vars with the letter ‘n’.
qstr in module.split(‘.’) (where, module == v.get_f_module(cls))
‘.’ in qstr and qstr in module
len(qstr)>=3 and qstr in value from module.split(‘.’)
len(qstr)>=3 and qstr in v.fname
re.fullmatch(k, qstr) # if k is a Pattern
otherwise, does not match.
_increment_call_depth()

context manager for incrementing call_depth.

use “with self._increment_call_depth():” inside of __call__, e.g.:

def __call__(self, *args, **kw):
with self._increment_call_depth():
# do stuff; possibly including calling self again.
Equivalent to self.call_depth_manager.increment()
_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.

_load_maindims_var_with_labels(var, *args, **kw)

equivalent to self.load_maindims_var(var, *args, assign_labels=True, **kw)

_load_maindims_var_without_labels(var, *args, **kw)

equivalent to self.load_maindims_var(var, *args, assign_labels=False, **kw)

_load_moment(eppic_var, *args__None, snap=UNSET, **kw__None)

load moment indicated by eppic_var. (e.g. ‘moment3x0’ –> moment 3, component x, fluid 0).

Units will be the same units as the moments.out files (raw units).
eppic_var: str
should match full_pattern=’moment([1234])([xyz])(d+)’, or partial_pattern=’moment([1234])’
matches full_pattern –>
([1234]) indices moment number (1,2,3,4),
([xyz]) indicates component (x, y, z),
(d+) indicates distribution number (any integer).
matches partial_pattern –>
try to match full_pattern using eppic_var=self._var_for_load_fromfile(eppic_var) instead.
(_var_for_load_fromfile appends x and N, if self._loading_component & self._loading_fluid)
match not found –>
raise LoadingNotImplementedError
match found but no associated value in moments data –>
raise ValueLoadingError
snap: UNSET, None, or any indicator of any number of snaps
if provided, return value at this snap, else return value at self.snap.
if snap indicates multiple values, result will be a list of values.
_loadable_moments()

tells eppic_var variable names of loadable moments.

_multi_slices_cls

alias of MultiSlices

_multi_slices_dims_default()

function to get multi_slices dims, by default.

Would love to use (lambda: self.maindims) instead of this function,
however lambdas are not pickleable, thus incompatible with multiprocessing module.
Providing this function allows the default multi_slices to still be pickleable.
_new_fft_slices()

Called when self.fft_slices accessed but not yet set; create & return new FFTSlices.

_new_multi_slices(**kw)

called when self.multi_slices accessed but not yet set; create & return new MultiSlices.

_openpmd_directly_loadable_vars(*, snap=None)

return tuple of directly loadable variables, for read_mode=’openpmd’.

_openpmd_load_fromfile(eppic_var, *args__None, snap=None, **kw__None)

return numpy array of var, loaded directly from file, using “openpmd” read_mode.

This corresponds to openpmd read mode.
eppic_var: str
the name of the variable as stored in the snapshot.
snap: None, str, int, or Snap
the snapshot number to load.
if None, use self.snap.
Example:
eppic_var=’fluxx1’, snap=7
–> zarr.open(‘data/000007/fields/fluid_2/fluxx1’)
classmethod _parenthesis_converted_var(before, here, after)

returns the var after converting it from var like ‘{before}({here}){after}’.

use same before & after, but use {i} instead of here.
Looks like: f’{before}{{{key}}}{after}’ where key=int, unique to this var.
_parenthesis_dep(_var, groups)

returns the ‘dep’ associated with this var for get_parenthesis.

_pop_kw_call_options(kw)

pop all self.kw_call_options() from kw, returning dict of popped options.

_pre_and_post_deriv_slices(x)

return slices to apply before & after differentiation. (result is a 2-tuple of dicts.)

x: str, or list of str.
only slices relevant to these dimensions will be adjusted.
(e.g. there’s no need to touch ‘y’ slices during ddx.)
Result depends primarily on self.deriv_before_slice.
Note if self.deriv_before_slice=False, this method just returns (self.slices, {}).
_print_or_warn(msg, debug_thresh=1)

if DEBUG>=debug_thresh, print msg. Else, warnings.warn(msg).

_provided_val(var, _val=None, _known_vals={})

returns the value of var, either from _known_vals or _val.

if _val provided, return it; if ‘_{var}’ in _known_vals, return it;
if both provided, crash with InputConflictError (unless they are the same object),
else, return None.
Can use this internally to avoid redundant recalculations. (See e.g. VectorArithmeticLoader)
_qn_direct_den0()

gets den0 in quasineutral case.

_read_all_moments()

read all moments; return result. See help(type(self).input_moments) for more details.

_repr_contents()

return list of strings to use inside self.__repr__

_sam_timeline_defaults(*, title=True)

sets sam’s defaults for timelines plots.

calls plt.grid(), and plt.title(ec.title).
_set_collisions_crosstab_defaults_from(mode='bruno', *, e=None, H_I=None, H_II=None, He_I=None, He_II=None, He_III=None, crossmap=None)

set as many CROSS_TABLE_DEFAULTS cross sections as possible, for provided fluids.

see also: self.set_collisions_crosstab_defaults - it provides relevant fluids from self.
e.g. if provided e, H_I, H_II, He_II, would set:
crossmap[e, H_I] = ‘e-h’
crossmap[H_II, H_I] = ‘h-p’
crossmap[He_II, H_I] = ‘h-he’
crossmap[H_I, H_I] = ‘h-h’
if provided more fluids, would set more crossmaps too.
see self.CROSS_TABLE_DEFAULTS for list of available defaults.
mode: ‘bruno’ or ‘vranjes’
tells which defaults to use. (bruno is probably more accurate than vranjes.)
e, H_I, H_II, He_I, He_II, He_III: None, Fluid, int, str, or other fluid specifier.
specifiers for electrons, H(neutral), H+, He(neutral), He+, He++ fluids.
None –> do not set default cross tables related to this fluid.
else –> will find corresponding Fluid value in self.fluids or self.jfluids.
crossmap: None or CrossMapping
if provided, set values in crossmap instead of in self.collisions_cross_mapping.
_slice_maindims_numpy(array, *, h5=False)

slice first len(maindims) dims of array, using self.slices.

h5: bool
whether ‘array’ might be an h5py dataset.
if True, handle negative step in the intuitive way;
i.e. slice with positive step, to select the expected points, then reverse order.
(This is necessary because h5 datasets crash when sliced by negative step…)
_slices_which_scalarize()

return list of maindims which become scalars when hit by self.slices.

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

returns expected abspath to file for storing tfbi solution across EBspeed grid.

Depends on current value of self.tfbi_EBspeed_grid_size.
Does not check whether file exists already
(might use this to find existing file, or to determine filepath for saving result.)
Result is like:
{self.unique_notes_dirname}/_pc_tfbi/EBspeed_{logmin:.4g}_{logmax:.4g}_{logstep:.4g}.pcxarr
_var_for_load_fromfile(varname_internal)

return var, suitably adjusted to pass into load_fromfile().

Here:
append self.component if self._loading_component
append self.fluid.N if self._loading_fluid
E.g. ‘flux’ turns into ‘fluxz2’ when loading ‘z’ component and fluid 2.
_vdist_loader()

load vdist. Helper function for self.get_vdist.

static angle_xy(A)

return angle between +xhat and A, in the xy plane, in radians.

A should be a DataArray (or Dataset) with x and y in ‘component’ dimension.
A can be any vector (does not need to be a unit vector, but it can be.)
static angle_xy_to_hat(A)

return unit vector u, given angle [radians] between +xhat and u in the xy plane.

Equivalent: cos(A) * xhat + sin(A) * yhat.
apply_mask(arr, masking=UNSET)

apply self.mask to arr, using self.masking to determine masking.

arr must have dims from self.mask.dims.
masking: UNSET, bool, ‘stacked’, or ‘simple’
UNSET –> use self.masking.
True –> alias for ‘stacked’
‘stacked’ –> apply stacked mask to self.stack(arr), dropping masked points.
‘simple’ –> apply mask to arr, filling masked regions with np.nan.
will crash with ValueError if masking corresponds to False, or if self.mask is None.
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})
assert_QN()

asserts self.quasineutral. if not self._assert_QN, instead does not assert self.quasineutral.

property assert_masking

whether to assert self.masking != False and mask is not None, when getting values.

property assign_behavior_attrs

whether to assign self.behavior values as attrs of result when calling self.

False –> don’t use self.behavior code architecture to assign attrs.
True –> equivalent to ‘nondefault’
‘nondefault’ –> self.behavior.assign_nondefault_attrs(result)
(for brevity, it does not assign behavior attrs with “default” value.)
‘all’ –> self.behavior.assign_attrs(result).
[EFF] only assigns attrs at call_depth >= self.assign_behavior_attrs_max_call_depth.
(default: only assigns attrs at call_depth=1, i.e. at top level.
property assign_behavior_attrs_max_call_depth

max call_depth at which to assign_behavior_attrs to result,

if self.assign_behavior_attrs indicates to assign behavior attrs.
default 1, i.e. only assign if at top level.
Use None to indicate “no max detph”.
property assign_behavior_attrs_skip_xr

whether to use include_xr=False if self.assign_behavior_attrs,

during self.behavior.assign_nondefault_attrs.
Use this if you want to assign behavior attrs EXCEPT array-valued behavior attrs.
property assign_component_along

alias to self.component_dim.assign_coord_along

property assign_component_coord

alias to self.component_dim.assign_coord

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

assign_maindims_coords(array)

assign maindims dims and coords, based on self.get_maindims_coords() with slicing=False.

array must have same shape as implied by maindims and coords.
if array is 0D, just return a 0D xr.DataArray.
returns an xarray with proper details for PlasmaCalcs.
This function creates a *new* xarray based on array, and maindims & coords are >0 dimensional.
This is not like assign_{dim}_coord functions, which assign 0D coord to an existing xarray.
property assign_snap_along

alias to self.snap_dim.assign_coord_along

property assign_snap_coord

alias to self.snap_dim.assign_coord

assign_velocity_coords(array, fluid=UNSET)

assign velocity dims and coords, based on fluid.get_velocity_coords().

E.g., for “vdist” data. Array shape and coords inferred from input deck.
(If subsampling_info exists, that will also be applied appropriately.)
returns an xarray with proper details for PlasmaCalcs. Output units according to self.units.
This is not like the assign_{dim}_coord functions, which assign 0D coord to an existing xarray;
this method creates a *new* xarray based on array, and velocity dims & coords are >0 dimensional.
array: 3D array
probably the “vdist” data, e.g. directly from reading output data from one snapshot.
fluid: UNSET, int, str, Fluid, or other way to specify a single fluid.
UNSET –> use self.fluid.
else –> temporarily set self.fluid = fluid, during this operation.
attach_extra_coords(arr)

attach any self.extra_coords to array arr but only if it is an xarray.DataArray or xarray.Dataset

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.
property blur

alias to gaussian_filter

property blur_dims

the dims over which to possibly apply blur (BlurLoader methods).

will only blur along these dims for an array if they actually appear in the array.
None –> use self.maindims. (this is the default.)
property blur_sigma

the default sigma to use for blurring calculations.

None –> use DEFAULTS.GAUSSIAN_FILTER_SIGMA (default: 1.0)
property cache_dirname

abspath to directory for containing cached values of this CachesLoader.

Default: {self.dirname}/_pc_caches if self.dirname exists, else raise InputMissingError. Caution: PlasmaCalcs may delete files with ‘_pc_caches’ in their path, without warning.

property caches_behavior_skip_xr

where to skip array-valued behavior attrs when caching arrays (to _pc_caches)

and when checking compatibility with already-cached arrays (in _pc_caches).

CAUTION: if True, might give subtly incorrect results if the relevant array-valued behavior attrs change.

Eventually, caching should save array-valued attrs too, but it’s trickier so this is a workaround for now.
property call_depth

depth of the current call to self. depth = number of calls to self from within self.

E.g., call_depth while calculating gyrofrequency:

# call_depth == 0, for any code run here (outside any call to self).
self(‘gyrof’)
# call_depth == 1, for any code run here (inside ‘gyrof’ call but not inside deeper calls).
q = self(‘q’)
# call_depth == 2, for code inside ‘q’ call.
mod_B = self(‘mod_B’)
# call_depth == 2, for code inside ‘mod_B’ call.
self(‘B’)
# call_depth == 3, for code inside ‘B’ call.
m = self(‘m’)
# call_depth == 2, for code inside ‘m’ call.
result = q * mod_B / m
Cannot be set directly; can only be manipulated via self.call_depth_manager.
property call_depth_manager

stores the value of call_depth, and helps to manage attrs dependent on call_depth value.

check_pickle(x=None)

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

Returns result of unpickling. Useful for debugging.
choose_params(**kw_init)

returns EppicChooseParams based on self.

Common usage:

# write a new eppic.i file based on the eppic.i file in self.dirname,
# and using the current values of params from self.
self.choose_params().write(dst=’eppic_updated.i’)
uses self.dirname and self.get_vals_for_inputs().
kwargs go to EppicChooseParams.__init__
clock_times()

return dict of clock times from this run. (From reading self.jobfiles.)

Result can have keys:
‘start’: datetime telling when the run started.
‘stepstart’: datetime telling when the iterations started.
‘end’: datetime telling when the run ended.
‘init_seconds’: (stepstart - start) [seconds]
‘steps_seconds’: (end - stepstart) [seconds]
‘total_seconds’: (end - start) [seconds]
If jobfile missing any info, relevant keys will not appear in result.
classmethod cls_help(qstr=None, only=None, *, tree=None, modules=False, signature=False, doc=True, dense=False, print=True, **kw)

prints str for help with quants. Fails for any quants which depend on present values of a cls instance.

qstr: None or str
None –> tells info about this class & how to use this function.
in particular, tells that quants are stored cls.KNOWN_VARS and cls.KNOWN_PATTERNS,
and describes behavior of calling help with a string.
str –> return str for help with all quants related to str.
use empty str to get help for all quants.
only: None or str
If provided, only get help for a subset of relevant quantities.
None –> get help with all quantities related to qstr.
‘VARS’ –> only get help with KNOWN_VARS.
‘PATTERNS’ –> only get help with KNOWN_PATTERNS.
‘TREE’ –> only get help with quantities in cls.cls_var_tree(str).
‘EXACT’ –> only get help for the KNOWN_VAR exactly matching qstr.
if provided when qstr is None, treat qstr as ‘’ instead.
tree: None or bool
How much help to give for quantities in cls.cls_var_tree(qstr).
False –> don’t even check cls.cls_var_tree(qstr).
True –> help for all quantities in cls.cls_var_tree.
None –> help for quantities in cls.cls_var_tree(qstr).flat_branches_until_vars()
i.e. patterns & vars in tree but ignore any nodes with LoadableVar ancestors.
e.g. qstr=’mean_mod_beta’ –> help with ‘mean_(.+)’, ‘mod_(.+)’, and ‘beta’,
but no help with dependencies of ‘beta’ (‘q’, ‘mod_B’, ‘m’).
modules: bool
Whether to include modules in result.
If True, result will be grouped into sections with modules written at top.
signature: signature: bool
whether to include line with signature in help string.
e.g. “help_str(f, *, module=True, signature=True, indent=None)”
doc: doc: bool
whether to include lines with docstring in help string.
e.g. “return str for help(f).” … and all the other docs in here.
dense: bool
Whether to reduce whitespace in result.
E.g. True –> no newlines between functions. False –> one newline between functions.
print: bool
whether to print the result. If False, return the result instead of printing.
classmethod cls_var_tree(var, *, missing_ok=False)

return QuantTree of MatchedQuantity objects from matching var and all dependencies,

using self.KNOWN_VARS and self.KNOWN_PATTERNS when searching for matches.
missing_ok: bool
whether to be lenient sometimes when missing details that would allow to fully determine deps.
see help(MatchedQuantity.dep_vars) for more details.
property collisions_cross_mapping

the collisions cross sections mapping to use.

keys are (fluid1, fluid2) pairs; values are CrossTable objects.
see self.CROSS_TABLE_DEFAULTS for shorthand options for values.
for convenient methods to build the cross mapping, see:
self.set_collisions_crosstab, self.set_collisions_crosstab_defaults.
property collisions_mode

str, the collisions mode to use when getting nusj. See COLLISIONS_MODE_OPTIONS for details.

Note that you can always calculate collisions using a specific formula with the appropriate var,
regardless of collisions_mode; e.g., nusj_maxwell will always use maxwell formula.
property component

alias to self.component_dim.v

property component_dim

component dimension for ComponentHaver.

component_dim_cls

alias of ComponentDimension

property component_is_iterable

alias to self.component_dim.is_iterable

property component_list

alias to self.component_dim.list

property component_type

alias to self.component_dim.get_type

property components

alias to self.component_dim.values

property coords_units

None or str telling the current unit system for coordinates, e.g. ‘si’.

None –> “coords_units should match self.units”.
Value stored at self.u.alts.get(‘coords’, None)
See also: coords_units_explicit
property coords_units_explicit

str telling the current unit system for coordinates, e.g. ‘si’.

alias to self.coords_units if not None, else self.units.
equivalent: self.u.alts.get(‘coords’, self.units)
copy()

returns a deep copy of self.

[TODO] implement something less hacky than using the pickle module?
property cross

alias to cross_product

static cross_component(A, B, x, *, yz=None, missing_ok=False)

return x component of A cross B, given A and B which have values for y and z ‘component’.

x: int, str, or Component
tells component (of result) to get. if int or str, use XYZ.get(x)
A, B: xarray.DataArray
vectors to take cross product of.
must include ‘component’ dimension including coordinates y and z.
yz: None or iterable of two (int, str, or Component) objects
the other two components; (x,y,z) should form a right-handed coordinate system.
if not provided, infer from x.
missing_ok: bool, default False
whether it is okay for ‘component’ dimension to be missing y or z components, of A or B.
if True, treat any missing components as 0.
cross_components_needed()

return the components vectors need in order to find all cross product components in self.component_list

e.g. if self.component == ‘x’, return (‘y’, ‘z’), because (A_cross_B)_x needs Ay, Az, By, Bz but not Ax, Bx.
cross_mapping_type

alias of CrossMapping

static cross_product(A, B, *, components=None)

return cross product of vectors A and B, along dimension ‘component’.

If A or B missing any components, treat them as 0.
components: None or iterable of component specifiers (int, str, or Component)
tells which components to get.
None –> get all components (XYZ)
e.g., (0, ‘z’) –> get component 0 and component ‘z’, i.e. X and Z.
curl_component(v, x, *, yz=None)

return x component of curl(v).

v: xarray.DataArray
vector to take curl of.
spatial derivatives will apply to dimensions (‘x’, ‘y’, ‘z’) (if they exist, else give 0).
must include ‘components’ dimension including coordinates y and z.
x: int, str, or Component
tells component to get. if int or str, use self.components to get corresponding Component
yz: None or iterable of two (int, str, or Component) objects
the other two components; (x,y,z) should form a right-handed coordinate system.
if not provided, infer from x.
property current_n_component

alias to self.component_dim.current_n

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

returns number of existing snaps, out of all snaps at self.snap.

Equivalent to self.snap_dim.current_n_existing_for(self).
property current_n_fluid

alias to self.fluid_dim.current_n

property current_n_jfluid

alias to self.jfluid_dim.current_n

property current_n_snap

alias to self.snap_dim.current_n

property deriv_before_slice

bool or ‘step’. Whether to apply derivatives before any maindims slicing.

see help(type(self).slices) for slicing details.
True –> get derivatives before applying slices.
E.g. if slices=dict(x=slice(10, 30, 4)), getting ddx_var,
would compute var across the entire domain, then ddx, then slice by x[10:30:4].
This mode is most computationally expensive, but derivatives are trustworthy everywhere.
‘step’ –> get derivatives before slicing step, but after slicing start & stop.
E.g. if slices=dict(x=slice(10, 30, 4)), getting ddx_var,
would compute var from x[10] to x[30], then ddx, then slice by x[::4].

Note: if slicing by non-slice (e.g. x=5, or y=[0, 7, 10]), apply slicing afterwards.

This mode balances computational cost and trustworthiness;
derivatives are trustworthy everywhere except near slices’ start & stop.
False –> get derivatives after applying slices.
E.g. if slices=dict(x=slice(10, 30, 4)), getting ddx_var,
would compute var from x[10:30:4], then ddx.
This mode is computationally cheapest, but derivatives are least trustworthy.
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
property direct_overrides

dict of {var: override} for all overrides of self which don’t depend on behavior_attrs of self.

For example, if user wants to set an override (or if setvars sets an override?), it will be here.
See also: self.direct_overrides_dynamic().
direct_overrides_dynamic()

returns dict of {var: override} for all overrides of self which depend on behavior_attrs of self.

directly_loadable_vars(snap=None)

return tuple of directly loadable variables.

These are the variables that can be loaded directly from a file,
using the current full_read_mode.
snap: None, str, int, or Snap
the snapshot number to load. if None, use self.snap.
property dirname

alias to self.input_deck.dirname

property dot

alias to dot_product

static dot_product(A, B)

return dot product of vectors A and B, assuming vector components along the dimension ‘component’.

property drop

value of ‘drop’ kwarg for any self(‘{var}_where_{condition}’) calls.

True –> drops points where condition is False. (See xarray.DataArray.where for details)
False –> use nan where condition is False.
default: UNSET –> True if self(‘condition’) has ndim==1, else False.
(easy when ndim==1 to drop nans, because condition is a 1D list of points.
hard when ndim>=2. E.g. if mask (x,y)=(0,0) but not (0,1) and (1,0), can’t drop x=0 nor y=0…)
property enable_fromfile

bool: whether self.load_fromfile is enabled during self.load_direct.

If False, raise QuantCalcError if load_direct can’t get value without load_fromfile().
property enumerate_component

alias to self.component_dim.enumerate

property enumerate_components

alias to self.component_dim.enumerate_values

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 enumerate_snap

alias to self.snap_dim.enumerate

property enumerate_snaps

alias to self.snap_dim.enumerate_values

existing_snaps()

return list of existing snaps. Equivalent to self.snaps.existing_snaps(self).

property extra_coords

dict of {coord_name: coord_value} to attach to outputs of self(var).

Useful if planning to join the output of self(var) with output from a different QuantityLoader.
E.g. self.extra_coords={‘run’: ‘run 0’} and other.extra_coords={‘run’: ‘run 1’},
then xr.concat([self(‘n’), other(‘n’)], ‘run’) gives ‘n’ from self AND other.
(this is nice if self and other have same values for dims. Otherwise, might struggle.)
property fft

alias to fftN

fftN(array, dim=UNSET, ds=None, *, slices=UNSET, **kw_xarray_fftN)

xarray_fftN with defaults for dim & slices determined by self.fft_dims, self.fft_slices.

kwargs are passed to xarray_fftN. For convenience, docs for xarray_fftN are copied below.
xarray_fftN docs
—————-
calculates fft(array) along N dimensions.
shifts frequencies such that the 0-frequency is in the center.
replaces result dimensions & coordinates appropriately, to indicate which dims were fft’d.
dim: None, str, or iterable of strs
coordinates(s) to take fft over.
Can be pre-fft or post-fft names. (e.g. ‘x’, ‘freq_x’, ‘freqrad_x’, ‘k_x’)
promote_dim(array, coord) for any non-dimension coordinates, as needed.
None –> equivalent to array.dims
str –> just this coordinate.
iterable of strs –> just these coordinates.
ds: None, number, or dict of {dim: d}
spacing between elements of array (pre-transform), along each dim.
if number, use the same value for all dims.
if None, infer via array.coords[dim].diff(dim) for each dim
(requires evenly-spaced coordinates in dim; spacing checked with np.allclose)
rad: None or bool
whether to convert frequencies to “radians” by multiplying them by 2 * pi.
E.g., for fft in space, rad=False gives 1/wavelength; rad=True gives wavenumber k.
if None, infer from dim if any post-fft names provided, else default to False.
abs: bool
if True, return np.abs(result), instead.
slices: dict or FFTSlices
instructions for slicing the final result.
Can provide {cname: indexer} instructing to slice post-fft dimension
associated with cname, via indexer. (cname can be pre-fft or post-fft name.)
These understand fractional indexing: can provide a fractional value
between -1 and 1, to use that fraction of the length along the relevant dimension.
Can also provide keep, half, step, and/or missing_slices, here (Or, as kwargs).
(raise InputConflictError if any provided in both places and have conflicting values.)
See those kwargs for more details.
keep: None, True, dict, or number in 0 < keep <= 1
implies the fraction of each dimension to keep.
(ignored for any dimensions which already have a slice specified.)
e.g. keep=0.4 with length=1000 would result in slice(300, 700),
since that keeps 400 out of 1000 points, and is centered at 1000/2.
None –> ignored.
True –> use keep = DEFAULTS.FFT_KEEP (default: 0.4).
dict –> different value in each dimension;
keys can be pre-fft OR post-fft dimension names.
UNSET –> use None.
half: None, str, or iterable of strs
dimensions along which to keep only the right half of the result.
(ignored for any dimensions which already have a slice specified.)
None –> ignored.
str or iterable of strs –>can be pre-fft OR post-fft dimension name(s).
Applied after keep, e.g. keep=0.4, length=1000, half=’x’ –> slice(500, 700) for x.
UNSET –> use None.
step: None, dict, int, or non-integer between -1 and 1
step to take along each dim.
(ignored for any dimensions which already have a slice specified.)
fractional value –> use fraction of length (e.g. 0.01 –> 1% of dim length), min |step|=1.
negative –> reverses direction (and swaps start & stop for the slice)
None –> equivalent to using step=1.
dict –> different value in each dimension;
keys can be pre-fft OR post-fft dimension names.
UNSET –> use None.
missing_slices: ‘ignore’, ‘warn’, or ‘raise’
tells how to handle keys not matching any fft-related coordinate.
‘ignore’ –> silently ignore these keys. This is the default.
‘warn’ –> issue a warning.
‘raise’ –> raise an error.
UNSET –> use ‘ignore’
additional kwargs passed to np.fft.fftn.
returns result of fftn(…), shifted such that the 0-frequency is in the center,
and with the relevant dimensions renamed as specified.
property fft_dims

the dims over which to possibly apply fft (FFTLoader methods).

will only apply fft along these dims for an array if they actually appear in the array.
None –> use self.maindims. (this is the default.)
See also: self.fft_dims_for(array).
fft_dims_for(array)

return the dims over which to apply fft for this array.

This is the intersection of self.fft_dims and array.dims.
property fft_half

alias to self.fft_slices.half

property fft_keep

alias to self.fft_slices.keep

property fft_slices

the dict of indexers to apply to all fft results from self, by default.

keys can be a pre-fft or post-fft dimension name,
e.g. ‘x’ or ‘freq_x’ both lead to slicing of the result’s ‘freq_x’ dimension.
(note if rad=True it would be ‘k_x’ in the result, and ‘x’ would apply but not ‘freq_x’.)
all other keys (not a pre-fft or post-fft dimension name) are ignored.
values can be slice, int, iterable, or non-integer value between -1 and 1.
fractional values are interpreted as a fraction of the length of the corresponding dimension,
as per interprets_fractional_indexing. Negative fractions refer to distance from the end.
e.g., dict(x=slice(-0.3, None, 0.01), y=0.8), where x and y correspond to length 1000,
would be equivalent to dict(x=slice(-300, None, 10), y=800).
Can also have special keys (which apply to all fft dims without a specifically-related key):
keep: fraction of each dimension to keep,
e.g. keep=0.4 with length=1000 would result in slice(300, 700),
since that keeps 400 out of 1000 points, and is centered at 1000/2.

half: dimension(s) along which to keep only the right half of the result. step: slice step. Can also be fractional to use fraction of dimension length.

For more help on special keys, see help(self._fft_slices_cls) or help(FFTSlices)
property fft_step

alias to self.fft_slices.step

property filename

alias to self.input_deck.filename

property fluid

alias to self.fluid_dim.v

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

classmethod from_here(filename='eppic.i', *, dist_names=None, **kw)

create EppicCalculator from input deck file found here (at filename).

dist_names: None or dict
{N: name for distribution N} for any number of distributions in filename.
E.g.: {0: ‘e’, 1: ‘H+’, 2: ‘C+’}
property full_read_mode

full read_mode, including hdf_output_arrays information.

gaussian_filter(array, dim=UNSET, sigma=UNSET, **kw_xarray_gaussian_filter)

xarray_gaussian_filter with defaults from self.blur_dims, self.blur_sigma.

kwargs are passed to xarray_gaussian_filter.
For convenience, docs for xarray_gaussian_filter are copied below:
xarray_gaussian_filter_docs
—————————
returns array after applying scipy.ndimage.gaussian_filter to it.
array: xarray.DataArray or Dataset
filters this array, or each data_var in a dataset.
dim: None or str or iterable of strs
dimensions to filter along.
if None, filter along all dims.
sigma: None, number, or iterable of numbers
standard deviation for Gaussian kernel.
if iterable, must have same length as dim.
if None, will use DEFAULTS.GAUSSIAN_FILTER_SIGMA (default: 1.0).
promote_dims_if_needed: bool
whether to promote non-dimension coords to dimensions.
if False, raise DimensionKeyError if any relevant coord is not already a dimension.
missing_dims: str in (‘ignore’, ‘warn’, ‘raise’)
what to do if any coord is not found:
‘ignore’ –> do nothing.
‘warn’ –> raise a warning.
‘raise’ –> raise DimensionKeyError.
additional kwargs go to scipy.ndimage.gaussian_filter.
property get

alias to __call__

get_0()

0, as an xarray. Code can also handle generic ints via self.get_int pattern.

get_1()

1, as an xarray. Code can also handle generic ints via self.get_int pattern.

get_B()

magnetic field. (directly from Eppic)

get_E()

electric field. E = E_external + E_phi = E_external - grad(phi)

get_E0S1(*, _skappa=None, _n=None)

E0S1 = sum_s (qs ns skappa_s / (1 + skappa_s^2)),

summed across all charged fluids (from self.fluids).
see help(self.get_E0_un0_perpB) for more details.
[EFF] for efficiency, can provide _skappa and/or _n if known.
get_E0S1_and_S2()

dataset containing ‘E0S1’ and ‘E0S2’. Equivalent to self([‘E0S1’, ‘E0S2’]),

but more efficient (only computes skappa and n one time).
E0S1 = sum_s (qs ns skappa_s / (1 + skappa_s^2))
E0S2 = sum_s (qs ns skappa_s^2/ (1 + skappa_s^2))
get_E0S2(*, _skappa=None, _n=None)

E0S2 = sum_s (qs ns skappa_s^2/ (1 + skappa_s^2)),

summed across all charged fluids (from self.fluids).
see help(self.get_E0_un0_perpB) for more details.
[EFF] for efficiency, can provide _skappa and/or _n if known.
get_E0_etaJ_perpB(*, _E0S1=None, _E0S2=None)

E0_perp_B = E0_etaJ_perpB + …, where E0_etaJ_perpB = eta0_J * J_perp_B.

see help(self.get_E0_un0_perpB_fromJ) for more details.
get_E0_hall(*, _E0S1=None, _E0S2=None)

E0_perp_B = E0_hall + …, where E0_hall = eta0_hall * J x Bhat.

see help(self.get_E0_un0_perpB) for more details.
get_E0_un0_perpB()

E0_un0_perpB = E0_etaJ_perpB + E0_hall

== eta0_J * J_perp_B + eta0_hall * J x Bhat
== (E0S1 |B| J_perp_B + E0S2 B cross J) / (E0S1^2 + E0S2^2), where
E0S1 = sum_s (qs ns skappa_s / (1 + skappa_s^2)),
E0S2 = sum_s (qs ns skappa_s^2/ (1 + skappa_s^2)),
This is the electric field in the un=0 frame of reference, assuming:
- zeroth order equilibrium velocities from multifluid equations,
- including only collisions with neutrals,
- considering only E (& J) perp to B; ignoring E0 (& J) parallel to B.
get_E0_un0_perpmodB()

E0_un0_perpmodB = |E0_un0_perpB|.

Should be equivalent to self(‘mod_E0_un0_perpB’), aside from rounding errors.
[EFF] the method here uses an algebraic simplification of the E0_un0_perpB formula:
E0_un0_perpB == (E0S1 |B| J_perp_B + E0S2 B cross J) / (E0S1^2 + E0S2^2)
–> (do some algebra, and utilizing J_perp_B dot B = 0) –>
E0_un0_perpmodB = (|B| |J_perp_B|) / sqrt(E0S1^2 + E0S2^2)
get_E0_un0_perpmodB_min()

E0_un0_perpmodB_min = minimum possible value of |E0_un0_perpB|, at each point.

E0_un0_perpmodB_min = (1/sqrt(2)) * |B| |J_perp_B| / (ne |qe|)
Regardless of kappa (& nusn) values for electrons and ions, will always have:
E0_un0_perpmodB >= E0_un0_perpmodB_min.
Logic which proves this fact (below, using “K” as shorthand for “skappa”):
E0_un0_perpmodB has sqrt(E0S1^2 + E0S2^2) in the denominator;
–> when sqrt(E0S1^2 + E0S2^2) is largest, E0_un0_perpmodB will be smallest.
sqrt(E0S1^2 + E0S2^2) is largest when |E0S1| and |E0S2| are both largest.
(1) |E0S1| <= sum_s (|qs| ns |Ks| / (1 + Ks^2))
(2) |E0S2| <= sum_s (qs ns Ks^2 / (1 + Ks^2))
For ANY real K, the relevant quantities are bounded by:
(i) 0 < |K| / (1 + K^2) <= 1/2
(ii) 0 < K^2 / (1 + K^2) < 1
which can be readily shown using introductory calculus:
|K|/(1+K^2) has local extrema (derivative=0) only at K=1, where |K|/(1+K^2)=1/2;
it tends to 0 when K->0; and it tends to 0 when K->inf.
K^2/(1+K^2) has local extrema (derivative=0) only at K=0, where it equals 0;
it tends to 0 when K->0; and it tends to 1 when K->inf.
Applying (i) to expression (1) above yields:
|E0S1| <= sum_s |qs| ns * 1/2
Utilizing quasineutrality (sum_s qs ns = 0) and qe < 0 and qi > 0, provides:
sum_s |qs| ns = ne |qe| + sum_i ni qi = 2 ne |qe|
–> |E0S1| <= ne |qe|
Meanwhile for expression (2), note that because qe < 0 and qi > 0,
ne qe (Ke^2 / (1 + Ke^2)) has opposite the sign as sum_i ni qi Ki^2 / (1 + Ki^2),
so the largest possible |E0S1| occurs when one of those two terms is as small as possible.
Applying (ii) to each term, and quasineutrality to the second term, yields:
|ne qe (Ke^2 / (1 + Ke^2))| < ne |qe|
|sum_i ni qi Ki^2 / (1 + Ki^2)| < sum_i ni qi = ne |qe|
–> |E0S2| < ne |qe|
Combining yields:
sqrt(E0S1^2 + E0S2^2) < sqrt(2) ne |qe|
Thus, we always have:
(|B| |J_perp_B|) / sqrt(E0S1^2 + E0S2^2) >= (|B| |J_perp_B|) / (sqrt(2) * ne |qe|)
i.e. E0_un0_perpmodB >= E0_un0_perpmodB_min.
get_E0_un0_perpmodB_simple()

E0_un0_perpmodB_simple = simple estimate of |E0_un0_perpB|, at each point.

E0_un0_perpmodB_simple = (|B| |J_perp_B|) / (ne |qe|)
This is a simple estimate of |E0_un0_perpB|, accurate when kappae>>1 and kappai<<1.
get_EBspeed()

speed determined from E_un0 and B: |E_un0 perp to B| / |B|.

get_E_ext()

external electric field. (directly from Eppic).

get_E_phi()

electric field, from phi. E_phi = -grad(phi). Doesn’t include E_ext component.

get_E_un0()

E_un0 = electric field in the neutral frame, where u_n=0.

Result depends on self.E_un0_mode; see help(type(self).E_un0_mode) for details.
get_E_un0_perpmod_B(**kw_perpmod)

E_un0_perpmod_B == |E_un0 perp to B| == magnitude of E, perp to B, in u_neutral=0 frame.

This is usually equivalent to using self.magnitude(self.take_perp_to(B, E_un0)),
but if E_un0_mode = ‘E0_perpmodB’ will use more efficient method (self(‘E0_un0_perpmodB’)),
and if E_un0_mode = ‘E0_perpmodB_min’ will use different method (self(‘E0_un0_perpmodB_min’)).
kwargs are passed to self.get_perpmod, if applicable.
get_E_un0_type()

string telling method that will be used to get E_un0. Based on self.E_un0_mode.

possible results:
‘nan’ <–> will crash. (e.g. this occurs if E_un0_mode = ‘E0_perpmodB_min’)
‘E+unxB’ <–> self(‘E’) + self(‘u_neutral_cross_B’)
‘E_u0’ <–> self(‘E_u0’)
‘E+uxB’ <–> self(‘E’) + self(‘u_cross_B’)
‘E’ <–> self(‘E’)
‘E0_perpB’ <–> self(‘E0_un0_perpB’)
get_Eheat()

Eheat = Eheat_perp + Eheat_par. total heating from electric field. Units of Kelvin.

From assuming u_n=0 and derivatives=0 in heating & momentum equations, which yields:

T_s = T_n + Eheat_perp + Eheat_par, where
Eheat_perp = Eheat_perp_coeff * |E_perp|^2,
Eheat_par = Eheat_par_coeff * |E_par|^2,
E_perp = E(in u_n=0 frame) perp to B,
E_par = E(in u_n=0 frame) parallel to B,
Eheat_perp_coeff = (m_n / (3 kB)) (kappa_s^2 / B^2) * (1 / (1 + kappa_s^2)),
Eheat_par_coeff = (m_n / (3 kB)) (kappa_s^2 / B^2).
get_Eheat_par(*, _E_un0=None, _B=None, _Eheat_par_coeff=None)

Eheat_par = Eheat_par_coeff * |E_par|^2. heating parallel to B. Units of Kelvin.

see help(self.get_Eheat) for more details.
[EFF] for efficiency, can provide _E_un0, _B and/or _Eheat_par_coeff if known.

caution: if providing _E_un0 or _B, will assume any missing components are 0.

get_Eheat_par_coeff()

Eheat_par = Eheat_par_coeff * |E_par|^2. for E heating parallel to B. Units of Kelvin.

see help(self.get_Eheat) for more details.
get_Eheat_perp(*, _E_un0=None, _B=None, _Eheat_par_coeff=None)

Eheat_perp = Eheat_perp_coeff * |E_perp|^2. heating perp to B. Units of Kelvin.

see help(self.get_Eheat) for more details.
[EFF] for efficiency, can provide _E_un0, _B and/or _Eheat_par_coeff if known.

caution: if providing _E_un0 or _B, will assume any missing components are 0.

get_Eheat_perp_coeff(*, _Eheat_par_coeff=None)

Eheat_perp = Eheat_perp_coeff * |E_perp|^2. for E heating perp to B. Units of Kelvin.

see help(self.get_Eheat) for more details.
[EFF] for efficiency, can provide _Eheat_par_coeff if known.
get_Eheat_perp_rate_n()

zeroth order rate of heating of neutrals due to collisions with all charged species.

Eheat_perp_rate_n = sum_s Eheat_perp_rate_n_s
== sum_s 2 * nuns * Eheat_perp
== sum_s 2 * (m_s / m_n) * (n_s / n_n) * nusn * Eheat_perp
== sum_s (2 m_s / (3 kB)) * (n_s / n_n) * nusn * (kappa_s^2 / (1 + kappa_s^2)) * (|E_perp|^2 / |B|^2)
Derived from plugging T_from_Eheat_perp and |u_drift| formulae into the neutral heating equation:
dTn/dt + (2/3) T_n div(u_n) =
sum_s (2 m_n / (m_n + m_s)) nu_{n,s} [(m_s / (3 kB)) |u_s - u_n|^2 + (T_s - T_n)]
in the neutral reference frame (u_n=0),
and using m_n n_n nu_{n,s} = m_s n_s nu_{s,n} which comes from conservation of momentum.
get_Eheat_perp_rate_n_s()

zeroth order rate of heating of neutrals due to collisions with s (self.fluid).

Eheat_perp_rate_n_s = 2 * nuns * Eheat_perp
== 2 * (m_s / m_n) * (n_s / n_n) * nusn * Eheat_perp
== (2 m_s / (3 kB)) * (n_s / n_n) * nusn * (kappa_s^2 / (1 + kappa_s^2)) * (|E_perp|^2 / |B|^2)
Derived from plugging T_from_Eheat_perp and |u_drift| formulae into the neutral heating equation:
dTn/dt + (2/3) T_n div(u_n) =
sum_s (2 m_n / (m_n + m_s)) nu_{n,s} [(m_s / (3 kB)) |u_s - u_n|^2 + (T_s - T_n)]
in the neutral reference frame (u_n=0),
and using m_n n_n nu_{n,s} = m_s n_s nu_{s,n} which comes from conservation of momentum.
See also: Eheat_perp_rate_n
get_Epar()

electric field, parallel to B. This is a full 3-vector.

Equivalent: self(‘E_par_B’) == (E dot Bhat) Bhat
get_Eperp()

electric field, perpendicular to B. This is a full 3-vector.

Equivalent: self(‘E_perp_B’) == E - self(‘E_par_B’) == E - (E dot Bhat) Bhat
get_J()

total current density. J = sum_across_fluids(n*q*u)

This is per unit area, e.g. the SI units would be Amperes / meter^2.
get_JBspeed()

speed determined from J perp to B, and ne: |J_perp to B| / (ne * |qe|).

get_J_from_moment1()

total current density, based on moment1 info: sum_fluids_Jf_from_moment1.

Always sums across all charged fluids from self.fluids.
(compare to self(‘J’), which tells sum_fluids(q * n * u).)
get_Jf()

current density (associated with fluid). Jf = (nq * u) = (charge density * velocity)

This is per unit area, e.g. the SI units would be Amperes / meter^2.
(If self is not a FluidHaver, this will equal the total current density.)
get_Jf_from_moment1()

self.fluid’s contribution to current density, based on moment1 info: q * n0 * moment1.

(compare to self(‘Jf’), which tells q * n * u.)
get_P()

pressure (“isotropic/maxwellian”). P = (n * Tjoule) = (number density * T [energy units])

get_T()

temperature, from nv^2. Rms average of all (3) anisotropic temperature components.

T == sqrt((Ta_x^2 + Ta_y^2 + Ta_z^2)/3)
if self.T_indim_only, instead return self(‘T_indim’), which ignores Tz if data is 2D.
get_T_box()

temperature of the entire simulation box, as if full of particles,

and observed by something that could not resolve the individual cells.
Equivalent: rmscomps(Ta_from_moment2).
Ignores Ta components for directions in which the box has no extent.
get_T_from_Eheat()

T_from_Eheat = T_n + Eheat. Units of Kelvin.

see help(self.get_Eheat) for more details.
get_T_from_Eheat_perp()

T_from_Eheat_perp = T_n + Eheat_perp. Units of Kelvin.

see help(self.get_Eheat) for more details.
get_T_from_moment2_or_Tjoule_from_moment2(var, *, _match=None)

temperature (“isotropic/maxwellian”), from moment2 instead of nvsqr/n.

‘T_from_moment2’ –> mean of Ta_from_moment2 across components.
== (m * moment2 / kB) [Kelvin], averaged across components.
‘Tjoule_from_moment2’ –> similar, but don’t divide by kB; result has [energy units].
get_T_indim()

temperature, from nv^2. Rms average of Ta components in self.maindims.

Equivalent to self(‘T’) in 3D, but in 2D xy data, T_indim ignores Tz.
get_T_neutral()

temperature of neutrals.

get_T_sj(*, _m_s=UNSET, _T_s=UNSET, _m_j=UNSET, _T_j=UNSET)

mass-weighted temperature. T_sj = (m_s * T_j + m_j * T_s) / (m_s + m_j).

s = self.fluid; j = self.jfluid.
[EFF] for efficiency, can provide any of m_s, T_s, m_j, T_j, if already known.
get_Ta_from_moment2_or_Tajoule_from_moment2(var, *, _match=None)

temperature (“anisotropic”), from moment2 instead of nvsqr/n.

‘Ta_from_moment2’ –> (m * moment2 / kB) [Kelvin]
‘Tajoule_from_moment2’ –> (m * moment2) [energy units]
Compare with nmean_Ta (or nmean_Tajoule).
nmean instead of mean because moments.out averages across all particles!
(see help(self.get_moment2) for more details.)
get_Ta_or_Tajoule(var, *, _match=None)

temperature (“anisotropic”).

‘Ta’ –> (m * (vsqr - u^2) / kB) [Kelvin]
‘Tajoule’ –> (m * (vsqr - u^2)) [energy units]
‘Ta_global’ or ‘Tajoule_global’
–> use nmean_u instead of u. nmean_u is the density-weighted mean velocity,
i.e. it is the mean velocity across all particles in the box
(which is not necessarily equivalent to mean across all cells in the box).
Note that if reading u directly from simulation, nmean_u should be equal to moment1.
components given by:
Ta_x = m * (vsqr_x - u_x^2) / kB
Tajoule_x = m * (vsqr_x - u_x^2)
There are 3 different quantities to consider, related to averaging:
- Ta_from_moment2_x: single value, temperature if the entire box is one distribution;
this is probably what observations would see if they can’t resolve the box.
Equal to x component of m * <(v - <v>)^2>, where <*> indicates mean across all particles.
This equals m * (<v^2> - 2<v*<v>> + <v>^2) = m * (<v^2> - <v>^2).

Note: <v^2> == nmean_vsqr, because nmean is equivalent to “mean across particles”.

- Ta_global_x: one value per grid cell. Not defined as a “temperature”,
instead, defined as the quantity whose nmean is equivalent to Ta_from_moment2.
Ta_global_x = m * (vsqr - <v>^2) == m * (vsqr - nmean_u^2).
- Ta_x: one value per grid cell. Temperature for that grid cell;
this is probably what observations would see if they could resolve the grid cells.
Ta_x = m * (vsqr - u^2), where u is the average of particle velocities in that cell, only.
Because Ta_x doesn’t use global nmean_u, nmean_Ta_x is NOT equivalent to Ta_from_moment2_x.
get_Tapar(var, *, _match=None)

Tapar –> anisotropic temperature, parallel to B. This is a full 3-vector.

Equivalent: self(‘Ta_par_B’) == (Ta dot Bhat) Bhat
Also supports ‘Tajoulepar’ to get value in energy units; == ‘Tapar*kB’.
get_Taperp(var, *, _match=None)

Taperp –> anisotropic temperature, perpendicular to B. This is a full 3-vector.

Equivalent: self(‘Ta_perp_B’) == Ta - self(‘Ta_par_B’) == Ta - (Ta dot Bhat) Bhat
Also supports ‘Tajouleperp’ to get value in energy units; == ‘Taperp*kB’.
get_Tjoule()

temperature (“isotropic/maxwellian”), in energy units. Tjoule = kB * T.

If using SI units, result will be in Joules.
get__nit_since_prev_simple()

naive implementation of nit_since_prev. Makes fewer assumptions, but can be slow.

(e.g., took 0.8 seconds for 800 snaps. Compare to 0.02 seconds via nit_since_prev.)
nit_since_prev should dispatch to this method if any of the assumptions fail.
get__nusj_singlej(*, collision_type)

_nusj_singlej = collision frequency between self.fluid and a single jfluid.

Implementation detail… may be removed later. Use self(‘nusj’) instead.
get_abs(var, *, _match=None)

absolute value. abs(var)

get_abs_qe()

|electron charge|, in [self.units] units. Equivalent to self.u(‘qe’).

abs to avoid any possible ambiguity, since electron charge itself is negative.
get_amu()

1 atomic mass unit, in [self.units] units. Equivalent to self.u(‘amu’)

get_angle_xy(var, *, _match=None, _val0=None, **_known_vals)

angle between +xhat and var, in the xy plane, in radians.

CAUTION: does not “unwrap”; all angles will be reported in the range -pi to pi.

See unwrapt2pi for example of unwrapping (see also: np.unwrap)
angle_xy_{A} –> atan2(Ay, Ax).
[EFF] can provide known val for A, to avoid recalculating it. (include leading underscore.)
e.g. self(‘angle_xy_E’, _E=E) –> angle between +xhat and E, using E which is already known.
get_angle_xy_to_hat(var, *, _match=None, _val0=None, **_known_vals)

unit vector u, given angle [radians] between +xhat and u in the xy plane.

angle_xy_to_hat_{A} –> cos(A) * xhat + sin(A) * yhat.
get_astats(var, *, _match=None)

return dataarray of stats for var, reporting stats along new dim: ‘stat’.

stats include: mean, std, min, max, median, rms.
Applied only along any self.stat_dims in array.
Compatible with Dataset vars (without existing ‘stat’ coord or dim).
The result excludes whichever dims the stats are being taken across,
and adds the new dim ‘stat’ with the stats.
Consider also: self(‘stats_var’), self(‘var’).pc.stats(to_da=’stat’)
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_best_pow2_subcycle()

largest power of 2 subcycling allowed for each fluid in self.fluid.

result = array of values like 2^N, with largest N such that result < best_subcycle.
get_best_subcycle()

largest subcycling allowed: best_subcycle = min_timescale / minf_timescale.

min_timescale = min timescale for self.fluid, across all timescales.
minf_timescale = min timescale across all fluids and all timescales.
(when computing minf_timescale here, always use all self.fluids.)
E.g. fluid=fluids=[‘e’,’H+’,’C+’], min_timescale=[1e-8, 1e-7, 5e-7]
–> minf_timescale will be 1e-8, so result will be [1, 10, 50].
get_beta()

plasma beta. beta = (pressure / magnetic pressure) = (P / (B^2 / (2 mu0)))

get_blur(var, *, _match=None)

gaussian_filter(var). Applied along all self.blur_dims in array.

‘blur_var’ or ‘gaussian_filter_var’; both are equivalent.
get_blurk(var, *, _match=None)

gaussian_filter(var), temporarily using self.blur_dims = [‘k_x’, ‘k_y’, ‘k_z’]

‘blurk_var’ or ‘gaussian_filterk_var’; both are equivalent.
get_blurt(var, *, _match=None)

gaussian_filter(var), temporarily using self.blur_dims = [‘snap’]

‘blurt_var’ or ‘gaussian_filtert_var’; both are equivalent.
get_braced_int_from_parenthesis_memory(var, *, _match=None)

{i} –> self(mem_var), where mem_var = self.parenthesis_memory_key_to_var[int(i)].

get_cache_var(var, *, _match=None)

get var, then save to cache. returns value of var.

if cached result already exists, will overwrite it.
if result is too big, crash with MemorySizeError.
see also: caches_var, cached_var
get_cached_tfbi_vs_EBspeed()

return a previously-computed tfbi solution across EBspeed grid.

Expects solution to live in _tfbi_vs_EBspeed_file(); default:
{self.unique_notes_dirname}/_pc_tfbi/EBspeed_{logmin:.4g}_{logmax:.4g}_{logstep:.4g}.pcxarr
CAUTION: the implementation here assumes self.tfbi_EBspeed_grid_size is enough to uniquely specify the result;
e.g. if there is a different result at each snapshot of self, that will not be understood here.
get_cached_var(var, *, _match=None)

get var from folder within self.cache_dirname.

if not already cached, crash with CacheNotApplicableError.
if previously cached, ensures attrs agree with self.behavior.nondefault(),
and ensures dims agree with self.behavior.dims.
see also: caches_var, cache_var
get_caches_var(var, *, _match=None)

get var, possibly from folder within self.cache_dirname.

puts self.behavior.nondefault() as attrs of result.
(caching not yet implemented for arrays with complicated nondefault behavior,
e.g. will fail if trying to use caches_var syntax and masking at the same time.

Workaround: separately call xarray_save and xarray_load, for results you care about.

Other workaround: use )
if previously cached, check if applicable, i.e.
whether attrs agree with self.behavior.nondefault(), and dims agree with self.behavior.dims.
if applicable, then return cached result.
else, destroy cache and proceed as if not already cached (see below).
if not already cached, saves to {self.cache_dirname}/{var},
unless result is too big (in which case, crash with MemorySizeError).
“too big” [MB] == DEFAULTS.CACHE_ARRAY_MBYTES_MAX (default: 1)
see also: cached_var, cache_var
get_calc_time()

Wall clock runtime, ignoring time spent writing output files. Same units as timers_dat info.

get_clock_times()

dataset of clock times from this run. (From reading self.jobfiles.)

Result can have keys:
‘start’: datetime telling when the run started.
‘stepstart’: datetime telling when the iterations started.
‘end’: datetime telling when the run ended.
‘init_seconds’: (stepstart - start) [seconds]
‘steps_seconds’: (end - stepstart) [seconds]
‘total_seconds’: (end - start) [seconds]
If jobfile missing any info, relevant keys will not appear in result.
get_collision_type()

collision type between self.fluid and self.jfluid.

result depends on fluids and on self.collisions_mode.
‘0’ <–> fluid and jfluid are the same fluid.
‘coulomb’ <–> do coulomb collisions
‘maxwell’ <–> do maxwell collisions
‘fromtable’ <–> get collision cross section from a table
get_collisions_cross_section()

cross section between self.fluid and self.jfluid.

interpolates on self.collisions_cross_mapping based on mass-weighted temperature;
cross_table = collisions_cross_mapping[(fluid, jfluid)]
T_sj = (m_j * T_s + m_s * T_j) / (m_j + m_s)
result_si = cross_table(T_sj, input=’T’, output=’cross_si’)
result = result_si * self.u(‘area’) # convert to self.units unit system.
if collisions_cross_mapping[(fluid, jfluid)] is not found:
either return 0 (as an xarray), or raise QuantInfoMissingError,
depending on self.collisions_mode. see help(type(self).collisions_mode) for details.
get_collisions_crosstab(fluid1, fluid2, *, crossmap=None)

roughly, returns self.collisions_cross_mapping[(fluid1, fluid2)],

but, this is more convenient, because:
- fluid1 and fluid2 can be provided in shorthand.
can provide them as Fluid objects, ints, or strs.
crossmap: None or CrossMapping
if provided, get value from crossmap instead of from self.collisions_cross_mapping.
get_collisions_crosstab_default_fluids()

return dict of fluids from self which have any corresponding CROSS_TABLE_DEFAULTS.

keys will be e, H_I, H_II, He_I, He_II, He_III.
values will be Fluid objects (from self.fluids or self.jfluids)
checks multiple possible shorthand notations for each fluid:

e : fluids.get_electron(), jfluids.get_electron() H_I : ‘H_I’, ‘H I’, ‘H’ H_II : ‘H_II’, ‘H II’, ‘H+’ He_I : ‘He_I’, ‘He I’, ‘He’ He_II : ‘He_II’, ‘He II’, ‘He+’ He_III: ‘He_III’, ‘He III’, ‘He++’

if multiple matches found in any case, raise FluidValueError.
subclass could implement more sophisticated matching if needed;
the implementation here aims to be flexible, but crash if anything is ambiguous.
note: possible shorthands defined by self._COLLISIONS_CROSSTAB_DEFAULT_FLUIDS_ALIASES;
subclass might override that instead of this method, if just needing to alter shorthands.
get_compare_equals(var, *, _match=None)

self(‘A==B’) –> boolean array: self(‘A’) == self(‘B’)

get_compare_greater_than(var, *, _match=None)

self(‘A>B’) –> boolean array: self(‘A’) > self(‘B’)

get_compare_greater_than_or_equal(var, *, _match=None)

self(‘A>=B’) –> boolean array: self(‘A’) >= self(‘B’)

get_compare_less_than(var, *, _match=None)

self(‘A<B’) –> boolean array: self(‘A’) < self(‘B’)

get_compare_less_than_or_equal(var, *, _match=None)

self(‘A<=B’) –> boolean array: self(‘A’) <= self(‘B’)

get_compare_not_equals(var, *, _match=None)

self(‘A!=B’) –> boolean array: self(‘A’) != self(‘B’)

get_coulomb_logarithm()

Coulomb logarithm, ln(Lambda). Used in coulomb collisions.

result = ln(Lambda) = 23.0 + 1.5 ln(Te [K] / 10^6) - 0.5 ln(ne [m^-3] / 10^12)
get_cpu_per_each2ct()

conversion factors: cpu_per_each2ct * cpu_per_each == cpu_per_ct.

Result is a dataset with timers as data vars.
These convert from (per particle per cell per timestep) to (per cell per timestep):
‘vadv time’, ‘xadv time’, ‘charge’, ‘output’.
(I.e., for these timers: result == nptotcell)
These do not convert at all:
‘collect’, ‘efield’
(I.e., for these timers: result == 1)
Other timers’ conversions are not included.
get_cpu_per_each2timestep()

conversion factors: cpu_per_each2timestep * cpu_per_each == cpu_per_timestep.

Result is a dataset with timers as data vars.
These convert from (per particle per cell per timestep) to (per timestep):
‘vadv time’, ‘xadv time’, ‘charge’, ‘output’.
(I.e., for these timers: result == nptotcell * ncells_sim)
These convert from (per cell per timestep) to (per timestep):
‘collect’, ‘efield’
(I.e. for these timers: result == ncells_sim)
Other timers’ conversions are not included.
get_cpu_seconds_per_ct()

cpu seconds per cell per timestep, for each timer in timers.

n_processors * timer2seconds * timers / (ncells_sim * nit_since_prev)
see also: cpu_seconds_per_timestep, cpu_seconds_per_pct
get_cpu_seconds_per_each()

cpu seconds per (particle, per) cell, per timestep, as relevant to each timer in timers.

cpu_seconds_per_pct for definitely scaling with nptotcell:

- vadv time
- xadv time
- charge
cpu_seconds_per_pct for timers probably scaling with nptotcell:
- output
cpu_seconds_per_ct for timers definitely NOT scaling with nptotcell:
- collect
- efield
EXCLUDE timers combining times above:
- Wall Clock
- Sys Clock
EXCLUDE timers not handled here:
- fluid
get_cpu_seconds_per_pct()

cpu seconds per particle, per cell, per timestep, for each timer in timers.

n_processors * timer2seconds * timers / (nptotcell * ncells_sim * nit_since_prev)
(note, nptotcell accounts for subcycling. See self.help(‘nptotcell’) for details.)
see also: cpu_seconds_per_timestep, cpu_seconds_per_ct
get_cpu_seconds_per_timestep()

cpu seconds per timestep, for each timer in timers.

n_processors * timer2seconds * timers / nit_since_prev
see also: cpu_seconds_per_ct, cpu_seconds_per_pct
get_cross(var, *, _match=None, _val0=None, _val1=None, **_known_vals)

cross product. {A}_cross_{B} –> A cross B.

returned components are determined by self.component.
(see also: the get_xyz pattern. E.g., {A}_cross_{B}_x –> x component of A cross B)
[EFF] can provide known vals for A or B, to avoid recalculating them. (include leading underscores.)
e.g. self(‘u_cross_E’, _u=u, _E=E) –> u cross E, using u and E which are already known.
CAUTION: if providing values, include all self.cross_components_needed() components;
missing components will be assumed to be 0.
E.g. if providing u to calculate u_cross_E, but u doesn’t have x component, assumes u_x=0.
can alternatively provide _val0 for A and/or _val1 for B.
get_csound()

sound speed. csound = sqrt(gamma * P / r)

get_csound2()

sound speed squared. csound2 = gamma P / r.

get_curl(var, *, _match=None)

curl. ‘curl_{var}’ –> curl(var), i.e. (du_z/dy - du_y/dz, du_x/dz - du_z/dx, du_y/dx - du_x/dy).

returned components are determined by self.component.
(see also: the get_xyz pattern. E.g., curl_u_x –> x component of curl(u))
if self.slices nonempty, self.deriv_before_slice controls whether slicing occurs before or after div.
get_dTndt()

rate of heating of neutrals due to collisions with all charged species.

dTndt = sum_s dTndt_s
== sum_s 2 m_n / (m_n + m_s) * nuns * [(m_s / (3 kB)) |u_s|^2 + (T_s - T_n)]
get_dTndt0()

zeroth order rate of heating of neutrals due to collisions with charged species.

dTndt0 = sum_s dTndt0_s == sum_s (2 m_n / (3 kB)) * nuns * |u0_s|^2.
See dTndt0_s for more details.
Result should be equivalent to self(‘frominputs_dTndt’), aside from rounding errors.
get_dTndt0_s()

zeroth order rate of heating of neutrals due to collisions with s.

Purely based on the input deck values.
dTndt0_s = (2 m_n / (3 kB)) * nuns * |u0_s|^2,
where u0_s is the zeroth order drift velocities (see u_drift)
|u0_s|^2 = (kappa_s^2 / (1 + kappa_s^2)) * EBspeed^2,
where EBspeed = E_perpmod_B / |B|.
Does the calculation at the INPUT_SNAP. Removes ‘snap’ dim from result.
(Future implementation note: might want to allow computing at other snaps, using means)
Result should be equivalent to self(‘frominputs_dTndt_s’), aside from rounding errors.
get_dTndt_s()

rate of heating of neutrals due to collisions with s (self.fluid).

dTndt_s = 2 m_n / (m_n + m_s) * nuns * [(m_s / (3 kB)) |u_s|^2 + (T_s - T_n)]
get_dTndt_s_T()

temperature contribution to rate of heating of neutrals due to collisions with s.

dTndt_s_T = 2 m_n / (m_n + m_s) * nuns * [(T_s - T_n)]
get_dTndt_s_ds()

dataset of contributions to rate of heating of neutrals due to collisions with s.

dTndt_s = 2 m_n / (m_n + m_s) * nuns * [(m_s / (3 kB)) |u_s|^2 + (T_s - T_n)]
Assumes u_n==0; else crash with QuantCalcError.
result has keys:
‘dTndt_u2’: 2 m_n / (m_n + m_s) * nuns * [(m_s / (3 kB)) |u_s|^2]
‘dTndt_T’: 2 m_n / (m_n + m_s) * nuns * [(T_s - T_n)]
get_dTndt_s_u2()

velocity contribution to rate of heating of neutrals due to collisions with s.

dTndt_s_u2 = 2 m_n / (m_n + m_s) * nuns * [(m_s / (3 kB)) |u_s|^2]
get_dTndt_turb0_s_ds()

dataset of contributions to neutral heating rate, based on ‘mean’ turbulent values,

for each fluid (in self.fluid), due to collisions.
Assumes u_n==0, and does not check.
result has keys:
‘dTndt_u2’: 2 m_n / (m_n + m_s) * nuns * [(m_s / (3 kB)) |u_s|^2]
‘dTndt_T’: 2 m_n / (m_n + m_s) * nuns * [(T_s - T_n)]
Except, use werrmeant_sureturb_u instead of u_s,
and werrmeant_sureturb_T instead of T_s
For more accurate computation, consider self(‘werrmeant_sureturb_dTndt_s’)
get_deg2rad(var, *, _match=None)

convert degrees to radians. deg2rad_{A} –> A * pi / 180.

self(‘deg2rad_var’) == np.deg2rad(self(‘var’))
get_delta(var, *, _match=None)

perturbation. var - mean(var). Applied only along any self.stat_dims in array.

get_delta_sj()

kronecker delta function between self.fluid and self.jfluid.

1 where self.fluid == self.jfluid; 0 otherwise.
Useful e.g. to avoid counting collisions between the same species.
get_deltafrac(var, *, _match=None)

perturbation. (var - mean(var)) / mean(var). Applied only along any self.stat_dims in array.

get_deltafrac_n()

normalized density perturbation. (directly from Eppic.) deltafrac_n = (n - n0) / n0.

get_derivative(var, *, _match=None)

derivative. dd{x}_{var} –> d{var}/d{x}.

self(var) must return an object with {x} in its coordinates.
E.g. for x=’y’, self(var).coords[‘y’] are required.
get_div(var, *, _match=None)

divergence. ‘div_{var}’ –> div(var), i.e. du_x/dx + du_y/dy + du_z/dz.

if component(s) is provided, only include that component(s) during the calculation.
e.g. div_u__xy –> du_x/dx + du_y/dy.
if self.slices nonempty, self.deriv_before_slice controls whether slicing occurs before or after div.
get_divide(var, *, _match=None)

division. var0 / var1.

get_dot(var, *, _match=None, _val0=None, _val1=None, **_known_vals)

dot product. {A}_dot_{B} –> A dot B.

if component(s) is provided, only include that component(s) during the calculation.
e.g. A_dot_B__xy –> Ax * Bx + Ay * By.
[EFF] can provide known vals for A or B, to avoid recalculating them. (include leading underscores.)
e.g. self(‘u_dot_E’, _u=u, _E=E) –> u dot E, using u and E which are already known.
if providing value as None, it will be treated as if value not provided.

CAUTION: Not tested when simultaneously providing components such as A_dot_B__xy.

can alternatively provide _val0 for A and/or _val1 for B.
get_ds()

grid spacing (of output files). vector(ds), e.g. [dx, dy, dz]. Depends on self.component.

ds = (ds_sim / nout_avg) * subsampling_step. subsampling_step=1 unless subsampling_info exists.
get_ds_for_timescales()

ds used when calculating timescales. vector(ds), e.g. [dx, dy, dz].

Like ds_sim, the value here doesn’t include the nout_avg factor.
ds_for_timescales equals ds_sim for components corresponding to self.input_deck.maindims()
(regarless of current value of self.component).
get_ds_sim()

grid spacing (of simulation). vector(ds), e.g. [dx, dy, dz]. Depends on self.component.

ds_sim = (dx, dy, dz) from input deck (not divided by nout_avg)
get_dsmin_for_timescales()

minimum spatial scale used when calculating timescales.

min(ds_for_timescales) across components.
get_dt_sim()

time spacing (of simulation). Time between iterations (not between snapshots)

get_e()

energy density. e = P / (gamma - 1) = pressure / (adiabatic index - 1)

get_eps0()

vacuum permittivity, in [self.units] units. Equivalent to self.u(‘eps0’)

get_eqperp_ldebye()

Debye length (of self.fluid), using T_from_Eheat_perp instead of T.

eqperp_ldebye = sqrt(epsilon0 kB T_from_Eheat_perp / (n q^2))
get_eqperp_ldebye2()

squared Debye length (of self.fluid), using Eheat_perp instead of T.

eqperp_ldebye2 = epsilon0 kB T_from_Eheat_perp / (n q^2)
get_eqperp_ldebye_total()

total Debye length for all fluids: sqrt(epsilon0 kB / sum_fluids(n q^2 / T)),

using T = T_from_Eheat_perp.
Equivalent: sqrt( 1 / sum_fluids(1/eqperp_ldebye^2) )
get_eqperp_mean_free_path()

collisional mean free path, using eqperp_vtherm instead of vtherm.

eqperp_lmfp = eqperp_vtherm / nusn
get_eqperp_vtherm()

thermal velocity, using T_from_Eheat_perp instead of T.

eqperp_vtherm = sqrt(kB T_from_Eheat_perp / m)
get_eta0_J(*, _E0S1=None, _E0S2=None)

E0_perp_B = eta0_J * J_perp_B + …, where eta0_J = E0S1 * |B| / (E0S1^2 + E0S2^2). note:

see help(self.get_E0_un0_perpB) for more details.
[EFF] for efficiency, can provide _E0S1 and/or _E0S2 if known.
get_eta0_hall(*, _E0S1=None, _E0S2=None)

E0_perp_B = eta0_hall J x Bhat + …, where eta0_hall = - E0S2 * |B| / (E0S1^2 + E0S2^2)

see help(self.get_E0_un0_perpB) for more details.
[EFF] for efficiency, can provide _E0S1 and/or _E0S2 if known.
get_exp(var, *, _match=None)

exponentiation. exp(var). Also known as e^var. See also: get_power

get_fft(var, *, _match=None)

N-dimensional fft. fft(var). Applied along all fft_dims in array.

self.get(‘[rad]fft[N]_[var]’), where [rad]=’rad’ or ‘’, and [N]=any integer or ‘’
E.g. ‘fft_var’, ‘radfft_var’, ‘fft1_var’, ‘fft2_var’, ‘radfft1_var’, ‘radfft2_var’.
‘rad’ –> multiply result’s frequency coordinates by 2 * pi.
(array values will be the same either way, but coordinates will be different.)
N provided –> fft must be along exactly this many dimensions, else crash with DimensionError.
E.g. N=2 means self(array) must have exactly 2 dims which are also in self.fft_dims.
Feel free to separately self.fft_dims, or enter it as a kwarg via self(…, fft_dims=…).
get_fft_with_dims(var, *, _match=None)

N-dimensional fft. fft(var). Applied along the indicated dims.

self.get(‘([rad]fft[dims]_[var]’), where [rad]=’rad’ or ‘’, and [dims]=any combination of xyzt.
E.g. ‘fftx_var’, ‘fftt_var’, ‘fftyz_var’, ‘radfftxy_var’, ‘fftzyt_var’, ‘radfftyzt_var’.
‘rad’ –> multiply result’s frequency coordinates by 2 * pi.
(array values will be the same either way, but coordinates will be different.)
get_finite(var, *, _match=None)

var, masked with NaN wherever values are not finite.

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_float(var, *, _match=None)

any float, as an xarray.

get_flux()

flux. (directly from Eppic)

get_frominputs_value(var, *, _match=None)

compute var based on inputs, i.e. when self.snap = INPUT_SNAP.

result drops ‘snap’ coord, if it exists.
self(‘frominputs_var’) is equivalent to:
with self.using(snap=INPUT_SNAP):
return self(‘var’).drop_vars(‘snap’, errors=’ignore’)
get_gamma()

adiabatic index.

[Not implemented for this class]
get_grad(var, *, _match=None)

gradient. ‘grad_{var}’ –> grad(var), i.e. (dn/dx, dn/dy, dn/dz).

returned components are determined by self.component.
(see also: the get_xyz pattern. E.g., ‘grad_n_x’ –> x component of grad(n).
to get grad of a vector’s component instead, use parentheses, e.g. ‘grad_(u_x)’)
if self.slices nonempty, self.deriv_before_slice controls whether slicing occurs before or after div.
get_growthfit(var, *, _match=None)

self(‘growthfit_var’) –> linear regression along ‘t’ coord, of ln|var|.

result[‘polyfit_coefficients’].sel(degree=1).drop_vars(‘degree’) gives the growth rate,

because growth rate = slope of natural log of |var| vs ‘t’.
result might also contain other variables, depending on self.polyfit_kw;
might want to use polyfit_stddev=True, polyfit_cov=True or polyfit_full=True to get more info.
see help(type(self).polyfit_kw) for more options.
get_growthfitk(var, *, _match=None)

self(‘growthfitk_var’) –> linear regression along ‘t’ coord, of ln|radfft_var|.

result[‘polyfit_coefficients’].sel(degree=1).drop_vars(‘degree’) gives the growth rate,

because growth rate = slope of natural log of |var| vs ‘t’.
result might also contain other variables, depending on self.polyfit_kw;
might want to use polyfit_stddev=True, polyfit_cov=True or polyfit_full=True to get more info.
see help(type(self).polyfit_kw) for more options.
Assumes, but does not check, that fft_dims are spatial, only.
get_growthk(var, *, _match=None)

self(‘growthk_var’) –> exponential growth rate of radfft_var.

i.e. for each k, gives slope of ln|radfft_var| vs ‘t’.
self(‘growthk_var’) == self(‘growthrate_radfft_var’).
Accepts strings starting with ‘growth_vs_k_’ or ‘growthk_’.
behavior affected by self.polyfit_kw; see help(type(self).polyfit_kw) for details.
Assumes, but does not check, that fft_dims are spatial, only.
get_growthrate(var, *, _match=None)

self(‘growthrate_var’) –> exponential growth rate of var. i.e., slope of ln|var| vs ‘t’.

self(‘growthrate_var’) == self(‘slopet_ln_abs_var’).
behavior affected by self.polyfit_kw; see help(type(self).polyfit_kw) for details.
get_guess_cpu_seconds(var, *, _match=None)

guess run cost, in cpu seconds. nt * guess_cpu_seconds_sum_per_timestep_safe

Uses ‘safe’ guess (unless ‘_unsafe’ included in name) but excludes initialization time.
Might want to add a safety factor (e.g. assume 20% larger than this time).
get_guess_cpu_seconds_per_each(var, *, _match=None)

guess log10(cpu seconds per (particle, per) grid cell, per timestep), for the indicated timer.

if ‘safe’ included in var, uses mean + stddev instead of just mean, to get a conservative estimate.
Result excludes initialization time (before iterations begin).
timer options:
‘all’: result will be a Dataset of results from all timers, with timer names as data_vars.
(timer names are ‘vadv time’, ‘xadv time’, ‘charge’, ‘collect’, ‘efield’, ‘output’.)
‘vadv’, ‘xadv’, ‘charge’, ‘collect’, ‘efield’, ‘output’: result for corresponding timer.
if timer is ‘all’, return sum of the results from other timers.
These results are per particle per grid cell per timestep:
‘vadv time’, ‘xadv time’, ‘charge’, ‘output’.
These results are per particle per timestep:
‘collect’, ‘efield’.
The guess is informed by self.CPU_SECONDS_PER_EACH_INFO,
which contains numerical values derived from some simulations run on Frontera.
Assumes ‘output’ is not very expensive.
The “output” timer was not tested across a large variety of ‘nout’.
(trying to detrend with respect to nout didn’t affect stddev significantly.)
get_guess_cpu_seconds_per_timestep_or_ct(var, *, _match=None)

guess cpu seconds required per (cell, per) timestep, for the indicated timer.

if ‘safe’ included in var, uses mean + stddev instead of just mean, to get a conservative estimate.
Use ‘ct’ to indicate ‘per cell per timestep’.
(result using ‘timestep’) == ncells_sim * (result using ‘ct’).
Result excludes initialization time (before iterations begin).
timer options:
‘all’: result will be a Dataset of results from all timers, with timer names as data_vars.
(timer names are ‘vadv time’, ‘xadv time’, ‘charge’, ‘collect’, ‘efield’, ‘output’.)
‘sum’: result will be the sum of the results from other timers.
‘vadv’, ‘xadv’, ‘charge’, ‘collect’, ‘efield’, ‘output’: result for corresponding timer.
Assumes ‘output’ is not very expensive; it was not tested as much as the others.
The guess is informed by self.CPU_SECONDS_PER_EACH_INFO.
For more details see: guess_cpu_seconds_per_each.
get_guess_node_hours(var, *, _match=None)

guess run cost, in node hours. guess_cpu_seconds * seconds2hours / tasks_per_node

(seconds2hours = 1/3600)
Uses ‘safe’ guess (unless ‘_unsafe’ included in name) but excludes initialization time.
Might want to add a safety factor (e.g. assume 20% larger than this time).
get_guess_runtime_seconds(var, *, _match=None)

guess run cost, in wall clock time [seconds]. guess_cpu_seconds / n_processors.

Uses ‘safe’ guess (unless ‘_unsafe’ included in name) but excludes initialization time.
Might want to add a safety factor (e.g. assume 20% larger than this time).
Compare directly with self(‘steps_seconds’).
get_gyrof()

(unsigned) gyrofrequency. gyrof == |sgyrof| == |q| |B| / m == |charge| * |B| / mass.

get_hat(var, *, _match=None, _val0=None, **_known_vals)

unit vector in the direction of var. hat_{A} –> A / |A|.

returned components are determined by self.component.
(e.g. when self.component==’x’, hat_A –> A_x / |A|.)
[EFF] can provide known val for A, to avoid recalculating it. (include leading underscore.)
e.g. self(‘hat_E’, _E=E) –> E / |E|, using E which is already known.
can alternatively provide _val0 for A.
get_ifft(var, *, _match=None)

N-dimensional ifft. ifft(var). Applied along all fft_dims in array.

self.get(‘ifft[N]_[var]’), where [N]=any integer or ‘’
E.g. ‘ifft_var’, ‘ifft1_var’, ‘ifft2_var’.
N provided –> ifft must be along exactly this many dimensions, else crash with DimensionError.
E.g. N=2 means self(array) must have exactly 2 dims which are also in self.fft_dims.
Feel free to separately self.fft_dims, or enter it as a kwarg via self(…, fft_dims=…).
get_imag(var, *, _match=None)

imaginary part. np.imag(self(var))

get_inf()

infinity, as an xarray.

get_init_seconds()

time [in seconds] spent initializing the run. (between start and when steps start.)

get_inputs_tfbi_vs_EBspeed()

get tfbi_vs_EBspeed at self.set_vars_from_inputs().

Makes a copy of self to do this computation, to avoid altering original self.
[TODO] update this if internal methods for this don’t alter the copy anymore
get_int(var, *, _match=None)

any integer, as an xarray.

get_ionnefrac()

ratio of n_ions / ne. Equivalent: self(‘nnefrac’, fluid=self.fluids.ions()).

get_ionnefrac_significant()

boolean array telling whether n_ions/ne >= self.nnefrac_tiny_thresh.

Equivalent: self(‘not_ionnefrac_tiny’)
get_ionnefrac_tiny()

boolean array telling whether n_ions/ne < self.nnefrac_tiny_thresh

get_kB()

boltzmann constant, in [self.units] units. Equivalent to self.u(‘kB’)

get_kappa()

(unsigned) kappa (magnetization parameter). kappa = |skappa| == |gyrof| / nusn.

kappa = |gyrofrequency| / collision frequency of self.fluid with neutrals.
get_ldebye()

Debye length (of self.fluid). ldebye = sqrt(epsilon0 kB T / (n q^2))

get_ldebye2()

squared Debye length (of self.fluid). ldebye2 = epsilon0 kB T / (n q^2)

get_ldebye_subset()

“total” Debye length; ldebye_subset = sqrt(epsilon0 kB / sum_fluids(n q^2 / (kB T)))

sum is taken over the fluids in self.fluid.
Equivalent: sqrt( 1 / sum_fluids(1/ldebye^2) )
get_ldebye_total()

total Debye length for all fluids; ldebye_total = sqrt(epsilon0 kB / sum_fluids(n q^2 / (kB T)))

sum is taken over all the fluids in self.fluids.
Equivalent: sqrt( 1 / sum_fluids(1/ldebye^2) )
get_linregt(var, *, _match=None)

linear regression along ‘t’ coord. result is an xarray.DataSet including ‘polyfit_coefficients’.

Equivalent to self.polyfit(var, ‘t’, degree=1).
behavior affected by self.polyfit_kw; see help(type(self).polyfit_kw) for details.
get_ln(var, *, _match=None)

log base e. ln(var). (‘ln’ and ‘loge’ are aliases. Uses np.log; not np.log10.)

get_load_direct_maindims_var(var, *, _match=None)

load maindims var directly (from files, cache, or setvars; see self.load_direct()).

var should be name of a directly loadable var (see self.directly_loadable_vars()).
Output always uses ‘raw’ units, regardless of self.units,
but coords are in self.coords_units (default: same as self.units).
get_log10(var, *, _match=None)

log base 10. log10(var)

get_log2(var, *, _match=None)

log base 2. log2(var)

get_logical_and(var, *, _match=None)

logical and. var0 and var1. Equivalent: self(var0) & self(var1)

get_logical_not(var, *, _match=None)

logical not. not var. Equivalent: ~self(var)

get_logical_or(var, *, _match=None)

logical or. var0 or var1. Equivalent: self(var0) | self(var1)

get_lowpass(var, *, _match=None)

lowpass filter across self.fft_dims; keep low frequencies, zero high frequencies.

ifft(fft(self(var) * filter), where filter = 1 for low frequencies, 0 for high frequencies.
fraction of each fft’d dimension to keep is determined by self.lowpass_keep.
Default is DEFAULTS.LOWPASS_KEEP (default: 0.4).
get_m()

mass, of a “single particle”. For protons, ~= +1 atomic mass unit

get_m_amu()

mass in atomic mass units. Equivalent to self(‘m/amu’).

get_m_neutral()

mass, of a “single neutral particle”. For Hydrogen, ~= +1 atomic mass unit

get_m_neutral_f()

mass, of a “single neutral particle,” varying across fluid. For Hydrogen, ~= +1 atomic mass unit

get_m_sj(*, _m_s=UNSET, _m_j=UNSET)

weighted mass. m_sj = m_s * m_j / (m_s + m_j).

s = self.fluid; j = self.jfluid.
[EFF] for efficiency, can provide m_s and/or m_j, if already known.
get_maindims_coords(units=None)

return dict of {‘x’: xcoords, ‘y’: ycoords}. Possibly also ‘z’: zcoords.

units: None or str
result will be in this unit system. if None, use self.coords_units (default: self.units).
coords will be subsampled appropriately if subsampling_info exists.
coords will also be sliced according to self.slices.
get_mask_var(var, *, _match=None)

mask_var –> masked version of self(var).

mask_var and stacked_mask_var = equivalent to self(var, masking=’stacked’).
simple_mask_var = equivalent to self(var, masking=’simple’).
get_max(var, *, _match=None)

maximum. max(var). Applied only along any self.stat_dims in array.

get_mean(var, *, _match=None)

mean. mean(var). Applied only along any self.stat_dims in array.

get_mean_free_path()

collisional mean free path. lmfp = vtherm / nusn = thermal velocity / collision frequency.

get_mean_pm_std(var, *, _match=None)

return dataset of ‘mean+std’, ‘mean’, ‘mean-std’ for var.

Computed along any self.stat_dims in array.
Equivalent: werr2pmstd_werrmean_var
get_meannormed(var, *, _match=None)

normalized by mean. var / mean(var). Applied only along any self.stat_dims in array.

get_meant(var, *, _match=None)

mean-across-time of var.

self(meant_var) –> self(var).mean(tdim), where tdim is the dim associated with time,
(tdim default ‘snap’, but if ‘t’ coord associated with a dim, use that dim.)
get_median(var, *, _match=None)

median. median(var). Applied only along any self.stat_dims in array.

get_min(var, *, _match=None)

minimum. min(var). Applied only along any self.stat_dims in array.

get_min_n_nodes_given_nsubdomains()

minimum number of nodes, given nsubdomains and tasks_per_node,

to ensure n_processors % nsubdomains == 0,
where n_processors = n_nodes * tasks_per_node.
Equivalent: nsubdomains / gcd(nsubdomains, tasks_per_node)
get_min_timescale()

minimum timescale across all timescales.

Equivalent: self(‘timescales’).pc.minimum()
get_min_timescale_type()

tells which timescale has the minimum value (across all timescales).

Equivalent: self(‘timescales_abbrv’).pc.varmin()
result is a string-valued array, values from self.TIMESCALE_VARS (removing ‘timescale_’ in names):
‘wplasma’, ‘gyrof’, ‘nusn’, ‘vtherm’, ‘EBspeed’
get_minf_timescale()

minimum timescale across all timescales and fluids.

Equivalent: self(‘timescales’).min(‘fluid’).pc.minimum()
get_minf_timescale_type()

tells which timescale has the minimum value (across all timescales and fluids).

Equivalent: self(‘timescales_abbrv’).min(‘fluid’).pc.varmin()
result is a string-valued array, values from self.TIMESCALE_VARS (removing ‘timescale_’ in names):
‘wplasma’, ‘gyrof’, ‘nusn’, ‘vtherm’, ‘EBspeed’
get_minus(var, *, _match=None)

subtraction. var0 - var1.

get_mod(var, *, _match=None, _val0=None, **_known_vals)

magnitude of var. mod_{A} –> |A|. == sqrt(A dot A) == sqrt(Ax^2 + Ay^2 + Az^2).

alias: ‘mag_{A}’ is equivalent to ‘mod_{A}’

if component(s) is provided, only include that component(s) during the calculation.
e.g. mod_A__xy –> sqrt(Ax^2 + Ay^2).
[EFF] can provide known vals for {var} to avoid recalculating it. (include leading underscore.)
e.g. self(‘mod_E’, _E=E) –> |E|, using E which is already known.

CAUTION: Not tested when simultaneously providing components such as mod_A__xy.

can alternatively provide _val0 for A.
get_mod2(var, *, _match=None, _val0=None, **_known_vals)

magnitude squared of var. mod2_{A} –> |A|^2. == A dot A == Ax^2 + Ay^2 + Az^2.

alias: ‘mag2_{A}’ is equivalent to ‘mod2_{A}’

if component(s) is provided, only include that component(s) during the calculation.
e.g. mod2_A__xy –> Ax^2 + Ay^2.
[EFF] can provide known vals for {var} to avoid recalculating it. (include leading underscore.)
e.g. self(‘mod2_E’, _E=E) –> |E|**2, using E which is already known.

CAUTION: Not tested when simultaneously providing components such as mod_A__xy.

can alternatively provide _val0 for A.
get_moment1()

1st moment of distribution function, along an axis (vector component). Mean.

directly from moments*.out files (multiplied by units conversion factor).
Compare with ‘nmean_u’ (which is equivalent to ‘mean_(n*u)/mean_n’).
(nmean instead of mean, because moments.out averages across all particles!
u is the value averaged across all particles in each cell,
and mean_u averages u across all cells, using an equal weight for each cell.
so mean_u gives less weight to particles in denser cells, unlike nmean_u and moments.out.)
get_moment2()

2nd moment of distribution function, along an axis (vector component). Variance.

directly from moments*.out files (multiplied by units conversion factor).
Compare with ‘nmean_(vsqr-(nmean_u)**2)’.
(nmean instead of mean, because moments.out averages across all particles!
vsqr is the value averaged across all particles in each cell,
and mean_vsqr averages vsqr across all cells, using an equal weight for each cell.
So, mean_vsqr gives less weight to particles in denser cells, unlike nmean_vsqr and moments.out.)
get_moment3()

3rd moment of distribution function, along an axis (vector component).

directly from moments*.out files (multiplied by units conversion factor).
get_moment4()

4th moment of distribution function, along an axis (vector component).

directly from moments*.out files (multiplied by units conversion factor).
get_n()

number density. n = n0 * (1 + deltafrac_n)

get_n0()

background density. (directly from Eppic.)

note: as with all other quantities, this will be output in [self.units] unit system;
numerically equal to eppic.i value if using ‘raw’ units.
get_n_neutral()

number density of neutrals.

get_n_nodes()

number of nodes used to run this run. From slurm file.

n_processors = n_nodes * tasks_per_node.
get_n_processors()

number of MPI processors used to run this run.

From logfile if possible, else from slurm files.
n_processors = n_nodes * tasks_per_node.
get_nan()

NaN, as an xarray.

get_nandelta(var, *, _match=None)

perturbation. var - mean(var), ignoring NaNs AND infs.

Applied only along any self.stat_dims in array.
get_nandeltafrac(var, *, _match=None)

perturbation. (var - mean(var)) / mean(var), ignoring NaNs AND infs.

Applied only along any self.stat_dims in array.
get_nanmax(var, *, _match=None)

maximum. max(var), ignoring NaNs AND infs. Applied only along any self.stat_dims in array.

get_nanmean(var, *, _match=None)

mean. mean(var), ignoring NaNs AND infs. Applied only along any self.stat_dims in array.

get_nanmedian(var, *, _match=None)

median. median(var), ignoring NaNs AND infs. Applied only along any self.stat_dims in array.

get_nanmin(var, *, _match=None)

minimum. min(var), ignoring NaNs AND infs. Applied only along any self.stat_dims in array.

get_nanrms(var, *, _match=None)

root mean square. sqrt(mean(var**2)), ignoring NaNs AND infs.

Applied only along any self.stat_dims in array.
get_nanstd(var, *, _match=None)

standard deviation. std(var), ignoring NaNs AND infs. Applied only along any self.stat_dims in array.

get_ncells_sim()

number of gridcells from simulation (differs from output when nout_avg != 1).

Scalar. E.g. Nx*Ny*Nz if 3D, Nx*Ny if 2D.
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_ndim_space()

number of spatial dimensions in simulation. 2 or 3.

get_ne()

electron number density. (ne qe) + sum_i (ni qi) = 0. (using qe < 0 convention)

get_negation(var, *, _match=None)

negation. -var.

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

ion-to-electron density ratio. niefrac = ni / ne.

Result always corresponds to fluid=IONS, regardless of current self.fluid.
get_nit_since_prev()

return number of timesteps since previous snapshot in self.

when determining previous snapshot, ignore any where snap.file_snap(self) is MISSING_SNAP.
return inf when no previous snap, e.g. at snap=0.
get_nmean(var, *, _match=None)

mean of var, weighted by n. nmean = sum(var * n) / sum(n). n=self(‘n’).

Equivalent: ‘nmean_var’ <–> ‘weighted_n_mean_var’
get_nnefrac()

ratio of number density to electron number density: n / ne.

get_nnefrac_significant()

boolean array telling whether n/ne >= self.nnefrac_tiny_thresh.

Equivalent: self(‘not_nnefrac_tiny’)
get_nnefrac_tiny()

boolean array telling whether n/ne < self.nnefrac_tiny_thresh

get_npcelld()

number of PIC particles per simulation cell.

get_npd()

number of PIC particles in each distribution.

This is equivalent to fluid[‘npd’] when it is provided,
otherwise determined by the appropriate alternative (npcelld, nptotd, or nptotcelld).
get_npow2_processors()

largest power of 2 which evenly divides n_processors.

E.g. if n_processors = 56 * 8 == 7 * 4 * 8 == 7 * 2^5, result would be 2^5.
get_nptotcell()

number of particles per cell for all fluids combined, appropriately weighted considering subcycling.

Equivalent: sum_fluids_(nptotcelld/subcycle)
get_nptotcelld()

number of PIC particles per simulation cell (total across all processors).

get_nptotd()

number of PIC particles (total across all processors).

get_nq()

charge density. nq = (n * q) = (number density * charge)

get_nstd(var, *, _match=None)

std of var, weighted by n. nstd = std(n*var)/mean(n), with n=self(‘n’).

get_nsubdomains()

number of subdomains. nsubdomains from the input deck.

Note: eppic runs require n_processors % nsubdomains == 0.

get_nuns()

collision frequency. for a single neutral particle to collide with any s.

nuns = nusn * (m / m_neutral) * (n / n_neutral).
(from conservation of momentum, and summing collisional momentum transfer between species)
get_nusj()

collision frequency.

“frequency for one particle of s (self.fluid) to collide with any of j (self.jfluid).”
Uses the appropriate formula based on self.collisions_mode, and self.fluid & self.jfluid.
get_nusj_best()

collision frequency, using self.collisions_mode=’best’.

“frequency for one particle of s (self.fluid) to collide with any of j (self.jfluid).”
Uses the appropriate formula based on self.fluid & self.jfluid.
Use coulomb for charge-charge, fromtable if table exists, maxwell otherwise.
get_nusj_coulomb()

coulomb collision frequency.

“frequency for one particle of s (self.fluid) to collide with any of j (self.jfluid).”
This is a good model for nusj when:
- s & j are both charged species.
nusj_coulomb = (1 Hz) * (1.7/20) * (ln(Lambda))
* (m_p/m_s) * (m_sj/m_p)^(1/2)
* (T_sj / Kelvin)^(-3/2)
* (q_s/q_e)^2 * (q_j/q_e)^2
* (n_j / (10^6 meters^-3)), where:
ln(Lambda) = Coulomb logarithm (see self.help(‘coulomb_logarithm’) for details)
n_j = number density of j (self.jfluid).
m_sj = weighted mass = m_s * m_j / (m_s + m_j)
T_sj = mass-weighted temperature = (m_s * T_j + m_j * T_s) / (m_s + m_j)
m_p = mass of proton
q_e = charge of electron
m_s, m_j = mass of s, j
T_s, T_j = temperature of s, j.
q_s, q_j = charge of s, j
get_nusj_fromtable()

collision frequency from a table.

“frequency for one particle of s (self.fluid) to collide with any of j (self.jfluid).”
Requires that the relevant CrossTable(s) are provided, in self.collisions_cross_mapping.
nusj_fromtable = n_j * (m_j / (m_s + m_j)) * C(T_sj) * sqrt(8 * kB * T_sj / (pi * m_sj)), where:
n_j = number density of j (self.jfluid)
m_sj = weighted mass = m_s * m_j / (m_s + m_j)
T_sj = mass-weighted temperature = (m_s * T_j + m_j * T_s) / (m_s + m_j)
m_s, m_j = mass of s, j
T_s, T_j = temperature of s, j
C(T_sj) = collisions_cross_section between s & j at temperature T_sj
kB = Boltzmann constant
get_nusj_maxwell()

maxwell collision frequency.

“frequency for one particle of s (self.fluid) to collide with any of j (self.jfluid).”
This is a good model for nusj when:
- s or j is neutral hydrogen.
(assumed by the implementation here; could be improved in the future)
- the charged species is a heavy ion.
(collisions between [e-,H] and [H+,H] behave differently.)
nusj_maxwell = (1 Hz) * (1.95856) * n_j * sqrt(
(alpha_n * q_e^2 / eps0) * (m_j / (m_s * (m_s + m_j)))
), where:
n_j = number density of j [si units, i.e. meters^-3]
alpha_n = polarizability of neutral hydrogen. [si units, i.e. meters^3]
q_e = charge of electron. [si units, i.e. C]
eps0 = permittivity of free space; standard definition for eps0. [si units]
m_s, m_j = mass of s, j. [si units, i.e. kg]
(formula from Oppenheim+2020, Appendix A.)
get_nusn()

collision frequency (of self.fluid) with neutrals.

“frequency for one particle of species s (self.fluid) to collide with any of the neutrals.”
[TODO] how does this compare with simulated collisions in PIC?
get_nusn_from_drift(var, *, _match=None)

nusn, calculated by assuming u satisfies momentum equation to zeroth order.

There are various options for how to solve for nusn, as explained below (see {drift}).
All solutions use nusn = sgyrof / skappa, where skappa is determined via
skappa = self(‘skappa’+var[len(‘nusn’):]).
E.g. ‘nusn_from_means_momExB’ –> use skappa = self(‘skappa_from_means_momExB’).
The description below helps explain the various options.
‘nusn_from_{means_}{u_}{drift}’
E.g. ‘nusn_from_means_momExB’, ‘nusn_from_hall’, ‘nusn_from_means_moment1_momB’
{means_} = ‘means_’ or ‘’.
if ‘means_’, take means of vars: ‘sgyrof’, any vars relevant to the chosen {drift} option.
{u_} = ‘’ or any other var then ‘_’.
if provided, use this var instead of ‘u’ for velocity. (Doesn’t affect “u_neutral” though.)
{drift} = ‘momExB’, ‘momE’, ‘hall’, or ‘pederson’
indicates how to solve for nusn. Use the similarly-named var when getting skappa.
‘momExB’ –> get skappa from the momentum equation in the E x B direction.
‘momE’ –> get skappa from the momentum equation in the E direction.
‘hall’ –> get skappa from u_hall = u, in the E x B direction.
‘pederson’ –> get skappa from u_pederson = u, in the E direction.
get_nvsqr()

n * ({x} component of velocity)^2. (directly from Eppic)

get_p()

momentum density. p = (u * r) = (velocity * mass density).

get_parallel(var, *, _match=None, _val0=None, _val1=None, **_known_vals)

A_par_B –> the component of A parallel to B.

Equivalent to self.take_parallel_to(B, A) == (A dot Bhat) Bhat.
see also: A_dot_hat_B, which is equivalent to mod_(A_par_B)
[EFF] can provide known vals for A or B, to avoid recalculating them. (include leading underscores.)
e.g. self(‘E_par_B’, _E=E, _B=B) –> E par to B, using E and B which are already known.
can alternatively provide _val0 for A and/or _val1 for B.
get_parenthesis(var, *, _match=None, **kw)

parenthesis. ‘{prefix}({here}){suffix}’, with no parenthesis inside {here}.

Ensures that {here} is interpreted as a single expression. Useful when combining operations.
E.g. ‘sqrt_q/m’, with no parenthesis, has an ambiguous interpretation.
‘sqrt_(q/m)’ unambiguously refers to “sqrt(ratio between q and m)”.
‘(sqrt_q)/m’ unambiguously refers to “ratio between sqrt(q) and m”.
The no-parenthesis interpretation is subject to change without warning, in future code updates.
(You can always check the interpretation that is being used, via self.match_var_tree(var))
get_parmod(var, *, _match=None, _val0=None, _val1=None, **_known_vals)

magnitude of the component of A parallel to B.

Equivalent to mod(A_par_B). Also equivalent to abs(A_dot_hat_B)
[EFF] can provide known vals for A or B, to avoid recalculating them. (include leading underscores.)
e.g. self(‘E_parmod_B’, _E=E, _B=B) –> |E par to B|, using E and B which are already known.
can alternatively provide _val0 for A and/or _val1 for B.
get_perp(var, *, _match=None, _val0=None, _val1=None, **_known_vals)

A_perp_B –> A after removing the component of A parallel to B.

Equivalent to self.take_perp_to(B, A) == A - (A dot Bhat) Bhat.
[EFF] can provide known vals for A or B, to avoid recalculating them. (include leading underscores.)
e.g. self(‘E_perp_B’, _E=E, _B=B) –> E perp to B, using E and B which are already known.
can alternatively provide _val0 for A and/or _val1 for B.
get_perpmod(var, *, _match=None, _val0=None, _val1=None, **_known_vals)

magnitude of A after removing the component of A parallel to B.

Equivalent to mod(A_perp_B).
[EFF] can provide known vals for A or B, to avoid recalculating them. (include leading underscores.)
e.g. self(‘E_perpmod_B’, _E=E, _B=B) –> |E perp to B|, using E and B which are already known.
can alternatively provide _val0 for A and/or _val1 for B.
get_phi()

electric potential. (directly from Eppic)

get_pi()

pi. numpy.pi. 3.1415…

get_plotter(name, who=UNSET)

gets the Plotter associated with this name and who.

Roughly equivalent: self.KNOWN_PLOTTERS[(name, who)]
name: str or Plotter
name of the plotter to use, or a Plotter instance.
who: UNSET, None, or str
person associated with the plotter.
UNSET –> use the plotter with this name; crash if found multiple same-named plotters.
see also: self.get_plotters(), which is good if you don’t know ‘who’, or want multiple plotters.
get_plotters(who=UNSET, kind=UNSET, *, name=None, all_whos=UNSET, all_kinds=UNSET, skip_who=[], skip_kinds=[], min_cost=None, max_cost=None, sortby=None, returns='plotters')

return list of all plotters associated with these inputs.

If called with no inputs, just returns a copy of self.UNIQUE_PLOTTERS.
who: UNSET, None, str, or list.
person associated with the plotter.
UNSET –> include plotters regardless of ‘who’.
None –> require len(plotter.who) == 0.
str –> require this name to be in plotter.who.
list –> require at least one of these to be in plotter.who
(or, if None in list, allow len(plotter.who)==0, too)
kind: UNSET, str, or list.
kind associated with the plotter.
UNSET –> include plotters regardless of ‘kind’.
str –> require this kind to be in plotter.kinds.
list –> require at least one of these to be in plotter.kinds.
name: None or str
plotter name. E.g. ‘deltafrac_n’.
None –> include all plotters regardless of ‘name’.
all_whos: UNSET or list.
include only plotters with ALL of these people in plotter.who.
all_kinds: UNSET or str.
include only plotters with ALL of these kinds in plotter.kinds.
skip_who: list
exclude plotters with any of these people in plotter.who.
skip_kinds: list
exclude plotters with any of these kinds in plotter.kinds.
min_cost: None or number
exclude plotters with cost < min_cost.
None –> no minimum.
max_cost: None or number
exclude plotters with cost > max_cost.
None –> no maximum.
sortby: None or ‘cost’
tells how to sort the result (if returns==’plotters’).
None –> keep in order they appear in self.UNIQUE_PLOTTERS.
‘cost’ –> sort by plotter.cost values.
returns: ‘plotters’, ‘names’, ‘who’, ‘kind’, or ‘kinds’
‘plotters’ –> returns list of plotters
‘names’ –> returns set of all names associated with at least 1 plotter in result.
‘who’ –> returns set of all people associated with at least 1 plotter in result.
‘kind’ or ‘kinds’ –> returns set of all kinds associated with at least 1 plotter in result.
get_plus(var, *, _match=None)

addition. var0 + var1.

get_pmstd2werr(var, *, _match=None)

convert dataset with ‘mean+std’ and ‘mean-std’ into dataset with ‘mean’ and ‘std’.

pmstd2werr_var will crash if self(var) doesn’t have ‘mean+std’ and ‘mean-std’ data vars.
get_power(var, *, _match=None)

power. var0 ** var1.

get_prod(var, *, _match=None)

prod. prod(var). Applied only along any self.stat_dims in array.

get_prod_fluid_var(var, *, _match=None)

var prodmed across self.fluid. Equivalent: self(var).pc.prod(‘fluid’).

(if not self.fluid_is_iterable(), result numerically equivalent to self(var).)

aliases: prod_fluid_var or prod_s_var.

get_prod_fluids_var(var, *, _match=None)

var prodmed across self.fluids. Equivalent: self(var, fluid=None).pc.prod(‘fluid’).

get_prod_ions_var(var, *, _match=None)

var prodmed across all ions in self.fluids.

Equivalent: self(var, fluid=self.fluids.ions()).pc.prod(‘fluid’).
get_prod_jfluid_var(var, *, _match=None)

var prodmed across self.jfluid. Equivalent: self(var).pc.prod(‘jfluid’).

(if not self.jfluid_is_iterable(), result numerically equivalent to self(var).)

aliases: prod_jfluid_var or prod_j_var.

get_prod_jfluids_var(var, *, _match=None)

var prodmed across self.jfluids. Equivalent: self(var, jfluid=None).pc.prod(‘jfluid’).

get_prod_neutrals_var(var, *, _match=None)

var prodmed across all neutrals in self.fluids.

Equivalent: self(var, fluid=self.fluids.neutrals()).pc.prod(‘fluid’).
get_pwl2_var(var, *, _match=None)

get pwl2_flatend fit to var across self.snap, evaluated at self.snap.

(fail if self.snap is not a list of multiple snaps.)
pwl2_flatend is a piecewise linear function with 2 pieces; final piece has slope=0.
Equivalent: fitter=self(var).pc.pwl2_flatend_fitter(‘t’); fitter.fit(); fitter.eval()
get_q()

charge, of a “single particle”. For protons, == +1 elementary charge

get_r()

mass density. r = (n * m) = (number density * mass)

get_rad2deg(var, *, _match=None)

convert radians to degrees. rad2deg_{A} –> A * 180 / pi.

self(‘rad2deg_var’) == np.rad2deg(self(‘var’))
get_real(var, *, _match=None)

real part. np.real(self(var))

get_rms(var, *, _match=None)

root mean square. sqrt(mean(var**2)). Applied only along any self.stat_dims in array.

get_rmscomps(var, *, _match=None)

root mean squared of components.

E.g., rmscomps_{A} –> sqrt((Ax^2 + Ay^2 + Az^2) / 3), if A has 3 components.
get_rosenberg_multi()

rosenberg criterion for multiple ions: rosenberg_multi = (nusn_multi / wplasma_multi)^2.

quasineutrality is “reasonable” (during farley-buneman analysis) iff rosenberg_multi << 1.
This criterion should be more accurate than using rosenberg_qn for each ion, separately.
(Below uses ‘…’ to denote “terms independent of wplasma_i and nu_in”.)
Rosenberg 1998 equation 17, derived from equation 14, assumed only 1 ion.
However, equation 14 comes from 13, where wplasma_i and nu_in only appear as (Ai/wplasma_i^2).
where Ai = omega * (omega + i nu_in) + … (see equation 15).
equation 13 looks like: … + (Ai/wplasma_i^2) = 0
From equation 4 I infer the dispersion relation with multiple ions will be like:
… + sum_i (Ai/wplasma_i^2) = 0.
Expanding this sum reveals that it can be expressed in the same algebraic form as with 1 ion:
… + Am/wplasma_m^2 = 0, when:
wplasma_m^2 = 1 / (1/wplasma_1^2 + 1/wplasma_2^2 + …),
Am = omega * (omega + i nu_mn) + …
nu_mn = nu1 * weight1 + nu2 * weight2 + … / (weight1 + weight2 + …),
where weightj = wplasma_1^2 * wplasma_2^2 * … / wplasma_j^2.
Thus, the remaining steps done by Rosenberg to derive the criterion should apply in the same way,
and for multiple ions we can conclude the criterion is (nu_mn / wplasma_m)^2 << 1.
Okay, actually, in practice, it’s probably not useful to use this…
it mostly just selects the least-dense ion, due to the 1/wplasma^2 scaling.
Also, the criterion means “instability gets dampened when collisions are faster than plasma oscillations”
But for multiple ions, it’s really more like, the instability for THAT ion gets dampened…
(Also, I think one of the assumptions in the paper probably fails when wplasma is small…)
get_rosenberg_multi_nusn()

collision frequency for rosenberg criterion with multiple ions.

nusn_multi = nu1 * weight1 + nu2 * weight2 + … / (weight1 + weight2 + …),
where weightj = wplasma_1^2 * wplasma_2^2 * … / wplasma_j^2.
see rosenberg_multi for details.
get_rosenberg_multi_wplasma()

plasma frequency for rosenberg criterion with multiple ions.

wplasma_multi^2 = 1 / (1 / wplasma1^2 + 1 / wplasma2^2 + …),
with sum across all ions in self(‘wplasma’, fluids=None)
see rosenberg_multi for details.
get_rosenberg_n()

n such that rosenberg_qn == 1, for each fluid.

Equivalent: rosenberg_qn * n.
To satisfy Rosenberg criterion, need rosenberg_qn << 1.
rosenberg_qn = (nusn / wplasma)^2 = nusn^2 * m * eps0 / (n * q^2),
which is proportional to 1 / n
–> n is “good” if n >> rosenberg_n.
Note: this also happens to be the solution to lmfp == ldebye…
lmfp = (vtherm/nusn) = ((kB T / m)^0.5 / nusn) == (epsilon0 kB T / (n q^2))^0.5 = ldebye
–> (nusn^-2 m^-1) == (epsilon0 n^-1 q^-2)
–> n == epsilon0 nusn^2 m / q^2.
get_rosenberg_n_margin()

n / rosenberg_n. margin of safety for rosenberg criterion. “safe” if margin is large.

get_rosenberg_qn()

Rosenberg criterion for quasineutrality, for each fluid: rosenberg_qn = (nusn / wplasma)^2.

quasineutrality is “reasonable” (during farley-buneman analysis) iff rosenberg_qn << 1 for ions.
(Intuitively: quasineutrality reasonable iff ‘collisions much slower than plasma oscillations’)
If multiple ions, consider using self(‘rosenberg_multi’) instead of one criterion per ion.
see Rosenberg 1998, equation 17, for details.
get_run_time()

Wall clock runtime for each snap. Same units as timers_dat info.

get_runtimes()

timers_dat info as an xarray.DataArray, at snaps in self.snap. see also: ‘timers’.

get_safe_pow2_subcycle(*, subcycle_safety=UNSET)

largest “safe” power of 2 subcycling allowed for each fluid in self.fluid.

result = array of values like 2^N, with largest N such that result < best_subcycle / safety.
(larger safety produces “safer” results. For safe_subcycle, just use best_subcycle / safety.)
get_sci_number(var, *, _match=None)

any number in scientific notation, as an xarray.

get_seconds2timer()

conversion factor from seconds to timers.dat units.

E.g. seconds2timer = 100 <–> 1 timer unit = 0.01 seconds <–> 1 second = 100 timer units.
seconds2timer = sum(run_time) / steps_seconds
Might vary from machine to machine. Seems to be 100 on Frontera (plus small rounding errors).
get_set_or_cached(var)

returns var if found in self.setvars or self.cache, with compatible behavior_attrs.

otherwise, raise CacheNotApplicableError.
if var is found in self.setvars and has relevant, but not matching behavior_attrs,
self.load_across_dims will be used to load the value.
get_sgyrof()

signed gyrofrequency. sgyrof == q |B| / m == charge * |B| / mass. Negative when charge < 0.

get_skappa()

signed kappa (magnetization parameter). skappa = sgyrof / nusn. Negative when charge < 0.

skappa = gyrofrequency / collision frequency of self.fluid with neutrals.
gyrofrequency == q * |B| / (mass * nusn).
get_skappa_from_hall(var, *, _match=None)

signed kappa (magnetization parameter) that statisfies u_hall = u, in the E x B direction.

‘skappa_from_{means_}{u_}hall’
E.g. ‘skappa_from_means_hall’, ‘skappa_from_hall’, ‘skappa_from_means_moment1_hall’
{means_} = ‘means_’ or ‘’.
if ‘means_’, take means of vars: ‘u’, ‘u_neutral’, ‘mod_B’, ‘E_cross_B’
{u_} = ‘’ or any other var then ‘_’.
if provided, use this var instead of ‘u’ for velocity. (Doesn’t affect “u_neutral” though.)
E.g. eppic calculator might use ‘moment1’ here, as in ‘skappa_from_moment1_hall’.
Algebraic solution:
formula for u_hall (from solving momentum equation for u in the E x B direction):
u_hall = (kappa**2 / (1 + kappa**2)) * (E x B) / |B|**2
solving for kappa**2, assuming u instead of u_hall, yields:
(u dot (E x B)) == (kappa**2 / (1 + kappa**2)) * (|E x B|**2 / |B|**2)
A + A * kappa**2 - kappa**2 == 0, where A = (u dot (E x B)) / (|E x B|**2 / |B|**2)
kappa**2 = A / (1 - A)
–> skappa = +- sqrt(A / (1 - A)),
There are two solutions; return solution with the same sign as self(‘q’) (i.e. fluid’s charge)
get_skappa_from_momE(var, *, _match=None)

signed kappa (magnetization parameter) that statisfies momentum equation in the E direction.

‘skappa_from_{means_}{u_}momE’
E.g. ‘skappa_from_means_momE’, ‘skappa_from_momE’, ‘skappa_from_means_moment1_momE’
{means_} = ‘means_’ or ‘’.
if ‘means_’, take means of vars: ‘u’, ‘u_neutral’, ‘mod_E’, ‘mod_B’, ‘E’, ‘E_cross_B’
{u_} = ‘’ or any other var then ‘_’.
if provided, use this var instead of ‘u’ for velocity. (Doesn’t affect “u_neutral” though.)
E.g. eppic calculator might use ‘moment1’ here, as in ‘skappa_from_moment1_momE’.
Algebraic solution:
momentum equation, rearranged using skappa = q * |B| / (m * nusn):
0 = q (E + u x B) - m * nusn * (u - u_neutral)
0 = skappa (E + u x B) - |B| (u - u_neutral)
dotting with E:
0 = skappa (|E|^2 + (u x B) dot E) - |B| (u - u_neutral) dot E # note uxB.E == BxE.u == -ExB.u
–> skappa = |B| (u - u_neutral) dot E / (|E|^2 - u dot (E x B))

Note: results untrustworthy when kappa >> 1, since that involves dividing by a value close to 0.

get_skappa_from_momExB(var, *, _match=None)

signed kappa (magnetization parameter) that statisfies momentum equation in the E x B direction.

‘skappa_from_{means_}{u_}momExB’
E.g. ‘skappa_from_means_momExB’, ‘skappa_from_momExB’, ‘skappa_from_means_moment1_momExB’
{means_} = ‘means_’ or ‘’.
if ‘means_’, take means of vars: ‘u’, ‘u_neutral’, ‘mod_B’, ‘E_cross_B’, ‘u_cross_B’
{u_} = ‘’ or any other var then ‘_’.
if provided, use this var instead of ‘u’ for velocity. (Doesn’t affect “u_neutral” though.)
E.g. eppic calculator might use ‘moment1’ here, as in ‘skappa_from_moment1_momExB’.
Algebraic solution:
momentum equation, rearranged using skappa = q * |B| / (m * nusn):
0 = q (E + u x B) - m * nusn * (u - u_neutral)
0 = skappa (E + u x B) - |B| (u - u_neutral)
dotting with E x B:
0 = skappa [(u x B) dot (E x B)] - |B| [(u - u_neutral) dot (E x B)]
–> skappa = |B| [(u - u_neutral) dot (E x B)] / [(u x B) dot (E x B)]
get_skappa_from_pederson(var, *, _match=None)

signed kappa (magnetization parameter) that statisfies u_pederson = u, in the E direction.

‘skappa_from_{means_}{u_}pederson’
E.g. ‘skappa_from_means_pederson’, ‘skappa_from_pederson’, ‘skappa_from_means_moment1_pederson’
{means_} = ‘means_’ or ‘’.
if ‘means_’, take means of vars: ‘u’, ‘u_neutral’, ‘mod_B’, ‘E’, ‘mod_E’,
{u_} = ‘’ or any other var then ‘_’.
if provided, use this var instead of ‘u’ for velocity. (Doesn’t affect “u_neutral” though.)
E.g. eppic calculator might use ‘moment1’ here, as in ‘skappa_from_moment1_pederson’.
Algebraic solution:
formula for u_pederson (from solving momentum equation for u in the E direction):
u_pederson = (skappa / (1 + skappa**2)) * E / |B|
solving for skappa, assuming u instead of u_pederson, yields:
(u dot E) == (skappa / (1 + skappa**2)) * (|E|**2 / |B|)
A + A * skappa**2 - skappa == 0, where A = (u dot E) / (|E|**2 / |B|)
skappa = (1 +- sqrt((-1)^2 - 4 * A * A)) / (2 * A),
There are two solutions; the correct choice can be determined by using the momentum equation;
the correct choice for the +- sign turns out to be: -sign(q) where q = self(‘q’) == fluid’s charge.

Note: results untrustworthy when kappa >> 1, since that involves dividing by a value close to 0.

get_slopet(var, *, _match=None)

slope calculated from linear regression along ‘t’ coord.

self(‘slopet_var’) == self(‘linregt_var)[‘polyfit_coefficients’].sel(degree=1).drop_vars(‘degree’)
behavior affected by self.polyfit_kw; see help(type(self).polyfit_kw) for details.
get_slurm_options()

dataset of all slurm options from slurmfiles in self.dirname.

crash if multiple slurmfiles in self.dirname with conflicting options.
property get_space_coords

alias to get_maindims_coords

get_sparmod(var, *, _match=None, _val0=None, _val1=None, **_known_vals)

signed “magnitude” of the component of A parallel to B.

Equivalent to A_dot_hat_B. Also abs(A_sparmod_B) is equivalent to mod(A_par_B).
[EFF] can provide known vals for A or B, to avoid recalculating them. (include leading underscores.)
e.g. self(‘E_parmod_B’, _E=E, _B=B) –> |E par to B|, using E and B which are already known.
can alternatively provide _val0 for A and/or _val1 for B.
get_sqrt(var, *, _match=None)

square root. sqrt(var)

get_stats(var, *, _match=None)

return dataset of stats for var

stats include: mean, std, min, max, median, rms.
Applied only along any self.stat_dims in array.
Incompatible with Dataset vars.
Consider also: self(‘astats_var’), self(‘var’).pc.stats()
get_std(var, *, _match=None)

standard deviation. std(var). Applied only along any self.stat_dims in array.

get_steps_seconds()

time [in seconds] spent doing timesteps. (total duration minus init_seconds.)

get_subcycle()

subcycling factor (for each fluid in self.fluid).

(If subcycle not provided for a distribution, assume it implies subcycle=1).
get_sum(var, *, _match=None)

sum. sum(var). Applied only along any self.stat_dims in array.

get_sum_fluid_var(var, *, _match=None)

var summed across self.fluid. Equivalent: self(var).pc.sum(‘fluid’).

(if not self.fluid_is_iterable(), result numerically equivalent to self(var).)

aliases: sum_fluid_var or sum_s_var.

get_sum_fluids_var(var, *, _match=None)

var summed across self.fluids. Equivalent: self(var, fluid=None).pc.sum(‘fluid’).

get_sum_ions_var(var, *, _match=None)

var summed across all ions in self.fluids.

Equivalent: self(var, fluid=self.fluids.ions()).pc.sum(‘fluid’).
get_sum_jfluid_var(var, *, _match=None)

var summed across self.jfluid. Equivalent: self(var).pc.sum(‘jfluid’).

(if not self.jfluid_is_iterable(), result numerically equivalent to self(var).)

aliases: sum_jfluid_var or sum_j_var.

get_sum_jfluids_var(var, *, _match=None)

var summed across self.jfluids. Equivalent: self(var, jfluid=None).pc.sum(‘jfluid’).

get_sum_neutrals_var(var, *, _match=None)

var summed across all neutrals in self.fluids.

Equivalent: self(var, fluid=self.fluids.neutrals()).pc.sum(‘fluid’).
get_surelin_var(var, *, _match=None)

values of var between (inclusive) t_surelin_min and t_surelin. Mask all other values.

[TODO][EFF] wasted time computing values which will later be masked…
get_sureturb_var(var, *, _match=None)

values of var at or after t_sureturb. Mask all values before t_sureturb.

[TODO][EFF] wasted time computing values which will later be masked…
get_t_surelin()

time before which, values are definitely in the linear regime.

self(‘t_turb’) * self.surelin_quantile.
get_t_surelin_min()

start time of “definitely linear regime”.

self(‘t_turb’) * self.surelin_min_quantile.
get_t_sureturb()

time, after which, values are definitely in the turbulent regime.

Currently, just returns self(‘t_turb’).
Eventually might implement some safety factor since t_turb might not be exact.
get_t_turb()

time of turbulent onset. Equal to self.t_turb if set; Crash if not set.

(here always converts result to DataArray if not DataArray already.)
get_t_turb_from_pwl2_var(var, *, _match=None)

t_turb from pwl2_flatend fit to var. Might want to do self.t_turb = result.

result depends on self.blur_sigma.
Equivalent: fitter=self(‘var’).pc.pwl2_flatend_fitter(‘t’); fitter.fit(); fitter.get_xsat()

Suggestion: t_turb_from_pwl2_ln_std_blur_deltafrac_n

get_tasks_per_node()

number of processors per node. From slurm file.

n_processors = n_nodes * tasks_per_node.
get_tfbi_EBspeed_grid()

return a 1D grid of EBspeed values with constant logstep.

determines logmin, logmax, logstep (base 10) from self.tfbi_EBspeed_grid_size.
result’s name & EBspeed grid dim is always ‘EBspeed’.
get_tfbi_EBspeed_thresh()

threshold EBspeed for TFBI to grow. NaN if no growth predicted across the EBspeed grid considered.

Assumes user has already run self.solve_tfbi_vs_EBspeed().

If not, consider doing:
copied = self.copy()
copied.set_attrs(maindims_means=True, snap=0) # or some other way to downsample…
copied.solve_tfbi_vs_EBspeed()
equivalent to tfbi_vs_EBspeed.pc.min_coord_where(‘EBspeed’, tfbi_vs_EBspeed.it.growth_kmax()>0)
get_tfbi_E_thresh()

threshold E_un0_perpmag_B for TFBI to grow. NaN if no growth predicted across the EBspeed grid considered.

Equivalent: self(‘tfbi_EBspeed_thresh’) * self(‘mod_B’).
Assumes user has already run self.solve_tfbi_vs_EBspeed().
See self.help(‘tfbi_EBspeed_thresh’) for more details.
get_tfbi_all(**kw_get_vars)

returns xarray.Dataset of values relevant to TFBI theory.

This includes tfbi_inputs (required for theory) and tfbi_extras (optional)
Results depend on self.fluid. May want to call as self(‘tfbi_all’, fluid=CHARGED).
get_tfbi_extras(**kw_get_vars)

returns xarray.Dataset of values relevant to TFBI theory but not necessary for inputs.

Currently this just includes:
‘eqperp_lmfp’: each fluid’s collisional mean free path at its “equilibrium” temperature,
after considering zeroth order heating due to E_un0_perpmag_B.
‘SF_n’: sum of number densities of all species (including neutrals)
‘n’: number densities of each specie in self.fluid.
‘n_n’: number density of neutral fluid.
‘n*kappa’: number density times kappa.
TFBI dispersion relation terms scale with n*kappa for each fluid,
so this quantity roughly estimates the relative importance of each fluid.
Results depend on self.fluid. May want to call as self(‘tfbi_extras’, fluid=CHARGED).
get_tfbi_fscale()

tfbi_fscale = n * kappa

tfbi dispersion relation sums terms proportional to n * kappa, for each fluid.
get_tfbi_fscale_rel()

tfbi_fscale_rel = tfbi_fscale(this fluid) / tfbi_fscale(electrons).

get_tfbi_inputs(**kw_get_vars)

returns xarray.Dataset of values to input to the tfbi theory.

“global” scalars (no dependence on component nor fluid)
‘mod_B’: |magnetic field|
‘E_un0_perpmag_B’: |E_un0 perp to B|. E_un0 = electric field in u_neutral=0 frame.
‘kB’: boltzmann constant. kB * T = temperature in energy units.
‘T_n’: temperature of neutrals.
‘m_n’: mass of neutrals.
scalars which depend on fluid. Note: checks self.fluid, not self.fluids.
‘m’: mass of all non-neutral fluids
‘nusn’: collision frequency between fluid and neutrals.
‘skappa’: signed magnetization parameter; q |B| / (m nusn)
‘eqperp_ldebye’: each fluid’s debye length at its “equilibrium” temperature,
after considering zeroth order heating due to E_un0_perpmag_B.
Results depend on self.fluid. May want to call as self(‘tfbi_inputs’, fluid=CHARGED).
get_tfbi_omega(*, kw_tfbi_solve={}, **kw_tfbi_solver)

Thermal Farley Buneman Instability roots with largest imaginary part at each point in self.

Equivalent: self.tfbi_solver(**kw_tfbi_solver).solve(**kw_solve)[‘omega’].
Can provide kwargs, e.g. self(‘tfbi_omega’, ions=[‘H_II’, ‘C_II’], kw_tfbi_solve=dict(ncpu=1)).
For more control, use self.tfbi_solver() directly.
For even more control, use the pattern described in help(self.tfbi_solver_cls).
Recommended: consider using ‘tfbi_omega_ds’ instead of ‘tfbi_omega’.
‘tfbi_omega_ds’ gives the full Dataset of all values relevant to the solution.
‘tfbi_omega’ just gives the DataArray of omega, which is harder to inspect later.
get_tfbi_omega_ds(*, kw_tfbi_solve={}, **kw_tfbi_solver)

Thermal Farley Buneman Instability solution at each point in self.

Equivalent: self.tfbi_solver(**kw_tfbi_solver).solve(**kw_solve).
Can provide kwargs, e.g. self(‘tfbi_omega_ds’, ions=[‘H_II’, ‘C_II’], kw_tfbi_solve=dict(ncpu=1)).
For more control, use self.tfbi_solver() directly.
For even more control, use the pattern described in help(self.tfbi_solver_cls).
get_tfbi_vs_EBspeed()

return tfbi solution across EBspeed grid. Load saved result if it exists, else save result to file.

CAUTION: the implementation here might self.set(‘E_un0_perpmod_B’, self(‘mod_B’) * EBspeed)

[TODO] avoid changing self.setvars… (or, at least, restore previous self.setvars afterwards.)
CAUTION: the implementation here assumes self.tfbi_EBspeed_grid_size is enough to uniquely specify the result;
e.g. if there is a different result at each snapshot of self, that will not be understood here.
Equivalent: self.solve_tfbi_vs_EBspeed(cache=’caches’)
get_time_frac(var, *, _match=None)

fraction of runtime spent on writing or calculating.

var=’write_time_frac’ –> fraction of runtime spent writing output files.
var=’calc_time_frac’ –> fraction of runtime spent calculating, ignoring write_time.
get_time_requested()

time limit for this run. From slurm file. Result is a string, like hh:mm:ss.

For numeric results, see self(‘hours_requested’), minutes_requested, or seconds_requested.
get_time_requested_numeric(var, *, _match=None)

time limit for this run, in hours, minutes, or seconds. From slurm file.

Result is the total amount, e.g. ‘01:15:00’ –> mins_requested=75.
get_timer2seconds()

conversion factor from timers.dat units to seconds.

E.g. timer2seconds = 0.01 <–> 1 timer unit = 0.01 seconds <–> 1 second = 100 timer units.
timer2seconds = steps_seconds / sum(run_time)
Might vary from machine to machine. Seems to be 0.01 on Frontera (plus small rounding errors).
get_timers()

timers_dat info as an xarray.Dataset, at snaps in self.snap. see also: ‘runtimes’.

get_times(var, *, _match=None)

multiplication. var0 * var1.

get_timescale_EBdrift()

timescale from drift speed if possible, else from speed using E & B fields.

tries to return self(‘timescale_udrift’), but if that causes a QuantCalcError,
use self(‘timescale_EBspeed’) instead.
get_timescale_EBspeed()

timescale from speed using E & B fields. dsmin / (|E_un0 cross B| / |B|^2).

E_un0 (not E) because the derivation assumes neutral frame: u_neutral=0.

note: to be more precise, use timescale_udrift instead.

get_timescale_eqperp_vtherm()

timescale from thermal velocity, using T_from_Eheat_perp instead of T.

dsmin / eqperp_vtherm.
get_timescale_gyrof()

timescale for cyclotron motion. 2 * pi / gyrof. (Hz, not rad/s)

gyrof = |q| |B| / m.
get_timescale_nusn()

timescale for collisions with neutrals. 1 / nusn.

nusn = collision frequency of self.fluid with neutrals.
get_timescale_udrift()

timescale from drift speed. dsmin / mod_u_drift.

note: to be less precise (but computationally cheaper), use timescale_EBspeed instead.

For electrons when kappae >> 1, timescale_EBspeed ~= timescale_udrift.
When accounting for directionality, or kappae <~= 1, or non-electrons,
timescale_EBspeed is always more conservative (i.e. smaller) than timescale_udrift.
get_timescale_vtherm()

timescale from thermal velocity. dsmin / vthermal.

vthermal = sqrt(kB T / m).
get_timescale_wplasma()

timescale from plasma oscillations. 2 * pi / wplasma. (Hz, not rad/s)

wplasma = sqrt(n q^2 / (m epsilon0)).
get_timescales()

all timescales (from self.TIMESCALE_VARS) as a dataset.

Consider also: self(‘timescales_abbrv’)
Useful patterns you might want to consider:
self(‘timescales’, maindims_means=True) # timescales based on mean values only
self(‘timescales’).min(‘fluid’) # minimum timescales across all fluids
self(‘timescales’).pc.minimum() # minimum timescale across all timescales
equivalent: self(‘min_timescale’)
self(‘timescales’).min(‘fluid’).pc.minimum() # minimum timescale at each point.
self(‘timescales’).pc.varmin() # name of timescale with minimum value at each point.
# timescale variable names, sorted from min to max values.
self(‘timescales’).to_dataarray().pc.sort_along(‘variable’)[‘variable’]
get_timescales_abbrv()

all timescales (from self.TIMESCALE_VARS) as a dataset, abbreviating names.

abbreviates ‘timescale_var’ –> ‘var’.
get_timestep_cost_or_dt_cost(var, *, _match=None)

total cpu time per simulated particle, per timestep (or per dt).

time_cost = (runtime / timestep_or_dt) * (n_processors / total number of particles)

total number of particles = n_processors * npart.

Note: n_processors cancels out; time_cost = (runtime / timestep_or_dt) / npart

timestep_or_dt = one timestep or one dt; see below.
npart = number of simulated particles, in one processor. Depends on {settings}; see below.
‘{clock}_{time}_cost{settings}’
E.g. ‘run_timestep_cost’, ‘write_dt_cost_f’, ‘calc_dt_cost_nosubf’
{clock} = ‘run’, ‘calc’, or ‘write’
tells which clock to use.
‘run’ –> ‘Wall clock’ | ‘calc’ –> ‘Wall Clock - output’ | ‘write’ –> ‘output’
{time} = ‘timestep’ or ‘dt’
‘timestep’ –> report result as cost per timestep, regardless of dt.
‘dt’ –> report result as cost per dt (converted to SI units).
{settings} = ‘’, ‘_f’, ‘_nosub’, ‘_fnosub’, or ‘_nosubf’
tells whether to return a separate value for each fluid, and whether to account for subcycling.
‘’ –> single value. account for subcycling. npart = self(‘npd/subcycle’).sum(‘fluid’)
‘_nosub’ –> single value. ignore subcycling. npart = self(‘npd’).sum(‘fluid’)
‘_f’ –> per-fluid values. account for subcycling. npart = self(‘npd/subcycle’)
‘_fnosub’ –> per-fluid values. ignore subcycling. npart = self(‘npd’)
‘_nosubf’ –> same as ‘_fnosub’; provided for convenience.
accounting for subcycling means dividing by the subcycling factor,
because less effort is spent on subcycled distributions.
get_total_seconds()

duration [in seconds] spent to run the entire run.

get_tturb_var(var, *, _match=None)

values of var at or after t_turb. Mask all values before t_turb.

[TODO][EFF] wasted time computing values which will later be masked…
get_tturbvar00()

var used for t_turb ‘00’ standard: caches_ln_std_blur_deltafrac_n,

with fluid=electron, snap=None, blur_sigma=10.
get_turblindiff_var(var, *, _match=None)

meant_sureturb_var - meant_surelin_var.

i.e., (time-averaged value in turbulent regime) minus (time-averaged value in linear regime).
see also: werrturblindiff_var
get_turblindiffwerr_var(var, *, _match=None)

werrmeant_sureturb_var - werrmeant_surelin_var.

i.e., (time-averaged value in turbulent regime) minus (time-averaged value in linear regime),
but result is a Dataset with ‘mean’ and ‘std’ data_vars,
with ‘std’ coming from “standard” error propagation formula assuming independent errors:
std(A - B) = sqrt(std(A)**2 + std(B)**2).
see also: turblindiff_var
get_turblindivwerr_var(var, *, _match=None)

werrmeant_sureturb_var / werrmeant_surelin_var.

i.e., (time-averaged value in turbulent regime) divided by (time-averaged value in linear regime),
but result is a Dataset with ‘mean’ and ‘std’ data_vars,
with ‘std’ coming from “standard” error propagation formula assuming independent errors.
get_u()

velocity. u = flux / n

get_u_EdotB(*, _E=None, _B=None)

EdotB drift velocity. u_EdotB = (skappa**3 / (1 + skappa**2)) * (E_un0 dot B) B / |B|^3

(Commonly neglected, but comes from the same physical equation as hall & pederson drifts;
from solving equilibrium momentum equation for u, when neglecting all derivatives.)
[EFF] for efficiency, can provide E and/or B, if already known.
get_u_drift()

equilibrium velocity; solution to the momentum equation with collisions,

assuming zero acceleration and zero spatial gradients.
u_drift = u_hall + u_pederson + u_EdotB.
get_u_hall(*, _E=None, _B=None)

Hall drift velocity. u_hall = (kappa**2 / (1 + kappa**2)) * (E_un0 x B) / |B|**2,

where kappa is the magnetization parameter, kappa = gyrof / nusn.
[EFF] for efficiency, can provide E and/or B, if already known.
get_u_neutral()

returns 0, since u_neutral is always 0 in every component, for eppic.

get_u_pederson(*, _E=None, _B=None)

Pederson drift velocity. u_pederson = (skappa / (1 + skappa**2)) * E_un0 / |B|,

where skappa is the (signed) magnetization parameter, skappa = q * |B| / (m * nusn).
[EFF] for efficiency, can provide E and/or B, if already known.
get_unwrapt_2pi_var(var, *, _match=None)

unwrapt_{A} –> unwrapped self(A) along ‘t’, via np.unwrap with period=2*pi.

CAUTION: result at a given snapshot can vary depending on self.snap,
(though, (result % 2*pi) will always be the same.)
E.g. self(‘unwrapt_angle_xy_E’) –> angle between +xhat and E, but unwrapped,
so e.g. if results change from just above -pi to just below -pi,
the values below -pi will actually be below -pi,
instead of being reported as 2*pi + (value just below -pi).
get_upar()

velocity vector, parallel to B. This is a full 3-vector.

Equivalent: self(‘u_par_B’) == (u dot Bhat) Bhat
get_uperp()

velocity vector, perpendicular to B. This is a full 3-vector.

Equivalent: self(‘u_perp_B’) == u - self(‘u_par_B’) == u - (u dot Bhat) Bhat
get_valfven()

Alfven speed. valfven = |B| / sqrt(mu0 * r)

get_valfven2()

Alfven speed squared. valfven2 = |B|^2 / (mu0 * r)

get_var_at_max_of_ref(var, *, _match=None)

var_at_max_of_ref –> self(var) at argmax of self(ref),

taking argmax across all dims in self(ref).
For more precise control, consider directly using xarray_at_max_of.
get_var_at_min_of_ref(var, *, _match=None)

var_at_min_of_ref –> self(var) at argmin of self(ref),

taking argmin across all dims in self(ref).
For more precise control, consider directly using xarray_at_min_of.
get_var_where_condition(var, *, _match=None)

var_where_condition –> self(var).where(self(condition)).

for ‘drop’ kwarg, in where(…, drop=…), use drop=self.drop.
get_vars(vars, *args, return_type='dataset', missing_vars=UNSET, **kw)

returns values of vars from self.

result is probably an xarray.Dataset, but not guaranteed; also depends on return_type.
Equivalent to self(vars, *args, return_type=’dataset’, **kw).
(Actually, self(vars, …) will call self.get_vars(vars, …).)
vars: iterable of strs
Names of the vars to load. [‘n’, ‘u’] for number density & velocity.
if any of these vars returns a return_type object, expand its keys,
e.g. if ‘myDSvar’ returns dataset with ‘myvar1’, ‘myvar2’,
then [‘n’, ‘myDSvar’] gives dataset with ‘n’, ‘myvar1’, ‘myvar2’.
return_type: ‘dataset’ or ‘dict’
if ‘dataset’, return result as xarray.Dataset.
the data_var names will be the same as the var names.
if ‘dict’, return result as dict of {var: value}.
missing_vars: UNSET, ‘ignore’, ‘warn’, or ‘raise’
what to do if any vars cause FormulaMissingError.
UNSET –> use self.missing_vars if it exists, else ‘raise’.
‘ignore’ –> ignore missing vars, and don’t include them in the result.
‘warn’ –> ignore missing vars, but print a warning.
‘raise’ –> raise FormulaMissingError if any vars are missing.
additional args & kwargs are passed to self(…).
get_vdist()

velocity distribution. (directly from Eppic)

get_vector_N(var, *, _match=None)

vector_n –> vector with n in each component. E.g. vector_0 –> vector with components (0,0,0).

result components determined by self.component.
get_vsqr()

v^2 in each grid cell. components given by: v_x^2 = nvsqr_x / n.

get_vtherm()

thermal velocity. vtherm = sqrt(kB T / m)

get_vtherm_n()

thermal velocity for neutrals. vtherm_n = sqrt(kB T_n / m_n)

get_weighted_mean(weights_var, *, _match=None)

mean, weighted by weights. mean(weights*var)/mean(weights).

E.g. ‘weighted_n_mean_T’ –> mean(n * T) / mean(n).
(see also: ‘nmean_[var]’, which is a shorthand for ‘weighted_n_mean_[var]’)
Applied only along any self.stat_dims in array.
get_weighted_std(weights_var, *, _match=None)

std, weighted by weights. std(weights*var)/mean(weights).

E.g. ‘weighted_n_std_mod_u’ –> std(n * mod_u) / mean(n).
(see also: ‘nstd_[var]’, which is a shorthand for ‘weighted_n_std_[var]’)
Applied only along any self.stat_dims in array.
Currently, equivalent to self(‘(std_({weights}*{var}))/mean(weights)’)
[TODO][EFF] internally, don’t compute weights twice…
get_werr2pmstd(var, *, _match=None)

convert dataset with ‘mean’ and ‘std’ into dataset with ‘mean+std’, ‘mean’, ‘mean-std’.

werr2pmstd_var will crash if self(var) doesn’t have ‘mean’ and ‘std’ data vars.
get_werradd(var, *, _match=None)

A_werradd_B = A + B, but result is a dataset with ‘mean’ and ‘std’.

Does not take any means or stds here, but if A or B has ‘std’ already,
assumes independent errors and applies “error propagation” formula:
mean(A + B) = mean(A) + mean(B)
std(A + B) = sqrt(std(A)**2 + std(B)**2)
(if A or B is DataArray, treat as ‘mean’. if missing ‘std’, assume 0.)
get_werrdiv(var, *, _match=None)

A_werrdiv_B = A / B, but result is a dataset with ‘mean’ and ‘std’.

Does not take any means or stds here, but if A or B has ‘std’ already,
assumes independent errors and applies “error propagation” formula:
z = A / B
mean(z) = mean(A) / mean(B)
std(z) = abs(mean(z)) * sqrt((std(A)/mean(A))**2 + (std(B)/mean(B))**2)
(if A or B is DataArray, treat as ‘mean’. if missing ‘std’, assume 0.)
get_werrmean(var, *, _match=None)

dataset of ‘mean’ and ‘std’ of var. Computed along self.stat_dims in array.

get_werrmeant(var, *, _match=None)

dataset of ‘mean’ and ‘std’ of var, taking stats across time dimension.

self(werrmeant_var) –> self(var).werrmean(tdim), where tdim is the dim associated with time,
(tdim default ‘snap’, but if ‘t’ coord associated with a dim, use that dim.)
get_werrmul(var, *, _match=None)

A_werrmul_B = A * B, but result is a dataset with ‘mean’ and ‘std’.

Does not take any means or stds here, but if A or B has ‘std’ already,
assumes independent errors and applies “error propagation” formula:
z = A * B
mean(z) = mean(A) * mean(B)
std(z) = abs(mean(z)) * sqrt((std(A)/mean(A))**2 + (std(B)/mean(B))**2)
(if A or B is DataArray, treat as ‘mean’. if missing ‘std’, assume 0.)
get_werrsub(var, *, _match=None)

A_werrsub_B = A - B, but result is a dataset with ‘mean’ and ‘std’.

Does not take any means or stds here, but if A or B has ‘std’ already,
assumes independent errors and applies “error propagation” formula:
mean(A - B) = mean(A) - mean(B)
std(A - B) = sqrt(std(A)**2 + std(B)**2)
(if A or B is DataArray, treat as ‘mean’. if missing ‘std’, assume 0.)
get_where_condition_var(var, *, _match=None)

where_condition_var –> self(var).where(self(condition)).

Note: if var contains any underscores, must use parenthesis (like ‘where_condition_(var)’).
The alias, self(‘var_where_condition’), does not have such a restriction.
for ‘drop’ kwarg, in where(…, drop=…), use drop=self.drop_in_where.
get_wplasma()

“plasma frequency”. wplasma = sqrt(n q^2 / (m epsilon0))

This is analogous to the “true” plasma frequency of Langmuir oscillations,
which is calculated using the same formula but applied to electrons.
wplasma is equivalent to wplasmae if self.fluid is electrons.
get_wplasmae()

electron plasma frequency; Langmuir oscillations. wpe = sqrt(ne qe^2 / (me epsilon0))

get_write_time()

time spent writing output files. Same units as timers_dat info.

get_xhat()

unit vector in the x direction.

result components determined by self.component, e.g. xhat_x == 1; xhat_y == 0.
get_xyz(var, *, _match=None)

x, y, and/or z components of var.

get_yhat()

unit vector in the y direction.

result components determined by self.component, e.g. yhat_x == 0; yhat_y == 1.
get_zhat()

unit vector in the z direction.

result components determined by self.component, e.g. zhat_x == 0; zhat_z == 1.
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)
has_var(var)

return whether self can load var. True if self.match_var(var) is found, else False.

Subclasses might override, to include checks for whether var can be loaded from data.
[TODO] also check if var in self.cache or self.setvars.
help(qstr=None, only=None, *, tree=None, modules=False, signature=False, doc=True, dense=False, print=True)

prints str for help with quants.

qstr: None or str
None –> tells info about this class & how to use this function.
in particular, tells that quants are stored cls.KNOWN_VARS and cls.KNOWN_PATTERNS,
and describes behavior of calling help with a string.
str –> return str for help with all quants related to str.
use empty str to get help for all quants.
only: None or str
If provided, only get help for a subset of relevant quantities.
None –> get help with all quantities related to qstr.
‘VARS’ –> only get help with KNOWN_VARS.
‘PATTERNS’ –> only get help with KNOWN_PATTERNS.
‘TREE’ –> only get help with quantities in cls.cls_var_tree(str).
‘EXACT’ –> only get help for the KNOWN_VAR exactly matching qstr.
if provided when qstr is None, treat qstr as ‘’ instead.
tree: None or bool
How much help to give for quantities in cls.cls_var_tree(qstr).
False –> don’t even check cls.cls_var_tree(qstr).
True –> help for all quantities in cls.cls_var_tree.
None –> help for quantities in cls.cls_var_tree(qstr).flat_branches_until_vars()
i.e. patterns & vars in tree but ignore any nodes with LoadableVar ancestors.
e.g. qstr=’mean_mod_beta’ –> help with ‘mean_(.+)’, ‘mod_(.+)’, and ‘beta’,
but no help with dependencies of ‘beta’ (‘q’, ‘mod_B’, ‘m’).
modules: bool
Whether to include modules in result.
If True, result will be grouped into sections with modules written at top.
signature: signature: bool
whether to include line with signature in help string.
e.g. “help_str(f, *, module=True, signature=True, indent=None)”
doc: doc: bool
whether to include lines with docstring in help string.
e.g. “return str for help(f).” … and all the other docs in here.
dense: bool
Whether to reduce whitespace in result.
E.g. True –> no newlines between functions. False –> one newline between functions.
help_call_options(search=None)

prints help for kw_call_options.

if search is provided, only print help for keys containing search.
classmethod help_quants_str(qstr=None, only=None, *, tree=None, modules=True, signature=False, doc=True, dense=False, _instance=None)

returns str for help with quants.

qstr: None or str
None –> tells info about this class & how to use this function.
in particular, tells that quants are stored cls.KNOWN_VARS and cls.KNOWN_PATTERNS,
and describes behavior of calling help with a string.
str –> return str for help with all quants related to str.
use empty str to get help for all quants.
only: None or str
If provided, only get help for a subset of relevant quantities.
None –> get help with all quantities related to qstr.
‘VARS’ –> only get help with KNOWN_VARS.
‘PATTERNS’ –> only get help with KNOWN_PATTERNS.
‘TREE’ –> only get help with quantities in cls.cls_var_tree(str).
‘EXACT’ –> only get help for the KNOWN_VAR exactly matching qstr.
if provided when qstr is None, treat qstr as ‘’ instead.
tree: None or bool
How much help to give for quantities in cls.cls_var_tree(qstr).
False –> don’t even check cls.cls_var_tree(qstr).
True –> help for all quantities in cls.cls_var_tree.
None –> help for quantities in cls.cls_var_tree(qstr).flat_branches_until_vars()
i.e. patterns & vars in tree but ignore any nodes with LoadableVar ancestors.
e.g. qstr=’mean_mod_beta’ –> help with ‘mean_(.+)’, ‘mod_(.+)’, and ‘beta’,
but no help with dependencies of ‘beta’ (‘q’, ‘mod_B’, ‘m’).
modules: bool
Whether to include modules in result.
If True, result will be grouped into sections with modules written at top.
signature: signature: bool
whether to include line with signature in help string.
e.g. “help_str(f, *, module=True, signature=True, indent=None)”
doc: doc: bool
whether to include lines with docstring in help string.
e.g. “return str for help(f).” … and all the other docs in here.
dense: bool
Whether to reduce whitespace in result.
E.g. True –> no newlines between functions. False –> one newline between functions.
_instance: None or QuantityLoader instance
if provided, use _instance.match_var_tree() instead of cls.cls_var_tree().
classmethod help_str(qstr=None, only=None, **kw)

returns cls.help_quants_str(qstr=qstr, only=only, **kw).

cls.help() calls help_str.
subclasses might overwrite help_str, but probably won’t touch help_quants_str.
property ifft

alias to ifftN

ifftN(array, dim=UNSET, df=None, *, x0=0, ds=None, **kw_xarray_ifftN)

xarray_ifftN with defaults for dim determined by self.fft_dims.

kwargs are passed to xarray_ifftN. For convenience, docs for xarray_ifftN are copied below.
xarray_ifftN docs
—————–
calculates ifft(array) along N dimensions.
shifts positions such that the 0-position is in the center.
replaces result dimensions & coordinates appropriately, to indicate which dims were ifft’d.
For convenience, all coordinate names can be pre-fft OR post-fft names,
e.g. ‘x’, ‘freq_x’, ‘freqrad_x’, or ‘k_x’.
“post-fft” names look like ‘freq_dim’, ‘freqrad_dim’,
or any value in DEFAULTS.FFT_FREQ_RAD_DIMNAMES.values(), e.g. ‘k_x’.
Caution: ifft(fft(arr)) == arr only approximately, due to floating point rounding errors.
Can at least ensure coordinate alignment by providing ds during ifft(fft(arr), ds=…)
dim: None, str, or iterable of strs
coordinates(s) of array to take ifft over.
promote_dim(array, coord) for any non-dimension coordinates, as needed.
None –> equivalent to array.dims
df: None, number, or dict of {dim: d}
spacing between elements of array (in frequency-space).
None –> infer from ds if provided, else infer from array.
number –> use this as df for all dims.
rad: None or bool
if True, interpret frequency-spacing (df) like it is “in radians”,
dividing it by 2 * pi before converting to position-space.
None –> infer rad from names of the dims being ifft’d.
ds: None, number, or dict of {dim: d}
spacing between elements of result (in position-space), along dims from result.
number –> use this as ds for all dims.
None –> infer from df if provided, else infer from array.
Note: provide ds to guarantee ifft(fft(arr)) == arr, exactly;
otherwise position coords might include small rounding errors.
x0: None, number, or dict of {dim: value}
if provided, alter position-space coordinates by adding a constant offset,
such that the 0’th position for each dim equals x0[dim].
number –> apply the same number to all dims.
iterable –> use these numbers; kwarg dim must also be provided as an iterable of strs.
dict –> dict of {dim: x0} specifying the value associated with each dim
ifft_dims_for(array)

return dims over which to apply ifft for this array.

This is the self.fft_dims which correspond to dims in array.dims,
though not via exact match.
E.g. ‘freq_x’ or ‘k_x’ in array.dims, if ‘x’ in fft_dims.
init_fluids()

set self.fluids and self.jfluids based on input_deck.

init_maindims()

set self.maindims based on input_deck.

init_snaps(*, snaps_from='parallel')

set self.snaps based on input_deck AND reading files.

snaps_from: ‘parallel’ or ‘timers’
how to determine existing snaps.
‘parallel’ –> from files in directory ‘parallel’ (located adjacent to ‘eppic.i’)
‘timers’ –> from data in ‘domain000/timers.dat’ (‘domain000’ adjacent to ‘eppic.i’)
init_units_manager(*, u=None, u_l=None, u_t=None, u_n=None, ne_si=None, **kw_get_units_manager)

set units manager self.u, based on input_deck.

must provide one of these values in order to fully determine the units.

u: UnitsManager object. if provided, set self.u = u. u_l: length [si] = u_l * length [raw] u_t: time [si] = u_t * time [raw] u_n: number density [si] = u_n * number density [raw] ne_si: electron number density [si]. (ne [raw] will be loaded from input_deck)

property input_moments

moments from domain000/moments*.out files.

Can be read using PlasmaCalcs architecture by reading vars:
moment1, moment2, moment3, moment4.
These are sensitive to self.component and self.fluid.
To get moments values directly from file, without helpful xarray labeling,
use the “eppic_var” versions, which look like:
‘moment{i}{x}{N}’ (e.g. ‘moment3x0’), where
i=1,2,3,4 is the moment number,
x=’x’,’y’,’z’ is the component,
N=0,1,2,… is the fluid number (i.e., distribution number).
That is similar to getting, e.g., ‘fluxx1’; it gives a value directly from file.
[EFF] for efficiency, input moments are only read from file one time, then cached.
You can remove the cached values by doing: del self.input_moments.
property iter_component

alias to self.component_dim.iter

property iter_components

alias to self.component_dim.iter_values

property iter_components_partition

alias to self.component_dim.iter_partition

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 iter_snap

alias to self.snap_dim.iter

property iter_snaps

alias to self.snap_dim.iter_values

property iter_snaps_partition

alias to self.snap_dim.iter_partition

property jfluid

alias to self.jfluid_dim.v

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

jobfiles()

return list of all jobfiles within self.dirname directory.

property join_components

alias to self.component_dim.join_along

property join_fluids

alias to self.fluid_dim.join_along

property join_jfluids

alias to self.jfluid_dim.join_along

property join_snaps

alias to self.snap_dim.join_along

kw_call_options(*, sorted=True)

returns list of kwarg names which can be used to set attrs self during self.__call__.

(see self.__call__ for more details).
Here, returns list(self.behavior_attrs) + list(self._extra_kw_for_quantity_loader_call)
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^
elf.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.
elf.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.
elf.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
elf.print_freq has not been set, infer from self.verbose if it exists,
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).
load_direct(var, *args, **kw)

load var “directly”, either from a file, self.setvars, self.direct_overrides,

or via self.load_input() if self.snap is INPUT_SNAP.
Steps:
1) attempt to get var from cache or self.setvars.
[EFF] only tries this if we are not self._inside_quantity_loader_call_logic,
to avoid redundant calls to self.get_set_or_cached.
2) adjust var name if appropriate, via new_varname = self._var_for_load_fromfile(var).
if new_varname != old varname, attempt to get new_varname from cache or setvars.
3) if self.snap is INPUT_SNAP, return self.load_input(new_varname).
4) super().load_direct(adjusted_var, *args, **kw),
which will use self.load_fromfile(…) unless any overrides apply here.
load_fromfile(fromfile_var, *args, snap=None, **kw)

return numpy array of fromfile_var, loaded directly from file.

use self.full_read_mode to determine which file(s) / how to read them.
fromfile_var: str
the name of the variable to read, adjusted appropriately for loading fromfile.
E.g., use ‘fluxz2’, not ‘flux’, to get flux for fluid 2 and component z.
See also: self._var_for_load_fromfile().
snap: None, str, int, or Snap
the snapshot number to load. if None, use self.snap.
Example:
fromfile_var=’fluxx1’, snap=7, read_mode=’h5_2’
–> h5py.File(‘parallel/parallel000007.h5’)[‘fluxx1’][:]
load_input(fromfile_var, *args__None, **kw__None)

load input value – one of the base quantities (fromfile_var) directly from eppic.i file.

Results are always in ‘raw’ units.
E.g., self(‘den’, fluid=0) internally uses self.load_input(‘den0’) for INPUT_SNAP,
and self.load_fromfile(‘den0’) for all other snaps.
Possible fromfile_vars are:
‘phi’: electric potential, excluding any imposed E_ext.
Always 0. (== “perturbation” to E_ext, implied by eppic.i file)
‘den{N}’: density of dist N.
Always 0. (== “perturbation” to n, implied by eppic.i file)
‘flux{x}{N}’: flux of dist N in x direction.
fN.get_n0() * fN.get_v0(x), where fN = self.fluids.get(N).
‘nvsqr{x}{N}’: n * (v_x^2) of dist N in x direction.
fN.get_nvsqr0(x), where fN = self.fluids.get(N).
== fN.get_n0() * (fN.get_v0(x)**2 + fN.get_vth0(x)**2)
load_maindims_var(var, *args, u=None, assign_labels=True, **kw)

return var, formatted as an xarray with proper details for PlasmaCalcs.

loading var should give an array with self.maindims as dimensions.
Also does these steps:
1) assign maindims coords via self.assign_maindims_coords().
2) slice array via self.slices.
3) convert units, if u is not None
4) set result.attrs[‘units’] = self.units
5) if self.maindims_means: take mean of result, across all maindims.
6) use result = self._maindims_postprocess_callback(result), if possible.
u: None, value, or str
units factor for the result.
None –> don’t do any units conversions.
str –> multiply result by self.u(u)
value –> multiply result by u
assign_labels: bool
whether to assign_maindims_coords and self.record_units.
Recommend to always use True, unless using this function internally.
(e.g. for load_maindims_var_across_dims, only use the first time, for efficiency.)
IGNORED if self.maindims_means.
Note:
If load_direct(var) uses an override or gets from cache or self.setvars,
skip steps 1,2,3,4
([TODO] Might need to reconsider this behavior?)
Note:
If self.multi_slices are provided, load_maindims_var for each slice,
then combine results into an xarray.Dataset.
if assign_labels=False, combine results into a dict instead.
load_maindims_var_across_dims(var, dims=None, *, skip=[], u=None, **kw)

load maindims var across these dims. Use all dims from self.dimensions if dims is None.

Only loads across the current value of these dims (e.g., self.fluid, not self.fluids).
(Can set current value to multiple values e.g. self.component = (‘x’, ‘y’).)
u: None, value, or str
units factor for the result.
None –> don’t do any units conversions.
str –> multiply result by self.u(u)
value –> multiply result by u
load_subsampling_info()

load subsampling info from {self.dirname}/subsampling_info.

property logfiles

alias to jobfiles

lowpass(array, dim=UNSET, keep=UNSET, *, keep_r=UNSET, **kw_xarray_lowpass)

xarray_lowpass with defaults for dim & keep determined by self.fft_dims, self.lowpass_keep.

kwargs are passed to xarray_lowpass. For convenience, docs for xarray_lowpass are copied below.
xarray_lowpass docs
——————-
return array after putting it through a lowpass filter using fft & ifft.
This is equivalent to ifft(fft(array) * filter), where filter is 0 at all “large” frequency values.
“large” is determined by keep & r; see below.
dim: None or iterable or strs
coordinates to apply lowpass filter over. If None, use all array.dims.
promote_dim(array, coord) for any non-dimension coordinates, as needed.
keep: UNSET, True, dict, or number between 0 < keep <= 1
fraction of frequencies to keep, along each dim.
(Must provide this or keep_r but not both.)
True –> use DEFAULTS.FFT_LOWPASS_KEEP.
number –> use this value for all dims.
keep_r: UNSET, True, or number between 0 < keep <= 1
radius of N-sphere to keep in normalized frequency-space,
normalized such that max(frequencies)==1 along each dim.
All values outside of this N-sphere will be set to 0.
Similar to keep, but here use an N-sphere instead of an N-cube.
(Must provide this or keep but not both.)
True –> use DEFAULTS.FFT_LOWPASS_KEEP.
[TODO] more options than just spherical? (e.g. ellipsoid)
ds: None, number, or dict of {dim: d}
spacing between elements of array along each dim.
number –> use the same value for all dims.
None –> infer via array.coords[dim].diff(dim) for each dim
(requires evenly-spaced coordinates in dim; spacing checked with np.allclose)
real: None or bool
whether to return np.real(ifft) instead of just ifft (which might have imaginary part)
None –> infer from array. Use True if np.all(np.isreal(array)), else False.
return_fft: bool
whether to return (result, masked fft) instead of just result.
mainly intended for debugging purposes.
property lowpass_keep

the default value for “keep” in self.lowpass. 0 < lowpass_keep <= 1.

Or, can be a dict of {dim: keep} pairs, to use different keep for different dims.
To use keep_r instead of keep, call lowpass directly and enter keep_r there.
static magnitude(A, *, squared=False)

return vector magnitude of A, assuming vector components along the dimension ‘component’.

squared: bool, default False
if True, return |A|**2 instead of |A|.
[EFF] to get |A|**2, when |A| is not needed,
magnitude(A, squared=True) is more efficient than magnitude(A)**2
property maindims_full_shape

self.maindims_shape when self.slices=None

property maindims_full_size

self.maindims_size when self.slices=None

property maindims_full_sizes

self.maindims_sizes when self.slices=None

property maindims_means

whether to immediately take means across maindims when loading arrays. (default False.)

True –> treat data across maindims as if it were the mean values, only.

Caution: this is different from taking means after doing calculations;

e.g., with maindims_means = True, ‘n*T’ –> mean(n)*mean(T), not mean(n*T).
property maindims_shape

tuple of (len(self.get_maindims_coords()[dim]) for dim in self.maindims).

Note, this should be sensitive to changes in self.slices. See also: self.maindims_full_shape.
property maindims_size

product of terms in self.maindims_shape.

Note, this should be sensitive to changes in self.slices. See also: self.maindims_full_size.
property maindims_sizes

dict of {dim: size of dim} for dim in self.maindims.

Note, this should be sensitive to changes in self.slices. See also: self.maindims_full_sizes.
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 mask

None or xarray.DataArray of bools,

if self.masking, apply mask to results (with mask dims) at top-level (call_depth=1)
(internal calls still do full calculations, so derivatives will still work.)
applying mask means calling self.apply_mask(result);
masking = True or ‘stacked’ –> xarray_mask(result, stack=True); i.e., drops all masked points.
(and, result will have ‘_mask_stack’ dimension instead of mask.dims dimensions)
masking = ‘simple’ –> xarray_mask(result, stack=False); i.e., masked points just replaced by nan.
never applies mask if self.mask = None.
setting self.mask = value is equivalent to calling self.set_mask(value).
property masking

how to apply self.mask to results at top level, if mask exists.

True –> alias for ‘stacked’. This is the default.
‘stacked’ –> apply stacked mask to self.stack(result), dropping masked points.
‘simple’ –> apply mask to result, filling masked regions with np.nan.
False –> do not apply mask, even if self.mask exists.
classmethod match_var(var, *, check=['KNOWN_VARS', 'KNOWN_PATTERNS'])

match var from cls.KNOWN_VARS or cls.KNOWN_PATTERNS, or raise FormulaMissingError.

returns result=MatchedQuantity(var, loadable, _match=_match) where:

loadable is the LoadableQuantity associated with this var,
_match is:
None, if var in cls.KNOWN_VARS;
re.fullmatch(pattern, var), if var matches any pattern in cls.KNOWN_PATTERNS.
if var matches multiple patterns, only the first matching pattern is used.
Uses MatchedVar if match from KNOWN_VARS, MatchedPattern if from KNOWN_PATTERNS.
(note that both MatchedVar and MatchedPattern subclass MatchedQuantity.)
check: str or list of str from [‘KNOWN_VARS’, ‘KNOWN_PATTERNS’]
where to check for matches. Default is to check KNOWN_VARS and KNOWN_PATTERNS.
E.g. to only check KNOWN_PATTERNS, use check=[‘KNOWN_PATTERNS’].
loadable and _match can be retrieved via result.loadable and result._match.
match_var_loading_dims(var, **kw_loading_dims)

return dims for loading var across.

Result will probably vary across these dims (but not guaranteed, if any dependency uses reduces_dims.)
These are all Dimension dims, not maindims. (E.g. ‘fluid’ and ‘snap’, but not ‘x’, ‘y’, ‘z’).
Equivalent: self.match_var_tree(var).loading_dims(**kw_loading_dims)
match_var_result_dims(var, **kw_result_dims)

return dims which result of cls(var) will vary across.

These are all Dimension dims, not maindims. (E.g. ‘fluid’ and ‘snap’, but not ‘x’, ‘y’, ‘z’).
Equivalent: cls.match_var_tree(var).result_dims(**kw_result_dims)
match_var_result_size(var, *, maindims=True, **kw_result_dims)

return size (number of elements) which self(var) will have.

(Efficient; doesn’t actually get self(var).)
Depends on current values of relevant dims. (E.g., self.fluid, not self.fluids)
maindims: bool
if True, include maindims_shape when calculating size.
match_var_tree(var=UNSET, **kw_quant_tree_from_quantity_loader)

return QuantTree of MatchedQuantity objects from matching var and all dependencies,

using self.KNOWN_VARS and self.KNOWN_PATTERNS when searching for matches.
var must be provided; var=UNSET will raise an error (helpful if tried calling this as a classmethod).
See also: type(self).cls_var_tree, for the classmethod version of this function.
Most of the time it is possible to get tree without any details from self,
but sometimes not. e.g. when getting collision frequencies, self.fluid affects deps.
additional kwargs will be passed to QuantTree.from_quantity_loader(…),
which passes kwargs from self.kw_call_options() into self.using(**kw) while getting deps.
matched_pattern_cls

alias of MatchedPattern

matched_var_cls

alias of MatchedVar

property multi_slices

dict of {key: slices dict}.

When getting any vars across maindims, make a Dataset by applying each of these, separately.
If len(multi_slices)>0 then ignore self.slices.
Can also provide special keys ‘ndim’ and/or ‘ikeep’ to create special slices:
Example: if self.maindims=[‘x’, ‘y’, ‘z’], then self.multi_slices = dict(ndim=2, ikeep=0)
is equivalent to: self.multi_slices = dict(x_y=dict(z=0), x_z=dict(y=0), y_z=dict(x=0))
Details:

ndim: None or int

None –> ignore, and do not create special slices.
int –> create special slices to keep this many dims after applying each slice.
Example: MultiSlices(ndim=2) is shorthand for
“MultiSlices with one slices for every possible combination of keeping 2 dims”.
Example: MultiSlices(ndim=2, dims=[‘x’, ‘y’, ‘z’], ikeep=0) is equivalent to:
MultiSlices(keep_x_y=dict(z=0), keep_y_z=dict(x=0), keep_x_z=dict(y=0))
Example: MultiSlices(ndim=1, dims=[‘x’, ‘y’, ‘z’], ikeep=0) is equivalent to:
MultiSlices(keep_x=dict(y=0, z=0), keep_y=dict(x=0, z=0), keep_z=dict(x=0, y=0))

ikeep: int or number between -1 < ikeep < 1

index to take when picking a single value for sliced dimensions for special slices.
Default is 0, e.g. when slicing x, keep x[0].
int –> when slicing dim, keep dim[ikeep]. E.g. 10 –> keep x[10]
non-int between -1 and 1 –> multiply by length of dim to get index.
see interprets_fractional_indexing for more details.
Can also set these as attributes of self.multi_slices to achieve the same effect.
E.g. self.multi_slices.ndim = 2
property multi_slices_ikeep

int or number between -1 < ikeep < 1

index to take when picking a single value for sliced dimensions for special slices.
Default is 0, e.g. when slicing x, keep x[0].
int –> when slicing dim, keep dim[ikeep]. E.g. 10 –> keep x[10]
non-int between -1 and 1 –> multiply by length of dim to get index.
see interprets_fractional_indexing for more details.
property multi_slices_ndim

None or int

None –> ignore, and do not create special slices.
int –> create special slices to keep this many dims after applying each slice.
Example: MultiSlices(ndim=2) is shorthand for
“MultiSlices with one slices for every possible combination of keeping 2 dims”.
Example: MultiSlices(ndim=2, dims=[‘x’, ‘y’, ‘z’], ikeep=0) is equivalent to:
MultiSlices(keep_x_y=dict(z=0), keep_y_z=dict(x=0), keep_x_z=dict(y=0))
Example: MultiSlices(ndim=1, dims=[‘x’, ‘y’, ‘z’], ikeep=0) is equivalent to:
MultiSlices(keep_x=dict(y=0, z=0), keep_y=dict(x=0, z=0), keep_z=dict(x=0, y=0))
property nGbytes

number of gigabytes across all files in self.dirname (and subdirectories).

== self.nbytes / 1024**3
property nMbytes

number of megabytes across all files in self.dirname (and subdirectories).

== self.nbytes / 1024**2
n_existing_snaps()

returns number of existing snaps. Equivalent to self.snap_dim.n_existing_for(self).

property nbytes

number of bytes across all files in self.dirname (and subdirectories)

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 nnefrac_tiny_thresh

threshhold for where_nnefrac_tiny and where_nnefrac_significant.

tiny if n/ne < nnefrac_tiny_thresh, significant if n/ne >= nnefrac_tiny_thresh.
property nondim_behavior_attrs

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

property notes_dirname

‘abspath to directory containing plots/notes for a DirectLoader.

Might be the same directory as self.dirname, but doesn’t need to be;
can explicitly set self.notes_dirname = value, if desired.
If not set, use notes_dirname == self.dirname,
unless self.dirname ends with one of the self._INDICATES_NOTES_DIRNAME options.
E.g. dirname == ‘path/to/dir0’ –> notes_dirname == ‘path/to/dir0’.
E.g. dirname == ‘path/to/dir1/_sim’ –> notes_dirname == ‘path/to/dir1’.
E.g. dirname == ‘path/to/dir1/_check0’ –> notes_dirname == ‘path/to/dir1’.
See also: self.unique_notes_dirname
npd_for_fluid(fluid)

return the npd for this fluid.

This is equivalent to fluid[‘npd’] when it is provided,
otherwise determined by the appropriate alternative (npcelld, nptotd, or nptotcelld).
This method is implemented for the calculator rather than the fluid,
because fluid doesn’t know the possibly-required global values (ncells and/or n_processors).
result will always be converted to int, since npd is an integer.
on_changed_quasineutral(*, old, new)

called when self.quasineutral changes.

default behavior: do nothing.
property output_mask

whether to store_mask during xarray_mask calls if self.masking.

False –> never store mask in results
True –> always store mask in top-level results
(all results will be xarray.Dataset objects with ‘_mask’ data_var)
None –> only store mask in results which would have been Datasets anyways.
plot(name, who=UNSET, *, save=False, show=False, close=False, **kw_plotter)

makes a single plot using the relevant plotter.

name: str or Plotter
name of the plotter to use, or a Plotter instance.
(if Plotter, use directly and ignore ‘who’ input.)
who: UNSET, None, or str
person associated with the plotter.
UNSET –> use the plotter with this name; crash if found multiple same-named plotters.
save: bool, str, or dict.
whether to save figure after calling plotter.
str –> filename=save.format(name=name, savename=savename), instead of default filename=name.
dict –> pass to saver as kwargs. Use kwarg ‘dst’ to also provide filename.
if plotter.ani, saver is movie_obj.ani(), else saver is plt.savefig().
show: bool
whether to plt.show() after making plot (and, after save).
if show when ani==True, return movie_obj.ani() (so it will display in jupyter)
close: bool
whether to plt.show() after making plot (and, after save).
if show when ani==True, return movie_obj.ani() (so it will display in jupyter)
additional kwargs go to plotter.plot(…)
see also: self.get_plotters(), self.save_plots().
plot_E_mod2_abs_radfft_manytimes(**kw_plot_settings)

abs_radfft_delta_mod2_E at “many” times (ec.sam_defaults[‘manytimes’]).

plot_E_mod2_blurk_abs_radfft_manytimes(**kw_plot_settings)

abs_radfft_delta_mod2_E at “many” times (ec.sam_defaults[‘manytimes’]).

plot_E_mod_sometimes(**kw_plot_settings)

mod_E at some times (ec.sam_defaults[‘sometimes’])

plot_E_mod_stats(**kw_plot_settings)

E-field (mod) stats timelines.

plot_E_stats(**kw_plot_settings)

E-field (vector) stats timelines.

plot_T_box(**kw_plot_settings)

T_box timelines for all fluids.

plot_T_sometimes(**kw_plot_settings)

T at some times (ec.sam_defaults[‘sometimes’])

plot_Ta_from_moment2(**kw_plot_settings)

Ta_from_moment2 timelines for all fluids.

plot_check_nusn_from_drift(*, u='u', drift='momExB', cycle1={'ls': ['-', '--', '-.', ':']}, means=True, log=True, **kw_timelines)

plots PlasmaCalcs.timelines() for comparing nusn to nusn inferred from drifts.

This is meant to be used as a quick check. Use this code as an example if you need more low-level control.
u: str or iterable of strs
var to use for velocity. Might want something else, e.g. EppicCalculator might use u=’moment1’
iterable of strs –> get multiple.
drift: str or iterable of strs
tells the way to infer skappa, and thus nusn. Options: ‘momExB’, ‘momE’, ‘hall’, ‘pederson’.
iterable of strs –> get multiple.
cycle1: dict of lists
parameters to use for matplotlib plotting if getting multiple u or drift.
means: bool
whether to take means of lower-level vars while getting skappa.
(e.g. use ‘skappa_from_means_momExB’ instead of ‘skappa_from_momExB’, if True.)
log: bool
whether to take log10 of the ratios (nusn_from_drift / nusn) before plotting.
returns plt.gcf().
plot_ddt_ln_std_blur_deltafrac_n(**kw_plot_settings)

ddt_ln_std_blur_deltafrac_n timelines for all fluids, for blur_sigma in [0, 1, 10, 20]

plot_ddt_ln_std_deltafrac_n(**kw_plot_settings)

ddt_ln_std_deltafrac_n timelines for all fluids.

plot_deltafrac_n(**kw_plot_settings)

deltafrac_n movie for all fluids, all current snaps (in self.snap).

plot_deltafrac_n_abs_radfft(**kw_plot_settings)

abs_radfft_deltafrac_n movie for all fluids, all current snaps (in self.snap).

Not the full region of k-space.
plot_deltafrac_n_abs_radfft_full_sometimes(**kw_plot_settings)

abs_radfft_deltafrac_n at some times (ec.sam_defaults[‘sometimes’]) for all fluids.

Includes the full region of k-space; see also plot_deltafrac_n_abs_radfft_full.
plot_deltafrac_n_abs_radfft_sometimes(**kw_plot_settings)

abs_radfft_deltafrac_n at some times (ec.sam_defaults[‘sometimes’]) for all fluids.

Not the full region of k-space; see also plot_deltafrac_n_abs_radfft_full.
plot_deltafrac_n_blurk_abs_radfft(**kw_plot_settings)

blurk_abs_radfft_deltafrac_n movie for all fluids, all current snaps (in self.snap).

Not the full region of k-space. Uses blur_sigma=1.
plot_deltafrac_n_blurk_abs_radfft_sometimes(**kw_plot_settings)

blurk_abs_radfft_deltafrac_n at some times (ec.sam_defaults[‘sometimes’]) for all fluids.

plot_deltafrac_n_sometimes(**kw_plot_settings)

deltafrac_n at some times (ec.sam_defaults[‘sometimes’]) for all fluids.

plot_deltafrac_ne_manytimes(**kw_plot_settings)

deltafrac_n for electrons at “many” times (ec.sam_defaults[‘manytimes’]).

plot_ln_std_blur_deltafrac_n(**kw_plot_settings)

ln_std_blur_deltafrac_n timelines for all fluids, for blur_sigma in [0, 1, 10, 20]

plot_ln_std_deltafrac_n(**kw_plot_settings)

ln_std_deltafrac_n timelines for all fluids.

plot_moment1(**kw_plot_settings)

moment1 timelines for all fluids.

plot_moment1_specie0(**kw_plot_settings)

plot the first moment of the simulation for specie0

plot_n_stats(**kw_plot_settings)

number density stats timelines for all fluids.

plot_u_mod_sometimes(**kw_plot_settings)

mod_u at some times (ec.sam_defaults[‘sometimes’])

plot_u_mod_stats(**kw_plot_settings)

stats of u (mod) timelines for all ions and electrons.

(electrons in a subplot above ions, if mean electrons |u| >> 3 * ions |u|.)
plot_u_std(**kw_plot_settings)

std of u (vector) timelines for all ions and electrons.

(electrons in a subplot above ions, if mean electrons std(u) >> 3 * ions std(u).)
plot_u_std_mod(**kw_plot_settings)

std of u (mod) timelines for all ions and electrons.

(electrons in a subplot above ions, if mean electrons std(u) >> 3 * ions std(u).)
polyfit(array_or_var, coord, degree, window=UNSET, **kw)

polyfit along coord. Might coarsen array, polyfit in each window, and concat results.

array_or_var: xarray.DataArray, or str
array to polyfit.
str –> use array=self(array_or_var). (Note; **kw will NOT go to self.get(array_or_var))
coord: str
coordinate to polyfit along.
If coord is not already a dimension, use array=promote_dim(array, coord).
degree: int
degree of polynomial to fit.
window: UNSET, None, or int.
UNSET –> use self.polyfit_window
None –> don’t use windowing; polyfit to the entire array along coord.
int –> coarsen array along dim, using windows of this length,
then polyfit in each window, then concat results along coord.
Pass additional kwargs to xarray_coarsened_polyfit;
also use self.polyfit_kw as defaults (for any kwargs not provided here).
returns an xarray.DataSet which is the result of polyfit.
property polyfit_boundary

alias to self.polyfit_kw[‘boundary’].

When polyfitting, tells how to handle boundaries when coarsening array.
probably ‘exact’, ‘trim’, or ‘pad’.
property polyfit_cov

alias to self.polyfit_kw[‘cov’].

When polyfitting, tells whether to also return the covariance matrix.
only used if self.polyfit_full=False.
property polyfit_full

alias to self.polyfit_kw[‘full’].

When polyfitting, tells whether to also return residuals, matrix rank and singular values.
property polyfit_keep_coord

alias to self.polyfit_kw[‘keep_coord’].

When polyfitting, tells whether to keep some of the original coord values in result.
probably ‘left’, ‘middle’, ‘right’, or False.
property polyfit_kw

kwargs to pass to self.polyfit(), other than array, coord, degree, and window.

See polyfit_kw_key_aliases for a list of aliases to some of these kwargs, as attributes of self.
getting self.polyfit_kw will also set keys to default values from aliases,
e.g. polyfit_boundary has default of ‘trim’ –> if polyfit_kw[‘boundary’] not set, set it to ‘trim’.
property polyfit_stddev

alias to self.polyfit_kw[‘stddev’].

When polyfitting, tells whether to also return the standard deviations of the coefficients.
incompatible with self.polyfit_full=True.
property polyfit_window

When polyfitting, tells window size to use for coarsening arrays before fitting.

E.g., polyfit_window=10 –> windows of length 10, polyfit in each window, concat results.
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.
quant_tree(var=UNSET, **kw_quant_tree_from_quantity_loader)

return QuantTree of MatchedQuantity objects from matching var and all dependencies,

using self.KNOWN_VARS and self.KNOWN_PATTERNS when searching for matches.
var must be provided; var=UNSET will raise an error (helpful if tried calling this as a classmethod).
See also: type(self).cls_var_tree, for the classmethod version of this function.
Most of the time it is possible to get tree without any details from self,
but sometimes not. e.g. when getting collision frequencies, self.fluid affects deps.
additional kwargs will be passed to QuantTree.from_quantity_loader(…),
which passes kwargs from self.kw_call_options() into self.using(**kw) while getting deps.
quant_tree_cls

alias of QuantTree

property quasineutral

tells whether self is in quasineutral mode.

rawvar_load(var, src)

load a single raw var from snap src.

Used by subsampling routines. Basically just calls self.load_fromfile.
rawvar_load_and_subsample(var, src, info)

returns var loaded and subsampled from src.

rawvar_save(var, data, dst)

saves a single raw var to snap dst.

crash if this would require overwriting any existing data at dst.
rawvars_loadable(src)

returns list of all directly loadble vars within snap src.

Used by subsampling routines. Basically just calls self.directly_loadable_vars.
rawvars_loadable_across(srcs=None)

returns dict of {src: [vars loadable from src]} for all snap srcs

The implementation here just calls rawvars_loadable for each src.
if srcs is None, use self.subsampling_snap_srcs().
property read_mode

mode telling which files to read.

Currently, must be ‘h5’ or ‘h5_2’
Maybe other modes will be added at some point.
Options:
‘h5’ –> read from .h5 files,
determine file format based on input_deck[‘hdf_output_arrays’].
‘h5_2’ –> read from .h5 files,
assuming input_deck[‘hdf_output_arrays’]==2.
record_units(array)

return array.assign_attrs(self.units_meta()).

if array is not an xarray.DataArray, convert it first.
static rmscomps(A)

return root mean squared of components of A.

E.g., rmscomps(A) –> sqrt((Ax^2 + Ay^2 + Az^2) / 3), if A has 3 components.
property sam_defaults

various defaults for sam’s plotting.

Editing ec.sam_defaults directly will change values for an instance.
Editing ec.SAM_DEFAULTS directly will change values for all future instances.
sam_plots_highres(*, dst='plots_highres/{savename}', dpi=400, bbox_inches='tight', snap=None, min_cost=None, max_cost=None, **kw)

save sam’s plots in highres mode. return abspath to folder containing plots.

sam_plots_lowres(*, dst='plots_lowres/{savename}', dpi=100, bbox_inches='tight', snap=slice(None, None, 0.0333), min_cost=None, max_cost=40, **kw)

save sam’s plots in lowres mode. return abspath to folder containing plots.

sam_plots_midres(*, dst='plots_midres/{savename}', dpi=200, bbox_inches='tight', snap=slice(None, None, 0.01), min_cost=None, max_cost=None, **kw)

save sam’s plots in midres mode. return abspath to folder containing plots.

save_plots(kind=UNSET, who=UNSET, *, name=None, all_whos=UNSET, all_kinds=UNSET, skip_who=[], skip_kinds=[], min_cost=None, max_cost=None, dst='{savename}', save_log=True, log_extras=[], kw_save={}, bbox_inches=UNSET, dpi=UNSET, show=False, close=True, print_freq=0, **kw_plotter)

saves all plots from plotters associated with these inputs.

returns dict of {plotter: plotter result} for all plotters called.
Consider checking self.get_plotters() first to learn which plotters will be included.
For choosing which plotters to include:
kind: UNSET, str, or list.
kind associated with the plotter.
UNSET –> include plotters regardless of ‘kind’.
str –> require this kind to be in plotter.kinds.
list –> require at least one of these to be in plotter.kinds.
who: UNSET, None, str, or list.
person associated with the plotter.
UNSET –> include plotters regardless of ‘who’.
None –> require len(plotter.who) == 0.
str –> require this name to be in plotter.who.
list –> require at least one of these to be in plotter.who
(or, if None in list, allow len(plotter.who)==0, too)
name: None or str
plotter name. E.g. ‘deltafrac_n’.
None –> include all plotters regardless of ‘name’.
all_whos: UNSET or list.
include only plotters with ALL of these people in plotter.who.
all_kinds: UNSET or str.
include only plotters with ALL of these kinds in plotter.kinds.
skip_who: list
exclude plotters with any of these people in plotter.who.
skip_kinds: list
exclude plotters with any of these kinds in plotter.kinds.
min_cost: None or number
exclude plotters with cost < min_cost.
None –> no minimum.
max_cost: None or number
exclude plotters with cost > max_cost.
None –> no maximum.
For plotting:
dst: str
where to save plots to. Hit by dst.format(name=plotter.name, savename=plotter.savename).
if not abspath, save to os.path.join(self.unique_notes_dirname, dst) if possible,
else save to dst within current directory.
save_log: bool or str
whether to save a log of plot progress to _save_plots_log.txt file.
str –> save to this file name. If not abspath, put it in dir implied by dst (see above).
The log tells current datetime, version info about PlasmaCalcs, and plot timing updates.
log_extras: list of str
extra lines to put in the log “header”, if doing save_log.
kw_save: dict
kwargs to pass to plotter.save(…)
bbox_inches: UNSET or any value
if provided, added to kw_save.
dpi: UNSET or any value
if provided, added to kw_save.
show: bool
whether to plt.show() after making plot (and, after save).
if show when ani==True, return movie_obj.ani() (so it will display in jupyter)
close: bool
whether to plt.show() after making plot (and, after save).
if show when ani==True, return movie_obj.ani() (so it will display in jupyter)
additional kwargs go to plotter.plot(…)
Misc:
print_freq: number
minimum seconds between printing progress updates.
-1 –> never print; 0 –> always print.
see also: self.get_plotters(), self.plot().
property set

alias to set_var

set_E_un0_perpmod_B(value, **kw)

set E_un0_perpmod_B to this value. Also sets E_un0_perpmag_B.

set_T(value, **kw)

set T to this value, by setting all components of ‘nvsqr’ to the appropriate value.

kB T == m * [vsqr - u^2]. –> nvsqr = n * ((kB * T / m) + u^2)
Depends on the current value of n; if also setting n be sure to set n first.
(To set neutral (jfluid) temperature, use set_Tj instead.)
set_Tj(value, **kw)

set T to this value for the current self.jfluid.

Getting ‘n’ returns value when self.fluid is the self.jfluid from when ‘n’ was set.
The implementation here assumes jfluids are inherently different from fluids,
which is true for Eppic, where jfluid is neutral (by default).
set_attrs(**attrs)

sets these attrs in self.

set_bases(*, n=UNSET, u=UNSET, T=UNSET, ux=UNSET, uy=UNSET, uz=UNSET, forall=[], v=UNSET, vx=UNSET, vy=UNSET, vz=UNSET, **kw)

set n, u, and T to these values (for the relevant current behavior in self..).

(e.g. if self.fluid=0, setting values for fluid=0, only.)
n, u, T, ux, uy, uz: UNSET, None, or number
UNSET –> don’t set this value
None –> delete this value from self.setvars
number –> set this value.
Note: if u is provided, self.component must be a single value.
v, vx, vy, vz:
aliases for u, ux, uy, uz, respectively.
forall: list of strings
behavior attrs to which set value should apply to all of.
E.g., forall=[‘snap’] –> set value applies at all snaps instead of just current snap.
additional kwargs, if provided, go to self.using(**kw) during the operation.
returns (list of set quantities, list of unset quantities)
set_collisions_crosstab(fluid1, fluid2, crosstab, *, crossmap=None)

roughly, does self.collisions_cross_mapping[(fluid1, fluid2)] = crosstab,

but this is a bit more convenient since it allows more shorthand options (see below)
fluid1, fluid2: int, str, or Fluid
the fluids to set the crosstab for.
Fluid –> use the provided value.
int or str –> infer the Fluid based on self.fluids.
crosstab: None, str, or CrossTable
None –> del self.collisions_cross_mapping[(fluid1, fluid2)], if possible.
else –> self.collisions_cross_mapping[(fluid1, fluid2)] = crosstab.
– CrossTable –> will use the provided value.
– str –> will use the CrossTable corresponding to this filename or key,
key from self.CROSS_TABLE_DEFAULTS.
Note: self.collisions_cross_mapping.smart=False can disable this.
crossmap: None or CrossMapping
if provided, set value in crossmap instead of in self.collisions_cross_mapping.
Example, these are all equivalent, if fluids[0]==’e’ and fluids[1]==’H II’:
self.set_collisions_crosstab(‘e’, ‘H II’, ‘e-h’)
self.set_collisions_crosstab(0, 1, ‘e-h-cross.txt’)
self.set_collisions_crosstab(self.fluids.get(‘e’), self.fluids.get(‘H II’),
CrossTable.from_file(‘e-h-cross.txt’))
self.collisions_cross_mapping[(self.fluids.get(0), self.fluids.get(1))] = ‘e-h’
set_collisions_crosstab_defaults(mode='bruno', *, crossmap=None)

set CROSS_TABLE_DEFAULTS cross sections for all relevant fluids in self.

e.g. if self has fluids e, H_I, H_II, He_II, would set:
crossmap[e, H_I] = ‘e-h’
crossmap[H_II, H_I] = ‘h-p’
crossmap[He_II, H_I] = ‘h-he’
crossmap[H_I, H_I] = ‘h-h’
if self has more relevant fluids, would set more crossmaps too.
see self.CROSS_TABLE_DEFAULTS for list of available defaults.
(note that order of keys doesn’t matter for crossmap since it’s a SymmetricPairMapping.)
mode: ‘bruno’ or ‘vranjes’
tells which defaults to use. (bruno is probably more accurate than vranjes.)
crossmap: None or CrossMapping
if provided, set values in crossmap instead of in self.collisions_cross_mapping.
gets relevant fluids from self.get_collisions_crosstab_default_fluids;
subclass may wish to override that method.
set_den(value, **kw)

set den to this value. See also: set_n

set_flux(value, **kw)

set flux to this value. See also: set_u

set_mask(mask)

sets self.mask = mask, and increments self._mask_cache_state (if checks succeed).

Also does some checks:
- mask is None or xarray.DataArray. If None, don’t do any other checks.
Also may alter mask slightly:
- discard non-dimension coords
set_mod_B(value, **kw)

set mod_B to this value. Also sets mag_B, mod2_B, and mag2_B.

set_n(value, **kw)

set n to this value, by setting ‘den’ to the appropriate value.

(To set neutral (jfluid) density, use set_nj instead.)
set_nj(value, **kw)

set n to this value for the current self.jfluid.

Getting ‘n’ returns value when self.fluid is the self.jfluid from when ‘n’ was set.
The implementation here assumes jfluids are inherently different from fluids,
which is true for Eppic, where jfluid is neutral (by default).
set_nvsqr(value, **kw)

set nvsqr to this value. See also: set_T

set_phi(value, **kw)

set phi to this value.

set_pop_dim_attrs(kw)

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

set_t_turb_00()

set self.t_turb & return t_turb from ‘00’ standard: t_turb_from_pwl2_ln_std_blur_deltafrac_n,

with fluid=electron, snap=None, blur_sigma=10.
Drops ‘fluid’, ‘snap’, and ‘t’ coords from result.
(internally, uses ‘caches_ln_std_blur_deltafrac_n’ with t_turb=None, to save time if recomputed later.)
(00 standard should never change, it will always mean this!)
set_t_turb_10()

set self.t_turb & return t_turb from ‘10’ standard: t_turb_from_pwl2_ln_std_blur_deltafrac_n,

for fluid=None, fitting across all snaps, and blur_sigma=10.
Renames ‘fluid’ to ‘tturb_fluid’ in result. Drops ‘snap’ and ‘t’ coords from result.
(internally, uses ‘caches_ln_std_blur_deltafrac_n’ with t_turb=None, to save time if recomputed later.)
(10 standard should never change, it will always mean this!)
set_u(value, **kw)

set u to this value, by setting ‘flux’ to the appropriate value. flux = n * u.

Depends on the current value of n; if also setting n be sure to set n first.
set_var(var, value, behavior_attrs=None, forall=[], *, ukey=None, forced=False, **kw_using)

set var in self. When later doing self(var) to get var, return the set value,

but only if self.behavior is compatible with the relevant parts of self.behavior when var was set.
This function will use, if it exists:
self.KNOWN_SETTERS[var](self, value, behavior_attrs, forall=forall)
Otherwise, calls:
self.set_var_internal(var, value, self.behavior_attrs, forall=forall)
var: str
the var to set in self.
value: number, xarray, iterable or 1D array, array with shape matching self.maindims_shape.
the value to set var to.
number –> set var to this number.
xarray –> set var to this xarray.
[TODO](not yet implemented) iterable or 1D array –> set var to these values along dim=’testing’.
[TODO](not yet implemented) array with shape matching self.maindims_shape –> set var to this array.
behavior_attrs: None or list
tells which attrs from self control behavior of the set var.
The set var will only be retrieved when behavior_attrs of self are compatible.
E.g. set_var(‘n’, [‘fluid’, ‘snap’]) –> saves ‘n’ in cache with current fluid & snap.
Will only load ‘n’ if self.fluid and self.snap == cached fluid and snap for ‘n’.
if var in self.KNOWN_SETTERS, cannot provide behavior_attrs here.
else, use self.behavior_attrs if None.
forall: list of strings
if provided, tells which attrs of self do NOT control the behavior of the set var.
E.g. forall=[‘snap’] –> ‘snap’ will NOT be included in behavior_attrs.
(anything in behavior_attrs AND forall will be removed from the final behavior_attrs)
ukey: None or str
if provided, tells string to give to UnitsManager when converting value’s units.
When ukey is known, setting value in any unit system will enable to read it in all unit systems.
E.g. set_var(‘n’, 1e10, …, ukey=’n’, units=’si’)
–> self(‘n’, units=’raw’) == self(‘n’, units=’si’) * self.u(‘u’, ‘raw’, convert_from=’si’)
if not provided, value will be associated with current unit system;
attempted to read value in any other unit system will not used the cached value set here.
E.g. set_var(‘u’, 1e10, …, units=’si’) # ukey not provided
–> self(‘u’, units=’raw’) –> uses self’s other logic for getting ‘u’, not from setvars.
note: if provided, ‘units’ will be added to behavior_attrs if not already in there.
forced: bool, default True
handles the case where self.KNOWN_SETTERS[var] doesn’t exist. In that case…
True –> set var in self, anyway.
False –> crash; raise FormulaMissingError
additional kwargs, if provided, go to self.using(**kw) during the operation.
returns list of set quantities.
set_var_internal(var, value, behavior_attrs, forall=[], *, ukey=None)

set var in self. KNOWN_SETTERS functions may wish to use this method.

(KNOWN_SETTERS functions should NOT use self.set_var, to avoid recursion issue.)
This function has the internal logic for self.set_var;
set_var calls set_var_internal when self.KNOWN_SETTERS[var] not provided.
var: str
the var to set in self.
value: number, xarray, iterable or 1D array, array with shape matching self.maindims_shape.
the value to set var to. See help(self.set_var) for more info.
behavior_attrs: list of strings
the behavior attrs relevant to setting this var;
getting var only gives value when current behavior attrs values are compatible with the cached ones.
forall: list of strings
if provided, tells which behavior attrs do NOT control the behavior of the set var.
e.g. behavior_attrs=[‘snap’, ‘fluid’], forall=[‘snap’] –> use [‘fluid’], only.
ukey: None or str
if provided, tells string to give to UnitsManager when converting value’s units;
when ukey is provided, can retrieve value in any unit system (probably ‘si’ or ‘raw’).
when ukey not provided, if ‘units’ in used behavior attrs, can only retrieve value in that unit system.
set_vars_from_inputs(snap=INPUT_SNAP, *, _version='new', **kw)

set self.snap to INPUT_SNAP. self will automatically load eppic.i values when snap=INPUT_SNAP.

(This function was useful before load_input() was implemented (on 2025-04-25),

but now that load_input() exists, there’s probably not a compelling reason to keep this around…
However, we will keep it around for a while, in case someone was using it.
It *should* also be *mostly* backwards compatible, as setting self.snap = INPUT_SNAP
will now produce equivalent result as the old version would have produced,
except the new version doesn’t touch self.setvars in order to do it.
snap: INPUT_SNAP or any snap specifier
sets self.snap = snap, and sets values at this snap. (doesn’t restore old self.snap after.)
INPUT_SNAP –> special value; refers to “snap from input deck, not a real snap”.
You can later access the set values by using self.snap = PlasmaCalcs.INPUT_SNAP
if _version==’new’, snap MUST be INPUT_SNAP, else will crash with InputConflictError
_version: ‘new’ or ‘old’
if ‘new’, just set self.snap = INPUT_SNAP.
if ‘old’, set self.snap=snap, then use self.set_bases() to adjust self.setvars appropriately.
kw are passed as self.using(**kw) while using this method.
set_vtherm(value, **kw)

set thermal velocity, by setting T.

vtherm = sqrt(kB T / m) –> set T to (m vtherm^2 / kB).
property setvar

alias to set_var

property setvars

VarCache of vars set via self.set_var(). Returns these values when appropriate,

i.e. whenever self.behavior is compatible with the behavior in the cache.
To empty the cache, use self.setvars.clear() to empty the cache.
slice_maindims(array, **kw_xarray_isel)

slice maindims of array using self.slices. See help(type(self).slices) for more details.

(if slices is an empty dict, return array, unchanged, without making a copy.)
Only slice dims which actually appear in array.
property slices

slices for maindims when loading arrays & during get_maindims_coords.

E.g. slices = dict(x=slice(0,50), y=7)
–> slice arrays along x & y, taking the first 50 x values, and only the 7th y value.
Notes:
- only applies slices along arrays which actually contain the related coordinates,
e.g. if z=10 appears in slice but loading an array with only x & y, won’t apply z=10 slice.
- supports fractional indexing, as per interprets_fractional_indexing.
Non-integer values between -1 and 1 can be used to infer to a fraction of the dimension length,
with negative values referring to a distance from the end, just like with integer indexing.
Example: dict(x=slice(-0.3, None, 0.01), y=0.8), where x and y each have length 1000
–> equivalent to dict(x=slice(-300, None, 10), y=800).
if self.slicing is False, self.slices will give an empty dict and cannot be set to any value!
however, the old value of self.slices will be remembered in case slicing is set to True later.
slicestr(*, sep=', ', keep_None=False)

string representation of self.slices, for use in filenames, titles, etc.

comma-separated, alphabetized, ignoring slice(None).
Supports single-indexes (e.g. x=5), slices (e.g. y=slice(0, 4)),
and fractional indexing (e.g. z=slice(0, 0.5, 0.01)),
though fractional indexing will be converted to ints.

sep: str, separator between slices keep_None: bool, whether to keep slices with value None in the string.

property slicing

whether to slice maindims when loading arrays & during get_maindims_coords.

if False, self.slices will return an empty dict.
property snap

alias to self.snap_dim.v

property snap_dim

snap dimension for SnapHaver.

snap_dim_cls

alias of SnapDimension

snap_filepath(snap=None)

convert snap to full file path for this snap.

snap: None, str, int, or Snap
the snapshot number to load.
if None, use self.snap.
property snap_is_iterable

alias to self.snap_dim.is_iterable

property snap_list

alias to self.snap_dim.list

snap_src_to_filepath(src)

convert snap src to filepath. Returns self.snap_filepath(src).

property snap_type

alias to self.snap_dim.get_type

property snapdir

directory containing the snapshot files.

If self.full_read_mode==’h5_2’ or ‘h5_3’ or ‘h5_4’,
this is ‘{self.dirname}/parallel’.
Otherwise, this will crash with a NotImplementedError.
property snaps

alias to self.snap_dim.values

property snaps_from

how existing self.snaps were determined. Probably ‘parallel’ or ‘timers’.

‘parallel’ –> from files in directory ‘parallel’ (located adjacent to ‘eppic.i’)
‘timers’ –> from data in ‘domain000/timers.dat’ (‘domain000’ adjacent to ‘eppic.i’)
setting self.snaps_from=value is equivalent to calling self.init_snaps(snaps_from=value).
solve_tfbi_vs_EBspeed(*, Mbytes_max=True, cache='caches', **kw_solve)

solve tfbi across EBspeed grid from self(‘tfbi_EBspeed_grid’).

CAUTION: the implementation here might self.set(‘E_un0_perpmod_B’, self(‘mod_B’) * EBspeed)

[TODO] avoid changing self.setvars… (or, at least, restore previous self.setvars afterwards.)

Suggestion: use self.setvars.clear() after calling this function.

Mbytes_max: bool or number
maxmimum allowed data size [in MB] of self(‘tfbi_inputs’), before setting EBspeed grid.
(helps prevent accidental requests to solve too many points at once.)
(ignored if cache implies to load from existing cached file.)
True –> use default: DEFAULTS.ADDONS.TFBI_EBSPEED_INPUTS_MBYTES_MAX (default: 0.1).
False or None –> no maximum
cache: ‘caches’, ‘cache’, ‘cached’, or False
controls how & whether to handle cache the result.
cached results go to self._tfbi_vs_EBspeed_file(); default:
{self.unique_notes_dirname}/_pc_tfbi/EBspeed_{logmin:.4g}_{logmax:.4g}_{logstep:.4g}.pcxarr
where logmin, logmax, logstep are from self.tfbi_EBspeed_grid_size
‘caches’ –> read from saved file if it exists. Else, solve and save to file.
‘cache’ –> solve and save to file. Saved file must not exist yet (else, crash).
‘cached’ –> read from saved file. Saved file must exist (else, crash).
False –> solve and return result, but do not save to file nor check if file exists.
additional kwargs are passed to self.tfbi_solver().solve(**kw)
standardized_slices()

returns a copy of self.slices, but calling interprets_fractional_indexing on all slices,

using lengths from self.maindims_full_sizes.
property stat_dims

the dims over which to possibly apply statistics (StatsLoader methods).

will only apply statics along these dims for an array if they actually appear in the array.
None –> use self.maindims. (this is the default.)
See also: self.stat_dims_for(array).
stat_dims_for(array)

return the dims to apply statistics over, for this array.

Here, returns tuple of d from self.stat_dims if d in array.dims.
property stats_dimpoint_wise

whether to apply stat calculations at each DimPoint, or after loading the full array.

[EFF] this setting is just for efficiency; it doesn’t affect results (when no MemorySizeError crash).
True –> apply stat calculations to each array (at each DimPoint) before joining arrays.
e.g., self(‘mean_n’) gets ‘mean_n’ at each fluid & snap, then joins results.
False –> join arrays across all DimPoints before applying stat calculations.
e.g., self(‘mean_n’) gets ‘n’ (which varies across fluid & snap), then takes mean.
None –> if result.size will be > DEFAULTS.STATS_DIMPOINT_WISE_MIN_N / self.get_ncpu(), use True.
otherwise try using False, then use True if MemorySizeError is raised.
(True seems to be faster for large arrays but slower for small arrays.
But also, when ncpu>1, loading across dimpoints is faster due to parallelization.)
regardless of this setting, stat calculations are applied only along self.stat_dims(array).
store_mask(arr)

equivalent: xarray_store_mask(arr, self.mask). Also equivalent: arr.pc.store_mask(self.mask)

subsample(subsampling_info, *, subsampled_data_exist_ok=False)

apply subsampling to all data indicated by subsampling_result_info.

returns SubsamplingResultPathManager with relevant paths.
(results will be saved to paths determined by SubsamplingResultPathManager;
probably ‘subsampling_result’ at the same directory-level as target.snapdir.)
Never overwrites any of the pre-subsampling data.
By default, refuses to overwrite any existing data at all.
subsampling_info: SubsamplingInfo, str, or json-like dict
str –> path to load subsampling info from.
can be filename or directory. see SubsamplingInfo.load for details.
dict –> subsampling info in json-like format, see SubsamplingInfo for details.
subsampled_data_exist_ok: bool
whether it is okay for subsampled data file(s) to already exist before saving any data. Default False.
(Doesn’t interact with any subsampling_info files.)
subsample_maindims_at_snaps(*, x=None, y=None, z=None, den=UNSET, flux=UNSET, nvsqr=UNSET, phi=UNSET, others=None, **kw_subsample)

subsample same maindims but different snaps for different vars.

x, y, z: None or slice
slice for this main dim.
den, flux, nvsqr, phi: UNSET, None or slice
slice for snaps for this variable.
None –> do NOT slice snaps for this variable (but still slice maindims!)
others: None or slice
slice snaps for whichever of den, flux, nvsqr, and phi are UNSET.
None –> do not slice snaps (but still slice maindims!)
subsample_maindims_simple(*, snap=None, x=None, y=None, z=None, **kw_subsample)

self.subsample(subsampling_info corresponding to slicing snaps and maindims, only).

snap, x, y, z: None or slice
slice for this dim.
subsampler(subsampling_info)

return self.subsampler_cls instance with self and subsampling_info.

See help(self.subsample) for details on subsampling_info.
subsampler_cls

alias of Subsampler

property subsampling_info

SubsamplingInfo telling how existing data was subsampled from prior data.

By default, this info will be loaded from {self.dirname}/subsampling_info.
subsampling_info_cls

alias of SubsamplingInfo

subsampling_info_maindims_at_snaps(*, x=None, y=None, z=None, den=UNSET, flux=UNSET, nvsqr=UNSET, phi=UNSET, others=None, as_json=False)

SubsamplingInfo corresponding to subsampling maindims at different snaps.

x, y, z: None or slice
slice for this main dim. All maindims variables will be sliced according to this.
den, flux, nvsqr, phi: UNSET, None or slice
slice for snaps for this variable.
None –> do not slice snaps for this variable (but still slice maindims!)
others: None or slice
slice snaps for whichever of den, flux, nvsqr, and phi are UNSET.
None –> do not slice snaps (but still slice maindims!)
as_json: bool
if True, return json for info instead of converting to SubsamplingInfo object.
(Could be useful if you want to use this json as a starting point then make small edits)
subsampling_info_maindims_simple(*, snap=None, x=None, y=None, z=None, as_json=False)

SubsamplingInfo corresponding to slicing snaps and maindims, only.

snap, x, y, z: None or slice
slice for this dim.
as_json: bool
if True, return json for info instead of converting to SubsamplingInfo object.
(Could be useful if you want to use this json as a starting point then make small edits)
subsampling_info_path_manager_cls

alias of SubsamplingInfoPathManager

subsampling_snap_srcs()

list of all snap srcs in self (before applying any subsampling).

Here, just returns self.snaps.
property surelin_min_quantile

fraction of t_turb which tells start time of “definitely linear regime”.

Use this to avoid including startup noise when computing linear properties.
Example: t_turb=10, surelin_min_quantile=0.05 –> t_surelin=0.05*10 = 0.5.
property surelin_quantile

fraction of t_turb which tells t_surelin.

t_turb tells when turbulence probably starts.
t_surelin tells time before which, values are definitely in the linear regime.
–> to compute linear properties consider only t < t_surelin.
Example: t_turb=10, surelin_quantile=0.2 –> t_surelin=0.2*10 = 2.
See also: surelin_min_quantile.
property t_turb

None, or time of turbulent onset. some _turb quantities tell values only at t>=t_turb.

Can be set to a DataArray, to test multiple possibilities at once.
Units should be self.units. Changing self.units afterwards will NOT auto-update t_turb.
property take_component

alias to self.component_dim.take

property take_components

alias to self.component_dim.take_along

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

static take_parallel_to(B, A)

return the component of A parallel to B. Equivalent: (A dot Bhat) Bhat.

Note that B is the first argument.
static take_perp_to(B, A)

return the component of A perpendicular to B. Equivalent: A - (A dot Bhat) Bhat.

Note that B is the first argument.
property take_snap

alias to self.snap_dim.take

property take_snaps

alias to self.snap_dim.take_along

property tfbi_EBspeed_grid_size

(logmin, logmax, logstep) for self(‘tfbi_EBspeed_grid’); log is base 10.

Default: DEFAULTS.ADDONS.TFBI_EBSPEED_LOGMIN, LOGMAX, LOGSTEP; (default: (3, 4, 0.01)).

tfbi_ds(ions=None, *, all=True, output_mask=True, **kw_get_var)

returns Dataset of all the values needed & relevant to TFBI theory.

Equivalent: self(‘tfbi_all’, fluid=[electron, *ions], masking=True, …)
ions: None or specifier of multiple fluids (e.g. slice, or list of strs)
list of ions to use. None –> self.fluids.ions()
all: bool
whether to include ‘tfbi_all’, or only ‘tfbi_inputs’.
With only ‘tfbi_inputs’, the theory is still solvable, but harder to inspect later.
output_mask: bool
whether to store_mask in results, if self.masking (and self.mask is not None)
additional kwargs passed to self(…)
property tfbi_growth_thresh

threshold for confirming “yes there is tfbi growth predicted here”, during self(‘tfbi_E_thresh’).

growth must be larger than (not equal to) this value, to confirm growth.
0.0 is the theoretical threshold. A small positive value (e.g. 0.001) helps to avoid tiny errors.
The default is DEFAULTS.ADDONS.TFBI_GROWTH_THRESH (default: 0.001).
tfbi_mask(*, kappae=1, ionfrac=0.001, kappai=1, set=True)

set & return self.mask appropriate for TFBI.

kappae: None or number, default 1
lower limit for kappae; mask points with kappae smaller than this value.
(kappae = |qe| |B| / (me nuen))
Internally, loaded as ‘kappa’ with fluid=’e’.
TFBI probably only matters when electrons are magnetized –> kappae >> 1.
Applying TFBI theory to kappae masked points would still be fine,
but will probably always say “instability doesn’t grow there”.
None –> no mask on kappae
ionfrac: None or number
upper limit for ionfrac; mask points with ionfrac larger than this value.
(ionfrac = ne / ntotal)
Internally, loaded as ‘SF_ionfrac’ if available,
else ne/(ne+n_neutral), with ne from self(‘n’, fluid=self.fluids.get_electron()).
(Note: checked in Bifrost: SF_ionfrac uses SF_n = sum of element densities.
SF_n does not include ne.
The formula SF_ionfrac = ne/(ne+nn) uses ne as a proxy for sum(ni),
which will be okay unless there are twice+ ionized species.)
TFBI assumes weakly ionized.
E_un0 also assumes weakly ionized, when self.assume_un=’u’.
Applying TFBI theory to ionfrac masked points would be a big issue,
as it could lead to many false positives,
where physical effects not included in the theory damp out the TFBI.
None –> no mask on ionfrac.
kappai: None or number, default 1
upper limit for min kappai; mask points with all kappai larger than this value.
(kappai = |qi| |B| / (mi nuin))
Internally, loaded as ‘kappa’ with fluid=ions, then take min across fluids.
TFBI probably only matters when at least 1 ion species is demagnetized –> kappai < 1.
Applying TFBI theory to kappai masked points would still be fine,
but will probably always say “instability doesn’t grow there”.
None –> no mask on kappai.
set: bool
whether to set self.mask = result.
if False, only returns the result, without also setting self.mask.
tfbi_solver(ions=None, **kw_solver)

return TfbiSolver object for solving TFBI theory based on values in self.

all inputs here get passed to TfbiSolver. Equivalent: TfbiSolver(self, …).
docs for TfbiSolver copied below for convenience:
————————————————-
high-level interface for solving TFBI theory across many physical parameters.
Call TfbiSolver to solve TFBI.
Example:
import PlasmaCalcs as pc
cc = pc.PlasmaCalculator(…) # <– your PlasmaCalculator of choice
solver = pc.TfbiSolver(cc)
solution = solver() # alias: solver.solve()
solution is an xarray.Dataset with all relevant quantities (see TfbiLoader.get_tfbi_all),
and ‘omega’ telling roots with largest imaginary part.
If you need more precise control over the solving process, use the pattern:
import tfbi_theory as tt
import PlasmaCalcs as pc
cc = … # any PlasmaCalculator object from PlasmaCalcs.
ds0 = cc.tfbi_ds()
kp = tt.kPickerLowres(ds0)
dsk = kp.get_ds() # copy of ds0, but with ds[‘k’] = k from kPicker.
drel = tt.TfbiDisprelC.from_ds(dsk)
dsR = drel.solve() # copy of dsk, but with ds[‘omega’] = solution to TFBI theory!
TfbiSolver internally stores self.cc, ds0, kp, dsk, drel, and dsR,
as defined by the pattern above.
cc: PlasmaCalculator
PlasmaCalculator object used to load the data.
Should be a TfbiLoader subclass. (PlasmaCalculator satisfies this by default,
assuming successful import SymSolver and import tfbi_theory.)
ions: None or specifier of multiple fluids (e.g. slice, or list of strs)
None –> use cc.fluids.ions()
print warning if this specifies more than DEFAULTS.ADDONS.TFBI_MAX_NUM_IONS ions
(default: 5), because then solving will be slow and may be inaccurate.
ions are determined when called, not during __init__.
kres: ‘low’, ‘mid’, or ‘high’
resolution in k-space. Tells which self.kPicker_cls to use.
‘low’ –> tfbi_theory.kPickerLowres. Recommended if solving across many points.
‘mid’ –> tfbi_theory.kPickerMidres. Recommended if solving across a few points.
‘high’ –> tfbi_theory.kPickerHighres. Recommended if solving at only 1 point.
mod, lmod, ang: UNSET or dict
passed directly to kPicker if provided. Can specify k values other than the defaults.
see help(self.kPicker_cls) for more details.
tfbi_all: bool
whether to compute all relevant tfbi vars, ds0 = cc(‘tfbi_all’).
False –> compute only the necessary vars, ds0 = cc(‘tfbi_inputs’).
drel_cls: None, str, or class
tfbi_theory class to use for solving TFBI theory.
None –> use self.drel_cls default: tt.TfbiDisprelC
str –> use getattr(tt, drel_cls) to get the class.
tfbi_solver_cls

alias of TfbiSolver

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.)
timers_dat(*, with_snaps=False, as_array=False)

return timers.dat as an xarray.Dataset. (dimension will be named ‘it’)

result will have the same units as timers.dat file.
with_snaps: bool
if True, attach snap & t coords and promote ‘snap’ to main dim.
based on self.snaps (not self.snap)
as_array: bool
whether to use xarray.Dataset.to_array() to return a DataArray instead of Dataset.
if True, vars from Dataset will be concatenated along the new dimension named ‘timer’.
timescales(**kw_init)

returns EppicTimescales based on self.

CAUTION: result will have units of self.units;
remember to switch to ‘raw’ when comparing to input_deck.
property title

title to help distinguish this calculator from others.

E.g. might want to add self.title to plots.
Default: os.path.basename(self.dirname) if self.notes_dirname == self.dirname,
else basename(self.notes_dirname) + basename(self.dirname),
except skip basename(self.dirname) if ‘_sim’.
Examples of default behavior:
‘/path/to/dir0’ –> ‘dir0’.
‘/path/to/dir1/_sim’ –> ‘dir1’.
‘/path/to/dir1/_check0’ –> ‘dir1_check0’.
title_with_slices(*, sep=', ', keep_None=False)

return self.title with slicestr appended (after sep), if slicestr is not empty.

see self.slicestr() for more details.
property toplevel_scale_coords

dict of {coord_name: coord_scaling} to apply to top-level outputs of self(var).

(Never applies to internal calls of self(var), only applies at self.call_depth==1.)
Useful if making plots and want to scale coords by some factor.
E.g., self.toplevel_scale_coords = {‘t’: 1000} to convert s to ms.

CAUTION: coord units labels will remain unaffected.

tree(var=UNSET, **kw_quant_tree_from_quantity_loader)

return QuantTree of MatchedQuantity objects from matching var and all dependencies,

using self.KNOWN_VARS and self.KNOWN_PATTERNS when searching for matches.
var must be provided; var=UNSET will raise an error (helpful if tried calling this as a classmethod).
See also: type(self).cls_var_tree, for the classmethod version of this function.
Most of the time it is possible to get tree without any details from self,
but sometimes not. e.g. when getting collision frequencies, self.fluid affects deps.
additional kwargs will be passed to QuantTree.from_quantity_loader(…),
which passes kwargs from self.kw_call_options() into self.using(**kw) while getting deps.
property typevar_crash_if_nan

bool. whether to crash methods if typevar output would be ‘nan’.

False –> return NaN when typevar gives ‘nan’, instead of crashing.
“typevar” here refers to any var used for checking which formula to use, from various options,
e.g. ‘ntype’ in MhdMultifluidLoader or ‘ionfrac_type’ in MhdIonizationLoader.
The relevant methods can check if self.typevar_crash_if_nan before returning a ‘nan’ result.
property u

the current units manager for self.

if not yet initialized, getting self.u will create (and store) a new UnitsManager().
property unique_notes_dirname

abspath to directory containing plots/notes for a DirectLoader,

probably not shared by DirectLoaders corresponding to any other data.
(E.g. if
Might be the same directory as self.dirname, but doesn’t need to be;
can explicitly set self.notes_dirname = value, if desired.
If not set, use unique_notes_dirname = self.dirname,
unless dirname ends with one of the self._INDICATES_UNIQUE_NOTES_DIRNAME options.
E.g. dirname == ‘path/to/dir0’ –> unique_notes_dirname == ‘path/to/dir0’.
E.g. dirname == ‘path/to/dir1/_sim’ –> unique_notes_dirname == ‘path/to/dir1’.
E.g. dirname == ‘path/to/dir1/_check0’ –> unique_notes_dirname == ‘path/to/dir1/_check0’.
See also: self.notes_dirname
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). Also include coords_units if different.

unmask(arr, **kw_xarray_unmask)

restore arr to the same shape as unmasked unstacked arrays. masked vals will still be np.nan.

Equivalent: xarray_unmask(arr) if arr has ‘_mask’ data_var, else xarray_unmask(arr, mask=self.mask)
property unset

alias to unset_var

unset_var(var, behavior_attrs=[], *, missing_ok=True, **kw_using)

remove var from self.setvars (but only at values stored with relevant behavior).

[TODO] define rules for which vars unset which other vars…
e.g. for eppic right now, set_var(‘n’) sets ‘den’ but not ‘n’;
unset_var(‘n’) unsets nothing… but should probably alias to unset_var(‘den’).
behavior_attrs: list of strings
only remove cached values where self.behavior matches cached behavior for these attrs.
if empty, remove all cached values for var, regardless of associated behavior.
missing_ok: bool
whether it is okay for there to be zero matching cached values for var.
raise CacheNotApplicableError if missing_ok=False when there are no matching cached values.
additional kwargs, if provided, go to self.using(**kw) during the operation.
return list of CachedQuantity objects which were removed from self.setvars.
unset_var_internal(var, behavior_attrs, forall=[], *, ukey=None, missing_ok=True)

unset var from self.setvars.

KNOWN_SETTERS functions may wish to use this method, to unset dependent values.
E.g. if u depends on n, and n is changed, may wish to unset the value of u.
behavior_attrs: list of strings
the behavior attrs relevant to setting this var.
forall: list of strings
if provided, tells which behavior attrs to ignore when unsetting the var.
ukey: None or string
if provided, ignore ‘units’ behavior attr when unsetting the var
(due to assuming that ukey was provided when setting the var,
hence that the set var could be retrieved in any units system)
missing_ok: bool
whether it is okay for there to be zero matching cached values for var.
raise CacheNotApplicableError if missing_ok=False when there are no matching cached values.
return list of CachedQuantity objects which were removed from self.setvars.
property using

alias to using_attrs

using_at_call_depth(depth, **attrs_and_values)

context manager for setting attrs_and_values but only while call_depth == depth.

E.g.:

with self.using_at_call_depth(3, verbose=3):
self(‘sgyrof’)
# while self.call_depth == 3 inside of this ‘with’ block, uses self.verbose=3.
# but everywhere else, uses original value of verbose.
# assuming originally verbose=False (or unset), this example will print:
| | (call_depth=2) get var=’q’
| | (call_depth=2) get var=’mod_B’
| | (call_depth=2) get var=’m’
# compare this to simply using self.verbose=3, which would print:
| (call_depth=1) get var=’sgyrof’
| | (call_depth=2) get var=’q’
| | (call_depth=2) get var=’mod_B’
| | | (call_depth=3) get var=’B_dot_B’
| | | | (call_depth=4) get var=’B_xyz’
| | | | | (call_depth=5) get var=’B’
| | (call_depth=2) get var=’m’
Equivalent to self.call_depth_manager.using_obj_attrs_at(depth, **attrs_and_values)
using_at_next_call_depth(**attrs_and_values)

context manager for setting attrs_and_values but only while call_depth == self.call_depth + 1

Equivalent to self.using_at_call_depth(self.call_depth + 1, **attrs_and_values).

(Also equivalent to self.call_depth_manager.using_obj_attrs_at_next(**attrs_and_values).)
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.
property werrmath_require_std

whether to require ‘std’ data var appear in at least 1 input for all werrmath operations.

E.g. if True and doing A_werradd_B but neither A nor B has ‘std’, crash with InputError.
where_loadable(var=None, snaps=None, *, set=False)

returns snaps from self.snaps where ‘n’, ‘flux’, ‘nvsqr’, ‘vdist’, ‘phi’ values can be loaded,

for ALL fluids in self.fluids.
Equivalent:
with self.using(fluid=None):
return self.wheref_loadable(var=var, snaps=snaps)
[EFF] method is IMPLICIT, based on var_out_subcycling details for each fluid.
Does not actually check the files directly, because it’s expensive to do that.
[TODO] account for subsampling_info too.
var: None, list of str, str from (‘n’, ‘flux’, ‘nvsqr’, ‘vdist’, ‘phi’), or ‘all’
None –> return dict of answer for each of those vars
‘all’ –> return SnapList where all vars are loadable.
list –> return SnapList where all vars in list are loadable.
str –> return SnapList for this var only.
snaps: None, ‘current’, ‘current_range’, ‘current_n’, or SnapList
the snaps to consider.
None –> self.snaps.
‘current’ –> self.snap
‘current_range’ –> self.snaps.select_between(self.snap[0].t, self.snap[-1].t)
‘current_n’ –> ‘current_range’, but evently downsample result size similar to current n snap.
(note: even downsampling isn’t always possible; result size won’t exactly match.
useful if you want “roughly N snaps”. See example below.)
E.g. if self.snap [10,20,30,…,200] (len=19), and self.snaps [0,…,300] (len=301),
checking where_loadable(var) which is available every 4 snaps, result will be:
None –> [0,4,8,…,300] (len=76)
‘current’ –> [20,40,…,200] (len=10) # because 10,30,50,… aren’t divisible by 4
‘current_range’ –> [12,16,20,…,200] (len=48)
‘current_n’ –> [12,20,28,…,200] (len=24)
# because interprets_fractional_indexing(slice(None,None,1/19), L=48)
# gives slice(0, None, 2), which is then applied to current_range result.
set: bool
if True, also set self.snap = result.
wheref_loadable(var=None, snaps=None, *, set=False)

returns snaps from self.snaps where ‘n’, ‘flux’, ‘nvsqr’, ‘vdist’, ‘phi’ values can be loaded,

for all fluids currently in self.fluid (for non-phi vars).
[EFF] method is IMPLICIT, based on var_out_subcycling details for each fluid.
Does not actually check the files directly, because it’s expensive to do that.
[TODO] account for subsampling_info too.
var: None, list of str, str from (‘n’, ‘flux’, ‘nvsqr’, ‘vdist’, ‘phi’), or ‘all’
None –> return dict of answer for each of those vars
‘all’ –> return SnapList where all vars are loadable.
list –> return SnapList where all vars in list are loadable.
str –> return SnapList for this var only.
snaps: None, ‘current’, ‘current_range’, ‘current_n’, or SnapList
the snaps to consider.
None –> self.snaps.
‘current’ –> self.snap
‘current_range’ –> self.snaps.select_between(self.snap[0].t, self.snap[-1].t)
‘current_n’ –> ‘current_range’, but evently downsample result size similar to current n snap.
(note: even downsampling isn’t always possible; result size won’t exactly match.
useful if you want “roughly N snaps”. See example below.)
E.g. if self.snap [10,20,30,…,200] (len=19), and self.snaps [0,…,300] (len=301),
checking where_loadable(var) which is available every 4 snaps, result will be:
None –> [0,4,8,…,300] (len=76)
‘current’ –> [20,40,…,200] (len=10) # because 10,30,50,… aren’t divisible by 4
‘current_range’ –> [12,16,20,…,200] (len=48)
‘current_n’ –> [12,20,28,…,200] (len=24)
# because interprets_fractional_indexing(slice(None,None,1/19), L=48)
# gives slice(0, None, 2), which is then applied to current_range result.
set: bool
if True, also set self.snap = result.
property window

alias to polyfit_window