AlignAndFocusPowderSlim v1¶
Warning
This algorithm is currently for the VULCAN instrument testing purposes
Summary¶
Algorithm to focus powder diffraction data into a number of histograms according to a grouping scheme defined in a CalFile.
See Also¶
Properties¶
Name |
Direction |
Type |
Default |
Description |
|---|---|---|---|---|
Filename |
Input |
string |
Mandatory |
The name of the Event NeXus file to read, including its full or relative path. The file name is typically of the form INST_####_event.nxs. Allowed extensions: [‘.nxs.h5’, ‘.nxs’, ‘_event.nxs’] |
FilterByTimeStart |
Input |
number |
Optional |
To only include events after the provided start time, in seconds (relative to the start of the run). |
FilterByTimeStop |
Input |
number |
Optional |
To only include events before the provided stop time, in seconds (relative to the start of the run). |
SplitterWorkspace |
Input |
Input workspace specifying “splitters”, i.e. time intervals and targets for event filtering. Currently only a single output workspace is supported. |
||
RelativeTime |
Input |
boolean |
False |
Flag indicating whether in SplitterWorkspace the times are absolute or relative. If true, they are relative to the run start time. |
ProcessBankSplitTask |
Input |
boolean |
False |
For development testing. Changes how the splitters are processed. If true then use ProcessBankSplitTask otherwise loop over ProcessBankTask. |
CorrectionToSample |
Input |
boolean |
False |
Find time-of-flight when neutron was at the sample position. This is only necessary for fast logs (i.e. more frequent than proton on target pulse). |
UseFullTime |
Input |
boolean |
False |
If true, events will be splitting using full time values (tof+pulsetime) rather than just pulsetime. |
FilterBadPulses |
Input |
boolean |
False |
Filter bad pulses in the same way that FilterBadPulses v1 does. |
BadPulsesLowerCutoff |
Input |
number |
95 |
The percentage of the average to use as the lower bound when filtering bad pulses. |
GroupingWorkspace |
Input |
GroupingWorkspace |
A GroupingWorkspace giving the grouping info. If not provided then the grouping from the calibration file will be used if provided, else a default grouping of one group per bank. |
|
CalFileName |
Input |
string |
The .cal file containing the position correction factors. Either this or OffsetsWorkspace needs to be specified. Allowed extensions: [‘.h5’, ‘.hd5’, ‘.hdf’, ‘.cal’] |
|
XMin |
Input |
dbl list |
0.1 |
Minimum x-value for the output binning |
XDelta |
Input |
dbl list |
0.0016 |
Bin size for output data |
XMax |
Input |
dbl list |
2 |
Minimum x-value for the output binning |
BinningUnits |
Input |
string |
dSpacing |
The units of the input X min, max and delta values. Output will always be TOF. Allowed values: [‘dSpacing’, ‘TOF’, ‘MomentumTransfer’] |
BinningMode |
Input |
string |
Logarithmic |
Specify binning behavior (‘Logarithmic’). Allowed values: [‘Logarithmic’, ‘Linear’] |
LogAllowList |
Input |
str list |
If specified, only these logs will be loaded from the file |
|
LogBlockList |
Input |
str list |
If specified, these logs will not be loaded from the file |
|
OutputWorkspace |
Output |
Mandatory |
An output workspace. |
|
ReadSizeFromDisk |
Input |
number |
100000000 |
Number of elements of time-of-flight or detector-id to read at a time. This is a maximum |
EventsPerThread |
Input |
number |
1000000 |
Number of events to read in a single thread. Higher means less threads are created. |
BankNumber |
Input |
number |
Optional |
The bank for which to read data; if specified, others will be blank |
L1 |
Input |
number |
Mandatory |
The primary distance \(\ell_1\) from beam to sample |
L2 |
Input |
dbl list |
Mandatory |
The secondary distances \(\ell_2\) from sample to focus group |
Polar |
Input |
dbl list |
Mandatory |
The effective polar angle (\(2\theta\)) of each focus group |
Azimuthal |
Input |
dbl list |
The effective azimuthal angle \(\phi\) for each focus group |
Description¶
This is a simplified version of AlignAndFocusPowderFromFiles v1 which uses very few child algorithms. The main feature is that this reads the events, filters and adjusts their time-of-flight, then increments the correct bin in the output workspace. As a result, there is a significantly smaller memory usage and the processing is significantly faster.
Current limitations compared to AlignAndFocusPowderFromFiles
does not support copping data
does not support removing prompt pulse
Child algorithms used are
Usage¶
Example - event filtering
This algorithm accepts the same SplitterWorkspace inputs as FilterEvents and more information can be found on the Event Filtering page.
# create splitter table using relative time
splitter = CreateEmptyTableWorkspace()
splitter.addColumn('float', 'start')
splitter.addColumn('float', 'stop')
splitter.addColumn('str', 'target')
splitter.addRow((10,20, '0'))
splitter.addRow((200,210, '0'))
splitter.addRow((400,410, '0'))
# pass the splitter table to AlignAndFocusPowderSlim
ws = AlignAndFocusPowderSlim("VULCAN_218062.nxs.h5",
SplitterWorkspace=splitter, RelativeTime=True,
XMin=0, XMax=50000, XDelta=50000,
BinningMode="Linear",
BinningUnits="TOF",
L1=43.755,
L2=[2.296, 2.296, 2.070, 2.070, 2.070, 2.530],
Polar=[90, 90, 120, 150, 157, 65.5],
Azimuthal=[180, 0, 0, 0, 0, 0])
# This is equivalent to using FilterEvents with the same splitter table.
# But note that this example doesn't align the data so put everything in 1 big bin to compare.
ws2 = LoadEventNexus("VULCAN_218062.nxs.h5", NumberOfBins=1)
grp = CreateGroupingWorkspace(ws2, GroupDetectorsBy='bank')
ws2 = GroupDetectors(ws2, CopyGroupingFromWorkspace="grp")
FilterEvents(ws2,
SplitterWorkspace=splitter, RelativeTime=True,
FilterByPulseTime=True,
OutputWorkspaceBaseName="filtered",
GroupWorkspaces=True)
out = Rebin("filtered", "0,50000,50000", PreserveEvents=False)
CompareWorkspaces(ws, out, CheckSpectraMap=False, CheckInstrument=False)
Example - splitting events based on log values
# Load only the log we need
cave_temperature = LoadEventNexus("VULCAN_218062.nxs.h5",
MetaDataOnly=True,
AllowList="CaveTemperature")
# Use GenerateEventsFilter to create a splitter table based on the log values
GenerateEventsFilter(cave_temperature,
OutputWorkspace='splitter',
InformationWorkspace='info',
LogName='CaveTemperature',
MinimumLogValue=70.10,
MaximumLogValue=70.15,
LogValueInterval=0.01)
# Use the splitter table to filter the events during loading and output to workspace group
ws = AlignAndFocusPowderSlim("VULCAN_218062.nxs.h5", SplitterWorkspace='splitter',
L1=43.755,
L2=[2.296, 2.296, 2.070, 2.070, 2.070, 2.530],
Polar=[90, 90, 120, 150, 157, 65.5],
Azimuthal=[180, 0, 0, 0, 0, 0])
print(ws.getNumberOfEntries()) # should be 6 workspaces in the group
# By default the events are split based on pulsetime of the events. If you want to split based on full time (pulsetime + tof), set UseFullTime=False.
ws2 = AlignAndFocusPowderSlim("VULCAN_218062.nxs.h5",
SplitterWorkspace='splitter',
UseFullTime=True,
L1=43.755,
L2=[2.296, 2.296, 2.070, 2.070, 2.070, 2.530],
Polar=[90, 90, 120, 150, 157, 65.5],
Azimuthal=[180, 0, 0, 0, 0, 0])
Example - filter bad pulses
ws = AlignAndFocusPowderSlim("VULCAN_218062.nxs.h5",
XMin=0, XMax=50000, XDelta=50000,
BinningMode="Linear",
BinningUnits="TOF",
FilterBadPulses=True,
L1=43.755,
L2=[2.296, 2.296, 2.070, 2.070, 2.070, 2.530],
Polar=[90, 90, 120, 150, 157, 65.5],
Azimuthal=[180, 0, 0, 0, 0, 0])
# This is equivalent to using FilterBadPulses.
# But note that this example doesn't align the data so put everything in 1 big bin to compare.
ws2 = LoadEventNexus("VULCAN_218062.nxs.h5")
grp = CreateGroupingWorkspace(ws2, GroupDetectorsBy='bank')
ws2 = GroupDetectors(ws2, CopyGroupingFromWorkspace="grp")
ws2 = FilterBadPulses(ws2)
ws2 = Rebin(ws2, "0,50000,50000", PreserveEvents=False)
CompareWorkspaces(ws, ws2, CheckSpectraMap=False, CheckInstrument=False)
Example - using a GroupingWorkspace
You can provide a GroupingWorkspace to define how the detectors are grouped in the output workspace. If a GroupingWorkspace is not provided, the grouping from the calibration file will be used if provided, else a default grouping of one group per bank is used.
The example done here is using GenerateGroupingPowder to create a grouping workspace. With an angle step of 45 degrees, this will create 3 groups.
inst = LoadEmptyInstrument(InstrumentName="VULCAN")
GenerateGroupingPowder(inst, GroupingWorkspace='powder_group', AngleStep=45)
ws = AlignAndFocusPowderSlim("VULCAN_218062.nxs.h5", GroupingWorkspace="powder_group",
L1=43.755,
L2=[2, 2.25, 2.5],
Polar=[90]*3)
print(ws.getNumberHistograms()) # should be 3 histograms in the output workspace
Categories: AlgorithmIndex | Workflow\Diffraction
Source¶
C++ header: AlignAndFocusPowderSlim.h
C++ source: AlignAndFocusPowderSlim.cpp