Commit 4e0edd6f authored by Damien Naudet's avatar Damien Naudet

Removed pixelsize and detector orientation.

parent 3541b9cb
......@@ -52,7 +52,7 @@ beam_energy = 8000.
# of scan numbers (i.e : the #S xxx lines in the scan headers)
# for example, if we only want scans 48.1, 54.1 and 68.1 we would write :
# scan_ids = ['48.1', '54.1', '68.1']
scan_id = None
scan_ids = None
# this (temporary?) keyword is used to tell the function about the format
# of the spec file. So far there is only two supported values :
......@@ -73,13 +73,6 @@ chan_per_deg = [318., 318.]
# direct beam position in the detector coordinates
center_chan = [140, 322]
# the pixel size of the detector
pixelsize = [-1, -1]
# detector orientation
# (not used at the moment though, still a work in progres)
detector_orient = 'phi'
# the merge will actually create one file per scan, then a "master" file
# (in the output directory) that will contain links to those files. You can
# give the master file the name you want (if None, a name will be generated
......@@ -96,9 +89,7 @@ merge_scan_data(output_dir,
spec_f,
beam_energy=beam_energy,
chan_per_deg=chan_per_deg,
pixelsize=pixelsize,
center_chan=center_chan,
detector_orient=detector_orient,
scan_ids=scan_ids,
master_f=master_f,
img_dir=img_base,
......
......@@ -23,9 +23,6 @@ class AcqParamsWidget(Qt.QWidget):
self.__dir_beam_v = None
self.__chpdeg_h = None
self.__chpdeg_v = None
self.__pixelsize_h = None
self.__pixelsize_v = None
self.__detector_orient = None
class DblValidator(Qt.QDoubleValidator):
def validate(self, text, pos):
......@@ -113,52 +110,6 @@ class AcqParamsWidget(Qt.QWidget):
h_line.setFrameShadow(Qt.QFrame.Sunken)
layout.addWidget(h_line, row, 0, 1, 3)
# ===========
# pixelsize
# ===========
row += 1
h_layout = Qt.QHBoxLayout()
layout.addLayout(h_layout, row, 1,
alignment=Qt.Qt.AlignLeft | Qt.Qt.AlignTop)
pixelsize_h_edit = dblLineEditWidget(6)
h_layout.addWidget(Qt.QLabel('v='))
h_layout.addWidget(pixelsize_h_edit)
pixelsize_v_edit = dblLineEditWidget(6)
h_layout.addWidget(Qt.QLabel(' h='))
h_layout.addWidget(pixelsize_v_edit)
h_layout.addWidget(Qt.QLabel(u'<b>\u03BCm</b>'))
layout.addWidget(Qt.QLabel('Pixel size. :'), row, 0)
# ===
row += 1
h_line = Qt.QFrame()
h_line.setFrameShape(Qt.QFrame.HLine)
h_line.setFrameShadow(Qt.QFrame.Sunken)
layout.addWidget(h_line, row, 0, 1, 3)
# ===========
# detector orientation
# ===========
row += 1
layout.addWidget(Qt.QLabel('Det. orientation :'), row, 0)
h_layout = Qt.QHBoxLayout()
det_phi_rb = None
det_mu_rb = None
det_orient_edit = None
if not read_only:
det_phi_rb = Qt.QRadioButton(u'Width is {0}.'.format(_PHI_LOWER))
h_layout.addWidget(det_phi_rb)
det_mu_rb = Qt.QRadioButton(u'Width is {0}.'.format(_MU_LOWER))
h_layout.addWidget(det_mu_rb)
else:
det_orient_edit = AdjustedLineEdit(5, read_only=True)
det_orient_edit.setAlignment(Qt.Qt.AlignCenter)
h_layout.addWidget(det_orient_edit, alignment=Qt.Qt.AlignLeft)
layout.addLayout(h_layout, row, 1)
# ===========
# size constraints
# ===========
......@@ -171,11 +122,6 @@ class AcqParamsWidget(Qt.QWidget):
self.__dir_beam_v_edit = dir_beam_v_edit
self.__chpdeg_h_edit = chpdeg_h_edit
self.__chpdeg_v_edit = chpdeg_v_edit
self.__pixelsize_h_edit = pixelsize_h_edit
self.__pixelsize_v_edit = pixelsize_v_edit
self.__det_phi_rb = det_phi_rb
self.__det_mu_rb = det_mu_rb
self.__det_orient_edit = det_orient_edit
def clear(self):
self.__beam_nrg_edit.clear()
......@@ -183,13 +129,6 @@ class AcqParamsWidget(Qt.QWidget):
self.__dir_beam_v_edit.clear()
self.__chpdeg_h_edit.clear()
self.__chpdeg_v_edit.clear()
self.__pixelsize_h_edit.clear()
self.__pixelsize_v_edit.clear()
if self.__read_only:
self.__det_orient_edit.clear()
else:
self.__det_phi_rb.setChecked(False)
self.__det_mu_rb.setChecked(False)
@property
def beam_energy(self):
......@@ -251,59 +190,6 @@ class AcqParamsWidget(Qt.QWidget):
self.__chpdeg_v_edit.setText(str(chperdeg_v))
self.__chpdeg_v = chperdeg_v
@property
def pixelsize_h(self):
text = self.__pixelsize_h_edit.text()
if len(text) == 0:
return None
return float(text)
@pixelsize_h.setter
def pixelsize_h(self, pixelsize_h):
self.__pixelsize_h_edit.setText(str(pixelsize_h))
self.__pixelsize_h = pixelsize_h
@property
def pixelsize_v(self):
text = self.__pixelsize_v_edit.text()
if len(text) == 0:
return None
return float(text)
@pixelsize_v.setter
def pixelsize_v(self, pixelsize_v):
self.__pixelsize_v_edit.setText(str(pixelsize_v))
self.__pixelsize_v = pixelsize_v
@property
def detector_orient(self):
if self.__read_only:
return self.__det_orient_edit.text()
elif self.__det_phi_rb.isChecked():
return 'phi'
elif self.__det_mu_rb.isChecked():
return 'mu'
return None
@detector_orient.setter
def detector_orient(self, detector_orient):
if detector_orient not in ('phi', 'mu', None):
raise ValueError('Unknown detector orientation : {0}.'
''.format(detector_orient))
if self.__read_only:
self.__det_orient_edit.setText(detector_orient or '')
elif detector_orient == 'phi':
self.__det_phi_rb.setChecked(True)
elif detector_orient == 'mu':
self.__det_mu_rb.setChecked(True)
else:
self.__det_phi_rb.setChecked(False)
self.__det_mu_rb.setChecked(False)
return
# raise ValueError('Unknown detector orientation : {0}.'
# ''.format(detector_orient))
self.__detector_orient = detector_orient
class AdjustedPushButton(Qt.QPushButton):
"""
......@@ -385,8 +271,6 @@ class AdjustedLineEdit(Qt.QLineEdit):
else:
pass
same_txt = False
if len(value) == 0:
if len(self.__defaultText) == 0:
same_txt = True
......@@ -401,9 +285,10 @@ class AdjustedLineEdit(Qt.QLineEdit):
default_value = self.__fieldType(self.__defaultText)
except:
# TODO : filter specific exception
same_txt = False
default_value = None
else:
default_value = self.__defaultText
if value == default_value:
same_txt = True
else:
......
......@@ -43,11 +43,6 @@ from ..widgets.Containers import GroupBox
from silx.gui import qt as Qt
_MAX_BEAM_ENERGY_EV = 10**7
_MU_LOWER = u'\u03BC'
_PHI_LOWER = u'\u03C6'
_HELP_WIDGET_STYLE = """
QLabel {
border-radius: 10px;
......@@ -509,19 +504,12 @@ class MergeWidget(Qt.QDialog):
version_cbx.addItem('0')
version_cbx.addItem('1')
version_cbx.setCurrentIndex(1)
version_help_bn = Qt.QLabel('?')
# TODO : use icon instead?
version_help_bn.setStyleSheet(_HELP_WIDGET_STYLE)
version_help_bn.setToolTip('Todo')
layout.addWidget(lab,
version_row, label_col,
Qt.Qt.AlignLeft)
layout.addWidget(version_cbx,
version_row, line_edit_col,
Qt.Qt.AlignLeft)
layout.addWidget(version_help_bn,
version_row, vers_help_col,
Qt.Qt.AlignLeft)
layout.addItem(Qt.QSpacerItem(0, 0,
Qt.QSizePolicy.Expanding,
Qt.QSizePolicy.Expanding))
......@@ -734,7 +722,6 @@ class MergeWidget(Qt.QDialog):
'img_dir_edit',
'img_dir_bn',
'version_cbx',
'version_help_bn',
'parse_bn',
'total_scans_edit',
'selected_scans_edit',
......@@ -757,7 +744,6 @@ class MergeWidget(Qt.QDialog):
img_dir_edit=img_dir_edit,
img_dir_bn=img_dir_bn,
version_cbx=version_cbx,
version_help_bn=version_help_bn,
parse_bn=parse_bn,
total_scans_edit=total_scans_edit,
selected_scans_edit=selected_scans_edit,
......@@ -896,15 +882,6 @@ class MergeWidget(Qt.QDialog):
chpdeg_v = assert_non_none(acq_params_wid.chperdeg_v)
merger.chan_per_deg = [chpdeg_h, chpdeg_v]
name = 'Pixel size'
pixelsize_h = assert_non_none(acq_params_wid.pixelsize_h)
pixelsize_v = assert_non_none(acq_params_wid.pixelsize_v)
merger.pixelsize = [pixelsize_h, pixelsize_v]
name = 'Detector orientation'
detector_orient = assert_non_none(acq_params_wid.detector_orient)
merger.detector_orient = detector_orient
name = 'Prefix'
master = str(widgets.master_edit.text())
if len(master) == 0:
......
......@@ -446,14 +446,9 @@ class RecipSpaceWidget(Qt.QDialog):
direct_beam_v = widgets.acq_params_rw.direct_beam_v
chperdeg_h = widgets.acq_params_rw.chperdeg_h
chperdeg_v = widgets.acq_params_rw.chperdeg_v
pixelsize_h = widgets.acq_params_rw.pixelsize_h
pixelsize_v = widgets.acq_params_rw.pixelsize_v
detector_orient = widgets.acq_params_rw.detector_orient
kwargs = dict(beam_energy=beam_energy,
chan_per_deg=[chperdeg_h, chperdeg_v],
center_chan=[direct_beam_h, direct_beam_v],
detector_orient=detector_orient,
pixelsize=[pixelsize_h, pixelsize_v])
center_chan=[direct_beam_h, direct_beam_v])
else:
kwargs = {}
......@@ -612,17 +607,13 @@ class RecipSpaceWidget(Qt.QDialog):
direct_beam = params['center_chan']
chperdeg = params['chan_per_deg']
pixelsize = params['pixelsize']
for wid in [ro_wid, rw_wid]:
wid.beam_energy = params['beam_energy']
wid.detector_orient = params['detector_orient']
wid.direct_beam_h = direct_beam[0]
wid.direct_beam_v = direct_beam[1]
wid.chperdeg_h = chperdeg[0]
wid.chperdeg_v = chperdeg[1]
wid.pixelsize_h = pixelsize[0]
wid.pixelsize_v = pixelsize[1]
def __fillScansInfos(self):
"""
......
......@@ -115,17 +115,10 @@ class XsocsH5(XsocsH5Base):
return self.__detector_params(entry, ['center_chan_dim0',
'center_chan_dim1'])
def pixel_size(self, entry):
return self.__detector_params(entry, ['pixelsize_dim0',
'pixelsize_dim1'])
def chan_per_deg(self, entry):
return self.__detector_params(entry, ['chan_per_deg_dim0',
'chan_per_deg_dim1'])
def detector_orient(self, entry):
return self.__detector_params(entry, 'detector_orient')
def n_images(self, entry):
# TODO : make sure that data.ndims = 3
path = self.img_data_tpl.format(entry)
......@@ -181,16 +174,12 @@ class XsocsH5(XsocsH5Base):
def acquisition_params(self, entry):
beam_energy = self.beam_energy(entry)
direct_beam = self.direct_beam(entry)
pixel_size = self.pixel_size(entry)
chan_per_deg = self.chan_per_deg(entry)
detector_orient = self.detector_orient(entry)
result = OrderedDict()
result['beam_energy'] = beam_energy
result['direct_beam'] = direct_beam
result['pixel_size'] = pixel_size
result['chan_per_deg'] = chan_per_deg
result['detector_orient'] = detector_orient
return result
......@@ -204,8 +193,7 @@ class XsocsH5(XsocsH5Base):
path = self.scan_params_tpl.format(entry) + '/{0}'
if isinstance(param_names, (list, set, tuple)):
return OrderedDict([(param, h5_file.get(path.format(param),
_np.array(None))[
()])
_np.array(None))[()])
for param in param_names])
def positioner(self, entry, positioner):
......@@ -259,20 +247,11 @@ class XsocsH5Writer(XsocsH5):
'center_chan_dim1': direct_beam[1]}
return self.__set_detector_params(entry, value)
def set_pixel_size(self, pixel_size, entry):
value = {'pixelsize_dim0': pixel_size[0],
'pixelsize_dim1': pixel_size[1]}
return self.__set_detector_params(entry, value)
def set_chan_per_deg(self, chan_per_deg, entry):
value = {'chan_per_deg_dim0': chan_per_deg[0],
'chan_per_deg_dim1': chan_per_deg[1]}
return self.__set_detector_params(entry, value)
def set_detector_orient(self, detector_orient, entry):
value = {'detector_orient': _np.string_(detector_orient)}
return self.__set_detector_params(entry, value)
def set_scan_params(self,
entry,
motor_0,
......
......@@ -290,8 +290,6 @@ class RecipSpaceConverter(object):
check_values(params, 'beam_energy', 'Beam energy', errors)
check_values(params, 'chan_per_deg', 'Chan. per deg.', errors)
check_values(params, 'center_chan', 'Center channel', errors)
check_values(params, 'pixelsize', 'Pixel size', errors)
check_values(params, 'detector_orient', 'Detector orientation', errors)
n_images = params[params.keys()[0]]['n_images']
n_positions = params[params.keys()[0]]['n_positions']
......@@ -445,7 +443,7 @@ def _get_all_params(data_h5f):
Read the whole data and returns the parameters for each entry.
Returns a dictionary will the scans as keys and the following fields :
n_images, n_positions, img_size, beam_energy, chan_per_deg,
center_chan, pixelsize, det_orient.
center_chan
Each of those fields are N elements arrays, where N is the number of
scans found in the file.
"""
......@@ -454,9 +452,7 @@ def _get_all_params(data_h5f):
img_sizes = []
beam_energies = []
center_chans = []
pixel_sizes = []
chan_per_degs = []
det_orients = []
angles = []
with XsocsH5.XsocsH5(data_h5f, mode='r') as master_h5:
......@@ -472,8 +468,6 @@ def _get_all_params(data_h5f):
beam_energy = master_h5.beam_energy(entry=entry)
chan_per_deg = master_h5.chan_per_deg(entry=entry)
center_chan = master_h5.direct_beam(entry=entry)
pixel_size = master_h5.pixel_size(entry=entry)
det_orient = master_h5.detector_orient(entry=entry)
angle = master_h5.positioner(entry, 'eta')
......@@ -483,22 +477,17 @@ def _get_all_params(data_h5f):
beam_energies.append(beam_energy)
chan_per_degs.append(chan_per_deg)
center_chans.append(center_chan)
pixel_sizes.append(pixel_size)
det_orients.append(det_orient)
angles.append(angle)
result = {scan: dict(scans=entries[idx],
n_images=n_images[idx],
n_positions=n_positions[idx],
img_size=img_sizes[idx],
beam_energy=beam_energies[idx],
chan_per_deg=chan_per_degs[idx],
center_chan=center_chans[idx],
pixelsize=pixel_sizes[idx],
detector_orient=det_orients[idx],
angle=angles[idx])
for idx, scan in enumerate(entries)}
result = dict([(scan, dict(scans=entries[idx],
n_images=n_images[idx],
n_positions=n_positions[idx],
img_size=img_sizes[idx],
beam_energy=beam_energies[idx],
chan_per_deg=chan_per_degs[idx],
center_chan=center_chans[idx],
angle=angles[idx]))
for idx, scan in enumerate(entries)])
return result
......@@ -585,8 +574,6 @@ def _img_2_qspace(data_h5f,
beam_energy=None,
chan_per_deg=None,
center_chan=None,
detector_orient=None,
pixelsize=None, # unused at the moment
image_binning=(1, 1),
pos_indices=None,
roi_shape=(-1, -1),
......@@ -598,7 +585,6 @@ def _img_2_qspace(data_h5f,
"""
TODO : put this in _ConvertThread::run
TODO : detector_orient is NOT supported YET.
This function does NOT :
- check input file consistency
(see RecipSpaceConverter.check_consistency)
......@@ -649,12 +635,6 @@ def _img_2_qspace(data_h5f,
raise ValueError('Invalid/missing center_chan value : {0}.'
''.format(center_chan))
if detector_orient is None:
detector_orient = first_param['detector_orient']
if detector_orient is None:
raise ValueError('Invalid/missing detector_orient value : {0}'
''.format(detector_orient))
n_images = first_param['n_images']
if n_images is None or n_images == 0:
raise ValueError('Data does not contain any images (n_images={0}).'
......
......@@ -146,8 +146,6 @@ class Id01DataMerger(object):
self.__beam_energy = None
self.__center_chan = None
self.__chan_per_deg = None
self.__pixelsize = None
self.__detector_orient = None
self.__set_parse_results(reset=True)
......@@ -297,9 +295,7 @@ class Id01DataMerger(object):
scans_infos,
self.__beam_energy,
self.__chan_per_deg,
self.__pixelsize,
self.__center_chan,
self.__detector_orient,
master_f=master_f,
overwrite=overwrite,
n_proc=self.__n_proc,
......@@ -433,10 +429,6 @@ class Id01DataMerger(object):
errors.append('invalid "Center channel"')
if self.__chan_per_deg is None:
errors.append('invalid "Channel per degree"')
if self.__pixelsize is None:
errors.append('invalid "Pixel size"')
if self.__detector_orient is None:
errors.append('invalid "Detector orientation"')
return errors
def get_imagefile_info(self, scan_id, key=None):
......@@ -544,14 +536,6 @@ class Id01DataMerger(object):
def beam_energy(self, beam_energy):
self.__beam_energy = float(beam_energy)
pixelsize = property(lambda self: self.__pixelsize)
@pixelsize.setter
def pixelsize(self, pixelsize):
if len(pixelsize) != 2:
raise ValueError('pixelsize must be a two elements array.')
self.__pixelsize = [float(pixelsize[0]), float(pixelsize[1])]
chan_per_deg = property(lambda self: self.__chan_per_deg)
@chan_per_deg.setter
......@@ -568,14 +552,6 @@ class Id01DataMerger(object):
raise ValueError('center_chan must be a two elements array.')
self.__center_chan = [float(center_chan[0]), float(center_chan[1])]
detector_orient = property(lambda self: self.__detector_orient)
@detector_orient.setter
def detector_orient(self, detector_orient):
if not isinstance(detector_orient, str):
raise ValueError('detector_orient must be a string.')
self.__detector_orient = detector_orient
compression = property(lambda self: self.__compression)
@compression.setter
......@@ -616,9 +592,7 @@ def merge_scan_data(output_dir,
spec_fname,
beam_energy=None,
chan_per_deg=None,
pixelsize=None,
center_chan=None,
detector_orient='',
scan_ids=None,
master_f=None,
img_dir=None,
......@@ -645,16 +619,12 @@ def merge_scan_data(output_dir,
:type beam_energy: numeric
:param chan_per_deg: 2 elements array containing the number of channels
per degree (as defined by xrayutilitied, used when converting to
per degree (v, h) (as defined by xrayutilitied, used when converting to
reciprocal space coordinates).
:type chan_per_deg: array_like
:param pixelsize: 2 elements array containing the pixel size of the,
detector, in TBD.
:type pixelsize: *optional* array_like
:param center_chan: 2 elements array containing the coordinates of the
direct beam position in the detector coordinates.
:param center_chan: 2 elements array containing the coordinates (v, h) of
the direct beam position in the detector coordinates.
:type center_chan: *optional* array_like
:param scan_ids: array of scan numbers to add to the merged file. If
......@@ -700,8 +670,6 @@ def merge_scan_data(output_dir,
id01_merger.beam_energy = beam_energy
id01_merger.center_chan = center_chan
id01_merger.chan_per_deg = chan_per_deg
id01_merger.pixelsize = pixelsize
id01_merger.detector_orient = detector_orient
id01_merger.n_proc = n_proc
id01_merger.compression = compression
......@@ -928,9 +896,7 @@ class _MergeThread(Thread):
scans,
beam_energy,
chan_per_deg,
pixelsize,
center_chan,
detector_orient,
master_f,
overwrite=True,
n_proc=None,
......@@ -943,9 +909,7 @@ class _MergeThread(Thread):
self.__output_dir = output_dir
self.__beam_energy = beam_energy
self.__chan_per_deg = chan_per_deg
self.__pixelsize = pixelsize
self.__center_chan = center_chan
self.__detector_orient = detector_orient
self.__n_proc = n_proc
self.__compression = compression
self.__master_f = master_f
......@@ -1006,9 +970,9 @@ class _MergeThread(Thread):
self.__spec_h5_fname,
self.__output_dir,
infos['output'], infos['image'],
self.__beam_energy, self.__chan_per_deg,
self.__pixelsize, self.__center_chan,
self.__detector_orient,
self.__beam_energy,
self.__chan_per_deg,
self.__center_chan,
self.__compression, master_f,
mode)
results[scan_id] = pool.apply_async(_add_edf_data,
......@@ -1119,9 +1083,7 @@ def _add_edf_data(scan_id,
img_f,
beam_energy,
chan_per_deg,
pixelsize,
center_chan,
detector_orient,
compression,
master_f,
mode):
......@@ -1139,9 +1101,6 @@ def _add_edf_data(scan_id,
entry = output_f.rpartition('.')[0]
entry_fn = os.path.join(output_dir, output_f)
if pixelsize is None:
pixelsize = [-1., -1.]
progress = np.frombuffer(g_shared_progress, dtype='int32') # noqa
progress[proc_idx] = 0
......@@ -1162,11 +1121,6 @@ def _add_edf_data(scan_id,
entry_h5f.set_scan_params(entry, **command_params)
if pixelsize is not None:
entry_h5f.set_pixel_size([float(pixelsize[0]),
float(pixelsize[1])],
entry=entry)
if beam_energy is not None:
entry_h5f.set_beam_energy(float(beam_energy), entry)
......@@ -1180,10 +1134,6 @@ def _add_edf_data(scan_id,
float(center_chan[1])],
entry=entry)
if detector_orient is not None:
entry_h5f.set_detector_orient(detector_orient,
entry=entry)
progress[proc_idx] = 2
edf_file = EdfFile.EdfFile(img_f, access='r', fastedf=True)
progress[proc_idx] = 5
......
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