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