Page History
...
- Flexibility; HDF5 file has indexed structure, that means direct access to any data of any file from your code.
Python
is a high-level scripting language allows to write transparent and compact code based on well-elaborated standard libraries.- In general, code in
Python
works slow comparing to C++, but there are libraries likeNumPy
written on C++, which solve this problem for manipulation with large arrays.
...
Similar code plots the dataset as an image or histogram using the matplotlib library
Code Block |
---|
#!/usr/bin/env python import h5py import numpy as np import matplotlib.pyplot as plt def plotImage(arr) : fig = plt.figure(figsize=(85,85), dpi=80, facecolor='w',edgecolor='w',frameon=True) imAx = plt.imshow(arr, origin='lower', interpolation='nearest') fig.colorbar(imAx, pad=0.01, fraction=0.1, shrink=1.00, aspect=20) def plotHistogram(arr) : fig = plt.figure(figsize=(5,5), dpi=80, facecolor='w',edgecolor='w',frameon=True) plt.hist(arr.showflatten(), bins=100) 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] plotImage(arr1ev) plotHistogram(arr1ev) plt.show() file.close() |
Example 2: Extract and print the time variables
...
Overview
Content Tools