| 1 | import tube |
|---|
| 2 | from tube_calib_fit_params import TubeCalibFitParams |
|---|
| 3 | import 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 | |
|---|
| 12 | ws = Load('work_with_this_data.nxs') |
|---|
| 13 | known_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]) |
|---|
| 14 | known_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 |
|---|
| 17 | knownPositions = known_pos1 |
|---|
| 18 | funcForm = [2]*len(knownPositions) |
|---|
| 19 | pixel_positions = numpy.array([20, 39, 80, 100, 140, 160, 200, 220, 262, 282, 323, 342, 383, 401, 444, 462]) |
|---|
| 20 | margin=10 |
|---|
| 21 | fitPar = TubeCalibFitParams(pixel_positions, outEdge=10.0, inEdge=10.0) |
|---|
| 22 | tubes = range(60) |
|---|
| 23 | caltable = 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 |
|---|
| 29 | knownRight = known_pos2 |
|---|
| 30 | pixel_right = [29, 47, 90, 109, 152, 172, 215, 234, 277, 297, 340, 359, 402, 422, 465, 484] |
|---|
| 31 | |
|---|
| 32 | fitPar = TubeCalibFitParams(pixel_right, outEdge=10.0, inEdge=10.0) |
|---|
| 33 | tubes = range(60,120) |
|---|
| 34 | caltable = tube.calibrate(ws, 'rear-detector',knownRight, funcForm, rangeList=tubes, plotTube= [60,80,90,100], margin=margin, fitPar=fitPar, calibTable=caltable) |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | ApplyCalibration(ws, caltable) |
|---|