Expected behavior
Sensible integration
Actual behavior
Not sensible integration. Result gives values way beyond realistic range. Repeated running of script below also gives different results.
Steps to reproduce the behavior
# The following line helps with future compatibility with Python 3
# print must now be used as a function, e.g print('Hello','World')
from __future__ import (absolute_import, division, print_function, unicode_literals)
# import mantid algorithms, numpy and matplotlib
from mantid.simpleapi import *
import matplotlib.pyplot as plt
import numpy as np
w = np.linspace(-0.5,0.5,1000)
q = np.linspace(0.2,2,50)
W,Q = np.meshgrid(w, q)
g = 0.15*Q**2
S = g/(W**2+g**2)
rnd = 25*np.random.rand(50000).reshape(50,1000)
fake_data = S+rnd
test_ws = CreateWorkspace(DataX = W, DataY = fake_data, NSpec=50)
fig, axs = plt.subplots(2,1)
axs[0].pcolormesh(W,Q, (S+rnd))
def quickinteg(workspace):
''' Takes a reduced workspace and integrates all spectra over an energy range'''
ws = mtd[workspace]
el_y, el_e = [],[]
spec = [i for i in range(ws.getNumberHistograms())]
for i in spec:
print('integrating workspace %s' %i)
elastic_ws = Integration(ws, StartWorkspaceIndex=i, EndWorkspaceIndex=i,
RangeLower = -0.0175, RangeUpper = 0.0175)
elasticy , elastice = elastic_ws.readY(0), elastic_ws.readE(0)
el_y.append(elasticy); el_e.append(elastice)
all_el_y = np.stack(el_y, axis = -1); all_el_e = np.stack(el_e, axis = -1)
elastic = CreateWorkspace(DataX=spec, DataY=all_el_y, DataE=all_el_e, NSpec = 1, UnitX='MomentumTransfer', YUnitLabel = 'Elastic Intensity')
RenameWorkspaces([elastic], Prefix = '%s_' %ws.name())
quickeisf('test_ws')
int_ws = mtd['test_ws_elastic']
x, y = int_ws.readX(0), int_ws.readY(0)
axs[1].plot(x,y)
plt.show
Platforms affected
Problem seen using Workbench 5.0.0 on mac