Ticket #1654: test_sns_geom_mp.py

File test_sns_geom_mp.py, 1.3 KB (added by Michael Reuter, 10 years ago)

Testing script for SNS geometry

Line 
1import math
2import os
3
4InstName = "ARCS"
5#InstName = "CNCS"
6#InstName = "SEQ"
7
8# EDIT THIS: Directory of a Mantid subversion checkout
9MantidSrcHome=os.path.expanduser(os.path.join("~", "Mantid"))
10DataDir = os.path.join("Test", "Data", "sns_event_prenexus")
11
12if InstName == "ARCS":
13    DataFileName = os.path.join(MantidSrcHome, DataDir, "ARCS_5025",
14                                "ARCS_5025_neutron_event.dat")
15    DetectorNumber = 0
16elif InstName == "CNCS":
17    DataFileName = os.path.join(MantidSrcHome, DataDir, 
18                                "CNCS_7850_neutron_event.dat")
19    DetectorNumber = 0
20elif InstName == "SEQ":
21    DataFileName = os.path.join(MantidSrcHome, DataDir, "SEQ_2731",
22                                "SEQ_2731_neutron_event.dat")
23    DetectorNumber = 37888
24
25print DataFileName
26WkspcName = InstName.lower()
27
28LoadEventPreNeXus(EventFilename=DataFileName, PadEmptyPixels="1",
29                  OutputWorkspace=WkspcName)
30outWS = mtd[WkspcName]
31
32source = outWS.getInstrument().getSource()
33sample = outWS.getInstrument().getSample()
34
35samplePos = sample.getPos()
36beamPos = samplePos - source.getPos()
37
38detector = outWS.getDetector(DetectorNumber)
39
40r = detector.getDistance(sample)
41polar = detector.getTwoTheta(samplePos, beamPos)
42azi = detector.getPhi()
43
44print "Distance: %.5f" % r
45print "Polar: %.5f" % polar
46print "Azimuthal: %.6f" % azi