hertzforge.io.sdynpy_npz¶
sdynpy_npz
¶
Read and write sdynpy geometry files (.npz).
The format is a NumPy .npz archive of structured arrays (self-describing;
read with plain_numpy, because the connectivity columns are pickled):
- node: id, coordinate (3,), color, def_cs, disp_cs;
- coordinate_system: id, name, color, cs_type, matrix (4, 3), where rows 0-2 are the rotation and row 3 is the origin (a length);
- traceline: id, color, description, connectivity (an object array of node id arrays, in which 0 lifts the pen, as in a universal file);
- element: id, type (the universal file dataset 2412 descriptor code), color, connectivity (an object array).
'node' and 'coordinate_system' are required; 'traceline' and 'element'
may be absent, as in a point cloud. Each node's coordinates are read in
the coordinate system it is defined in and converted to global. The
file has no units: length_unit declares them at import, and without
it the geometry is unit-less.
Functions:
| Name | Description |
|---|---|
sniff |
True for an |
load |
Read an sdynpy geometry file. |
handles |
True for a Geometry, the one object this layout holds. |
save |
Write a geometry in the sdynpy .npz layout. |
Classes¶
Functions:¶
load
¶
load(path: str | PathLike, length_unit: str | None = None) -> Geometry
Read an sdynpy geometry file.
The file has no units; without length_unit the geometry imports
with the file's coordinates and the units can be defined later. The
elements are split into one element group per element family, and
each traceline id becomes one drawn line. Raises ValueError for a file
holding Python objects beyond the numbers and text of a connectivity.
save
¶
save(geometry: Geometry, path: str | PathLike, unit_system: UnitSystem | None = None) -> None
Write a geometry in the sdynpy .npz layout.
Coordinates are written in unit_system when
the geometry's units are defined, and as stored otherwise. The format
records no units either way, so the reader has to be told what they
are. Each node's coordinates are written in the coordinate system it
is defined in, its def_cs, as load reads them. Drawn lines
are written as tracelines, one row per line with a 0 between its
runs, and not as elements. A drawn line through a node numbered 0
cannot be written, because the layout reads that 0 as a break.