Calibration

Calibration is currently based on tubes and is accessed using the tube module.

Definition of Calibration

excludeShorTubes, overridePeaks, fitPolyn, outputPeak ] )

Use Cases

Among the examples, inside the Examples folder, the user is encouraged to look at TubeCalibDemoMaps_All, there he will find 7 examples showing how to use calibrate method.

  • minimalInput() shows the easiest way to use calibrate.
  • provideTheExpectedValue() shows the usage of fitPar parameter to provide the expected values for the peaks in pixels.
  • changeMarginAndExpectedValue() demonstrate how to use margin, fitPar, plotTube, and outputPeak
  • improvingCalibrationSingleTube() explores the usage of rangeList and overridePeaks to improve the calibration of specific tubes.
  • improvingCalibrationOfListOfTubes() extends theimprovingCalibrationSingleTube to provide a good calibration to almost all instrument.
  • calibrateB2Window() explore a singularity of the MAP14919 example, where the second peak does not appear clear on some tubes inside one door. So, this example, shows how to use rangeList to carry a calibration to the group of tubes.
  • completeCalibration() demonstrate how the rangeList, overridePeaks, may be used together to allow the calibration of the whole instrument, despite, its particularities in some cases.
  • findThoseTubesThatNeedSpecialCareForCalibration() show an aproach to find the tubes that will require special care on calibrating. It will also help to find detectors that are not working well.

Examples

MAPS instrument

Tube Calibration Demonstration for MAPS instrument.

This module group many examples and also demonstrate how to work with the tube.calibrate().

It starts from the simplest way to perform a calibration. It them increase the complexity of dealing with real calibration work, when particularities of the instrument must be considered

At the end, it gives a suggestion on a techinique to investigate and improve the calibration itself.

Minimal Input

Examples.TubeCalibDemoMaps_All.minimalInput(filename)

Simplest way of calling tube.calibrate()

The minimal input for the calibration is the integrated workspace and the knwon positions.

Eventhough it is easy to call, the calibration performs well, but there are ways to improve the results, as it is explored after.

../../../_images/outputOfMinimalInput.png

Provide Expected Value

Examples.TubeCalibDemoMaps_All.provideTheExpectedValue(filename)

Giving the expected value for the position of the peaks in pixel.

The minimalInput() let to the calibrate to guess the position of the pixels among the tubes. Altough it works nicelly, providing these expected values may improve the results. This is done through the fitPar parameter.

Change Margin and Expected Value

Examples.TubeCalibDemoMaps_All.changeMarginAndExpectedValue(filename)

To fit correcly, it is important to have a good window around the peak. This windown is defined by the margin parameter.

This examples shows how the results worsen if we change the margin from its default value 15 to 10.

It shows how to see the fitted values using the plotTube parameter.

It will also output the peaks position and save them, through the outputPeak option and the tube.savePeak() method.

An example of the fitted data compared to the acquired data to find the peaks positions:

../../../_images/calibratePlotFittedData.png

The result deteriorate, as you can see:

../../../_images/calibrateChangeMarginAndExpectedValue.png

Improving Calibration Single Tube

Examples.TubeCalibDemoMaps_All.improvingCalibrationSingleTube(filename)

The provideTheExpectedValue() provided a good solution, but there are few tubes whose calibration was not so good.

This method explores how to deal with these tubes.

First of all, it is important to identify the tubes that did not work well.

From the outputs of provideTheExpectedValue, looking inside the instrument tree, it is possible to list all the tubes that are not so good.

Unfortunatelly, they do not have a single name identifier. So, locating them it is a little bit trickier. The findThoseTubesThatNeedSpecialCareForCalibration() shows one way of finding those tubes. The index is the position inside the PeakTable.

For this example, we have used inspection from the Instrument View. One of them is inside the A1_Window, 3rd PSD_TUBE_STRIP 8 pack up, 4th PSD_TUBE_STRIP: Index = 8+8+4 - 1 = 19.

In this example, we will ask the calibration to run the calibration only for 3 tubes (indexes 18,19,20). Them, we will check why the 19 is not working well. Finally, we will try to provide another peaks position for this tube, and run the calibration again for these tubes, to improve the results.

This example shows how to use overridePeaks option

Improving Calibration of List of Tubes

Examples.TubeCalibDemoMaps_All.improvingCalibrationOfListOfTubes(filename)

Analysing the result of provideTheExpectedValue it was seen that the calibration of some tubes was not good.

Note

This method list some of them, there are a group belonging to window B2 that shows only 2 peaks that are not dealt with here.

If first plot the bad ones using the plotTube option. It them, find where they fail, and how to correct their peaks, using the overridePeaks. If finally, applies the calibration again with the points corrected.

Calibrating Window B2

Examples.TubeCalibDemoMaps_All.calibrateB2Window(filename)

There are among the B2 window tubes, some tubes that are showing only 2 strips.

Those tubes must be calibrated separated, as the known positions are not valid.

This example calibrate them, using only 4 known values: 2 edges and 2 peaks.

Run this example, and them see the worksapce in the calibrated instrument and you will see how it worked.

The picture shows the output, look that only a section of the B2 Window was calibrated.

../../../_images/calibrateB2Window.png

Complete Calibration

Examples.TubeCalibDemoMaps_All.completeCalibration(filename)

This example shows how to use some properties of calibrate method to join together the calibration done in provideTheExpectedValue(), and improved in calibrateB2Window(), and improvingCalibrationOfListOfTubes().

It also improves the result of the calibration because it deals with the E door. The aquired data cannot be used to calibrate the E door, and trying to do so, produces a bad result. In this example, the tubes inside the E door are excluded to the calibration. Using the ‘’‘rangeList’‘’ option.

Calibration technique: Finding tubes not well calibrated

Examples.TubeCalibDemoMaps_All.findThoseTubesThatNeedSpecialCareForCalibration(filename)

The example provideTheExpectedValue() has shown its capability to calibrate almost all tubes, but, as explored in the improvingCalibrationOfListOfTubes() and improvingCalibrationSingleTube() there are some tubes that could not be calibrated using that method.

The goal of this method is to show one way to find the tubes that will require special care.

It will first perform the same calibration seen in provideTheExpectedValue(), them, it will process the peakTable output of the calibrate method when enabling the parameter outputPeak.

It them creates the Peaks workspace, that is the diffence of the peaks position from the expected values of the peaks positions for all the tubes. This allows to spot what are the tubes whose fitting are outliers in relation to the others.

../../../_images/plotingPeaksDifference.png

The final result for this method is to output using plotTube the result of the fitting to all the ‘outliers’ tubes.

MERLIN instrument

Tube Calibration Demonstration program for MERLIN.

Attention

MERLIN instruments are loaded with already calibrated values. The calibration works nicelly with these files, but if you want to see the uncalibrated file you can do it. Look at How to reset detectors calibration.

In this example, the calibration of the whole MERLIN instrument is shown. It demonstrate how to use tube.calibrate() to calibrate MERLIN tubes.

Opening the calibrated data in the Instrument View, it is possible to group the tubes in some common regions:

  • Doors 9 and 8 are similar and can be calibrated together using 7 key points
  • Doors 7,6,5,4, 2 and 1 can be calibrated using 9 key points.
  • Door 3 is particular, because it is formed with some smaller tubes as well as some large tubes.

This example shows:

  • How to calibrate regions of the instrument separetelly.
  • How to use calibTable parameter to append information in order to create a calibration table for the whole instrument.
  • How to use the outputPeak to check how the calibration is working as well as the usage of analisePeakTable method to look into the details of the operation to improve the calibration.
  • It deals with defining different known positions for the different tube lengths.

The output of this examples shows an improvement in relation to the previous calibrated instrument.

../../../_images/calibratedMantidMerlin.png

The previous calibrated instrument view:

../../../_images/calibratedCurrentMerlin.png

Other Usefull Methods

tube.savePeak(peakTable, filePath)

Allows to save the peakTable to a text file.

Parameters:peakTable – peak table as the workspace table provided by calibrated method, as in the example:
calibTable, peakTable = calibrate(..., outputPeak=peakTable)
savePeak(peakTable, 'myfolder/myfile.txt')
Parameters:filePath – where to save the file. If the filePath is not given as an absolute path, it will be considered relative to the defaultsave.directory.

The file will be saved with the following format:

id_name (parsed space to %20) [peak1, peak2, ..., peakN]

You may load these peaks using readPeakFile

panel1/tube001 [23.4, 212.5, 0.1]
...
panel1/tubeN   [56.3, 87.5, 0.1]
tube.readPeakFile(file_name)

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.

Example of usage:

for (det_code, cal_values) in readPeakFile('pathname/TubeDemo'):
   print det_code
   print cal_values
Parameters:file_name – Path for the file
Return type:list of tuples(det_code, peaks_values)

Implementation

More details on the finer points of the calibration implementation can be found at http://www.mantidproject.org/Tube_Calibration and in: