Table of Contents
The LoadNexus algorithm will try to identify the type of Nexus file given to it and invoke the appropriate algorithm to read the data and populate the named workspace.
Name | Direction | Type | Default | Description |
---|---|---|---|---|
Filename | Input | string | Mandatory | The name of the Nexus file to read, as a full or relative path. Allowed extensions: [‘.nxs’, ‘.nx5’, ‘.xml’, ‘.n*’] |
OutputWorkspace | Output | Workspace | Mandatory | The name of the workspace to be created as the output of the algorithm. A workspace of this name will be created and stored in the Analysis Data Service. For multiperiod files, one workspace will be generated for each period. |
SpectrumMin | Input | number | 1 | Number of first spectrum to read, only for single period data. |
SpectrumMax | Input | number | Optional | Number of last spectrum to read, only for single period data. |
SpectrumList | Input | int list | List of spectrum numbers to read, only for single period data. | |
EntryNumber | Input | number | 0 | 0 indicates that every entry is loaded, into a separate workspace within a group. A positive number identifies one entry to be loaded, into one workspace |
The algorithm LoadNexus will read the given Nexus file and try to identify its type so that it can be read into a workspace. The file name can be an absolute or relative path and should have the extension .nxs or .nx5.
The type of Nexus file is identified as follows:
If the file contains data for more than one period, a separate workspace will be generated for each. After the first period the workspace names will have “_2”, “_3”, and so on, appended to the given workspace name. For single period data, the optional parameters can be used to control which spectra are loaded into the workspace. If spectrum_min and spectrum_max are given, then only that range to data will be loaded. If a spectrum_list is given than those values will be loaded.
Note
To run these usage examples please first download the usage data, and add these to your path. In MantidPlot this is done using Manage User Directories.
Example - Load ISIS histogram Nexus file: (see LoadISISNexus v2 for more options)
# Load LOQ histogram dataset
ws = LoadNexus('LOQ49886.nxs')
print("The 1st x-value of the first spectrum is: {}".format(ws.readX(0)[0]))
Output:
The 1st x-value of the first spectrum is: 5.0
Example - Load ISIS Muon file: (see LoadMuonNexus v2 for more options)
# Load ISIS multiperiod muon MUSR dataset
ws = LoadNexus('MUSR00015189.nxs')
print("The number of periods (entries) is: {}".format(ws[0].getNumberOfEntries()))
Output:
The number of periods (entries) is: 2
Example - Load Mantid processed Nexus file ISIS: (see LoadNexusProcessed v2 for more options:
# Load Mantid processed GEM data file
ws = LoadNexus('focussed.nxs')
print("The number of histograms (spectra) is: {}".format(ws.getNumberHistograms()))
Output:
The number of histograms (spectra) is: 6
Categories: AlgorithmIndex | DataHandling\Nexus
C++ source: LoadNexus.cpp (last modified: 2019-06-05)
C++ header: LoadNexus.h (last modified: 2018-10-05)