Skip to content

pyflightstream.post.unsteady (stable)

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

Per-timestep field frames, read back as an ordered series.

Pipeline role: the entry point of unsteady post-processing. An unsteady run asked to animate (UNSTEADY_SOLVER_ANIMATION, FSM-26.120 pp.347-348) writes one file every so many solver time steps into a folder, and this module reads that folder back as a series a reduction can be taken over. The reduction itself is pure and lives here too (:func:blade_passage_average); WRITING one is :mod:pyflightstream.post.reductions, deliberately a different module, because the file rule that reduction writing has to obey is a rule about destinations and this module has none.

ORDER COMES FROM EVIDENCE, NEVER FROM A FILE NAME. Nothing in this repository records how the solver names its animation frames: the command is documented on every registered build and probed on none (reports/compat/CMP-26120_2026-08-09_identity.md). Sorting the names would therefore be this library inventing a vendor convention, and an animation read in the wrong order yields a plausible average of the wrong thing, which is the failure nobody notices. So the reader takes the order from one of exactly two places, and REFUSES when it has neither:

  • the caller declares that the sequence handed over is already in solver order (order="given"), which is a fact the caller has and this module does not;
  • each frame carries its own solution time in its header, which the Tecplot ASCII zone record can (SOLUTIONTIME=), so the frames sort themselves.

The refusal names what would settle it: one licensed run of the export and a committed probe report recording how the frames are named.

FREQUENCY IS COUNTED IN SOLVER STEPS, which is what the command's frequency keyword means, so the step axis of a series read in a declared order is one plus the frame index times frequency (the first frame is solver step 1). It is not read out of the file and is not guessed: a caller that passes the frequency it asked the solver for gets solver steps, and one that does not gets frame numbers, which the series says of itself.

THE TWO FRAME FORMATS are the two the command's own entry lists as data filetypes, TECPLOT_DATA and PARAVIEW_VTK. They are read here in the shapes :mod:pyflightstream.post.writers writes, which is the only form of either this repository has evidence for.

Advanced

pyflightstream.post.unsteady.FrameAverage dataclass

FrameAverage(
    window: tuple[int, int],
    n_frames: int,
    points: ndarray,
    fields: dict[str, ndarray],
    sources: tuple[Path, ...],
    source_window: tuple[int, int] | None = None,
)

A reduction of a :class:TimestepSeries over one window.

Attributes:

Name Type Description
window tuple of int

Inclusive (first_step, last_step) in solver steps, as declared by the caller. Recorded so the written file can say what was averaged.

n_frames int

How many frames fell inside the window and were averaged. A window holding none is refused rather than averaged, so this is never zero.

points ndarray

Sample positions, shape (n_points, 3), unchanged from the series.

fields dict of str to numpy.ndarray

Per-sample mean of each quantity over the window, shape (n_points,) for a scalar and (n_points, 3) for a vector, in the series' own units.

sources tuple of pathlib.Path

The frame files behind the series, carried through so the writing seam can refuse to overwrite one of them.

source_window tuple of int or None

First and last source steps actually averaged, which can lie inside the declared window when exports are sparse. None for manually constructed averages without that evidence.

pyflightstream.post.unsteady.TimestepSeries dataclass

TimestepSeries(
    steps: ndarray,
    times_s: ndarray | None,
    points: ndarray,
    fields: dict[str, ndarray],
    sources: tuple[Path, ...],
    order_evidence: str = "given",
)

One field, at every exported time step of one unsteady run.

Attributes:

Name Type Description
steps ndarray

Solver step index of each frame, shape (n_frames,), dimensionless. One plus the frame index times the frequency the caller passed: the export's frequency is counted in solver steps and the first frame is solver step 1 (26.124 wrote frames 1, 3, 5 at frequency 2; L4 X-F-0363).

times_s ndarray or None

Solution time of each frame in seconds, when the frames carried one; None when the order came from the caller instead.

points ndarray

Sample positions, shape (n_points, 3), in the reference frame of the export and in simulation length units. Taken from the first frame. The reader checks that every later frame holds the same NUMBER of samples and that sample k sits at the same coordinate, within _POINT_RTOL of the extent of the first frame, so a reduction over the series averages one place over time. A frame that moves its points is refused, not averaged.

fields dict of str to numpy.ndarray

One entry per exported quantity, shape (n_frames, n_points) for a scalar and (n_frames, n_points, 3) for a vector. Units are whatever the solver exported; nothing here rescales.

sources tuple of pathlib.Path

The frame files, in the order they were read. Carried so a reduction taken from this series can be refused a destination equal to one of them.

order_evidence str

How the order was established: given (the caller declared it) or solution time (each frame's own header). There is no third value, and in particular no value meaning "the file names looked sorted".

n_frames property

n_frames: int

Number of exported frames in the series.

pyflightstream.post.unsteady.blade_one_azimuth

blade_one_azimuth(
    step: float,
    *,
    datum_deg: float,
    sense: float,
    steps_per_revolution: float,
) -> float

Return where blade one of a rotor is at step, in degrees, wrapped to one turn.

The one convention of every table that states an azimuth: (datum + sense * step * 360 / steps_per_revolution) mod 360, the datum being blade one's azimuth at step zero and sense the sign of the rotor's speed, all of THAT rotor.

Parameters:

Name Type Description Default
step float

The time step.

required
datum_deg float

Blade one's azimuth at step zero, in degrees.

required
sense float

The sign of the rotor's speed.

required
steps_per_revolution float

The rotor's clock, in steps per revolution.

required

Returns:

Type Description
float

The azimuth in degrees, wrapped to one turn.

Raises:

Type Description
ProductError

If the step, the datum and the steps per revolution do not state a clock.

Examples:

>>> blade_one_azimuth(3, datum_deg=10.0, sense=-1.0, steps_per_revolution=8.0)
235.0

pyflightstream.post.unsteady.blade_passage_average

blade_passage_average(
    series: TimestepSeries,
    *,
    window: tuple[int, int],
    read_steps: set[int] | None = None,
) -> FrameAverage

Average a series over one declared window of solver steps.

The only implementation of this average in the package. A phase-locked reduction is this function applied once per passage, over the windows :func:passage_windows hands out, rather than a second averaging routine: two implementations of one average is how two published numbers come to disagree.

It is PURE. It reads no file and writes none, so nothing about it can enforce the rule that a reduction never overwrites what it came from; that rule lives at the writing seam, :func:pyflightstream.post.reductions.write_reduction.

Parameters:

Name Type Description Default
series TimestepSeries

The read-back frames.

required
window tuple of int, keyword-only

Inclusive (first_step, last_step) in solver steps. Declared by the caller rather than derived: a blade passage is a fact about the rotor, not about the export.

required
read_steps set of int or None

When supplied, collect the plotted steps used by this average.

None

Returns:

Type Description
FrameAverage

Per-sample means over the frames inside the window.

Raises:

Type Description
ProductError

If the window holds no frame, or is given backwards. An average of nothing is still a number, which is exactly why it is refused rather than returned as a NaN.

pyflightstream.post.unsteady.passage_windows

passage_windows(
    series: TimestepSeries, *, period_steps: int
) -> list[tuple[int, int]]

Cut a series into successive passages of a declared period.

The composition point for a phase-locked reduction: each window goes through :func:blade_passage_average, so the release holds one implementation of the average and this function holds only the arithmetic of where a passage starts.

Parameters:

Name Type Description Default
series TimestepSeries

The read-back frames.

required
period_steps (int, keyword - only)

Solver steps in one blade passage. For a rotor this is the caller's own conversion from RPM and blade count into steps; the library does not make it, because the time step is a fact of the run and not of the export.

required

Returns:

Type Description
list of tuple of int

Inclusive (first_step, last_step) windows covering the series, dropping a trailing partial passage rather than averaging it against a shorter one.

Raises:

Type Description
ProductError

If period_steps is not positive, or is longer than the series; or if the frames are not exported at one stride that divides period_steps, because the passages would then hold their equally weighted frames at different phases.

MalformedOutputError

If the frames' steps do not advance.

pyflightstream.post.unsteady.phase_locked_rows

phase_locked_rows(
    series: TimestepSeries,
    columns: Sequence[str],
    *,
    last_step: int,
    revolutions: float,
    steps_per_revolution: float,
    blade1_azimuth_deg: float,
    sense: float = 1.0,
    blades: int = 0,
    blade_families: Sequence[str] = (),
    read_steps: set[int] | None = None,
) -> list[dict[str, object]]

Return the mean AT EACH AZIMUTH across the last revolutions turns, a row per azimuth.

THIS IS NOT A WINDOW AVERAGE, and that is the whole of it. A window average (:func:blade_passage_average) runs ALONG the history; this one runs ACROSS it: the sample at one azimuthal position is taken from each of the last revolutions revolutions, and those samples are averaged. With three revolutions every azimuth has three datapoints in its mean.

THE ROWS are the azimuthal positions the rotor visits in its LAST revolution, one per solver step of it, sorted from 0 towards 360. AZIMUTH is where blade one is, by :func:blade_one_azimuth.

A COLUMN OF ONE BLADE IS TABULATED BY THAT BLADE'S OWN AZIMUTH. A plot is named <parameter>_<group> and a group cut per blade ends in the blade's family, so a column ending _<family> of a family in blade_families is sampled where THAT blade, which sits position * 360 / blades after blade one, is at the row's azimuth. Two blades then line up azimuth for azimuth. Every other column, a rotor's total or the aircraft's, is tabulated by blade one's azimuth.

BETWEEN TWO STEPS THE HISTORY IS READ LINEARLY. One revolution earlier is steps_per_revolution steps earlier, which is a whole step only when the revolution is a whole number of steps, and a blade's offset is a whole step only when that number divides by blades. Where both hold every sample is a row of the history and nothing is interpolated.

REVOLUTIONS is the FEWEST samples that entered the mean of any column of the row. The columns of blade one are sampled at the row's azimuth and those of the other blades a fraction of a revolution earlier, so at a fractional depth a shifted blade can hold one sample less than blade one; the row states the smaller count, never the larger. It is revolutions exactly when that is a whole number.

Parameters:

Name Type Description Default
series TimestepSeries

The plots history, read back.

required
columns sequence of str

The plotted columns to reduce, in order; the clock is the caller's to leave out.

required
last_step int

The step the last revolution ends at.

required
revolutions float

How many of the last revolutions enter each mean; at least one.

required
steps_per_revolution float

Solver steps in one revolution of THIS rotor.

required
blade1_azimuth_deg float

Blade one's azimuth at step zero, and the sign of the rotor's speed.

required
sense float

Blade one's azimuth at step zero, and the sign of the rotor's speed.

required
blades int

The rotor's blade count, which spaces the blades.

0
blade_families sequence of str

The blade families in the rotor's own order, blade one first.

()
read_steps set of int or None

Collect the plotted steps contributing to the interpolation. Every nonzero interpolation weight counts, without a tolerance cutoff.

None

Returns:

Type Description
list of dict of str to object

One row per azimuth of the last revolution, with AZIMUTH, REVOLUTIONS and the mean of each column.

Raises:

Type Description
ProductError

If the depth is under one revolution, the clock is not positive, a requested column is not in series.fields, or the history does not cover the revolutions asked for. Could-not-measure is never a pass.

Examples:

Two revolutions of four steps; the mean of steps 1 and 5, 2 and 6, and so on.

>>> import numpy as np
>>> history = TimestepSeries(
...     steps=np.arange(1, 9), times_s=None, points=np.zeros((1, 3)),
...     fields={"CL": np.array([1.0, 2.0, 4.0, 8.0, 3.0, 6.0, 0.0, 0.0])[:, None]},
...     sources=(),
... )
>>> rows = phase_locked_rows(
...     history, ["CL"], last_step=8, revolutions=2, steps_per_revolution=4.0,
...     blade1_azimuth_deg=0.0,
... )
>>> [(row["AZIMUTH"], row["CL"]) for row in rows]
[(0.0, 4.0), (90.0, 2.0), (180.0, 4.0), (270.0, 2.0)]

pyflightstream.post.unsteady.read_timestep_series

read_timestep_series(
    frames: Sequence[str | Path],
    *,
    order: str | None = None,
    frequency: int = 1,
) -> TimestepSeries

Read exported frames back as one ordered series.

This reader supports stationary sample coordinates only. A moving point keeps its named refusal: moving-grid series are a new capability outside 0.44.0 (RB5-30), not coordinates silently borrowed from the first frame.

Parameters:

Name Type Description Default
frames sequence of str or pathlib.Path

The exported frame files. They may be handed over in any order when each carries its own solution time; when they do not, the sequence is the order and order="given" says so.

required
order str

"given" to declare that frames is already in solver order. Omitted (the default) means the order is read from each frame's own header, and the call is REFUSED when no frame carries one. There is deliberately no option that sorts file names.

None
frequency int

Solver time steps between exported frames, the frequency keyword the run passed to UNSTEADY_SOLVER_ANIMATION. Dimensionless step count, a positive integer (a bool, a float or a value below 1 is refused); the step axis is 1 plus the frame index times this, because the first frame is solver step 1. Default 1, which yields steps 1, 2, 3 and so on.

1

Returns:

Type Description
TimestepSeries

The series, with the order evidence recorded on it.

Raises:

Type Description
ProductError

If order is not "given" or None, or frequency is not a positive integer. Both are mistakes of the call and not malformed solver output.

MalformedOutputError

If no order can be established; if a frame is in neither supported shape; if a frame's variables or sample count disagree with the first frame's, or a sample sits at another coordinate (beyond _POINT_RTOL), because a series is one quantity over time at one set of places or it is not a series; or if the frames carry solution times and two of them are equal or the spacing is not uniform within a relative tolerance of _TIME_SPACING_RTOL, because the step axis is frame index times frequency and a missing or repeated frame would shift every later step without a word; or if a solution time or a sample coordinate is NaN or infinite, because it has no place in an order or in space, or a VTK POINTS record states no count.

Examples:

Frames written by this package's own writers, read back in the order they were handed over:

>>> import numpy as np, pathlib, tempfile
>>> from pyflightstream.post import OutputProvenance, read_timestep_series
>>> from pyflightstream.post import write_tecplot_points
>>> from pyflightstream.script import Script, helpers
>>> setup = helpers.solver_settings(Script(version="26.120"), velocity=30.0)
>>> record = OutputProvenance(run_id="rotor/sim_1/a+00.0", setup=setup)
>>> folder = pathlib.Path(tempfile.mkdtemp())
>>> points = np.array([[0.0, 0.0, 0.0], [1.0, 0.0, 0.0]])
>>> written = [
...     write_tecplot_points(
...         folder / f"frame_{i}.dat", points, {"cp": np.array([v, v])},
...         provenance=record,
...     )[0]
...     for i, v in enumerate([1.0, 2.0, 3.0])
... ]
>>> series = read_timestep_series(written, order="given", frequency=10)
>>> series.steps.tolist()
[1, 11, 21]
>>> series.fields["cp"][:, 0].tolist()
[1.0, 2.0, 3.0]

pyflightstream.post.unsteady.revolution_drift_warnings

revolution_drift_warnings(
    previous: Mapping[str, float],
    current: Mapping[str, float],
    shown: Mapping[str, str],
    *,
    limit_pct: float,
) -> list[str]

Judge the last revolution of each force and moment column against its SCALE (FR-180).

A plotted load column is named <parameter>_<group> (FY_PROP_X), the parameter one of the solver's force plot parameters. Its KIND is what the parameter measures (a force FX FY FZ, a moment MX MY MZ, a force coefficient CL CDI CDO CD) and its GROUP is the text after the parameter: the columns of one kind and one group are the components of ONE load of one body in one frame, so an in-plane force is judged against the thrust and an in-plane moment against the torque. The scale is the largest magnitude among the PREVIOUS revolution's means of that kind and group, the revolution the relative drift divides by; a column warns when |mean_now - mean_prev| > limit_pct / 100 * scale. For the column that IS the largest this is the relative drift of the table, unchanged; a near-zero component is not judged against itself, whose relative change is noise.

shown maps each column to the name the table prints. Returns one clause per warned column, in column order, stating the change against the scale. A column that is no load, whose group has no finite nonzero mean, or whose own means are not numbers is never warned about.

Parameters:

Name Type Description Default
previous mapping of str to float

Each column's mean over the previous revolution.

required
current mapping of str to float

Each column's mean over the last revolution.

required
shown mapping of str to str

Each column's name as the table prints it.

required
limit_pct float

The drift allowed, in per cent of the scale.

required

Returns:

Type Description
list of str

One clause per warned column, in column order.

Examples:

>>> before = {"FX_P": 100.0, "FY_P": 0.02, "MACH_P1": 0.1}
>>> names = {name: name for name in before}
>>> after = {"FX_P": 100.1, "FY_P": 0.005, "MACH_P1": 0.2}
>>> revolution_drift_warnings(before, after, names, limit_pct=1.0)
[]
>>> (clause,) = revolution_drift_warnings(before, {**after, "FY_P": 2.5}, names, limit_pct=1.0)
>>> clause.split(" (")[0]
'column FY_P drifts +2.4800 per cent of its scale 100'