Skip to content

Data I/O

File readers and writers for the formats used by the LST workflow.

Fortran Binary (re-exported from cfd-io)

lst_tools re-exports the Fortran binary reader and writer used for solver binary files from cfd-io:

1
2
3
4
from lst_tools import FortranBinaryReader, FortranBinaryWriter

reader = FortranBinaryReader("meanflow.bin")
writer = FortranBinaryWriter("output.bin")

See the cfd-io documentation for the full API.

Meanflow Binary

LastracReader

from lst_tools.data_io import LastracReader

lst_tools.data_io.LastracReader

Bases: FortranBinaryReader

Fortran binary reader with LASTRAC mean-flow record helpers.

read_header

read_header() -> dict

Read LASTRAC file header records.

Returns a dict with keys

title, n_station, igas, iunit, Pr, stat_pres, nsp

read_station_header

read_station_header() -> dict

Read LASTRAC station header (two records).

Returns a dict with keys

i_loc, n_eta, s, lref, re1, kappa, rloc, drdx, stat_temp, stat_uvel, stat_dens

read_station_vector

read_station_vector(*, count: int | None = None) -> np.ndarray

Read a station vector (1-D array of reals).

If count is given, validate the record length.

LastracWriter

from lst_tools.data_io import LastracWriter

lst_tools.data_io.LastracWriter

Bases: FortranBinaryWriter

Fortran binary writer with LASTRAC mean-flow record helpers.

write_header

write_header(title: str, n_station: int, igas: int, iunit: int, Pr: float, stat_pres: float, nsp: int) -> None

Write LASTRAC file header records.

write_station_header

write_station_header(*, i_loc: int, n_eta: int, s: float, lref: float, re1: float, kappa: float, rloc: float, drdx: float, stat_temp: float, stat_uvel: float, stat_dens: float) -> None

Write LASTRAC station header (two records).

write_station_vector

write_station_vector(vec: ndarray | list[float], *, count: int | None = None) -> None

Write a station vector (1-D array of reals) as one Fortran record.

Flow Conditions

read_flow_conditions

1
2
3
from lst_tools import read_flow_conditions

fc = read_flow_conditions("flow_conditions.dat")

lst_tools.data_io.read_flow_conditions

Read legacy flow_conditions.dat and return a dict of SI flow conditions.

Only extracts the first numeric value on each line. Unknown lines are ignored gracefully.

read_flow_conditions

read_flow_conditions(fpath: str | Path) -> dict[str, float]

Parse a legacy flow_conditions.dat and return a dict with keys compatible with your config's flow_conditions section.

We favor the first numeric value on the line (expected SI). Lines with multiple numbers like "ptot: / " will yield the first (Pa).

Parameters

fpath : str | Path Path to the flow_conditions.dat file.

Returns

dict[str, float] A mapping like: { "mach": 5.3, "re1": 1.79e7, "gamma": 1.4, "cp": 1005.0, "cv": 717.9, "rgas": 287.15, "pres_0": ..., "temp_0": ..., "pres_inf": ..., "temp_inf": ..., "dens_inf": ..., "uvel_inf": ... } Only keys that were found are returned.

Tecplot ASCII

read_tecplot_ascii

1
2
3
from lst_tools import read_tecplot_ascii

data = read_tecplot_ascii("profile.dat")

lst_tools.data_io.read_tecplot_ascii

read_tecplot_ascii(path: str | Path) -> TecplotData

read a Tecplot ASCII file with one ordered ZONE returns TecplotData with data shaped (K, J, I, nvars).