nexus_writer¶
Functions for writing Nexus files
add_6circle_diffractometer(instrument, name, phi, chi, eta, mu, delta, gamma)
¶
6-circle Euler diffractometer
Source code in mmg_toolbox/nexus/nexus_writer.py
add_6circle_diffractometer_kappa(instrument, name, kphi, kappa, ktheta, mu, delta, gamma, kalpha)
¶
6-circle Kappa diffractometer
Source code in mmg_toolbox/nexus/nexus_writer.py
add_analyser_detector(instrument, name, data, d_spacing, crystal_type='HOPG', reflection=(0, 0, 1), order_no=1, bragg=90, stokes=0, sample_analyser_distance_mm=1000, analyser_det_distance_mm=50, pixel_size_mm=0.1, depends_on='.')
¶
Add analyser detector
Source code in mmg_toolbox/nexus/nexus_writer.py
add_channel_cut_mono(instrument, name, energy, d_spacing, crystal_type='Si', units='eV', reflection=(1, 1, 1), order_no=1)
¶
Add channel cut mono
Source code in mmg_toolbox/nexus/nexus_writer.py
add_entry_links(root, *filenames)
¶
Add entry links to nexus file
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxbeam(root, name, incident_energy_ev, polarisation_label='lh', beam_size_um=None)
¶
Create NXbeam group
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxclass(root, name, nx_class)
¶
add_nxcrystal(root, name, usage, crystal_type, d_spacing, reflection=(1, 1, 1), order_no=1)
¶
Create NXcrystal group Used for monochromators and analyser crystals
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
Group
|
h5py group |
required |
name
|
str
|
name of crystal |
required |
usage
|
str
|
'Bragg' or 'Laue' |
required |
crystal_type
|
str
|
Chemical formula or substance, e.g. Si, HOPG, multilayer |
required |
d_spacing
|
float
|
spacing between crystals in Angstrom |
required |
reflection
|
tuple[int, int, int]
|
reflection index in Miller-indices (h,k,l) |
(1, 1, 1)
|
order_no
|
int
|
order of the reflection, n*(h,k,l) |
1
|
Returns:
| Type | Description |
|---|---|
Group
|
NXcrystal group |
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxdata(root, name, axes, signal, *auxilliary_signals)
¶
Create NXdata group
xvals = np.arange(10) yvals = 3 + xvals ** 2 group = NXdata(entry, 'xydata', axes=['x'], signal='y') xdata = add_nxfield(group, 'x', xvals, units='mm') ydata = add_nxfield(group, 'y' yvals, units='')
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxdetector(root, name, data, detector_distance_mm=1000, pixel_size_mm=0.055, depends_on=None, transformations=None)
¶
Create NXdetector group
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxentry(root, name, definition=None)
¶
Create NXentry group
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxfield(root, name, data, **attrs)
¶
add_nxinsertion_device(root, name, id_type='undulator', gap=7.0, harmonic=7)
¶
Create NXinsertion_device group
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxinstrument(root, name, instrument_name)
¶
Create NXinstrument group
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxmonitor(root, name, data)
¶
Create NXmonitor group with monitor signal
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxmono(root, name, energy_ev, units='eV')
¶
Create NXmonochromator group
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxnote(root, name, description, data=None, filename=None, sequence_index=None)
¶
add NXnote to parent group
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxprocess(root, name, program, version, date=None, sequence_index=None)
¶
Create NXprocess group
Example: entry = add_nxentry(root, 'processed') process = add_nxprocess(entry, 'process', program='Python', version='1.0') add_nxnote(process, 'step_1', description='First step', data='details', sequence_index=1 ) add_nxnote(process, 'step_2', description='Second step', data='details', sequence_index=2 ) data = add_nxdata(process, 'result', axes=['x'], signal='y') xdata = add_nxfield(group, 'x', xvals, units='mm') ydata = add_nxfield(group, 'y' yvals, units='')
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxsample(root, name, sample_name='', chemical_formula='', temperature_k=300, magnetic_field_t=0, electric_field_v=0, mag_field_dir='z', electric_field_dir='z', sample_type='sample', description='')
¶
Create NXsample group
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxsource(root, name, source_name='dls', source_type='Synchrotron X-ray Source', probe='x-ray', energy_gev=3.0)
¶
Create NXsource group for DLS
Source code in mmg_toolbox/nexus/nexus_writer.py
add_nxtransformations(root, name, *transformations, depends_on=None)
¶
Add NXtransformations group Adds a depends_on dataset to the given group and a sub-group called 'transformations'