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

SaveNXcanSAS v1

../_images/ImageNotFound.png

Enable screenshots using DOCS_SCREENSHOTS in CMake

Summary

Writes a MatrixWorkspace to a file in the NXcanSAS format.

See Also

SaveCanSAS1D, LoadNXcanSAS

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 Mantid 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

SampleTransmissionRunNumber

Input

string

The run number for the sample transmission workspace. Optional.

SampleDirectRunNumber

Input

string

The run number for the sample direct workspace. Optional.

CanScatterRunNumber

Input

string

The run number for the can scatter workspace. Optional.

CanDirectRunNumber

Input

string

The run number for the can direct workspace. Optional.

Description

Saves a workspace with momentum transfer units into a file adhering to the NXcanSAS format specified by NXcanSAS Data Formats Working Group schema. 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 the 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: AlgorithmIndex | DataHandling\Nexus

Source

C++ header: SaveNXcanSAS.h

C++ source: SaveNXcanSAS.cpp