Skip to content

pyflightstream.post.polar (provisional)

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

The polar: one row per point of a sweep, per boundary group, as a CSV table.

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 the legacy product surface. The interpolation writer is available directly from this domain module.

The polar files of a polar, the FAM files and one set of group files per boundary GROUP under polars/ (FR-88), are written by the post stage (:mod:pyflightstream.post._polar_stage). This module holds what they share: a point is a :class:PolarPoint, the axes a polar is swept over are measured by :func:swept_axes (:data:SWEEP_AXES), and an induced drag the solver declined to compute is named by :func:declined_induced_drag and summed as NA. The earlier table writers are refused by name (docs/upgrading.md).

The TRIMMED POLAR (FR-2302, FR-2303) is the polar's row at zero pitching moment, interpolated inside the sampled angles and never extrapolated: :func:trimmed_polar_row finds it and :func:write_trimmed_polar writes it beside its polar table ([products] trimmed_polar). A further kind of the backlog (a Richardson-extrapolated polar over a mesh family) joins this module beside the table it extends.

Advanced

pyflightstream.post.polar.DRAG_PRODUCT_COLUMNS module-attribute

DRAG_PRODUCT_COLUMNS: dict[
    tuple[str, str], tuple[str, str]
] = {
    DRAG_PAIRS[0]: (
        COEFFICIENT_COLUMNS[-2],
        COEFFICIENT_COLUMNS[-1],
    ),
    DRAG_PAIRS[1]: ("CDV", "CDP"),
}

pyflightstream.post.polar.GCI_SAFETY_FACTOR module-attribute

GCI_SAFETY_FACTOR = 1.25

pyflightstream.post.polar.GEOMETRY_ANALYSIS_FRAMES module-attribute

GEOMETRY_ANALYSIS_FRAMES = frozenset(
    {"reference", "global", "geometry", "mrp"}
)

pyflightstream.post.polar.GridConvergence dataclass

GridConvergence(
    order: float | None,
    extrapolated: float,
    gci_fine: float | None,
    uncertainty: float,
)

The numerical uncertainty of one result from a three-level refinement study (NL-TRST-7).

The levels are ordered finest first: f1 on the smallest representative size h1. order is the observed order of convergence p; extrapolated the Richardson extrapolation (r21^p f1 - f2) / (r21^p - 1); gci_fine the fine-level grid convergence index Fs e21 / (r21^p - 1), relative to f1 (None where f1 is zero); uncertainty the same band in the result's own units, Fs |f1 - f2| / (r21^p - 1), the numerical uncertainty u_num reported beside f1. Three equal values give no order (None) and a zero band.

pyflightstream.post.polar.PolarPoint dataclass

PolarPoint(
    name: str,
    loads: LoadsReport,
    loads_path: Path,
    point: Mapping[str, float] | None = None,
    state: PointState | None = None,
    vorticity_selection: object = None,
)

One point of a polar: its loads report and where it came from.

point is the sweep point the RECORD states, which is what the point was ASKED for; the angles below are what the solver REPORTED and are read off the table. The two are separate on purpose: the file name and the swept column are about the request (FR-85), and the coefficients are about the answer.

alpha_deg property

alpha_deg: float

The point's angle of attack, from its loads table.

beta_deg property

beta_deg: float

The point's sideslip, from its loads table.

pyflightstream.post.polar.SWEEP_AXES module-attribute

SWEEP_AXES: tuple[str, ...] = (
    "alpha",
    "beta",
    "advance_ratio",
)

pyflightstream.post.polar.TRIM_ANGLE_COLUMN module-attribute

TRIM_ANGLE_COLUMN = 'ALPHA'

pyflightstream.post.polar.TRIM_MOMENT_COLUMN module-attribute

TRIM_MOMENT_COLUMN = 'CMB25'

pyflightstream.post.polar.TRIM_SUFFIX module-attribute

TRIM_SUFFIX = '_trim'

pyflightstream.post.polar.declined_induced_drag

declined_induced_drag(
    loads: LoadsReport, selection: object
) -> tuple[str, ...]

Return the surfaces whose induced drag the solver did not compute, in table order.

PFS-2006.03, FR-22a. A boundary on the vorticity induced-drag list (SET_VORTICITY_DRAG_BOUNDARIES) without a defined trailing edge is not computed, and the export prints its CDi as zero (FSM-26.120 p.202). A surface is declined when selection puts it on that list AND its printed CDi is exactly 0.0. The list is what decides, not the zero: a body left off it is integrated by surface pressure and can print a real zero.

selection is the value the run record keeps for that command: "all" (the -1 the script emits) is every surface; a list of 1-based boundary indices is those surfaces, boundary i read as the table's i-th surface row, since the export prints one row per boundary in the order the geometry numbers them: measured on 40 recorded exports of 11 geometries, four of them with several boundaries, every table in its inventory's order (reports/probes/PFS-2006-03_2026-09-24_row-order.yaml). Resolving the index through the boundary names each run records (RunRecord.inventory, R03), rather than through the table's order, is the stronger reading; the record now exists, and reading the index through it is not done here yet and remains unimplemented. A list holding anything the table cannot place -- a label, a bool, an index out of range -- is read as every surface, because a false NA is loud and a false zero is a number a reader believes. The empty default, None and anything else decline nothing.

A trailing-edged surface whose induced drag rounds to zero at the printed precision is declined too; SET_SIGNIFICANT_DIGITS narrows that band.

Parameters:

Name Type Description Default
loads LoadsReport

The parsed loads table, one row per surface in the solver's order.

required
selection object

The recorded value of SET_VORTICITY_DRAG_BOUNDARIES: "all", a list of 1-based boundary indices, or an empty or other value.

required

Returns:

Type Description
tuple of str

The names of the declined surfaces, in table order; empty when none.

pyflightstream.post.polar.farfield_column_names

farfield_column_names(
    rows: Sequence[tuple[tuple[object, ...], str]],
    columns: Sequence[str],
    *,
    declared_entries: Mapping[str, Sequence[str]]
    | None = None,
) -> list[dict[int, str]]

Name each far-field cell by quantity, method and target (FR-1062).

Parameters:

Name Type Description Default
rows sequence

Long-table rows paired with point names, after window selection.

required
columns sequence of str

Columns following POL, ENTRY, step and the condition block.

required
declared_entries mapping

Entry names in declaration order for each method of this simulation row. Without declarations, use the row's table union and warn once (FR-3661).

None

Returns:

Type Description
list of dict

One mapping from cell index to projected name per input row.

pyflightstream.post.polar.grid_convergence

grid_convergence(
    values: Sequence[float],
    spacings: Sequence[float],
    *,
    safety_factor: float = GCI_SAFETY_FACTOR,
) -> GridConvergence

Estimate the discretization uncertainty of a result from three refinement levels.

The procedure of the grid convergence index (Roache; Celik and others): the changes e21 = f2 - f1 and e32 = f3 - f2 between the levels and the ratios r21 = h2 / h1 and r32 = h3 / h2 give the observed order p, solved by fixed point where the ratios differ; the result is extrapolated to h = 0 and its fine-level band is the GCI. The same procedure serves a time-step study, the time steps as spacings.

Parameters:

Name Type Description Default
values sequence of float

f1, f2, f3, the result on each level, finest first.

required
spacings sequence of float

h1, h2, h3, each level's representative size (a cell size or a time step), positive and increasing.

required
safety_factor float

Fs, 1.25 for three levels; at least 1.

GCI_SAFETY_FACTOR

Returns:

Type Description
GridConvergence

The observed order, the extrapolated value and the uncertainty band.

Raises:

Type Description
ProductError

If there are not three finite values and three positive increasing spacings, if the changes alternate in sign or one of them is zero (oscillatory or stalled convergence, from which no order is estimated), or if the values move away with refinement.

Examples:

>>> study = grid_convergence([1.5, 3.0, 9.0], [1.0, 2.0, 4.0])
>>> study.order, study.extrapolated, study.uncertainty
(2.0, 1.0, 0.625)

pyflightstream.post.polar.swept_axes

swept_axes(
    points: Sequence[Mapping[str, float]],
) -> tuple[str, ...]

Return the axes that VARY across points, in the convention's order (FR-85).

Measured over the points rather than declared, so a one-point case sweeps nothing and a row whose matrix declared a sweep that resolved to a single value is named for the value it actually has. Compared at the precision the name itself writes, because two advance ratios that round to one field are one field.

Parameters:

Name Type Description Default
points sequence of mapping of str to float

The sweep points, each holding some of alpha, beta and advance_ratio.

required

Returns:

Type Description
tuple of str

The axes whose values differ across the points, in the order of :data:SWEEP_AXES.

pyflightstream.post.polar.trimmed_polar_row

trimmed_polar_row(
    columns: Sequence[str],
    rows: Sequence[Mapping[str, object]],
    *,
    moment: str = TRIM_MOMENT_COLUMN,
    angle: str = TRIM_ANGLE_COLUMN,
) -> dict[str, object]

Return a polar's row at zero pitching moment, interpolated inside its sampled range.

The rows are ordered by angle; the pair of neighbouring rows whose moment changes sign brackets the trim, and every numeric column is interpolated linearly between them at the fraction m0 / (m0 - m1) of the way, so moment reads exactly zero (FR-2302). A row that states the zero itself is the trim. A text column keeps its value where both rows agree and reads NA where they do not; so does a numeric cell either row lacks. Nothing is extrapolated: a polar whose sampled moments do not change sign is refused (FR-2303), and so is one that changes sign more than once, because it has more than one trim and the table would have to choose.

Parameters:

Name Type Description Default
columns sequence of str

The polar table's columns.

required
rows sequence of mapping

The polar table's rows, by column (the text :func:read_csv_table reads).

required
moment str

The pitching-moment column, :data:TRIM_MOMENT_COLUMN by default.

TRIM_MOMENT_COLUMN
angle str

The angle the trim moves, :data:TRIM_ANGLE_COLUMN by default.

TRIM_ANGLE_COLUMN

Returns:

Type Description
dict of str to object

The trimmed row by column; None where a cell is not available.

Raises:

Type Description
ProductError

If moment or angle is not a column, fewer than two rows state both, the sampled moments do not bracket zero, or they cross it more than once.

Examples:

>>> rows = [{"ALPHA": "0.0", "CMB25": "0.1", "CLB": "0.2"},
...         {"ALPHA": "4.0", "CMB25": "-0.1", "CLB": "0.6"}]
>>> trimmed_polar_row(["ALPHA", "CMB25", "CLB"], rows)
{'ALPHA': 2.0, 'CMB25': 0.0, 'CLB': 0.4}

pyflightstream.post.polar.write_interpolated_polar

write_interpolated_polar(
    polar: str | Path,
    target: str | Path,
    *,
    axis: str,
    values: Sequence[float],
) -> Path

Write requested coordinates with POL then axis, warning once per unavailable row.

Every numeric cell is linear in the selected coordinate. Text survives only when both bracket rows agree. Unavailable rows retain their requested axis value and common POL identity; all other cells are NA (FR-3343 to FR-3347). The caller prepares the destination using the existing product archive rule.

Parameters:

Name Type Description Default
polar str or Path

Source polar CSV in sweep order.

required
target str or Path

Destination CSV, replaced if it already exists.

required
axis str

Numeric column used as the interpolation coordinate, in its recorded units.

required
values sequence of float

Requested finite coordinates in output order and the axis column's units.

required

Returns:

Type Description
Path

The written table, including warned NA rows where no unique bracket exists.

Raises:

Type Description
ProductError

If the axis is absent or wholly nonnumeric. The campaign post catches this error and warns and skips only the requested product.

pyflightstream.post.polar.write_trimmed_polar

write_trimmed_polar(
    polar: str | Path,
    out: str | Path | None = None,
    *,
    moment: str = TRIM_MOMENT_COLUMN,
    angle: str = TRIM_ANGLE_COLUMN,
    overwrite: bool = False,
) -> Path

Write a polar table's trimmed polar: its row at zero pitching moment (FR-2302).

The table is read back as written, :func:trimmed_polar_row finds the row, and the file has the polar's own columns and that one row, by default beside the polar as <polar stem>_trim.csv. The pproc artifact asks for it beside every polar table with [products] trimmed_polar = true.

Parameters:

Name Type Description Default
polar str or Path

A polar table.

required
out str or Path

Where the trimmed polar is written; <polar stem>_trim.csv beside it by default.

None
moment str

As :func:trimmed_polar_row.

TRIM_MOMENT_COLUMN
angle str

As :func:trimmed_polar_row.

TRIM_MOMENT_COLUMN
overwrite bool

Replace a file already at out.

False

Returns:

Type Description
Path

The file written.

Raises:

Type Description
ProductError

As :func:trimmed_polar_row, naming the polar.

ProductExistsError

If out exists and overwrite is not set.