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

Workspace2D

This is a Python binding to the C++ class Mantid::DataObjects::Workspace2D.

bases: mantid.api.MatrixWorkspace

class mantid.dataobjects.Workspace2D
YUnit((MatrixWorkspace)self) str :

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

YUnitLabel((MatrixWorkspace)self[, (bool)useLatex[, (bool)plotAsDistribution]]) str :

Returns the caption for the Y axis

applyBinEdgesFromAnotherWorkspace((MatrixWorkspace)self, (MatrixWorkspace)ws, (int)getIndex, (int)setIndex) None :

Sets the bin edges at setIndex to be the bin edges of ws at getIndex.

applyPointsFromAnotherWorkspace((MatrixWorkspace)self, (MatrixWorkspace)ws, (int)getIndex, (int)setIndex) None :

Sets the points at setIndex to be the points of ws at getIndex.

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 (deprecated, use yIndexOfX instead)

blocksize((MatrixWorkspace)self) int :

Returns size of the Y data array

clearMonitorWorkspace((MatrixWorkspace)self) None :

Forget about monitor workspace, attached to the current workspace

clearOriginalWorkspaces((MDGeometry)self) None :

Clear any attached original workspaces

clone(InputWorkspace)

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.

componentInfo((ExperimentInfo)self) ComponentInfo :

Return a const reference to the ComponentInfo object.

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

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)[DeltaE, DeltaE_inFrequency, DeltaE_inWavenumber, dSpacing, dSpacingPerpendicular, Energy, Energy_inWavenumber, Momentum, MomentumTransfer, QSquared, SpinEchoLength, SpinEchoTime, 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://docs.mantidproject.org/algorithms/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)

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 MDNormalization of the workspace.

displayNormalizationHisto((IMDWorkspace)self) MDNormalization :

For MDEventWorkspaces returns the visual MDNormalization of derived 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.

findY((MatrixWorkspace)self, (float)value[, (tuple)start=(0, 0)]) tuple :

Find first index in Y equal to value. Start may be specified to begin at a specifc index. Returns tuple with the histogram and bin indices.

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 IMDDimension 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 IMDDimension 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 IMDDimension 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 WorkspaceHistory

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

getIndicesFromDetectorIDs((MatrixWorkspace)self, (list)detID_list) std_vector_size_t :

Returns a list of workspace indices from the corrresponding detector IDs.

getInstrument((ExperimentInfo)self) Instrument :

Returns the Instrument for this run.

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

Returns IDF filename

getMaxNumberBins((MatrixWorkspace)self) int :

Returns the maximum number of bins in a workspace (works on ragged data).

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

getNumNonIntegratedDims((MDGeometry)self) int :

Returns the number of non-integrated dimensions present

getNumberBins((MatrixWorkspace)self, (int)index) int :

Returns the number of bins for a given histogram index.

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

getPlotType((MatrixWorkspace)self) str :

Returns the plot type of the workspace

static getResourceFilenames((str)prefix, (list)fileFormats, (list)directoryNames, (str)date) list :

Compile a list of files in compliance with name pattern-matching, file format, and date-stamp constraints

Ideally, the valid-from and valid-to of any valid file should encapsulate the argument date. If this is not possible, then the file with the most recent valid-from stamp is selected

prefix: the name of a valid file must begin with this pattern fileFormats: list of valid file extensions directoryNames: list of directories to be searched date : the ‘valid-from’ and ‘valid-to ‘dates of a valid file will encapsulate this date (e.g ‘1900-01-31 23:59:00’)

returns : list of absolute paths for each valid file

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)

getSignalAtCoord((MatrixWorkspace)self, (object)coords, (MDNormalization)normalization) object :

Return signal for array of coordinates

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.

getSpectrumNumbers((MatrixWorkspace)self) list :

Returns a list of all spectrum numbers in the workspace

getTDimension((MDGeometry)self) IMDDimension :

Returns the IMDDimension description mapped to time

getTitle((Workspace)self) str :

Returns the title of the workspace

getXDimension((MDGeometry)self) IMDDimension :

Returns the IMDDimension description mapped to X

getYDimension((MDGeometry)self) IMDDimension :

Returns the IMDDimension description mapped to Y

getZDimension((MDGeometry)self) IMDDimension :

Returns the IMDDimension description mapped to Z

hasAnyMaskedBins((MatrixWorkspace)self) bool :

Returns true if any of the bins in this workspace are masked.

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

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

hasMaskedBins((MatrixWorkspace)self, (int)workspaceIndex) bool :

Returns true if this spectrum contains any masked bins

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

isCommonBins((MatrixWorkspace)arg1) bool :

Returns true if the workspace has common X bins.

isCommonLogBins((MatrixWorkspace)arg1) bool :

Returns true if the workspace has common X bins with log spacing.

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

isGroup((Workspace)self) bool :

Returns if it is a group workspace

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.

isRaggedWorkspace((MatrixWorkspace)self) bool :

Returns true if the workspace is ragged (has differently sized spectra).

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

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 A list of spectra to mask

DetectorList(Input) int list A list of detector ID’s to mask

WorkspaceIndexList(Input) unsigned int list A list of 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 A list names of components to mask

maskedBinsIndices((MatrixWorkspace)self, (int)workspaceIndex) std_vector_size_t :

Returns all the masked bins’ indices at the workspace index. hasMaskedBins MUST be called first to check if any bins are masked, otherwise an exception will be thrown

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

readLock((DataItem)self) None :

Acquires a read lock on the data item.

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, UseReverseLogarithmic=None, Power=None, BinningMode=None)

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

UseReverseLogarithmic(Input) boolean For logarithmic intervals, the splitting starts from the end and goes back to the start, ie the bins are bigger at the start getting exponentially smaller until they reach the end. For these bins, the FullBinsOnly flag is ignored.

Power(Input) number Splits the interval in bins which actual width is equal to requested width / (i ^ power); default is linear. Power must be between 0 and 1.

BinningMode(Input) string Optional. Binning behavior can be specified in the usual way through sign of binwidth and other properties (‘Default’); or can be set to one of the allowed binning modes. This will override all other specification or default behavior.[Default, Linear, Logarithmic, ReverseLogarithmic, Power]

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

Replaces one of the workspace’s axes with the new one provided. The axis is cloned.

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.

setPlotType((MatrixWorkspace)self, (str)newType) None :

Sets a new plot type for the workspace

setRun((ExperimentInfo)self, (Run)run) None
setSample((ExperimentInfo)self, (Sample)sample) None
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((ExperimentInfo)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

unlock((DataItem)self) None :

Unlocks a read or write lock on the data item.

yIndexOfX((MatrixWorkspace)self, (float)xvalue[, (int)workspaceIndex[, (float)tolerance]]) int :

Returns the y index which corresponds to the X Value provided. The workspace_index [default=0] and tolerance [default=0.0] is optional.