PlasmaCalcs.hookups.bifrost.bifrost_snaps.BifrostScrSnap

class PlasmaCalcs.hookups.bifrost.bifrost_snaps.BifrostScrSnap(s=None, i=None, *, t=None, params=None)

Bases: BifrostSnap, SpecialDimensionValue

BifrostSnap corresponding to the “.scr” snapshot.
There is at most 1 scr snap per Bifrost simulation.
__init__(s=None, i=None, *, t=None, params=None)

Methods

__init__([s, i, t, params])

copy(**kw_init)

copy_add_t(t_add)

deserialize(serial)

equal_except_i(v)

exists_for(calculator)

file_path(calculator)

file_s(calculator)

file_snap(calculator)

from_dict(d, *[, ignore_dt])

from_here(snapname, *[, dir, missing_ok])

from_idl_file(filename, *[, i])

get(key[, default])

getter(dlist)

items()

keys()

lookup_dict()

register_type(cls_to_register[, ...])

serialize()

to_dict()

values()

var_paths_manager(calculator)

with_i(i)

Attributes

SERIAL_TYPES

filename

ndim

size

snapname

copy(**kw_init)
return a copy of self. Can provide new kwargs here to override old values in result.
E.g. self.copy(i=7) makes a copy of self but with i=7 instead of self.i.
copy_add_t(t_add)
create a copy of self but with t increased by t_add.
Equivalent to self.copy(t=self.t + t_add).
Provided separately for convenience; shifting t can be quite useful.
static deserialize(serial)
creates an XarrayIoSerializable object from a serialized representation.
serial: dict or str
str –> convert to dict via ast.literal_eval.
dict must contain ‘typename’ key.
The output here will be an instance of XarrayIoSerializable.SERIAL_TYPES[typename]
equal_except_i(v)
returns whether self == v (another DimensionValue), ignoring i.
equal if v is an instance of type(self) and
all kw from both self._kw_eq and v._kw_eq have the same values.
(any kw missing attrs will be treated as UNSET.)
For DimensionValue: self.s==v.s and self.i==v.i. Subclasses may add more.
exists_for(calculator)
returns whether this snap exists for this calculator.
Here, just return self is not MISSING_SNAP. subclass should override if desired.
file_path(calculator)
returns the abspath to the file associated with this snap for this calculator.
Here, just return calculator.snap_filepath(self).
file_s(calculator)
returns the str used when determining file related to this snap.
Here, just return str(self). subclass should override if desired.
file_snap(calculator)
returns the snap used when determining file related to this snap.
Here, just returns self. Subclasses might override.
property filename
return filename of idl file for this snap: snapname_NNN.idl
classmethod from_dict(d, *, ignore_dt=True)
return cls from dict d. d should NOT have ‘typename’ key.
Use cls.deserialize(d) instead if d has ‘typname’ key.
ignore_dt: bool
whether to ignore ‘dt’ key from d.
This exists for backwards compatibility when reading older files;
Snap previously accepted ‘dt’ key but doesn’t anymore.
classmethod from_here(snapname, *, dir='.', missing_ok=True)
return BifrostScrSnap from the scr file with this snapname, in this directory.
missing_ok: bool
whether it is okay for scr file to be missing.
True & missing –> return MISSING_SNAP.
False & missing –> raise FileNotFoundError.
classmethod from_idl_file(filename, *, i=None)
return BifrostSnap based on idl file.
filename: str.
file to read from. Like snapname_NNN.idl.
will use s=NNN as label. E.g. snapname_071.idl –> s=’071’.
snapname determined from file contents (one of the params should be “snapname”)
i: None or int
index of this snapshot in a SnapList.
get(key, default=UNSET)
return self[key]. if default is provided and self[key] doesn’t exist, return default.
getter(dlist)
get the value from dlist specified by self.
(Here, just returns self, the SpecialDimensionValue)
items()
return tuple of (key, value) pairs corresponding to self.keys() and self.values().
keys()
return tuple of keys of self.params
lookup_dict()
returns dict for looking up self within a DimensionValueList, given int, str, or self.
(used by DimensionValueList.lookup_dict)
static register_type(cls_to_register, _serial_typename=None)
register cls_to_register as a serializable subclass of XarrayIoSerializable.
_serial_typename: str or None
name to use for serialization. if None, use cls_to_register.__name__.
serialize()
return dict of info about self, including ‘typename’ key.
property snapname
return snapname of this snap: self.params[“snapname”]
to_dict()
return dictionary of info about self. Attribute values for keys in self._kw_def.
e.g. if _kw_def={‘s’, ‘i’}: result = {‘s’: self.s, ‘i’: self.i}
values()
return tuple of values corresponding to self.keys().
var_paths_manager(calculator)
return BifrostVarPathsManager for this snap.

calculator: BifrostCalculator. used for snapdir.

var_paths_manager_cls

alias of BifrostScrVarPathsManager

with_i(i)
return copy of self with i=i, or self if self.i==i already.