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

SaveNXcanSAS v1

Summary

Save a MatrixWorkspace to a file in the NXcanSAS format (for both 1D and 2D data).

See Also

SaveCanSAS1D, LoadNXcanSAS

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

The input workspace, which must be in units of Q. Can be a 1D or a 2D workspace.

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.

BackgroundSubtractionWorkspace

Input

string

The name of the workspace used in the scaled background subtraction, to be included in the metadata. Optional.

BackgroundSubtractionScaleFactor

Input

number

0

The scale factor used in the scaled background subtraction, to be included in the metadata. Optional.

Geometry

Input

string

Unknown

The geometry type of the collimation. Allowed values: [‘Cylinder’, ‘FlatPlate’, ‘Flat plate’, ‘Disc’, ‘Unknown’]

SampleHeight

Input

number

0

The height of the collimation element in mm. If specified as 0 it will not be recorded.

SampleWidth

Input

number

0

The width of the collimation element in mm. If specified as 0 it will not be recorded.

SampleThickness

Input

number

0

The thickness of the sample in mm. If specified as 0 it will not be recorded.

Description

Saves a workspace with momentum transfer units into a file adhering to the NXcanSAS format specified by NXcanSAS Data Formats Working Group schema.

1D or 2D workspaces may be saved.

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