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

SaveCanSAS1D v2

../_images/SaveCanSAS1D-v2_dlg.png

SaveCanSAS1D dialog.

Summary

Save a MatrixWorkspace to a file in the canSAS 1-D format

See Also

LoadCanSAS1D

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 xml file to save. Allowed extensions: [‘.xml’]

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’]

Append

Input

boolean

False

Selecting append allows the workspace to be added to an existing canSAS 1-D file as a new SASentry

Process

Input

string

Text to append to Process section

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.

Geometry

Input

string

Disc

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

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.

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.

OneSpectrumPerFile

Input

boolean

False

If true, each spectrum will be saved in an invididual file

Description

Saves the given Matrix Workspace to a file in the canSAS 1-D format.

If the workspace contains several spectra, two options are available:

  • if OneSpectrumPerFile if false (default value), all spectra will be appended into the same file (into different <SASdata> entries)

  • if OneSpectrumPerFile is true, each spectrum will be written in a separate file. The name of the file will be created as follows: <Filename property>_ <spectrum index>_<axis value><axis unit>.<extension>

The canSAS 1-D Format

The canSAS 1-D standard for reduced 1-D SAS data is implemented using XML files. A single file can contain SAS data from a single experiment or multiple experiments.

Version 1.1 of the canSAS 1-D schema can be used to validate files of this format.

There is a canSAS Wiki available which provides more information about the format.

Versions

This is version 2 of the algorithm, which meets version 1.1 of the canSAS 1-D specification.

You can export data to files using version 1.0 of the specification by using version 1 of SaveCanSAS1D.

Usage

Example - Save/Load “Roundtrip”

import os

# Create dummy workspace.
dataX = [0,1,2,3]
dataY = [9,5,7]
out_ws = CreateWorkspace(dataX, dataY, UnitX="MomentumTransfer")

file_path = os.path.join(config["defaultsave.directory"], "canSASData.xml")

# Do a "roundtrip" of the data.
SaveCanSAS1D(out_ws, file_path)
in_ws = LoadCanSAS1D(file_path)

print("Contents of the file = " + str(in_ws.readY(0)) + ".")

Output:

Contents of the file = [ 9.  5.  7.].

Categories: AlgorithmIndex | DataHandling\XML | SANS\DataHandling

Source

C++ header: SaveCanSAS1D2.h

C++ source: SaveCanSAS1D2.cpp