Skip to content

Instantly share code, notes, and snippets.

@DanPorter
Created August 14, 2023 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DanPorter/eb37c0683d27e9b5c77e25af996e539f to your computer and use it in GitHub Desktop.
Save DanPorter/eb37c0683d27e9b5c77e25af996e539f to your computer and use it in GitHub Desktop.
Read I16 Nexus Files in Python using h5py
# module load python/3
# or pip install h5py (comes with anaconda python)
import h5py
with h5py.File('example_nexus/794932.nxs', 'r') as nx:
print(nx['entry1']['measurement'].keys())
dataset = nx['entry1/measurement/eta']
print(dataset)
values = nx['entry1/measurement/eta'][()]
scan_command = nx['entry1/scan_command']
print(scan_command)
detector_dataset = nx['entry1/pil3_100k/data']
print(detector_dataset)
image = detector_dataset[len(detector_dataset)//2]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment