Skip to content

Commit

Permalink
Started to fix background subtraction. This refs #4303"
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanBilheux committed Feb 7, 2012
1 parent 36bc9c4 commit 913f2e1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 35 deletions.
55 changes: 30 additions & 25 deletions Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,41 +207,45 @@ def PyExec(self):
geo_correction=True,
q_binning=[q_min,q_step,q_max])

ConvertToHistogram(InputWorkspace=ws_integrated_data,
OutputWorkspace=ws_integrated_data)

ws_data = "__DataWks"
ws_transposed = '__TransposedID'
Transpose(InputWorkspace=ws_integrated_data,
OutputWorkspace=ws_transposed)

ConvertToHistogram(InputWorkspace=ws_transposed,
OutputWorkspace=ws_transposed)

if subtract_data_bck:
ConvertToHistogram(InputWorkspace=ws_integrated_data,
OutputWorkspace=ws_integrated_data)

Transpose(InputWorkspace=ws_integrated_data,
OutputWorkspace=ws_transposed)

ConvertToHistogram(InputWorkspace=ws_transposed,
OutputWorkspace=ws_transposed)

FlatBackground(InputWorkspace=ws_transposed,
OutputWorkspace=ws_transposed,
StartX=BackfromYpixel,
Mode='Mean',
EndX=data_peak[0],
OutputMode="Return Background")

ws_data_bck = "__DataBckWks"
Transpose(InputWorkspace=ws_transposed,
OutputWorkspace=ws_data_bck)
ws_data_bck = "__DataBckWks"
Transpose(InputWorkspace=ws_transposed,
OutputWorkspace=ws_data_bck)

ConvertToHistogram(ws_data_bck, OutputWorkspace=ws_data_bck)
RebinToWorkspace(WorkspaceToRebin=ws_data_bck,
WorkspaceToMatch=ws_integrated_data,
OutputWorkspace=ws_data_bck)
ConvertToHistogram(ws_data_bck, OutputWorkspace=ws_data_bck)
RebinToWorkspace(WorkspaceToRebin=ws_data_bck,
WorkspaceToMatch=ws_integrated_data,
OutputWorkspace=ws_data_bck)

ws_data = "__DataWks"
Minus(ws_integrated_data, ws_data_bck, OutputWorkspace=ws_data)

# Clean up intermediary workspaces
mtd.deleteWorkspace(ws_data_bck)
mtd.deleteWorkspace(ws_integrated_data)
mtd.deleteWorkspace(ws_transposed)
mtd.deleteWorkspace(ws_histo_data)
Minus(ws_integrated_data, ws_data_bck, OutputWorkspace=ws_data)

# Clean up intermediary workspaces
mtd.deleteWorkspace(ws_integrated_data)
mtd.deleteWorkspace(ws_histo_data)
mtd.deleteWorkspace(ws_data_bck)
mtd.deleteWorkspace(ws_transposed)

else:
ConvertToHistogram(InputWorkspace=ws_integrated_data,
OutputWorkspace=ws_data)


# Work on Normalization file #########################################
Expand Down Expand Up @@ -338,8 +342,9 @@ def PyExec(self):
Divide(LHSWorkspace=ws_data,
RHSWorkspace=ws_norm_rebinned,
OutputWorkspace=ws_data)

ReplaceSpecialValues(InputWorkspace=ws_data, NaNValue=0, NaNError=0, InfinityValue=0, InfinityError=0, OutputWorkspace=ws_data)

output_ws = self.getPropertyValue("OutputWorkspace")

if mtd.workspaceExists(output_ws):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,6 @@ def convertToRvsQ(dMD=-1,theta=-1,tof=None):
_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 @@ -437,9 +435,6 @@ 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 @@ -452,11 +447,6 @@ 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 913f2e1

Please sign in to comment.