Skip to content

Instantly share code, notes, and snippets.

@RobbieClarken
Created February 19, 2016 01:45
Show Gist options
  • Save RobbieClarken/1a3f32194f27623b9036 to your computer and use it in GitHub Desktop.
Save RobbieClarken/1a3f32194f27623b9036 to your computer and use it in GitHub Desktop.
import h5py
from epics import PV, caget
import time
camera_pv = PV('SR10BM02IMG01:DATA_MONITOR')
MAX_SAMPLES = 1000
WIDTH = 128
HEIGHT = 128
with h5py.File('camera-data.hdf5', 'w') as file:
dataset = file.create_dataset('injection-001',
shape=(MAX_SAMPLES, WIDTH, HEIGHT),
dtype='uint8',
chunks=(1, WIDTH, HEIGHT))
# Note: specifying the chunk size is necessary to keep the file size down
# Store metadata in attrs
dataset.attrs['SR03ID01:GAP_MONITOR'] = caget('SR03ID01:GAP_MONITOR')
dataset.attrs['SR05ID01:GAP_MONITOR'] = caget('SR05ID01:GAP_MONITOR')
dataset.attrs['SR13ID01:GAP_MONITOR'] = caget('SR13ID01:GAP_MONITOR')
# Collect camera data
for i in range(10):
dataset[i] = camera_pv.get(use_monitor=False).reshape(WIDTH, HEIGHT)
time.sleep(1)
dataset.resize(i + 1, axis=0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment