openPMD backend§
Available file types§
At the moment, ozzy can read openPMD files in HDF5 format, whether with group-, file- or variable-based iteration encoding.
Default metadata§
The metadata from openPMD files is mostly converted into xarray attrs, while unit-related metadata is also used to rescale the actual data.
The backend reads metadata from two places:
openpmd_viewer.OpenPMDTimeSeries, especiallyfields_metadataand themetadatareturned byget_field(...).- Raw HDF5 attributes via
h5py
For field data, unitSI is used to rescale field values, timeOffset to shift t, and gridUnitSI / gridUnitSIPerDimension to rescale spatial coordinates. Then each data variable, or DataArray, gets a TeX label, compact display units derived from unitDimension, and selected attributes like geometry, type, geometryParameters, fieldSmoothing, gridGlobalOffset, plus theta_mode for geometries with azimuthal mode decomposition.
For particle data, metadata is collected from the attributes both at particle and species level. These attributes are used for weighting correction, unitSI conversion, labels and units. The dataset for each species will contain two additional attributes: species_name and unique_pids. Particle id, when present, is renamed to pid.
Entry-point read function§
read
§
read(
files,
records=None,
separate_theta_modes=False,
**kwargs
)
Read selected records from openPMD files into a Dataset.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
list[str]
|
Paths to the openPMD files to read. |
required |
|
str, list[str], or None
|
Records to read from the files. Accepted values are:
If |
None
|
|
bool
|
Whether to keep each azimuthal mode separate for each data variable when reading grid-based data in geometries with azimuthal mode decomposition. If |
False
|
Returns:
| Type | Description |
|---|---|
Dataset
|
Dataset containing the requested openPMD records. If no files are provided, or the files cannot be opened, an empty dataset is returned. |
Raises:
| Type | Description |
|---|---|
NotImplementedError
|
If the files appear to be in ADIOS2 format, identified by the |
ValueError
|
If |
Examples:
Read all grid-based variables
ds = ozzy.open("openpmd", files, records="fields")
# ds is an xarray.Dataset containing all available grid-based variables.
Read one particle species
ds_electrons = ozzy.open("openpmd", files, records="electrons")
# ds_electrons is an xarray.Dataset containing particle data for the
# `electrons` species, if that species exists in the files.