Ticket #9399: verify9399.py

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