pyflightstream.post.settings_table (stable)¶
Generated from the docstrings at build time: every one of the 11 names in the __all__ of pyflightstream.post.settings_table has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
The optional all-numeric projection of a solver-setup snapshot.
Pipeline role: a projection FOR TOOLS, never the record. The settings record PFS-2012.11 writes beside every result is strings and mixed types, which a plotting script or a spreadsheet cannot treat as data. This module turns one or more snapshots into a table holding nothing but numbers, so those tools can read it, and it is lossy by construction, which is why it is optional and never replaces the full record.
THE MEASUREMENT THE LAYOUT RESTS ON. Across the sixty-five flags of a
bare snapshot on 26.120 the value field holds FIVE Python types:
fifty-seven None, two int, four float, one str and one
list. One column cannot carry that and stay numeric.
THE RULE: A SENTINEL MAY ONLY APPEAR IN A COLUMN WHOSE DOMAIN WE CONTROL. The code columns are assigned here, densely from 1, so 999 is free in them by construction. The value columns are not ours: they carry iteration counts, angles and boundary indices, any of which can legitimately be 999. Carrying the value AND whether we know it in one cell is the collision; separating them is the whole fix, and unknown stops being a magic number and becomes the provenance code it always was.
THE CODEBOOK IS FROZEN AND ITS HOME IS THE PAGE. docs/settings-codebook.md
carries the flag ids, the provenance and kind codes and the per-flag
enumerations, and tests/tier1_offline/test_settings_codebook.py reads that page
and fails when this module disagrees with it. That direction is
deliberate: if the only thing holding the encoding still were a page
describing the code, the two would drift the first time a flag gained a
state, and every file written in between would be misread from then on.
FLAG IDS ARE APPENDED, NEVER DERIVED. FLAG_SPECS grows whenever a
registered build adds a settings command, and it grows in the MIDDLE:
its order is the helper's emission order, not an arrival order. An id
read off a position there would renumber half the codebook on the next
build. So the order below is frozen literally, and a new flag takes the
next unused id in the same commit that moves the page.
Advanced¶
pyflightstream.post.settings_table.ENUMERATIONS
module-attribute
¶
ENUMERATIONS: Mapping[str, tuple[str, ...]] = (
MappingProxyType(
{
"SET_BOUNDARY_LAYER_TYPE": (
"LAMINAR",
"TRANSITIONAL",
"TURBULENT",
),
"SET_SOLVER_MODEL": (
"INCOMPRESSIBLE",
"SUBSONIC",
"TRANSONIC",
"LOW_ORDER_SUPERSONIC",
),
"AEROELASTIC_RBF_TYPE": (
"WENDLAND_C2",
"GAUSSIAN",
"THIN_PLATE_SPLINE",
"MULTI_QUADRATIC",
"INV_MULTI_QUADRATIC",
),
"SET_VISCOUS_EXCLUDED_BOUNDARIES": ("all",),
"SET_THIN_BOUNDARIES": ("all",),
"SET_AXIAL_SEPARATION_BOUNDARIES": ("all",),
"SET_VALAREZO_SEPARATION_BOUNDARIES": ("all",),
"SET_CROSSFLOW_SEPARATION_BOUNDARIES": ("all",),
"SET_VORTICITY_DRAG_BOUNDARIES": ("all",),
"DELETE_SEPARATION": ("all",),
}
)
)
pyflightstream.post.settings_table.FLAG_IDS
module-attribute
¶
FLAG_IDS: Mapping[str, int] = MappingProxyType(
{
name: index
for index, name in enumerate(_FROZEN_ORDER, start=1)
}
)
pyflightstream.post.settings_table.LOSSY_KINDS
module-attribute
¶
LOSSY_KINDS: tuple[str, ...] = ('list', 'mapping')
pyflightstream.post.settings_table.PROVENANCE_CODES
module-attribute
¶
PROVENANCE_CODES: Mapping[str, int] = MappingProxyType(
{"explicit": 1, "default": 2, "unknown": 3}
)
pyflightstream.post.settings_table.TIDY_COLUMNS
module-attribute
¶
TIDY_COLUMNS: tuple[str, ...] = (
"codebook_version",
"run_index",
"flag_id",
"provenance_code",
"emitted",
"value_kind",
"value_num",
"value_code",
"value_count",
)
pyflightstream.post.settings_table.VALUE_KINDS
module-attribute
¶
VALUE_KINDS: Mapping[str, int] = MappingProxyType(
{
"bool": 1,
"int": 2,
"float": 3,
"enumerated": 4,
"list": 5,
"mapping": 6,
}
)
pyflightstream.post.settings_table.codebook
¶
codebook() -> dict[str, object]
Return the legend written beside every table.
The file has to be readable alone, so its legend travels with it rather than living only on the documentation page. The page is still the contract, and the test that compares the two is what keeps this dictionary from becoming a second opinion.
Returns:
| Type | Description |
|---|---|
dict
|
|
pyflightstream.post.settings_table.read_settings_table
¶
read_settings_table(path: str | Path) -> list[Row]
Read a numeric settings table, refusing another codebook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
A file written by :func: |
required |
Returns:
| Type | Description |
|---|---|
list of dict
|
The rows, with every cell that does not apply as None and every
other cell of the codebook's columns as a number (a key column that
|
Raises:
| Type | Description |
|---|---|
MalformedOutputError
|
If the file carries no |
pyflightstream.post.settings_table.settings_table
¶
settings_table(
setups: Sequence[SolverSetup],
*,
wide: bool = False,
fill: int | None = None,
fill_values: bool = False,
) -> list[Row]
Project solver-setup snapshots into an all-numeric table.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
setups
|
sequence of SolverSetup
|
One snapshot per run, in the order the runs are to be indexed.
|
required |
wide
|
(bool, keyword - only)
|
One row per run instead of one row per run and flag. Each flag
contributes |
False
|
fill
|
int
|
NUMERIC value written into a CODE column that does not apply, for a
tool that needs a number there rather than a token. 999 is the
conventional choice and is free by construction, because the code
columns are assigned densely from 1. Default None, which writes
:data: Use |
None
|
fill_values
|
(bool, keyword - only)
|
Ask for the VALUE columns to be filled too. Always refused, naming the flags whose legal range contains the fill value. |
False
|
Returns:
| Type | Description |
|---|---|
list of dict
|
Rows keyed by column label. Every cell is an |
Raises:
| Type | Description |
|---|---|
ProductError
|
If |
MalformedOutputError
|
If a flag holds a token the frozen codebook does not code, or a type this projection has no kind for. |
Examples:
>>> from pyflightstream.post.settings_table import FLAG_IDS, settings_table
>>> from pyflightstream.script import Script, helpers
>>> setup = helpers.solver_settings(Script(version="26.120"), velocity=30.0)
>>> rows = {row["flag_id"]: row for row in settings_table([setup])}
>>> rows[FLAG_IDS["SOLVER_SET_VELOCITY"]]["value_num"]
30.0
>>> rows[FLAG_IDS["SOLVER_SET_AOA"]]["provenance_code"]
3
pyflightstream.post.settings_table.write_settings_table
¶
write_settings_table(
path: str | Path,
setups: Sequence[SolverSetup],
*,
wide: bool = False,
fill: int | None = None,
fill_values: bool = False,
overwrite: bool = False,
legend: str | Path | None = None,
keys: Sequence[Mapping[str, str]] | None = None,
) -> tuple[Path, Path]
Write the numeric table and its legend, and return the pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Destination CSV file. The legend is written beside it as
|
required |
setups
|
sequence of SolverSetup
|
One snapshot per run. |
required |
wide
|
see :func:`settings_table`
|
Passed through unchanged. |
False
|
fill
|
see :func:`settings_table`
|
Passed through unchanged. |
False
|
fill_values
|
see :func:`settings_table`
|
Passed through unchanged. |
False
|
overwrite
|
(bool, keyword - only)
|
Replace existing files. Default False, the same refusal the flow-visualization writers take. |
False
|
legend
|
str or Path
|
Where the legend is written, when it is not |
None
|
keys
|
sequence of mapping
|
One mapping of text cells per run, in the order of |
None
|
Returns:
| Type | Description |
|---|---|
tuple of pathlib.Path
|
|
Raises:
| Type | Description |
|---|---|
OutputExistsError
|
If either file exists and |
ProductError
|
As :func: |
MalformedOutputError
|
As :func: |