Skip to content

Commit

Permalink
Fixed geometry correction. This refs #4303.
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Feb 1, 2012
1 parent f5a886e commit 5ed91f1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def PyExec(self):
source_to_detector=dMD,
sample_to_detector=dSD,
theta=theta,
geo_correction=False,
geo_correction=True,
q_binning=[q_min,q_step,q_max])

ConvertToHistogram(InputWorkspace='IntegratedDataWks1',
Expand Down Expand Up @@ -276,7 +276,6 @@ def PyExec(self):
OutputWorkspace='NormBckWks')

ConvertToHistogram("NormBckWks", OutputWorkspace="NormBckWks")
# RebinToWorkspace(WorkspaceToRebin="NormBckWks", WorkspaceToMatch="IntegratedNormWks", OutputWorkspace="NormBckWks")
RebinToWorkspace(WorkspaceToRebin="NormBckWks", WorkspaceToMatch="IntegratedNormWks", OutputWorkspace="NormBckWks")

Minus("IntegratedNormWks", "NormBckWks", OutputWorkspace="NormWks")
Expand All @@ -293,15 +292,20 @@ def PyExec(self):

# Normalization
SumSpectra(InputWorkspace="NormWks", OutputWorkspace="NormWks")


#### divide data by normalize histo workspace
Divide(LHSWorkspace='DataWks',
RHSWorkspace='NormWks',
OutputWorkspace='NormalizedWks')
ReplaceSpecialValues("NormalizedWks",NaNValue=0,NaNError=0, OutputWorkspace="NormalizedWks")

output_ws = self.getPropertyValue("OutputWorkspace")
mt1 = mtd['DataWks']
print mt1.readE(0)[:]

mt2 = mtd['NormWks']
print mt2.readE(0)[:]

output_ws = self.getPropertyValue("OutputWorkspace")

SumSpectra(InputWorkspace="NormalizedWks", OutputWorkspace=output_ws)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,18 +155,25 @@ def createIntegratedWorkspace(mt1, outputWorkspace,
_y_error_axis_tmp = _y_error_axis_tmp[::-1]

CreateWorkspace(OutputWorkspace=_outputWorkspace,
DataX=_q_axis[_q_index],
DataX=q_axis,
DataY=_y_axis_tmp,
DataE=_y_error_axis_tmp,
Nspec=1,
UnitX="MomentumTransfer")

if _q_index == 0:
mt_tmp = mtd[_outputWorkspace]

_outputWorkspace_rebin = 'tmpOWks_' + str(_q_index)

Rebin(InputWorkspace=_outputWorkspace,
OutputWorkspace=_outputWorkspace_rebin,
Params=q_binning)

if _q_index == 0:
mt_tmp = mtd[_outputWorkspace_rebin]


_mt = mtd['tmpOWks_0']
_x_array = _mt.readX(0)[:]

Expand Down Expand Up @@ -390,13 +397,17 @@ def convertToRvsQWithCorrection(mt, dMD=-1, theta=-1,tof=None, yrange=None, cpix
for x in xrange:
_px = yrange[x]
dangle = ref_beamdiv_correct(cpix, mt, dSD, _px)
#theta += (2.0 * dangle)
theta += dangle

if dangle is not None:
_theta = theta + dangle
else:
_theta = theta

for t in range(sz_tof-1):
tof1 = tof[t]
tof2 = tof[t+1]
tofm = (tof1+tof2)/2.
_Q = _const * math.sin(theta) / (tofm*1e-6)
_Q = _const * math.sin(_theta) / (tofm*1e-6)
q_array[x,t] = _Q*1e-10

return q_array
Expand Down Expand Up @@ -430,17 +441,20 @@ def ref_beamdiv_correct(cpix, mt, det_secondary,
last_slit_size = getS2h(mt)

last_slit_dist = 0.654 #m
slit_dist = 2.193 #m
slit_dist = 0.885000050068 #m

first_slit_size = float(first_slit_size[0]) * 0.001
last_slit_size = float(last_slit_size[0]) * 0.001

_y = 0.5 * (first_slit_size[0] + last_slit_size[0])
_y = 0.5 * (first_slit_size + last_slit_size)
_x = slit_dist
gamma_plus = math.atan2( _y, _x)

_y = 0.5 * (first_slit_size[0] - last_slit_size[0])
_y = 0.5 * (first_slit_size - last_slit_size)
_x = slit_dist
gamma_minus = math.atan2( _y, _x)

half_last_aperture = 0.5 * last_slit_size[0]
half_last_aperture = 0.5 * last_slit_size
neg_half_last_aperture = -1.0 * half_last_aperture

last_slit_to_det = last_slit_dist + det_secondary
Expand Down Expand Up @@ -539,7 +553,7 @@ def ref_beamdiv_correct(cpix, mt, det_secondary,
center_of_mass = calc_center_of_mass(int_poly_x,
int_poly_y,
area)

return center_of_mass

def calc_area_2D_polygon(x_coord, y_coord, size_poly):
Expand Down

0 comments on commit 5ed91f1

Please sign in to comment.