\(\renewcommand\AA{\unicode{x212B}}\)
The Workspace2D is a Mantid data type for a MatrixWorkspace.
It consists of a workspace with 1 or more spectra. Typically, each spectrum will be a histogram. For example, you might have 10 bins, and so have 11 X-value, 10 Y-values and 10 E-values in a workspace.
In contrast to an EventWorkspace, a Workspace2D only contains bin information and does not contain the underlying event data. The EventWorkspace presents itself as a histogram (with X,Y,E values) but preserves the underlying event data.
For more information on what a Workspace2D contains, see MatrixWorkspace.
There is also a specialised form of Workspace2D, called a RebinnedOutput which is produced by SofQWNormalisedPolygon v1. In addition to the signal Y and error E values for each bin, it also carries the fractional weight F of the signal in the bin. This is needed to keep track of the portions of counts from bins in the original grid which has been put into the new (rebinned) grid. A more detailed explanation is given in the description of SofQWNormalisedPolygon v1. For correct handling of the fractional weights in rebinning, the user is recommended to use the Rebin2D v1 algorithm in preference to Integration v1 or SumSpectra v1 although the other algorithms do account for the fractional weights.
Warning
Note, however, that all binary and unary operations on workspaces will ignore the fractional weights. Thus it is important to handle all background subtractions and scaling in the original reduced dataset(s) before conversion using SofQWNormalisedPolygon v1.
Workspace2D is a MatrixWorkspace and does not offer any functionality above that of a Matrix Workspace.
The methods for getting a variable to an EventWorkspace is the same as shown in the Workspace help page.
If you want to check if a variable points to something that is a Workspace2D you can use this:
histoWS = CreateSampleWorkspace()
if histoWS.id() == "Workspace2D":
print(histoWS.name() + " is an " + histoWS.id())
Output:
histoWS is an Workspace2D
A Workspace2D may be pickled <https://docs.python.org/2/library/pickle.html/> and de-pickled in python. The current pickling process has the following limitations to beware.
In addition, users should prefer using cPickle over pickle, and make sure that the protocol option is set to the HIGHEST_PROTOCOL to ensure that the serialization/deserialization process is as fast as possible.
import cPickle as pickle
pickled = pickle.dumps(ws2d, pickle.HIGHEST_PROTOCOL)
Category: Concepts