Ticket #10928: verify10928.py

File verify10928.py, 1.5 KB (added by Wenduo Zhou, 6 years ago)

script to help to verify the ticket

Line 
1########################################################################
2# Verify ticket 10928 for HB2A IDF
3########################################################################
4import math
5
6vecx = []
7vecy = []
8vece = []
9for i in xrange(44):
10    vecx.extend([0., 1.0])
11    vecy.append( math.exp( -(float(i)-10.)**2/3.**2) + 2.)
12    vece.append(1.0)
13
14CreateWorkspace(OutputWorkspace="MockHB2AData", DataX=vecx, DataY=vecy, DataE=vece, NSpec=44)
15
16AddSampleLog(Workspace="MockHB2AData", LogName="rotangle", LogText="5.0", LogType="Number Series")
17
18CloneWorkspace(InputWorkspace='MockHB2AData', OutputWorkspace='Mock2')
19
20LoadInstrument(Workspace="MockHB2AData", InstrumentName="HB2A", RewriteSpectraMap=True)
21LoadInstrument(Workspace="Mock2", Filename="HB2A_Definition_manual.xml", RewriteSpectraMap=True)
22
23ws = mtd["MockHB2AData"]
24hb2a = ws.getInstrument()
25
26ws2 = mtd['Mock2']
27hb2a2 = ws2.getInstrument()
28
29# Compare source
30source = hb2a.getSource()
31source2 = hb2a2.getSource()
32print "Difference in source position: ", source.getPos() - source2.getPos()
33
34sample = hb2a.getSample()
35sample2 = hb2a2.getSample()
36print "Difference in sample position: ", sample.getPos() - sample2.getPos()
37
38numdet = 0
39for i in xrange(100):
40    try:
41        detx = hb2a.getDetector(i)
42        detpos = detx.getPos()
43        numdet += 1
44        dety = hb2a2.getDetector(i)
45        detpos2 = dety.getPos()
46        print detx.getFullName(), " Diff in position = ", detpos - detpos2
47    except RuntimeError as e:
48        # print e
49        continue
50
51print "Total %d detectors. " % (numdet)