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

SANSDarkRunBackgroundCorrection v1

Summary

Correct SANS data with a dark run measurement.

Properties

Name

Direction

Type

Default

Description

InputWorkspace

Input

MatrixWorkspace

Mandatory

DarkRun

Input

MatrixWorkspace

Mandatory

OutputWorkspace

Output

MatrixWorkspace

Mandatory

The corrected SANS workspace.

NormalizationRatio

Input

number

1

Number to scale the dark run in orderto make it comparable to the SANS run

Mean

Input

boolean

False

If True then a mean value of all spectra is used to calculate the value to subtract

Uniform

Input

boolean

True

If True then we treat the treat the tim ebins a

ApplyToDetectors

Input

boolean

True

If True then we apply the correction to the detector pixels

ApplyToMonitors

Input

boolean

False

If True then we apply the correction to the monitors

SelectedMonitors

Input

long list

List of selected detector IDs of monitors to which the correction should be applied. If empty, all monitors will be corrected, if ApplyToMonitors has been selected.

Description

This algorithm subtracts a dark run from a workspace. InputWorkspace and DarkRun have to be of type Workspace2D and need to contain the same spectra. The user can choose to either subtract spectra which are associated with detecors (ApplyToDetectors) and/or monitors (ApplyToMonitors). In the case of monitors, the user can select specific monitors (SelectedMonitors) according to their detecotor IDs.

The NormalizationRatio is used to scale the signal values of the DarkRun workspace before subtraction.

The background subtraction can be performed in several ways.

  • Uniform disabled: DarkRun is subtracted bin by bin from the InputWorkspace.

  • Uniform enabled: An average value for each spectra of the DarkRun is calculated. This average value is subtracted from the corresponding spectrum of the InputWorkspace. Note that Mean cannot be enabled when Uniform is disabled.

  • Mean enabled: This calculates an average over all spectra. This average is subtracted from all the spectra

  • Mean disabled: The subtraction happens for all spectra separately.

Usage

Example - SANSDarkRunBackgroundCorrection for

# Create sample workspaces. Note that the dark run is here the same as the sample run
ws_sample = CreateSampleWorkspace()
ws_dark_run = CloneWorkspace(ws_sample)

out_ws = SANSDarkRunBackgroundCorrection(InputWorkspace = ws_sample,
                                         DarkRun = ws_dark_run,
                                         NormalizationRatio = 0.5,
                                         Uniform = False,
                                         Mean = False,
                                         ApplyToDetectors = True,
                                         ApplyToMonitors = False)

# We should have effectively halfed the data values
in_y = ws_sample.dataY(0)
out_y = out_ws.dataY(0)

print("The first bin of the first spectrum of the input was {:.1f}".format(in_y[0]))
print("After the dark run correction it is {:.2f}".format(out_y[0]))

Output:

The first bin of the first spectrum of the input was 0.3
After the dark run correction it is 0.15

Categories: AlgorithmIndex | Workflow\SANS\UsesPropertyManager

Source

Python: SANSDarkRunBackgroundCorrection.py