def do_plot_3d(self): """ :return: """ # color: get R, G, B status, rgb_values = guiutility.parse_float_editors([self.ui.lineEdit_baseColorRed, self.ui.lineEdit_baseColorGreen, self.ui.lineEdit_baseColorBlue]) assert status # set the color to get change change_r = self.ui.checkBox_changeRed.isChecked() change_g = self.ui.checkBox_changeGreen.isChecked() change_b = self.ui.checkBox_changeBlue.isChecked() # get threshold status, thresholds = guiutility.parse_integers_editors([self.ui.lineEdit_countsThresholdLower, self.ui.lineEdit_countsThresholdUpper], allow_blank=True) assert status, thresholds if thresholds[0] is None: thresholds[0] = 0 if thresholds[1] is None: thresholds[1] = sys.maxint assert 0 <= thresholds[0] < thresholds[1] # data key data_key = int(self.ui.comboBox_dataKey.currentText()) # plot self.plot_3d(data_key, rgb_values, thresholds, [change_r, change_g, change_b]) return
def set_calibration_to_reduction_controller(self, exp_number): """set user-specified instrument calibrations to the my controller :param exp_number: :return: """ # set up the experiment number if it is different if exp_number != self._myController.get_experiment(): self._myController.set_exp_number(exp_number) self._myController.set_default_detector_sample_distance(0.3750) self._myController.set_default_pixel_number(256, 256) # set up the calibration # wave length user_wavelength_str = str(self.ui.lineEdit_infoWavelength.text()).strip() if len(user_wavelength_str) > 0: try: user_wavelength = float(user_wavelength_str) self._myController.set_user_wave_length(exp_number, user_wavelength) except ValueError: gui_util.show_message(self, '[ERROR] User-specified wave length {0} cannot be converted to float.' ''.format(user_wavelength_str)) return # END-IF # detector center user_det_center_str = str(self.ui.lineEdit_infoDetCenter.text()).strip() user_det_center_str = user_det_center_str.replace('x', ',') if len(user_det_center_str) > 0: try: det_center = gui_util.parse_integer_list(user_det_center_str, 2) except RuntimeError as run_err: gui_util.show_message(self, 'Unable to parse detector center {0} due to {1}' ''.format(user_det_center_str, run_err)) return self._myController.set_detector_center(exp_number, det_center[0], det_center[1]) # END-IF # detector sample distance status, ret_obj = gui_util.parse_float_editors([self.ui.lineEdit_infoDetSampleDistance], allow_blank=True) if not status: error_message = ret_obj gui_util.show_message(self, '[ERROR] {0}'.format(error_message)) return user_det_sample_distance = ret_obj[0] if user_det_sample_distance is not None: self._myController.set_detector_sample_distance(exp_number, user_det_sample_distance) # detector size curr_det_size_index = self.ui.comboBox_detSize.currentIndex() if curr_det_size_index > 2: gui_util.show_message(self, 'Detector {0} is not supported by now!' ''.format(str(self.ui.comboBox_detSize.currentText()))) return det_size = [256, 512][curr_det_size_index] self._myController.set_detector_geometry(det_size, det_size) return
def do_select_scans(self): """ :return: """ # get check box if self.ui.checkBox_selectAllPeaks.isChecked(): self._myParent.select_ub_scans(select_all=True) else: select_args = dict() if self.ui.checkBox_selectNuclearPeaks.isChecked(): status, ret_obj = guiutility.parse_float_editors( [self.ui.lineEdit_nuclearPeaksTolerance], allow_blank=False) if not status: raise RuntimeError(ret_obj) hkl_tol = ret_obj[0] select_args['nuclear_peaks'] = True select_args['hkl_tolerance'] = hkl_tol if self.ui.checkBox_wavelength.isChecked(): # wave length selection status, ret_obj = guiutility.parse_float_editors( [ self.ui.lineEdit_wavelength, self.ui.lineEdit_wavelengthTolerance ], allow_blank=False) if status: wave_length, wave_length_tol = ret_obj select_args['wavelength'] = wave_length select_args['wavelength_tolerance'] = wave_length_tol else: select_args['wavelength'] = None # select with filters self._myParent.ub_matrix_processing_table.select_scans( **select_args) # END-IF-ELSE return
def do_add_ub_peak(self): """ Add current to ub peaks :return: """ # Add peak status, int_list = gutil.parse_integers_editors([ self.ui.lineEdit_exp, self.ui.lineEdit_scanNumber, self.ui.lineEdit_ptNumber ]) if status is False: self.pop_one_button_dialog(int_list) exp_no, scan_no, pt_no = int_list # Get HKL from GUI status, float_list = gutil.parse_float_editors( [self.ui.lineEdit_H, self.ui.lineEdit_K, self.ui.lineEdit_L]) if status is False: err_msg = float_list self.pop_one_button_dialog(err_msg) return h, k, l = float_list status, peak_info_obj = self._myControl.get_peak_info( exp_no, scan_no, pt_no) if status is False: error_message = peak_info_obj self.pop_one_button_dialog(error_message) return assert isinstance(peak_info_obj, r4c.PeakInfo) if self.ui.checkBox_roundHKLInt.isChecked(): h = math.copysign(1, h) * int(abs(h) + 0.5) k = math.copysign(1, k) * int(abs(k) + 0.5) l = math.copysign(1, l) * int(abs(l) + 0.5) peak_info_obj.set_user_hkl(h, k, l) self.set_ub_peak_table(peak_info_obj) # Clear self.ui.lineEdit_scanNumber.setText('') self.ui.lineEdit_ptNumber.setText('') self.ui.lineEdit_sampleQx.setText('') self.ui.lineEdit_sampleQy.setText('') self.ui.lineEdit_sampleQz.setText('') self.ui.lineEdit_H.setText('') self.ui.lineEdit_K.setText('') self.ui.lineEdit_L.setText('') return
def do_add_ub_peak(self): """ Add current to ub peaks :return: """ # Add peak status, int_list = gutil.parse_integers_editors([self.ui.lineEdit_exp, self.ui.lineEdit_scanNumber, self.ui.lineEdit_ptNumber]) if status is False: self.pop_one_button_dialog(int_list) exp_no, scan_no, pt_no = int_list # Get HKL from GUI status, float_list = gutil.parse_float_editors([self.ui.lineEdit_H, self.ui.lineEdit_K, self.ui.lineEdit_L]) if status is False: err_msg = float_list self.pop_one_button_dialog(err_msg) return h, k, l = float_list status, peak_info_obj = self._myControl.get_peak_info(exp_no, scan_no, pt_no) if status is False: error_message = peak_info_obj self.pop_one_button_dialog(error_message) return assert isinstance(peak_info_obj, r4c.PeakInfo) if self.ui.checkBox_roundHKLInt.isChecked(): h = math.copysign(1, h)*int(abs(h)+0.5) k = math.copysign(1, k)*int(abs(k)+0.5) l = math.copysign(1, l)*int(abs(l)+0.5) peak_info_obj.set_user_hkl(h, k, l) self.set_ub_peak_table(peak_info_obj) # Clear self.ui.lineEdit_scanNumber.setText('') self.ui.lineEdit_ptNumber.setText('') self.ui.lineEdit_sampleQx.setText('') self.ui.lineEdit_sampleQy.setText('') self.ui.lineEdit_sampleQz.setText('') self.ui.lineEdit_H.setText('') self.ui.lineEdit_K.setText('') self.ui.lineEdit_L.setText('') return
def _get_lattice_parameters(self): """ Get lattice parameters from GUI :return: (Boolean, Object). True, 6-tuple as a, b, c, alpha, beta, gamm False: error message """ status, ret_list = gutil.parse_float_editors([ self.ui.lineEdit_a, self.ui.lineEdit_b, self.ui.lineEdit_c, self.ui.lineEdit_alpha, self.ui.lineEdit_beta, self.ui.lineEdit_gamma ]) if status is False: err_msg = ret_list err_msg = 'Unable to parse unit cell due to %s' % err_msg return False, err_msg a, b, c, alpha, beta, gamma = ret_list return True, (a, b, c, alpha, beta, gamma)
def _get_lattice_parameters(self): """ Get lattice parameters from GUI :return: (Boolean, Object). True, 6-tuple as a, b, c, alpha, beta, gamm False: error message """ status, ret_list = gutil.parse_float_editors([self.ui.lineEdit_a, self.ui.lineEdit_b, self.ui.lineEdit_c, self.ui.lineEdit_alpha, self.ui.lineEdit_beta, self.ui.lineEdit_gamma]) if status is False: err_msg = ret_list err_msg = 'Unable to parse unit cell due to %s' % err_msg return False, err_msg a, b, c, alpha, beta, gamma = ret_list return True, (a, b, c, alpha, beta, gamma)
def do_plot_3d(self): """ :return: """ # color: get R, G, B status, rgb_values = guiutility.parse_float_editors([ self.ui.lineEdit_baseColorRed, self.ui.lineEdit_baseColorGreen, self.ui.lineEdit_baseColorBlue ]) assert status # set the color to get change change_r = self.ui.checkBox_changeRed.isChecked() change_g = self.ui.checkBox_changeGreen.isChecked() change_b = self.ui.checkBox_changeBlue.isChecked() # get threshold status, thresholds = guiutility.parse_integers_editors( [ self.ui.lineEdit_countsThresholdLower, self.ui.lineEdit_countsThresholdUpper ], allow_blank=True) assert status, thresholds if thresholds[0] is None: thresholds[0] = 0 if thresholds[1] is None: thresholds[1] = sys.maxint assert 0 <= thresholds[0] < thresholds[1] # data key data_key = int(self.ui.comboBox_dataKey.currentText()) # plot self.plot_3d(data_key, rgb_values, thresholds, [change_r, change_g, change_b]) return
def set_calibration_to_reduction_controller(self, exp_number): """set user-specified instrument calibrations to the my controller :param exp_number: :return: """ # set up the experiment number if it is different if exp_number != self._myController.get_experiment(): self._myController.set_exp_number(exp_number) self._myController.set_default_detector_sample_distance(0.3750) self._myController.set_default_pixel_number(256, 256) # set up the calibration # wave length user_wavelength_str = str( self.ui.lineEdit_infoWavelength.text()).strip() if len(user_wavelength_str) > 0: try: user_wavelength = float(user_wavelength_str) self._myController.set_user_wave_length( exp_number, user_wavelength) except ValueError: gui_util.show_message( self, '[ERROR] User-specified wave length {0} cannot be converted to float.' ''.format(user_wavelength_str)) return # END-IF # detector center user_det_center_str = str( self.ui.lineEdit_infoDetCenter.text()).strip() user_det_center_str = user_det_center_str.replace('x', ',') if len(user_det_center_str) > 0: try: det_center = gui_util.parse_integer_list( user_det_center_str, 2) except RuntimeError as run_err: gui_util.show_message( self, 'Unable to parse detector center {0} due to {1}' ''.format(user_det_center_str, run_err)) return self._myController.set_detector_center(exp_number, det_center[0], det_center[1]) # END-IF # detector sample distance status, ret_obj = gui_util.parse_float_editors( [self.ui.lineEdit_infoDetSampleDistance], allow_blank=True) if not status: error_message = ret_obj gui_util.show_message(self, '[ERROR] {0}'.format(error_message)) return user_det_sample_distance = ret_obj[0] if user_det_sample_distance is not None: self._myController.set_detector_sample_distance( exp_number, user_det_sample_distance) # detector size curr_det_size_index = self.ui.comboBox_detSize.currentIndex() if curr_det_size_index > 2: gui_util.show_message( self, 'Detector {0} is not supported by now!' ''.format(str(self.ui.comboBox_detSize.currentText()))) return det_size = [256, 512][curr_det_size_index] self._myController.set_detector_geometry(det_size, det_size) return