[Nexus] How to access data

Tim Gruene tgruene at gwdg.de
Thu Jun 12 21:13:09 BST 2014


Dear all,

I have a file in Nexus format (HDF v.5) and I would like to access the
data at
/run_466/tof_detector_1/single_events_time
/run_466/tof_detector_1/single_events_x
/run_466/tof_detector_1/single_events_y

from a C or C++ program.
So far I got stepwise into the groups so that
	NXopendata (myfile, (dir_tof1 + "/single_events_x").c_str());
returned NX_OK.

At this point I don't know how to proceed. I looked at the online API
documentation and the example file napi_test.c

I assume for the 3x1.5 million numbers, the functionNXgetslab would be
helpful. In napi_test.c the calls are:
 NXgetslab (fileid, data_buffer, slab_start, slab_size)

the data_buffer is the memory block where the data get stored, I assume.
It was allocated with
NXmalloc ((void **) &data_buffer, NXrank, NXdims, NXtype)

Question 1: does this allocate the memory for the entire data? If so,
what if there is too much data for the RAM of my computer?

I also don't understand the roles of slab_start and slab_size. In
napi_test.c, these are two-dimensional arrays.

Question 2: Is it correct that for my one-dimensional data
"single_events_time" I require a one-dimesional
	int slab_start[1], slab_size[1];
respectively?

Question 3: I would think that NXgetslab reads data according to the
rank of the data beginning at entries number slab_start[0],
slab_start[1], ... and reads a total number of slab_size[0],
slab_size[1], ... into memory at once. Is this correct?

Question 4: Is there a simple way to access the one-dimensional data  in
single_events_time, single_events_x, and single_events_y?
I used the DUMP command in the utility nxbrowse in order to create plain
text files containing the data just to test my ideas, which work
greatly. So all I need is a C-version of dumping the data out of the
nexus-container.

I greatly appreciate any help, maybe a link to a decent tutorial (for C
or C++) on how to read nexus format. Many of the tutorials start with
how to write nexus, which is confusing to me and something I don't need.

Regards,
Tim Gruene
-- 
Dr Tim Gruene
Institut fuer anorganische Chemie
Tammannstr. 4
D-37077 Goettingen

GPG Key ID = A46BEE1A


More information about the NeXus mailing list