| 1 | ######################################################################## |
|---|
| 2 | # Verify ticket 10928 for HB2A IDF |
|---|
| 3 | ######################################################################## |
|---|
| 4 | import math |
|---|
| 5 | |
|---|
| 6 | vecx = [] |
|---|
| 7 | vecy = [] |
|---|
| 8 | vece = [] |
|---|
| 9 | for 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 | |
|---|
| 14 | CreateWorkspace(OutputWorkspace="MockHB2AData", DataX=vecx, DataY=vecy, DataE=vece, NSpec=44) |
|---|
| 15 | |
|---|
| 16 | AddSampleLog(Workspace="MockHB2AData", LogName="rotangle", LogText="5.0", LogType="Number Series") |
|---|
| 17 | |
|---|
| 18 | CloneWorkspace(InputWorkspace='MockHB2AData', OutputWorkspace='Mock2') |
|---|
| 19 | |
|---|
| 20 | LoadInstrument(Workspace="MockHB2AData", InstrumentName="HB2A", RewriteSpectraMap=True) |
|---|
| 21 | LoadInstrument(Workspace="Mock2", Filename="HB2A_Definition_manual.xml", RewriteSpectraMap=True) |
|---|
| 22 | |
|---|
| 23 | ws = mtd["MockHB2AData"] |
|---|
| 24 | hb2a = ws.getInstrument() |
|---|
| 25 | |
|---|
| 26 | ws2 = mtd['Mock2'] |
|---|
| 27 | hb2a2 = ws2.getInstrument() |
|---|
| 28 | |
|---|
| 29 | # Compare source |
|---|
| 30 | source = hb2a.getSource() |
|---|
| 31 | source2 = hb2a2.getSource() |
|---|
| 32 | print "Difference in source position: ", source.getPos() - source2.getPos() |
|---|
| 33 | |
|---|
| 34 | sample = hb2a.getSample() |
|---|
| 35 | sample2 = hb2a2.getSample() |
|---|
| 36 | print "Difference in sample position: ", sample.getPos() - sample2.getPos() |
|---|
| 37 | |
|---|
| 38 | numdet = 0 |
|---|
| 39 | for 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 | |
|---|
| 51 | print "Total %d detectors. " % (numdet) |
|---|