Skip to content
Snippets Groups Projects
Commit 32cd0b03 authored by Robert Applin's avatar Robert Applin
Browse files

Refs #21401. Propagate y value errors for _elt workspace[C

parent a325b6d1
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,9 @@ from mantid.kernel import *
from mantid.api import *
import numpy as np
def _normalize_by_index(workspace, index):
"""
Normalize each spectra of the specified workspace by the
......@@ -19,15 +22,23 @@ def _normalize_by_index(workspace, index):
@param workspace The workspace to normalize.
@param index The index of the y-value to normalize by.
"""
number_of_histograms = workspace.getNumberHistograms()
for idx in range(0, number_of_histograms):
y_values = workspace.readY(idx)
y_errors = workspace.readE(idx)
# Normalise y values
scale = np.reciprocal(y_values[index])
y_values_normalised = scale * y_values
num_hist = workspace.getNumberHistograms()
# Propagate y errors: C = A / B ; dC = sqrt( (dA/B)^2 + (A*dB/B^2)^2 )
a = (y_errors*scale)
b = (y_values*y_errors[index]*(scale ** 2))
y_errors_propagated = np.sqrt(a ** 2 + b ** 2)
# Normalize each spectrum in the workspace
for idx in range(0, num_hist):
y_vals = workspace.readY(idx)
scale = 1.0 / y_vals[index]
y_vals_scaled = scale * y_vals
workspace.setY(idx, y_vals_scaled)
workspace.setY(idx, y_values_normalised)
workspace.setE(idx, y_errors_propagated)
class ElasticWindowMultiple(DataProcessorAlgorithm):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment