Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
.. algorithm::
.. summary::
.. alias::
.. properties::
Description
-----------
Merges workspaces from a given list using :ref:`algm-MergeRuns` algorithm. Sample logs are merged in the following way.
+---------++-------------------------------+
| Type of || Parameter |
| merging || |
+=========++===============================+
| Average || temperature |
+---------++-------------------------------+
| Minimum || run_start |
+---------++-------------------------------+
| Maximum || run_end |
+---------++-------------------------------+
| Summed || duration, monitor_counts |
+---------++-------------------------------+
| Listed || run_number |
+---------++-------------------------------+
Other sample logs are copied from the first workspace.
**Valid input workspaces**
Algorithm accepts both, matrix workspaces and groups of matrix workspaces. Valid input workspaces
- must have following sample logs: *channel_width*, *chopper_ratio*, *chopper_speed*, *Ei*, *wavelength*, *full_channels*, *EPP*, *monitor_counts*, *duration*, *run_number*, *run_start*, *run_end*
- must have identical following sample logs: *channel_width*, *chopper_ratio*, *chopper_speed*, *Ei*, *wavelength*, *full_channels*, *EPP*. Tolerance for double comparison is 0.01.
- must have common binning for all its spectra for each input workspace.
If these conditions are not fulfilled, algorithm terminates with an error message.
Sample log *temperature* is optional. If it is present in some of input workspaces, mean value will be calculated. Otherwise, no *temperature* sample log will be created in the output workspace.
Algorithm will produce warning if
- *temperature* and *run_title* sample logs are not present or different,
- some of input workspaces have zero monitor counts.
Usage
-----
**Example - Merge list of workspaces**
.. testcode:: ExTOFTOFMergeRuns2ws
ws1 = LoadMLZ(Filename='TOFTOFTestdata.nxs')
ws2 = LoadMLZ(Filename='TOFTOFTestdata.nxs')
# change sample logs for a second workspace, not needed for real workspaces
AddSampleLog(ws1, 'temperature', str(294.14), 'Number')
lognames = 'temperature,run_start,run_end,monitor_counts,run_number'
logvalues = '296.16,2013-07-28T11:32:19+0053,2013-07-28T12:32:19+0053,145145,TOFTOFTestdata2'
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
AddSampleLogMultiple(ws2, lognames, logvalues)
# Input = list of workspaces
ws3 = TOFTOFMergeRuns('ws1,ws2')
# Temperature
print "Temperature of experiment for 1st workspace (in K): ", ws1.getRun().getLogData('temperature').value
print "Temperature of experiment for 2nd workspace (in K): ", ws2.getRun().getLogData('temperature').value
print "Temperature of experiment for merged workspaces = average over workspaces (in K): ", ws3.getRun().getLogData('temperature').value
# Duration
print "Duration of experiment for 1st workspace (in s): ", ws1.getRun().getLogData('duration').value
print "Duration of experiment for 2nd workspace (in s): ", ws2.getRun().getLogData('duration').value
print "Duration of experiment for merged workspaces = sum of all durations (in s): ", ws3.getRun().getLogData('duration').value
# Run start
print "Start of experiment for 1st workspace: ", ws1.getRun().getLogData('run_start').value
print "Start of experiment for 2nd workspace: ", ws2.getRun().getLogData('run_start').value
print "Start of experiment for merged workspaces = miminum of all workspaces: ", ws3.getRun().getLogData('run_start').value
# Run end
print "End of experiment for 1st workspace: ", ws1.getRun().getLogData('run_end').value
print "End of experiment for 2nd workspace: ", ws2.getRun().getLogData('run_end').value
print "End of experiment for merged workspaces = maximum of all workspaces: ", ws3.getRun().getLogData('run_end').value
# Run number
print "Run number for 1st workspace: ", ws1.getRun().getLogData('run_number').value
print "Run number for 2nd workspace: ", ws2.getRun().getLogData('run_number').value
print "Run number for merged workspaces = list of all workspaces: ", ws3.getRun().getLogData('run_number').value
# Monitor counts
print "Monitor counts for 1st workspace: ", ws1.getRun().getLogData('monitor_counts').value
print "Monitor counts for 2nd workspace: ", ws2.getRun().getLogData('monitor_counts').value
print "Monitor counts for merged workspaces = sum over all workspaces: ", ws3.getRun().getLogData('monitor_counts').value
Output:
.. testoutput:: ExTOFTOFMergeRuns2ws
Property temperature does not match! TOFTOFTestdata: 294.14, but TOFTOFTestdata2: 296.16
Temperature of experiment for 1st workspace (in K): 294.14
Temperature of experiment for 2nd workspace (in K): 296.16
Temperature of experiment for merged workspaces = average over workspaces (in K): 295.15
Duration of experiment for 1st workspace (in s): 3601
Duration of experiment for 2nd workspace (in s): 3601
Duration of experiment for merged workspaces = sum of all durations (in s): 7202
Start of experiment for 1st workspace: 2013-07-28T10:32:19+0053
Start of experiment for 2nd workspace: 2013-07-28T11:32:19+0053
Start of experiment for merged workspaces = miminum of all workspaces: 2013-07-28T10:32:19+0053
End of experiment for 1st workspace: 2013-07-28T11:32:20+0053
End of experiment for 2nd workspace: 2013-07-28T12:32:19+0053
End of experiment for merged workspaces = maximum of all workspaces: 2013-07-28T12:32:19+0053
Run number for 1st workspace: TOFTOFTestdata
Run number for 2nd workspace: TOFTOFTestdata2
Run number for merged workspaces = list of all workspaces: ['TOFTOFTestdata', 'TOFTOFTestdata2']
Monitor counts for 1st workspace: 136935
Monitor counts for 2nd workspace: 145145
Monitor counts for merged workspaces = sum over all workspaces: 282080
**Example - Merge group of workspaces**
.. testcode:: ExTOFTOFMergeRunsGroup
ws1 = LoadMLZ(Filename='TOFTOFTestdata.nxs')
ws2 = LoadMLZ(Filename='TOFTOFTestdata.nxs')
# change sample logs for a second workspace, not needed for real workspaces
AddSampleLog(ws1, 'temperature', str(294.14), 'Number')
lognames = 'temperature,run_start,run_end,monitor_counts,run_number'
logvalues = '296.16,2013-07-28T11:32:19+0053,2013-07-28T12:32:19+0053,145145,TOFTOFTestdata2'
AddSampleLogMultiple(ws2, lognames, logvalues)
group=GroupWorkspaces('ws1,ws2')
groupmerged=TOFTOFMergeRuns(group)
print "Monitor counts for 1st workspace: ", ws1.getRun().getLogData('monitor_counts').value
print "Monitor counts for 2nd workspace: ", ws2.getRun().getLogData('monitor_counts').value
print "Monitor counts for merged workspaces = sum over all workspaces: ", groupmerged.getRun().getLogData('monitor_counts').value
Output:
.. testoutput:: ExTOFTOFMergeRunsGroup
Property temperature does not match! TOFTOFTestdata: 294.14, but TOFTOFTestdata2: 296.16