visualdynamics.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 np.load):
- 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);
- 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 |
|---|---|
load |
Read an sdynpy geometry file. |
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.
Source code in src/visualdynamics/io/sdynpy_npz.py
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 the coherent form of 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 run, and not as elements.