stagyydata
Define high level structure StagyyData and helper classes.
Note
The helper classes are not designed to be instantiated on their own, but
only as attributes of StagyyData
instances. Users of this module should
only instantiate StagyyData
.
Refstate
Reference state profiles.
The StagyyData.refstate
attribute is an instance of this class.
Reference state profiles are accessed through the attributes of this
object.
systems
property
adiabats
property
Adiabatic reference state profiles.
It is a list of :class:pandas.DataFrame
containing the reference
profiles associated with each system. The last item is the combined
adiabat.
Tseries
Time series.
The StagyyData.tseries
attribute is an instance of this class.
Tseries
implements the getitem mechanism. Keys are series names
defined in stagpy.phyvars.TIME[_EXTRA]
. Items are
stagpy.datatypes.Tseries instances.
isteps
property
Step indices.
This is such that time[istep]
is at step isteps[istep]
.
tslice
Return a Tseries
between specified times.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
time variable. |
required |
tstart |
Optional[float]
|
starting time. Set to None to start at the beginning of available data. |
None
|
tend |
Optional[float]
|
ending time. Set to None to stop at the end of available data. |
None
|
RprofsAveraged
Bases: Rprofs
Radial profiles time-averaged over a StepsView
.
The StepsView.rprofs_averaged
attribute is an instance of this class.
It implements the same interface as Rprofs
but
returns time-averaged profiles instead.
Steps
Collections of time steps.
The StagyyData.steps
attribute is an instance of this class.
Time steps (which are Step
instances) can be
accessed with the item accessor:
Slices or tuple of istep and slices of Steps
object are
StepsView
instances that you can iterate and filter:
for step in steps[500:]:
# iterate through all time steps from the 500-th one
do_something(step)
for step in steps[-100:].filter(snap=True):
# iterate through all snapshots present in the last 100 time steps
do_something(step)
for step in steps[0,3,5,-2:]:
# iterate through steps 0, 3, 5 and the last two
do_something(step)
at_time
Return step corresponding to a given physical time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time |
float
|
the physical time requested. |
required |
after |
bool
|
when False (the default), the returned step is such that its time is immediately before the requested physical time. When True, the returned step is the next one instead (if it exists, otherwise the same step is returned). |
False
|
Returns:
Type | Description |
---|---|
Step
|
the relevant step. |
Snaps
Bases: Steps
Collection of snapshots.
The StagyyData.snaps
attribute is an instance of this class.
Snapshots (which are Step
instances) can be accessed
with the item accessor:
at_time
Return snap corresponding to a given physical time.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time |
float
|
the physical time requested. |
required |
after |
bool
|
when False (the default), the returned snap is such that its time is immediately before the requested physical time. When True, the returned snap is the next one instead (if it exists, otherwise the same snap is returned). |
False
|
Returns:
Type | Description |
---|---|
Step
|
the relevant |
StepsView
Filtered iterator over steps or snaps.
Instances of this class are returned when taking slices of
StagyyData.steps
or StagyyData.snaps
attributes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
steps_col |
Union[Steps, Snaps]
|
steps collection, i.e. |
required |
items |
Sequence[StepIndex]
|
iterable of isteps/isnaps or slices. |
required |
filter
filter(
snap: bool = False,
rprofs: bool = False,
fields: Optional[Iterable[str]] = None,
func: Optional[Callable[[Step], bool]] = None,
) -> StepsView
Add filters to the view.
Note that filters are only resolved when the view is iterated.
Successive calls to :meth:filter
compose. For example, with this
code:
the produced view
, when iterated, will generate the steps after the
500-th that have radial profiles, and both the temperature and
viscosity fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snap |
bool
|
if true, the step must be a snapshot to pass. |
False
|
rprofs |
bool
|
if true, the step must have rprofs data to pass. |
False
|
fields |
Optional[Iterable[str]]
|
list of fields that must be present to pass. |
None
|
func |
Optional[Callable[[Step], bool]]
|
arbitrary function returning whether a step should pass the filter. |
None
|
Returns:
Type | Description |
---|---|
StepsView
|
self. |
StagyyData
Generic lazy interface to StagYY output data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
PathLike
|
path of the StagYY run. It can either be the path of the directory containing the par file, or the path of the par file. If the path given is a directory, the path of the par file is assumed to be path/par. |
required |
read_parameters_dat |
bool
|
read |
True
|
Attributes:
Name | Type | Description |
---|---|---|
steps |
Steps
|
collection of time steps. |
snaps |
Snaps
|
collection of snapshots. |
refstate |
Refstate
|
reference state profiles. |
nfields_max
property
writable
Maximum number of scalar fields kept in memory.
Setting this to a value lower or equal to 5 raises a
stagpy.error.InvalidNfieldsError. Set this to None
if
you do not want any limit on the number of scalar fields kept in
memory. Defaults to 50.
filename
filename(
fname: str,
timestep: Optional[int] = None,
suffix: str = "",
force_legacy: bool = False,
) -> Path
Return name of StagYY output file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fname |
str
|
name stem. |
required |
timestep |
Optional[int]
|
snapshot number if relevant. |
None
|
suffix |
str
|
optional suffix of file name. |
''
|
force_legacy |
bool
|
force returning the legacy output path. |
False
|
Returns:
Type | Description |
---|---|
Path
|
the path of the output file constructed with the provided segments. |