Skip to content

Commit

Permalink
Put LinearBackGround into slit/bar fitting re #6344
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 Feb 11, 2013
1 parent e39d22e commit 5c6e86e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions Code/Mantid/scripts/Calibration/tube_calib.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ def getPoints ( IntegratedWorkspace, funcForms, fitParams, whichTube, showPlot=F
#margin = 0.3
margin = 0.2

# Use a different workspace if plotting, so plot survives.
# Set workspace names, a different workspace if plotting, so plot survives.
calibPointWs = "CalibPoint"
getPointsWs = "getPoints"
if(showPlot):
getPointsWs = "TubePlot"
else:
getPointsWs = "getPoints"

# Check functional form
if ( nFf != 0 and nFf < nPts):
Expand All @@ -123,6 +123,10 @@ def getPoints ( IntegratedWorkspace, funcForms, fitParams, whichTube, showPlot=F
edgeMode = 1 # We assume first edge is approached from outside
# Loop over the points
for i in range(nPts):
# Use different workpace if plotting fit, so plot survives
if(showPlot):
calibPointWs = "TubeCalibPlot"+str(i)

if( nFf != 0 and funcForms[i] == 2 ):
# We have an edge
centre = eP[i]
Expand All @@ -132,10 +136,10 @@ def getPoints ( IntegratedWorkspace, funcForms, fitParams, whichTube, showPlot=F
else:
start = eP[i] - inedge
end = eP[i] + outedge
Fit(InputWorkspace=getPointsWs,Function=fitEndErfcParams(centre,endGrad*edgeMode),StartX=str(start),EndX=str(end),Output="CalibPoint")
Fit(InputWorkspace=getPointsWs,Function=fitEndErfcParams(centre,endGrad*edgeMode),StartX=str(start),EndX=str(end),Output=calibPointWs)
edgeMode = -edgeMode # Next edge would be reverse of this edge
else:
# We have a slit
# We have a slit or bar
centre = eP[i]
if( i == 0):
start = (1-margin)*eP[i]
Expand All @@ -145,9 +149,10 @@ def getPoints ( IntegratedWorkspace, funcForms, fitParams, whichTube, showPlot=F
end = (1-margin)*eP[i] + (margin)*nDets
else:
end = (1-margin)*eP[i] + (margin)*eP[i+1]
Fit(InputWorkspace=getPointsWs,Function=fitGaussianParams(eHeight,centre,eWidth), StartX=str(start),EndX=str(end),Output="CalibPoint")
Fit(InputWorkspace=getPointsWs,Function='name=LinearBackground, A0=1000',StartX=str(start),EndX=str(end),Output="Z1")
Fit(InputWorkspace="Z1_Workspace",Function=fitGaussianParams(eHeight,centre,eWidth), WorkspaceIndex='2',StartX=str(start),EndX=str(end),Output=calibPointWs)

paramCalibPeak = mtd['CalibPoint_Parameters']
paramCalibPeak = mtd[calibPointWs+'_Parameters']
pkRow = paramCalibPeak.row(1).items()
thisResult = pkRow[1][1]
if( start < thisResult and thisResult < end):
Expand Down

0 comments on commit 5c6e86e

Please sign in to comment.