hertzforge.io.run_folder¶
run_folder
¶
The run folder: one control run as the control service records it.
A run folder (schema hertzforge-run/1) is how a control run is meant
to reach the analysis side: one folder per run, valid at every moment,
needing no other file and no running service to be read. Every control
module of the control service writes one for every run: Random, MIMO
Random, Sine, Mixed Mode, Classical Shock, SRS shock, MIMO Shock, TWR,
Explorer, the Recorder, Playback and the Modal Test (docs/run-folder.md).
hertzforge.io.run_convert turns a folder into an ordinary project
file. Its members:
run.json, the manifest: the schema, the test, the run's identity, the operator's words, the source (SIMorHARDWARE, never absent), the station, the build, the start, the streams and results it declares, andcomplete;table.json, the channel table as armed, every row in the protocol's spelling for a channel row, with any further columns underextra;setup.json, the configuration as accepted (config) and what the service resolved it to (resolved);law/, the law'slaw.jsonand, for a law that is a file, its bytes;log.jsonl, the run's log, one JSON object per line;streams/<name>/,telemetry.f32(little-endian float32, frame-interleaved, engineering units, no header) andstream.json;results/<name>.jsondescribing named arrays held in<name>.bin(little-endian; complex as real and imaginary pairs), with<name>.jsonlholding a line per record of a result that repeats;end.json, written once at a clean end.
read takes a folder whole, including one whose run did not end: a run
with complete false or no end.json, a stream whose length is what
its file holds (a frame cut short is left out), a log whose last line
was torn. What it lacked is listed (RunFolder.missing), never filled
in. A folder with no source label is refused, since whether a run was
simulated is never guessed, and so is a schema newer than this reader.
Members a reader does not know are ignored and kept.
Classes:
| Name | Description |
|---|---|
RunFolderError |
A folder that is not a run folder this reader can take, with the |
Stream |
One stream of a run: its description and where its samples are. |
Result |
One result of a run: its description and its arrays. |
RunFolder |
A run folder as read: every member parsed, the streams sized from |
Functions:
| Name | Description |
|---|---|
folder_of |
The run folder |
read |
Read a run folder whole, or the folder whose |
Classes¶
RunFolderError
¶
Bases: ValueError
A folder that is not a run folder this reader can take, with the reason.
Stream
dataclass
¶
Stream(name: str, kind: str, path: str, description: dict[str, Any], channels: list[int], units: list[str], rate: float, frames: int)
One stream of a run: its description and where its samples are.
frames is what the file holds, whole frames only; channels are
the table indexes of its slots in order, and units the unit each
is recorded in.
Methods:
| Name | Description |
|---|---|
blocks |
The samples, a block of frames at a time, as read from the |
Methods:¶
blocks
¶
The samples, a block of frames at a time, as read from the file: (first frame, frames by channels, float32). Only one block is in memory at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frames_per_block
|
int
|
The most frames in one block. |
required |
Returns:
| Type | Description |
|---|---|
iterator of (int, numpy.ndarray)
|
Each block's first frame and its values. |
Result
dataclass
¶
Result(name: str, kind: str, description: dict[str, Any], arrays: dict[str, ndarray], records: list[dict[str, Any]] | None = None)
One result of a run: its description and its arrays.
A result that repeats has a record per line of its .jsonl, and
each array holds the records first.
RunFolder
dataclass
¶
RunFolder(path: str, manifest: dict[str, Any], table: dict[str, Any], setup: dict[str, Any], log: list[dict[str, Any]] = list(), end: dict[str, Any] | None = None, law: dict[str, Any] | None = None, law_file: tuple[str, bytes] | None = None, streams: dict[str, Stream] = dict(), results: dict[str, Result] = dict(), missing: list[str] = list())
A run folder as read: every member parsed, the streams sized from their files, the results' arrays read, and what the folder lacked.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
The run's name: the folder's. |
source |
str
|
'SIM' or 'HARDWARE'. |
test |
str
|
The test the run was ('random', 'recorder', ...). |
rows |
list[dict[str, Any]]
|
The channel table's rows as armed. |
Functions:¶
folder_of
¶
The run folder path names, or None when it names none: the
folder itself, or the run.json inside one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
A folder, or a file. |
required |
Returns:
| Type | Description |
|---|---|
str or None
|
The folder's absolute path, when it holds a manifest naming the
run folder schema (of any number, so a newer one is refused by
|
read
¶
read(path: str | PathLike) -> RunFolder
Read a run folder whole, or the folder whose run.json path is.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str or PathLike
|
The run folder, or its |
required |
Returns:
| Type | Description |
|---|---|
RunFolder
|
Every member parsed, and what the folder lacked in |
Raises:
| Type | Description |
|---|---|
RunFolderError
|
For a folder with no manifest, a schema newer than this reader
( |