Ejemplo n.º 1
0
    def set_band_range(self, current_signal=None):
        """Highlight the signal's band labels.

        If no signal is selected remove all highlights.
        """
        if current_signal is not None and not is_undef_freq(current_signal):
            lower_freq = safe_cast(
                current_signal.at[Signal.INF_FREQ], int
            )
            upper_freq = safe_cast(
                current_signal.at[Signal.SUP_FREQ], int
            )
            zipped = list(zip(Constants.BANDS, self.band_labels))
            for i, w in enumerate(zipped):
                band, band_label = w
                if lower_freq >= band.lower and lower_freq < band.upper:
                    self.activate_band_category(band_label)
                    for uband, uband_label in zipped[i + 1:]:
                        if upper_freq > uband.lower:
                            self.activate_band_category(uband_label)
                        else:
                            self.activate_band_category(uband_label, False)
                    break
                else:
                    self.activate_band_category(band_label, False)
        else:
            for band_label in self.band_labels:
                self.activate_band_category(band_label, False)
Ejemplo n.º 2
0
    def display_specs(self, item, previous_item):
        """Display the signal properties.

        'item' is the item corresponding to the selected signal
        'previous_item' is unused.
        """
        self.display_spectrogram()
        if item is not None:
            self.current_signal_name = item.text()
            self.name_lab.setText(self.current_signal_name)
            self.name_lab.setAlignment(Qt.AlignHCenter)
            current_signal = self.db.loc[self.current_signal_name]
            if not current_signal.at[Signal.WIKI_CLICKED]:
                state = UrlButton.State.ACTIVE
            else:
                state = UrlButton.State.CLICKED
            self.url_button.set_enabled(state)
            category_code = current_signal.at[Signal.CATEGORY_CODE]
            undef_freq = is_undef_freq(current_signal)
            undef_band = is_undef_band(current_signal)
            if not undef_freq:
                self.freq_lab.setText(
                    format_numbers(current_signal.at[Signal.INF_FREQ],
                                   current_signal.at[Signal.SUP_FREQ]))
            else:
                self.freq_lab.setText("Undefined")
            if not undef_band:
                self.band_lab.setText(
                    format_numbers(current_signal.at[Signal.INF_BAND],
                                   current_signal.at[Signal.SUP_BAND]))
            else:
                self.band_lab.setText("Undefined")

            self.mode_lab.setText(current_signal.at[Signal.MODE])
            self.modul_lab.setText(current_signal.at[Signal.MODULATION])
            self.loc_lab.setText(current_signal.at[Signal.LOCATION])
            self.acf_lab.setText(
                ACFValue.concat_strings(current_signal.at[Signal.ACF]))
            self.description_text.setText(
                current_signal.at[Signal.DESCRIPTION])
            for cat, cat_lab in zip(category_code, self.category_labels):
                if cat == '0':
                    cat_lab.setStyleSheet(f"color: {self.inactive_color};")
                elif cat == '1':
                    cat_lab.setStyleSheet(f"color: {self.active_color};")
            self.set_band_range(current_signal)
            self.audio_widget.set_audio_player(self.current_signal_name)
        else:
            self.url_button.set_disabled()
            self.current_signal_name = ''
            self.name_lab.setText("No Signal")
            self.name_lab.setAlignment(Qt.AlignHCenter)
            for lab in self.property_labels:
                lab.setText(Constants.UNKNOWN)
            for lab in self.category_labels:
                lab.setStyleSheet(f"color: {self.inactive_color};")
            self.set_band_range()
            self.audio_widget.set_audio_player()
Ejemplo n.º 3
0
    def _ok(self, signal_name):
        """Evalaute if the signal matches the frequency filters."""
        if not self.apply_remove_btn.isChecked():
            return True
        undef_freq = is_undef_freq(self._owner.db.loc[signal_name])
        if undef_freq:
            if self._owner.include_undef_freqs.isChecked():
                return True
            else:
                return False

        signal_freqs = (safe_cast(
            self._owner.db.at[signal_name, Signal.INF_FREQ], int),
                        safe_cast(
                            self._owner.db.at[signal_name, Signal.SUP_FREQ],
                            int))

        band_filter_ok = False
        any_checked = False
        for btn, band_limits in zip(self._frequency_filters_btns,
                                    Constants.BANDS):
            if btn.isChecked():
                any_checked = True
                if signal_freqs[0] < band_limits.upper and signal_freqs[
                        1] >= band_limits.lower:
                    band_filter_ok = True
        lower_limit_ok = True
        upper_limit_ok = True
        if self._owner.activate_low_freq_filter_btn.isChecked():
            if not signal_freqs[1] >= filters_limit(
                    self._owner.lower_freq_spinbox,
                    self._owner.lower_freq_filter_unit,
                    self._owner.lower_freq_confidence, -1):
                lower_limit_ok = False
        if self._owner.activate_up_freq_filter_btn.isChecked():
            if not signal_freqs[0] < filters_limit(
                    self._owner.upper_freq_spinbox,
                    self._owner.upper_freq_filter_unit,
                    self._owner.upper_freq_confidence):
                upper_limit_ok = False
        if any_checked:
            return band_filter_ok and lower_limit_ok and upper_limit_ok
        else:
            return lower_limit_ok and upper_limit_ok