Stitch1D v3

../_images/Stitch1D-v3_dlg.png

Stitch1D dialog.

Summary

Stitches single histogram matrix workspaces together

Properties

Name Direction Type Default Description
LHSWorkspace Input MatrixWorkspace Mandatory LHS input workspace.
RHSWorkspace Input MatrixWorkspace Mandatory RHS input workspace.
OutputWorkspace Output MatrixWorkspace Mandatory Output stitched workspace.
StartOverlap Input number Optional Start overlap x-value in units of x-axis. Optional.
EndOverlap Input number Optional End overlap x-value in units of x-axis. Optional.
Params Input dbl list   Rebinning Parameters. See Rebin for format. If only a single value is provided, start and end are taken from input workspaces.
ScaleRHSWorkspace Input boolean True Scaling either with respect to workspace 1 or workspace 2
UseManualScaleFactor Input boolean False True to use a provided value for the scale factor.
ManualScaleFactor Input number 1 Provided value for the scale factor. Optional.
OutScaleFactor Output number   The actual used value for the scaling factor.

Description

Stitches single histogram Matrix Workspaces together outputting a stitched Matrix Workspace. Either the right-hand-side or left-hand-side workspace can be chosen to be scaled. Users must provide a Param step (single value), but the binning start and end are calculated from the input workspaces if not provided. Likewise, StartOverlap and EndOverlap are optional. If the StartOverlap or EndOverlap are not provided, then these are taken to be the region of x-axis intersection.

The workspaces must be histogrammed. Use ConvertToHistogram v1 on workspaces prior to passing them to this algorithm.

Special Value Processing

Special values, meaning infinite and NaN double precision values, are treated in a different way by the algorithm. The processing is as follows:

  1. The workspaces are initially rebinned, as prescribed by the rebin Params (determined automatically if not provided)
  2. Each spectra is searched for signal values and error values that are special values. Positions and type of special value are recorded
  3. Special values found in the previous step are set to zero
  4. Stitching proceeds, integration will not be performed considering any special values
  5. Post processing the indexes of the special values are used to put the special values back where they came from

Usage

Example - a basic example using stitch1D to stitch two workspaces together.

import numpy as np

def gaussian(x, mu, sigma):
  """Creates a gaussian peak centered on mu and with width sigma."""
  return (1/ sigma * np.sqrt(2 * np.pi)) * np.exp( - (x-mu)**2  / (2*sigma**2))

#create two histograms with a single peak in each one
x1 = np.arange(-1, 1, 0.02)
x2 = np.arange(0.4, 1.6, 0.02)
ws1 = CreateWorkspace(UnitX="1/q", DataX=x1, DataY=gaussian(x1[:-1], 0, 0.1)+1)
ws2 = CreateWorkspace(UnitX="1/q", DataX=x2, DataY=gaussian(x2[:-1], 1, 0.05)+1)

#stitch the histograms together
stitched, scale = Stitch1D(LHSWorkspace=ws1, RHSWorkspace=ws2, StartOverlap=0.4, EndOverlap=0.6, Params=0.02)

Output:

Stitch1D output

Example - a practical example using reflectometry data and a scale factor.

trans1 = Load('INTER00013463')
trans2 = Load('INTER00013464')

trans1_wav = CreateTransmissionWorkspaceAuto(trans1)
trans2_wav = CreateTransmissionWorkspaceAuto(trans2)

stitched_wav, y = Stitch1D(trans1_wav, trans2_wav, UseManualScaleFactor=True, ManualScaleFactor=0.85)

Output:

Stitch1D output

Categories: Algorithms | Reflectometry

Source

C++ source: Stitch1D.cpp

C++ header: Stitch1D.h