SaveNXcanSAS v1

../_images/SaveNXcanSAS-v1_dlg.png

SaveNXcanSAS dialog.

Summary

Writes a MatrixWorkspace to a file in the NXcanSAS format.

Properties

Name Direction Type Default Description
InputWorkspace Input MatrixWorkspace Mandatory The input workspace, which must be in units of Q
Filename Input string Mandatory The name of the .h5 file to save. Allowed extensions: [‘.h5’]
RadiationSource Input string Spallation Neutron Source The type of radiation used. Allowed values: [‘Spallation Neutron Source’, ‘Pulsed Reactor Neutron Source’, ‘Reactor Neutron Source’, ‘Synchrotron X-ray Source’, ‘Pulsed Muon Source’, ‘Rotating Anode X-ray’, ‘Fixed Tube X-ray’, ‘neutron’, ‘x-ray’, ‘muon’, ‘electron’]
DetectorNames Input string   Specify in a comma separated list, which detectors to store information about; where each name must match a name given for a detector in the [[IDF|instrument definition file (IDF)]]. IDFs are located in the instrument sub-directory of the MantidPlot install directory.
Transmission Input MatrixWorkspace   The transmission workspace. Optional. If given, will be saved at TransmissionSpectrum
TransmissionCan Input MatrixWorkspace   The transmission workspace of the Can. Optional. If given, will be saved at TransmissionSpectrum

Description

Saves a workspace with momentum transfer units into a file adhering to the NXcanSAS format specified by NXcanSAS Data Formats Working Group schema http://cansas-org.github.io/NXcanSAS/classes/contributed_definitions/NXcanSAS.html. If the input workspace is 2D then the vertical axis needs to be a numeric axis in momentum transfer units. The created file can be reloaded using he LoadNXcanSAS v1 algorithm.

In addition it is possible to save the transmission workspaces obtain from a reduction.

Usage

Example

import os

# Create a example workspace with units of momentum transfer
ws = CreateSampleWorkspace("Histogram",NumBanks=1,BankPixelWidth=1)
ws = ConvertUnits(ws,Target="MomentumTransfer")
LoadInstrument(ws,False,InstrumentName="SANS2D")

# Save the file
file_name = "test_file_for_nxcansas"
SaveNXcanSAS(ws,file_name)

# Load the file back
ws_loaded = LoadNXcanSAS(file_name)

#remove the file we created
alg = ws_loaded.getHistory().lastAlgorithm()
filePath = alg.getPropertyValue("Filename")
os.remove(filePath)

Categories: Algorithms | DataHandling\Nexus

Source

C++ source: SaveNXcanSAS.cpp (last modified: 2018-03-14)

C++ header: SaveNXcanSAS.h (last modified: 2016-06-30)