NeXpy Example Files

The following files are included in the NeXpy distribution and may be accessed from the Help menu or downloaded from the Github repository.

Example data

About these example data files

These files are examples of data files that may be read by NeXpy.

file

type

description

example.nxs

NeXus HDF5

2-D NeXus sine wave example

chopper.nxs

NeXus HDF5

2-D time-of-flight neutron chopper spectrometer

Example plugins

About the example plugin

This contains an example of a package, chopper_plugin that provides a plugin menu to NeXpy. The entire directory can be copied to another location to form the template of another plugin, which should be given a unique name.

The package has an example pyproject.toml file, which defines the name of the package and an entry point labelled nexpy.readers, which allows NeXpy to discover the plugin when the package has been installed, using python -m pip install ..

Alternatively, the chopper sub-directory could be installed either locally or within the installed NeXpy package using the Install Plugin... dialog. However, installing the plugin as an external package with an entry point is now the preferred method for making the plugin discoverable.

In this example, a menu item, ‘Chopper’, is added to the top-level NeXpy menu, with two sub-menu items designed to operated on chopper.nxs, which is included as an example file. When loaded, select the chopper root in the NeXpy tree before clicking on either menu item.

The requirement for a plugin is that a function plugin_menu initializes the submenu items in the package’s __init__.py. These would normally initiate dialog boxes that are defined within files in the package, although they could also be imported from an external package.

get_ei

A simple GUI to calibrate the incident energy by determining the first moments of two monitor peaks and computing the energy from the time difference. The NeXus root must be selected and unlocked so that the calibrated energy can be saved to the NXmonochromator group.

convert_qe

A simple GUI to convert inelastic neutron scattering data in chopper.nxs from angular and time-of-flight coordinates into Q and energy transfer. After choosing Q and energy bin sizes, the converted data can be plotted and/or saved as a new NXdata group within the NeXus root.

Example scripts

About these example scripts

These files are examples of scripts that can be run from the script editor within NeXpy. If they are copied to ~/.nexpy/scripts, they can be opened directly from the Scripts Menu.

example.py

A simple script to create a NeXus tree containing a two-dimensional function of NumPy arrays. A similar example is given in the NeXpy documentation.

chopper_plot.py

A script to plot a sequence of cuts, displaced along the y-axis. It assumes that chopper.nxs, which is one of the example files, has been loaded.