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

CrossCorrelate v1

Summary

Cross-correlates a range of spectra against one reference spectra in the same workspace.

See Also

GetDetectorOffsets

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

A 2D workspace with X values of d-spacing

OutputWorkspace

Output

MatrixWorkspace

Mandatory

The name of the output workspace

ReferenceSpectra

Input

number

0

The Workspace Index of the spectra to correlate all other spectra against.

WorkspaceIndexMin

Input

number

0

The workspace index of the first member of the range of spectra to cross-correlate against.

WorkspaceIndexMax

Input

number

0

The workspace index of the last member of the range of spectra to cross-correlate against.

WorkspaceIndexList

Input

unsigned int list

A comma-separated list of individual workspace indices of spectra to cross-correlate against.

XMin

Input

number

0

The starting point of the region to be cross correlated.

XMax

Input

number

0

The ending point of the region to be cross correlated.

MaxDSpaceShift

Input

number

Optional

Optional float for maximum shift to calculate (in d-spacing)

Description

Compute the cross correlation function for a range of spectra with respect to a reference spectrum.

\[c_{fg}(r) = \frac{1}{\sigma_f \sigma_g} \int (f(x) - \mu_f) (g(x+r)-\mu_g) dx\]

This is use in powder diffraction experiments when trying to estimate the offset of one spectra with respect to another one. The spectra are converted in d-spacing and then interpolate on the X-axis of the reference. The cross correlation function is computed in the range [-N/2,N/2] where N is the number of points.

More details can be found here.

Usage

Example - Crosscorrelate 2 spectra

#Create a workspace with 2 spectra with five bins of width 0.5
ws = CreateSampleWorkspace(BankPixelWidth=1, XUnit='dSpacing', XMax=5, BinWidth=0.5)
ws = ScaleX(InputWorkspace='ws', Factor=0.5, Operation='Add', IndexMin=1, IndexMax=1)
# Run algorithm  CrossCorrelate
OutputWorkspace = CrossCorrelate(InputWorkspace='ws', WorkspaceIndexMax=1, XMin=2, XMax=4)

# Show workspaces
print("AutoCorrelation {}".format(OutputWorkspace.readY(0)))
print("CrossCorrelation {}".format(OutputWorkspace.readY(1)))
AutoCorrelation [-0.01890212  1.         -0.01890212]
CrossCorrelation [-0.68136257  0.16838401  0.45685055]

Categories: AlgorithmIndex | Arithmetic

Source

C++ header: CrossCorrelate.h

C++ source: CrossCorrelate.cpp