Ticket #8845: calibrate_sans2d.py

File calibrate_sans2d.py, 1.5 KB (added by Gesner Passos, 7 years ago)

Calibration of the simulated data constructed by Richard.

Line 
1import tube
2from tube_calib_fit_params import TubeCalibFitParams
3import numpy
4#ws = Load(Filename=r'\\olympic\Babylon5\Public\rkh\SANS2dTubes\SANS2D60024183.nxs',Precount='0')
5#ws = ws.rebin('5.5,100000,100000', PreserveEvents=False)
6#ws = Integration(ws)
7#for i in range(ws.getNumberHistograms()):
8#       if ws.readY(i)>1500:
9#         ws.dataY(i)[:] = 0
10#SaveNexusDialog(ws)
11
12ws = Load('work_with_this_data.nxs')
13known_pos1 = numpy.array([-0.475,       -0.437, -0.353, -0.315, -0.231, -0.193, -0.109, -0.071, 0.013,  0.051,  0.135,  0.173,  0.257,  0.295,  0.379,  0.417])
14known_pos2 = numpy.array([-0.445,       -0.407, -0.323, -0.285, -0.201, -0.163, -0.079, -0.041, 0.043,  0.081,  0.165,  0.203,  0.287,  0.325,  0.409,  0.447])
15
16# left tubes
17knownPositions = known_pos1
18funcForm = [2]*len(knownPositions)
19pixel_positions = numpy.array([20, 39, 80, 100, 140, 160, 200, 220, 262, 282, 323, 342, 383, 401, 444, 462])
20margin=10
21fitPar = TubeCalibFitParams(pixel_positions, outEdge=10.0, inEdge=10.0)
22tubes = range(60)
23caltable = tube.calibrate(ws, 'rear-detector',knownPositions, funcForm, rangeList=tubes,plotTube=[10,20,30,40,50], margin=margin, fitPar=fitPar)
24
25
26
27
28# right tubes
29knownRight = known_pos2
30pixel_right = [29, 47, 90, 109, 152, 172, 215, 234, 277, 297, 340, 359, 402, 422, 465, 484]
31
32fitPar = TubeCalibFitParams(pixel_right, outEdge=10.0, inEdge=10.0)
33tubes = range(60,120)
34caltable = tube.calibrate(ws, 'rear-detector',knownRight, funcForm, rangeList=tubes, plotTube= [60,80,90,100], margin=margin, fitPar=fitPar, calibTable=caltable)
35
36
37ApplyCalibration(ws, caltable)