CreateWorkspace v1

../_images/CreateWorkspace-v1_dlg.png

CreateWorkspace dialog.

Summary

This algorithm constructs a MatrixWorkspace when passed a vector for each of the X, Y, and E data values.

Properties

Name Direction Type Default Description
OutputWorkspace Output MatrixWorkspace Mandatory Name to be given to the created workspace.
DataX Input dbl list Mandatory X-axis data values for workspace.
DataY Input dbl list Mandatory Y-axis data values for workspace (measures).
DataE Input dbl list   Error values for workspace.
NSpec Input number 1 Number of spectra to divide data into.
UnitX Input string   The unit to assign to the XAxis
VerticalAxisUnit Input string SpectraNumber The unit to assign to the second Axis (leave blank for default Spectra number). Allowed values: [‘Degrees’, ‘DeltaE’, ‘DeltaE_inFrequency’, ‘DeltaE_inWavenumber’, ‘dSpacing’, ‘dSpacingPerpendicular’, ‘Empty’, ‘Energy’, ‘Energy_inWavenumber’, ‘Label’, ‘Momentum’, ‘MomentumTransfer’, ‘QSquared’, ‘SpinEchoLength’, ‘SpinEchoTime’, ‘Temperature’, ‘Time’, ‘TOF’, ‘Wavelength’, ‘SpectraNumber’, ‘Text’]
VerticalAxisValues Input str list   Values for the VerticalAxis.
Distribution Input boolean False Whether OutputWorkspace should be marked as a distribution.
YUnitLabel Input string   Label for Y Axis
WorkspaceTitle Input string   Title for Workspace
ParentWorkspace Input MatrixWorkspace   Name of a parent workspace.
Dx Input dbl list   X error values for workspace (optional).
ParallelStorageMode Input string Parallel::StorageMode::Cloned The parallel storage mode of the output workspace for MPI builds. Allowed values: [‘Parallel::StorageMode::Cloned’, ‘Parallel::StorageMode::Distributed’, ‘Parallel::StorageMode::MasterOnly’]

Description

This algorithm constructs a MatrixWorkspace when passed a vector for each of the X, Y and optionally E and Dx values. The E values of the output workspace will be zero if not provided. The unit for the X Axis can optionally be specified as any of the units in the Mantid Unit Factory. Multiple spectra may be created by supplying the NSpec Property (integer, default 1). When this is provided the vectors are split into equal-sized spectra (all X, Y, E, Dx values must still be in a single vector for input).

When you use the input property ParentWorkspace, the new workspace is created with the same instrument (including its parameters), sample and run information, and comment field as the parent. The Y units and title are also copied from the parent workspace unless they are provided in the input properties passed to the algorithm.

Note on old behavior regarding spectrum-detector mapping

Until release 3.11 (inclusive) this algorithm created a default (and potentially wrong) mapping from spectra to detectors if no parent workspace was given. This change has no effect if any of the following applies:

  • A parent workspace is given.
  • No instrument is loaded into to workspace at a later point.
  • An instrument is loaded at a later point but LoadInstrument is used with RewriteSpectraMapping=True.
  • An instrument is loaded at a later point but LoadInstrument is used with RewriteSpectraMapping=False but a correct mapping is set up before or after loading the instrument.

That is, only the following use is affected:

# See usage example below for setting up input data.
ws = CreateWorkspace(DataX=dataX, DataY=dataY, DataE=dataE, NSpec=4, UnitX="Wavelength")
LoadInstrument(ws, InstrumentName='MARI', RewriteSpectraMap=False)
# None of the spectra in `ws` maps to any detectors since detectors were not known
# at the time of workspace creation. The old behavior used to map spectra 1,2,3,4
# to detector IDs 1,2,3,4. This worked only accidentally if MARI contains detectors
# with IDs 1,2,3,4. Accidental mappings are not a feature anymore.

The solution to this is to set RewriteSpectraMapping=True, set the correct mapping by hand via ws.getSpectrum(i).setDetectorID(id), or use CreateWorkspace with a parent workspace that contains the correct instrument and mapping.

Usage

dataX = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
dataY = [1,2,3,4,5,6,7,8,9,10,11,12]

# The workspace will be named "dataWS1", error values will be zero.
dataWS1 = CreateWorkspace(DataX=dataX, DataY=dataY, NSpec=4, UnitX="Wavelength")

# Create a workspace containing the following error values:
dataE = [1,2,3,4,5,6,7,8,9,10,11,12]
dataWS2 = CreateWorkspace(DataX=dataX, DataY=dataY, DataE=dataE, NSpec=4, UnitX="Wavelength")

# Create a workspace containing Dx values:
dX = [1,2,3,4,5,6,7,8,9,10,11,12]
dataWS3 = CreateWorkspace(DataX=dataX, DataY=dataY, DataE=dataE, NSpec=4, UnitX="Wavelength", Dx=dX)

Categories: AlgorithmIndex | Utility\Workspaces

Source

C++ source: CreateWorkspace.cpp (last modified: 2019-07-17)

C++ header: CreateWorkspace.h (last modified: 2018-10-05)