StitchByBackground v1

Summary

Stitch banks together at given x-axis values, without rebinning the data to preserve resolution.

Properties

Name

Direction

Type

Default

Description

InputWorkspaces

Input

str list

Mandatory

List of workspaces to be stitched together.

OutputWorkspace

Output

Workspace

Mandatory

The stitched workspace.

StitchPoints

Input

dbl list

Values on the x-axis (between adjacent spectra) where the stitch should take place. i.e. Overlaps in the data.

OverlapWidth

Input

number

0.05

A linear background is fitted to data in the region StitchPoint +/- OverlapWidth (i.e. the data is fitted to span range 2*OverlapWidth).

CropLowerBound

Input

number

0

The XMin to use when cropping the output workspace.

CropUpperBound

Input

number

0

The XMax to use when cropping the output workspace.

Description

This algorithm allows for the stitching of a list of single-spectra workspaces into one workspace by using a number of user-defined stitch points at x values and an overlap region around these points in which to perform a linear background fit.

In comparison to Stitch1DMany v1 or MatchAndMergeWorkspaces v1, this algorithm does not perform any rebinning during the stitching process, creating a ragged workspace that can be rebinned appropriately later in the reduction.

StitchByBackground example. Shows 5 different spectra on the right and the stitched result on the left.

Usage

Example - StitchByBackground

ws_list = []
stitch_points = []

for i in range(5):
    CreateSampleWorkspace(OutputWorkspace=f"ws_{i+1}", NumBanks=1, BankPixelWidth=1, Function="Multiple Peaks", XMin=20000*i, XMax=20000*(i+1))
    ws_list.append(f"ws_{i+1}")
    stitch_points.append(20000*(i+1))
stitch_points.pop(-1)

StitchByBackground(InputWorkspaces=ws_list, StitchPoints=stitch_points, OutputWorkspace="out", OverlapWidth=2000, CropUpperBound=95000, CropLowerBound=0)
print(f"Stitched workspace has {mtd['out'].blocksize()} bins.")

Output:

Stitched workspace has 475 bins.

Categories: AlgorithmIndex | Utility

Source

Python: StitchByBackground.py