Skip to content

Convert

Format conversion utilities for base flow data.

Functions

convert_meanflow

1
2
3
from lst_tools import convert_meanflow

convert_meanflow(grid, flow, "meanflow.bin", cfg=config)

Convert an HDF5 base flow to the Fortran binary format used by the LST solver.

lst_tools.convert.convert_meanflow

convert_meanflow(grid: Grid, flow: Flow, out: str | Path, *, cfg: Config, format: str = 'binary', debug_path: Path | str | None = None) -> Path

Convert grid and flow fields to LASTRAC meanflow format.

Steps performed
  1. Compute curvilinear coordinate s
  2. Compute surface angle and (optionally) rotate velocity profiles
  3. Compute local body radius and curvature
  4. Write meanflow file (Fortran binary or ASCII)

Parameters:

Name Type Description Default
grid Grid

Computational grid (lst_tools.core).

required
flow Flow

Flow field data defined on grid (lst_tools.core).

required
out str | Path

Output file path for the LASTRAC meanflow file.

required
cfg dict

Configuration object (typically Config from config/schema.py).

required
format str

Output format: "binary" (default) or "ascii".

'binary'
debug_path Path | str | None

If given, write diagnostic files to this directory.

None

Returns:

Name Type Description
Path Path

The resolved output file path.

Raises:

Type Description
ValueError

If the configuration contains invalid station ranges or missing geometry type.

generate_lst_input_deck

1
2
3
from lst_tools import generate_lst_input_deck

generate_lst_input_deck(cfg=config, out_path="lst_input.dat")

Generate an input deck for the LST solver.

lst_tools.convert.generate_lst_input_deck

generate_lst_input_deck(*, cfg: Config | None = None, out_path: str | Path) -> Path

Write a complete LASTRAC input deck to out_path.

Parameters:

Name Type Description Default
cfg Config | None

Configuration object. None falls back to schema defaults.

None
out_path str | Path

Destination file path for the input deck.

required

Returns:

Name Type Description
Path Path

The path the input deck was written to.

convert_meanflow(grid, flow, "meanflow.bin", cfg=config)

Use this path when base-flow data is already available in Python. For the
exact data requirements and helper objects, use the
[Convert](../api/convert.md) and [Grid & Flow](../api/core.md) reference
pages.

## Typical API Automation Pattern

Use one Python driver to edit config values and prepare several runs.

```python
from lst_tools import read_config, parsing_setup, write_config

config = read_config("lst.cfg")

for beta_max in (0.02, 0.04, 0.06):
    config.lst.params.beta_e = beta_max
    out_name = f"lst_input_beta_{beta_max:.2f}.dat"
    parsing_setup(cfg=config, out_name=out_name, auto_fill=True)

write_config("lst.cfg", overwrite=True, cfg_data=config.to_dict())

This pattern is usually the main reason to switch from CLI to API.

Where the API Reference Fits

Use this page for practical workflow patterns. Use the API Reference when you need exact signatures, class definitions, module organization, or lower-level utility details.