MergeRuns v1

../_images/MergeRuns-v1_dlg.png

MergeRuns dialog.

Summary

Combines the data contained in an arbitrary number of input workspaces.

Properties

Name Direction Type Default Description
InputWorkspaces Input str list Mandatory The names of the input workspaces as a list. You may also group workspaces using the GUI or [[GroupWorkspaces]], and specify the name of the group instead.
OutputWorkspace Output Workspace Mandatory Name of the output workspace
SampleLogsTimeSeries Input string   A comma separated list of the sample logs to merge into a time series. The initial times are taken as the start times for the run, and the merged sample log is suffixed with “_time_series”. Sample logs must be numeric.
SampleLogsList Input string   A comma separated list of the sample logs to merge into a list. The merged sample log is suffixed with “_list”.
SampleLogsWarn Input string   A comma separated list of the sample logs to generate a warning if different when merging.
SampleLogsWarnTolerances Input string   The tolerances for warning if sample logs are different. Can either be empty for a comparison of the strings, a single value for all warn sample logs, or a comma separated list of values (must be the same length as SampleLogsWarn).
SampleLogsFail Input string   The sample logs to fail if different when merging. If there is a difference the run is skipped.
SampleLogsFailTolerances Input string   The tolerances for failing if sample logs are different. Can either be empty for a comparison of the strings, a single value for all fail sample logs, or a comma separated list of values (must be the same length as SampleLogsFail).

Description

Combines the data contained in an arbitrary number of input workspaces. If the input workspaces do not have common binning, the bins in the output workspace will cover the entire range of all the input workspaces, with the largest bin widths used in regions of overlap.

The combination of each workspace is performed using the Plus v1 algorithm, this does not preform any weighting based on the duration of collection, or proton charge. If you wish to perform Merge runs that should not be equally weighted then they should be corrected individually prior to merging.

Restrictions on the input workspace

The input workspaces must contain histogram data with the same number of spectra and matching units and instrument name in order for the algorithm to succeed.

Workspace2Ds: Each input workspace must have common binning for all its spectra.

EventWorkspaces: This algorithm is Event-aware; it will append event lists from common spectra. Binning parameters need not be compatible; the output workspace will use the first workspaces’ X bin boundaries.

WorkspaceGroups: Each nested has to be one of the above.

Other than this it is currently left to the user to ensure that the combination of the workspaces is a valid operation.

Processing Group Workspaces

Multi-period Group Workspaces

Group workspaces will be merged respecting the periods within each group. For example if you have two multiperiod group workspaces A and B and an output workspace C. A contains matrix workspaces A_1 and A_2, and B contains matrix workspaces B_1 and B2. Since this is multiperiod data, A_1 and B_1 share the same period, as do A_2 and B_2. So merging must be with respect to workspaces of equivalent periods. Therefore, merging is conducted such that A_1 + B_1 = C_1 and A_2 + B_2 = C_2.

Group Workspaces that are not multiperiod

If group workspaces are provided that are not multi-period, this algorithm will merge across all nested workspaces, to give a singe output matrix workspace.

Merging Sample Logs

Sample logs are optionally merged when running this algorithm. The behaviour when merging is defined in the instrument parameter file, but can be added to or overridden via this algorithm. Definitions in the XML file are given as shown in the example below. See the usage examples at the end of this document for examples of overriding the behaviour defined in the XML file.

When performing the tolerance check for the warn or fail options it is always with respect to the first workspace in the merge. When choosing via the GUI this will be the first workspace that was selected.

Note: this currently only works when the underying workspaces being merged are Matrix Workspaces.

<parameter name="sample_logs_time_series" type="string">
    <value val="sample.temperature, sample.pressure" />
</parameter>
<parameter name="sample_logs_list" type="string">
    <value val="run_number" />
</parameter>
<parameter name="sample_logs_warn" type="string">
    <value val="EPP, Fermi.phase, sample.temperature" />
</parameter>
<parameter name="sample_logs_warn_tolerances" type="string">
    <value val="5, 0.001, 50" />
</parameter>
<parameter name="sample_logs_fail" type="string">
    <value val="experiment_identifier, Ei, Fermi.rotation_speed" />
</parameter>
<parameter name="sample_logs_fail_tolerances" type="string">
    <value val="0, 0.1, 2" />
</parameter>

ChildAlgorithms used

The Rebin v1 algorithm is used, if neccessary, to put all the input workspaces onto a common binning.

The Plus v1 algorithm is used to combine each of the workspaces together one pair at a time.

Usage

Example: Merge Two Workspaces

dataX = [1, 2, 3, 4, 5]
dataY = [6, 15, 21, 9]

a = CreateWorkspace(dataX, dataY)
b = CreateWorkspace(dataX, dataY)

merged = MergeRuns(InputWorkspaces="a, b")

print "a      = " + str(a.readY(0))
print "b      = " + str(b.readY(0))
print "merged = " + str(merged.readY(0))

Output:

a      = [  6.  15.  21.   9.]
b      = [  6.  15.  21.   9.]
merged = [ 12.  30.  42.  18.]

Example: Merge Two GroupWorkspaces

dataX = [1, 2, 3, 4, 5]
dataY = [6, 15, 21, 9]

a = CreateWorkspace(dataX, dataY)
b = CreateWorkspace(dataX, dataY)
c = CreateWorkspace(dataX, dataY)
d = CreateWorkspace(dataX, dataY)

group_1 = GroupWorkspaces(InputWorkspaces="a, b")
group_2 = GroupWorkspaces(InputWorkspaces="c, d")

merged = MergeRuns(InputWorkspaces="group_1, group_2")

print "group_1 = [" + str(group_1[0].readY(0)) + ","
print "           " + str(group_1[1].readY(0)) + "]"

print "group_2 = [" + str(group_2[0].readY(0)) + ","
print "           " + str(group_2[1].readY(0)) + "]"

print "merged   = " + str(merged.readY(0))

Output:

group_1 = [[  6.  15.  21.   9.],
           [  6.  15.  21.   9.]]
group_2 = [[  6.  15.  21.   9.],
           [  6.  15.  21.   9.]]
merged   = [ 24.  60.  84.  36.]

Note

To run these usage examples please first download the usage data, and add these to your path. In MantidPlot this is done using Manage User Directories.

Example: Merge Workspace Combining Sample Logs as a TimeSeries

Load(Filename='MUSR00015189.nxs, MUSR00015190.nxs', OutputWorkspace='gws')

merged = MergeRuns(InputWorkspaces='MUSR00015189_1, MUSR00015190_1',
                   SampleLogsTimeSeries='sample_magn_field')

print merged.run().getLogData('sample_magn_field_time_series').valueAsString().rstrip()

Output:

2007-Nov-27 17:10:35  1350
2007-Nov-27 17:12:30  1360

Example: Merge Workspace Combining Sample Logs as a List

Load(Filename='MUSR00015189.nxs, MUSR00015190.nxs', OutputWorkspace='gws')

merged = MergeRuns(InputWorkspaces='MUSR00015189_1, MUSR00015190_1',
                   SampleLogsList='sample_magn_field')

print merged.run().getLogData('sample_magn_field_list').value

Output:

1350, 1360

Example: Merge Workspace Combining Sample Logs with a Warnining if Different

Load(Filename='MUSR00015189.nxs, MUSR00015190.nxs', OutputWorkspace='gws')

merged = MergeRuns(InputWorkspaces='MUSR00015189_1, MUSR00015190_1',
                   SampleLogsTimeSeries='sample_temp',
                   SampleLogsWarn='sample_magn_field')

print merged.run().getLogData('sample_temp_time_series').size()

Output:

2

Example: Merge Workspace Combining Sample Logs with an Error if Different

Load(Filename='MUSR00015189.nxs, MUSR00015190.nxs', OutputWorkspace='gws')

merged = MergeRuns(InputWorkspaces='MUSR00015189_1, MUSR00015190_1',
                   SampleLogsTimeSeries='sample_magn_field',
                   SampleLogsFail='sample_magn_field, nspectra',
                   SampleLogsFailTolerances='5, 0')

print merged.run().getLogData('sample_magn_field_time_series').size()

Output:

1

Categories: Algorithms | Transforms\Merging

Source

C++ source: MergeRuns.cpp

C++ header: MergeRuns.h