\(\renewcommand\AA{\unicode{x212B}}\)
GenerateGoniometerIndependentBackground v1¶
Summary¶
Extract the background from a dataset where sample is rotated through multiple positions
Properties¶
Name |
Direction |
Type |
Default |
Description |
---|---|---|---|---|
InputWorkspaces |
Input |
str list |
Mandatory |
Input workspaces. Must be Event Workspace and have at least 2 input workspaces. |
GroupingFile |
Input |
string |
Mandatory |
A file that consists of lists of spectra numbers to group. To be read by LoadDetectorsGroupingFile v1. Allowed extensions: [‘.map’, ‘.xml’] |
PercentMin |
Input |
number |
0 |
Starting percentage range of input files that will be combined to create the background |
PercentMax |
Input |
number |
20 |
Ending percentage range of input files that will be combined to create the background |
OutputWorkspace |
Output |
Mandatory |
Extracted background workspace. |
Description¶
This algorithm will extract the background from a dataset where sample is rotated through multiple positions, so that I don’t need to make a separate background measurement.
This algorithm requires at least 2 input Event Workspace that are all binned identically. The proton charge of the workspaces are check to be within 1% of each other as this algorithm assume all the data was collected in the same conditions.
This algorithm operates by first grouping the detectors of the input workspaces with the provided GroupingFile
. Then iterating through each bin of each spectra of the grouped workspaces, selecting the range (defined by PercentMin
and PercentMax
properties) of workspaces sorted by intensity for that bin, copying the events from the associated ungrouped input to the output workspace. The output is then normalized by the number of input workspaces selected.
Usage¶
Example - GenerateGoniometerIndependentBackground
# create 4 sample workspaces with different intensities
for n in range(1,5):
ws = CreateSampleWorkspace(WorkspaceType='Event', Function='Flat background', BinWidth=10000, NumEvents=n*1000, NumBanks=2, BankPixelWidth=1, OutputWorkspace=f"w{n}")
print(f"Input workspace w{n} intensity = ", ws.readY(0))
# create a grouping workspace, group by bank
CreateGroupingWorkspace(InputWorkspace='w1', GroupDetectorsBy='bank', OutputWorkspace='groups')
SaveDetectorsGrouping("groups", "/tmp/groups.xml")
# select only the lowest 25% intensity workspaces
background = GenerateGoniometerIndependentBackground('w1,w2,w3,w4', GroupingFile="/tmp/groups.xml", PercentMin=0, PercentMax=25)
print("Background intensity, lowest 25% =", background.readY(0))
# select only the highest 25% intensity workspaces
background = GenerateGoniometerIndependentBackground('w1,w2,w3,w4', GroupingFile="/tmp/groups.xml", PercentMin=75, PercentMax=100)
print("Background intensity, highest 25% =", background.readY(0))
# select only the middle 50%intensity workspaces
background = GenerateGoniometerIndependentBackground('w1,w2,w3,w4', GroupingFile="/tmp/groups.xml", PercentMin=25, PercentMax=75)
print("Background intensity, middle 50% =", background.readY(0))
Output:
Input workspace w1 intensity = [500. 500.]
Input workspace w2 intensity = [1000. 1000.]
Input workspace w3 intensity = [1500. 1500.]
Input workspace w4 intensity = [2000. 2000.]
Background intensity, lowest 25% = [500. 500.]
Background intensity, highest 25% = [2000. 2000.]
Background intensity, middle 50% = [1250. 1250.]
Categories: AlgorithmIndex | CorrectionFunctions\BackgroundCorrections
Source¶
C++ header: GenerateGoniometerIndependentBackground.h
C++ source: GenerateGoniometerIndependentBackground.cpp