Skip to content
Snippets Groups Projects
Commit 7314a5d9 authored by Edward Brown's avatar Edward Brown
Browse files

Re #20991: Applied autopep8 to l2q.py

parent c43f7b47
Branches 22031_phaseQuadGUI
No related tags found
No related merge requests found
#pylint: disable=invalid-name
# pylint: disable=invalid-name
from __future__ import (absolute_import, division, print_function)
import math
from mantid.simpleapi import * # New API
def l2q(ws,whichDet,theta, sample_component_name):
def l2q(ws, whichDet, theta, sample_component_name):
'''
call signature::call signature::
......@@ -33,30 +33,41 @@ def l2q(ws,whichDet,theta, sample_component_name):
else:
inst = ws.getInstrument()
sampleLocation=inst.getComponentByName(sample_component_name).getPos()
detLocation=inst.getComponentByName(whichDet).getPos()
sample2detector=detLocation-sampleLocation # meters
sampleLocation = inst.getComponentByName(sample_component_name).getPos()
detLocation = inst.getComponentByName(whichDet).getPos()
sample2detector = detLocation - sampleLocation # meters
theta=theta*math.pi/180.0 # convert to radians
theta = theta * math.pi / 180.0 # convert to radians
# Fetch the reference frame to determine the instrument orientation.
reference_frame = inst.getReferenceFrame()
sample_to_detector_along_beam = sample2detector.scalar_prod( reference_frame.vecPointingAlongBeam() )
sample_to_detector_along_beam = sample2detector.scalar_prod(
reference_frame.vecPointingAlongBeam())
# calculate new detector position based on angle theta in degrees:
across_offset = 0.0 # Across the beam (side to side)
up_offset = sample_to_detector_along_beam * math.sin(2.0 * theta) # Normal to the beam (up)
beam_offset = detLocation.scalar_prod( reference_frame.vecPointingAlongBeam() )
# Across the beam (side to side)
across_offset = 0.0
up_offset = sample_to_detector_along_beam * \
math.sin(2.0 * theta) # Normal to the beam (up)
beam_offset = detLocation.scalar_prod(
reference_frame.vecPointingAlongBeam())
coord_args = dict()
coord_args[ reference_frame.pointingAlongBeamAxis() ] = beam_offset
coord_args[ reference_frame.pointingUpAxis() ] = up_offset
coord_args[ reference_frame.pointingHorizontalAxis() ] = across_offset
coord_args[reference_frame.pointingAlongBeamAxis()] = beam_offset
coord_args[reference_frame.pointingUpAxis()] = up_offset
coord_args[reference_frame.pointingHorizontalAxis()] = across_offset
logger.information('Correcting detector location')
MoveInstrumentComponent(ws, ComponentName=whichDet, RelativePosition=False, **coord_args )
MoveInstrumentComponent(
ws,
ComponentName=whichDet,
RelativePosition=False,
**coord_args)
# Now convert to momentum transfer
IvsQ = ConvertUnits(InputWorkspace=ws,OutputWorkspace="IvsQ",Target="MomentumTransfer")
IvsQ = ConvertUnits(
InputWorkspace=ws,
OutputWorkspace="IvsQ",
Target="MomentumTransfer")
return IvsQ
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