Example #1
0
    def set_wlet_pars(self):

        # period validator
        vali = self.periodV

        # read all the LineEdits:

        text = self.T_min.text()
        T_min = text.replace(",", ".")
        check, _, _ = vali.validate(T_min, 0)
        if self.debug:
            print("Min periodValidator output:", check, "value:", T_min)
        if check == 0:
            self.OutOfBounds = MessageWindow("Wavelet periods out of bounds!",
                                             "Value Error")
            return False
        self.T_min_value = float(T_min)

        step_num = self.step_num.text()
        check, _, _ = posintV.validate(step_num, 0)
        if self.debug:
            print("# Periods posintValidator:", check, "value:", step_num)
        if check == 0:
            self.OutOfBounds = MessageWindow(
                "The Number of periods must be a positive integer!",
                "Value Error")
            return False
        self.step_num_value = int(step_num)

        text = self.T_max.text()

        T_max = text.replace(",", ".")
        check, _, _ = vali.validate(T_max, 0)
        if self.debug:
            print("Max periodValidator output:", check)
            print(f"Max period value: {self.T_max.text()}")
        if check == 0 or check == 1:
            self.OutOfBounds = MessageWindow(
                "Wavelet highest period out of bounds!", "Value Error")
            return False
        self.T_max_value = float(T_max)

        text = self.p_max.text()
        p_max = text.replace(",", ".")
        check, _, _ = posfloatV.validate(p_max, 0)  # checks for positive float
        if check == 0:
            self.OutOfBounds = MessageWindow("Powers are positive!",
                                             "Value Error")
            return False

        # check for empty string:
        if p_max:
            self.p_max_value = float(p_max)
        else:
            self.p_max_value = None

        # success!
        return True
Example #2
0
    def set_wlet_pars(self):

        '''
        Retrieves and checks the set wavelet parameters
        of the 'Analysis' input box reading the following
        QLineEdits:

        self.Tmin
        self.Tmax
        self.step_num
        self.pmax

        Further the checkboxes regarding detrending and amplitude
        normalization are evaluated. And

        self.get_L()
        self.get_T_c()

        are called if needed. These respective parameters are set to False
        if the opereation in question is not requested.

        Returns
        -------

        wlet_pars : dictionary holding the retrieved parameters,
                    L and T_c are set to None if no amplitude
                    normalization or detrending operation should be done

        '''

        wlet_pars = {}

        # period validator
        vali = self.periodV

        # -- read all the QLineEdits --

        text = self.T_min.text()
        T_min = text.replace(",", ".")
        check, _, _ = vali.validate(T_min, 0)
        if self.debug:
            print("Min periodValidator output:", check, "value:", T_min)
        if check == 0:
            self.OutOfBounds = MessageWindow(
                "Wavelet periods out of bounds!", "Value Error"
            )
            return False

        wlet_pars['T_min'] = float(T_min)
                
        step_num = self.step_num.text()
        check, _, _ = posintV.validate(step_num, 0)
        if self.debug:
            print("# Periods posintValidator:", check, "value:", step_num)
        if check == 0:
            self.OutOfBounds = MessageWindow(
                "The Number of periods must be a positive integer!", "Value Error"
            )
            return False

        wlet_pars['step_num'] = int(step_num)
        if int(step_num) > 1000:

            choice = QMessageBox.question(
                self,
                "Too much periods?: ",
                "High number of periods: Do you want to continue?",
                QMessageBox.Yes | QMessageBox.No,
            )
            if choice == QMessageBox.Yes:
                pass
            else:
                return False        
        
        text = self.T_max.text()
        T_max = text.replace(",", ".")
        check, _, _ = vali.validate(T_max, 0)
        if self.debug:
            print("Max periodValidator output:", check)
            print(f"Max period value: {self.T_max.text()}")
        if check == 0 or check == 1:
            self.OutOfBounds = MessageWindow(
                "Wavelet highest period out of bounds!", "Value Error"
            )
            return False
        wlet_pars['T_max'] = float(T_max)

        text = self.p_max.text()
        p_max = text.replace(",", ".")
        check, _, _ = posfloatV.validate(p_max, 0)  # checks for positive float
        if check == 0:
            self.OutOfBounds = MessageWindow("Powers are positive!", "Value Error")
            return False

        # check for empty string:
        if p_max:
            wlet_pars['p_max'] = float(p_max)
        else:
            wlet_pars['p_max'] = None

        # -- the checkboxes --
            
        # detrend for the analysis?
        if self.cb_use_detrended.isChecked():
            T_c = self.get_T_c(self.T_c_edit)
            if T_c is None:
                return False # abort settings            
            wlet_pars['T_c'] = T_c
        else:
            # indicates no detrending requested
            wlet_pars['T_c'] = False
            
        # amplitude normalization is downstram of detrending!
        if self.cb_use_envelope.isChecked():
            L = self.get_L(self.L_edit)        
            if L is None:
                return False # abort settings                        
            wlet_pars['L'] = L
        else:
            # indicates no ampl. normalization
            wlet_pars['L'] = False
                    
        # success!
        return wlet_pars
Example #3
0
    def set_wlet_pars(self):
        '''
        Retrieves and checks the set wavelet parameters
        of the 'Analysis' input box reading the following
        QLineEdits:

        self.Tmin_edit
        self.Tmax_edit
        self.nT_edit
        self.pow_max_edit

        Further the checkboxes regarding detrending and amplitude
        normalization are evaluated. And

        self.get_wsize()
        self.get_T_c()

        are called if needed. 

        Returns
        -------

        wlet_pars : dictionary holding the retrieved parameters,
                    window_size and T_c are set to None if no amplitude
                    normalization or detrending operation should be done

        '''

        wlet_pars = {}

        # period validator
        vali = self.periodV

        # -- read all the QLineEdits --

        text = self.Tmin_edit.text()
        text = text.replace(",", ".")
        check, _, _ = vali.validate(text, 0)
        if self.debug:
            print("Min periodValidator output:", check, "value:", text)
        if check == 0:

            msgBox = QMessageBox()
            msgBox.setText("Lowest period out of bounds!")
            msgBox.exec()

            return False

        Tmin = float(text)

        if Tmin < 2 * self.dt:

            Tmin = 2 * self.dt
            self.Tmin_edit.clear()
            self.Tmin_edit.insert(str(Tmin))

            msgBox = QMessageBox()
            msgBox.setWindowTitle('Warning')
            msg = f"Lowest period set to Nyquist limit: {Tmin} {self.time_unit}!"
            msgBox.setText(msg)
            msgBox.exec()

        wlet_pars['Tmin'] = Tmin

        step_num = self.nT_edit.text()
        check, _, _ = posintV.validate(step_num, 0)
        if self.debug:
            print("# Periods posintValidator:", check, "value:", step_num)
        if check == 0:

            msgBox = QMessageBox()
            msgBox.setText("The Number of periods must be a positive integer!")
            msgBox.exec()
            return False

        wlet_pars['step_num'] = int(step_num)
        if int(step_num) > 1000:

            choice = QMessageBox.question(
                self,
                "Too much periods?: ",
                "High number of periods: Do you want to continue?",
                QMessageBox.Yes | QMessageBox.No,
            )
            if choice == QMessageBox.Yes:
                pass
            else:
                return False

        text = self.Tmax_edit.text()
        Tmax = text.replace(",", ".")
        check, _, _ = vali.validate(Tmax, 0)
        if self.debug:
            print("Max periodValidator output:", check)
            print(f"Max period value: {self.Tmax_edit.text()}")
        if check == 0 or check == 1:

            msgBox = QMessageBox()
            msgBox.setText("Highest periods out of bounds!")
            msgBox.exec()

            return False
        wlet_pars['Tmax'] = float(Tmax)

        text = self.pow_max_edit.text()
        pow_max = text.replace(",", ".")
        check, _, _ = posfloatV.validate(pow_max,
                                         0)  # checks for positive float
        if check == 0:

            msgBox = QMessageBox()
            msgBox.setText("Maximal power must be positive!")
            msgBox.exec()

            return False

        # check for empty string:
        if pow_max:
            wlet_pars['pow_max'] = float(pow_max)
        else:
            wlet_pars['pow_max'] = None

        # -- the checkboxes --

        # detrend for the analysis?
        if self.cb_use_detrended.isChecked():
            T_c = self.get_T_c(self.T_c_edit)
            if T_c is None:
                return False  # abort settings
            wlet_pars['T_c'] = T_c
        else:
            # indicates no detrending requested
            wlet_pars['T_c'] = None

        # amplitude normalization is downstram of detrending!
        if self.cb_use_envelope.isChecked():
            window_size = self.get_wsize(self.wsize_edit)
            if window_size is None:
                return False  # abort settings
            wlet_pars['window_size'] = window_size
        else:
            # indicates no ampl. normalization
            wlet_pars['window_size'] = None

        # success!
        return wlet_pars