Skip to content

stagyyparsers

Parsers of StagYY output files.

Note

These functions are low level utilities. You should not use these unless you know what you are doing. To access StagYY output data, use an instance of StagyyData.

time_series

time_series(
    timefile: Path, colnames: list[str]
) -> DataFrame | None

Read temporal series text file.

If colnames is too long, it will be truncated. If it is too short, additional numeric column names from 0 to N-1 will be attributed to the N extra columns present in timefile.

Parameters:

Name Type Description Default
timefile Path

path of the time.dat file.

required
colnames list[str]

names of the variables expected in timefile (may be modified).

required

Returns:

Type Description
DataFrame | None

A pandas.DataFrame containing the time series, organized by variables in columns and time steps in rows.

time_series_h5

time_series_h5(
    timefile: Path, colnames: list[str]
) -> DataFrame | None

Read temporal series HDF5 file.

If colnames is too long, it will be truncated. If it is too short, additional column names will be deduced from the content of the file.

Parameters:

Name Type Description Default
timefile Path

path of the TimeSeries.h5 file.

required
colnames list[str]

names of the variables expected in timefile (may be modified).

required

Returns:

Type Description
DataFrame | None

A pandas.DataFrame containing the time series, organized by variables in columns and the time steps in rows.

rprof

rprof(
    rproffile: Path, colnames: list[str]
) -> tuple[dict[int, DataFrame], DataFrame | None]

Extract radial profiles data.

If colnames is too long, it will be truncated. If it is too short, additional numeric column names from 0 to N-1 will be attributed to the N extra columns present in timefile.

Parameters:

Name Type Description Default
rproffile Path

path of the rprof.dat file.

required
colnames list[str]

names of the variables expected in rproffile.

required

Returns:

Name Type Description
profs dict[int, DataFrame]

a dict mapping istep to radial profiles.

times DataFrame | None

the time indexed by time steps.

rprof_h5

rprof_h5(
    rproffile: Path, colnames: list[str]
) -> tuple[dict[int, DataFrame], DataFrame | None]

Extract radial profiles data.

If colnames is too long, it will be truncated. If it is too short, additional column names will be deduced from the content of the file.

Parameters:

Name Type Description Default
rproffile Path

path of the rprof.h5 file.

required
colnames list[str]

names of the variables expected in rproffile.

required

Returns:

Name Type Description
profs dict[int, DataFrame]

a dict mapping istep to radial profiles.

times DataFrame | None

the time indexed by time steps.

refstate

refstate(
    reffile: Path, ncols: int = 8
) -> tuple[list[list[DataFrame]], list[DataFrame]] | None

Extract reference state profiles.

Parameters:

Name Type Description Default
reffile Path

path of the refstate file.

required
ncols int

number of columns.

8

Returns:

Name Type Description
syst tuple[list[list[DataFrame]], list[DataFrame]] | None

list of list of pandas.DataFrame containing the reference state profiles for each system and each phase in these systems.

adia tuple[list[list[DataFrame]], list[DataFrame]] | None

list of pandas.DataFrame containing the adiabatic reference state profiles for each system, the last item being the combined adiabat.

field_istep

field_istep(fieldfile: Path) -> int | None

Read istep from binary field file.

Parameters:

Name Type Description Default
fieldfile Path

path of the binary field file.

required

Returns:

Type Description
int | None

the time step at which the binary file was written.

field_header

field_header(fieldfile: Path) -> dict[str, Any] | None

Read header info from binary field file.

Parameters:

Name Type Description Default
fieldfile Path

path of the binary field file.

required

Returns:

Type Description
dict[str, Any] | None

the header information of the binary file.

fields

fields(
    fieldfile: Path,
) -> tuple[dict[str, Any], NDArray[np.float64]] | None

Extract fields data.

Parameters:

Name Type Description Default
fieldfile Path

path of the binary field file.

required

Returns:

Type Description
tuple[dict[str, Any], NDArray[float64]] | None

the tuple (header, fields). fields is an array of scalar fields indexed by variable, x-direction, y-direction, z-direction, block.

tracers

tracers(
    tracersfile: Path,
) -> dict[str, list[NDArray[np.float64]]] | None

Extract tracers data.

Parameters:

Name Type Description Default
tracersfile Path

path of the binary tracers file.

required

Returns:

Type Description
dict[str, list[NDArray[float64]]] | None

Tracers data organized by attribute names and blocks.

read_geom_h5

read_geom_h5(
    xdmf: FieldXmf, snapshot: int
) -> dict[str, Any]

Extract geometry information from hdf5 files.

Parameters:

Name Type Description Default
xdmf FieldXmf

xdmf file parser.

required
snapshot int

snapshot number.

required

Returns:

Type Description
dict[str, Any]

geometry information.

read_field_h5

read_field_h5(
    xdmf: FieldXmf,
    fieldname: str,
    snapshot: int,
    header: dict[str, Any] | None = None,
) -> tuple[dict[str, Any], NDArray[np.float64]] | None

Extract field data from hdf5 files.

Parameters:

Name Type Description Default
xdmf FieldXmf

xdmf file parser.

required
fieldname str

name of field to extract.

required
snapshot int

snapshot number.

required
header dict[str, Any] | None

geometry information.

None

Returns:

Type Description
tuple[dict[str, Any], NDArray[float64]] | None

geometry information and field data. None is returned if data is unavailable.

read_tracers_h5

read_tracers_h5(
    xdmf: TracersXmf, infoname: str, snapshot: int
) -> list[NDArray[np.float64]]

Extract tracers data from hdf5 files.

Parameters:

Name Type Description Default
xdmf TracersXmf

xdmf file parser.

required
infoname str

name of information to extract.

required
snapshot int

snapshot number.

required

Returns:

Type Description
list[NDArray[float64]]

Tracers data organized by attribute and block.

read_time_h5

read_time_h5(h5folder: Path) -> Iterator[tuple[int, int]]

Iterate through (isnap, istep) recorded in h5folder/'time_botT.h5'.

Parameters:

Name Type Description Default
h5folder Path

directory of HDF5 output files.

required

Yields:

Type Description
tuple[int, int]

tuple (isnap, istep).