Skip to content

hertzforge.io.native

native

The native .hforge file format, which is HDF5, and the reader for older .vdyn files it started from.

A file with a single object has one group at the root, named for the object's kind ('geometry', 'data', 'shapes', and so on). A file with a whole test has an objects/ group of numbered groups, numbered in the test's order, with each object's name and kind as attributes, so a name may contain anything, including characters h5py would read as a path. The test's name, active geometry, project type, object groups and provenance are attributes of the root. Ragged connectivity is stored as a flat array plus offsets. Every file is stamped with its schema version, and a file from a newer schema is refused with a message to update. docs/hforge-format.md writes the layout down.

A .hforge file is a .vdyn file of schema 3 under a new stamp, with the element-group fields and the object groups under their current names (VDYN_NAMES). A .vdyn file is read, by its own stamp, and never written: saving it again writes .hforge.

A project can hold an object by reference to another .hforge file instead of a copy (schema 2): the object's group names the file and the object, with the file's size and SHA-256, and the reader reads the object from there (Reference).

A converted control run holds a run record (schema 3), the control service's own record of the run (core.run_record), and its streams are written block by block (StreamedHistory), so a run larger than memory converts.

Classes:

Name Description
MappedFileError

A save over a file an open project has mapped, where the operating

StreamedHistory

A time history to be saved from blocks of samples, so it is never

Functions:

Name Description
compressed

Within the block, saves write each array of COMPRESS_FROM_BYTES

mapped_files

The files arrays are mapped from now, by their real paths: what an

is_run_file

Whether path is a control run's converted project file: the

save_geometry

Write a geometry into group: nodes, coordinate systems and

load_geometry

Read a geometry written by save_geometry.

save_data

Write a data object into group: abscissa, ordinate and the

load_data

Read a data object written by save_data, as the class its name

save_channel_table

Write a channel table into group, one dataset per column in its

load_channel_table

Read a channel table written by save_channel_table. Columns are

save_shapes

Write a shape set into group: frequencies, damping, shape matrix

load_shapes

Read a shape set written by save_shapes; an empty mass unit

save_element_shapes

Write an element shape set into group: the modes' frequencies and

load_element_shapes

Read an element shape set written by save_element_shapes; an

save_report

Write a report into group: title and marking as attributes, its

load_report

Read a report written by save_report; a file from before

save_predictions

Write a Predictions object into group: its comment, and one

load_predictions

Read a Predictions object written by save_predictions, each

save_photos

Write photos into group: names and formats as strings, and each

load_photos

Read photos written by save_photos, each image as the bytes it

save_run_log_extract

Write a RunLogExtract into group: the snapshot's JSON Lines

load_run_log_extract

Read a RunLogExtract written by save_run_log_extract. A log

save_matches

Write matched modes into group: the two shape sets' names and

load_matches

Read matched modes written by save_matches; an empty geometry

save_sine_specification

Write a sine sweep specification into group, one subgroup per

load_sine_specification

Read a sine sweep specification written by

save_sine_levels

Write a sine level set into group, one subgroup per tone, each

load_sine_levels

Read a sine level set written by save_sine_levels, each tone's

save_streamed_history

Write a StreamedHistory into group in the layout save_data

save_run_record

Write a RunRecord into group: its identity as attributes, each

load_run_record

Read a RunRecord written by save_run_record.

save_test_setup

Write a TestSetup into group: its module, protocol, title and

load_test_setup

Read a TestSetup written by save_test_setup.

load_scan

Read a scan/ group as a geometry. Schema 5 stored measured points

schema_for

The schema a file holding objects of kinds is stamped with: the

hforge_path

path with .hforge added when it does not end in it. A .vdyn

save

Save one Hertzforge object to a .hforge (HDF5) file.

save_into

Write one object into an open, empty HDF5 file.

fingerprint

A digest of everything saving obj would write, with each mapped

object_sizes

{object name: (kind, bytes stored)} for the objects in a

save_test

Save a whole test, every named object, to one .hforge file.

save_test_into

save_test into an open, empty HDF5 file (see save_into).

load

Load a .hforge or .vdyn file: the object it holds, or a whole test.

load_from

load from an open HDF5 file (see save_into). path names the

Classes

MappedFileError

Bases: PermissionError

A save over a file an open project has mapped, where the operating system cannot replace a mapped file (Windows): the file is left as it was, and the save is made under a new name instead.

StreamedHistory

StreamedHistory(header: Any, samples: int, first: float, rate: float, blocks: Callable[[], Iterable[StreamBlock]], dtype: Any = float32)

A time history to be saved from blocks of samples, so it is never whole in memory.

A converted run's streams can be larger than the memory of the machine converting them. header carries everything a time history saves but its samples (DOFs, units, roles, averaging, run identity, source), with an ordinate of no columns; blocks() yields the samples a block at a time (StreamBlock), and the abscissa is written from its first instant and rate. It saves as the data kind, and reads back as the TimeHistory it describes.

Parameters:

Name Type Description Default
header TimeHistory

The history's fields, with as many records as the ordinate has rows and no samples.

required
samples int

Columns of the ordinate.

required
first float

The first instant, seconds.

required
rate float

Samples per second.

required
blocks callable

Called once, while saving; returns an iterable of StreamBlock that fills every row and column between them.

required
dtype numpy dtype

What the ordinate is stored as: float32 by default, the precision the control service records.

float32

Functions:

compressed

compressed(on: bool = True) -> Iterator[None]

Within the block, saves write each array of COMPRESS_FROM_BYTES or more with gzip and the shuffle filter, chunked along its last axis (time, for a time history). Arrays are uncompressed otherwise: gzip saved 12% on a random-vibration run and wrote at 58 MB/s, so it is for archiving, not for every save. Every HDF5 reader reads the file either way.

mapped_files

mapped_files() -> list[str]

The files arrays are mapped from now, by their real paths: what an open project still holds open.

is_run_file

is_run_file(path: str | PathLike) -> bool

Whether path is a control run's converted project file: the <run name>.hforge inside its own run folder, beside the folder's run.json (run_convert.default_output). Nothing replaces it in place while it is mapped, so it can be mapped on Windows too.

save_geometry

save_geometry(geom: Geometry, group: Group) -> None

Write a geometry into group: nodes, coordinate systems and elements as datasets, connectivity as a flat array plus offsets.

The rigid-body settings, view, solids, mates and element-group properties are written only when set, so a file from before each existed reads back the same.

load_geometry

load_geometry(group: Group) -> Geometry

Read a geometry written by save_geometry.

A file from before 2026-09-30, which kept tracelines apart from elements, is converted on the way in: each traceline becomes an element group of two-node lines, and element groups are split by family.

save_data

save_data(data: DataArray, group: Group) -> None

Write a data object into group: abscissa, ordinate and the per-record strings as datasets, and what its kind carries (an SRS's Q, a sine level's tone, interpolation, band constraints, averaging, filtering, run identity and so on) beside them, each only when set.

The class name is stored as well as the function type, because a Specification shares the PSD's and the code alone cannot say which class to rebuild.

load_data

load_data(group: Group) -> DataArray

Read a data object written by save_data, as the class its name was stored under, or by its function type in a file without one. An attribute the file lacks leaves the object's default, so older files load unchanged.

save_channel_table

save_channel_table(table: ChannelTable, group: Group) -> None

Write a channel table into group, one dataset per column in its order, and its control loops as numbered subgroups: an environment name is free text, and h5py reads a slash in a group name as a path.

load_channel_table

load_channel_table(group: Group) -> ChannelTable

Read a channel table written by save_channel_table. Columns are read by their stored type rather than the current column specs, so a column the schema has since dropped still reads and the constructor decides what is kept.

save_shapes

save_shapes(shapes: ShapeSet, group: Group) -> None

Write a shape set into group: frequencies, damping, shape matrix and modal mass as datasets with its strings, mass unit and unscaled flag; modal damping and the reference-only DOFs only when the set has them.

load_shapes

load_shapes(group: Group) -> ShapeSet

Read a shape set written by save_shapes; an empty mass unit reads back as None.

save_element_shapes

save_element_shapes(shapes: Any, group: Group) -> None

Write an element shape set into group: the modes' frequencies and damping, each stress point's element, point, position and weight, and the strain and stress (modes x points x 6), with its units.

load_element_shapes

load_element_shapes(group: Group) -> Any

Read an element shape set written by save_element_shapes; an empty unit reads back as None.

save_report

save_report(report: Report, group: Group) -> None

Write a report into group: title and marking as attributes, its blocks as one JSON string. Features and identity are written only when entered, so a report with neither is stored as it was before they existed.

load_report

load_report(group: Group) -> Report

Read a report written by save_report; a file from before features or identity loads with none.

save_predictions

save_predictions(predictions: Predictions, group: Group) -> None

Write a Predictions object into group: its comment, and one subgroup per prediction holding its values as JSON (Prediction.as_record) and its curve, when it has one.

load_predictions

load_predictions(group: Group) -> Predictions

Read a Predictions object written by save_predictions, each prediction rebuilt from its JSON record and its curve.

save_photos

save_photos(photos: Photos, group: Group) -> None

Write photos into group: names and formats as strings, and each image as its file's own bytes, neither decoded nor re-encoded.

load_photos

load_photos(group: Group) -> Photos

Read photos written by save_photos, each image as the bytes it was saved with.

save_run_log_extract

save_run_log_extract(extract: RunLogExtract, group: Group) -> None

Write a RunLogExtract into group: the snapshot's JSON Lines whole, in a dataset (it can pass the 64 KiB an attribute holds), and what it was taken from as attributes. The log's path is stored relative to the project file when the log is in the file's folder or one beneath it (run_log_extract.stored_path), so a project moved with its log still finds it.

load_run_log_extract

load_run_log_extract(group: Group) -> RunLogExtract

Read a RunLogExtract written by save_run_log_extract. A log path stored relative to the project file is resolved against where the file is now (run_log_extract.resolved_path).

save_matches

save_matches(matches: MatchedModes, group: Group) -> None

Write matched modes into group: the two shape sets' names and geometries as attributes, the pairs as an (n, 2) integer array and their MACs as committed.

load_matches

load_matches(group: Group) -> MatchedModes

Read matched modes written by save_matches; an empty geometry name reads back as None.

save_sine_specification

save_sine_specification(spec: SineSweepSpecification, group: Group) -> None

Write a sine sweep specification into group, one subgroup per tone: its breakpoints with the sweep law of each segment, and its bands where it has them.

load_sine_specification

load_sine_specification(group: Group) -> SineSweepSpecification

Read a sine sweep specification written by save_sine_specification, its tones in tone_order's order; an empty unit reads back as None, undeclared.

save_sine_levels

save_sine_levels(levels: SineLevelSet, group: Group) -> None

Write a sine level set into group, one subgroup per tone, each in the ordinary data layout, since the set only groups the levels.

load_sine_levels

load_sine_levels(group: Group) -> SineLevelSet

Read a sine level set written by save_sine_levels, each tone's level by load_data.

save_streamed_history

save_streamed_history(history: StreamedHistory, group: Group) -> None

Write a StreamedHistory into group in the layout save_data writes, the abscissa and ordinate filled block by block, so memory holds one block at a time. The arrays are written plainly (uncompressed, unchunked) whatever the save asks, so a large one is mapped when it is read (_read_array).

save_run_record

save_run_record(record: RunRecord, group: Group) -> None

Write a RunRecord into group: its identity as attributes, each JSON member as one UTF-8 string dataset (they pass the 64 KiB an attribute holds), the log as JSON Lines, the law file's bytes verbatim, and the arrays of results no analysis class holds in numbered subgroups, since a result's name is free text.

load_run_record

load_run_record(group: Group) -> RunRecord

Read a RunRecord written by save_run_record.

save_test_setup

save_test_setup(setup: TestSetup, group: Group) -> None

Write a TestSetup into group: its module, protocol, title and origin kind as attributes, and its configuration, channel table, origin and notes each as one UTF-8 string dataset, the first three as JSON.

load_test_setup

load_test_setup(group: Group) -> TestSetup

Read a TestSetup written by save_test_setup.

load_scan

load_scan(group: Group) -> Geometry

Read a scan/ group as a geometry. Schema 5 stored measured points as an object of their own for a few days in November 2026; they are a geometry now (io.point_files.points_geometry), and a file that holds the old group opens as one. Nothing writes the group.

schema_for

schema_for(kinds: Iterable[str], references: bool = False, measured_points: bool = False) -> int

The schema a file holding objects of kinds is stamped with: the earliest that holds everything in it.

Parameters:

Name Type Description Default
kinds iterable of str

The kinds of the objects in the file, held or referred to.

required
references bool

Whether any object is held by reference to another file.

False
measured_points bool

Whether any geometry in the file holds measured points.

False

Returns:

Type Description
int

TIME_COMPARISON_SCHEMA when any is a time comparison, otherwise ELEMENT_SHAPES_SCHEMA when any is an element shape set, otherwise MEASURED_POINT_SCHEMA when a geometry holds measured points, otherwise TEST_SETUP_SCHEMA when any is a test setup, otherwise RUN_RECORD_SCHEMA when any is a run record, otherwise REFERENCE_SCHEMA for a file with references, otherwise BASE_SCHEMA.

hforge_path

hforge_path(path: str | PathLike) -> str

path with .hforge added when it does not end in it. A .vdyn path is refused: .vdyn files are opened, never written.

save

save(obj: Any, path: str | PathLike, compress: bool = False) -> None

Save one Hertzforge object to a .hforge (HDF5) file.

Raises TypeError for an object of a kind the format does not hold, and ValueError for a .vdyn path.

Parameters:

Name Type Description Default
obj object

The object to save.

required
path str or PathLike

Where; .hforge is added when the suffix is not there.

required
compress bool

Write the large arrays with gzip (compressed), for archiving.

False

Returns:

Type Description
None

save_into

save_into(obj: Any, f: File) -> None

Write one object into an open, empty HDF5 file.

This is save without opening the file, so that other formats (io.matlab, io.escdf_objects) can write the same layout into memory and store it inside their own files.

fingerprint

fingerprint(obj: Any) -> str

A digest of everything saving obj would write, with each mapped array named by where it is mapped rather than read.

Two fingerprints of one object differ when anything a save would write has changed: a unit, a name, a value in memory, or an array replaced by another. A project compares them to tell an object it holds by reference that is still the one in the other file from one edited since, which a reference would lose. A mapped array costs nothing here, so a run of any size is fingerprinted in the time its small fields take. Within one session only: the mapping's address is part of the name.

What it cannot see is a value changed inside a mapped array in place, since the array is named, not read. The core never does that without also changing a unit or a name (DataArray.define_units rescales in place and records the unit); a script that writes into a referenced run's samples should copy the array first.

object_sizes

object_sizes(path: str | PathLike) -> dict[str, tuple[str, int]]

{object name: (kind, bytes stored)} for the objects in a .hforge file, with '' as the name of a file's single object. An object the file itself holds by reference stores nothing.

save_test

save_test(path: str | PathLike, name: str, objects: Mapping[str, Any], active_geometry: str | None = None, project_type: str | None = None, object_groups: Sequence[Mapping[str, Any]] | None = None, provenance: Mapping[str, Any] | None = None, data_index: Sequence[Mapping[str, Any]] | None = None, compress: bool = False, projections: Sequence[Mapping[str, Any]] | None = None, references: Mapping[str, Reference] | None = None) -> None

Save a whole test, every named object, to one .hforge file.

Objects go in numbered groups with the name as an attribute, so a name may contain anything h5py would read as a path. objects maps each name to its object, in order. object_groups is the object groups, each a mapping with its members (object names); provenance records how each derived object was computed. Both are stored as JSON. data_index is the project's data index, its entries as plain values (DataIndex.records), stored as JSON in a data_index dataset at the root when there are any. .hforge is added to path when it is not there, and a .vdyn path raises ValueError. compress writes the large arrays with gzip (compressed), for archiving.

references are the objects written as references to other files rather than copied, by name (Reference): a name in objects is written as its reference in its place, and any other is written after the objects, as a reference kept for an object that is not loaded. A file with any reference is stamped schema 2, and one without, schema 1.

save_test_into

save_test_into(f: File, name: str, objects: Mapping[str, Any], active_geometry: str | None = None, project_type: str | None = None, object_groups: Sequence[Mapping[str, Any]] | None = None, provenance: Mapping[str, Any] | None = None, data_index: Sequence[Mapping[str, Any]] | None = None, references: Mapping[str, Reference] | None = None, projections: Sequence[Mapping[str, Any]] | None = None) -> None

save_test into an open, empty HDF5 file (see save_into). References are written relative to the folder the file is in.

load

load(path: str | PathLike, progress: Callable[[int, int], None] | None = None) -> Any

Load a .hforge or .vdyn file: the object it holds, or a whole test.

The stamp inside the file decides how it is read, not the suffix.

For a whole test, progress is called as (objects loaded, objects in the file), once at the start with 0 and once per object, because a large project can take minutes to load and only the reader knows how far along it is. For a single-object file it is not called, since loading one object is a single step.

Parameters:

Name Type Description Default
path str or PathLike

The .hforge or .vdyn file.

required
progress callable

Called as progress(loaded, total), once up front and once per object.

None

Returns:

Type Description
object

The object the file holds, or a Project for a whole test.

Raises:

Type Description
ValueError

When the file has neither the .hforge nor the .vdyn stamp, was written with a newer schema, or holds nothing this reader recognizes.

load_from

load_from(f: File, progress: Callable[[int, int], None] | None = None, path: str = '') -> Any

load from an open HDF5 file (see save_into). path names the file in error messages.