Ejemplo n.º 1
0
    def do_browse_output_dir(self):
        """
        browse the output directory
        :return:
        """
        # get scan number or numbers
        try:
            exp_number = self.get_exp_number()
        except RuntimeError as run_err:
            gui_util.show_message(self, '[ERROR] {0}'.format(run_err))
            return

        default_dir = os.path.join(
            '/HFIR/HB3A/Exp{0}/shared/'.format(exp_number))

        # get output directory
        output_dir = str(
            QtGui.QFileDialog.getExistingDirectory(
                self, 'Outputs for pre-processed scans', default_dir))
        if output_dir is None or len(output_dir) == 0:
            return

        self.ui.lineEdit_outputDir.setText(output_dir)

        return
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    def do_browse_output_dir(self):
        """
        browse the output directory
        :return:
        """
        # get scan number or numbers
        try:
            exp_number = self.get_exp_number()
        except RuntimeError as run_err:
            gui_util.show_message(self, '[ERROR] {0}'.format(run_err))
            return

        default_dir = os.path.join('/HFIR/HB3A/Exp{0}/shared/'.format(exp_number))

        # get output directory
        output_dir = QFileDialog.getExistingDirectory(self, 'Outputs for pre-processed scans', default_dir)
        if not output_dir:
            return
        if isinstance(output_dir, tuple):
            output_dir = output_dir[0]
        self.ui.lineEdit_outputDir.setText(output_dir)
Ejemplo n.º 4
0
    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