Skip to content

Commit

Permalink
Conforming documentation to rest
Browse files Browse the repository at this point in the history
small changes to conform documentation to rest.

For tube_calib_fit_params add an attribute that allows the fitting steps to
guess the best parameters (automatic).

re #7387
  • Loading branch information
gesnerpassos committed Jul 12, 2013
1 parent ab0df6d commit 90edebe
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 30 deletions.
38 changes: 27 additions & 11 deletions Code/Mantid/scripts/Calibration/tube_calib_fit_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,33 @@ class TubeCalibFitParams:

# Author: Karl Palmen ISIS

def __init__(self, peaks, Height=1000.0, Width=30.0, ThreePointMethod=False, outEdge=30.0, inEdge=50.0, EdgeGrad=6.0, Margin=0.4):
def __init__(self, peaks, height=1000.0, width=30.0, threePointMethod=False, outEdge=30.0, inEdge=50.0, edgeGrad=6.0, margin=10):

"""
Creates an instance
@param peaks: expected positions of the peaks in pixels
@param height: expect height of peaks
@param width: expected width (sigma for Gaussian fitting) of peaks
@param ThreePointMethod: True if three point method is used (first and last peaks are the extreme ends of very wide peaks).
:param peaks: expected positions of the peaks in pixels
:param height: expect height of peaks
:param width: expected width (sigma for Gaussian fitting) of peaks
:param threePointMethod: True if three point method is used (first and last peaks are the extreme ends of very wide peaks).
:param margin: defines the region around the peak that will be considered for fitting
This class has also an attribute, called automatic, accessed through getAutomatic, that
defines it a dynamic evaluation of the fit parameters can be used or not.
"""
# Peaks
self.height = Height*1.0
self.width = Width*1.0
self.height = height*1.0
self.width = width*1.0
self.peaks = peaks
# Margin
self.margin = Margin
self.margin = margin
# Three pointMethod parameter (to be phased out)
self.threePointMethod = ThreePointMethod
self.threePointMethod = threePointMethod
# Edges
self.outEdge = outEdge
self.inEdge = inEdge
self.edgeGrad = EdgeGrad
self.edgeGrad = edgeGrad
self.automatic = False

def getPeaks(self):
return self.peaks
Expand All @@ -45,5 +50,16 @@ def getEdgeParameters(self):

def getMargin(self):
return self.margin

def setMargin(self, mar):
self.margin = mar

def setAutomatic(self, boolOption):
self.automatic = boolOption

def getAutomatic(self):
return self.automatic

def __str__(self):
return 'peaks'+str(self.peaks)+'height'+str(self.height)+'width'+str(self.width)+'margin'+str(self.margin)+'outedge'+str(self.outEdge)+'inedge'+str(self.inEdge)+'edgegrad'+str(self.edgeGrad )


38 changes: 19 additions & 19 deletions Code/Mantid/scripts/Calibration/tube_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def __init__(self,ws):
"""
Creates empty tube specification for specified instrument.
@param ws: workspace containing the specified instrument with one pixel detector per spectrum.
:param ws: workspace containing the specified instrument with one pixel detector per spectrum.
"""
self.ws = ws
self.inst = ws.getInstrument()
Expand All @@ -33,7 +33,7 @@ def setTubeSpecByString(self, tubeSpecString ):
If the tube specification is not empty this component is added to those already
in the specification. No checking is done for repeated or overlapping components.
@param tubeSpecString: string specifying tubes of a component of the instrument
:param tubeSpecString: string specifying tubes of a component of the instrument
The 'tubeSpecString' may be the full path name for the component or
steps may be missed out provided it remains unique.
Expand Down Expand Up @@ -64,9 +64,9 @@ def isTube(self, comp):
"""
Determines whether the component is a tube.
@param comp: the component
:param comp: the component
@return Value: true if component passes test as being a tube
:rtype: Value, true if component passes test as being a tube
"""
# We simply assume it's a tube if it has a large number of children
if( hasattr( comp, "nelements")):
Expand All @@ -78,7 +78,7 @@ def searchForTubes(self, comp):
"""
Searches the component for tubes and saves them in array, appending if array is not empty.
@param comp: the component
:param comp: the component
"""
# Go through all descendents that are not a descendent of a tube and if it's a tube, store and count it.

Expand All @@ -96,7 +96,7 @@ def getNumTubes(self):
"""
Returns number of tubes specified. May also save info about these tubes
@return Value: number of tubes (-1 for erroneous specification)
:rtype: Value, number of tubes (-1 for erroneous specification)
"""
if(self.numTubes >= 0):
return self.numTubes
Expand All @@ -117,7 +117,7 @@ def getComponent ( self ):
"""
Returns instrument component corresponding to specification
@Return value: instrument component
:rtype: instrument component
"""
if( self.componentArray != []):
return self.componentArray[0]
Expand All @@ -137,7 +137,7 @@ def getComponents ( self ):
"""
Returns instrument components corresponding to specification
@Return value: array of instrument components
:rtype: array of instrument components
"""
if( self.componentArray != []):
return self.componentArray
Expand Down Expand Up @@ -165,9 +165,9 @@ def getDetectorInfoFromTube( self, tubeIx ):
Returns detector info for one tube (currently ID of first detector and number of detectors in tube)
It assumes that all the pixels along the tube have consecutive detector IDs.
@param tubeIx: index of Tube in specified set
:param tubeIx: index of Tube in specified set
@Return value: ID of first detector, number of detectors and step between detectors +1 or -1
:rtype: ID of first detector, number of detectors and step between detectors +1 or -1
"""
nTubes = self.getNumTubes()
if(nTubes < 0):
Expand Down Expand Up @@ -207,9 +207,9 @@ def getTubeLength( self, tubeIx ):
"""
Returns length of tube.
@param tubeIx: index of Tube in specified set
:param tubeIx: index of Tube in specified set
@Return value: Length of tube (first pixel to last pixel) in metres. 0.0 if tube not found.
:rtype: Length of tube (first pixel to last pixel) in metres. 0.0 if tube not found.
"""
nTubes = self.getNumTubes()
if(nTubes < 0):
Expand All @@ -235,9 +235,9 @@ def getTubeName ( self, tubeIx ):
This function is not used in tube calibration, but may be useful as a diagnostic.
It is used in creating the peakfile, which lists the peaks found for each tube.
@param tubeIx: index of Tube in specified set
:param tubeIx: index of Tube in specified set
@Return value: Name of tube as in IDF or 'unknown' if not found.
:rtype: Name of tube as in IDF or 'unknown' if not found.
"""
nTubes = self.getNumTubes()
if(nTubes < 0):
Expand All @@ -262,9 +262,9 @@ def getTubeByString(self, tubeIx):
Returns list of workspace indices of a tube set that has been specified by string
It assumes that all the pixels along the tube have consecutive detector IDs
@param tubeIx: index of Tube in specified set
:param tubeIx: index of Tube in specified set
Return value: list of indices
:rtype: list of indices
"""
firstDet, numDet, step = self.getDetectorInfoFromTube( tubeIx )
wkIds = []
Expand Down Expand Up @@ -308,9 +308,9 @@ def getTube(self, tubeIx):
"""
Returns list of workspace indices of a tube
@param tubeIx: index of Tube in specified set
:param tubeIx: index of Tube in specified set
Return value: list of indices
:rtype: list of indices
"""
nTubes = self.getNumTubes()
if( (0 <= tubeIx) & (tubeIx < nTubes) ):
Expand All @@ -319,4 +319,4 @@ def getTube(self, tubeIx):
print "Tube", tubeIx, "out of range 0 to",self.numTubes,"."




0 comments on commit 90edebe

Please sign in to comment.