visualdynamics.io.escdf¶
escdf
¶
The Engineering Sciences Common Data Format, read and written by its specification.
ESCDF (github.com/sandialabs/Engineering-Sciences-Common-Data-Format,
BSD-3-Clause) is one HDF5 file: metadata groups at the root — a
geometry, a channel table, a set of parameters — and an activities
group with one group per test or analysis, holding the results it
produced and a parameters list naming the metadata it links to. Every
dataset is a group stamped with the name of its specification, a
descriptive name and a version, and carries one HDF5 dataset per
property, each stamped with its type. What the types are is written in
plain-text specification files, one per type, and those files are the
standard: a reader that parses them reads every type there is, and a
type added tomorrow is a file added tomorrow. The files ship here as
package data (escdf_specifications/, with their license), and this
module reads them the way the reference implementation does, from the
grammar its documentation states — and was held to the reference's own
files, both ways, as it was written (2026-09-30; PLAN.md "ESCDF: import
and export first").
What this module is: the generic layer. Specification is a parsed
file; Dataset is one group's worth of values against its
specification, validated the way the reference validates — every
property named, every shared dimension the same size wherever it
appears, one choice of every either-or group, an enumeration honored —
and File is the whole file with its activities. read and write
move a File to and from disk on h5py. What it is not: the mapping
from these to Visual Dynamics' own objects, which is escdf_objects.
The on-disk conventions, as measured from files the reference wrote:
strings are variable-length UTF-8, a scalar string a zero-dimensional
dataset; bytes are variable-length uint8; a variable_length property
is a one-dimensional dataset of variable-length rows of its type;
numbers are the type the specification names, u8 meaning eight
bytes, so uint64, and c16 complex128; every property dataset
carries a data_type attribute naming that type; every group carries
_specification_name, _descriptive_name and _version (three
integers); an activity group carries activity_name and
activity_date (ISO 8601, UTC) and a parameters string dataset of
the metadata names it links to; the file carries created_by and
created_date. A choice group is written as whichever alternative was
chosen, under the shared property name, and read back by which shape
and type is found.
Classes:
| Name | Description |
|---|---|
Property |
One property of a specification: its name, type, shape and options. |
Specification |
One parsed specification file. |
Dataset |
One dataset: a group's values against its specification. |
Activity |
One activity: a test or an analysis, its results and the metadata |
File |
A whole file: who made it and when, the metadata at its root, and |
Functions:
| Name | Description |
|---|---|
valid_identifier |
The format's name for a group: ASCII letters, digits and |
specifications |
Every type the vendored specification files define, by name, |
write |
Write a |
read |
Read an ESCDF file whole: every dataset against its |
Classes¶
Property
dataclass
¶
Property(name: str, dtype: str, shape: tuple[str | int, ...] = (), optional: bool = False, variable_length: bool = False, enum: str | None = None, regex: str | None = None, choice: tuple[str, str] | None = None)
One property of a specification: its name, type, shape and options.
shape is the specification's own words: named dimensions
('num_nodes'), literal sizes (3), or () for a scalar. choice is
(group, alternative) for a property in an either-or group, where
exactly one alternative of the group is written.
Attributes:
| Name | Type | Description |
|---|---|---|
key |
str
|
What the on-disk dataset is called: the name, shared by the |
Specification
dataclass
¶
Specification(name: str, version: tuple[int, int, int], extends: str | None, properties: list[Property] = list(), enumerations: dict[str, list[str]] = dict(), doc: str = '', _parents: dict[str, Specification] = dict())
One parsed specification file.
Attributes: name: The type's name, the file's first word. version: Three integers from the first line's 'vX.Y.Z'. extends: The type this one inherits from, or None. properties: This file's own properties, in order. enumerations: Each enumeration's allowed values. doc: The prose between the header and the properties block.
Methods:
| Name | Description |
|---|---|
all_properties |
Every property, inherited ones first, a child's redefinition |
is_a |
Whether this type is |
Methods:¶
all_properties
¶
all_properties() -> list[Property]
Every property, inherited ones first, a child's redefinition
of a parent's name replacing the parent's (a data_type that
narrows its enumeration, as response_spectrum does).
Source code in src/visualdynamics/io/escdf.py
is_a
¶
Whether this type is name or extends it.
Source code in src/visualdynamics/io/escdf.py
Dataset
dataclass
¶
Dataset(name: str, kind: str, descriptive_name: str = '', values: dict[str, Any] = dict(), version: tuple[int, int, int] | None = None, extras: dict[str, Any] = dict())
One dataset: a group's values against its specification.
Attributes:
name: The group's name, a valid identifier.
kind: The specification's name ('geometry', 'data', ...).
descriptive_name: Free text, the reference's _descriptive_name.
values: Property name to value. A string property is a str or
an array of str; a bytes property a list of uint8 arrays; a
variable-length property a list of arrays; numbers arrays.
version: The specification version the group claims, or None
to write the vendored specification's own.
extras: Datasets in the group the specification does not name,
kept as read so a re-export loses nothing.
Methods:
| Name | Description |
|---|---|
problems |
What keeps this dataset from validating against its |
Methods:¶
problems
¶
What keeps this dataset from validating against its specification, as the reference would refuse it: a required property missing, a choice group with none or two alternatives chosen, a shared dimension of two sizes, a type the value cannot take, an enumeration or pattern not honored. Empty when valid; an unknown type is a problem of its own.
Returns:
| Type | Description |
|---|---|
list of str
|
|
Source code in src/visualdynamics/io/escdf.py
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 | |
Activity
dataclass
¶
Activity(name: str, descriptive_name: str = '', date: datetime | None = None, links: list[str] = list(), data: dict[str, Dataset] = dict())
One activity: a test or an analysis, its results and the metadata it links to.
File
dataclass
¶
File(created_by: str = '', created_date: datetime | None = None, metadata: dict[str, Dataset] = dict(), activities: dict[str, Activity] = dict())
A whole file: who made it and when, the metadata at its root, and its activities.
Methods:
| Name | Description |
|---|---|
problems |
Every dataset's problems, each prefixed with where it is, and |
Methods:¶
problems
¶
Every dataset's problems, each prefixed with where it is, and a link that names no metadata.
Source code in src/visualdynamics/io/escdf.py
Functions:¶
valid_identifier
¶
The format's name for a group: ASCII letters, digits and
underscores, starting with a letter — whitespace to underscores,
anything else dropped, prefix in front if what is left does not
start with a letter (the reference's own repair, so a name repaired
here is the name it would give).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Any text. |
required |
prefix
|
str
|
What to put in front when the repaired name starts with a digit or is empty. |
'item_'
|
Returns:
| Type | Description |
|---|---|
str
|
|
Source code in src/visualdynamics/io/escdf.py
parse_specification
¶
parse_specification(text: str) -> Specification
A specification file's text, parsed by the documented grammar.
The first line is 'name - vX.Y.Z', underlined; an 'extends: other'
line names the parent; prose follows until a 'properties' header;
each property line is 'name - type [- shape [- options]]', the
fields split on ' - ', the shape comma-separated names or numbers or
the word 'scalar', the options comma-separated from 'optional',
'variable_length', 'enum:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The file's contents. |
required |
Returns:
| Type | Description |
|---|---|
Specification
|
|
Source code in src/visualdynamics/io/escdf.py
specifications
¶
specifications() -> dict[str, Specification]
Every type the vendored specification files define, by name, each knowing its parents.
Returns:
| Type | Description |
|---|---|
dict of str to Specification
|
|
Source code in src/visualdynamics/io/escdf.py
write
¶
write(file: File, path: str | PathLike) -> None
Write a File as an ESCDF file, validating first.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
file
|
File
|
What to write; |
required |
path
|
path - like
|
The file to write; replaced if it exists. |
required |
Source code in src/visualdynamics/io/escdf.py
read
¶
read(path: str | PathLike) -> File
Read an ESCDF file whole: every dataset against its specification, unknown types and undefined properties kept as they are.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
path - like
|
The file. |
required |
Returns:
| Type | Description |
|---|---|
File
|
|
Source code in src/visualdynamics/io/escdf.py
sniff
¶
An HDF5 file with an activities group and the file's own
creation stamps.
Source code in src/visualdynamics/io/escdf.py
datasets_of
¶
Every dataset in the file that is kind or extends it, with the
activity it belongs to (None for metadata), in file order.