h5storage
HDF5 storage macros
- class macro(param_def=None, result_def=None, env=None, hints=None, interactive=None)[source]
Class designed to decorate a python function to transform it into a macro. Examples:
@macro() def my_macro1(self): self.output("Executing %s", self.getName()) @macro([ ["moveable", Type.Moveable, None, "motor to watch"] ]) def where_moveable(self, moveable): self.output("Moveable %s is at %s", moveable.getName(), moveable.getPosition())
- class NXscanH5_FileRecorder(filename=None, macro=None, overwrite=False, **pars)[source]
Saves data to a nexus file that follows the NXscan application definition (This is a pure h5py implementation that does not depend on the nxs module)
- h5_start_session(self, swmr_mode)[source]
Start write session for HDF5 scan file(s)
Open HDF5 scan files in write mode and keep them for the needs of recorders until the session is closed by
h5_end_session
.The session file path is obtained by inspecting ScanDir and ScanFile environment variables. If you want to use a different file path, use
h5_start_session_path
Optionally, enable SWMR mode (either with
swmr_mode
parameter or withScanH5SWMR
environment variable)
- h5_start_session_path(self, path, swmr_mode)[source]
Start write session for HDF5 file path
Open HDF5 files in write mode and keep them for the needs of recorders until the session is closed by
h5_end_session
.Optionally, enable SWMR mode (either with
swmr_mode
parameter or withScanH5SWMR
environment variable)
- h5_end_session(self)[source]
End write session for HDF5 scan file(s)
Close previously opened HDF5 scan files with the use
h5_start_session
orh5_start_session_path
.The session file path is obtained by inspecting ScanDir and ScanFile environment variables. If you want to close a different file path, use
h5_end_session_path
- h5_end_session_path(self, path)[source]
End write session for HDF5 file path
Close previously opened HDF5 scan files with the use
h5_start_session
orh5_start_session_path
.
- h5_write_session(macro, path=None, swmr_mode=False)[source]
Context manager for HDF5 file write session.
Maintains HDF5 file opened for the context lifetime. Optionally, open the file as SWMR writer.
Resolve configured H5 scan file names by inspecting ScanDir and ScanFile environment variables.
Example of macro executing multiple scans within the same write session:
@macro() def experiment(self): with h5_write_session(macro=self, swmr_mode=True): for i in range(10) self.execMacro("ascan", "mot01", 0, 10, 10, 0.1)