Skip to content

hertzforge.io.run_convert

run_convert

A run folder becomes an ordinary project file.

convert reads a run folder (hertzforge.io.run_folder) and writes a .hforge project every analysis tool opens with Project.open, by default <run name>.hforge inside the folder. Every control module of the control service writes a run folder for every run: Random, MIMO Random, Sine, Mixed Mode, MIMO Mixed Mode, Classical Shock, SRS shock, MIMO Shock, TWR, Explorer, the Recorder and Playback. This is the analysis side of that bridge.

The project holds, in this order:

  • the channel table as armed, a ChannelTable with its controller columns (channel_table_from_rows, the one mapping between a control channel row and the analysis table, used both ways);
  • a TimeHistory per stream, in SI with the declared unit kept, its roles (a drive is a reference), the run's source label, the averaging the setup names, and a run identity whose source is the controller. A recording's time is measured from its trigger, so its pre-trigger samples are at negative times; a pulse module's stream is one record per shot, timed from its firing, with a history for each kind of shot (a shock run's identification, its pulses; a TWR run's identification, its plays, each timed from its section's start, and a play cut short in a history of its own); a shot that holds no frames (a pulse withheld before it played) is no record. The samples are copied a block at a time, float32 as recorded (native.StreamedHistory);
  • the Specification a Random run was controlled to, from the setup's resolved profile, with its alarm and abort bands as warning and abort limits; for a Sine sweep or dwell, the SineSweepSpecification it was controlled to, one tone over the control channels, from the profile as the service resolved it on the run's band (results/reference), with its alarm and abort bands as the tone's warning and abort limits; for a MIMO Random run, the reference spectral density matrix it was controlled to (results/reference, kind sdm_reference), a Specification with its cross terms, each controlled channel's alarm and abort lines as its warning and abort limits (a reference in virtual degrees of freedom, which are not channels, stays in the run record as arrays); a MIMO Mixed Mode run's floor reference the same way, its tones' and bands' histories, spectra and law calls (control_trace) kept in the run record as arrays;
  • for a Sine sweep or step test, a SineLevelSet of the inputs' tracked levels (a result of kind sine_levels): the last one-way sweep at the highest level the run reached, as one SineLevel of that tone over every enabled input, complex (the tracked amplitude at the phase the run measured against the drive), with the time each line was read; every point of every pass stays in the run record as arrays;
  • a Psd, Frf, Coherence or MultipleCoherence per result of kind psd, cpsd, frf or coherence, converted to SI, cross terms as written (the control service writes them in the file's convention, conj(X) Y, so nothing is conjugated here);
  • an Srs per result of kind srs (a record per pulse, and for a MIMO Shock run per control), and a ShockSpecification per result of kind srs_reference, its band as the warning limits and its abort band (where it has one) as the abort limits, in SI at the result's Q;
  • the TransientSpecification a TWR or MIMO Shock waveform run was controlled to, from its result of kind transient_reference (a TWR run's prepared section between its pads at full level, time from the section's start; a MIMO Shock run's reference at every control), in SI; it has no limits, so its tolerance stays in the result's description;
  • the RunRecord: the manifest, the table and setup as written, the law, the log, the end, each stream's and result's description, the arrays of results no analysis class holds (an Explorer run's survey line and amplitude spectra among them: magnitudes with no phase, kept in the channels' units as written; a Playback run's check of its drive file, playback_check, and its outcome, playback_outcome, whose drive file is named in the setup with its SHA-256 and sidecar), and what the folder lacked. A Playback run has no specification: its inputs and its drives as played are its time histories.

A Modal Test run has no specification either, and its streams are not copied whole: its measurements become each measurement's accepted frames, its FRFs (turned round by reciprocity as well when the excitation roved), its coherence and its reference autospectra (modal_run, which says how); its frame lines and outcome stay in the run record.

All of them are linked in one object group named for the run. A gap in a stream is not padded: the samples after it follow on, and each record of the history says where the gap was and how many frames it lost.

The file is written atomically (a failed conversion leaves no partial file), with no timestamps and in a fixed order, so one folder converted twice gives the same bytes.

Classes:

Name Description
Conversion

What convert wrote: the file, the objects in it by name, and

Functions:

Name Description
channel_table_from_rows

The ChannelTable a control channel table's rows describe.

environment_from_json

An Environment from its JSON form (environment_to_json), or the

environment_to_json

An Environment as JSON: its control and drive channel numbers in

rows_from_channel_table

The control channel rows a ChannelTable with controller columns

default_output

Where a run folder's project file goes unless told otherwise:

convert

Convert a run folder into a project file.

converted

The project file of the run folder path names, converting the

Classes

Conversion dataclass

Conversion(path: str, objects: list[str] = list(), lacked: list[str] = list())

What convert wrote: the file, the objects in it by name, and what the run lacked, in words.

Functions:

channel_table_from_rows

channel_table_from_rows(rows: Sequence[Mapping[str, Any]], environments: Mapping[str, Any] | None = None) -> Any

The ChannelTable a control channel table's rows describe.

Each row is in the protocol's spelling: the fields every row has (index, enabled, description, role, physical, interface, iepe_bias_v, units, sensitivity_mv_per_eu, range_max, polarity, control_group, abort) and the optional members (ANALYSIS_MEMBERS): node, direction, channel_type, analysis_role, daq_range_v, sensor_range_v, serial_number, make, model, triax_dof, expiration, analysis_tier, limit and extra. A member is the table's column of the same name, except description (its comment), units (unit), sensitivity_mv_per_eu (sensitivity), analysis_role (role) and the two ranges (daq_range, sensor_range). An extra entry whose name the table reads as one of its columns fills that column where the row's own member does not; the rest are kept together in the table's extra column. A channel's loop role is three columns: a drive is drive, a control channel control, and a reference a role of reference. Its analysis role is the one the row states (a monitor is never a reference), else reference for a drive or a reference and response for the rest. A channel with no node is given its channel number as its node, a node-only identity, so no two channels share a DOF.

Parameters:

Name Type Description Default
rows sequence of mapping

The control table's rows.

required
environments mapping of str to Environment or mapping

The table's control loops by name, each an Environment or its JSON form (environment_from_json).

None

Returns:

Type Description
ChannelTable

The table, with the controller's columns.

environment_from_json

environment_from_json(value: Any) -> Any

An Environment from its JSON form (environment_to_json), or the Environment itself.

environment_to_json

environment_to_json(environment: Any) -> dict[str, Any]

An Environment as JSON: its control and drive channel numbers in the controller's order, each transformation as a list of rows, or None, and the kind of test it ran when it is known.

rows_from_channel_table

rows_from_channel_table(table: Any) -> list[dict[str, Any]]

The control channel rows a ChannelTable with controller columns describes: channel_table_from_rows the other way.

A cell the table leaves blank takes a new row's value (a drive in V at 1000 mV/V and 10 V full scale, any other channel in g at 100 mV/g and 100 g). Each optional member is written only when its column holds something: the measurement's columns (node, direction, the sensor's identity and the rest), the analysis tier, the limit mark, and the extra column's entries under extra.

Parameters:

Name Type Description Default
table ChannelTable

A table carrying the controller's columns.

required

Returns:

Type Description
list of dict

One row per channel, in the protocol's spelling.

Raises:

Type Description
ValueError

If the table has no controller columns.

default_output

default_output(folder: str | PathLike) -> str

Where a run folder's project file goes unless told otherwise: <run name>.hforge inside the folder.

Parameters:

Name Type Description Default
folder str or PathLike

The run folder.

required

Returns:

Type Description
str

The path.

convert

convert(path: str | PathLike, output: str | PathLike | None = None, progress: Callable[[int, int], None] | None = None) -> Conversion

Convert a run folder into a project file.

Parameters:

Name Type Description Default
path str or PathLike

The run folder, or its run.json.

required
output str or PathLike

The file to write; default_output when omitted. .hforge is added when it is not there.

None
progress callable

Called as progress(frames copied, frames in every stream).

None

Returns:

Type Description
Conversion

The file written, its objects, and what the run lacked.

Raises:

Type Description
RunFolderError

For a folder run_folder.read refuses, or a stream naming a channel the table does not hold. Nothing is written then.

converted

converted(path: str | PathLike) -> str

The project file of the run folder path names, converting the folder when it has none yet, or when its manifest was written after the file (the run went on, or ended, after a conversion). A file converted since is opened as it is, edits and all.

Parameters:

Name Type Description Default
path str or PathLike

The run folder, or its run.json.

required

Returns:

Type Description
str

The project file, default_output of the folder.

Raises:

Type Description
RunFolderError

For a folder run_folder.read refuses.