STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
engine.layerx.export Namespace Reference

Functions

str unit_of (str name)
Any _cell (Any v)
bool _is_column (Any v, int n)
None _walk (str prefix, Any block, int n, List[Tuple[str, List[Any], Optional[str]]] out, List[str] skipped, int depth=0)
List[Any] _place (int n, Sequence[int] rows, Sequence[Any] values)
Optional[List[int]] _rows_of (Sequence[Any] times, Sequence[float] t, float tol=1e-6)
Tuple[List[Tuple[str, str, List[Any]]], List[str]] columns (Mapping[str, Any] result)
None _diagnostic (str prefix, Any block, Sequence[float] t, Any add, List[str] skipped, Optional[List[int]] rows=None, int depth=0)
str _header (str name, str unit)
str to_csv (Mapping[str, Any] result)
Dict[str, Tuple[str, List[Optional[float]]]] read_csv (str text)
bytes to_parquet (Mapping[str, Any] result)
Tuple[List[float], List[Optional[float]], str] _engine_history (Mapping[str, Any] result, str key_delivered, str key_twin)
Optional[Dict[str, float]] _peak (Sequence[float] t, Sequence[Optional[float]] v)
str _csv (Iterable[Sequence[Any]] rows)
Optional[List[List[Any]]] _heatflux_rows (Mapping[str, Any] side, str qkey, Optional[str] tkey)
bytes fea_bundle (Mapping[str, Any] result, Optional[Mapping[str, Any]] sidecar=None)
str _readme (Mapping[str, str] files, str pc_src, str f_src, Optional[Mapping[str, Any]] sidecar)

Variables

float PSI = 6894.757293168361
tuple _SUFFIX_UNITS
dict _NAME_UNITS
 NOT_HISTORIES
 HEADER_RE = re.compile(r"^(?P<name>.*) \‍[(?P<unit>[^\‍]]*)\‍]$")

Detailed Description

A Layer X run, exported (DATA-CONTRACT 4: ``GET /api/layerx/runs/{id}/export/{fmt}``).

* :func:`to_csv` -- every per-step signal in the result, one row per twin step (``series.t``), one
  column per signal, headed ``name [unit]``. The series, the delivered (replay) columns on the firing
  steps, the replay's own points on their steps, the full network record and every diagnostics
  column that follows the series. Floats are written with ``repr``, so they read back bit for bit.
* :func:`to_parquet` -- the same table as Parquet (pyarrow), each field's unit in its metadata.
* :func:`fea_bundle` -- a zip for structural and thermal analysis: ``pc_t.csv``, ``thrust_t.csv``,
  ``heatflux_xt.csv`` (from the ``axial`` sidecar, when given), ``loads.json`` with the peak loads,
  and ``README.txt`` with units and basis.

Nothing is interpolated onto the twin's grid. A value sampled at a replay point is written on that
point's step and left empty elsewhere: a table must not imply a resolution the model did not have.
A block on its own clock that does not land on the twin's steps is not written to the table;
:func:`columns` returns what was left out, and the Parquet file's metadata lists it
(``columns_skipped``).

Function Documentation

◆ _cell()

Any engine.layerx.export._cell ( Any v)
protected

Definition at line 64 of file export.py.

Referenced by _diagnostic(), _engine_history(), _heatflux_rows(), _place(), _walk(), columns(), and fea_bundle().

◆ _csv()

str engine.layerx.export._csv ( Iterable[Sequence[Any]] rows)
protected

Definition at line 363 of file export.py.

Referenced by fea_bundle().

◆ _diagnostic()

None engine.layerx.export._diagnostic ( str prefix,
Any block,
Sequence[float] t,
Any add,
List[str] skipped,
Optional[List[int]] rows = None,
int depth = 0 )
protected
Write the histories under a diagnostics block. A block carrying its own ``index`` (series
steps) or ``t`` (times that are series steps) places its lists on those steps, and its children
inherit that clock; a list on no known clock is listed in ``skipped``.

Definition at line 225 of file export.py.

References _cell(), _diagnostic(), _place(), and _rows_of().

Referenced by _diagnostic(), and columns().

◆ _engine_history()

Tuple[List[float], List[Optional[float]], str] engine.layerx.export._engine_history ( Mapping[str, Any] result,
str key_delivered,
str key_twin )
protected
``(t, values, source)`` over the firing steps: EngineDesign's delivered values when the run
has them (the eroding engine), else the twin's own chamber.

Definition at line 339 of file export.py.

References _cell().

Referenced by fea_bundle().

◆ _header()

str engine.layerx.export._header ( str name,
str unit )
protected

Definition at line 276 of file export.py.

Referenced by to_csv().

◆ _heatflux_rows()

Optional[List[List[Any]]] engine.layerx.export._heatflux_rows ( Mapping[str, Any] side,
str qkey,
Optional[str] tkey )
protected

Definition at line 371 of file export.py.

References _cell().

Referenced by fea_bundle().

◆ _is_column()

bool engine.layerx.export._is_column ( Any v,
int n )
protected

Definition at line 73 of file export.py.

Referenced by _walk(), and columns().

◆ _peak()

Optional[Dict[str, float]] engine.layerx.export._peak ( Sequence[float] t,
Sequence[Optional[float]] v )
protected

Definition at line 355 of file export.py.

References max.

Referenced by fea_bundle().

◆ _place()

List[Any] engine.layerx.export._place ( int n,
Sequence[int] rows,
Sequence[Any] values )
protected

Definition at line 97 of file export.py.

References _cell().

Referenced by _diagnostic(), and columns().

◆ _readme()

str engine.layerx.export._readme ( Mapping[str, str] files,
str pc_src,
str f_src,
Optional[Mapping[str, Any]] sidecar )
protected

Definition at line 461 of file export.py.

Referenced by fea_bundle().

◆ _rows_of()

Optional[List[int]] engine.layerx.export._rows_of ( Sequence[Any] times,
Sequence[float] t,
float tol = 1e-6 )
protected
The series step of each time, when every time is one of the series' steps; else None.

Definition at line 105 of file export.py.

Referenced by _diagnostic(), and columns().

◆ _walk()

None engine.layerx.export._walk ( str prefix,
Any block,
int n,
List[Tuple[str, List[Any], Optional[str]]] out,
List[str] skipped,
int depth = 0 )
protected
Every per-step list of length ``n`` under ``block``, as ``(dotted name, values, unit)``.

Definition at line 77 of file export.py.

References _cell(), _is_column(), and _walk().

Referenced by _walk(), and columns().

◆ columns()

Tuple[List[Tuple[str, str, List[Any]]], List[str]] engine.layerx.export.columns ( Mapping[str, Any] result)
``([(name, unit, values)], skipped)``: the export table, one entry per column, every column as
long as ``series.t``; and the dotted names of per-point blocks that were not on the twin's steps.

Definition at line 120 of file export.py.

References _cell(), _diagnostic(), _is_column(), _place(), _rows_of(), _walk(), and unit_of().

Referenced by to_csv(), and to_parquet().

◆ fea_bundle()

bytes engine.layerx.export.fea_bundle ( Mapping[str, Any] result,
Optional[Mapping[str, Any]] sidecar = None )
The loads a structural or thermal model needs, as a zip (bytes).

``sidecar`` is the run's ``axial`` sidecar (``{x_mm, t, q_MW_m2, T_wall_K}``, rows t, columns x);
without it there is no ``heatflux_xt.csv`` and ``loads.json`` says so.

Definition at line 386 of file export.py.

References _cell(), _csv(), _engine_history(), _heatflux_rows(), _peak(), _readme(), and max.

◆ read_csv()

Dict[str, Tuple[str, List[Optional[float]]]] engine.layerx.export.read_csv ( str text)
:func:`to_csv`'s output back as ``{name: (unit, values)}``: the round trip the tests use and a
reader for anyone scripting against an export.

Definition at line 297 of file export.py.

◆ to_csv()

str engine.layerx.export.to_csv ( Mapping[str, Any] result)
Every per-step signal as CSV: a header row of ``name [unit]``, then one row per twin step.
Booleans are 1/0, undefined cells empty, floats ``repr`` (exact).

Definition at line 280 of file export.py.

References _header(), and columns().

◆ to_parquet()

bytes engine.layerx.export.to_parquet ( Mapping[str, Any] result)
The CSV's table as Parquet: one float64 column per signal (booleans as 0/1), named as the CSV
names it without the unit; each field's ``unit`` in its metadata, and the run's identity and the
skipped blocks in the file's.

Definition at line 311 of file export.py.

References columns().

◆ unit_of()

str engine.layerx.export.unit_of ( str name)
The unit a Layer X key carries, from the repo's naming convention (``*_psia``, ``*_K``, ...);
``1`` for a key without a unit suffix, which in this result is a ratio or a fraction (ΔP/Pc,
O/F, ε, η, margins). Instrument and network columns pass their own unit explicitly.

Definition at line 51 of file export.py.

Referenced by columns().

Variable Documentation

◆ _NAME_UNITS

dict engine.layerx.export._NAME_UNITS
protected
Initial value:
1= {
2 "t": "s", "dt": "s", "mdot": "kg/s", "mdot_O": "kg/s", "mdot_F": "kg/s", "mdot_ox": "kg/s",
3 "mdot_fuel": "kg/s", "capacity_mdot": "kg/s", "cstar": "m/s", "cstar_ideal": "m/s", "cstar_actual": "m/s",
4 "isp": "s", "Isp": "s", "thrust": "N", "p": "psia", "T": "K",
5 "v_ox": "m/s", "v_fuel": "m/s", "omega": "rad/s", "frequency": "Hz", "firing": "bool", "converged": "bool",
6 "extrapolated": "bool", "choked": "bool", "wide_open": "bool", "summerfield": "bool", "schmucker": "bool",
7 "replay_point": "bool", "in_start": "bool",
8}

Definition at line 41 of file export.py.

◆ _SUFFIX_UNITS

tuple engine.layerx.export._SUFFIX_UNITS
protected
Initial value:
1= (
2 # Compound suffixes before their tails: "_mm_s" (a recession rate) would otherwise read as "_s".
3 ("_MW_m2", "MW/m^2"), ("_kg_m3", "kg/m^3"), ("_m_s2", "m/s^2"), ("_mm_s", "mm/s"), ("_m_s", "m/s"),
4 ("_kg_s", "kg/s"),
5 ("_psia", "psia"), ("_psig", "psig"), ("_psi", "psi"), ("_pa", "Pa"), ("_Pa", "Pa"), ("_K", "K"),
6 ("_kg", "kg"), ("_N", "N"), ("_Ns", "N*s"), ("_hz", "Hz"), ("_Hz", "Hz"), ("_mm", "mm"), ("_m2", "m^2"),
7 ("_m3", "m^3"), ("_um", "um"), ("_ms", "ms"), ("_deg", "deg"), ("_cal", "cal"), ("_pct", "%"), ("_J", "J"),
8 ("_W", "W"), ("_L", "L"), ("_s", "s"), ("_m", "m"), ("_g", "g0"),
9)

Definition at line 32 of file export.py.

◆ HEADER_RE

engine.layerx.export.HEADER_RE = re.compile(r"^(?P<name>.*) \‍[(?P<unit>[^\‍]]*)\‍]$")

Definition at line 294 of file export.py.

◆ NOT_HISTORIES

engine.layerx.export.NOT_HISTORIES
Initial value:
1= frozenset({"model", "nyquist", "tau_sweep", "acoustic", "contour", "frames", "soak", "inputs",
2 "worst", "settled_min", "other_basis", "check", "feed", "start", "summary"})

Definition at line 221 of file export.py.

◆ PSI

float engine.layerx.export.PSI = 6894.757293168361

Definition at line 29 of file export.py.