Skip to content
Snippets Groups Projects
Commit 9e29c6f3 authored by Owen Arnold's avatar Owen Arnold
Browse files

refs #9576. Usage examples for specular reflection algorithms.

parent b41e5f56
No related merge requests found
...@@ -19,4 +19,36 @@ The calculated theta value in degrees is returned by the algorithm. ...@@ -19,4 +19,36 @@ The calculated theta value in degrees is returned by the algorithm.
Also see Also see
:ref:`algm-SpecularReflectionPositionCorrect` :ref:`algm-SpecularReflectionPositionCorrect`
Usage
-----
**Example - Point detector theta calculation :**
.. testcode:: SpecularReflectionCalculateThetaPointDetectorExample
# Set up an instrument with a 45 degree final two theta angle
import os
instrument_def = os.path.join( config.getInstrumentDirectory() , "INTER_Definition.xml")
ws = LoadEmptyInstrument(instrument_def)
inst = ws.getInstrument()
ref_frame = inst.getReferenceFrame()
upoffset = ref_frame.vecPointingUp()
det_position = {ref_frame.pointingUpAxis(): 1.0, ref_frame.pointingAlongBeamAxis(): 1.0, ref_frame.pointingHorizontalAxis():0}
MoveInstrumentComponent(ws, 'point-detector',RelativePosition=False, **det_position)
MoveInstrumentComponent(ws, 'some-surface-holder',RelativePosition=False, X=0, Y= 0, Z=0)
# Calculate the two theta.
two_theta = SpecularReflectionCalculateTheta(InputWorkspace=ws, DetectorComponentName='point-detector', AnalysisMode='PointDetectorAnalysis')
print two_theta
.. testcleanup:: SpecularReflectionCalculateThetaPointDetectorExample
DeleteWorkspace('ws')
Output:
.. testoutput:: SpecularReflectionCalculateThetaPointDetectorExample
45.0
.. categories:: .. categories::
...@@ -22,3 +22,35 @@ For LineDetectors and MultiDetectors, the algorithm uses an average of ...@@ -22,3 +22,35 @@ For LineDetectors and MultiDetectors, the algorithm uses an average of
grouped detector locations to determine the detector position. grouped detector locations to determine the detector position.
.. categories:: .. categories::
.. testcode:: SpecularReflectionPositionCorrectExample
# Set up an instrument so that the sample is 1.0 distance from the base of a point detector
import os
instrument_def = os.path.join( config.getInstrumentDirectory() , "INTER_Definition.xml")
ws = LoadEmptyInstrument(instrument_def)
inst = ws.getInstrument()
ref_frame = inst.getReferenceFrame()
vertical_position = {ref_frame.pointingUpAxis(): 0, ref_frame.pointingAlongBeamAxis(): 1.0, ref_frame.pointingHorizontalAxis():0}
MoveInstrumentComponent(ws, 'point-detector',RelativePosition=False, **vertical_position)
MoveInstrumentComponent(ws, 'some-surface-holder',RelativePosition=False, X=0, Y= 0, Z=0)
# Correct the detector position. Has a 45 degree incident beam angle.
corrected_ws = SpecularReflectionPositionCorrect(InputWorkspace=ws, DetectorComponentName='point-detector', AnalysisMode='PointDetectorAnalysis', TwoThetaIn=45.0)
# Get the detector position post correction. We expect that the vertical offset of the point detector == 1.0
inst = corrected_ws.getInstrument()
det_pos = inst.getComponentByName('point-detector').getPos()
print det_pos
.. testcleanup:: SpecularReflectionPositionCorrectExample
DeleteWorkspace('ws')
DeleteWorkspace('corrected_ws')
Output:
.. testoutput:: SpecularReflectionPositionCorrectExample
[0,1,1]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment