Commit 837490f8 authored by Carsten Richter's avatar Carsten Richter

changed the definition of the spherical coordinate system

parent 863a7423
Pipeline #6715 passed with stages
in 3 minutes and 52 seconds
......@@ -644,31 +644,31 @@ class QSpaceWidget(Qt.QDialog):
entry = entries[0] # Get default config from first entry
for coordinates in QSpaceCoordinates.ALLOWED:
if coordinates == QSpaceCoordinates.CARTESIAN:
# Compute Qspace conversion
q_array = qspace_conversion(
img_size=xsocsH5.image_size(entry),
center_chan=xsocsH5.direct_beam(entry),
chan_per_deg=xsocsH5.chan_per_deg(entry),
beam_energy=beamEnergies,
phi=phi,
eta=eta,
nu=nu,
delta=delta,
coordinates=coordinates)
# Estimate bin numbers based on smallest distance between q vectors
maxbins = []
for dim in (q_array[..., 0], q_array[..., 1], q_array[..., 2]):
maxbin = np.inf
for j in range(dim.ndim):
step = abs(np.diff(dim, axis=j)).max()
bins = (abs(dim).max() - abs(dim).min()) / step
maxbin = min(maxbin, bins)
maxbins.append(int(maxbin) + 1)
else:
# TODO estimate bins for spherical coordinates
maxbins = [0, 0, 0]
#if coordinates == QSpaceCoordinates.CARTESIAN or 1:
# Compute Qspace conversion
q_array = qspace_conversion(
img_size=xsocsH5.image_size(entry),
center_chan=xsocsH5.direct_beam(entry),
chan_per_deg=xsocsH5.chan_per_deg(entry),
beam_energy=beamEnergies,
phi=phi,
eta=eta,
nu=nu,
delta=delta,
coordinates=coordinates)
# Estimate bin numbers based on smallest distance between q vectors
maxbins = []
for dim in (q_array[..., 0], q_array[..., 1], q_array[..., 2]):
maxbin = np.inf
for j in range(dim.ndim):
step = abs(np.diff(dim, axis=j)).max()
bins = (abs(dim).max() - abs(dim).min()) / step
maxbin = min(maxbin, bins)
maxbins.append(int(maxbin) + 1)
# TODO estimate bins for spherical coordinates
# CR: it should just work?!
#maxbins = [0, 0, 0]
self.__paramsWid.setQSpaceDims(coordinates, maxbins)
......
......@@ -511,7 +511,7 @@ class QSpaceView(Qt.QMainWindow):
axisNames = list(qspaceH5.qspace_dimension_names)
# Swap qspace dataset to be qz, qy, qx (was qx, qy, qz)
# For spherical, swap from (qr, qincl, qazim) to (qazim, qincl, qr).
# For spherical, swap from (pitch, roll, radial) to (radial, roll, pitch).
qspace = qspace.swapaxes(0, 2)
for widget, label in zip(self.__fitWidget.roiWidget().roiAxisWidgets(),
......
......@@ -48,7 +48,7 @@ class QSpaceCoordinates(object):
"""Cartesian coordinates: (x, y, z)"""
SPHERICAL = 'spherical'
"""Spherical coordinates (ISO): (radius, inclination, azimuth)"""
"""Spherical coordinates (ISO): (pitch, roll, radial)"""
ALLOWED = CARTESIAN, SPHERICAL
"""Supported coordinate systems"""
......@@ -59,7 +59,7 @@ class QSpaceCoordinates(object):
if coordinates == cls.CARTESIAN:
return 'qx', 'qy', 'qz'
elif coordinates == cls.SPHERICAL:
return 'radius', 'inclination', 'azimuth'
return 'pitch', 'roll', 'radial'
else:
raise ValueError('Unsupported coordinates argument')
......
......@@ -79,7 +79,7 @@ def qspace_conversion(img_size, center_chan, chan_per_deg,
Set the coordinate system of the returned array
:return: Array Q vectors of shape:
(nb images, image height, image width, coordinates).
Coordinates are either (qx, qy, qz) or (radius, inclination, azimuth)
Coordinates are either (qx, qy, qz) or (pitch, roll, radial)
depending on coordinates argument.
:rtype: numpy.ndarray
"""
......@@ -136,11 +136,11 @@ def qspace_conversion(img_size, center_chan, chan_per_deg,
elif coordinates == QSpaceCoordinates.SPHERICAL:
# Radius
radius = np.sqrt(qx**2 + qy**2 + qz**2)
q_ar[index, :, :, 0] = radius
# Inclination
q_ar[index, :, :, 1] = np.arccos(qz / radius)
# Azimuth
q_ar[index, :, :, 2] = np.arctan2(qy, qx)
q_ar[index, :, :, 2] = radius
# Roll (Phi)
q_ar[index, :, :, 1] = 90 - np.degrees(np.arctan2(qz, qy))
# Pitch (Theta)
q_ar[index, :, :, 0] = 90 - np.degrees(np.arccos(qx/radius))
else:
raise ValueError("Unsupported coordinate system")
......
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