gwexpy.interop.openems_ο
Interoperate with openEMS field dump HDF5 files.
Interoperability with openEMS field dump HDF5 files.
openEMS writes electromagnetic field data via CSPropDumpBox.
The HDF5 layout is:
/Mesh/
x # 1-D node coordinates along x
y
z
/FieldData/
TD/ # time-domain dumps
<step_0> # 4-D array (Nx, Ny, Nz, 3) β 3 = x/y/z components
<step_1>
...
FD/ # frequency-domain dumps
f0_real # 4-D (Nx, Ny, Nz, 3)
f0_imag
f1_real
...
The DumpType value (set in the CSXCAD AddDump call) controls which physical
quantity is stored and in which domain. Only h5py is required; the openEMS
Python bindings are not needed.
HDF5 dataset attributesο
If time-domain datasets carry a "Time" attribute (float, seconds), the
returned axis0 uses those physical time values. If frequency-domain datasets
carry a "frequency" attribute (float, Hz), axis0 uses those physical
frequency values. Both fall back to integer indices when the attribute is
absent.
References
https://openems.de/index.php/HDF5_Field_Dumps.html
Functions
|
Read an openEMS field dump HDF5 file into a ScalarField or VectorField. |
- gwexpy.interop.openems_.from_openems_hdf5(cls: type, filepath: str | Path, *, dump_type: int = 0, timestep: int | None = None, frequency_index: int | None = None, component: Literal['x', 'y', 'z'] | None = None, unit: Any | None = None) ScalarField | VectorField[source]
Read an openEMS field dump HDF5 file into a ScalarField or VectorField.
openEMS dumps field data as HDF5 files containing mesh coordinates under
/Mesh/x,/Mesh/y,/Mesh/zand field values under/FieldData/TD(time domain) or/FieldData/FD(frequency domain). Each time step or frequency bin stores a 4-D array of shape(Nx, Ny, Nz, 3)where the last axis holds the x, y, z components.- Parameters:
cls (type) β
ScalarFieldorVectorFieldclass.filepath (str or Path) β Path to the HDF5 dump file.
dump_type (int, default 0) β
openEMS
DumpTypevalue used when the dump was configured. Determines the physical quantity and domain:0 β E-field, time domain
1 β H-field, time domain
10 β E-field, frequency domain
11 β H-field, frequency domain
20-22 β SAR (scalar, frequency domain)
timestep (int, optional) β For time-domain dumps: which step index to extract.
Noneloads all steps along axis 0.frequency_index (int, optional) β For frequency-domain dumps: which frequency index to extract.
Noneloads all frequencies along axis 0.component ({"x", "y", "z"}, optional) β Return a single vector component as
ScalarField.Nonereturns all three components asVectorField.unit (str or astropy.units.Unit, optional) β Override the physical unit. Defaults to the unit implied by dump_type (see
DUMP_TYPE_MAP).
- Returns:
ScalarField β When component is given, dump type is SAR, or cls is
ScalarField.VectorField β When component is
Noneand cls isVectorField.
- Raises:
ValueError β If the required field group is absent, or if a requested time step / frequency index does not exist.
ImportError β If
h5pyis not installed.
Examples
Read all components of a time-domain E-field dump:
>>> from gwexpy.fields import VectorField >>> vf = VectorField.from_openems_hdf5("e_dump.h5", dump_type=0)
Read only the z-component:
>>> from gwexpy.fields import ScalarField >>> sf = ScalarField.from_openems_hdf5("e_dump.h5", component="z")