PlasmaCalcs.hookups.bifrost.bifrost_stagger.Staggerer

class PlasmaCalcs.hookups.bifrost.bifrost_stagger.Staggerer(x, *, periodic, dx=None, order=5, mode='numpy_improved', short_ok=True, assert_ndim=None)

Bases: object

class to do staggering along an axis.
internally, staggering will transpose, stagger along 0th axis, then transpose back.
x: int or str
the axis to take the derivative along.
str –> ‘x’, ‘y’, or ‘z’, corresponding to 0, 1, 2.
internally stored as int.
periodic: bool
whether to treat the array as periodic along x.
True –> use pad=’wrap’ to fill values for stagger at edges of array.
False –> use pad=’reflect’ to fill values for stagger at edges of array.
dx: None, number, or 1D array
spacing along this axis. relevant for deriv but not shift.
None –> deriv methods will crash.
order: 1 or 5.
order of the scheme to use, by default.
mode: str
method for stagger calculations. Right now, only supports ‘numpy_improved’.
Eventually might support ‘numpy’, ‘numba’, and ‘numba_improved’.
short_ok: bool
whether it is okay for arrays to be too short along x axis.
True –> if too short: for shift, return as-is; for derivative, return zeros.
False –> if too short: raise DimensionSizeError
assert_ndim: None or int
if provided, assert ndim(array) equals this value, before staggering.
e.g. if expecting all arrays to be 3D, use assert_ndim=3.
__init__(x, *, periodic, dx=None, order=5, mode='numpy_improved', short_ok=True, assert_ndim=None)

Methods

__init__(x, *, periodic[, dx, order, mode, ...])

at_least_size_x(array, size, *[, short_ok])

deriv(array, *, up, **kw)

deriv_dn(array, **kw)

deriv_o1(array, *, up[, pre_padded, depad_dx])

deriv_o5(array, *, up[, pre_padded, depad_dx])

deriv_up(array, **kw)

pad(transposed_array, *, up)

shift(array, *, up, **kw)

shift_dn(array, **kw)

shift_o1(array, *, up[, pre_padded])

shift_o5(array, *, up[, pre_padded])

shift_up(array, **kw)

size_x(array)

transpose(array)

Attributes

PAD_AMOUNT

dddn

ddup

dn

dx

up

at_least_size_x(array, size, *, short_ok=None)
returns whether array has at least this size along x axis.
short_ok: None or bool
whether it is okay for arrays to be too short along x axis.
None –> use self.short_ok.
False –> raise DimensionSizeError if too short.
property dddn
alias to deriv_dn
property ddup
alias to deriv_up
deriv(array, *, up, **kw)
take derivative of array along x axis, staggering as appropriate.
up=True (up) or False (down)
deriv_dn(array, **kw)
take derivative of array down. Equivalent: deriv(array, up=False)
deriv_o1(array, *, up, pre_padded=False, depad_dx=None)
first order derivative, staggering up.
deriv_o5(array, *, up, pre_padded=False, depad_dx=None)
fifth order derivative, staggering as appropriate.
deriv_up(array, **kw)
take derivative of array up. Equivalent: deriv(array, up=True)
property dn
alias to shift_dn
property dx
spacing along this axis. relevant for deriv but not shift.
if None, getting self.dx will raise InputMissingError.
pad(transposed_array, *, up)
pad array along 0th axis as appropriate, to prepare it for staggering computations.
up=True (up) or False (down)
shift(array, *, up, **kw)
shift array along x axis, staggering as appropriate.
up=True (up) or False (down)
shift_dn(array, **kw)
shift array down. Equivalent: shift(array, up=False)
shift_o1(array, *, up, pre_padded=False, **kw_None)
first order shift, staggering up.
shift_o5(array, *, up, pre_padded=False, **kw_None)
fifth order shift, staggering as appropriate.
shift_up(array, **kw)
shift array up. Equivalent: shift(array, up=True)
size_x(array)
returns size of array along x axis.
transpose(array)
swap axis self.x with axis 0.
Note, this is its own inverse, i.e. transpose(transpose(array)) == array.
property up
alias to shift_up