Skip to content

Commit

Permalink
Modified the way the Qrange is calculated. Now, it's using the mid TO…
Browse files Browse the repository at this point in the history
…F bin value instead of the left value. This refs #4303
  • Loading branch information
JeanBilheux committed Feb 2, 2012
1 parent f2243e5 commit 33c2845
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
19 changes: 17 additions & 2 deletions Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from MantidFramework import *
from mantidsimple import *
from numpy import zeros, shape
import math

class RefLReduction(PythonAlgorithm):

Expand Down Expand Up @@ -167,9 +169,22 @@ def PyExec(self):
theta = tthd_rad - ths_rad

if dMD is not None and theta is not None:
# _tof_axis = mtd[ws_histo_data].readX(0)
# print _tof_axis
# _const = float(4) * math.pi * m * dMD / h
# _q_axis = 1e-10 * _const * math.sin(theta) / (_tof_axis*1e-6)
# q_max = max(_q_axis)

_tof_axis = mtd[ws_histo_data].readX(0)
_const = float(4) * math.pi * m * dMD / h
_q_axis = 1e-10 * _const * math.sin(theta) / (_tof_axis*1e-6)
sz_tof = numpy.shape(_tof_axis)[0]
_q_axis = zeros(sz_tof-1)
for t in range(sz_tof-1):
tof1 = _tof_axis[t]
tof2 = _tof_axis[t+1]
tofm = (tof1+tof2)/2.
_Q = _const * math.sin(theta) / (tofm*1e-6)
_q_axis[t] = _Q*1e-10
q_max = max(_q_axis)

wks_utility.createIntegratedWorkspace(mtd[ws_histo_data],
Expand All @@ -184,7 +199,7 @@ def PyExec(self):
source_to_detector=dMD,
sample_to_detector=dSD,
theta=theta,
geo_correction=True,
geo_correction=False,
q_binning=[q_min,q_step,q_max])

ConvertToHistogram(InputWorkspace='IntegratedDataWks1',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,9 @@ def convertToRvsQ(dMD=-1,theta=-1,tof=None):
TOF: TOF of pixel
theta: angle of detector
"""
print 'dMD: '
print dMD
print

_const = float(4) * math.pi * m * dMD / h
sz_tof = numpy.shape(tof)[0]
Expand All @@ -357,6 +360,9 @@ def convertToRvsQ(dMD=-1,theta=-1,tof=None):
tofm = (tof1+tof2)/2.
_Q = _const * math.sin(theta) / (tofm*1e-6)
q_array[t] = _Q*1e-10

print 'q_array'
print q_array
return q_array

def convertToRvsQWithCorrection(mt, dMD=-1, theta=-1,tof=None, yrange=None, cpix=None):
Expand Down Expand Up @@ -398,6 +404,9 @@ def convertToRvsQWithCorrection(mt, dMD=-1, theta=-1,tof=None, yrange=None, cpix
_px = yrange[x]
dangle = ref_beamdiv_correct(cpix, mt, dSD, _px)

print 'dangle:'
print dangle

if dangle is not None:
_theta = theta + dangle
else:
Expand All @@ -410,6 +419,11 @@ def convertToRvsQWithCorrection(mt, dMD=-1, theta=-1,tof=None, yrange=None, cpix
_Q = _const * math.sin(_theta) / (tofm*1e-6)
q_array[x,t] = _Q*1e-10

print 'q_array'
print q_array

print

return q_array

def getQHisto(source_to_detector, theta, tof_array):
Expand Down

0 comments on commit 33c2845

Please sign in to comment.