\(\renewcommand\AA{\unicode{x212B}}\)

LoadNexusProcessed v2

../_images/LoadNexusProcessed-v2_dlg.png

LoadNexusProcessed dialog.

Summary

The LoadNexusProcessed algorithm will read the given Nexus Processed data file containing a Mantid Workspace. The data is placed in the named workspace. LoadNexusProcessed may be invoked by LoadNexus if it is given a Nexus file of this type.

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’]
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 may be generated for each period. Currently only one workspace can be saved at a time so multiperiod Mantid files are not generated.
SpectrumMin Input number 1 Number of first spectrum to read.
SpectrumMax Input number Optional Number of last spectrum to read.
SpectrumList Input int list   List of spectrum numbers to read.
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
LoadHistory Input boolean True If true, the workspace history will be loaded
FastMultiPeriod Input boolean True For multiperiod workspaces. Copy instrument, parameter and x-data rather than loading it directly for each workspace. Y, E and log information is always loaded.

Description

The algorithm LoadNexusProcessed will read a Nexus data file created by SaveNexusProcessed v1 or algm-SaveNexusESS and place the data into the named workspace. The file name can be an absolute or relative path and should have the extension .nxs, .nx5 or .xml.

Warning

Using XML format can be extremely slow for large data sets and generate very large files.

The optional parameters can be used to control which spectra are loaded into the workspace. If SpectrumMin and SpectrumMax are given, then only that range to data will be loaded. A specific list of spectra to load can also be given (SpectrumList). Filtering of spectra is supported when loading into workspaces of type Workspace2Ds and also EventWorkspaces.

A Mantid Nexus file may contain several workspace entries each labelled with an integer starting at 1. By default the highest number workspace is read, earlier ones can be accessed by setting the EntryNumber.

If the saved data has a reference to an XML file defining instrument geometry this will be read.

This is version 2 of the algorithm. For old behaviour SaveNexusProcessed v1, which does not handle SaveNexusESS v1 outputs. This is the only difference between the two versions.

Time series data

The log data in the Nexus file (NX_LOG sections) is loaded as TimeSeriesProperty data within the workspace. Time is stored as seconds from the Unix epoch. Only floating point logs are stored and loaded at present.

Child algorithms used

The Child Algorithms used by LoadMuonNexus are:

  • LoadInstrument - this algorithm looks for an XML description of the instrument and if found reads it.

Usage

Example

import os

#Create an absolute path by joining the proposed filename to a directory
#os.path.expanduser("~") used in this case returns the home directory of the current user
savePath = os.path.expanduser("~")
wsPath = os.path.join(savePath, "LoadNexusProcessedTest.nxs")

ws = CreateSampleWorkspace(WorkspaceType="Histogram", NumBanks=2, BankPixelWidth=1, BinWidth=10, Xmax=50)
SaveNexusProcessed(ws, wsPath)

wsOutput = LoadNexusProcessed(wsPath)

print(CompareWorkspaces(ws,wsOutput, CheckInstrument=False)[0])

os.remove(wsPath)

Output:

True
from mantid.simpleapi import *
import os
import tempfile
simple_run = CreateSampleWorkspace(NumBanks=2, BankPixelWidth=10)
destination = os.path.join(tempfile.gettempdir(), "sample_processed.nxs")
SaveNexusESS(Filename=destination, InputWorkspace=simple_run)
ws = LoadNexusProcessed(Filename=destination)
print("Workspace includes {} detectors".format(ws.detectorInfo().size(), 2 * 10 * 10))
os.remove(destination)

Output:

Workspace includes 200 detectors

Categories: AlgorithmIndex | DataHandling\Nexus

Source

C++ header: LoadNexusProcessed2.h (last modified: 2021-03-31)

C++ source: LoadNexusProcessed2.cpp (last modified: 2021-03-31)