This file is concerned with calibrating a specified set of tubes
The main function is getCalibration() which is at the end of this file. It populates an empty Calibration Table Workspace with the new positions of the pixel detectors after calibration. This Calibration Table Workspace can be used later to move the pixel detectors to the calibrated positions.
Users should not need to directly call any other function other than getCalibration() from this file.
Construct an ideal tube from an actual tube (assumed ideal)
Parameters: |
|
---|---|
Return type: | IdealTube |
Corrects position errors in a tube in the same manner as is done for MERLIN according to an algorithm used by Rob Bewley in his MATLAB code.
@param AP: Fit position of left (in pixels) @param BP: Fit position of right (in pixels) @param CP: Fit position of centre (in pixels) @param nDets: Number of pixel detectors in tube
Return Value: Array of corrected Xs (in pixels)
Corrects position errors in a tube given an array of points and their ideal positions.
Parameters: |
|
---|
Return Value: Array of corrected Xs (in same units as ideal tube points)
Note that any element of tubePoints not between 0.0 and nDets is considered a rogue point and so is ignored.
Creates workspace with integrated data for one tube against distance along tube The tube is specified by a list of workspace indices of its spectra
@param IntegratedWorkspace: Workspace of integrated data @param workspaceIndexList: list of workspace indices for the tube @param xUnit: unit of distance ( Pixel) @param showPlot: True = show plot of workspace created, False = just make the workspace.
Return Value: Workspace created
Get the calibrated detector positions for one tube The tube is specified by a list of workspace indices of its spectra Calibration is assumed to be done parallel to the Y-axis
Parameters: |
|
---|
Return Array of pixel detector IDs and array of their calibrated positions
Get the results the calibration and put them in the calibration table provided.
Parameters: |
|
---|
This is the main method called from calibrate() to perform the calibration.
Get the results the calibration and put them in the calibration table provided.
@param ws: Integrated Workspace with tubes to be calibrated @param calibTable: Calibration table into which the calibration results are placed @param iTube: The ideal tube @param PeakFile: File of peaks for calibtation
Given N slits for calibration on an ideal tube convert to Y values to form a ideal tube for correctTubeToIdealTube()
@param IntegratedWorkspace: Workspace of integrated data @param eP: positions of slits for ideal tube (in pixels)
Return Value: Ideal tube in Y-coords for use by correctTubeToIdealTube()
Get the centres of N slits or edges for calibration
It does look for the peak position in pixels by fitting the peaks and edges. It is the method responsible for estimating the peak position in each tube.
Note
This N slit method is suited for WISH or the five sharp peaks of MERLIN .
Parameters: |
|
---|---|
Return type: | array of the slit/edge positions (-1.0 indicates failed to find position) |
Load the file calibration
It returns a list of tuples, where the first value is the detector identification and the second value is its calibration values.
The python class TubeSpec provides a way of specifying a set of tubes for calibration, so that the necessary information about detectors etc. is forethcoming. This class is provide by the python file tube_spec.py. The function getCalibration() of tube_calib needs such an object.
Configuration methods:
There are some functions useful for getting information about a tube specification. It is not necessary to call them in a calibration script, but they may be useful for checking the specification. These methods are:
Note
Tubes are currently ordered in the specification in the same order as they appear in the IDF. This may differ from the order they appear in the workspace indices.
The constructor creates empty tube specification for specified instrument. :param ws: workspace containing the specified instrument with one pixel detector per spectrum.
Returns instrument component corresponding to specification
Return type: | instrument component |
---|
Returns instrument components corresponding to specification
Return type: | array of instrument components |
---|
Returns detector info for one tube.
Returns information about detectors in the ( tubeIx +1)st tube in the specification, where tubeIx is the argument. Three integers are returned:
the ID for the first detector, the number of detectors in the tube and the increment step of detector IDs in the tube (usually 1, but may be -1).
It assumes that all the pixels along the tube have consecutive detector IDs.
Parameters: | tubeIx – index of Tube in specified set |
---|---|
Return type: | ID of first detector, number of detectors and step between detectors +1 or -1 |
Returns number of tubes specified. May also save info about these tubes
Return type: | Value, number of tubes (-1 for erroneous specification) |
---|
Returns list of workspace indices of a tube
Parameters: | tubeIx – index of Tube in specified set |
---|---|
Return type: | list of indices |
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
Parameters: | tubeIx – index of Tube in specified set |
---|---|
Return type: | list of indices |
Returns length of the ( tubeIx +1)st tube.
Parameters: | tubeIx – index of Tube in specified set |
---|---|
Return type: | Length of tube (first pixel to last pixel) in metres. 0.0 if tube not found. |
Returns name of tube.
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.
Parameters: | tubeIx – index of Tube in specified set |
---|---|
Return type: | Name of tube as in IDF or ‘unknown’ if not found. |
Determines whether the component is a tube.
Parameters: | comp – the component |
---|---|
Return type: | Value, true if component passes test as being a tube |
Searches the component for tubes and saves them in array, appending if array is not empty.
Parameters: | comp – the component |
---|
Define the sets of tube from the workspace.
Sets tube specification by string. The string specifies a component of the intrument as in the instrument tree of its IDF file. This component may contain one or more tubes and possibly all the tunes in the instrument. 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.
Parameters: | 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. For example panel03 of WISH can be specified by just panel03, because panel03 is unique within the instrument. Also tube012 of this panel, which is unique within the panel but not within the instrument can be specified by panel03/tube012 but not tube012. If the specification is not unique, the first found will be used and there will be no error message. So if in doubt don’t skip a step.
Define the sets of tube from the workspace with an array of strings.
Set tube specification like setTubeSpecByString, but with an array of string to enable multiple components to be calibrated.
This function allows you to calibrate a set of tubes that is not defined by a single component. For example a set of windows. It takes an array of strings as its argument. Each string specifies a component such as a window or a single tube in the same manner as for setTubeSpecByString(). The components must be disjoint.
Parameters: | tubeSpecArray – array of strings (ex. [‘door1’, ‘door2’]) |
---|
Holds the parameters needed for fitting the positions of the peaks formed by the slits or edges.
The constructor has the following arguments:
Parameters: |
|
---|
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 (see calibrate() to check how the automatic flag will be used).
The function getCalibration() of tube_calib needs such an object.
The IdealTube specifies where the peaks formed by slits or edges should occur.
They can be considered as the known positions as well. It does also keep informatin about the shape of the known_positions, if they are peaks or edges.
First you create an ideal tube by calling the empty constructor idealTube(). Then call another function to populate it.
You may fill it up with the following methods:
You may than query the known positions and functional forms through :
Create empty instance
Construct and ideal tube for Merlin 3-point calibration
Parameters: |
|
---|
Reurn the array of of points where the peaks should be in Metres
Reurn the array of of points where the peaks should be in Metres
Construct an ideal tube directly from an array of positions
Parameters: | points – Array of points where the peaks should be in Metres |
---|
Define the functional form for the peaks
Construct and ideal tube directly from an array of positions and functional forms
Parameters: |
|
---|