| 1 | wsname = "NOM_26140" |
|---|
| 2 | efname = "NOM_26140_event.nxs" |
|---|
| 3 | peaks = '0.8920,1.0758,1.2615,2.0599' |
|---|
| 4 | minpeakheight = 5 |
|---|
| 5 | |
|---|
| 6 | LoadEventNexus(Filename=efname,OutputWorkspace=wsname) |
|---|
| 7 | FilterBadPulses(InputWorkspace=wsname,OutputWorkspace=wsname) |
|---|
| 8 | CompressEvents(InputWorkspace=wsname,OutputWorkspace=wsname,Tolerance='0.01') |
|---|
| 9 | ConvertUnits(InputWorkspace=wsname,OutputWorkspace=wsname,Target='dSpacing') |
|---|
| 10 | SortEvents(InputWorkspace=wsname) |
|---|
| 11 | Rebin(InputWorkspace=wsname,OutputWorkspace=wsname,Params='0.5,-0.005,5') |
|---|
| 12 | |
|---|
| 13 | # Make a copy |
|---|
| 14 | CloneWorkspace(InputWorkspace=wsname, OutputWorkspace=wsname+"_copy") |
|---|
| 15 | |
|---|
| 16 | # Use non-fit-window version |
|---|
| 17 | GetDetOffsetsMultiPeaks(InputWorkspace=wsname,DReference=peaks,BackgroundType='Linear', |
|---|
| 18 | OutputWorkspace='%soffset'%(wsname),NumberPeaksWorkspace='%speaks'%(wsname),MaskWorkspace='%smask'%(wsname), |
|---|
| 19 | MinimumPeakHeight=minpeakheight, |
|---|
| 20 | SpectraFitInfoTableWorkspace=wsname+"_offsetinfo_old", |
|---|
| 21 | PeaksOffsetTableWorkspace=wsname+"_fitpeakinfo_old") |
|---|
| 22 | Rebin(InputWorkspace=wsname,OutputWorkspace=wsname,Params='0.5,-0.005,5') |
|---|
| 23 | ConvertUnits(InputWorkspace=wsname,OutputWorkspace=wsname,Target='TOF') |
|---|
| 24 | MaskDetectors(Workspace=wsname,MaskedWorkspace='%smask'%(wsname)) |
|---|
| 25 | AlignDetectors(InputWorkspace=wsname,OutputWorkspace=wsname,OffsetsWorkspace='%soffset'%(wsname)) |
|---|
| 26 | SortEvents(InputWorkspace=wsname) |
|---|
| 27 | Rebin(InputWorkspace=wsname,OutputWorkspace=wsname,Params='0.5,-0.005,5') |
|---|
| 28 | RenameWorkspace(InputWorkspace=wsname,OutputWorkspace='%s_calibrated_old'%(wsname)) |
|---|
| 29 | RenameWorkspace(InputWorkspace=wsname+"mask", OutputWorkspace=wsname+"mask_old") |
|---|
| 30 | |
|---|
| 31 | # Use fit window |
|---|
| 32 | |
|---|
| 33 | # Generate fit window table workspace |
|---|
| 34 | RenameWorkspace(InputWorkspace=wsname+"_copy", OutputWorkspace=wsname) |
|---|
| 35 | ws = mtd[wsname] |
|---|
| 36 | numspec = ws.getNumberHistograms() |
|---|
| 37 | print "Number of histogram = ", numspec |
|---|
| 38 | |
|---|
| 39 | windowws = CreateEmptyTableWorkspace(OutputWorkspace="NOM_26140_Window") |
|---|
| 40 | |
|---|
| 41 | windowws.addColumn("int", "spectrum") |
|---|
| 42 | windowws.addColumn("double", "peak0_left") |
|---|
| 43 | windowws.addColumn("double", "peak0_right") |
|---|
| 44 | windowws.addColumn("double", "peak1_left") |
|---|
| 45 | windowws.addColumn("double", "peak1_right") |
|---|
| 46 | windowws.addColumn("double", "peak2_left") |
|---|
| 47 | windowws.addColumn("double", "peak2_right") |
|---|
| 48 | windowws.addColumn("double", "peak3_left") |
|---|
| 49 | windowws.addColumn("double", "peak3_right") |
|---|
| 50 | |
|---|
| 51 | # 0.892000, 1.075800, 1.261500, 2.06000 |
|---|
| 52 | |
|---|
| 53 | peak0left = 0.872 |
|---|
| 54 | peak0right = 0.945 |
|---|
| 55 | |
|---|
| 56 | peak1left = 1.050 |
|---|
| 57 | peak1right = 1.138 |
|---|
| 58 | |
|---|
| 59 | peak2left = 1.218 |
|---|
| 60 | peak2right = 1.350 |
|---|
| 61 | |
|---|
| 62 | peak3left = 1.91 |
|---|
| 63 | peak3right = 2.20 |
|---|
| 64 | |
|---|
| 65 | for iws in xrange(numspec): |
|---|
| 66 | windowws.addRow([iws, peak0left, peak0right, peak1left, peak1right, peak2left, peak2right, |
|---|
| 67 | peak3left, peak3right]) |
|---|
| 68 | |
|---|
| 69 | GetDetOffsetsMultiPeaks(InputWorkspace=wsname,DReference=peaks,BackgroundType='Linear', |
|---|
| 70 | OutputWorkspace='%soffset'%(wsname),NumberPeaksWorkspace='%speaks'%(wsname),MaskWorkspace='%smask'%(wsname), |
|---|
| 71 | MinimumPeakHeight=minpeakheight, |
|---|
| 72 | FitwindowTableWorkspace = "NOM_26140_Window", |
|---|
| 73 | SpectraFitInfoTableWorkspace=wsname+"_offsetinfo_new", |
|---|
| 74 | PeaksOffsetTableWorkspace=wsname+"_fitpeakinfo_new") |
|---|
| 75 | Rebin(InputWorkspace=wsname,OutputWorkspace=wsname,Params='0.5,-0.005,5') |
|---|
| 76 | ConvertUnits(InputWorkspace=wsname,OutputWorkspace=wsname,Target='TOF') |
|---|
| 77 | MaskDetectors(Workspace=wsname,MaskedWorkspace='%smask'%(wsname)) |
|---|
| 78 | AlignDetectors(InputWorkspace=wsname,OutputWorkspace=wsname,OffsetsWorkspace='%soffset'%(wsname)) |
|---|
| 79 | SortEvents(InputWorkspace=wsname) |
|---|
| 80 | Rebin(InputWorkspace=wsname,OutputWorkspace=wsname,Params='0.5,-0.005,5') |
|---|
| 81 | RenameWorkspace(InputWorkspace=wsname,OutputWorkspace='%s_calibrated_new'%(wsname)) |
|---|
| 82 | RenameWorkspace(InputWorkspace=wsname+"mask", OutputWorkspace=wsname+"mask_new") |
|---|