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

MatchAndMergeWorkspaces v1

../_images/MatchAndMergeWorkspaces-v1_dlg.png

MatchAndMergeWorkspaces dialog.

Summary

Merges a group workspace using weighting from a set of range limits for each workspace.

Properties

Name Direction Type Default Description
InputWorkspaces Input str list Mandatory List of workspaces or group workspace containing workspaces to be merged.
OutputWorkspace Output Workspace Mandatory The merged workspace.
XMin Input dbl list   Array of minimum X values for each workspace.
XMax Input dbl list   Array of maximum X values for each workspace.
CalculateScale Input boolean True Calculate scale factor when matching spectra.
CalculateOffset Input boolean True Calculate vertical shift when matching spectra.

Description

This is a workflow algorithm that merges down a workspace, workspace group, or list of workspaces, MatchSpectra <algm-MatchSpectra> and sums the spectra using weighted mean from ranges for each spectra. For each workspace an XMin and XMax is supplied, the workspace is then cropped to that range and all workspaces are Rebinned to have common bin edges. The output is the mean value for each bin for all workspaces with a value in that bin. This is done by executing several sub-algorithms as listed below.

  1. Rebin v1 To rebin all spectra to have common bins.
  2. ConjoinWorkspaces v1 repeated for every workspaces in the workspace group.
  3. MatchSpectra v1 Matched against the spectra with the largest original x range.
  4. CropWorkspaceRagged v1 to cut spectra to match the X limits given.
  5. Rebin v1 To rebin all spectra to have common bins.
  6. SumSpectra v1 using WeightedSum=True and MultiplyBySpectra=False.

Usage

from mantid.simpleapi import *

import numpy as np

from isis_powder import polaris, SampleDetails
config_file_path = r"C:/Users/wey38795/Documents/polaris-calculate-pdf/polaris_config_example.yaml"
polaris = polaris.Polaris(config_file=config_file_path, user_name="test", mode="PDF")

sample_details = SampleDetails(height=4.0, radius=0.2985, center=[0, 0, 0], shape='cylinder')
sample_details.set_material(chemical_formula='Si')
polaris.set_sample_details(sample=sample_details)

polaris.create_vanadium(first_cycle_run_no="98532",
                        multiple_scattering=False)
polaris.focus(run_number="98533", input_mode='Summed')

polaris.create_total_scattering_pdf(run_number="98533", merge_banks=False)
x_min = np.array([0.5, 3, 4, 6, 7])
x_max = np.array([3.5, 5, 7, 11, 20])
merged_ws = MatchAndMergeWorkspaces(WorkspaceGroup='focused_ws', XMin=x_min, XMax=x_max, CalculateScale=False)

fig, ax = plt.subplots(subplot_kw={'projection':'mantid'})
ax.plot(merged_ws)
ax.legend()
fig.show()

This will produce a plot that looks like this:

../_images/MatchAndMergeWorkspaces.png

Source

Python: MatchAndMergeWorkspaces.py (last modified: 2020-03-27)