예제 #1
0
    def show_scan_pt_list(self):
        """ Show the range of Pt. in a scan
        :return:
        """
        # Get parameters
        status, inp_list = gutil.parse_integers_editors([self.ui.lineEdit_exp, self.ui.lineEdit_run])
        if status is False:
            self.pop_one_button_dialog(inp_list)
            return
        else:
            exp_no = inp_list[0]
            scan_no = inp_list[1]

        status, ret_obj = self._myControl.get_pt_numbers(exp_no, scan_no)

        # Form message
        if status is False:
            # Failed to get Pt. list
            error_message = ret_obj
            self.pop_one_button_dialog(error_message)
        else:
            # Form message
            pt_list = sorted(ret_obj)
            num_pts = len(pt_list)
            info = 'Exp %d Scan %d has %d Pt. ranging from %d to %d.\n' % (exp_no, scan_no, num_pts,
                                                                           pt_list[0], pt_list[-1])
            num_miss_pt = pt_list[-1] - pt_list[0] + 1 - num_pts
            if num_miss_pt > 0:
                info += 'There are %d Pt. skipped.\n' % num_miss_pt

            self.pop_one_button_dialog(info)

        return
예제 #2
0
    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
예제 #3
0
    def show_scan_pt_list(self):
        """ Show the range of Pt. in a scan
        :return:
        """
        # Get parameters
        status, inp_list = gutil.parse_integers_editors(
            [self.ui.lineEdit_exp, self.ui.lineEdit_run])
        if status is False:
            self.pop_one_button_dialog(inp_list)
            return
        else:
            exp_no = inp_list[0]
            scan_no = inp_list[1]

        status, ret_obj = self._myControl.get_pt_numbers(exp_no, scan_no)

        # Form message
        if status is False:
            # Failed to get Pt. list
            error_message = ret_obj
            self.pop_one_button_dialog(error_message)
        else:
            # Form message
            pt_list = sorted(ret_obj)
            num_pts = len(pt_list)
            info = 'Exp %d Scan %d has %d Pt. ranging from %d to %d.\n' % (
                exp_no, scan_no, num_pts, pt_list[0], pt_list[-1])
            num_miss_pt = pt_list[-1] - pt_list[0] + 1 - num_pts
            if num_miss_pt > 0:
                info += 'There are %d Pt. skipped.\n' % num_miss_pt

            self.pop_one_button_dialog(info)

        return
예제 #4
0
    def do_plot_next_pt_raw(self):
        """ Plot the Pt.
        """
        # Get measurement pt and the file number
        status, ret_obj = gutil.parse_integers_editors([self.ui.lineEdit_exp,
                                                        self.ui.lineEdit_run,
                                                        self.ui.lineEdit_rawDataPtNo])
        if status is True:
            exp_no = ret_obj[0]
            scan_no = ret_obj[1]
            pt_no = ret_obj[2]
        else:
            self.pop_one_button_dialog(ret_obj)
            return

        # Previous one
        pt_no += 1
        # get last Pt. number
        status, last_pt_no = self._myControl.get_pt_numbers(exp_no, scan_no)
        if status is False:
            error_message = last_pt_no
            self.pop_one_button_dialog('Unable to access Spice table for scan %d. Reason" %s.' % (
                scan_no, error_message))
        if pt_no > last_pt_no:
            self.pop_one_button_dialog('Pt. = %d is the last one of scan %d.' % (pt_no, scan_no))
            return
        else:
            self.ui.lineEdit_rawDataPtNo.setText('%d' % pt_no)

        # Plot
        self._plot_raw_xml_2d(exp_no, scan_no, pt_no)

        return
예제 #5
0
    def do_check_counts(self):
        """ Check the intensity and count how many data points are above threshold of specified data-key
        :return:
        """
        # get threshold (upper and lower)
        status, ret_obj = guiutility.parse_integers_editors([self.ui.lineEdit_countsThresholdLower,
                                                             self.ui.lineEdit_countsThresholdUpper],
                                                            allow_blank=True)
        assert status, ret_obj
        threshold_lower, threshold_upper = ret_obj
        if threshold_lower is None:
            threshold_lower = 0
        if threshold_upper is None:
            threshold_upper = sys.maxint
        assert 0 <= threshold_lower < threshold_upper

        # get data key
        data_key = int(self.ui.comboBox_dataKey.currentText())
        assert data_key in self._dataKeyList, 'Data key %d does not exist in ' \
                                              'key list %s.' % (data_key, str(self._dataKeyList))

        # get intensity
        points, intensity_array = self.ui.graphicsView.get_data(data_key)
        assert points is not None
        num_within_threshold = 0
        array_size = len(intensity_array)
        for index in xrange(array_size):
            if threshold_lower <= intensity_array[index] <= threshold_upper:
                num_within_threshold += 1
        # END-FOR

        # set value
        self.ui.label_numberDataPoints.setText('%d' % num_within_threshold)

        return
예제 #6
0
    def do_plot_prev_pt_raw(self):
        """ Plot the Pt.
        """
        # Get measurement pt and the file number
        status, ret_obj = gutil.parse_integers_editors([
            self.ui.lineEdit_exp, self.ui.lineEdit_run,
            self.ui.lineEdit_rawDataPtNo
        ])
        if status is True:
            exp_no = ret_obj[0]
            scan_no = ret_obj[1]
            pt_no = ret_obj[2]
        else:
            self.pop_one_button_dialog(ret_obj)
            return

        # Previous one
        pt_no -= 1
        if pt_no <= 0:
            self.pop_one_button_dialog('Pt. = 1 is the first one.')
            return
        else:
            self.ui.lineEdit_rawDataPtNo.setText('%d' % pt_no)

        # Plot
        self._plot_raw_xml_2d(exp_no, scan_no, pt_no)

        return
예제 #7
0
    def do_plot_prev_pt_raw(self):
        """ Plot the Pt.
        """
        # Get measurement pt and the file number
        status, ret_obj = gutil.parse_integers_editors([self.ui.lineEdit_exp,
                                                        self.ui.lineEdit_run,
                                                        self.ui.lineEdit_rawDataPtNo])
        if status is True:
            exp_no = ret_obj[0]
            scan_no = ret_obj[1]
            pt_no = ret_obj[2]
        else:
            self.pop_one_button_dialog(ret_obj)
            return

        # Previous one
        pt_no -= 1
        if pt_no <= 0:
            self.pop_one_button_dialog('Pt. = 1 is the first one.')
            return
        else:
            self.ui.lineEdit_rawDataPtNo.setText('%d' % pt_no)

        # Plot
        self._plot_raw_xml_2d(exp_no, scan_no, pt_no)

        return
예제 #8
0
    def do_download_spice_data(self):
        """ Download SPICE data
        :return:
        """
        # Check scans to download
        scan_list_str = str(self.ui.lineEdit_downloadScans.text())
        if len(scan_list_str) > 0:
            # user specifies scans to download
            valid, scan_list = fcutil.parse_int_array(scan_list_str)
            if valid is False:
                error_message = scan_list
                self.pop_one_button_dialog(error_message)
        else:
            # Get all scans
            status, ret_obj = gutil.parse_integers_editors(
                [self.ui.lineEdit_exp])
            if status is False:
                self.pop_one_button_dialog(ret_obj)
                return
            exp_no = ret_obj
            assert isinstance(exp_no, int)
            server_url = str(self.ui.lineEdit_url.text())
            scan_list = fcutil.get_scans_list(server_url,
                                              exp_no,
                                              return_list=True)
        self.pop_one_button_dialog('Going to download scans %s.' %
                                   str(scan_list))

        # Check location
        destination_dir = str(self.ui.lineEdit_localSrcDir.text())
        status, error_message = self._myControl.set_local_data_dir(
            destination_dir)
        if status is False:
            self.pop_one_button_dialog(error_message)
        else:
            self.pop_one_button_dialog(
                'Spice files will be downloaded to %s.' % destination_dir)

        # Set up myControl for downloading data
        exp_no = int(self.ui.lineEdit_exp.text())
        self._myControl.set_exp_number(exp_no)

        server_url = str(self.ui.lineEdit_url.text())
        status, error_message = self._myControl.set_server_url(server_url)
        if status is False:
            self.pop_one_button_dialog(error_message)
            return

        # Download
        self._myControl.download_data_set(scan_list)

        return
예제 #9
0
    def do_find_peak(self):
        """ Find peak in a given scan/pt and record it
        """
        # Get experiment, scan and pt
        status, ret_obj = gutil.parse_integers_editors([
            self.ui.lineEdit_exp, self.ui.lineEdit_scanNumber,
            self.ui.lineEdit_ptNumber
        ])
        if status is True:
            exp_no, scan_no, pt_no = ret_obj
        else:
            self.pop_one_button_dialog(ret_obj)
            return

        # Find peak
        status, err_msg = self._myControl.find_peak(exp_no, scan_no, pt_no)
        if status is False:
            self.pop_one_button_dialog(ret_obj)
            return
        if self.ui.checkBox_loadHKLfromFile.isChecked() is True:
            # This is the first time that in the workflow to get HKL from MD workspace
            status, err_msg = self._myControl.set_hkl_to_peak(
                exp_no, scan_no, pt_no)
            if status is False:
                self.pop_one_button_dialog(
                    'Unable to locate peak info due to %s.' % err_msg)

        # Set up correct values to table tableWidget_peaksCalUB
        self._myControl.add_peak_info(exp_no, scan_no, pt_no)
        status, peak_info = self._myControl.get_peak_info(
            exp_no, scan_no, pt_no)
        if status is False:
            err_msg = peak_info
            raise KeyError(err_msg)
        assert isinstance(peak_info, r4c.PeakInfo)

        # Set the HKL value from PeakInfo directly
        # BAD PROGRAMMING! THERE ARE TOO MANY WAYS TO ACCESS STORED HKL
        h, k, l = peak_info.get_peak_ws_hkl()
        self.ui.lineEdit_H.setText('%.2f' % h)
        self.ui.lineEdit_K.setText('%.2f' % k)
        self.ui.lineEdit_L.setText('%.2f' % l)

        q_sample = peak_info.getQSample()
        self.ui.lineEdit_sampleQx.setText('%.5E' % q_sample[0])
        self.ui.lineEdit_sampleQy.setText('%.5E' % q_sample[1])
        self.ui.lineEdit_sampleQz.setText('%.5E' % q_sample[2])

        # self.set_ub_peak_table(peak_info)

        return
예제 #10
0
    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
예제 #11
0
    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
예제 #12
0
    def do_find_peak(self):
        """ Find peak in a given scan/pt and record it
        """
        # Get experiment, scan and pt
        status, ret_obj = gutil.parse_integers_editors([self.ui.lineEdit_exp,
                                                        self.ui.lineEdit_scanNumber,
                                                        self.ui.lineEdit_ptNumber])
        if status is True:
            exp_no, scan_no, pt_no = ret_obj
        else:
            self.pop_one_button_dialog(ret_obj)
            return

        # Find peak
        status, err_msg = self._myControl.find_peak(exp_no, scan_no, pt_no)
        if status is False:
            self.pop_one_button_dialog(ret_obj)
            return
        if self.ui.checkBox_loadHKLfromFile.isChecked() is True:
            # This is the first time that in the workflow to get HKL from MD workspace
            status, err_msg = self._myControl.set_hkl_to_peak(exp_no, scan_no, pt_no)
            if status is False:
                self.pop_one_button_dialog('Unable to locate peak info due to %s.' % err_msg)

        # Set up correct values to table tableWidget_peaksCalUB
        self._myControl.add_peak_info(exp_no, scan_no, pt_no)
        status, peak_info = self._myControl.get_peak_info(exp_no, scan_no, pt_no)
        if status is False:
            err_msg = peak_info
            raise KeyError(err_msg)
        assert isinstance(peak_info, r4c.PeakInfo)

        # Set the HKL value from PeakInfo directly
        # BAD PROGRAMMING! THERE ARE TOO MANY WAYS TO ACCESS STORED HKL
        h, k, l = peak_info.get_peak_ws_hkl()
        self.ui.lineEdit_H.setText('%.2f' % h)
        self.ui.lineEdit_K.setText('%.2f' % k)
        self.ui.lineEdit_L.setText('%.2f' % l)

        q_sample = peak_info.getQSample()
        self.ui.lineEdit_sampleQx.setText('%.5E' % q_sample[0])
        self.ui.lineEdit_sampleQy.setText('%.5E' % q_sample[1])
        self.ui.lineEdit_sampleQz.setText('%.5E' % q_sample[2])

        # self.set_ub_peak_table(peak_info)

        return
예제 #13
0
    def do_download_spice_data(self):
        """ Download SPICE data
        :return:
        """
        # Check scans to download
        scan_list_str = str(self.ui.lineEdit_downloadScans.text())
        if len(scan_list_str) > 0:
            # user specifies scans to download
            valid, scan_list = fcutil.parse_int_array(scan_list_str)
            if valid is False:
                error_message = scan_list
                self.pop_one_button_dialog(error_message)
        else:
            # Get all scans
            status, ret_obj = gutil.parse_integers_editors([self.ui.lineEdit_exp])
            if status is False:
                self.pop_one_button_dialog(ret_obj)
                return
            exp_no = ret_obj
            assert isinstance(exp_no, int)
            server_url = str(self.ui.lineEdit_url.text())
            scan_list = fcutil.get_scans_list(server_url, exp_no, return_list=True)
        self.pop_one_button_dialog('Going to download scans %s.' % str(scan_list))

        # Check location
        destination_dir = str(self.ui.lineEdit_localSrcDir.text())
        status, error_message = self._myControl.set_local_data_dir(destination_dir)
        if status is False:
            self.pop_one_button_dialog(error_message)
        else:
            self.pop_one_button_dialog('Spice files will be downloaded to %s.' % destination_dir)

        # Set up myControl for downloading data
        exp_no = int(self.ui.lineEdit_exp.text())
        self._myControl.set_exp_number(exp_no)

        server_url = str(self.ui.lineEdit_url.text())
        status, error_message = self._myControl.set_server_url(server_url)
        if status is False:
            self.pop_one_button_dialog(error_message)
            return

        # Download
        self._myControl.download_data_set(scan_list)

        return
예제 #14
0
    def do_load_scan_info(self):
        """ Load SIICE's scan file
        :return:
        """
        # Get scan number
        status, ret_obj = gutil.parse_integers_editors([self.ui.lineEdit_run])
        if status is True:
            scan_no = ret_obj[0]
        else:
            err_msg = ret_obj
            self.pop_one_button_dialog('Unable to get scan number in raw data tab due to %s.' % err_msg)
            return

        status, err_msg = self._myControl.load_spice_scan_file(exp_no=None, scan_no=scan_no)
        if status is False:
            self.pop_one_button_dialog(err_msg)

        return
예제 #15
0
    def do_plot_pt_raw(self):
        """ Plot the Pt.
        """
        # Get measurement pt and the file number
        status, ret_obj = gutil.parse_integers_editors([self.ui.lineEdit_exp,
                                                        self.ui.lineEdit_run,
                                                        self.ui.lineEdit_rawDataPtNo])
        if status is True:
            exp_no = ret_obj[0]
            scan_no = ret_obj[1]
            pt_no = ret_obj[2]
        else:
            self.pop_one_button_dialog(ret_obj)
            return

        # Call to plot 2D
        self._plot_raw_xml_2d(exp_no, scan_no, pt_no)

        return
예제 #16
0
    def do_cal_ub_matrix(self):
        """ Calculate UB matrix by 2 or 3 reflections
        """
        # Get reflections
        num_rows = self.ui.tableWidget_peaksCalUB.rowCount()
        peak_info_list = list()
        status, exp_number = gutil.parse_integers_editors(self.ui.lineEdit_exp)
        for i_row in xrange(num_rows):
            if self.ui.tableWidget_peaksCalUB.is_selected(i_row) is True:
                scan_num, pt_num = self.ui.tableWidget_peaksCalUB.get_exp_info(
                    i_row)
                status, peak_info = self._myControl.get_peak_info(
                    exp_number, scan_num, pt_num)
                peak_info.set_peak_ws_hkl_from_user()
                if status is False:
                    self.pop_one_button_dialog(peak_info)
                    return
                assert isinstance(peak_info, r4c.PeakInfo)
                peak_info_list.append(peak_info)
        # END-FOR

        # Get lattice
        status, ret_obj = self._get_lattice_parameters()
        if status is True:
            a, b, c, alpha, beta, gamma = ret_obj
        else:
            err_msg = ret_obj
            self.pop_one_button_dialog(err_msg)
            return

        # Calculate UB matrix
        status, ub_matrix = self._myControl.calculate_ub_matrix(
            peak_info_list, a, b, c, alpha, beta, gamma)

        # Deal with result
        if status is True:
            self._show_ub_matrix(ub_matrix)
        else:
            err_msg = ub_matrix
            self.pop_one_button_dialog(err_msg)

        return
예제 #17
0
    def do_plot_pt_raw(self):
        """ Plot the Pt.
        """
        # Get measurement pt and the file number
        status, ret_obj = gutil.parse_integers_editors([
            self.ui.lineEdit_exp, self.ui.lineEdit_run,
            self.ui.lineEdit_rawDataPtNo
        ])
        if status is True:
            exp_no = ret_obj[0]
            scan_no = ret_obj[1]
            pt_no = ret_obj[2]
        else:
            self.pop_one_button_dialog(ret_obj)
            return

        # Call to plot 2D
        self._plot_raw_xml_2d(exp_no, scan_no, pt_no)

        return
예제 #18
0
    def do_set_experiment(self):
        """ Set experiment
        :return:
        """
        status, ret_obj = gutil.parse_integers_editors([self.ui.lineEdit_exp])
        if status is True:
            exp_number = ret_obj[0]
            curr_exp_number = self._myControl.get_experiment()
            if curr_exp_number is not None and exp_number != curr_exp_number:
                self.pop_one_button_dialog('Changing experiment to %d.  Clean previous experiment %d\'s result'
                                           ' in Mantid manually.' % (exp_number, curr_exp_number))
            self._myControl.set_exp_number(exp_number)
            self.ui.lineEdit_exp.setStyleSheet('color: black')
        else:
            err_msg = ret_obj
            self.pop_one_button_dialog('Unable to set experiment as %s' % err_msg)
            self.ui.lineEdit_exp.setStyleSheet('color: red')

        self.ui.tabWidget.setCurrentIndex(0)

        return
예제 #19
0
    def do_load_scan_info(self):
        """ Load SIICE's scan file
        :return:
        """
        # Get scan number
        status, ret_obj = gutil.parse_integers_editors([self.ui.lineEdit_run])
        if status is True:
            scan_no = ret_obj[0]
        else:
            err_msg = ret_obj
            self.pop_one_button_dialog(
                'Unable to get scan number in raw data tab due to %s.' %
                err_msg)
            return

        status, err_msg = self._myControl.load_spice_scan_file(exp_no=None,
                                                               scan_no=scan_no)
        if status is False:
            self.pop_one_button_dialog(err_msg)

        return
예제 #20
0
    def do_cal_ub_matrix(self):
        """ Calculate UB matrix by 2 or 3 reflections
        """
        # Get reflections
        num_rows = self.ui.tableWidget_peaksCalUB.rowCount()
        peak_info_list = list()
        status, exp_number = gutil.parse_integers_editors(self.ui.lineEdit_exp)
        for i_row in xrange(num_rows):
            if self.ui.tableWidget_peaksCalUB.is_selected(i_row) is True:
                scan_num, pt_num = self.ui.tableWidget_peaksCalUB.get_exp_info(i_row)
                status, peak_info = self._myControl.get_peak_info(exp_number, scan_num, pt_num)
                peak_info.set_peak_ws_hkl_from_user()
                if status is False:
                    self.pop_one_button_dialog(peak_info)
                    return
                assert isinstance(peak_info, r4c.PeakInfo)
                peak_info_list.append(peak_info)
        # END-FOR

        # Get lattice
        status, ret_obj = self._get_lattice_parameters()
        if status is True:
            a, b, c, alpha, beta, gamma = ret_obj
        else:
            err_msg = ret_obj
            self.pop_one_button_dialog(err_msg)
            return

        # Calculate UB matrix
        status, ub_matrix = self._myControl.calculate_ub_matrix(peak_info_list, a, b, c,
                                                                alpha, beta, gamma)

        # Deal with result
        if status is True:
            self._show_ub_matrix(ub_matrix)
        else:
            err_msg = ub_matrix
            self.pop_one_button_dialog(err_msg)

        return
예제 #21
0
    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
예제 #22
0
    def do_set_experiment(self):
        """ Set experiment
        :return:
        """
        status, ret_obj = gutil.parse_integers_editors([self.ui.lineEdit_exp])
        if status is True:
            exp_number = ret_obj[0]
            curr_exp_number = self._myControl.get_experiment()
            if curr_exp_number is not None and exp_number != curr_exp_number:
                self.pop_one_button_dialog(
                    'Changing experiment to %d.  Clean previous experiment %d\'s result'
                    ' in Mantid manually.' % (exp_number, curr_exp_number))
            self._myControl.set_exp_number(exp_number)
            self.ui.lineEdit_exp.setStyleSheet('color: black')
        else:
            err_msg = ret_obj
            self.pop_one_button_dialog('Unable to set experiment as %s' %
                                       err_msg)
            self.ui.lineEdit_exp.setStyleSheet('color: red')

        self.ui.tabWidget.setCurrentIndex(0)

        return
예제 #23
0
    def do_check_counts(self):
        """ Check the intensity and count how many data points are above threshold of specified data-key
        :return:
        """
        # get threshold (upper and lower)
        status, ret_obj = guiutility.parse_integers_editors([
            self.ui.lineEdit_countsThresholdLower,
            self.ui.lineEdit_countsThresholdUpper
        ],
                                                            allow_blank=True)
        assert status, ret_obj
        threshold_lower, threshold_upper = ret_obj
        if threshold_lower is None:
            threshold_lower = 0
        if threshold_upper is None:
            threshold_upper = sys.maxint
        assert 0 <= threshold_lower < threshold_upper

        # get data key
        data_key = int(self.ui.comboBox_dataKey.currentText())
        assert data_key in self._dataKeyList, 'Data key %d does not exist in ' \
                                              'key list %s.' % (data_key, str(self._dataKeyList))

        # get intensity
        points, intensity_array = self.ui.graphicsView.get_data(data_key)
        assert points is not None
        num_within_threshold = 0
        array_size = len(intensity_array)
        for index in xrange(array_size):
            if threshold_lower <= intensity_array[index] <= threshold_upper:
                num_within_threshold += 1
        # END-FOR

        # set value
        self.ui.label_numberDataPoints.setText('%d' % num_within_threshold)

        return
예제 #24
0
    def do_find_peak(self):
        """
        find the peak(s) in a merged scan
        :return:
        """
        # get scan number
        status, ret_obj = guiutility.parse_integers_editors(
            [self.ui.lineEdit_scanNumber])
        if status:
            scan_number = ret_obj[0]
        else:
            # pop error message
            self._myParent.pop_one_button_dialog(ret_obj)
            return

        # load HKL from SPICE?
        hkl_from_spice = self.ui.checkBox_loadHKLfromFile.isChecked()

        # find peak
        status, ret_obj = self._myParent.find_peak_in_scan(
            scan_number, hkl_from_spice)

        # set the result
        if status:
            hkl, vec_q = ret_obj
            if len(hkl) > 0:
                self.ui.lineEdit_H.setText('%.2f' % hkl[0])
                self.ui.lineEdit_K.setText('%.2f' % hkl[1])
                self.ui.lineEdit_L.setText('%.2f' % hkl[2])

            self.ui.lineEdit_sampleQx.setText('%.5E' % vec_q[0])
            self.ui.lineEdit_sampleQy.setText('%.5E' % vec_q[1])
            self.ui.lineEdit_sampleQz.setText('%.5E' % vec_q[2])
        # END-IF

        return
예제 #25
0
    def do_plot_next_pt_raw(self):
        """ Plot the Pt.
        """
        # Get measurement pt and the file number
        status, ret_obj = gutil.parse_integers_editors([
            self.ui.lineEdit_exp, self.ui.lineEdit_run,
            self.ui.lineEdit_rawDataPtNo
        ])
        if status is True:
            exp_no = ret_obj[0]
            scan_no = ret_obj[1]
            pt_no = ret_obj[2]
        else:
            self.pop_one_button_dialog(ret_obj)
            return

        # Previous one
        pt_no += 1
        # get last Pt. number
        status, last_pt_no = self._myControl.get_pt_numbers(exp_no, scan_no)
        if status is False:
            error_message = last_pt_no
            self.pop_one_button_dialog(
                'Unable to access Spice table for scan %d. Reason" %s.' %
                (scan_no, error_message))
        if pt_no > last_pt_no:
            self.pop_one_button_dialog('Pt. = %d is the last one of scan %d.' %
                                       (pt_no, scan_no))
            return
        else:
            self.ui.lineEdit_rawDataPtNo.setText('%d' % pt_no)

        # Plot
        self._plot_raw_xml_2d(exp_no, scan_no, pt_no)

        return