pyflightstream.cases.windows (stable)¶
Generated from the docstrings at build time: every one of the 17 names in the __all__ of pyflightstream.cases.windows has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
The ONE resolver of the averaging window, for the plan and for the post stage.
The window of an unsteady point is a MATRIX input: LAST_REVS_AVG on a row
that turns a rotor, LAST_ITERS_AVG on one that does not. It is stated once
and every unsteady product of the point is cut from it: the polar, the time
average, the per-blade table, the phase-locked passages, the rotor table.
The plan and post stage use the same window resolver. A post-processing choice does not require a solver rerun; all reductions must derive their windows consistently from the selected inputs.
It lives in cases because post may import cases and never the
reverse. It reads a mapping of row variables and a recorded plan and nothing
else: no case, no script, no solver.
A WINDOW IS A COUNT OF TURNS, NOT A RANGE OF STEPS. One revolution of a lifter
and one of a pusher are different numbers of solver steps, so the same
LAST_REVS_AVG gives each rotor its own span (FR-68). The ROW's span, which
the polar and the time average use, is counted on the row's clock rotor.
Advanced¶
pyflightstream.cases.windows.ExportThresholdRecord
¶
Bases: TypedDict
The clock and threshold stored under a run record's export_window key.
pyflightstream.cases.windows.RESTART_STEP_OFFSET_VARIABLE
module-attribute
¶
RESTART_STEP_OFFSET_VARIABLE = 'RESTART_STEP_OFFSET'
pyflightstream.cases.windows.StoppedStepRecord
¶
Bases: TypedDict
The local march step and elapsed time where a march stopped.
Add export_window.step_offset to recover the whole row's absolute step.
pyflightstream.cases.windows.averaging_span
¶
averaging_span(
variables: Mapping[str, object],
*,
last_step: int,
per_revolution: float | None,
) -> tuple[int, int] | None
Return the inclusive, 1-based window (first, last) ending at last_step.
Longer than the run is the whole run, never a step before the first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
mapping
|
The matrix row's variables, keyed by their upper-case names. |
required |
last_step
|
int
|
The last solver step of the run, 1-based. The window ends here. |
required |
per_revolution
|
float or None
|
Solver steps in one revolution of the clock rotor; None where there is none. |
required |
Returns:
| Type | Description |
|---|---|
tuple of (int, int) or None
|
The inclusive 1-based |
Examples:
>>> averaging_span({"LAST_REVS_AVG": "0.5"}, last_step=1000, per_revolution=250.0)
(876, 1000)
>>> averaging_span({"LAST_ITERS_AVG": "100"}, last_step=1000, per_revolution=None)
(901, 1000)
pyflightstream.cases.windows.averaging_steps
¶
averaging_steps(
variables: Mapping[str, object],
*,
per_revolution: float | None,
) -> int | None
Return the window's LENGTH in solver steps on a clock of per_revolution.
A count of iterations is already in steps and is the same for every rotor. A count of revolutions has no length without a clock, and resolves to None rather than to a guess.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
mapping
|
The matrix row's variables, keyed by their upper-case names. |
required |
per_revolution
|
float or None
|
Solver steps in one revolution of the rotor whose clock counts the window. None where the row has no clock. |
required |
Returns:
| Type | Description |
|---|---|
int or None
|
The window's length in steps, at least 1, or None where the row states no key or a count of revolutions meets no clock. A fractional number of steps is rounded to the nearest whole step, halves to the even one (2.5 steps is 2, 3.5 is 4). Invalid values and windows shorter than one step raise CampaignConfigError. |
Raises:
| Type | Description |
|---|---|
CampaignConfigError
|
If the stated averaging window is nonnumeric, nonfinite or shorter than one step. The
run length is unknown here, so a window longer than the run is clipped to it later, by
:func: |
pyflightstream.cases.windows.march_end
¶
march_end(
plan: Mapping[str, object] | None, *, last_step: int
) -> dict[str, object] | None
Return the recorded plan with every window moved to end at last_step.
A CONTINUATION RECORDS THE ROW'S CLOCK (FR-96): its plan states the
row's time_iterations, which is the last step of the run it continues
and not of the march it extends. Every window here is the LAST part of the
run (LAST_REVS_AVG, LAST_ITERS_AVG, the last revolution, the passages
and the phase-locked revolutions that end with them), so each is moved by
the same number of steps, keeping its length, to end at the last step of
the whole march; the plan's time_iterations becomes that step, so
:func:replan and :func:regate cut from it too. A window that would
begin before step 1 begins at step 1. The record is never rewritten: the
result is a new mapping.
Returns None where there is nothing to move: no plan, no last step in it, or one already ending there.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan
|
mapping or None
|
The |
required |
last_step
|
int
|
The last step of the whole march, 1-based. |
required |
Returns:
| Type | Description |
|---|---|
dict or None
|
A new plan with every window moved to end at |
Examples:
>>> plan = {"time_iterations": 720, "time_average": {"windows": [[596, 720]]}}
>>> march_end(plan, last_step=1220)["time_average"]["windows"]
[[1096, 1220]]
>>> march_end(plan, last_step=720) is None
True
pyflightstream.cases.windows.passages
¶
passages(
window: tuple[int, int], period: float
) -> list[tuple[int, int]]
Cut an inclusive step window into successive passages of period steps.
From the first step forward, a trailing partial passage dropped rather than
averaged against a shorter one. A passage counts as whole when its length,
rounded to the step the solver takes, fits the window: the rule
:func:whole_passage_refusals judges the window by, so a window the gate
accepts is cut into the passages it was accepted for (LAST_REVS_AVG =
0.166667 of 500 steps over six blades is 83 steps, one passage of 83.33).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
window
|
tuple of (int, int)
|
The inclusive |
required |
period
|
float
|
Physical steps in one passage. Fractional periods retain their cumulative boundaries; a value below 1 gives no passage. |
required |
Returns:
| Type | Description |
|---|---|
list of tuple of (int, int)
|
The inclusive |
pyflightstream.cases.windows.phase_locked_entry
¶
phase_locked_entry(
gate: object,
*,
last_step: float,
per_revolution: float,
who: str,
) -> dict[str, object]
Return the plan entry of the phase-locked reduction a [phase_locked] table asks for.
gate is the table: min_revolutions, last_revolutions_avg and the
comparison itself, generated_for(revolutions=...), which is AT LEAST.
What is compared is what the row TURNS, last_step / per_revolution of
THAT rotor, and never the length of an exported window.
A run that turned fewer is a SKIP carrying both numbers, and only of this
reduction. One that turned enough gets ONE window, the last
last_revolutions_avg revolutions of that rotor ending at the run's last
step, and shape :data:AZIMUTHAL: the products stage averages ACROSS
those revolutions at each azimuth and writes one row per azimuthal position.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gate
|
object
|
The |
required |
last_step
|
float
|
The last solver step of the run. |
required |
per_revolution
|
float
|
Solver steps in one revolution of this rotor. |
required |
who
|
str
|
The rotor's name, written into the entry's provenance text. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Either |
Examples:
>>> class Gate:
... min_revolutions, last_revolutions_avg = 4.0, 2.0
... def generated_for(self, *, revolutions):
... return revolutions >= self.min_revolutions
>>> entry = phase_locked_entry(Gate(), last_step=1000, per_revolution=250.0, who="PUSHER")
>>> entry["windows"], entry["revolutions"], entry["shape"]
([[501, 1000]], 2.0, 'azimuthal')
>>> sorted(phase_locked_entry(Gate(), last_step=999, per_revolution=250.0, who="PUSHER"))
['min_revolutions', 'revolutions_turned', 'skipped']
pyflightstream.cases.windows.phase_locked_plan
¶
phase_locked_plan(
gate: object | None,
*,
last_step: float,
per_revolution: float,
who: str,
span: tuple[int, int],
period: float,
) -> dict[str, object]
Plan one rotor's phase-locked reduction, including its named skip.
A declared table gates on total revolutions and selects an azimuthal mean. Without a table, the row's window supplies complete blade passages. Other reductions are independent of this decision.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
gate
|
object or None
|
The |
required |
last_step
|
float
|
The last solver step of the run. |
required |
per_revolution
|
float
|
Solver steps in one revolution of this rotor. |
required |
who
|
str
|
The rotor's name, written into the entry's provenance text. |
required |
span
|
tuple of (int, int)
|
The row's inclusive averaging window, cut into passages when there is no table. |
required |
period
|
float
|
Steps in one blade passage of this rotor. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
The plan entry: |
pyflightstream.cases.windows.regate
¶
regate(
plan: Mapping[str, object] | None, gate: object | None
) -> dict[str, object] | None
Return plan with its phase-locked reduction as the pproc asks for it TODAY.
The [phase_locked] table is a post-processing choice, so it is read again
when the products are composed and needs no solver re-run: a table added,
edited or removed after the campaign ran moves this one reduction. The
record is never rewritten; the result is a new mapping.
With a table, every block that has a clock (steps_per_revolution and the
plan's time_iterations) and a reduction to move gets
:func:phase_locked_entry. A block skipped for a reason no table cures, no
rotor speed or no blade count, keeps its skip. Without a table, a block
recorded under one goes back to the passages of the point's averaging
window; any other block is left exactly as recorded.
Returns None where there is nothing to move, so a caller keeps its plan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan
|
mapping or None
|
The |
required |
gate
|
object or None
|
The current |
required |
Returns:
| Type | Description |
|---|---|
dict or None
|
A new plan with the phase-locked reduction moved, or None where nothing moves. |
pyflightstream.cases.windows.replan
¶
replan(
plan: Mapping[str, object] | None,
variables: Mapping[str, object] | None,
*,
gate: object = _KEEP_GATE,
) -> dict[str, object] | None
Return the recorded plan with EVERY window re-cut from what the row states NOW.
The matrix wins the record, and the record is never rewritten: the result is
a new mapping, and plan is left exactly as it was handed in.
Returns None, so the caller keeps the recorded plan, where the row states no usable key, the plan carries no last step, or a count of revolutions meets a plan with no clock. A reduction the run recorded as skipped for a reason the window cannot cure (no blade count, no rotor speed) stays skipped.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
plan
|
mapping or None
|
The |
required |
variables
|
mapping or None
|
The matrix row's variables as they stand today. |
required |
gate
|
object or None
|
The current phase-locked table. Explicit None removes the table; omitted, a recorded gate or azimuthal window is preserved. Supplying the table re-cuts and gates each rotor in one operation. |
_KEEP_GATE
|
Returns:
| Type | Description |
|---|---|
dict or None
|
A new plan with every window re-cut, or None where the recorded plan stands. |
pyflightstream.cases.windows.stated_key
¶
stated_key(
variables: Mapping[str, object],
) -> tuple[str, float] | None
Return (key, value) of the ONE averaging key the row states, or None.
None where the row states neither key (including the unstated cell -).
An invalid value or both keys raise CampaignConfigError: picking a fallback
would hide a contradictory or invalid window.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
variables
|
mapping
|
The matrix row's variables, keyed by their upper-case names. |
required |
Returns:
| Type | Description |
|---|---|
tuple of (str, float) or None
|
The key ( |
Raises:
| Type | Description |
|---|---|
CampaignConfigError
|
If declarations use conflicting aliases for the same window. |
pyflightstream.cases.windows.surface_average_window
¶
surface_average_window(
*,
last_step: int,
per_revolution: float | None = None,
last_revs: float | None = None,
last_iters: int | None = None,
) -> SurfaceAverageWindow
Resolve the window the package averages the per-step surface exports over (G25).
The bounds of :func:surface_averaging_window, on the clock of
LAST_REVS_AVG: inclusive, 1-based time steps ending at the run's last
step, clipped at step 1. The package counts these steps itself and averages
the exports stamped with them, so the window carries no verification.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
last_step
|
int
|
The last solver step of the run, 1-based. |
required |
per_revolution
|
float
|
Solver steps in one revolution of the rotor clock. Required with
|
None
|
last_revs
|
float
|
The window as a count of revolutions ( |
None
|
last_iters
|
int
|
The window as a count of solver steps ( |
None
|
Returns:
| Type | Description |
|---|---|
SurfaceAverageWindow
|
The inclusive |
Raises:
| Type | Description |
|---|---|
CampaignConfigError
|
When both or neither of |
Examples:
>>> surface_average_window(last_step=144, last_revs=1.5, per_revolution=36)["iterations"]
[91, 144]
>>> "verification" in surface_average_window(last_step=144, last_iters=54)
False
pyflightstream.cases.windows.surface_averaging_window
¶
surface_averaging_window(
*,
last_step: int,
per_revolution: float | None = None,
last_revs: float | None = None,
last_iters: int | None = None,
) -> SurfaceAveragingWindow
Resolve the solver surface window using the matrix averaging clock.
Bounds are inclusive time steps: FSM-26.122 p.353 names each bound an unsteady time iteration without distinguishing time steps from inner iterations, which awaits licensed verification. This is the sole conversion to the command's bounds.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
last_step
|
int
|
The last solver step of the run, 1-based. |
required |
per_revolution
|
float
|
Solver steps in one revolution of the rotor clock. Required with
|
None
|
last_revs
|
float
|
The window as a count of revolutions ( |
None
|
last_iters
|
int
|
The window as a count of solver steps ( |
None
|
Returns:
| Type | Description |
|---|---|
SurfaceAveragingWindow
|
The inclusive |
Raises:
| Type | Description |
|---|---|
CampaignConfigError
|
When both or neither of |
Examples:
>>> surface_averaging_window(last_step=144, last_iters=54)["iterations"]
[91, 144]
>>> surface_averaging_window(last_step=144, last_revs=1.5, per_revolution=36)["iterations"]
[91, 144]
pyflightstream.cases.windows.whole_passage_refusals
¶
whole_passage_refusals(
pol: str,
variables: Mapping[str, object],
rotors: Sequence[tuple[str, int, int, float]],
) -> list[str]
Judge a row's window against whole blade passages of each rotor (PFS-2235, FR-3795).
A passage is steps_per_revolution / blades steps. The window of L steps spans
k = L / passage passages, and is valid when round(k) >= 1 and
round(round(k) * passage) == L, so a fractional passage is judged on the steps the
solver can take. A row stating no window key judges nothing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pol
|
str
|
The row's simulation id. |
required |
variables
|
mapping
|
The row's variables, keyed by their upper-case names. |
required |
rotors
|
sequence of tuple
|
Each rotor the row turns with a known clock: its alias, id, blade count and steps per revolution. |
required |
Returns:
| Type | Description |
|---|---|
list of str
|
One refusal sentence per failing rotor, naming the window, the passages it spans, the rotor and the nearest valid window; empty where every rotor passes. |