Skip to content

Commit

Permalink
Complete work on deleting unwanted workspaces at end re #5414
Browse files Browse the repository at this point in the history
Signed-off-by: Karl Palmen <karl.palmen@stfc.ac.uk>
  • Loading branch information
KarlPalmen committed Oct 26, 2012
1 parent 5dfd141 commit a09ed74
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# Get calibration raw file and integrate it
rawMapWS = Load(path+filename) #'raw' in 'rawMapWS' means unintegrated.
mapWS = Integration( rawMapWS, RangeLower=rangeLower, RangeUpper=rangeUpper )
DeleteWorkspace(rawMapWS)


# == Create Objects needed for calibration ==
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
filename = 'WISH00017701.raw' # Name of calibration run
rawMapWS = Load(path+filename) #'raw' in 'rawMapWS' means unintegrated.
mapWS = Integration( rawMapWS, RangeLower=1, RangeUpper=20000 )
DeleteWorkspace(rawMapWS)

#Create Calibration Table
calibrationTable = CreateEmptyTableWorkspace(OutputWorkspace="CalibTable")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
filename = 'WISH00017701.raw' # Name of calibration run
rawMapWS = Load(path+filename) #'raw' in 'rawMapWS' means unintegrated.
mapWS = Integration( rawMapWS, RangeLower=1, RangeUpper=20000 )
DeleteWorkspace(rawMapWS)

#Create Calibration Table
calibrationTable = CreateEmptyTableWorkspace(OutputWorkspace="CalibTable")
Expand Down
62 changes: 33 additions & 29 deletions Code/Mantid/scripts/Calibration/tube_calib.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ def createTubeCalibtationWorkspaceByWorkspaceIndexList ( integratedWorkspace, ou
Return Value: Workspace created
"""

nSpectra = len(workspaceIndexList)
if( nSpectra < 1):
return
Expand Down Expand Up @@ -72,7 +73,7 @@ def fitEndErfcParams ( B, C ): # Compose string argument for fit
#print "name=EndErfc, B="+str(B)+", C="+str(C)
return "name=EndErfc, B="+str(B)+", C="+str(C)

def get3pointsFor3pointMethod ( IntegratedWorkspace, whichTube, fitParams):
def get3pointsFor3pointMethod ( IntegratedWorkspace, whichTube, fitParams ):
"""
Get the three points for the three point calibration method
from a centre peak, the left rise and right fall of the function.
Expand Down Expand Up @@ -135,26 +136,10 @@ def get3pointsFor3pointMethod ( IntegratedWorkspace, whichTube, fitParams):
C = g[1][1]
else:
C = (A+B)/2.0 # If we haven't got a centre peak, we put one half way between the end points.

# Delete temporary workspaces
DeleteWorkspace( 'get3pointsFor3pointMethod')
DeleteWorkspace('Z1_NormalisedCovarianceMatrix')
DeleteWorkspace('Z1_Parameters')
DeleteWorkspace('Z1_Workspace')
DeleteWorkspace('CentrePoint_NormalisedCovarianceMatrix')
DeleteWorkspace('CentrePoint_Parameters')
DeleteWorkspace('CentrePoint_Workspace')
DeleteWorkspace('LeftPoint_NormalisedCovarianceMatrix')
DeleteWorkspace('LeftPoint_Parameters')
DeleteWorkspace('LeftPoint_Workspace')
DeleteWorkspace('RightPoint_NormalisedCovarianceMatrix')
DeleteWorkspace('RightPoint_Parameters')
DeleteWorkspace('RightPoint_Workspace')



return A, B, C

def getPeaksForNSlitsMethod ( IntegratedWorkspace, eP, eHeight, eWidth, whichTube):
def getPeaksForNSlitsMethod ( IntegratedWorkspace, eP, eHeight, eWidth, whichTube ):
"""
Get the centres of N slits for calibration
This N slit method is suited for WISH or the five sharp peaks of MERLIN .
Expand Down Expand Up @@ -321,14 +306,6 @@ def correctTubeToIdealTube( tubePoints, idealTubePoints, nDets, TestMode=False )
for i in range( len(usedTubePoints) ):
#print "used point",i,"shoving pixel",int(usedTubePoints[i]+0.5)
xResult[ int(usedTubePoints[i]+0.5) ] = xResult[0]


# Delete temporary workspaces
DeleteWorkspace('QuadraticFittingWorkspace')
DeleteWorkspace('QF_NormalisedCovarianceMatrix')
DeleteWorkspace('QF_Parameters')
DeleteWorkspace('QF_Workspace')


# print xResult
return xResult
Expand Down Expand Up @@ -425,12 +402,12 @@ def getCalibration ( ws, tubeSet, calibTable, fitPar, iTube, PeakTestMode=False,
actualTube = OverridePeaks
elif( fitPar.isThreePointMethod() ):
# Find the three peaks in the tube
AP, BP, CP = get3pointsFor3pointMethod( ws, wht, fitPar )
AP, BP, CP = get3pointsFor3pointMethod( ws, wht, fitPar)
#print i+1, AP, BP, CP
actualTube = [AP, CP, BP]
else:
ht, wd = fitPar.getHeightAndWidth()
actualTube = getPeaksForNSlitsMethod ( ws, eP, ht, wd, wht)
actualTube = getPeaksForNSlitsMethod ( ws, eP, ht, wd, wht )
print actualTube

if( len(actualTube) == 0):
Expand All @@ -453,3 +430,30 @@ def getCalibration ( ws, tubeSet, calibTable, fitPar, iTube, PeakTestMode=False,
if(PeakFile != ""):
pFile.close()

# Delete temporary workspaces for obtaioning slit points
if( fitPar.isThreePointMethod() ):
DeleteWorkspace( 'get3pointsFor3pointMethod')
DeleteWorkspace('Z1_NormalisedCovarianceMatrix')
DeleteWorkspace('Z1_Parameters')
DeleteWorkspace('Z1_Workspace')
DeleteWorkspace('CentrePoint_NormalisedCovarianceMatrix')
DeleteWorkspace('CentrePoint_Parameters')
DeleteWorkspace('CentrePoint_Workspace')
DeleteWorkspace('LeftPoint_NormalisedCovarianceMatrix')
DeleteWorkspace('LeftPoint_Parameters')
DeleteWorkspace('LeftPoint_Workspace')
DeleteWorkspace('RightPoint_NormalisedCovarianceMatrix')
DeleteWorkspace('RightPoint_Parameters')
DeleteWorkspace('RightPoint_Workspace')
else:
DeleteWorkspace('getPeaksForNSlitsMethod')
DeleteWorkspace('CalibPeak_NormalisedCovarianceMatrix')
DeleteWorkspace('CalibPeak_Parameters')
DeleteWorkspace('CalibPeak_Workspace')

# Delete temporary workspaces for getting new detector positions
DeleteWorkspace('QuadraticFittingWorkspace')
DeleteWorkspace('QF_NormalisedCovarianceMatrix')
DeleteWorkspace('QF_Parameters')
DeleteWorkspace('QF_Workspace')

0 comments on commit a09ed74

Please sign in to comment.