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

RemoveBins v1

../_images/RemoveBins-v1_dlg.png

RemoveBins dialog.

Summary

Used to remove data from a range of bins in a workspace.

See Also

CropWorkspace

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

The name of the input workspace.

OutputWorkspace

Output

MatrixWorkspace

Mandatory

The name of the output workspace.

XMin

Input

number

Mandatory

The lower bound of the region to be removed.

XMax

Input

number

Mandatory

The upper bound of the region to be removed.

RangeUnit

Input

string

AsInput

The unit in which XMin/XMax are being given. If not given, it will peak the unit from the Input workspace X unit. Allowed values: [‘AsInput’, ‘AtomicDistance’, ‘DeltaE’, ‘DeltaE_inFrequency’, ‘DeltaE_inWavenumber’, ‘dSpacing’, ‘dSpacingPerpendicular’, ‘Energy’, ‘Energy_inWavenumber’, ‘Momentum’, ‘MomentumTransfer’, ‘Phi’, ‘QSquared’, ‘SpinEchoLength’, ‘SpinEchoTime’, ‘Temperature’, ‘TOF’, ‘Wavelength’]

Interpolation

Input

string

None

Whether mid-axis bins should be interpolated linearly (“Linear”) or set to zero (“None”). Note: Used when the region to be removed is within a bin. Linear scales the value in that bin by the proportion of it that is outside the region to be removed and none sets it to zero. Allowed values: [‘None’, ‘Linear’]

WorkspaceIndex

Input

number

Optional

If set, will remove data only in the given spectrum of the workspace. Otherwise, all spectra will be acted upon.

Description

This algorithm removes bins from a workspace. A minimum and maximum X value to be removed needs to be provided. This can be in a different unit to the workspace, in which case it is transformed internally.

The treatment of the removed bins is slightly different, depending on where in the spectrum the bins to be removed lie:

Bins at either end of spectrum

If the workspaces has common X binning for all spectra, then the CropWorkspace v1 algorithm will be called as a child algorithm. This will result in the affected bins (which includes the bin in which the boundary - XMin or XMax - lies) being removed completely, leading to the output workspace having fewer bins than the input one. In the case where the X binning varies from spectrum to spectrum, the bin values will be set to zero regardless of the setting of the Interpolation property.

Bins in the middle of a spectrum

The Interpolation property is applicable to this situation. If it is set to “Linear” then the bins are set to values calculated from the values of the bins on either side of the range. If set to “None” then bins entirely within the range given are set to zero whilst the bins in which the boundary fall have their values scaled in proportion to the percentage of the bin’s width which falls outside XMin or XMax as appropriate.

Restrictions on the input workspace

  • The input workspace must have a unit set

  • The input workspace must contain histogram data

Usage

Example - Remove some bins from a 5-bin worksapce

# Create a workspace with 1 spectrum with five bins of width 10
ws = CreateSampleWorkspace("Histogram",  NumBanks=1, BankPixelWidth=1, BinWidth=10, Xmax=50)

# Run algorithm  removing 2nd, 3rd bins and half of 4th bin.
OutputWorkspace = RemoveBins( ws, 20, 35)

# Show workspaces
print("Before RemoveBins {}".format(ws.readY(0)))
print("After RemoveBins {}".format(OutputWorkspace.readY(0)))

Output:

Before RemoveBins [ 10.3   0.3   0.3   0.3   0.3]
After RemoveBins [ 10.3    0.     0.     0.15   0.3 ]

Categories: AlgorithmIndex | Transforms\Splitting

Source

C++ header: RemoveBins.h

C++ source: RemoveBins.cpp