Skip to content

pyflightstream.post.point_tables (provisional)

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

The tables of one point: its sections, its plots and probes, and their reductions.

One of the product families of :mod:pyflightstream.post (AD-13, work package WP5), written by the post stage of :mod:pyflightstream.post.products, which re-exports every name here:

  • the SECTIONS table of a point, sections/<point>_sections.csv, the sectional loads export re-tabled with the point's condition and the rotor each section belongs to (:func:write_sections_table);
  • the PLOTS table of a point, probes/<point>_plots.csv, the unsteady plots export re-tabled with its coefficients brought to the free stream (:func:write_plots_table);
  • the PROBES table of a point, probes/<point>_probes.csv: the probe points export of a steady row (:func:write_probes_table) or the fluid-plots history of an unsteady row (:func:write_unsteady_probes_table), with the recorded positions (:func:read_probe_positions) on the spine :data:PROBE_SPINE;
  • the REDUCTIONS of the plots table, one file per applicable reduction beside it: the time average (:func:write_reduction_table), the per-blade table (the retired write_per_blade_table, :data:PER_BLADE_COLUMNS) and the phase-locked table (:func:write_phase_locked_table, :data:PHASE_LOCKED_COLUMNS);
  • the PER-REVOLUTION table: one row per complete revolution of the plots history (:func:per_revolution_table, :data:PER_REVOLUTION_COLUMNS), and the drift of each force or moment column between the last two revolutions (:func:revolution_drift_pct, :func:is_force_or_moment_column), written beside it (:data:DRIFT_SUFFIX).

Which reductions a point gets, over which windows, is decided by the private reduction stage (:mod:pyflightstream.post._reduction_stage); the tables are written here.

A new per-point table of the backlog (a far-field product, a further reduction) joins this module beside the writers it resembles.

Advanced

pyflightstream.post.point_tables.DRIFT_SUFFIX module-attribute

DRIFT_SUFFIX = '_DRIFT_PCT'

pyflightstream.post.point_tables.PER_BLADE_COLUMNS module-attribute

PER_BLADE_COLUMNS: tuple[str, ...] = (
    POLAR_ID_COLUMN,
    "REDUCTION",
    "ROTOR",
    "BLADE",
    "FAMILY",
    "FIRST_STEP",
    "LAST_STEP",
    "STEPS",
    "AZIMUTH_START",
    "AZIMUTH_END",
    *CONTEXT_COLUMNS,
    "XMOM",
    "YMOM",
    "ZMOM",
)

pyflightstream.post.point_tables.PER_REVOLUTION_COLUMNS module-attribute

PER_REVOLUTION_COLUMNS: tuple[str, ...] = (
    POLAR_ID_COLUMN,
    "REDUCTION",
    ROTOR_ID_COLUMN,
    "REVOLUTION",
    "FIRST_STEP",
    "LAST_STEP",
    "STEPS",
    *CONTEXT_COLUMNS,
    *_MOMENT_POINT_COLUMNS,
)

pyflightstream.post.point_tables.PHASE_LOCKED_COLUMNS module-attribute

PHASE_LOCKED_COLUMNS: tuple[str, ...] = (
    POLAR_ID_COLUMN,
    "REDUCTION",
    "ROTOR",
    "AZIMUTH",
    "STEP",
    "REVOLUTIONS",
    "FIRST_STEP",
    "LAST_STEP",
    "STEPS",
    *CONTEXT_COLUMNS,
    "XMOM",
    "YMOM",
    "ZMOM",
)

pyflightstream.post.point_tables.PROBE_SPINE module-attribute

PROBE_SPINE: tuple[str, ...] = (
    POLAR_ID_COLUMN,
    *PROBE_POSITION_COLUMNS,
    "STEP",
    *CONTEXT_COLUMNS,
)

pyflightstream.post.point_tables.is_force_or_moment_column

is_force_or_moment_column(name: str) -> bool

Whether a plotted column is a force or a moment, or a force coefficient of one.

The plots table names a column <parameter>_<group> (FX_MRP_TOTAL), and the parameter is one of the solver's force plot parameters: the six components and the four force coefficients. The parameter is what is asked, so a group that happens to begin with F is not mistaken for a force.

Parameters:

Name Type Description Default
name str

A column name of the plots table.

required

Returns:

Type Description
bool

True when the part of the name before the first underscore is one of the solver's force plot parameters.

Examples:

>>> is_force_or_moment_column("FX_MRP_TOTAL"), is_force_or_moment_column("CDI_WING")
(True, True)
>>> is_force_or_moment_column("VX_probe1"), is_force_or_moment_column("FXX_TOTAL")
(False, False)

pyflightstream.post.point_tables.per_revolution_table

per_revolution_table(
    series: TimestepSeries,
    columns: Sequence[str],
    *,
    revolution_steps: int,
    read_steps: set[int] | None = None,
) -> tuple[
    list[tuple[int, int]], list[dict[str, float]], int
]

Cut a plots history into COMPLETE revolutions and take each column's mean.

Revolution k is rows (k-1) * revolution_steps to k * revolution_steps - 1 of the table, counted from its first row, so a history that begins at step one cuts at steps 1 to N, N+1 to 2N and so on. The mean is :func:pyflightstream.post.unsteady.blade_passage_average, the package's one implementation of that average, so this table cannot disagree with the time average about what a mean is. A trailing partial revolution is NOT averaged: its length differs, so its mean would be the mean of another thing under the same name.

Parameters:

Name Type Description Default
series TimestepSeries

The plots table as :func:plots_table_series reads it.

required
columns sequence of str

The columns to average.

required
revolution_steps int

Solver steps in one revolution; at least one.

required
read_steps set of int

Receives the steps the averages read.

None

Returns:

Type Description
tuple

The (first, last) step of each complete revolution, each revolution's mean by column, and the number of rows left over in the partial one.

Raises:

Type Description
ProductError

If revolution_steps is below one.

pyflightstream.post.point_tables.read_probe_positions

read_probe_positions(
    path: str | Path,
) -> dict[int, tuple[float, float, float, str]]

Read a run's probe positions, keyed by the vertex number (FR-91).

The file the run stage wrote beside the script that placed the points, sims/<sim>/profiles/<sim>_probe_points.csv. The key is the vertex number, which is the suffix an unsteady fluid plot carries in its own name, so MACH7 is vertex 7 here.

A file THAT IS NOT THERE answers an empty mapping: every run recorded in legacy releases names none, and a probe table without its positions is what those runs have always produced. Refusing them would take a product away from a campaign that already happened.

An existing positions file that cannot be read is refused. A missing file and a malformed file are distinct: a truncated file must not silently produce empty coordinates.

Parameters:

Name Type Description Default
path str or Path

The positions file of the run.

required

Returns:

Type Description
dict

Vertex number to (x, y, z, frame), empty when the file is absent.

Raises:

Type Description
ProductError

The file is there and this reader cannot read it. The caller records it as a skip naming the file, as it does for a probe export it cannot parse.

pyflightstream.post.point_tables.revolution_drift_pct

revolution_drift_pct(
    current: float, previous: float
) -> float | None

Return the drift of one mean from the previous one, in per cent, or None (NA).

(current - previous) / |previous| * 100: the sign says whether the mean rose or fell whatever the sign of the quantity. None where the previous mean is zero, which has no relative change, and where either mean is not a number.

Parameters:

Name Type Description Default
current float

The mean of the revolution.

required
previous float

The mean of the revolution before it.

required

Returns:

Type Description
float or None

The drift in per cent, or None where it is undefined.

Examples:

>>> revolution_drift_pct(101.0, 100.0)
1.0
>>> revolution_drift_pct(-99.0, -100.0)
1.0
>>> revolution_drift_pct(1.0, 0.0) is None
True

pyflightstream.post.point_tables.write_phase_locked_table

write_phase_locked_table(
    path: str | Path,
    series: TimestepSeries,
    columns: Sequence[str],
    *,
    window: Sequence[int],
    revolutions: float,
    steps_per_revolution: float,
    rotor: str | None,
    blades: int,
    facts: Mapping[str, object],
    condition: Mapping[str, object] | None = None,
    reference: ReferenceValues | None = None,
    pol: str | int | None = None,
    overwrite: bool = True,
) -> Path

Write the phase-locked reduction a [phase_locked] table asks for: ONE ROW PER AZIMUTH.

pol is the polar the point belongs to, the first column of every row (G16); NA where the caller states none.

Each row is an azimuthal position of the rotor's last revolution, and each value the mean of the samples AT that position across the last revolutions revolutions; the rows run from 0 towards 360 degrees. It is :func:pyflightstream.post.unsteady.phase_locked_rows, which says how a blade's own columns are tabulated by that blade's azimuth.

facts is what the retired write_per_blade_table takes of the rotor: its blade families, its blade1_azimuth_deg and its signed rpm. The columns keep the names the plots export prints, all in one file: a blade's end in its family, a rotor's in the group the pproc named for it.

Parameters:

Name Type Description Default
path str or Path

Destination CSV.

required
series TimestepSeries

The plots table as :func:plots_table_series reads it.

required
columns sequence of str

The plots table's columns, in its order.

required
window sequence of int

First and last solver step of the window.

required
revolutions float

How many of the last revolutions enter each mean.

required
steps_per_revolution float

Solver steps in one revolution.

required
rotor str or None

The rotor's alias, written in each row.

required
blades int

The rotor's blade count.

required
facts mapping

What the run states of the rotor: families, blade1_azimuth_deg and rpm.

required
condition mapping

The point's condition block, written in every row.

None
reference ReferenceValues

Reference lengths and moment point written beside each row.

None
pol str or int

The polar the point belongs to, written first in every row.

None
overwrite bool

Replace a file that already exists, as the writer always did (the default). False refuses an existing file, naming it, before it is replaced.

True

Returns:

Type Description
Path

The file written, one row per azimuth.

Raises:

Type Description
ProductError

If nothing states where blade one is or which way the rotor turns, so no azimuth can be written, or the history does not hold the revolutions.

pyflightstream.post.point_tables.write_plots_table

write_plots_table(
    path: str | Path,
    export_text: str,
    *,
    pol: str | int | None = None,
    overwrite: bool = True,
) -> Path | None

Write one plots table from an unsteady plots export.

The coefficient columns (CL_, CDI_, CDO_, CDP_, CDV_, CD_) are multiplied by the square of the reference velocity over the free stream, so a run whose reference velocity differs from the free stream reads as free-stream coefficients. An export the reader cannot parse is a refusal naming the file, never a silent skip; an export with no step returns None.

pol is the polar the point belongs to. It is the table's FIRST column (G16), NA where the caller states none, and the export's own header follows it unchanged; :func:plots_table_series reads every column AFTER it back as a plotted quantity.

Parameters:

Name Type Description Default
path str or Path

Destination CSV; also named in the refusal message.

required
export_text str

Complete text of the unsteady plots export.

required
pol str or int

The polar the point belongs to, written first in every row.

None
overwrite bool

Replace a file that already exists, as the writer always did (the default). False refuses an existing file, naming it, before it is replaced.

True

Returns:

Type Description
Path or None

The file written, or None when the export holds no step.

Raises:

Type Description
ProductError

If the export cannot be read.

pyflightstream.post.point_tables.write_probes_table

write_probes_table(
    path: str | Path,
    export_text: str,
    *,
    positions: Mapping[int, tuple[float, float, float, str]]
    | None = None,
    condition: Mapping[str, object] | None = None,
    reference: ReferenceValues | None = None,
    pol: str | int | None = None,
    step: int | None = None,
    overwrite: bool = True,
) -> Path | None

Write one probe-points table from an EXPORT_PROBE_POINTS export (FR-87, FR-91).

pol is the polar the point belongs to, the first column of every row (G16); NA where the caller states none.

The flow-field samples of a point that is not an unsteady history: one row per probe point, the export's own columns in its own order and units, which carry the fluid quantities (Mach, Cp, vx, vy, vz, vtot) beside the boundary-layer columns. Nothing is scaled: the plots table brings its COEFFICIENT columns from the solver's reference velocity to the free stream because those columns are coefficients, and a sampled velocity is not. The sampled Mach header is MACH_LOCAL; the condition keeps MACH.

It lands beside the unsteady plots table, under :data:PROBES_DIR, which is the whole point of FR-87: a steady row and an unsteady row citing the same artifact put their flow-field samples in one place. An export the reader cannot parse is a refusal naming the file, never a silent skip; an export with no probe point returns None, as an unsteady export with no step does, since a table of nothing is a promise of content that is not there.

FR-91 PUTS THE SPINE IN FRONT OF THOSE COLUMNS. A steady export already states X, Y and Z and it never states WHICH FRAME they are measured in, so a reader could place the numbers only by knowing the artifact. The export's own coordinates are kept, because they are the solver's answer about the point it sampled. The export is labeled REFERENCE; recorded positions cannot relabel it. A licensed per-export placement probe remains pending.

Parameters:

Name Type Description Default
path str or Path

Destination CSV; also named in the refusal message.

required
export_text str

Complete text of the probe points export.

required
positions mapping

Vertex number to (x, y, z, frame), from :func:read_probe_positions. Absent for every run recorded in legacy releases. Exported coordinates still carry REFERENCE; only a position unavailable from both sources reads NA. Missing cells were EMPTY in legacy releases; the producer still returns a blank there and the funnel in :mod:pyflightstream.post._tables renders it, so this says what the user opens rather than what the tuple carries.

None
condition mapping

The point's condition block, written in every row.

None
reference ReferenceValues

Reference lengths written beside each row.

None
pol str or int

The polar the point belongs to, written first in every row.

None
step int

The time step the export holds, written in every row's STEP: the last time step of an unsteady run whose probes are normal (FR-417 FR-887). NA where the caller states none, as on a steady point.

None
overwrite bool

Replace a file that already exists, as the writer always did (the default). False refuses an existing file, naming it, before it is replaced.

True

Returns:

Type Description
Path or None

The file written, or None when the export holds no probe point.

Raises:

Type Description
ProductError

If the export cannot be read.

pyflightstream.post.point_tables.write_reduction_table

write_reduction_table(
    path: str | Path,
    series: TimestepSeries,
    columns: Sequence[str],
    *,
    reduction: str,
    windows: Sequence[Sequence[int]],
    names: Mapping[str, str] | None = None,
    condition: Mapping[str, object] | None = None,
    reference: ReferenceValues | None = None,
    rotor: str | None = None,
    pol: str | int | None = None,
    overwrite: bool = True,
) -> Path

Write one reduction of a plots table: one row per window, the table's columns averaged.

pol is the polar the point belongs to, the first column of every row (G16) and the first of :data:REDUCTION_COLUMNS; NA where the caller states none.

THE CLOCK IS NOT AVERAGED. FIRST_STEP and LAST_STEP identify the span; Time-step is a counter rather than a plotted physical quantity. rotor is the alias this reduction is cut for, NA for the time average.

condition and reference are what the row is a reduction OF, and this table carried neither in legacy releases: a window of averaged coefficients with no angle of attack and no reference area beside it is a set of numbers about nothing. Both are optional, and what neither supplies reads NA rather than being invented.

The average is :func:pyflightstream.post.unsteady.blade_passage_average, the only implementation of that average in the package, applied once per window; the time average is one window, the phase-locked reduction one per passage, the per-blade reduction one per blade. Coefficients and recognized physical quantities retain six significant digits where that is closer than five decimals; other numeric columns use five decimals.

Parameters:

Name Type Description Default
path str or Path

Destination CSV, beside the plots table it reduces.

required
series TimestepSeries

The plots table as :func:plots_table_series reads it.

required
columns sequence of str

The plots table's columns, in its order.

required
reduction str

time_average, phase_locked or per_blade.

required
windows sequence of (first, last)

Inclusive solver-step windows, 1-based, each inside the table.

required
names mapping of str to str

The pproc dictionary renaming columns of the heading.

None
condition mapping

The point's condition block, written in every row.

None
reference ReferenceValues

Reference lengths and moment point written beside each row.

None
rotor str

The alias the reduction is cut for; NA for the time average.

None
pol str or int

The polar the point belongs to, written first in every row.

None
overwrite bool

Replace a file that already exists, as the writer always did (the default). False refuses an existing file, naming it, before it is replaced.

True

Returns:

Type Description
Path

The file written, one row per window.

Raises:

Type Description
ProductError

If a window reaches past the rows the table holds: a shorter history averaged as a whole one is the shape every reader here refuses, and the caller records the refusal as a skip.

pyflightstream.post.point_tables.write_sections_table

write_sections_table(
    path: str | Path,
    export_text: str,
    *,
    mach: float,
    step: int | None = None,
    iteration: object = _ITERATION_UNSET,
    unsteady: bool = False,
    azimuth_deg: float | None = None,
    reference: ReferenceValues | None = None,
    advance_ratio: float | None = None,
    condition: Mapping[str, object] | None = None,
    layout: Sequence[Mapping[str, object]] | None = None,
    rotors: Mapping[str, Mapping[str, object]]
    | None = None,
    pol: str | int | None = None,
    inventory: Sequence[str] | None = None,
    rotor_ids: Mapping[str, int] | None = None,
    split: str = "point",
    family_files: list[Path] | None = None,
    overwrite: bool = True,
) -> Path | None

Write one sections table from a sectional loads export.

pol is the polar the point belongs to, the matrix row's POL: the first column of every row (G16), NA where the caller states none.

layout is WHICH DISTRIBUTION EACH ROW BELONGS TO: the blocks the run's script created, in order, as the run record states them under sections_layout. A pproc declares several distributions, the wing in XZ and each blade in its own frame, and the export concatenates them with no marker; with Offset the only coordinate, two distributions of similar span were indistinguishable. FAMILY, PLANE and ROTOR say which is which. The layout is applied ONLY when its counts add up to the rows the export holds; otherwise, and on every record written before the run recorded one, the three read NA. The script states surfaces by index, so nothing at post can name them.

rotors maps a rotor's alias to its families, its steps_per_revolution, its blade1_azimuth_deg and its signed rpm. AZIMUTH is where BLADE ONE OF THE BLOCK'S OWN ROTOR is at the export's step,

(blade1_azimuth_deg + sign(rpm) * STEP * 360 / steps_per_revolution) mod 360

and NA on a block no rotor owns.

condition is the POINT's condition as :func:point_condition assembles it, and the stage always passes it. The export header's Altitude (ft) line is not set by the campaign and cannot substitute for the point's altitude. Without it the header is read, for a caller holding an export and no point.

step is the solver step the distribution was sampled at and azimuth_deg is where the blade was when it was; both lead the row because they are the only two things that vary down the file. They replace the POINT column, which carried the polar's NAME and therefore restated the file name. A run with no rotor states no azimuth and the cell reads NA, which is not zero: zero is a real azimuth.

Write step=; passing iteration= raises :class:ProductArgumentError naming that replacement, even for None.

On a steady export, an omitted step is read from the header. With unsteady=True the header counts inner iterations, so the caller supplies the time step from the run record; an unknown step stays NA.

THE AZIMUTH IS WRAPPED -- a step count is not an angle, and 1575 steps of 3.6 degrees is 5670 degrees, which is not somewhere a blade can be. Without a rotor that owns the block it stays NA, because the alternative is writing a zero that a reader would believe. azimuth_deg is for a caller holding one export of one rotor and no layout; it states every row.

Returns None without writing when the export declares no section, as a run that defined no distribution leaves; the columns are the point, its condition, and the export's own seven, in the export's units.

reference supplies the reference LENGTHS, which this table carried none of in legacy releases: a sectional force beside no area is a number nobody can check. It is optional because a caller that genuinely holds no reference should write NA rather than be refused a product it can otherwise make, and a run's reference is recorded beside its outputs rather than inside this export.

Parameters:

Name Type Description Default
path str or Path

Destination CSV.

required
export_text str

Complete text of the sectional loads export.

required
mach float

Mach number of the point, for the condition block when condition is not given.

required
step int

Solver step the distribution was sampled at; read from the export's header on a steady export when omitted, NA on an unsteady one.

None
iteration object

Removed; passing any value raises.

_ITERATION_UNSET
unsteady bool

Whether the export is of an unsteady run, whose header counts inner iterations rather than time steps.

False
azimuth_deg float

Azimuth in degrees stated for every row, for a caller holding one export of one rotor and no layout.

None
reference ReferenceValues

Reference lengths written beside each row; NA where None.

None
advance_ratio float

Advance ratio of the point, used only when condition is not given.

None
condition mapping

The point's condition as :func:point_condition assembles it.

None
layout sequence of mapping

The distribution blocks of the run's script, in order, as the run record states them.

None
rotors mapping of str to mapping

Each rotor's alias to its families, steps_per_revolution, blade1_azimuth_deg and signed rpm.

None
pol str or int

The polar the point belongs to, written first in every row.

None
inventory sequence of str

The geometry's boundary inventory, in file order: FAMILY_ID is the 1-based index of the family in it, NA where it names none.

None
rotor_ids mapping of str to int

Each rotor alias to its declared id, for ROTOR_ID.

None
split ('point', 'family', 'both')

[sections] split. The point table is always written; family and both also write one table per family, <point>_FAM-<FAMILY>_sections.csv, and the caller drops the point table where only the family files are asked for.

'point'
family_files list of Path

Where the per-family paths written are appended.

None
overwrite bool

Replace a file that already exists, as the writer always did (the default). False refuses an existing file, naming it, before it is replaced.

True

Returns:

Type Description
Path or None

The point table written, or None when the export declares no section.

Raises:

Type Description
ProductArgumentError

If iteration is passed.

ProductError

If the export cannot be read or carries fewer than seven columns.

pyflightstream.post.point_tables.write_unsteady_probes_table

write_unsteady_probes_table(
    path: str | Path,
    plots_table: str | Path,
    *,
    positions: Mapping[
        int, tuple[float, float, float, str]
    ],
    parameters: Sequence[str],
    condition: Mapping[str, object] | None = None,
    reference: ReferenceValues | None = None,
    notes: list[str] | None = None,
    pol: str | int | None = None,
    overwrite: bool = True,
) -> Path | None

Write the probe table of an UNSTEADY row, from its plots table (FR-91).

pol is the polar the point belongs to, the first column of every row (G16); NA where the caller states none. The plots table it reads carries its own POL first, which is read by name and never as a probe group.

The export that an unsteady row produces for its probes is the plots table, and it carries one NUMBERED GROUP per probe point: MACH7, VELOCITY7, VX7, VY7, VZ7, STATIC_PRESSURE_RATIO7. It is taken not to say where vertex 7 is, which is the whole of the requirement: the positions file is what makes a sample placeable. (The group names are those the package's own builder emits; no committed report records the plots-table header, nor that it states no position.) This un-pivots those groups into one row per point and step and puts the recorded position in front of them.

Sample parameter MACH is written as MACH_LOCAL to distinguish it from the condition's MACH column. Source plot names stay unchanged.

THE COLUMNS ARE COMPOSED FORWARD, from the parameters the artifact declares and the vertices the script recorded, exactly as the builder composed the names it emitted. A pattern read backward off the header would collect a force column of a family named Blade1 as parameter Blade of vertex 1.

Read from the WRITTEN plots table rather than from the export in memory, which is this module's rule: a derived table is derived from the file a user holds and can be recomputed from it.

THE STEP COLUMN IS THE TABLE'S OWN Time-step, not the row's position, which is the rule post.superfile already states: the step a sample came from is not a guess. A plots table carrying no such column falls back to the ordinal, because a product is better than a refusal there and the two agree on every export that begins at one and steps by one.

Parameters:

Name Type Description Default
path str or Path

Destination CSV.

required
plots_table str or Path

The plots table written for the same point.

required
positions mapping

Vertex number to (x, y, z, frame), from :func:read_probe_positions.

required
parameters sequence of str

The probe parameters the artifact declares, for example MACH.

required
condition mapping

The point's condition block, written in every row.

None
reference ReferenceValues

Reference lengths written beside each row.

None
notes list of str

Receives the recorded vertices the table has no history for.

None
pol str or int

The polar the point belongs to, written first in every row.

None
overwrite bool

Replace a file that already exists, as the writer always did (the default). False refuses an existing file, naming it, before it is replaced.

True

Returns:

Type Description
Path or None

None when the row recorded no probe position, when the artifact declares no probe parameter, or when no group of the two is actually in the table: a file of a spine and nothing else is a promise of content that is not there.

Parameters absent at a vertex are written as NA, so entries requesting
different parameters retain their available histories in the same table.
A recorded vertex whose group is absent from the export is named in ``notes``; the remaining
vertices are kept.