Page History
...
- Open file, get dataset, get array for current event, and close file:
Code Block |
---|
file = h5py.File(hdf5_file_name, 'r') # Open hdf5 file in read-only mode dataset = file[dataset_name] arr1ev = dataset[event_number] file.close() |
where we assume that all necessary parameters were defined earlier, for example
Code Block |
---|
hdf5_file_name = '/reg/d/psdm/XPP/xppcom10/hdf5/xppcom10-r0546.h5' dataset_name = '/Configure:0000/Run:0000/CalibCycle:0000/Camera::FrameV1/XppSb4Pim.1:Tm6740.1/image'] event_number = 5 |
The arr1ev
is returned as a NumPy
object. There are many methods which allow to manipulate with this object. For example, one can
- print array shape and content:
Code Block |
---|
print 'arr1ev.shape = dataset[eventNumber]', arr1ev.shape file.close()print 'arr1ev =\n', arr1ev |
Advanced operations
- Get item attributes
- Get group name and the list of daughters
- Check if the HDF5 item is "File", "Group", or "Data"
Code examples
- Example 1, basic operations:
Code Block |
---|
#!/usr/bin/env python import h5py import numpy as np eventNumber = 5 file = h5py.File('/reg/d/psdm/XPP/xppcom10/hdf5/xppcom10-r0546.h5', 'r') dataset = file['/Configure:0000/Run:0000/CalibCycle:0000/Camera::FrameV1/XppSb4Pim.1:Tm6740.1/image'] arr1ev = dataset[eventNumber] file.close() print 'arr1ev.shape =', arr1ev.shape print 'arr1ev =\n', arr1ev |
- Example 2, advanced operations:
Code Block |
---|
Needs to be added
|
Overview
Content Tools