Skip to content

pyflightstream.cases.naming (provisional)

Generated from the docstrings at build time: every one of the 11 names in the __all__ of pyflightstream.cases.naming has an entry below. The names a guide or an example uses come first; the others follow under Advanced.

The names of a point and of a sweep: the identity a run carries.

Pipeline role: turns a case's flight condition into the name that ends its run_id, names its datapoint folder and stems every file it writes (:func:point_name, :func:sweep_name, :func:name_field and the code table :data:POINT_NAME_FIELDS), and owns the one-sweep-per-case rule (:func:multiplied_sweep).

The package root re-exports these functions (AD-16). They read a case and a sweep through the attributes they use, stated as two protocols, so this module never imports the package root that defines :class:~pyflightstream.cases.SimCase and :class:~pyflightstream.cases.SweepAxis.

Advanced

pyflightstream.cases.naming.NameField dataclass

NameField(
    code: str,
    scale: float,
    width: int,
    signed: bool,
    magnitude: bool = False,
)

How one flight-condition variable is written in a point name.

code then the value times scale, rounded, zero-padded to width characters; a signed field counts its sign in the width.

magnitude writes the field WITHOUT a sign and refuses a negative value rather than dropping its sign. It lives here, beside signed, because it is the same kind of fact about the same field, and a reader adding a variable reads this dataclass and the table below. Held in a second table keyed by the same keys, it had to be remembered at each call site and was remembered at one of three: the sweep name and the duplicate-identity guard were writing the sign the point name had just dropped (the architect lens, FIX-0220).

pyflightstream.cases.naming.POINT_AXIS_KEYS module-attribute

POINT_AXIS_KEYS: dict[str, str] = {
    "MACH": "MACH",
    "TASmps": "TASmps",
    "REmi": "REmi",
    "ALTFT": "ALTFT",
    "dISA": "dISA",
    "RHOkgm3": "RHOkgm3",
    "MUPas": "MUPas",
    "ASMPS": "ASMPS",
    "TK": "TK",
    "PPA": "PPA",
    "alpha": "ALPHA",
    "beta": "BETA",
    "advance_ratio": "ADVANCE_RATIO",
    "RPM": "RPM",
    "roll_rate": "roll_rate",
    "pitch_rate": "pitch_rate",
    "yaw_rate": "yaw_rate",
}

pyflightstream.cases.naming.POINT_NAME_FIELDS module-attribute

POINT_NAME_FIELDS: dict[str, NameField] = {
    "MACH": NameField("M", 1000.0, 3, False),
    "TASmps": NameField("V", 10.0, 4, False),
    "REmi": NameField("RE", 100.0, 3, False),
    "ALTFT": NameField("ALT", 1.0, 5, False),
    "dISA": NameField("DT", 10.0, 4, True),
    "RHOkgm3": NameField("RHO", 10000.0, 5, False),
    "MUPas": NameField("MU", 1000000000.0, 5, False),
    "ASMPS": NameField("A", 10.0, 4, False),
    "TK": NameField("T", 10.0, 4, False),
    "PPA": NameField("PS", 1.0, 6, False),
    "ALPHA": NameField("AL", 10.0, 4, True),
    "BETA": NameField("BE", 10.0, 4, True),
    "ADVANCE_RATIO": NameField("J", 100.0, 4, True),
    "RPM": NameField("RPM", 1.0, 5, False, magnitude=True),
    "roll_rate": NameField("P", 10.0, 4, True),
    "pitch_rate": NameField("Q", 10.0, 4, True),
    "yaw_rate": NameField("R", 10.0, 4, True),
}

pyflightstream.cases.naming.ROTATION_OFFSET_KEY module-attribute

ROTATION_OFFSET_KEY = 'angle_deg'

pyflightstream.cases.naming.ROTATION_SWEEP_KEY module-attribute

ROTATION_SWEEP_KEY = 'angle_sweep_deg'

pyflightstream.cases.naming.SWEEP_NAME_VALUE module-attribute

SWEEP_NAME_VALUE = '+sweep'

pyflightstream.cases.naming.geometric_sweep_values

geometric_sweep_values(
    variables: Mapping[str, object],
) -> list[str]

Return the angles a case's geometric sweep variable declares.

The variable is :data:ROTATION_SWEEP_KEY, and its values are comma separated because a case variable holds one scalar or one string and never a list. Values are returned as written, in degrees, without being converted: this function counts how many angles were asked for, and whether each is a number is the recipe's or the workflow's refusal to make, naming the key the user typed.

The key is matched CASE-INSENSITIVELY. Its spelling is settled elsewhere, and a limit that fires only for one casing is a limit a user gets past by shouting.

EVERY matching key is read and their values are POOLED, rather than the first match winning. Two keys differing only in case are two distinct entries in a variables mapping, so a first-match rule let a one-angle angle_sweep_deg stand in front of a three-angle ANGLE_SWEEP_DEG and carry the whole declaration past the limit. Pooling closes that and is right on its own terms besides: two keys naming one rotation is an ambiguity, and counting both is what makes the ambiguous case meet a refusal rather than a coin toss.

Parameters:

Name Type Description Default
variables mapping of str to object

A case's free variables, as :attr:SimCase.variables holds them or as the run matrix reader parsed its VAR_NAMES_VALUES cell.

required

Returns:

Type Description
list of str

The declared angles in degrees, in the order written, pooled across every key that spells :data:ROTATION_SWEEP_KEY in any casing. Empty when no such key is present or all of them hold nothing but separators, which are the same fact here: no geometric sweep was asked for.

Examples:

>>> geometric_sweep_values({"angle_sweep_deg": "0.0,5.0,10.0"})
['0.0', '5.0', '10.0']
>>> geometric_sweep_values({"angle_sweep_deg": "5.0", "ANGLE_SWEEP_DEG": "7.5"})
['5.0', '7.5']
>>> geometric_sweep_values({"CONFIG": "NSX"})
[]

pyflightstream.cases.naming.multiplied_sweep

multiplied_sweep(
    sweep: _NamedSweep, variables: Mapping[str, object]
) -> list[str]

Return the geometric angles that would MULTIPLY with the sweep.

This is the single owner of the one-sweep-per-case limit, called from both places a case can be declared: the campaign.toml model (:class:SimCase) and the run matrix reader (:func:pyflightstream.cases.matrix.read_matrix). Two owners would be two rules, and the drift would be discovered by a user whose hand-written campaign ran what the matrix refuses.

THE DECISION IT ENFORCES (design note DD-28): a geometric sweep does NOT multiply with the aerodynamic one. A case carries one aerodynamic sweep and at most one FIXED geometric offset (:data:ROTATION_OFFSET_KEY); a study OF the geometry is one case per geometry, each with its own sim_id. Multiplication was rejected on identity rather than on taste. A run is identified by :func:point_name, whose aerodynamic sweep axes are :data:_TAG_PREFIXES, and none of the three is geometric, so the three angles of a rotation sweep crossed with an eleven point alpha sweep are thirty three runs wearing eleven identities: each group of three renders one tag, one run_id and one set of output file names. That is exactly the collision :meth:SweepAxis._points_have_distinct_tags already refuses within one axis, and it is not made safe by arriving from a second axis. The same collapse reaches the evidence: :class:pyflightstream.qa.cost.PointKey keys a cost row by sim_id and the recorded point, so three geometries under one sim_id average into one cell and the geometry that got slower cannot be seen.

Parameters:

Name Type Description Default
sweep SweepAxis

The case's aerodynamic sweep.

required
variables mapping of str to object

The case's free variables.

required

Returns:

Type Description
list of str

The geometric angles in degrees when BOTH sweeps carry two or more values, which is the multiplying shape. Empty otherwise, so a fixed offset beside a sweep, a rotation sweep on a single point case, and a case with no geometric variable at all all pass: each of those is one sweep, and one sweep is what a case may have.

Examples:

>>> from pyflightstream.cases import SweepAxis
>>> sweep = SweepAxis(type="alpha", values=[0.0, 2.0, 4.0])
>>> multiplied_sweep(sweep, {"angle_sweep_deg": "0.0,5.0"})
['0.0', '5.0']
>>> multiplied_sweep(sweep, {"angle_deg": "5.0"})
[]

pyflightstream.cases.naming.name_field

name_field(key: str, value: float) -> str

Write one variable the way a point name carries it, for example M144 or AL-020.

Parameters:

Name Type Description Default
key str

The FLIGHT_CONDITION key, a key of :data:POINT_NAME_FIELDS.

required
value float

The variable's value on the point.

required

Returns:

Type Description
str

The field: its code, then the scaled value, zero-padded to its width.

Raises:

Type Description
CampaignConfigError

If the key has no code, the value is not finite, a magnitude variable is negative, or an unsigned variable is negative.

Examples:

>>> name_field("MACH", 0.144)
'M144'
>>> name_field("ALPHA", -2.0)
'AL-020'

pyflightstream.cases.naming.point_name

point_name(
    case: _NamedCase, point: Mapping[str, float]
) -> str

Return the name of one point of a case: its identity, folder and file stem.

Every variable the row's FLIGHT_CONDITION declares, in the order the row declares them, written as :data:POINT_NAME_FIELDS says, with the point's own value for a swept one: M144RE438AL+000BE+000J+080. A case with no cell (authored in Python) is named by its Mach number when it has one and then by the axes of its point. It ends the run_id, names the datapoint folder DP-<name> and is the stem of every file P<POL>-<name>.

Parameters:

Name Type Description Default
case SimCase

The case the point belongs to.

required
point mapping of str to float

The point's coordinates, as :meth:SweepAxis.points yields them.

required

Returns:

Type Description
str

The point name, every field of :func:name_field in the row's order.

Raises:

Type Description
CampaignConfigError

If a declared variable has no value on this point or no code.

Examples:

>>> from pyflightstream.cases import SimCase, SweepAxis
>>> case = SimCase(
...     sim_id="7002",
...     aircraft="Wing",
...     recipe="steady",
...     sweep=SweepAxis(type="alpha", values=[0.0, 2.0]),
...     mach=0.144,
... )
>>> point_name(case, {"alpha": 2.0})
'M144AL+020'

pyflightstream.cases.naming.sweep_name

sweep_name(case: _NamedCase) -> str

Return the name of a case's whole sweep, each swept field written <code>+sweep.

Parameters:

Name Type Description Default
case SimCase

The case whose sweep is named.

required

Returns:

Type Description
str

The name of the case's first point with every swept field written :data:SWEEP_NAME_VALUE in place of its value, for example M144AL+sweep.