How to read individual frame from a NeXus file_127565846 - Gumtree/gumtree GitHub Wiki
Created by Tony Lam, last modified on Aug 12, 2009
The following Python code shows how to read a NeXus file with nFrame x ySize x xSize dimension dataset. It will print each frame as a single dimensional array with size = ySize x xSize.
# Read file
filename = 'C:\\Data\\ECH0002305.nx.hdf'
# Get dataset
dataset = Factory.getDataset(File(filename).toURI());
# Get root
rootGroup = dataset.getRootGroup();
# Get the first data group
dataGroup = NexusUtils.getNexusData(NexusUtils.getNexusEntryList(rootGroup).get(0))
# Copy to plot
plot = PlotFactory.copyToPlot(dataGroup, 'data', StaticDefinition.getDataDimensionType('mapset'))
# Slice into frames
frames = PlotUtil.slice(plot)
# First frame
frame = frames.get(0)
# Get signal data in array form
data = frame.findSignalArray()
for i in xrange(0, data.getShape()[1]):
print data.slice(0, i).toString()
Document generated by Confluence on Apr 01, 2015 00:11