Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
mantid
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mantidproject
mantid
Commits
7314a5d9
Commit
7314a5d9
authored
7 years ago
by
Edward Brown
Browse files
Options
Downloads
Patches
Plain Diff
Re #20991: Applied autopep8 to l2q.py
parent
c43f7b47
Branches
22031_phaseQuadGUI
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scripts/Reflectometry/isis_reflectometry/l2q.py
+26
-15
26 additions, 15 deletions
scripts/Reflectometry/isis_reflectometry/l2q.py
with
26 additions
and
15 deletions
scripts/Reflectometry/isis_reflectometry/l2q.py
+
26
−
15
View file @
7314a5d9
#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
This diff is collapsed.
Click to expand it.
WHITFIELDRE email
@rwp
mentioned in commit
9c51b2ef
·
6 years ago
mentioned in commit
9c51b2ef
mentioned in commit 9c51b2ef3e609b3b157d662846c5df8f54b2b651
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment