pyflightstream.post.reductions (stable)¶
Generated from the docstrings at build time: every one of the 2 names in the __all__ of pyflightstream.post.reductions has an entry below. The names a guide or an example uses come first; the others follow under Advanced.
The writing seam of a reduction, and the file rule it holds.
Pipeline role: the only place in the package where a reduction of an
unsteady series becomes a file. It exists as its own module because the
rule it enforces is a rule about DESTINATIONS, and the average itself
(:func:pyflightstream.post.unsteady.blade_passage_average) is pure and
has none.
THE FILE RULE (PFS-2015.01):
- a reduction NEVER overwrites the file it came from;
- the time series keeps its own dedicated file.
Both are enforced HERE rather than in a workflow, and that placement is the whole point of the rule as stated: it holds however the reduction is reached, so a caller who bypasses the workflow and calls this layer directly cannot obtain an average with no history beside it. A rule that only a workflow keeps is a rule with a documented way round it.
Three refusals, and they are deliberately of two different types
because they are two different failures. Writing onto a file that was
READ, and writing a reduction with no series beside it, are file
management refusing to destroy evidence, which is
:class:~pyflightstream.workspace.WorkspaceError. Writing onto a file
that already exists is the silent-overwrite class PYFS-005 records,
which is :class:~pyflightstream.post.writers.OutputExistsError and
takes the same overwrite=True way through as the flow-visualization
writers.
Advanced¶
pyflightstream.post.reductions.write_reduction
¶
write_reduction(
path: str | Path,
average: FrameAverage,
*,
series_file: str | Path,
sources: tuple[Path, ...] | list[Path] | None = None,
overwrite: bool = False,
) -> Path
Write a reduction, refusing every way it could lose its history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Destination CSV file, holding one row per field and sample:
|
required |
average
|
FrameAverage
|
The reduction, from
:func: |
required |
series_file
|
(str or Path, keyword - only)
|
The time series this reduction came from, written by
:func: |
required |
sources
|
sequence of pathlib.Path
|
Extra files this reduction was read from, on top of the frames the average already carries. Both sets are refused as destinations. |
None
|
overwrite
|
(bool, keyword - only)
|
Replace an existing destination. Default False. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
The written file. |
Raises:
| Type | Description |
|---|---|
WorkspaceError
|
If the destination is a file the reduction was read from, or if the series file is missing or is not beside the destination. |
OutputExistsError
|
If the destination exists and |
pyflightstream.post.reductions.write_series
¶
write_series(
path: str | Path,
series: TimestepSeries,
*,
overwrite: bool = False,
) -> Path
Write the time series to its own dedicated file.
One row per exported frame: the solver step, the solution time in seconds where the frames carried one, and one column per sample of each field. The history is what makes an average auditable, so it gets a file rather than a section of one.
A finite value is written at full precision, the shortest decimal that
reads back to the same double, never rounded to the five decimals of the
product tables, because the series is the evidence an average is checked
against. A value that is not available (NaN or infinite, a sample or a
time) is written NA, never nan (FR-2310).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or Path
|
Destination CSV file. Its parent is created if absent. |
required |
series
|
TimestepSeries
|
The read-back frames. |
required |
overwrite
|
(bool, keyword - only)
|
Replace an existing destination. Default False. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
The written file. |
Raises:
| Type | Description |
|---|---|
OutputExistsError
|
If the destination exists and |
WorkspaceError
|
If the destination is one of the frame files the series was read from. |