MatrixWorkspace

This a python binding to the C++ class Mantid::API::MatrixWorkspace.

bases: mantid.api.ExperimentInfo, mantid.api.IMDWorkspace

class mantid.api.MatrixWorkspace
YUnit((MatrixWorkspace)self) → str :

Returns the current Y unit for the data (Y axis) in the workspace

YUnitLabel((MatrixWorkspace)self) → str :

Returns the caption for the Y axis

__init__()

Raises an exception This class cannot be instantiated from Python

axes((MatrixWorkspace)self) → int :

Returns the number of axes attached to the workspace

binIndexOf((MatrixWorkspace)self, (float)xvalue[, (int)workspaceIndex]) → int :

Returns the index of the bin containing the given xvalue. The workspace_index is optional [default=0]

blocksize((MatrixWorkspace)self) → int :

Returns size of the Y data array

clearMonitorWorkspace((MatrixWorkspace)self) → None :

Forget about monitor workspace, attached to the current workspace

clone(*InputWorkspace, **Version=1)

Copies an existing workspace into a new one.

Property descriptions:

InputWorkspace(Input:req) Workspace Name of the input workspace. Must be a MatrixWorkspace (2D or EventWorkspace), a PeaksWorkspace or a MDEventWorkspace.

OutputWorkspace(Output:req) Workspace Name of the newly created cloned workspace.

convertUnits(*InputWorkspace, Target, EMode=None, EFixed=None, AlignBins=None, ConvertFromPointData=None, **Version=1)

Performs a unit change on the X values of a workspace

Property descriptions:

InputWorkspace(Input:req) MatrixWorkspace Name of the input workspace

OutputWorkspace(Output:req) MatrixWorkspace Name of the output workspace, can be the same as the input

Target(Input:req) string The name of the units to convert to (must be one of those registered in the Unit Factory)[Degrees, DeltaE, DeltaE_inWavenumber, dSpacing, Empty, Energy, Energy_inWavenumber, Label, Momentum, MomentumTransfer, QSquared, SpinEchoLength, SpinEchoTime, Time, TOF, Wavelength]

EMode(Input) string The energy mode (default: elastic)[Elastic, Direct, Indirect]

EFixed(Input) number Value of fixed energy in meV : EI (EMode=Direct) or EF (EMode=Indirect) . Must be set if the target unit requires it (e.g. DeltaE)

AlignBins(Input) boolean If true (default is false), rebins after conversion to ensure that all spectra in the output workspace have identical bin boundaries. This option is not recommended (see http://www.mantidproject.org/ConvertUnits).

ConvertFromPointData(Input) boolean When checked, if the Input Workspace contains Points the algorithm ConvertToHistogram will be run to convert the Points to Bins. The Output Workspace will contains Bins.

dataDx((MatrixWorkspace)self, (int)workspaceIndex) → numpy.ndarray :

Creates a writable numpy wrapper around the original Dx data at the given index

dataE((MatrixWorkspace)self, (int)workspaceIndex) → numpy.ndarray :

Creates a writable numpy wrapper around the original E data at the given index

dataX((MatrixWorkspace)self, (int)workspaceIndex) → numpy.ndarray :

Creates a writable numpy wrapper around the original X data at the given index

dataY((MatrixWorkspace)self, (int)workspaceIndex) → numpy.ndarray :

Creates a writable numpy wrapper around the original Y data at the given index

delete(*Workspace, **Version=1)

Removes a workspace from memory.

Property descriptions:

Workspace(Input:req) Workspace Name of the workspace to delete.

detectorInfo((ExperimentInfo)self) → DetectorInfo :

Return a const reference to the DetectorInfo object.

detectorSignedTwoTheta((MatrixWorkspace)self, (IDetector)det) → float :

Returns the signed two theta value for given detector

detectorTwoTheta((MatrixWorkspace)self, (IDetector)det) → float :

Returns the two theta value for a given detector

displayNormalization((IMDWorkspace)self) → MDNormalization :

Returns the visual normalization of the workspace.

displayNormalizationHisto((IMDWorkspace)self) → MDNormalization :

For MDEventWorkspaces returns the visual normalization of dervied MDHistoWorkspaces.For all others returns the same as displayNormalization.

equals((MatrixWorkspace)self, (MatrixWorkspace)other, (float)tolerance) → bool :

Performs a comparison operation on two workspaces, using the CompareWorkspaces algorithm

estimateResolution((MDGeometry)self) → numpy.ndarray :

Returns a numpy array containing the width of the smallest bin in each dimension

extractDx((MatrixWorkspace)self) → object :

Extracts (copies) the E data from the workspace into a 2D numpy array. Note: This can fail for large workspaces as numpy will require a block of memory free that will fit all of the data.

extractE((MatrixWorkspace)self) → object :

Extracts (copies) the E data from the workspace into a 2D numpy array. Note: This can fail for large workspaces as numpy will require a block of memory free that will fit all of the data.

extractX((MatrixWorkspace)self) → object :

Extracts (copies) the X data from the workspace into a 2D numpy array. Note: This can fail for large workspaces as numpy will require a block of memory free that will fit all of the data.

extractY((MatrixWorkspace)self) → object :

Extracts (copies) the Y data from the workspace into a 2D numpy array. Note: This can fail for large workspaces as numpy will require a block of memory free that will fit all of the data.

getAxis((MatrixWorkspace)self, (int)axis_index) → MantidAxis :

Get a pointer to a workspace axis

getBasisVector((MDGeometry)self, (int)index) → VMD :

Returns a VMD object defining the basis vector for the specified dimension

getComment((Workspace)self) → str :

Returns the comment field on the workspace

getDetector((MatrixWorkspace)self, (int)workspaceIndex) → IDetector :

Return the Detector or DetectorGroup that is linked to the given workspace index

getDimension((MDGeometry)self, (int)index) → IMDDimension :

Returns the description of the dimension at the given index (starts from 0). Raises RuntimeError if index is out of range.

getDimensionIndexById((MDGeometry)self, (str)id) → int :

Returns the index of the dimension with the given ID. Raises RuntimeError if the name does not exist.

getDimensionIndexByName((MDGeometry)self, (str)name) → int :

Returns the index of the dimension with the given name. Raises RuntimeError if the name does not exist.

getDimensionWithId((MDGeometry)self, (str)id) → IMDDimension :

Returns the description of the dimension with the given id string. Raises ValueError if the string is not a known id.

getEFixed((ExperimentInfo)self, (int)detId) → float
getEMode((ExperimentInfo)self) → DeltaEModeType :

Returns the energy mode.

getGeometryXML((MDGeometry)self) → str :

Returns an XML representation, as a string, of the geometry of the workspace

getHistory((Workspace)self) → WorkspaceHistory :

Return read-only access to the workspace history

getIndexFromSpectrumNumber((MatrixWorkspace)self, (int)spec_no) → int :

Returns workspace index correspondent to the given spectrum number. Throws if no such spectrum is present in the workspace

getInstrument((ExperimentInfo)self) → Instrument :

Returns the instrument for this run.

getInstrumentFilename((str)instrument[, (str)date='']) → str :

Returns IDF

getMemorySize((Workspace)self) → int :

Returns the memory footprint of the workspace in KB

getMonitorWorkspace((MatrixWorkspace)self) → Workspace :

Return internal monitor workspace bound to current workspace.

getNEvents((IMDWorkspace)self) → int :

Returns the total number of events, contributed to the workspace

getNPoints((IMDWorkspace)self) → int :

Returns the total number of points within the workspace

getName((Workspace)self) → str :

Returns the name of the workspace. This could be an empty string

getNonIntegratedDimensions((MDGeometry)self) → list :

Returns the description objects of the non-integrated dimension as a python list of IMDDimension.

getNumDims((MDGeometry)self) → int :

Returns the number of dimensions present

getNumberBins((MatrixWorkspace)self) → int :

Returns size of the Y data array (deprecated, use blocksize instead)

getNumberHistograms((MatrixWorkspace)self) → int :

Returns the number of spectra in the workspace

getNumberTransformsFromOriginal((MDGeometry)self) → int :

Returns the number of transformations from original workspace coordinate systems

getNumberTransformsToOriginal((MDGeometry)self) → int :

Returns the number of transformations to original workspace coordinate systems

getOrigin((MDGeometry)self) → VMD :

Returns the vector of the origin (in the original workspace) that corresponds to 0,0,0... in this workspace

getOriginalWorkspace((MDGeometry)self, (int)index) → Workspace :

Returns the source workspace attached at the given index

getRun((MatrixWorkspace)self) → Run :

Return the Run object for this workspace

getRunNumber((ExperimentInfo)self) → int :

Returns the run identifier for this run.

getSampleDetails((MatrixWorkspace)self) → Run :

Return the Run object for this workspace (deprecated, use getRun instead)

getSpecialCoordinateSystem((IMDWorkspace)self) → SpecialCoordinateSystem :

Returns the special coordinate system of the workspace

getSpectrum((MatrixWorkspace)self, (int)workspaceIndex) → ISpectrum :

Return the spectra at the given workspace index.

getTDimension((MDGeometry)self) → IMDDimension :

Returns the dimension description mapped to time

getTitle((Workspace)self) → str :

Returns the title of the workspace

getXDimension((MDGeometry)self) → IMDDimension :

Returns the dimension description mapped to X

getYDimension((MDGeometry)self) → IMDDimension :

Returns the dimension description mapped to Y

getZDimension((MDGeometry)self) → IMDDimension :

Returns the dimension description mapped to Z

hasDx((MatrixWorkspace)self, (int)workspaceIndex) → bool :

Returns True if the spectrum uses the DX (X Error) array, else False.

hasOriginalWorkspace((MDGeometry)self, (int)index) → bool :

Returns True if there is a source workspace at the given index

id((DataItem)self) → str :

The string ID of the class

isDirty((Workspace)self[, (int)n]) → bool :

True if the workspace has run more than n algorithms (Default=1)

isDistribution((MatrixWorkspace)self) → bool :

Returns the status of the distribution flag

isHistogramData((MatrixWorkspace)self) → bool :

Returns True if this is considered to be binned data.

isMDHistoWorkspace((IMDWorkspace)self) → bool :

Returns True if this is considered to be binned data.

maskDetectors(*Workspace, SpectraList=None, DetectorList=None, WorkspaceIndexList=None, MaskedWorkspace=None, ForceInstrumentMasking=None, StartWorkspaceIndex=None, EndWorkspaceIndex=None, ComponentList=None, **Version=1)

An algorithm to mask a detector, or set of detectors, as not to be used. The workspace spectra associated with those detectors are zeroed.

Property descriptions:

Workspace(InOut:req) Workspace The name of the input and output workspace on which to perform the algorithm.

SpectraList(Input) int list An ArrayProperty containing a list of spectra to mask

DetectorList(Input) int list An ArrayProperty containing a list of detector ID’s to mask

WorkspaceIndexList(Input) unsigned int list An ArrayProperty containing the workspace indices to mask

MaskedWorkspace(Input) MatrixWorkspace If given but not as a SpecialWorkspace2D, the masking from this workspace will be copied. If given as a SpecialWorkspace2D, the masking is read from its Y values.[]

ForceInstrumentMasking(Input) boolean Works when ‘MaskedWorkspace’ is provided and forces to use spectra-detector mapping even in case when number of spectra in ‘Workspace’ and ‘MaskedWorkspace’ are equal

StartWorkspaceIndex(Input) number If other masks fields are provided, it’s the first index of the target workspace to be allowed to be masked from by these masks, if not, its the first index of the target workspace to mask. Default value is 0 if other masking is present or ignored if not.

EndWorkspaceIndex(Input) number If other masks are provided, it’s the last index of the target workspace allowed to be masked to by these masks, if not, its the last index of the target workspace to mask. Default is number of histograms in target workspace if other masks are present or ignored if not.

ComponentList(Input) str list An ArrayProperty containing a list of component names to mask

mutableRun((ExperimentInfo)self) → Run :

Return a modifiable Run object.

mutableSample((ExperimentInfo)self) → Sample :

Return a modifiable Sample object.

name((DataItem)self) → str :

The name of the object

numOriginalWorkspaces((MDGeometry)self) → int :

Returns the number of source workspaces attached

readDx((MatrixWorkspace)self, (int)workspaceIndex) → numpy.ndarray :

Creates a read-only numpy wrapper around the original Dx data at the given index

readE((MatrixWorkspace)self, (int)workspaceIndex) → numpy.ndarray :

Creates a read-only numpy wrapper around the original E data at the given index

readX((MatrixWorkspace)self, (int)workspaceIndex) → numpy.ndarray :

Creates a read-only numpy wrapper around the original X data at the given index

readY((MatrixWorkspace)self, (int)workspaceIndex) → numpy.ndarray :

Creates a read-only numpy wrapper around the original Y data at the given index

rebin(*InputWorkspace, Params, PreserveEvents=None, FullBinsOnly=None, IgnoreBinErrors=None, **Version=1)

Rebins data with new X bin boundaries. For EventWorkspaces, you can very quickly rebin in-place by keeping the same output name and PreserveEvents=true.

Property descriptions:

InputWorkspace(Input:req) MatrixWorkspace Workspace containing the input data

OutputWorkspace(Output:req) MatrixWorkspace The name to give the output workspace

Params(Input:req) dbl list A comma separated list of first bin boundary, width, last bin boundary. Optionally this can be followed by a comma and more widths and last boundary pairs. Optionally this can also be a single number, which is the bin width. In this case, the boundary of binning will be determined by minimum and maximum TOF values among all events, or previous binning boundary, in case of event Workspace, or non-event Workspace, respectively. Negative width values indicate logarithmic binning.

PreserveEvents(Input) boolean Keep the output workspace as an EventWorkspace, if the input has events. If the input and output EventWorkspace names are the same, only the X bins are set, which is very quick. If false, then the workspace gets converted to a Workspace2D histogram.

FullBinsOnly(Input) boolean Omit the final bin if it’s width is smaller than the step size

IgnoreBinErrors(Input) boolean Ignore errors related to zero/negative bin widths in input/output workspaces. When ignored, the signal and errors are set to zero

replaceAxis((MatrixWorkspace)self, (int)axisIndex, (MantidAxis)newAxis) → None :

Replaces one of the workspace’s axes with the new one provided.

run((ExperimentInfo)self) → Run :

Return the Run object. This cannot be modified, use mutableRun to modify.

sample((ExperimentInfo)self) → Sample :

Return the Sample object. This cannot be modified, use mutableSample to modify.

setComment((Workspace)self, (str)comment) → None :

Set the comment field of the workspace

setDistribution((MatrixWorkspace)self, (bool)newVal) → None :

Set distribution flag. If True the workspace has been divided by the bin-width.

setDx((MatrixWorkspace)self, (int)workspaceIndex, (object)dX) → None :

Set Dx values from a python list or numpy array. It performs a simple copy into the array.

setE((MatrixWorkspace)self, (int)workspaceIndex, (object)e) → None :

Set E values from a python list or numpy array. It performs a simple copy into the array.

setEFixed((ExperimentInfo)self, (int)detId, (float)value) → None
setMonitorWorkspace((MatrixWorkspace)self, (object)MonitorWS) → None :

Set specified workspace as monitor workspace forcurrent workspace. Note: The workspace does not have to contain monitors though some subsequent algorithms may expect it to be monitor workspace later.

setTitle((Workspace)self, (str)title) → None :

Set the title of the workspace

setX((MatrixWorkspace)self, (int)workspaceIndex, (object)x) → None :

Set X values from a python list or numpy array. It performs a simple copy into the array.

setY((MatrixWorkspace)self, (int)workspaceIndex, (object)y) → None :

Set Y values from a python list or numpy array. It performs a simple copy into the array.

setYUnit((MatrixWorkspace)self, (str)newUnit) → None :

Sets a new unit for the data (Y axis) in the workspace

setYUnitLabel((MatrixWorkspace)self, (str)newLabel) → None :

Sets a new caption for the data (Y axis) in the workspace

spectrumInfo((MatrixWorkspace)self) → SpectrumInfo :

Return a const reference to the SpectrumInfo object.

threadSafe((DataItem)self) → bool :

Returns true if the object can be accessed safely from multiple threads