diff --git a/Code/Mantid/docs/source/algorithms/SpecularReflectionCalculateTheta-v1.rst b/Code/Mantid/docs/source/algorithms/SpecularReflectionCalculateTheta-v1.rst index 51dcf7e74dd9d1a9f7f35e6e73b0d537455c200c..f5e89daab1e2b4a496838e8803032501d9a5d566 100644 --- a/Code/Mantid/docs/source/algorithms/SpecularReflectionCalculateTheta-v1.rst +++ b/Code/Mantid/docs/source/algorithms/SpecularReflectionCalculateTheta-v1.rst @@ -19,4 +19,36 @@ The calculated theta value in degrees is returned by the algorithm. Also see :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:: diff --git a/Code/Mantid/docs/source/algorithms/SpecularReflectionPositionCorrect-v1.rst b/Code/Mantid/docs/source/algorithms/SpecularReflectionPositionCorrect-v1.rst index 13a051fc367a01276d67d331fd5cd83525d60d35..d12ce7b7f8795ccb5d1c0484df03f43755939de7 100644 --- a/Code/Mantid/docs/source/algorithms/SpecularReflectionPositionCorrect-v1.rst +++ b/Code/Mantid/docs/source/algorithms/SpecularReflectionPositionCorrect-v1.rst @@ -22,3 +22,35 @@ For LineDetectors and MultiDetectors, the algorithm uses an average of grouped detector locations to determine the detector position. .. 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]