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]
) -> Optional[DataFrame]

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
Optional[DataFrame]

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]
) -> Optional[DataFrame]

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
Optional[DataFrame]

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], Optional[DataFrame]]

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 Optional[DataFrame]

the time indexed by time steps.

rprof_h5

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

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 Optional[DataFrame]

the time indexed by time steps.

refstate

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

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 Optional[tuple[list[list[DataFrame]], list[DataFrame]]]

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

adia Optional[tuple[list[list[DataFrame]], list[DataFrame]]]

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) -> Optional[int]

Read istep from binary field file.

Parameters:

Name Type Description Default
fieldfile Path

path of the binary field file.

required

Returns:

Type Description
Optional[int]

the time step at which the binary file was written.

field_header

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

Read header info from binary field file.

Parameters:

Name Type Description Default
fieldfile Path

path of the binary field file.

required

Returns:

Type Description
Optional[dict[str, Any]]

the header information of the binary file.

fields

fields(
    fieldfile: Path,
) -> Optional[tuple[dict[str, Any], NDArray]]

Extract fields data.

Parameters:

Name Type Description Default
fieldfile Path

path of the binary field file.

required

Returns:

Type Description
Optional[tuple[dict[str, Any], NDArray]]

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,
) -> Optional[dict[str, list[NDArray]]]

Extract tracers data.

Parameters:

Name Type Description Default
tracersfile Path

path of the binary tracers file.

required

Returns:

Type Description
Optional[dict[str, list[NDArray]]]

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: Optional[dict[str, Any]] = None,
) -> Optional[tuple[dict[str, Any], NDArray]]

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 Optional[dict[str, Any]]

geometry information.

None

Returns:

Type Description
Optional[tuple[dict[str, Any], NDArray]]

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]

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]

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
int

tuple (isnap, istep).