Commit 413f05e9 authored by Thomas Vincent's avatar Thomas Vincent

add support of multiple energy in qspace conversion function

parent ec01f4db
......@@ -31,6 +31,7 @@ __date__ = "01/03/2016"
import logging
import numbers
import os
import time
import ctypes
......@@ -68,7 +69,8 @@ def qspace_conversion(img_size, center_chan, chan_per_deg,
Calibration center channel in image coordinates (dim0, dim1)
:param List[float] chan_per_deg:
Channel per degree calibration in image coordinates (dim0, dim1)
:param float beam_energy: Energy in eV
:param Union[float,numpy.ndarray] beam_energy:
Energy in eV. Either a float or a 1D array with energy for each image
:param numpy.ndarray phi: 1D array of phi angle for each image
:param numpy.ndarray eta: 1D array of eta angle for each image
:param numpy.ndarray nu: 1D array of nu angle for each image
......@@ -86,6 +88,12 @@ def qspace_conversion(img_size, center_chan, chan_per_deg,
nu = np.array(nu, copy=False, dtype=np.float64)
delta = np.array(delta, copy=False, dtype=np.float64)
n_images = len(eta)
if isinstance(beam_energy, numbers.Real): # Convert to array
beam_energy = [beam_energy] * n_images
beam_energy = np.array(beam_energy, copy=False, dtype=np.float64)
qconv = xu.experiment.QConversion(['y-', 'z-'],
['z-', 'y-'],
[1, 0, 0])
......@@ -97,7 +105,6 @@ def qspace_conversion(img_size, center_chan, chan_per_deg,
# (righthanded)
hxrd = xu.HXRD([1, 0, 0],
[0, 0, 1],
en=beam_energy,
qconv=qconv)
hxrd.Ang2Q.init_area('z-',
......@@ -109,8 +116,6 @@ def qspace_conversion(img_size, center_chan, chan_per_deg,
chpdeg1=chan_per_deg[0],
chpdeg2=chan_per_deg[1])
n_images = len(eta)
# shape of the array that will store the q vectors for all
# rocking angles
q_shape = n_images, img_size[0], img_size[1], 3
......@@ -120,7 +125,8 @@ def qspace_conversion(img_size, center_chan, chan_per_deg,
for index in range(n_images):
qx, qy, qz = hxrd.Ang2Q.area(
eta[index], phi[index], nu[index], delta[index])
eta[index], phi[index], nu[index], delta[index],
en=beam_energy[index])
if coordinates == QSpaceCoordinates.CARTESIAN:
q_ar[index, :, :, 0] = qx
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment