Skip to content

Commit

Permalink
Fixed issue with the way some of the workspace were cleared in REFL_r…
Browse files Browse the repository at this point in the history
…eduction. Added infos messages to REFLSFcalculator and still working on making the code GUI compatible. This refs #4303 #5071
  • Loading branch information
JeanBilheux committed May 1, 2012
1 parent d0d2ba4 commit 26af31e
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 44 deletions.
133 changes: 97 additions & 36 deletions Code/Mantid/Framework/PythonAPI/PythonAlgorithms/RefLReduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,35 +322,58 @@ def PyExec(self):
RHSWorkspace=ws_data_bck+'_scale',
OutputWorkspace=ws_data)

mtd.deleteWorkspace(ws_data_bck+'_scale')
mtd.deleteWorkspace(ws_data_bck)
mtd.deleteWorkspace(ws_data_bck_1_rebin)
mtd.deleteWorkspace(ws_data_bck_2_rebin)
mtd.deleteWorkspace(ws_data_bck_1)
mtd.deleteWorkspace(ws_data_bck_2)
mtd.deleteWorkspace(ws_histo_data)
if mtd.workspaceExists(ws_data_bck+'_scale'):
mtd.deleteWorkspace(ws_data_bck+'_scale')

if mtd.workspaceExists(ws_data_bck):
mtd.deleteWorkspace(ws_data_bck)

if mtd.workspaceExists(ws_data_bck_1_rebin):
mtd.deleteWorkspace(ws_data_bck_1_rebin)

if mtd.workspaceExists(ws_data_bck_2_rebin):
mtd.deleteWorkspace(ws_data_bck_2_rebin)

if mtd.workspaceExists(ws_data_bck_1):
mtd.deleteWorkspace(ws_data_bck_1)

if mtd.workspaceExists(ws_data_bck_2):
mtd.deleteWorkspace(ws_data_bck_2)

if mtd.workspaceExists(ws_histo_data):
mtd.deleteWorkspace(ws_histo_data)

elif (bBackLeft):

Minus(LHSWorkspace=ws_histo_data,
RHSWorkspace=ws_data_bck_1_rebin,
OutputWorkspace=ws_data)
mtd.deleteWorkspace(ws_data_bck_1_rebin)
mtd.deleteWorkspace(ws_data_bck_1)

if mtd.workspaceExists(ws_data_bck_1_rebin):
mtd.deleteWorkspace(ws_data_bck_1_rebin)

if mtd.workspaceExists(ws_data_bck_1):
mtd.deleteWorkspace(ws_data_bck_1)

elif (bBackRight):

Minus(LHSWorkspace=ws_histo_data,
RHSWorkspace=ws_data_bck_2_rebin,
OutputWorkspace=ws_data)
mtd.deleteWorkspace(ws_data_bck_2_rebin)
mtd.deleteWorkspace(ws_data_bck_2)

if mtd.workspaceExists(ws_data_bck_2_rebin):
mtd.deleteWorkspace(ws_data_bck_2_rebin)

if mtd.workspaceExists(ws_data_bck_2):
mtd.deleteWorkspace(ws_data_bck_2)

#cleanup (remove all negatives values
ResetNegatives(InputWorkspace=ws_data,
OutputWorkspace=ws_data,
AddMinimum=0)
mtd.deleteWorkspace(ws_histo_data)

if mtd.workspaceExists(ws_histo_data):
mtd.deleteWorkspace(ws_histo_data)

if (subtract_data_bck and (backSubMethod == 2)):

Expand Down Expand Up @@ -440,7 +463,8 @@ def PyExec(self):
OutputWorkspace=ws_data,
AddMinimum=0)

mtd.deleteWorkspace(ws_histo_data+'_1D')
if mtd.workspaceExists(ws_histo_data+'_1D'):
mtd.deleteWorkspace(ws_histo_data+'_1D')

# SumSpectra(InputWorkspace=ws_data,
# OutputWorkspace='wks_after_back_subtraction_1d')
Expand All @@ -459,8 +483,8 @@ def PyExec(self):
ConvertToMatrixWorkspace(InputWorkspace=ws_data,
OutputWorkspace=ws_data)


mtd.deleteWorkspace(ws_histo_data)
if mtd.workspaceExists(ws_histo_data):
mtd.deleteWorkspace(ws_histo_data)

if (NormFlag):

Expand Down Expand Up @@ -574,30 +598,54 @@ def PyExec(self):
Minus(LHSWorkspace=ws_norm_histo_data,
RHSWorkspace=ws_norm_bck+'_scale',
OutputWorkspace=ws_norm_rebinned)
mtd.deleteWorkspace(ws_norm_bck_1_rebin)
mtd.deleteWorkspace(ws_norm_bck_2_rebin)
mtd.deleteWorkspace(ws_norm_bck_1)
mtd.deleteWorkspace(ws_norm_bck_2)
mtd.deleteWorkspace(ws_norm_histo_data)
mtd.deleteWorkspace(ws_norm_bck+'_scale')

if mtd.workspaceExists(ws_norm_bck_1_rebin):
mtd.deleteWorkspace(ws_norm_bck_1_rebin)

if mtd.workspaceExists(ws_norm_bck_2_rebin):
mtd.deleteWorkspace(ws_norm_bck_2_rebin)

if mtd.workspaceExists(ws_norm_bck_1):
mtd.deleteWorkspace(ws_norm_bck_1)

if mtd.workspaceExists(ws_norm_bck_2):
mtd.deleteWorkspace(ws_norm_bck_2)

if mtd.workspaceExists(ws_norm_histo_data):
mtd.deleteWorkspace(ws_norm_histo_data)

if mtd.workspaceExists(ws_norm_bck+'_scale'):
mtd.deleteWorkspace(ws_norm_bck+'_scale')

elif (bBackLeft):

Minus(LHSWorkspace=ws_norm_histo_data,
RHSWorkspace=ws_norm_bck_1_rebin,
OutputWorkspace=ws_norm_rebinned)
mtd.deleteWorkspace(ws_norm_bck_1_rebin)
mtd.deleteWorkspace(ws_norm_bck_1)
mtd.deleteWorkspace(ws_norm_histo_data)

if mtd.workspaceExists(ws_norm_bck_1_rebin):
mtd.deleteWorkspace(ws_norm_bck_1_rebin)

if mtd.workspaceExists(ws_norm_bck_1):
mtd.deleteWorkspace(ws_norm_bck_1)

if mtd.workspaceExists(ws_norm_histo_data):
mtd.deleteWorkspace(ws_norm_histo_data)

elif (bBackRight):

Minus(LHSWorkspace=ws_norm_histo_data,
RHSWorkspace=ws_norm_bck_2_rebin,
OutputWorkspace=ws_norm_rebinned)
mtd.deleteWorkspace(ws_norm_bck_2_rebin)
mtd.deleteWorkspace(ws_norm_bck_2)
mtd.deleteWorkspace(ws_norm_histo_data)

if mtd.workspaceExists(ws_norm_bck_2_rebin):
mtd.deleteWorkspace(ws_norm_bck_2_rebin)

if mtd.workspaceExists(ws_norm_bck_2):
mtd.deleteWorkspace(ws_norm_bck_2)

if mtd.workspaceExists(ws_norm_histo_data):
mtd.deleteWorkspace(ws_norm_histo_data)


#Here I need to set to zeros all the negative entries
Expand Down Expand Up @@ -698,8 +746,11 @@ def PyExec(self):
RHSWorkspace='background',
OutputWorkspace=ws_norm_rebinned)

mtd.deleteWorkspace(ws_norm_histo_data+'_1D')
mtd.deleteWorkspace('background')
if mtd.workspaceExists(ws_norm_histo_data+'_1D'):
mtd.deleteWorkspace(ws_norm_histo_data+'_1D')

if mtd.workspaceExists('background'):
mtd.deleteWorkspace('background')

ResetNegatives(InputWorkspace=ws_norm_rebinned,
OutputWorkspace=ws_norm_rebinned,
Expand All @@ -724,7 +775,8 @@ def PyExec(self):
WorkspaceToMatch=ws_data,
OutputWorkspace=ws_norm_rebinned)

mtd.deleteWorkspace(ws_integrated_data)
if mtd.workspaceExists(ws_integrated_data):
mtd.deleteWorkspace(ws_integrated_data)

#Normalization
print '-> Sum spectra'
Expand Down Expand Up @@ -799,7 +851,8 @@ def PyExec(self):
geo_correction=False,
q_binning=[q_min,q_step,q_max])

mtd.deleteWorkspace(ws_integrated_data)
if mtd.workspaceExists(ws_integrated_data):
mtd.deleteWorkspace(ws_integrated_data)

else:
ws_data_Q = ws_data + '_Q'
Expand All @@ -816,7 +869,8 @@ def PyExec(self):
geo_correction=True,
q_binning=[q_min,q_step,q_max])

mtd.deleteWorkspace(ws_data_scaled)
if mtd.workspaceExists(ws_data_scaled):
mtd.deleteWorkspace(ws_data_scaled)


print '-> replace special values'
Expand Down Expand Up @@ -880,10 +934,17 @@ def PyExec(self):

#cleanup all workspace used
print '-> Cleaning useless workspaces'
mtd.deleteWorkspace(ws_event_data)
mtd.deleteWorkspace(ws_data_Q)
mtd.deleteWorkspace(ws_data)
mtd.deleteWorkspace(ws_norm_event_data)
if mtd.workspaceExists(ws_event_data):
mtd.deleteWorkspace(ws_event_data)

if mtd.workspaceExists(ws_data_Q):
mtd.deleteWorkspace(ws_data_Q)

if mtd.workspaceExists(ws_data):
mtd.deleteWorkspace(ws_data)

if mtd.workspaceExists(ws_norm_event_data):
mtd.deleteWorkspace(ws_norm_event_data)

print

Expand Down

0 comments on commit 26af31e

Please sign in to comment.