pyoptics.fdtd.storage

Saving and loading monitor data.

Results are dictionaries of NumPy arrays plus scalar attributes. They are written to compressed .npz files (no extra dependency) or, for files ending in .h5/.hdf5, to HDF5 with gzip compression (needs the optional h5py, pip install pyoptics[hdf5]). HDF5 also allows streaming snapshot frames to disk during a run (Snapshots(path=…)).

Classes

FrameWriter

Appends frames to a growing, chunked and gzip compressed HDF5 dataset (used by Snapshots(path=...)).

Functions

load

Read a file written by save(); returns (arrays, attrs).

save

Write a dict of arrays (and scalar/string attributes) to .npz or HDF5.

pyoptics.fdtd.storage.save(path, arrays, attrs=None)[source]

Write a dict of arrays (and scalar/string attributes) to .npz or HDF5.

pyoptics.fdtd.storage.load(path)[source]

Read a file written by save(); returns (arrays, attrs).

class pyoptics.fdtd.storage.FrameWriter(path, frame_shape, dtype, coords, attrs)[source]

Bases: object

Appends frames to a growing, chunked and gzip compressed HDF5 dataset (used by Snapshots(path=…)).