Commit b777b087 authored by Peterson, Peter's avatar Peterson, Peter
Browse files

Re #10137. Fixing python whitespace in Code/Mantid/scripts tree

parent 094236d4
#
# TUBE CALIBRATION DEMONSTRATION PROGRAM FOR MAPS - Execute this
#
# Here we run the calibration of a selected part of MAPS
# Here we run the calibration of a selected part of MAPS
#
import tube
......@@ -9,7 +9,7 @@ from tube_calib_fit_params import TubeCalibFitParams
# == Set parameters for calibration ==
filename = 'MAP14919.raw' # Calibration run ( found in \\isis\inst$\NDXMAPS\Instrument\data\cycle_09_5 )
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeUpper = 10000 #
# Set initial parameters for peak finding
......@@ -19,14 +19,14 @@ ExpectedPositions = [4.0, 85.0, 128.0, 161.0, 252.0] # Expected positions of the
# Set what we want to calibrate (e.g whole intrument or one door )
CalibratedComponent = 'B1_window' # Calibrate B1 window
# Get calibration raw file and integrate it
# Get calibration raw file and integrate it
rawCalibInstWS = Load(filename) #'raw' in 'rawCalibInstWS' means unintegrated.
print "Integrating Workspace"
CalibInstWS = Integration( rawCalibInstWS, RangeLower=rangeLower, RangeUpper=rangeUpper )
DeleteWorkspace(rawCalibInstWS)
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
# == Create Objects needed for calibration ==
# The positions of the shadows and ends here are an intelligent guess.
......@@ -43,8 +43,8 @@ print "Created objects needed for calibration."
# == Get the calibration and put results into calibration table ==
# also put peaks into PeakFile
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, knownPos, funcForm,
fitPar=fitPar, outputPeak=True)
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, knownPos, funcForm,
fitPar=fitPar, outputPeak=True)
print "Got calibration (new positions of detectors) "
# == Apply the Calibation ==
......@@ -56,5 +56,5 @@ print "Applied calibration"
SaveNexusProcessed( CalibInstWS, 'TubeCalibDemoMapsResult.nxs',"Result of Running TCDemoMaps_B1.py")
print "saved calibrated workspace (CalibInstWS) into Nexus file TubeCalibDemoMapsResult.nxs"
# == Save Peak File ==
# == Save Peak File ==
tube.savePeak(peakTable, 'TubeDemoMaps01.txt')
......@@ -2,7 +2,7 @@
# TUBE CALIBRATION DEMONSTRATION PROGRAM FOR MAPS - Execute this
#
# Here we run the calibration of a selected part of MAPS consisting of several components
# by running setTubeSpecByString several times.
# by running setTubeSpecByString several times.
#
import tube
......@@ -14,20 +14,20 @@ from tube_spec import TubeSpec
# == Set parameters for calibration ==
filename = 'MAP14919.raw' # Name of calibration run
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeUpper = 10000 #
# Set what we want to calibrate (e.g whole intrument or one door )
CalibratedComponent1 = 'C4_window' # Calibrate C4 window
CalibratedComponent2 = 'C3_window' # Calibrate C3 window
# Get calibration raw file and integrate it
# Get calibration raw file and integrate it
rawCalibInstWS = Load(filename) #'raw' in 'rawCalibInstWS' means unintegrated.
print "Integrating Workspace"
CalibInstWS = Integration( rawCalibInstWS, RangeLower=rangeLower, RangeUpper=rangeUpper )
DeleteWorkspace(rawCalibInstWS)
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
# == Create Objects needed for calibration ==
......@@ -44,8 +44,8 @@ print "Created objects needed for calibration."
# == Get the calibration and put results into calibration table ==
calibrationTable, peakTable = tube.calibrate(CalibInstWS, thisTubeSet, knownPos, funcForm,
outputPeak=True)
calibrationTable, peakTable = tube.calibrate(CalibInstWS, thisTubeSet, knownPos, funcForm,
outputPeak=True)
print "Got calibration (new positions of detectors) "
# == Apply the Calibation ==
......
......@@ -2,27 +2,27 @@
# TUBE CALIBRATION DEMONSTRATION PROGRAM FOR MAPS - Execute this
#
# Here we run the calibration of a selected part of MAPS consisting of several components
# specifying them in an array of strings.
# specifying them in an array of strings.
import tube
# == Set parameters for calibration ==
filename = 'MAP14919.raw' # Name of calibration run
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeUpper = 10000 #
# Set what we want to calibrate (e.g whole intrument or one door )
# Set what we want to calibrate (e.g whole intrument or one door )
CalibratedComponents = ['C4_window','C3_window','C2_window'] # Calibrate three C windows
# Get calibration raw file and integrate it
# Get calibration raw file and integrate it
rawCalibInstWS = Load(filename) #'raw' in 'rawCalibInstWS' means unintegrated.
print "Integrating Workspace"
CalibInstWS = Integration( rawCalibInstWS, RangeLower=rangeLower, RangeUpper=rangeUpper )
DeleteWorkspace(rawCalibInstWS)
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
# == Create Objects needed for calibration ==
......@@ -34,8 +34,8 @@ print "Created objects needed for calibration."
# == Get the calibration and put results into calibration table ==
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponents, knownPos, funcForm,
outputPeak=True)
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponents, knownPos, funcForm,
outputPeak=True)
print "Got calibration (new positions of detectors) "
# == Apply the Calibation ==
......
#
# TUBE CALIBRATION DEMONSTRATION PROGRAM FOR MAPS - Execute this
#
# Here we run the calibration of a selected part of MAPS
# Here we run the calibration of a selected part of MAPS
#
import tube
......@@ -11,16 +11,16 @@ from tube_calib_fit_params import TubeCalibFitParams
filename = 'MAP14919.raw' # Calibration run ( found in \\isis\inst$\NDXMAPS\Instrument\data\cycle_09_5 )
# Set what we want to calibrate (e.g whole intrument or one door )
CalibratedComponent = 'D2_window' # Calibrate D2 window
# Get calibration raw file and integrate it
# Get calibration raw file and integrate it
rawCalibInstWS = Load(filename) #'raw' in 'rawCalibInstWS' means unintegrated.
print "Integrating Workspace"
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeUpper = 10000 #
CalibInstWS = Integration( rawCalibInstWS, RangeLower=rangeLower, RangeUpper=rangeUpper )
DeleteWorkspace(rawCalibInstWS)
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
# == Create Objects needed for calibration ==
......@@ -41,7 +41,7 @@ fitPar.setAutomatic(True)
print "Created objects needed for calibration."
# == Get the calibration and put results into calibration table ==
calibrationTable = tube.calibrate(CalibInstWS, CalibratedComponent, knownPos, funcForm,
calibrationTable = tube.calibrate(CalibInstWS, CalibratedComponent, knownPos, funcForm,
fitPar = fitPar)
print "Got calibration (new positions of detectors) "
......
#
# TUBE CALIBRATION DEMONSTRATION PROGRAM FOR MAPS - Execute this
#
# Here we run the calibration of a selected part of MAPS
# Here we run the calibration of a selected part of MAPS
#
import tube
......@@ -9,20 +9,20 @@ import tube
# == Set parameters for calibration ==
filename = 'MAP14919.raw' # Name of calibration run
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeUpper = 10000 #
# Set what we want to calibrate (e.g whole intrument or one door )
CalibratedComponent = 'D2_window' # Calibrate D2 window
# Get calibration raw file and integrate it
# Get calibration raw file and integrate it
rawCalibInstWS = Load(filename) #'raw' in 'rawCalibInstWS' means unintegrated.
print "Integrating Workspace"
CalibInstWS = Integration( rawCalibInstWS, RangeLower=rangeLower, RangeUpper=rangeUpper )
DeleteWorkspace(rawCalibInstWS)
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
# == Create Objects needed for calibration ==
......
#
# TUBE CALIBRATION DEMONSTRATION PROGRAM FOR MAPS - Execute this
#
# Here we run the calibration of a selected part of MAPS
# Here we run the calibration of a selected part of MAPS
#
import tube
......@@ -13,14 +13,14 @@ filename = 'MAP14919.raw' # Calibration run ( found in \\isis\inst$\NDXMAPS\Inst
# Set what we want to calibrate (e.g whole intrument or one door )
CalibratedComponent = 'D4_window' # Calibrate D4 window
# Get calibration raw file and integrate it
# Get calibration raw file and integrate it
rawCalibInstWS = Load(filename) #'raw' in 'rawCalibInstWS' means unintegrated.
print "Integrating Workspace"
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeLower = 2000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeUpper = 10000 #
CalibInstWS = Integration( rawCalibInstWS, RangeLower=rangeLower, RangeUpper=rangeUpper )
DeleteWorkspace(rawCalibInstWS)
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
# == Create Objects needed for calibration ==
......@@ -37,11 +37,11 @@ ExpectedWidth = 8.0 # Expected width of Gaussian peaks in pixels (initial value
ExpectedPositions = [4.0, 85.0, 128.0, 165.0, 252.0] # Expected positions of the edges and Gaussian peaks (initial values of fit parameters)
fitPar = TubeCalibFitParams( ExpectedPositions, ExpectedHeight, ExpectedWidth)
fitPar.setAutomatic(True)
print "Created objects needed for calibration."
# == Get the calibration and put results into calibration table ==
calibrationTable = tube.calibrate(CalibInstWS, CalibratedComponent, knownPos, funcForm,
calibrationTable = tube.calibrate(CalibInstWS, CalibratedComponent, knownPos, funcForm,
fitPar = fitPar)
print "Got calibration (new positions of detectors) "
......
......@@ -3,30 +3,30 @@ Tube Calibration Demonstration program for MERLIN.
.. attention::
MERLIN instruments are loaded with already calibrated values. The calibration works nicelly with these files,
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 <http://www.mantidproject.org/How_to_reset_detectors_calibration>`_.
In this example, the calibration of the whole MERLIN instrument is shown. It demonstrate how to
In this example, the calibration of the whole MERLIN instrument is shown. It demonstrate how to
use :py:func:`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.
* 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:
This example shows:
* How to calibrate regions of the instrument separetelly.
* 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.
The output of this examples shows an improvement in relation to the previous calibrated instrument.
.. image:: /images/calibratedMantidMerlin.png
......@@ -46,42 +46,42 @@ import tube
def analisePeakTable(pTable, peaksName='Peaks'):
print 'parsing the peak table'
n = len(pTable)
peaks = pTable.columnCount() -1
peaksId = n*['']
data = numpy.zeros((n,peaks))
line = 0
for row in pTable:
data_row = [row['Peak%d'%(i)] for i in range(1,peaks+1)]
data[line,:] = data_row
peaksId[line] = row['TubeId']
line+=1
# data now has all the peaks positions for each tube
# the mean value is the expected value for the peak position for each tube
expected_peak_pos = numpy.mean(data,axis=0)
print expected_peak_pos
#calculate how far from the expected position each peak position is
distance_from_expected = numpy.abs(data - expected_peak_pos)
Peaks = CreateWorkspace(range(n),distance_from_expected,NSpec=peaks, OutputWorkspace=peaksName)
check = numpy.where(distance_from_expected > 10)[0]
problematic_tubes = list(set(check))
print 'Tubes whose distance is far from the expected value: ', problematic_tubes
print 'parsing the peak table'
n = len(pTable)
peaks = pTable.columnCount() -1
peaksId = n*['']
data = numpy.zeros((n,peaks))
line = 0
for row in pTable:
data_row = [row['Peak%d'%(i)] for i in range(1,peaks+1)]
data[line,:] = data_row
peaksId[line] = row['TubeId']
line+=1
# data now has all the peaks positions for each tube
# the mean value is the expected value for the peak position for each tube
expected_peak_pos = numpy.mean(data,axis=0)
print expected_peak_pos
#calculate how far from the expected position each peak position is
distance_from_expected = numpy.abs(data - expected_peak_pos)
Peaks = CreateWorkspace(range(n),distance_from_expected,NSpec=peaks, OutputWorkspace=peaksName)
check = numpy.where(distance_from_expected > 10)[0]
problematic_tubes = list(set(check))
print 'Tubes whose distance is far from the expected value: ', problematic_tubes
def calibrateMerlin(filename):
# == Set parameters for calibration ==
rangeLower = 3000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeLower = 3000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeUpper = 20000 #
# Get calibration raw file and integrate it
# Get calibration raw file and integrate it
rawCalibInstWS = LoadRaw(filename) #'raw' in 'rawCalibInstWS' means unintegrated.
print "Integrating Workspace"
CalibInstWS = Integration( rawCalibInstWS, RangeLower=rangeLower, RangeUpper=rangeUpper )
DeleteWorkspace(rawCalibInstWS)
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
# the known positions are given in pixels inside the tubes and transformed to provide the positions
# with the center of the tube as the origin
......@@ -89,7 +89,7 @@ def calibrateMerlin(filename):
funcForm = numpy.array([2,2,1,1,1,1,1,2,2],numpy.int8)
# The calibration will follow different steps for sets of tubes
# For the door9, the best points to define the known positions are the 1st edge, 5 peaks, last edge.
# For the door9, the best points to define the known positions are the 1st edge, 5 peaks, last edge.
points7 = knownPositions[[0,2,3,4,5,6,8]]
points7func = funcForm[[0,2,3,4,5,6,8]]
......@@ -98,11 +98,11 @@ def calibrateMerlin(filename):
CalibratedComponent = 'MERLIN/door9' # door9
# == Get the calibration and put results into calibration table ==
# also put peaks into PeakFile
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, door9pos, door9func,
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, door9pos, door9func,
outputPeak=True,
margin=30,
rangeList=range(20) # because 20, 21, 22, 23 are defective detectors
)
margin=30,
rangeList=range(20) # because 20, 21, 22, 23 are defective detectors
)
print "Got calibration (new positions of detectors) and put slit peaks into file TubeDemoMerlin01.txt"
analisePeakTable(peakTable, 'door9_tube1_peaks')
......@@ -110,22 +110,22 @@ def calibrateMerlin(filename):
door8pos = points7
door8func = points7func
CalibratedComponent = 'MERLIN/door8'
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, door8pos,
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, door8pos,
door8func,
outputPeak = True, #change to peakTable to append to peakTable
calibTable = calibrationTable,
margin = 30)
analisePeakTable(peakTable, 'door8_peaks')
outputPeak = True, #change to peakTable to append to peakTable
calibTable = calibrationTable,
margin = 30)
analisePeakTable(peakTable, 'door8_peaks')
# For the doors 7,6,5,4, 2, 1 we may use the 9 points
doorpos = knownPositions
doorfunc = funcForm
CalibratedComponent = ['MERLIN/door%d'%(i) for i in [7,6,5,4, 2, 1]]
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, doorpos,
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, doorpos,
doorfunc,
outputPeak = True,
calibTable = calibrationTable,
margin = 30)
outputPeak = True,
calibTable = calibrationTable,
margin = 30)
analisePeakTable(peakTable, 'door1to7_peaks')
# The door 3 is a special case, because it is composed by diffent kind of tubes.
......@@ -134,7 +134,7 @@ def calibrateMerlin(filename):
# For the tubes 3_3, 3_2, 3_1 -> it is better to skip the central peak
# For the tubes 1_x (smaller tube below), it is better to take the final part of known positions: peak4,peak5,edge6,edge7
# For the tubes 2_x (smaller tube above, it is better to take the first part of known positions: edge1, edge2, peak1,peak2
# NOTE: the smaller tubes they have length = 1.22879882813, but 1024 detectors
# so we have to correct the known positiosn by multiplying by its lenght and dividing by the longer dimension
......@@ -148,57 +148,57 @@ def calibrateMerlin(filename):
# here a little bit of attempts is necessary. The efective center position and lengh is different for the calibrated tube, that
# is the reason, the calibrated values of the smaller tube does not seems aligned with the others. By, finding the 'best' half_diff_center
# value, the alignment occurs nicely.
half_diff_center = 0.835 #
half_diff_center = 0.835 #
# the knownpositions were given with the center of the bigger tube as origin, to convert
# the knownpositions were given with the center of the bigger tube as origin, to convert
# to the center of the upper tube as origin is necessary to subtract them with the half_diff_center
doorpos = knownPositions[[5,6,7,8]] - half_diff_center
doorfunc = [1,1,2,2]
# for the smal tubes, automatically searching for the peak position in pixel was not working quite well,
# for the smal tubes, automatically searching for the peak position in pixel was not working quite well,
# so we will give the aproximate position for these tubes through fitPar argument
fitPar = TubeCalibFitParams([216, 527, 826, 989])
fitPar.setAutomatic(True)
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, doorpos,
doorfunc,
outputPeak = True,
fitPar = fitPar,
calibTable = calibrationTable,
margin = 30)
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, doorpos,
doorfunc,
outputPeak = True,
fitPar = fitPar,
calibTable = calibrationTable,
margin = 30)
analisePeakTable(peakTable, 'door3_tube1_peaks')
# calibrating tubes 2_x
CalibratedComponent = ['MERLIN/door3/tube_2_%d'%(i) for i in range(1,9)]
# the knownpositions were given with the center of the bigger tube as origin, to convert
# the knownpositions were given with the center of the bigger tube as origin, to convert
# to the center of the lower tube as origin is necessary to sum them with (len_big - len_small)/2
doorpos = knownPositions[[0,1,2,3]] + half_diff_center
# print doorpos
doorfunc = [2,2,1,1]
# for the smal tubes, automatically searching for the peak position in pixel was not working quite well,
# for the smal tubes, automatically searching for the peak position in pixel was not working quite well,
# so we will give the aproximate position for these tubes through fitPar argument
fitPar = TubeCalibFitParams([50, 202, 664, 815])
fitPar.setAutomatic(True)
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, doorpos,
doorfunc,
outputPeak = True,
calibTable = calibrationTable,
fitPar = fitPar,
margin = 30)
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, doorpos,
doorfunc,
outputPeak = True,
calibTable = calibrationTable,
fitPar = fitPar,
margin = 30)
analisePeakTable(peakTable, 'door3_tube2_peaks')
# calibrating tubes 3_3,3_2,3_1
CalibratedComponent = ['MERLIN/door3/tube_3_%d'%(i) for i in [1,2,3]]
doorpos = knownPositions[[0,1,2,3,5,6,7,8]]
doorfunc = funcForm[[0,1,2,3,5,6,7,8]]
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, doorpos,
doorfunc,
outputPeak = True,
calibTable = calibrationTable,
margin = 30)
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, doorpos,
doorfunc,
outputPeak = True,
calibTable = calibrationTable,
margin = 30)
analisePeakTable(peakTable, 'door3_123_peaks')
# calibrating others inside door3
......@@ -209,11 +209,11 @@ def calibrateMerlin(filename):
CalibratedComponent = part_3 + part_4 + part_5
doorpos = knownPositions
doorfunc = funcForm
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, doorpos,
calibrationTable, peakTable = tube.calibrate(CalibInstWS, CalibratedComponent, doorpos,
doorfunc,
outputPeak = True,
calibTable = calibrationTable,
margin = 30)
outputPeak = True,
calibTable = calibrationTable,
margin = 30)
analisePeakTable(peakTable, 'door3_peaks')
# == Apply the Calibation ==
......
#
# TUBE CALIBRATION DEMONSTRATION PROGRAM FOR MERLIN
# TUBE CALIBRATION DEMONSTRATION PROGRAM FOR MERLIN
#
# This is a simple example for running calibration for and calibration run of MERLIN.
# This is a simple example for running calibration for and calibration run of MERLIN.
# It uses the CalibrateMerlin Function
#
# Here we run the calibration of MERLIN or selected part of MERLIN
# (excluding short tubes of door 3)
# (excluding short tubes of door 3)
# This calibration is organised by the function CalibrateMerlin,
# which takes a string consisting of the run number of a calibration run number as argument.
# The workspace with calibrated instrument is saved to a Nexus file
#
import tube
from tube_calib_fit_params import TubeCalibFitParams
from tube_calib_fit_params import TubeCalibFitParams
import numpy
RunNumber = 12024
......@@ -20,11 +20,11 @@ def CalibrateMerlin(RunNumber):
# == Set parameters for calibration ==
previousDefaultInstrument = config['default.instrument']
config['default.instrument']="MERLIN"
filename = str(RunNumber) # Name of calibration run.
rangeLower = 3000 # Integrate counts in each spectra from rangeLower to rangeUpper
filename = str(RunNumber) # Name of calibration run.
rangeLower = 3000 # Integrate counts in each spectra from rangeLower to rangeUpper
rangeUpper = 20000 #
# Set parameters for ideal tube.
# Set parameters for ideal tube.
Left = 2.0 # Where the left end of tube should be in pixels (target for AP)
Centre = 512.5 # Where the centre of the tube should be in pixels (target for CP)
Right = 1023.0 # Where the right of the tube should be in pixels (target for BP)
......@@ -38,25 +38,25 @@ def CalibrateMerlin(RunNumber):
# Set what we want to calibrate (e.g whole intrument or one door )
CalibratedComponent = 'MERLIN' # Calibrate door 2
# Get calibration raw file and integrate it
# Get calibration raw file and integrate it
print filename
rawCalibInstWS = LoadRaw(filename)
rawCalibInstWS = LoadRaw(filename)
# 'raw' in 'rawCalibInstWS' means unintegrated.
print "Integrating Workspace"
CalibInstWS = Integration( rawCalibInstWS, RangeLower=rangeLower, RangeUpper=rangeUpper )
DeleteWorkspace(rawCalibInstWS)
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
print "Created workspace (CalibInstWS) with integrated data from run and instrument to calibrate"
# == Create Objects needed for calibration ==
## In the merlin case, the positions are usually given in pixels, instead of being given in
## In the merlin case, the positions are usually given in pixels, instead of being given in
## meters, to convert to meter and put the origin in the center, we have to apply the following
## transformation:
##
## transformation:
##
## pos = pixel * length/npixels - length/2 = length (pixel/npixels - 1/2)
##
##