Commit cbba53ac authored by Thomas Vincent's avatar Thomas Vincent

add estimation of number of bins

parent 43fd8ab7
......@@ -40,7 +40,7 @@ from ...io.XsocsH5 import XsocsH5
from ..widgets.AcqParamsWidget import AcqParamsWidget
from ..widgets.Containers import GroupBox, SubGroupBox
from ..widgets.Input import StyledLineEdit
from ...process.qspace.QSpaceConverter import QSpaceConverter
from ...process.qspace import QSpaceConverter, qspace_conversion
_ETA_LOWER = u'\u03B7'
......@@ -340,8 +340,8 @@ class ConversionParamsWidget(Qt.QWidget):
return [qsize_x, qsize_y, qsize_z]
def setQSpaceDims(self, qspaceDims):
"""
Sets the qspace dimensions.
"""Sets the qspace dimensions.
:param qspaceDims: A three integers array.
:return:
"""
......@@ -598,6 +598,44 @@ class QSpaceWidget(Qt.QDialog):
self.__fillScansInfos()
# Set default qspace bin size
if entries:
# Get angles from all entries
phi = []
eta = []
nu = []
delta = []
for entry in entries:
phi.append(xsocsH5.positioner(entry, 'phi'))
eta.append(xsocsH5.positioner(entry, 'eta'))
nu.append(xsocsH5.positioner(entry, 'nu'))
delta.append(xsocsH5.positioner(entry, 'del'))
entry = entries[0] # Get default config from first entry
# 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=xsocsH5.beam_energy(entry),
phi=phi,
eta=eta,
nu=nu,
delta=delta)
# 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(j)
bins = np.nanmin(((abs(dim).max() - abs(dim).min()) / step))
maxbin = min(maxbin, bins)
maxbins.append(int(maxbin) + 1)
self.__paramsWid.setQSpaceDims(maxbins)
def __slotConvertBnClicked(self):
"""
Slot called when the convert button is clicked. Does some checks
......
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