LoadNexus v1

../_images/LoadNexus-v1_dlg.png

LoadNexus dialog.

Summary

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.

Properties

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

Description

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 has a group of class SDS of name "definition" or "analysis" with value "muonTD" or "pulsedTD", then it is taken to be a muon Nexus file and LoadMuonNexus v2 is called.
  • Else if main entry is "mantid_workspace_1" then it is taken to be a processed Nexus file and LoadNexusProcessed v1 is called. The spectrum properties are ignored in this case.
  • Else if main entry is "raw_data_1" then it is taken to be an ISIS Nexus file and LoadISISNexus v2 is called.
  • Else if instrument group has a "SNSdetector_calibration_id" item, then LoadTOFRawNexus v1 is called.
  • Else exception indicating unsupported type of Nexus file is thrown.

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.

Usage

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 v1 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: Algorithms | DataHandling\Nexus

Source

C++ source: LoadNexus.cpp (last modified: 2017-12-06)

C++ header: LoadNexus.h (last modified: 2016-06-07)