forked from nexusformat/definitions
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4ceed2d
Showing
7,953 changed files
with
4,903,268 additions
and
0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
manual.nexusformat.org |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
manual.nexusformat.org |
53 changes: 53 additions & 0 deletions
53
docs/SPM_domain_app_def/_downloads/0a877a94f6f32b982b9a0c74073f6f01/write_nexus_file2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import numpy as np | ||
from nexusformat.nexus import * | ||
|
||
|
||
def write_nexus_file(fname, image, md={}): | ||
""" | ||
write the image to a NeXus HDF5 data file | ||
Parameters | ||
---------- | ||
fname : str | ||
name of the file (relative or absolute) to be written | ||
image : numpy array | ||
the image data | ||
md : dictionary | ||
key: value where value is something that can be written by h5py | ||
(such as str, int, float, numpy array, ...) | ||
""" | ||
nx = NXroot() | ||
nx['/entry'] = NXentry(NXinstrument(NXdetector())) | ||
nx['entry/instrument/detector/image'] = NXfield(image, units='counts', | ||
compression='gzip') | ||
nx['entry/data'] = NXdata() | ||
nx['entry/data'].makelink(nx['entry/instrument/detector/image']) | ||
nx['entry/data'].nxsignal = nx['entry/data/image'] | ||
|
||
if len(md) > 0: | ||
# /entry/instrument/metadata (optional, for metadata) | ||
metadata = nx['/entry/instrument/metadata'] = NXcollection() | ||
for k, v in md.items(): | ||
metadata[k] = v | ||
|
||
nx.save(fname, 'w') | ||
|
||
|
||
if __name__ == "__main__": | ||
"""demonstrate how to use this code""" | ||
import epics | ||
prefix = "13SIM1:" | ||
img = epics.caget(prefix+"image1:ArrayData") | ||
size_x = epics.caget(prefix+"cam1:ArraySizeX_RBV") | ||
size_y = epics.caget(prefix+"cam1:ArraySizeY_RBV") | ||
# edit the full image for just the binned data | ||
img = img[:size_x*size_y].reshape((size_x, size_y)) | ||
|
||
extra_information = dict( | ||
unique_id = epics.caget(prefix+"image1:UniqueId_RBV"), | ||
size_x = size_x, | ||
size_y = size_y, | ||
detector_state = epics.caget(prefix+"cam1:DetectorState_RBV"), | ||
bitcoin_value="15000", | ||
) | ||
write_nexus_file("example.h5", img, md=extra_information) |
49,524 changes: 49,524 additions & 0 deletions
49,524
docs/SPM_domain_app_def/_downloads/0d9b3db52a075e9d9b6a1a0457a842ba/nxdl_vocabulary.json
Large diffs are not rendered by default.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
..._domain_app_def/_downloads/0ff27da7c434704769b51d02fbf4db92/external_counts_structure.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
entry:NXentry | ||
@NX_class = "NXentry" | ||
instrument:NXinstrument | ||
@NX_class = "NXinstrument" | ||
detector:NXdetector | ||
@NX_class = "NXdetector" | ||
counts:NX_INT32[31] = [1037, 1318, 1704, '...', 1321] | ||
@units = "counts" | ||
two_theta:NX_FLOAT64[31] = [17.92608, 17.92591, 17.92575, '...', 17.92108] | ||
@units = "degrees" | ||
@file = "external_angles.hdf5" | ||
@path = "/angles" |
15 changes: 15 additions & 0 deletions
15
docs/SPM_domain_app_def/_downloads/1937642b9af657d29b9267f91b81136f/attributes.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" standalone="no" ?> | ||
<!-- Attributes --> | ||
<Attributes | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://github.com/areaDetector/ADCore/blob/master/iocBoot/NDAttributes.xsd" | ||
> | ||
<Attribute name="AcquireTime" type="EPICS_PV" source="13SIM1:cam1:AcquireTime" dbrtype="DBR_NATIVE" description="Camera acquire time"/> | ||
<Attribute name="ImageCounter" type="PARAM" source="ARRAY_COUNTER" datatype="INT" description="Image counter"/> | ||
<Attribute name="calc1_val" type="EPICS_PV" source="prj:userCalc1.VAL" datatype="DBR_NATIVE" description="some calculation result"/> | ||
<Attribute name="calc2_val" type="EPICS_PV" source="prj:userCalc2.VAL" datatype="DBR_NATIVE" description="another calculation result"/> | ||
<Attribute name="MaxSizeX" type="PARAM" source="MAX_SIZE_X" datatype="INT" description="Detector X size"/> | ||
<Attribute name="MaxSizeY" type="PARAM" source="MAX_SIZE_Y" datatype="INT" description="Detector Y size"/> | ||
<Attribute name="CameraModel" type="PARAM" source="MODEL" datatype="STRING" description="Camera model"/> | ||
<Attribute name="CameraManufacturer" type="PARAM" source="MANUFACTURER" datatype="STRING" description="Camera manufacturer"/> | ||
</Attributes> |
Binary file added
BIN
+6.24 KB
docs/SPM_domain_app_def/_downloads/1fd3c5bb8f3a7adb332aa2d8bce37b6f/external_angles.hdf5
Binary file not shown.
Binary file added
BIN
+51.2 KB
docs/SPM_domain_app_def/_downloads/2369107dda331106afc31515a2026299/mrinal_001.h5
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
docs/SPM_domain_app_def/_downloads/2d54d9af02ee715da23fed8d858526ba/simple_example_write1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Writes the simplest NeXus HDF5 file using h5py | ||
Uses method accepted at 2014NIAC | ||
according to the example from Figure 1.3 | ||
in the Introduction chapter | ||
""" | ||
|
||
from pathlib import Path | ||
|
||
import numpy | ||
|
||
from nexusformat.nexus import NXdata, NXentry, NXfield, nxopen | ||
|
||
filename = str(Path(__file__).absolute().parent.parent / "simple_example.dat") | ||
buffer = numpy.loadtxt(filename).T | ||
tthData = buffer[0] | ||
countsData = numpy.asarray(buffer[1], "int32") | ||
|
||
with nxopen("simple_example_write1.hdf5", "w") as f: # create the NeXus file | ||
f["Scan"] = NXentry() | ||
tth = NXfield(tthData, name="two_theta", units="degrees") | ||
counts = NXfield(countsData, name="counts", units="counts") | ||
f["Scan/data"] = NXdata(counts, tth) |
37 changes: 37 additions & 0 deletions
37
docs/SPM_domain_app_def/_downloads/3211ba74a45c7be2ed8549b5f33c6187/simple_example_write1.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Writes the simplest NeXus HDF5 file using h5py | ||
Uses method accepted at 2014NIAC | ||
according to the example from Figure 1.3 | ||
in the Introduction chapter | ||
""" | ||
|
||
from pathlib import Path | ||
import h5py | ||
import numpy | ||
|
||
filename = str(Path(__file__).absolute().parent.parent / "simple_example.dat") | ||
buffer = numpy.loadtxt(filename).T | ||
tthData = buffer[0] # float[] | ||
countsData = numpy.asarray(buffer[1], "int32") # int[] | ||
|
||
with h5py.File("simple_example_write1.hdf5", "w") as f: # create the HDF5 NeXus file | ||
# since this is a simple example, no attributes are used at this point | ||
|
||
nxentry = f.create_group("Scan") | ||
nxentry.attrs["NX_class"] = "NXentry" | ||
|
||
nxdata = nxentry.create_group("data") | ||
nxdata.attrs["NX_class"] = "NXdata" | ||
nxdata.attrs["signal"] = "counts" | ||
nxdata.attrs["axes"] = "two_theta" | ||
nxdata.attrs["two_theta_indices"] = [ | ||
0, | ||
] | ||
|
||
tth = nxdata.create_dataset("two_theta", data=tthData) | ||
tth.attrs["units"] = "degrees" | ||
|
||
counts = nxdata.create_dataset("counts", data=countsData) | ||
counts.attrs["units"] = "counts" |
Binary file added
BIN
+10.9 KB
docs/SPM_domain_app_def/_downloads/34d182b530d7f0d7c3133569078f47a4/external_counts.hdf5
Binary file not shown.
43 changes: 43 additions & 0 deletions
43
docs/SPM_domain_app_def/_downloads/36b2d63db078aaa74a2c739feae5e837/h5link.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
function h5link(filename, from, to) | ||
%H5LINK Create link to an HDF5 dataset. | ||
% H5LINK(FILENAME,SOURCE,TARGET) creates an HDF5 link from the | ||
% dataset at location SOURCE to a dataset at location TARGET. All | ||
% intermediate groups in the path to target are created. | ||
% | ||
% Example: create a link from /hello/world to /goodbye/world | ||
% h5create('myfile.h5','/hello/world',[100 200]); | ||
% h5link('myfile.h5','/hello/world','/goodbye/world'); | ||
% hgdisp('myfile.h5'); | ||
% | ||
% See also: h5create, h5read, h5write, h5info, h5disp | ||
|
||
% split from and to into group/dataset | ||
idx = strfind(from,'/'); | ||
from_path = from(1:idx(end)-1); | ||
from_data = from(idx(end)+1:end); | ||
idx = strfind(to,'/'); | ||
to_path = to(1:idx(end)-1); | ||
to_data = to(idx(end)+1:end); | ||
|
||
% open the HDF file | ||
fid = H5F.open(filename,'H5F_ACC_RDWR','H5P_DEFAULT'); | ||
|
||
% create target group if it doesn't already exist | ||
create_intermediate = H5P.create('H5P_LINK_CREATE'); | ||
H5P.set_create_intermediate_group(create_intermediate, 1); | ||
try | ||
H5G.create(fid,to_path,create_intermediate,'H5P_DEFAULT','H5P_DEFAULT'); | ||
catch | ||
end | ||
H5P.close(create_intermediate); | ||
|
||
% open groups and create link | ||
from_id = H5G.open(fid, from_path); | ||
to_id = H5G.open(fid, to_path); | ||
H5L.create_hard(from_id, from_data, to_id, to_data, 'H5P_DEFAULT','H5P_DEFAULT'); | ||
|
||
% close all | ||
H5G.close(from_id); | ||
H5G.close(to_id); | ||
H5F.close(fid); | ||
end |
11 changes: 11 additions & 0 deletions
11
...n_app_def/_downloads/3a18cf1e63a6e3f68fb400d21e68231d/simple_example_write1_structure.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Scan:NXentry | ||
@NX_class = "NXentry" | ||
data:NXdata | ||
@NX_class = "NXdata" | ||
@axes = "two_theta" | ||
@signal = "counts" | ||
@two_theta_indices = [0] | ||
counts:NX_INT32[31] = [1037, 1318, 1704, '...', 1321] | ||
@units = "counts" | ||
two_theta:NX_FLOAT64[31] = [17.92608, 17.92591, 17.92575, '...', 17.92108] | ||
@units = "degrees" |
54 changes: 54 additions & 0 deletions
54
docs/SPM_domain_app_def/_downloads/3b7dde73e3bfd8b7c7fe8278259ef911/simple_example_write2.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python | ||
""" | ||
Writes a simple NeXus HDF5 file using h5py with links | ||
according to the example from Figure 2.1 in the Design chapter | ||
""" | ||
|
||
from pathlib import Path | ||
import h5py | ||
import numpy | ||
|
||
filename = str(Path(__file__).absolute().parent.parent / "simple_example.dat") | ||
buffer = numpy.loadtxt(filename).T | ||
tthData = buffer[0] # float[] | ||
countsData = numpy.asarray(buffer[1], "int32") # int[] | ||
|
||
with h5py.File("simple_example_write2.hdf5", "w") as f: # create the HDF5 NeXus file | ||
f.attrs["default"] = "entry" | ||
|
||
nxentry = f.create_group("entry") | ||
nxentry.attrs["NX_class"] = "NXentry" | ||
nxentry.attrs["default"] = "data" | ||
|
||
nxinstrument = nxentry.create_group("instrument") | ||
nxinstrument.attrs["NX_class"] = "NXinstrument" | ||
|
||
nxdetector = nxinstrument.create_group("detector") | ||
nxdetector.attrs["NX_class"] = "NXdetector" | ||
|
||
# store the data in the NXdetector group | ||
ds_tth = nxdetector.create_dataset("two_theta", data=tthData) | ||
ds_tth.attrs["units"] = "degrees" | ||
ds_counts = nxdetector.create_dataset("counts", data=countsData) | ||
ds_counts.attrs["units"] = "counts" | ||
|
||
# create the NXdata group to define the default plot | ||
nxdata = nxentry.create_group("data") | ||
nxdata.attrs["NX_class"] = "NXdata" | ||
nxdata.attrs["signal"] = "counts" | ||
nxdata.attrs["axes"] = "two_theta" | ||
nxdata.attrs["two_theta_indices"] = [ | ||
0, | ||
] | ||
|
||
source_addr = "/entry/instrument/detector/two_theta" # existing data | ||
target_addr = "two_theta" # new location | ||
ds_tth.attrs["target"] = source_addr # a NeXus API convention for links | ||
nxdata[target_addr] = f[source_addr] # hard link | ||
# nxdata._id.link(source_addr, target_addr, h5py.h5g.LINK_HARD) | ||
|
||
source_addr = "/entry/instrument/detector/counts" # existing data | ||
target_addr = "counts" # new location | ||
ds_counts.attrs["target"] = source_addr # a NeXus API convention for links | ||
nxdata[target_addr] = f[source_addr] # hard link | ||
# nxdata._id.link(source_addr, target_addr, h5py.h5g.LINK_HARD) |
31 changes: 31 additions & 0 deletions
31
...SPM_domain_app_def/_downloads/416583d2a0aeeb16432d9ff7e762f9ac/reader_attributes_trail.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from pathlib import Path | ||
import h5py | ||
|
||
filename = str( | ||
Path(__file__).absolute().parent.parent | ||
/ "simple_example_basic" | ||
/ "simple_example_basic.nexus.hdf5" | ||
) | ||
with h5py.File(filename, "r") as nx: | ||
# find the default NXentry group | ||
nx_entry = nx[nx.attrs["default"]] | ||
# find the default NXdata group | ||
nx_data = nx_entry[nx_entry.attrs["default"]] | ||
# find the signal field | ||
signal = nx_data[nx_data.attrs["signal"]] | ||
# find the axes field(s) | ||
attr_axes = nx_data.attrs["axes"] | ||
if isinstance(attr_axes, (set, tuple, list)): | ||
# but check that attr_axes only describes 1-D data | ||
if len(attr_axes) == 1: | ||
attr_axes = attr_axes[0] | ||
else: | ||
raise ValueError(f"expected 1-D data but @axes={attr_axes}") | ||
axes = nx_data[attr_axes] | ||
|
||
print(f"file: {nx.filename}") | ||
print(f"signal: {signal.name}") | ||
print(f"axes: {axes.name}") | ||
print(f"{axes.name} {signal.name}") | ||
for x, y in zip(axes, signal): | ||
print(x, y) |
Oops, something went wrong.