hertzforge.io.escdf_objects¶
escdf_objects
¶
Write a project to an ESCDF file and read one back, with each object written both as the standard's own type and whole, as Hertzforge keeps it.
The standard has types for what a test produces: geometry,
channel_table, data, response_spectrum and mode. Each object of
those kinds is written as that type, so any reader of the format gets
the nodes, channels, records and modes from the standard fields alone.
The standard has no fields for much of what a project holds: element
blocks and their properties, coordinate systems, the processing record
and provenance, reports, matched modes, sine and random specifications,
and a geometry's view. Those are kept in the attachments every group
has, one attachment per object, holding the object in its .hforge
layout (written by io.native into memory). A file written here
therefore reads back complete, and a reader that does not know the
attachment can ignore it. A report is attached twice: rendered as a
self-contained HTML page, and as its definition, so it opens again
editable.
Values in the standard fields are written in the units their labels
name. A geometry's positions are in its declared length unit
(position_units), each data record is in its own declared unit
(ordinate_unit), and mode shape coefficients are normalized against
the declared mass unit (modal_mass_unit). An object whose units are
not defined is written as stored, with the unit left blank. Abscissas
are written in seconds or hertz.
An activity is an object group: the group's results (data and mode shapes) are the activity's data, and the geometry and channel tables it uses are metadata at the root, linked from the activity. A named group becomes an activity with that name; an unnamed one takes the name of its geometry, or of its first member. Objects in no group form one more activity. Photos, reports, matched modes and sine specifications are metadata as well, written as parameter sets and linked to the activity whose group holds them, because the standard puts anything that is not a result at the root.
A file this program did not write is read from the standard fields: a geometry's nodes, lines, elements and per-node directions (a node whose axes are not the global ones gets a coordinate system of its own), a data record's values and units, and a mode set's frequencies, damping and shapes. The declared units are applied on reading, so positions, records and shapes are converted from the units the file names. Unit strings are written with '^' for a power, as the format's examples spell them, and either '^' or '**' is read.
Functions:
| Name | Description |
|---|---|
handles |
True for a whole project, or for any one kind of object a project |
sniff |
True for an HDF5 file with an |
to_file |
A project as an ESCDF |
save |
Write a project, or one object as a project of one, as an ESCDF |
from_file |
A project from an ESCDF |
load |
Read an ESCDF file as a project (see |
Classes¶
Functions:¶
handles
¶
True for a whole project, or for any one kind of object a project holds.
sniff
¶
True for an HDF5 file with an activities group and a created_by
attribute (escdf.sniff). The suffix is not looked at.
to_file
¶
A project as an ESCDF File, ready for escdf.write.
Each object is written as the standard's type with the object whole
in an attachment, and each object group becomes an activity. The
project's name, object groups, provenance and settings go in a
parameter set at the root named hertzforge_project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project
|
Project
|
What to write. |
required |
created_by
|
str
|
The file's creator; the login name when left out. |
None
|
unit_system
|
UnitSystem
|
The system the reports are rendered in; SI when left out. It does not change the units of the standard fields, which are the objects' own declared units. |
None
|
Returns:
| Type | Description |
|---|---|
File
|
|
save
¶
save(obj: Any, path: str | PathLike, unit_system: Any = None, created_by: str | None = None, **_ignored: Any) -> None
Write a project, or one object as a project of one, as an ESCDF file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj
|
Project or object
|
What to write. |
required |
path
|
path - like
|
Where; |
required |
unit_system
|
UnitSystem
|
The system reports are rendered in; SI when left out. The standard fields are written in each object's declared units whatever this is. |
None
|
created_by
|
str
|
The creator recorded in the file; the login name when left out. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
|
from_file
¶
A project from an ESCDF File.
Each dataset becomes an object, built from its whole-object attachment when it has one and from the standard fields otherwise. A dataset whose type the specifications do not define is left out with a note. The project's own record, when the file has one, restores the object names, order, object groups and provenance; without it, each activity with two or more objects becomes an object group named for the activity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
File
|
As |
required |
Returns:
| Type | Description |
|---|---|
Project
|
|