From 175cb66c7603eb43892b70f58d6dc58cde77e20a Mon Sep 17 00:00:00 2001 From: alessandro90 Date: Sat, 4 May 2019 17:55:17 +0200 Subject: [PATCH 1/6] Forecast screen. Just a partial implementation: gui and info btn --- .gitignore | 2 +- artemis.py | 73 ++- artemis.ui | 1103 ++++++++++++++++++++++++++++++++- clickable_progress_bar.py | 10 +- constants.py | 285 +++++---- fixed_aspect_ratio_label.py | 12 +- forecastdata.py | 3 + space_weather_data.py | 4 +- switchable_label.py | 62 +- themes.py => themesmanager.py | 26 +- threads.py | 8 +- 11 files changed, 1394 insertions(+), 194 deletions(-) create mode 100644 forecastdata.py rename themes.py => themesmanager.py (95%) diff --git a/.gitignore b/.gitignore index bcc7033..4a63335 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,6 @@ to_do.txt csv_info.txt pyinstaller_cmd.txt themes/.current_theme -*.bat +launch.bat *.sh .vscode/ diff --git a/artemis.py b/artemis.py index 5b48943..012d820 100644 --- a/artemis.py +++ b/artemis.py @@ -23,6 +23,7 @@ from PyQt5.QtCore import (QFileInfo, from audio_player import AudioPlayer from space_weather_data import SpaceWeatherData +from forecastdata import ForecastData from download_window import DownloadWindow from switchable_label import SwitchableLabelsIterable from constants import (Constants, @@ -31,8 +32,9 @@ from constants import (Constants, Database, ChecksumWhat, Messages, - Signal,) -from themes import Theme + Signal, + Months) +from themesmanager import ThemeManager from utilities import (checksum_ok, uncheck_and_emit, pop_up, @@ -80,6 +82,7 @@ class Artemis(QMainWindow, Ui_MainWindow): self.current_signal_name = '' self.signal_names = [] self.total_signals = 0 + self.switchable_r_labels = SwitchableLabelsIterable( self.r0_now_lbl, self.r1_now_lbl, @@ -138,23 +141,23 @@ class Artemis(QMainWindow, Ui_MainWindow): self.a_quiet_lbl ) - self.forecast_labels = ( - self.forecast_lbl_0, - self.forecast_lbl_1, - self.forecast_lbl_2, - self.forecast_lbl_3, - self.forecast_lbl_4, - self.forecast_lbl_5, - self.forecast_lbl_6, - self.forecast_lbl_7, - self.forecast_lbl_8 + self.space_weather_labels = ( + self.space_weather_lbl_0, + self.space_weather_lbl_1, + self.space_weather_lbl_2, + self.space_weather_lbl_3, + self.space_weather_lbl_4, + self.space_weather_lbl_5, + self.space_weather_lbl_6, + self.space_weather_lbl_7, + self.space_weather_lbl_8 ) - for lab in self.forecast_labels: + for lab in self.space_weather_labels: lab.set_default_stylesheet() - self.forecast_label_container.labels = self.forecast_labels - self.theme = Theme(self) + self.space_weather_label_container.labels = self.space_weather_labels + self.theme_manager = ThemeManager(self) # Manage frequency filters. self.frequency_filters_btns = ( @@ -501,18 +504,52 @@ class Artemis(QMainWindow, Ui_MainWindow): # Space weather self.info_now_btn.clicked.connect( - lambda : webbrowser.open(Constants.FORECAST_INFO) + lambda: webbrowser.open(Constants.SPACE_WEATHER_INFO) ) self.update_now_bar.clicked.connect(self.start_update_space_weather) self.update_now_bar.set_idle() self.space_weather_data = SpaceWeatherData() self.space_weather_data.update_complete.connect(self.update_space_weather) + # Forecast + self.forecast_info_btn.clicked.connect( + lambda: webbrowser.open(Constants.SPACE_WEATHER_INFO) + ) + self.update_forecast_bar.clicked.connect(self.start_update_forecast) + self.update_forecast_bar.set_idle() + self.forecast_data = ForecastData() + self.today_forecast_labels = [] + self.today_p1_forecast_labels = [] + self.today_p2_forecast_labels = [] + self.all_forecast_labels = [] + flags = ['', 'p1_', 'p2_'] + for flag in flags: + title_lbl = getattr(self, "today_" + flag + "lbl") + title_lbl.setText("-") + for index in range(20): + label = getattr( + self, + "forecast_today_" + flag + str(index) + "_lbl" + ) + label.setText(Constants.UNKNOWN) + self.all_forecast_labels.append(label) + if flag == flags[0]: + self.today_forecast_labels.append(label) + if flag == flags[1]: + self.today_p1_forecast_labels.append(label) + if flag == flags[2]: + self.today_p2_forecast_labels.append(label) + + # Final operations. - self.theme.initialize() + self.theme_manager.start() self.load_db() self.display_signals() + @pyqtSlot() + def start_update_forecast(self): + pass + @pyqtSlot() def start_update_space_weather(self): if not self.space_weather_data.is_updating: @@ -659,7 +696,7 @@ class Artemis(QMainWindow, Ui_MainWindow): val = int([x[4] for x in self.space_weather_data.sgas if "SSN" in x][0]) self.sn_lbl.setText(f"{val:d}") - for label, pixmap in zip(self.forecast_labels, self.space_weather_data.images): + for label, pixmap in zip(self.space_weather_labels, self.space_weather_data.images): label.pixmap = pixmap label.make_transparent() label.apply_pixmap() diff --git a/artemis.ui b/artemis.ui index 86163b4..5524ce9 100644 --- a/artemis.ui +++ b/artemis.ui @@ -178,7 +178,7 @@ QTabWidget::Rounded - 0 + 3 true @@ -4681,7 +4681,10 @@ www.qrg.globaltuners.com - + + + 1 + Now @@ -4751,6 +4754,9 @@ www.qrg.globaltuners.com Radio Blackout + + 25 + @@ -4935,6 +4941,9 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto Solar Radiation Storm + + 25 + @@ -6076,6 +6085,9 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto Peak Flux Class + + 25 + @@ -6371,7 +6383,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6380,7 +6392,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6415,7 +6427,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6444,7 +6456,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6473,7 +6485,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6502,7 +6514,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6531,7 +6543,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6560,7 +6572,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6589,7 +6601,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6618,7 +6630,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + 0 @@ -6844,8 +6856,1063 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - Tab 2 + Forecast + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + 21 - 00 + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + 18 - 21 + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + 15 - 18 + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + 12 - 15 + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + 03 - 06 + + + 25 + + + + + + + + 11 + 75 + true + + + + Kp Index Forecast + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + 09 - 12 + + + 25 + + + + + + + 00 - 03 + + + 25 + + + + + + + 06 - 09 + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + Major + + + 50 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 10 + + + + High Lat. + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + Major + + + 50 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + Minor + + + 50 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + Active + + + 50 + + + + + + + Active + + + 50 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + Minor + + + 50 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 10 + + + + Mid Lat. + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 11 + 75 + true + + + + Geomagnetic Act. + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + + + + R1 - R2 + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 11 + 75 + true + + + + Radio Blackout Act. + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Info + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + + + + + 0 + 0 + + + + + 11 + 75 + true + + + + today+1 + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + + 11 + 75 + true + + + + today+2 + + + Qt::AlignCenter + + + + + + + + 11 + 75 + true + + + + Solar Radiation Storm + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + S1 or Greater + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + 1 + + + 0 + + + false + + + + + + + + 0 + 0 + + + + + 11 + 75 + true + + + + today + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 11 + 75 + true + + + + Event Probabilities + + + + + + + Class M flare + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + + + + Class X flare + + + 25 + + + + + + + Proton flare + + + 25 + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + TextLabel + + + Qt::AlignCenter + + + + + + + > R3 + + + 25 + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + @@ -7230,6 +8297,16 @@ QSlider::handle:horizontal { QLabel
fixed_aspect_ratio_label.h
+ + SingleColorSwitchableLabel + QLabel +
switchable_label.h
+
+ + MultiColorSwitchableLabel + QLabel +
switchable_label.h
+
diff --git a/clickable_progress_bar.py b/clickable_progress_bar.py index 815a8e3..2ab387d 100644 --- a/clickable_progress_bar.py +++ b/clickable_progress_bar.py @@ -11,18 +11,20 @@ class ClickableProgressBar(QProgressBar): self.__text = '' super().__init__(parent) - def __set_text(self, text): - self.__text = text + # def __set_text(self, text): + # self.__text = text def text(self): return self.__text def set_idle(self): - self.__set_text(Constants.CLICK_TO_UPDATE_STR) + # self.__set_text(Constants.CLICK_TO_UPDATE_STR) + self.__text = Constants.CLICK_TO_UPDATE_STR self.setMaximum(self.minimum() + 1) def set_updating(self): - self.__set_text(Constants.UPDATING_STR) + # self.__set_text(Constants.UPDATING_STR) + self.__text = Constants.UPDATING_STR self.setMaximum(self.minimum()) def mousePressEvent(self, event): diff --git a/constants.py b/constants.py index c465342..0870dd3 100644 --- a/constants.py +++ b/constants.py @@ -2,7 +2,7 @@ from collections import namedtuple from enum import Enum, auto -class Ftype(object): +class Ftype: FREQ = "freq" BAND = "band" @@ -17,7 +17,7 @@ class ChecksumWhat(Enum): DB = auto() -class Messages(object): +class Messages: DB_UP_TO_DATE = "Already up to date" DB_UP_TO_DATE_MSG = "No newer version to download." DB_NEW_VER = "New version available" @@ -32,7 +32,7 @@ class Messages(object): BAD_DOWNLOAD_MSG = "Something went wrong with the downaload.\nCheck your internet connection and try again." -class Signal(object): +class Signal: NAME = "name" INF_FREQ = "inf_freq" SUP_FREQ = "sup_freq" @@ -48,7 +48,7 @@ class Signal(object): WIKI_CLICKED = "url_clicked" -class Database(object): +class Database: LINK_LOC = "https://aresvalley.com/Storage/Artemis/Database/data.zip" LINK_REF = "https://aresvalley.com/Storage/Artemis/Database/data.zip.log" NAME = "db.csv" @@ -73,128 +73,155 @@ class Database(object): Signal.CATEGORY_CODE,) -class Constants(object): - CLICK_TO_UPDATE_STR = "Click to update" - SIGIDWIKI = "https://www.sigidwiki.com/wiki/Signal_Identification_Guide" - ADD_SIGNAL_LINK = "https://www.sigidwiki.com/index.php/Special:FormEdit/Signal/?preload=Signal_Identification_Wiki:Signal_form_preload_text" - FORUM_LINK = "https://aresvalley.com/community/" - ARESVALLEY_LINK = "https://aresvalley.com/" - RTL_SDL_LINK = "https://www.rtl-sdr.com/" - UPDATING_STR = "Updating..." - ACF_DOCS = "https://aresvalley.com/documentation/" - FORECAST_XRAY = "https://services.swpc.noaa.gov/text/goes-xray-flux-primary.txt" - FORECAST_PROT_EL = "https://services.swpc.noaa.gov/text/goes-particle-flux-primary.txt" - FORECAST_AK_INDEX = "https://services.swpc.noaa.gov/text/wwv.txt" - FORECAST_SGAS = "https://services.swpc.noaa.gov/text/sgas.txt" - FORECAST_GEO_STORM = "https://services.swpc.noaa.gov/text/3-day-forecast.txt" - FORECAST_INFO = "https://www.swpc.noaa.gov/sites/default/files/images/NOAAscales.pdf" - FORECAST_IMGS = ["http://www.mmmonvhf.de/eme/eme.png", - "http://www.mmmonvhf.de/ms/ms.png", - "http://www.mmmonvhf.de/es/es.png", - "http://www.mmmonvhf.de/solar/solar.png", - "http://amunters.home.xs4all.nl/eskip50status.gif", - "http://amunters.home.xs4all.nl/eskip70status.gif", - "http://amunters.home.xs4all.nl/eskipstatus.gif", - "https://amunters.home.xs4all.nl/eskipstatusNA.gif", - "https://amunters.home.xs4all.nl/aurorastatus.gif"] - SEARCH_LABEL_IMG = "search_icon.png" - VOLUME_LABEL_IMG = "volume.png" - DATA_FOLDER = "Data" - SPECTRA_FOLDER = "Spectra" - SPECTRA_EXT = ".png" - AUDIO_FOLDER = "Audio" - ACTIVE = "active" - INACTIVE = "inactive" - LABEL_ON_COLOR = "on" - LABEL_OFF_COLOR = "off" - TEXT_COLOR = "text" - NOT_AVAILABLE = "spectrumnotavailable.png" - NOT_SELECTED = "nosignalselected.png" - __Band = namedtuple("Band", ["lower", "upper"]) - __ELF = __Band(0, 30) # Formally it is (3, 30) Hz. - __SLF = __Band(30, 300) - __ULF = __Band(300, 3000) - __VLF = __Band(3000, 30000) - __LF = __Band(30 * 10**3, 300 * 10**3) - __MF = __Band(300 * 10 ** 3, 3000 * 10**3) - __HF = __Band(3 * 10**6, 30 * 10**6) - __VHF = __Band(30 * 10**6, 300 * 10**6) - __UHF = __Band(300 * 10**6, 3000 * 10**6) - __SHF = __Band(3 * 10**9, 30 * 10**9) - __EHF = __Band(30 * 10**9, 300 * 10**9) - BANDS = (__ELF, __SLF, __ULF, __VLF, __LF, __MF, __HF, __VHF, __UHF, __SHF, __EHF) - MAX_DIGITS = 3 - RANGE_SEPARATOR = ' รท ' - GFD_SITE = "http://qrg.globaltuners.com/" - CONVERSION_FACTORS = {"Hz" : 1, - "kHz": 1000, - "MHz": 1000000, - "GHz": 1000000000} - MODES = {"FM": ("NFM", "WFM"), - "AM": (), - "CW": (), - "SK": ("FSK", "PSK", "MSK"), - "SB": ("LSB", "USB", "DSB"), - "Chirp Spread Spectrum": (), - "FHSS-TDM": (), - "RAW": (), - "SC-FDMA": (),} - APPLY = "Apply" - REMOVE = "Remove" - UNKNOWN = "N/A" - MODULATIONS = ("8VSB", - "AFSK", - "AM", - "BFSK", - "C4FM", - "CDMA", - "COFDM", - "CW", - "FFSK", - "FM", - "FMCW", - "FMOP", - "FSK", - "GFSK", - "GMSK", - "IFK", - "MFSK", - "MSK", - "OFDM", - "OOK", - "PAM", - "PPM", - "PSK", - "QAM", - "TDMA",) - LOCATIONS = (UNKNOWN, - "Australia", - "Canada", - "Central Europe", - "China", - "Cyprus", - "Eastern Europe", - "Europe", - "Europe, japan and Asia", - "Exmouth, Australia", - "Finland", - "France", - "Germany", - "Home Base Mobile , AL", - "Hungary", - "Iran", - "Israel", - "Japan", - "LaMour, North Dakota", - "Lualualei, Hawaii", - "North America", - "North Korea", - "Poland", - "Romania", - "Ruda, Sweden", - "UK", - "United Kingdom", - "United States", - "Varberg, Sweden", - "World Wide", - "Worldwide",) +class ForecastColors: + WARNING_COLOR = "#F95423" + KP9_COLOR = "#FFCCCB" + KP8_COLOR = "#FFCC9A" + KP7_COLOR = "#FFFECD" + KP6_COLOR = "#CDFFCC" + KP5_COLOR = "#BEE3FE" + + +class Months: + MONTS = [ + "0", + "Jan", + "Feb", + "Mar", + "Apr", + "May", + "Jun", + "Jul", + "Aug", + "Sep", + "Oct", + "Nov", + "Dec" + ] + + +class Constants: + CLICK_TO_UPDATE_STR = "Click to update" + SIGIDWIKI = "https://www.sigidwiki.com/wiki/Signal_Identification_Guide" + ADD_SIGNAL_LINK = "https://www.sigidwiki.com/index.php/Special:FormEdit/Signal/?preload=Signal_Identification_Wiki:Signal_form_preload_text" + FORUM_LINK = "https://aresvalley.com/community/" + ARESVALLEY_LINK = "https://aresvalley.com/" + RTL_SDL_LINK = "https://www.rtl-sdr.com/" + UPDATING_STR = "Updating..." + ACF_DOCS = "https://aresvalley.com/documentation/" + SPACE_WEATHER_XRAY = "https://services.swpc.noaa.gov/text/goes-xray-flux-primary.txt" + SPACE_WEATHER_PROT_EL = "https://services.swpc.noaa.gov/text/goes-particle-flux-primary.txt" + SPACE_WEATHER_AK_INDEX = "https://services.swpc.noaa.gov/text/wwv.txt" + SPACE_WEATHER_SGAS = "https://services.swpc.noaa.gov/text/sgas.txt" + SPACE_WEATHER_GEO_STORM = "https://services.swpc.noaa.gov/text/3-day-forecast.txt" + SPACE_WEATHER_INFO = "https://www.swpc.noaa.gov/sites/default/files/images/NOAAscales.pdf" + SPACE_WEATHER_IMGS = ["http://www.mmmonvhf.de/eme/eme.png", + "http://www.mmmonvhf.de/ms/ms.png", + "http://www.mmmonvhf.de/es/es.png", + "http://www.mmmonvhf.de/solar/solar.png", + "http://amunters.home.xs4all.nl/eskip50status.gif", + "http://amunters.home.xs4all.nl/eskip70status.gif", + "http://amunters.home.xs4all.nl/eskipstatus.gif", + "https://amunters.home.xs4all.nl/eskipstatusNA.gif", + "https://amunters.home.xs4all.nl/aurorastatus.gif"] + SEARCH_LABEL_IMG = "search_icon.png" + VOLUME_LABEL_IMG = "volume.png" + DATA_FOLDER = "Data" + SPECTRA_FOLDER = "Spectra" + SPECTRA_EXT = ".png" + AUDIO_FOLDER = "Audio" + ACTIVE = "active" + INACTIVE = "inactive" + LABEL_ON_COLOR = "on" + LABEL_OFF_COLOR = "off" + TEXT_COLOR = "text" + NOT_AVAILABLE = "spectrumnotavailable.png" + NOT_SELECTED = "nosignalselected.png" + __Band = namedtuple("Band", ["lower", "upper"]) + __ELF = __Band(0, 30) # Formally it is (3, 30) Hz. + __SLF = __Band(30, 300) + __ULF = __Band(300, 3000) + __VLF = __Band(3000, 30000) + __LF = __Band(30 * 10**3, 300 * 10**3) + __MF = __Band(300 * 10 ** 3, 3000 * 10**3) + __HF = __Band(3 * 10**6, 30 * 10**6) + __VHF = __Band(30 * 10**6, 300 * 10**6) + __UHF = __Band(300 * 10**6, 3000 * 10**6) + __SHF = __Band(3 * 10**9, 30 * 10**9) + __EHF = __Band(30 * 10**9, 300 * 10**9) + BANDS = (__ELF, __SLF, __ULF, __VLF, __LF, __MF, __HF, __VHF, __UHF, __SHF, __EHF) + MAX_DIGITS = 3 + RANGE_SEPARATOR = ' รท ' + GFD_SITE = "http://qrg.globaltuners.com/" + CONVERSION_FACTORS = {"Hz" : 1, + "kHz": 1000, + "MHz": 1000000, + "GHz": 1000000000} + MODES = {"FM": ("NFM", "WFM"), + "AM": (), + "CW": (), + "SK": ("FSK", "PSK", "MSK"), + "SB": ("LSB", "USB", "DSB"), + "Chirp Spread Spectrum": (), + "FHSS-TDM": (), + "RAW": (), + "SC-FDMA": (),} + APPLY = "Apply" + REMOVE = "Remove" + UNKNOWN = "N/A" + MODULATIONS = ("8VSB", + "AFSK", + "AM", + "BFSK", + "C4FM", + "CDMA", + "COFDM", + "CW", + "FFSK", + "FM", + "FMCW", + "FMOP", + "FSK", + "GFSK", + "GMSK", + "IFK", + "MFSK", + "MSK", + "OFDM", + "OOK", + "PAM", + "PPM", + "PSK", + "QAM", + "TDMA",) + LOCATIONS = (UNKNOWN, + "Australia", + "Canada", + "Central Europe", + "China", + "Cyprus", + "Eastern Europe", + "Europe", + "Europe, japan and Asia", + "Exmouth, Australia", + "Finland", + "France", + "Germany", + "Home Base Mobile , AL", + "Hungary", + "Iran", + "Israel", + "Japan", + "LaMour, North Dakota", + "Lualualei, Hawaii", + "North America", + "North Korea", + "Poland", + "Romania", + "Ruda, Sweden", + "UK", + "United Kingdom", + "United States", + "Varberg, Sweden", + "World Wide", + "Worldwide",) diff --git a/fixed_aspect_ratio_label.py b/fixed_aspect_ratio_label.py index 3b61f9b..8f13adc 100644 --- a/fixed_aspect_ratio_label.py +++ b/fixed_aspect_ratio_label.py @@ -8,14 +8,16 @@ class FixedAspectRatioLabel(QLabel): self.pixmap = None def set_default_stylesheet(self): - self.setStyleSheet(""" - color: #ffffff; - background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #304352 ,stop: 1 #d7d2cc); - """) + self.setStyleSheet("border: 3px;") + # self.setStyleSheet(""" + # color: #ffffff; + # background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #304352 ,stop: 1 #d7d2cc); + # """) def make_transparent(self): self.setText('') - self.setStyleSheet("background-color: transparent;") + self.setStyleSheet("border: 0px;") + # self.setStyleSheet("background-color: transparent;") def apply_pixmap(self): if self.pixmap: diff --git a/forecastdata.py b/forecastdata.py new file mode 100644 index 0000000..5c1a0ed --- /dev/null +++ b/forecastdata.py @@ -0,0 +1,3 @@ +class ForecastData: + def __init__(self): + pass diff --git a/space_weather_data.py b/space_weather_data.py index 4f3b764..7928ec0 100644 --- a/space_weather_data.py +++ b/space_weather_data.py @@ -1,6 +1,6 @@ from PyQt5.QtGui import QPixmap from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject -from threads import UpadteSpaceWeatherThread, ThreadStatus +from threads import UpdateSpaceWeatherThread, ThreadStatus class SpaceWeatherData(QObject): @@ -24,7 +24,7 @@ class SpaceWeatherData(QObject): QPixmap(), QPixmap() ] - self.__update_thread = UpadteSpaceWeatherThread(self) + self.__update_thread = UpdateSpaceWeatherThread(self) self.__update_thread.finished.connect(self.__parse_and_emit_signal) @property diff --git a/switchable_label.py b/switchable_label.py index 6e6e074..f853295 100644 --- a/switchable_label.py +++ b/switchable_label.py @@ -1,20 +1,32 @@ from PyQt5.QtWidgets import QLabel +from constants import ForecastColors -class SwitchableLabel(QLabel): +class _BaseSwitchableLabel(QLabel): + def __init__(self, parent=None): + super().__init__(parent) + self.is_on = False + + def switch_on(self): + self.is_on = True + + def switch_off(self): + self.is_on = False + + +class SwitchableLabel(_BaseSwitchableLabel): def __init__(self, parent=None): super().__init__(parent) self.switch_on_colors = () self.switch_off_colors = () self.text_color = '' - self.is_on = False def switch_on(self): - self.is_on = True + super().switch_on() self.__apply_colors(*self.switch_on_colors) def switch_off(self): - self.is_on = False + super().switch_off() self.__apply_colors(*self.switch_off_colors) def __apply_colors(self, start, end): @@ -26,7 +38,47 @@ class SwitchableLabel(QLabel): ) -class SwitchableLabelsIterable(object): +class SingleColorSwitchableLabel(_BaseSwitchableLabel): + def __init__(self, parent=None): + super().__init__(parent) + self.active_color = ForecastColors.WARNING_COLOR + + def switch_on(self): + super().switch_on() + self.setStyleSheet(f"background-color: {self.active_color};") + + def switch_off(self): + super().switch_off() + self.setStyleSheet("background-color: transparent;") + + +class MultiColorSwitchableLabel(_BaseSwitchableLabel): + + LEVEL_COLORS = { + 9: ForecastColors.KP9_COLOR, + 8: ForecastColors.KP8_COLOR, + 7: ForecastColors.KP7_COLOR, + 6: ForecastColors.KP6_COLOR, + 5: ForecastColors.KP5_COLOR + } + + def __init__(self, parent=None): + super().__init__(parent) + self.level = 0 + + def switch_on(self): + if 5 <= self.level <= 9: + super().switch_on() + self.setStyleSheet(f""" + background-color: {self.LEVEL_COLORS[self.level]}; + """) + + def switch_off(self): + super().switch_off() + self.setStyleSheet("background-color: transparent;") + + +class SwitchableLabelsIterable: def __init__(self, *labels): self.labels = labels diff --git a/themes.py b/themesmanager.py similarity index 95% rename from themes.py rename to themesmanager.py index 38798dc..70a979d 100644 --- a/themes.py +++ b/themesmanager.py @@ -10,7 +10,7 @@ from switchable_label import SwitchableLabelsIterable from utilities import pop_up -class ThemeConstants(object): +class ThemeConstants: FOLDER = "themes" EXTENSION = ".qss" ICONS_FOLDER = "icons" @@ -26,7 +26,7 @@ class ThemeConstants(object): THEME_NOT_FOUND = "Theme not found" MISSING_THEME = "Missing theme in '" + FOLDER + "' folder." -class Theme(object): +class ThemeManager: def __init__(self, parent): self.__parent = parent self.__parent.active_color = ThemeConstants.DEFAULT_ACTIVE_COLOR @@ -41,7 +41,7 @@ class Theme(object): ThemeConstants.ICONS_FOLDER ) - self.__forecast_labels = SwitchableLabelsIterable( + self.__space_weather_labels = SwitchableLabelsIterable( *list( chain( self.__parent.switchable_r_labels, @@ -55,11 +55,11 @@ class Theme(object): ) ) - self.__forecast_labels.set( + self.__space_weather_labels.set( "switch_on_colors", ThemeConstants.DEFAULT_ON_COLORS ) - self.__forecast_labels.set( + self.__space_weather_labels.set( "switch_off_colors", ThemeConstants.DEFAULT_OFF_COLORS ) @@ -106,7 +106,7 @@ class Theme(object): self.__parent.active_color, self.__parent.inactive_color ) - self.__forecast_labels.refresh() + self.__space_weather_labels.refresh() def __pretty_name(self, bad_name): return ' '.join( @@ -257,20 +257,20 @@ class Theme(object): inactive_color_ok = True if quality.lower() == Constants.TEXT_COLOR: text_color_ok = True - self.__forecast_labels.set( + self.__space_weather_labels.set( "text_color", color ) if color_len == 2: if quality.lower() == Constants.LABEL_ON_COLOR: switch_on_color_ok = True - self.__forecast_labels.set( + self.__space_weather_labels.set( "switch_on_colors", color ) if quality.lower() == Constants.LABEL_OFF_COLOR: switch_off_color_ok = True - self.__forecast_labels.set( + self.__space_weather_labels.set( "switch_off_colors", color ) @@ -280,17 +280,17 @@ class Theme(object): self.__parent.inactive_color = ThemeConstants.DEFAULT_INACTIVE_COLOR if not (switch_on_color_ok and switch_off_color_ok): - self.__forecast_labels.set( + self.__space_weather_labels.set( "switch_on_colors", ThemeConstants.DEFAULT_ON_COLORS ) - self.__forecast_labels.set( + self.__space_weather_labels.set( "switch_off_colors", ThemeConstants.DEFAULT_OFF_COLORS ) if not text_color_ok: - self.__forecast_labels.set( + self.__space_weather_labels.set( "text_color", ThemeConstants.DEFAULT_TEXT_COLOR ) @@ -305,7 +305,7 @@ class Theme(object): except Exception: pass - def initialize(self): + def start(self): current_theme_file = os.path.join( ThemeConstants.FOLDER, ThemeConstants.CURRENT diff --git a/threads.py b/threads.py index f85e830..13d49a0 100644 --- a/threads.py +++ b/threads.py @@ -66,7 +66,7 @@ class DownloadThread(_BaseDownloadThread): self.status = ThreadStatus.OK -class UpadteSpaceWeatherThread(_BaseDownloadThread): +class UpdateSpaceWeatherThread(_BaseDownloadThread): __properties = ("xray", "prot_el", "ak_index", "sgas", "geo_storm") @@ -79,12 +79,12 @@ class UpadteSpaceWeatherThread(_BaseDownloadThread): return await resp.read() async def __download_property(self, session, property_name): - link = getattr(Constants, "FORECAST_" + property_name.upper()) + link = getattr(Constants, "SPACE_WEATHER_" + property_name.upper()) data = await self.__download_resource(session, link) setattr(self.__space_weather_data, property_name, str(data, 'utf-8')) async def __download_image(self, session, n): - im = await self.__download_resource(session, Constants.FORECAST_IMGS[n]) + im = await self.__download_resource(session, Constants.SPACE_WEATHER_IMGS[n]) self.__space_weather_data.images[n].loadFromData(im) async def __download_resources(self, *links): @@ -96,7 +96,7 @@ class UpadteSpaceWeatherThread(_BaseDownloadThread): asyncio.create_task(self.__download_property(session, p)) ) - tot_images = range(len(Constants.FORECAST_IMGS)) + tot_images = range(len(Constants.SPACE_WEATHER_IMGS)) t1 = [] for im_number in tot_images: t1.append( From 36f941131c6c9045abb1b3dbc7ad5751a6e7f1cb Mon Sep 17 00:00:00 2001 From: alessandro90 Date: Sun, 5 May 2019 11:45:53 +0200 Subject: [PATCH 2/6] Fix details in fixed aspect ratio labels. --- artemis.py | 18 +- artemis.ui | 512 +++++++++++++++++++---------------- constants.py | 18 -- fixed_aspect_ratio_label.py | 12 +- fixed_aspect_ratio_widget.py | 8 +- threads.py | 1 - 6 files changed, 306 insertions(+), 263 deletions(-) diff --git a/artemis.py b/artemis.py index 012d820..3ffe1c1 100644 --- a/artemis.py +++ b/artemis.py @@ -32,8 +32,7 @@ from constants import (Constants, Database, ChecksumWhat, Messages, - Signal, - Months) + Signal,) from themesmanager import ThemeManager from utilities import (checksum_ok, uncheck_and_emit, @@ -157,6 +156,17 @@ class Artemis(QMainWindow, Ui_MainWindow): lab.set_default_stylesheet() self.space_weather_label_container.labels = self.space_weather_labels + self.space_weather_label_name_container.labels = [ + self.eme_lbl, + self.ms_lbl, + self.muf_lbl, + self.hi_lbl, + self.eu50_lbl, + self.eu70_lbl, + self.eu144_lbl, + self.na_lbl, + self.aurora_lbl + ] self.theme_manager = ThemeManager(self) # Manage frequency filters. @@ -455,7 +465,7 @@ class Artemis(QMainWindow, Ui_MainWindow): ) self.apply_remove_acf_filter_btn.clicked.connect(self.display_signals) self.reset_acf_filters_btn.clicked.connect(self.reset_acf_filters) - self.acf_info_btn.clicked.connect(lambda : webbrowser.open(Constants.ACF_DOCS)) + self.acf_info_btn.clicked.connect(lambda: webbrowser.open(Constants.ACF_DOCS)) connect_events_to_func( events_to_connect=[self.acf_spinbox.valueChanged, @@ -561,7 +571,7 @@ class Artemis(QMainWindow, Ui_MainWindow): self.update_now_bar.set_idle() if status_ok: xray_long = float(self.space_weather_data.xray[-1][7]) - format_text = lambda letter, power : letter + f"{xray_long * 10**power:.1f}" + format_text = lambda letter, power: letter + f"{xray_long * 10**power:.1f}" if xray_long < 1e-8 and xray_long != -1.00e+05: self.peak_flux_lbl.setText(format_text("= 1e-8 and xray_long < 1e-7: diff --git a/artemis.ui b/artemis.ui index 5524ce9..cd446a5 100644 --- a/artemis.ui +++ b/artemis.ui @@ -6,8 +6,8 @@ 0 0 - 1387 - 761 + 1458 + 795
@@ -17,7 +17,7 @@ - ARTEMIS3 + ARTฮฃMIS 3.0 @@ -6150,239 +6150,281 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto 0 - - - 9 - - - 0 - - - + + + 0 0 - - - 13 - false - + + Qt::LeftToRight - - E.M.E.โ†’ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Qt::LeftToRight + + + E.M.E.โ†’ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Qt::LeftToRight + + + Meteor Scatterโ†’ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Qt::LeftToRight + + + M.U.F.โ†’ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Qt::LeftToRight + + + Hystorical Indexโ†’ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Qt::LeftToRight + + + QFrame::NoFrame + + + 50 MHz E-skip in EUโ†’ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Qt::LeftToRight + + + 70 MHz E-skip in EUโ†’ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Qt::LeftToRight + + + 144 MHz E-skip in EUโ†’ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Qt::LeftToRight + + + 144 MHz E-skip in NAโ†’ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + + + + + 0 + 0 + + + + + 13 + false + + + + Qt::LeftToRight + + + VHF Auroraโ†’ + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + 15 + + + + - - - - - 0 - 0 - - - - - 13 - false - - - - 50 MHz E-skip in EUโ†’ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 15 - - - - - - - - 0 - 0 - - - - - 13 - false - - - - VHF Auroraโ†’ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 15 - - - - - - - - 0 - 0 - - - - - 13 - false - - - - Hystorical Indexโ†’ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 15 - - - - - - - - 0 - 0 - - - - - 13 - false - - - - 144 MHz E-skip in EUโ†’ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 15 - - - - - - - - 0 - 0 - - - - - 13 - false - - - - M.U.F.โ†’ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 15 - - - - - - - - 0 - 0 - - - - - 13 - false - - - - Meteor Scatterโ†’ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 15 - - - - - - - - 0 - 0 - - - - - 13 - false - - - - 144 MHz E-skip in NAโ†’ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 15 - - - - - - - - 0 - 0 - - - - - 13 - false - - - - 70 MHz E-skip in EUโ†’ - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - 15 - - - - + @@ -6834,7 +6876,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto 1 - -1 + 0 Qt::AlignCenter @@ -6842,6 +6884,9 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto true + + false + %p% @@ -7708,14 +7753,23 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto 0 + + + 75 + true + + 1 0 + + Qt::AlignCenter + - false + true @@ -8175,7 +8229,7 @@ QSlider::handle:horizontal { 0 0 - 1387 + 1458 21 diff --git a/constants.py b/constants.py index 0870dd3..a4aab83 100644 --- a/constants.py +++ b/constants.py @@ -82,24 +82,6 @@ class ForecastColors: KP5_COLOR = "#BEE3FE" -class Months: - MONTS = [ - "0", - "Jan", - "Feb", - "Mar", - "Apr", - "May", - "Jun", - "Jul", - "Aug", - "Sep", - "Oct", - "Nov", - "Dec" - ] - - class Constants: CLICK_TO_UPDATE_STR = "Click to update" SIGIDWIKI = "https://www.sigidwiki.com/wiki/Signal_Identification_Guide" diff --git a/fixed_aspect_ratio_label.py b/fixed_aspect_ratio_label.py index 8f13adc..a8a5d18 100644 --- a/fixed_aspect_ratio_label.py +++ b/fixed_aspect_ratio_label.py @@ -8,16 +8,14 @@ class FixedAspectRatioLabel(QLabel): self.pixmap = None def set_default_stylesheet(self): - self.setStyleSheet("border: 3px;") - # self.setStyleSheet(""" - # color: #ffffff; - # background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #304352 ,stop: 1 #d7d2cc); - # """) + self.setStyleSheet("""border-width: 1px; + border-style: solid; + border-color: black;""" + ) def make_transparent(self): self.setText('') - self.setStyleSheet("border: 0px;") - # self.setStyleSheet("background-color: transparent;") + self.setStyleSheet("border-width: 0px;") def apply_pixmap(self): if self.pixmap: diff --git a/fixed_aspect_ratio_widget.py b/fixed_aspect_ratio_widget.py index bcf381e..297166f 100644 --- a/fixed_aspect_ratio_widget.py +++ b/fixed_aspect_ratio_widget.py @@ -12,10 +12,10 @@ class FixedAspectRatioWidget(QWidget): h, w = self.height(), self.width() h_lbl = h / 9 - self.space w_lbl = 5 * h_lbl - - if w_lbl > w: - w_lbl = w - h_lbl = h / 9 - self.space + w_pad = w - 10 + if w_lbl > w_pad: + w_lbl = w_pad + h_lbl = w_pad / 5 for label in self.labels: label.rescale(QSize(w_lbl, h_lbl)) diff --git a/threads.py b/threads.py index 13d49a0..17c1027 100644 --- a/threads.py +++ b/threads.py @@ -27,7 +27,6 @@ class _BaseDownloadThread(QThread): def __del__(self): self.terminate() self.wait() - super().__del__() class DownloadThread(_BaseDownloadThread): From faf891ee7c301958e4c3382de737f53923771a5d Mon Sep 17 00:00:00 2001 From: alessandro90 Date: Mon, 6 May 2019 21:50:09 +0200 Subject: [PATCH 3/6] Fix reset of location and modulation filters when search bar is not empty --- artemis.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/artemis.py b/artemis.py index 3ffe1c1..b7bb2fb 100644 --- a/artemis.py +++ b/artemis.py @@ -1113,6 +1113,10 @@ class Artemis(QMainWindow, Ui_MainWindow): def reset_modulation_filters(self): uncheck_and_emit(self.apply_remove_modulation_filter_btn) self.search_bar_modulation.setText('') + self.show_matching_strings( + self.modulation_list, + self.search_bar_modulation.text() + ) for i in range(self.modulation_list.count()): if self.modulation_list.item(i).isSelected(): self.modulation_list.item(i).setSelected(False) @@ -1121,6 +1125,10 @@ class Artemis(QMainWindow, Ui_MainWindow): def reset_location_filters(self): uncheck_and_emit(self.apply_remove_location_filter_btn) self.search_bar_location.setText('') + self.show_matching_strings( + self.locations_list, + self.search_bar_location.text() + ) for i in range(self.locations_list.count()): if self.locations_list.item(i).isSelected(): self.locations_list.item(i).setSelected(False) From 3d571844b8f826daf2688e5a6059bd7f6885d0b2 Mon Sep 17 00:00:00 2001 From: alessandro90 Date: Sun, 12 May 2019 11:56:11 +0200 Subject: [PATCH 4/6] Add logic to the forecast screen --- .gitignore | 1 + artemis.py | 43 +- artemis.ui | 1808 +++++++++++++++++++++++++---------------- constants.py | 1 + forecastdata.py | 3 - space_weather_data.py | 74 -- switchable_label.py | 24 +- threads.py | 73 +- weatherdata.py | 314 +++++++ 9 files changed, 1538 insertions(+), 803 deletions(-) delete mode 100644 forecastdata.py delete mode 100644 space_weather_data.py create mode 100644 weatherdata.py diff --git a/.gitignore b/.gitignore index 4a63335..4d08bb8 100644 --- a/.gitignore +++ b/.gitignore @@ -7,5 +7,6 @@ csv_info.txt pyinstaller_cmd.txt themes/.current_theme launch.bat +designer.bat *.sh .vscode/ diff --git a/artemis.py b/artemis.py index b7bb2fb..ee2c3cc 100644 --- a/artemis.py +++ b/artemis.py @@ -22,8 +22,7 @@ from PyQt5.QtCore import (QFileInfo, pyqtSlot,) from audio_player import AudioPlayer -from space_weather_data import SpaceWeatherData -from forecastdata import ForecastData +from weatherdata import SpaceWeatherData, ForecastData from download_window import DownloadWindow from switchable_label import SwitchableLabelsIterable from constants import (Constants, @@ -525,30 +524,10 @@ class Artemis(QMainWindow, Ui_MainWindow): self.forecast_info_btn.clicked.connect( lambda: webbrowser.open(Constants.SPACE_WEATHER_INFO) ) + self.forecast_data = ForecastData(self) self.update_forecast_bar.clicked.connect(self.start_update_forecast) self.update_forecast_bar.set_idle() - self.forecast_data = ForecastData() - self.today_forecast_labels = [] - self.today_p1_forecast_labels = [] - self.today_p2_forecast_labels = [] - self.all_forecast_labels = [] - flags = ['', 'p1_', 'p2_'] - for flag in flags: - title_lbl = getattr(self, "today_" + flag + "lbl") - title_lbl.setText("-") - for index in range(20): - label = getattr( - self, - "forecast_today_" + flag + str(index) + "_lbl" - ) - label.setText(Constants.UNKNOWN) - self.all_forecast_labels.append(label) - if flag == flags[0]: - self.today_forecast_labels.append(label) - if flag == flags[1]: - self.today_p1_forecast_labels.append(label) - if flag == flags[2]: - self.today_p2_forecast_labels.append(label) + self.forecast_data.update_complete.connect(self.update_forecast) # Final operations. @@ -558,7 +537,9 @@ class Artemis(QMainWindow, Ui_MainWindow): @pyqtSlot() def start_update_forecast(self): - pass + if not self.forecast_data.is_updating: + self.update_forecast_bar.set_updating() + self.forecast_data.update() @pyqtSlot() def start_update_space_weather(self): @@ -566,6 +547,16 @@ class Artemis(QMainWindow, Ui_MainWindow): self.update_now_bar.set_updating() self.space_weather_data.update() + @pyqtSlot(bool) + def update_forecast(self, status_ok): + self.update_forecast_bar.set_idle() + if status_ok: + self.forecast_data.update_all_labels() + elif not self.closing: + pop_up(self, title=Messages.BAD_DOWNLOAD, + text=Messages.BAD_DOWNLOAD_MSG).show() + self.forecast_data.remove_data() + @pyqtSlot(bool) def update_space_weather(self, status_ok): self.update_now_bar.set_idle() @@ -1421,6 +1412,8 @@ class Artemis(QMainWindow, Ui_MainWindow): self.download_window.close() if self.space_weather_data.is_updating: self.space_weather_data.shutdown_thread() + if self.forecast_data.is_updating: + self.forecast_data.shutdown_thread() super().closeEvent(event) diff --git a/artemis.ui b/artemis.ui index cd446a5..138febd 100644 --- a/artemis.ui +++ b/artemis.ui @@ -178,7 +178,7 @@ QTabWidget::Rounded - 3 + 0 true @@ -197,7 +197,7 @@ - Main + Signal @@ -4683,7 +4683,7 @@ www.qrg.globaltuners.com - 1 + 0 @@ -4781,8 +4781,7 @@ www.qrg.globaltuners.com - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + R0 @@ -4802,8 +4801,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + R1 @@ -4823,8 +4821,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + R2 @@ -4844,8 +4841,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + R3 @@ -4865,8 +4861,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + R4 @@ -4886,8 +4881,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + R5 @@ -4968,8 +4962,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + S0 @@ -4989,8 +4982,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + S1 @@ -5010,8 +5002,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + S2 @@ -5031,8 +5022,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + S3 @@ -5052,8 +5042,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + S4 @@ -5073,8 +5062,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + S5 @@ -5803,8 +5791,7 @@ STORM - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G0 @@ -5824,8 +5811,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G1 @@ -5845,8 +5831,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G2 @@ -5866,8 +5851,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G3 @@ -5887,8 +5871,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G4 @@ -5908,8 +5891,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G5 @@ -5944,8 +5926,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G0 @@ -5965,8 +5946,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G1 @@ -5986,8 +5966,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G2 @@ -6007,8 +5986,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G3 @@ -6028,8 +6006,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G4 @@ -6049,8 +6026,7 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - color:#ffffff; -background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,stop: 1 #859398); + G5 @@ -6904,38 +6880,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto Forecast - - - - TextLabel + + + + + 75 + true + - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - TextLabel @@ -6946,6 +6898,11 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto + + + 9 + + 21 - 00 @@ -6954,108 +6911,78 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + - - TextLabel + + + 75 + true + - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - 18 - 21 - - - 25 - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - 15 - 18 - - - 25 - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - 12 - 15 - - - 25 - - - - - TextLabel @@ -7066,86 +6993,12 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - TextLabel + + + 75 + true + - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - TextLabel @@ -7156,6 +7009,11 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto + + + 9 + + 03 - 06 @@ -7164,6 +7022,259 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 9 + + + + 09 - 12 + + + 25 + + + + + + + + 9 + false + + + + Major + + + 50 + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 9 + + + + 06 - 09 + + + 25 + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 9 + + + + 15 - 18 + + + 25 + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + @@ -7178,8 +7289,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + + + + 75 + true + + TextLabel @@ -7190,6 +7307,12 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto + + + 75 + true + + TextLabel @@ -7200,6 +7323,12 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto + + + 75 + true + + TextLabel @@ -7208,8 +7337,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + + + + 75 + true + + TextLabel @@ -7218,8 +7353,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + + + + 75 + true + + TextLabel @@ -7228,10 +7369,31 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + + + + 75 + true + + - 09 - 12 + TextLabel + + + Qt::AlignCenter + + + + + + + + 9 + + + + 12 - 15 25 @@ -7240,6 +7402,11 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto + + + 9 + + 00 - 03 @@ -7248,18 +7415,29 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + + + + 9 + + - 06 - 09 + 18 - 21 25 - - + + + + + 75 + true + + TextLabel @@ -7268,68 +7446,110 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + + + + 75 + true + + - Major + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 9 + false + + + + Minor 50 - - - - TextLabel + + + + + 75 + true + - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - TextLabel @@ -7340,6 +7560,12 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto + + + 75 + true + + TextLabel @@ -7352,7 +7578,8 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - 10 + 9 + false @@ -7363,197 +7590,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - - - TextLabel - - - Qt::AlignCenter - - - - - - - Major - - - 50 - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - Minor - - - 50 - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - Active - - - 50 - - - - - - - Active - - - 50 - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - Minor - - - 50 - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - - 10 - - - - Mid Lat. - - - 25 - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - 11 75 true - - Geomagnetic Act. - - - - - TextLabel @@ -7577,6 +7621,11 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto + + + 9 + + R1 - R2 @@ -7585,8 +7634,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + + + + 75 + true + + TextLabel @@ -7597,6 +7652,43 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 9 + + + + > R3 + + + 25 + + + + + + + + 75 + true + + TextLabel @@ -7619,8 +7711,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + + + + 75 + true + + TextLabel @@ -7629,7 +7727,356 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 11 + 75 + true + + + + Geomagnetic Act. + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 9 + false + + + + Minor + + + 50 + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 9 + false + + + + Mid Lat. + + + 25 + + + + + + + + 9 + false + + + + Major + + + 50 + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 9 + false + + + + Active + + + 50 + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 9 + false + + + + Active + + + 50 + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + + + + + 9 + + + + Proton flare + + + 25 + + + + + + + + 11 + 75 + true + + + + Solar Radiation Storm + + + + + + + + 0 + 0 + + + + + 11 + 75 + true + + + + today + + + Qt::AlignCenter + + + + + + + + 11 + 75 + true + + + + Event Probabilities + + + + @@ -7642,16 +8089,67 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - - - - 0 - 0 - + + + + + 75 + true + - - Qt::Horizontal + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter @@ -7701,22 +8199,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + - 11 75 true - - Solar Radiation Storm - - - - - TextLabel @@ -7725,18 +8215,42 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + + + + 0 + 0 + + + + Qt::Horizontal + + + + + + + + 9 + + - S1 or Greater + Class M flare 25 - - + + + + + 75 + true + + TextLabel @@ -7745,7 +8259,52 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 75 + true + + + + TextLabel + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + + @@ -7773,31 +8332,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - - - - 0 - 0 - - + + - 11 75 true - - today - - - Qt::AlignCenter - - - - - TextLabel @@ -7806,75 +8348,28 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - - - TextLabel - - - Qt::AlignCenter - - - - - + + - 11 - 75 - true + 9 - Event Probabilities - - - - - - - Class M flare + S1 or Greater 25 - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - + + + 9 + + Class X flare @@ -7883,48 +8378,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - - - Proton flare - - - 25 - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - - - - - TextLabel - - - Qt::AlignCenter - - - + + + 75 + true + + TextLabel @@ -7933,8 +8394,14 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - + + + + + 75 + true + + TextLabel @@ -7943,29 +8410,6 @@ background-color: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,stop:0 #283048 ,sto - - - - > R3 - - - 25 - - - - - - - - 0 - 0 - - - - Qt::Horizontal - - - diff --git a/constants.py b/constants.py index a4aab83..c8058a7 100644 --- a/constants.py +++ b/constants.py @@ -91,6 +91,7 @@ class Constants: RTL_SDL_LINK = "https://www.rtl-sdr.com/" UPDATING_STR = "Updating..." ACF_DOCS = "https://aresvalley.com/documentation/" + FORECAST_PROBABILITIES = "https://services.swpc.noaa.gov/text/sgarf.txt" SPACE_WEATHER_XRAY = "https://services.swpc.noaa.gov/text/goes-xray-flux-primary.txt" SPACE_WEATHER_PROT_EL = "https://services.swpc.noaa.gov/text/goes-particle-flux-primary.txt" SPACE_WEATHER_AK_INDEX = "https://services.swpc.noaa.gov/text/wwv.txt" diff --git a/forecastdata.py b/forecastdata.py deleted file mode 100644 index 5c1a0ed..0000000 --- a/forecastdata.py +++ /dev/null @@ -1,3 +0,0 @@ -class ForecastData: - def __init__(self): - pass diff --git a/space_weather_data.py b/space_weather_data.py deleted file mode 100644 index 7928ec0..0000000 --- a/space_weather_data.py +++ /dev/null @@ -1,74 +0,0 @@ -from PyQt5.QtGui import QPixmap -from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject -from threads import UpdateSpaceWeatherThread, ThreadStatus - - -class SpaceWeatherData(QObject): - update_complete = pyqtSignal(bool) - - def __init__(self): - super().__init__() - self.xray = '' - self.prot_el = '' - self.ak_index = '' - self.sgas = '' - self.geo_storm = '' - self.images = [ - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap() - ] - self.__update_thread = UpdateSpaceWeatherThread(self) - self.__update_thread.finished.connect(self.__parse_and_emit_signal) - - @property - def is_updating(self): - return self.__update_thread.isRunning() - - @pyqtSlot() - def update(self): - self.__update_thread.start() - - def __parse_data(self): - double_split = lambda string: [i.split() for i in string.splitlines()] - self.xray = double_split(self.xray) - self.prot_el = double_split(self.prot_el) - self.ak_index = double_split(self.ak_index) - self.sgas = double_split(self.sgas) - self.geo_storm = double_split(self.geo_storm) - - def remove_data(self): - self.xray = '' - self.prot_el = '' - self.ak_index = '' - self.sgas = '' - self.geo_storm = '' - self.images = [ - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap(), - QPixmap() - ] - - @pyqtSlot() - def __parse_and_emit_signal(self): - status_ok = False - if self.__update_thread.status is ThreadStatus.OK: - status_ok = True - self.__parse_data() - self.update_complete.emit(status_ok) - - def shutdown_thread(self): - self.__update_thread.terminate() - self.__update_thread.wait() diff --git a/switchable_label.py b/switchable_label.py index f853295..69773d0 100644 --- a/switchable_label.py +++ b/switchable_label.py @@ -6,6 +6,7 @@ class _BaseSwitchableLabel(QLabel): def __init__(self, parent=None): super().__init__(parent) self.is_on = False + self.level = 0 def switch_on(self): self.is_on = True @@ -44,12 +45,17 @@ class SingleColorSwitchableLabel(_BaseSwitchableLabel): self.active_color = ForecastColors.WARNING_COLOR def switch_on(self): - super().switch_on() - self.setStyleSheet(f"background-color: {self.active_color};") + if self.level >= 30: + super().switch_on() + self.setStyleSheet(f"color: {self.active_color}" + # f"""background-color: {self.active_color}; + # color: #000000;""" + ) def switch_off(self): super().switch_off() - self.setStyleSheet("background-color: transparent;") + # self.setStyleSheet("""background-color: transparent;""") + self.setStyleSheet("") class MultiColorSwitchableLabel(_BaseSwitchableLabel): @@ -64,18 +70,20 @@ class MultiColorSwitchableLabel(_BaseSwitchableLabel): def __init__(self, parent=None): super().__init__(parent) - self.level = 0 def switch_on(self): if 5 <= self.level <= 9: super().switch_on() - self.setStyleSheet(f""" - background-color: {self.LEVEL_COLORS[self.level]}; - """) + self.setStyleSheet(f"color: {self.LEVEL_COLORS[self.level]}" + # f"""background-color: {self.LEVEL_COLORS[self.level]}; + # color: #000000; + # """ + ) def switch_off(self): super().switch_off() - self.setStyleSheet("background-color: transparent;") + # self.setStyleSheet("background-color: transparent;") + self.setStyleSheet("") class SwitchableLabelsIterable: diff --git a/threads.py b/threads.py index 17c1027..fc928f3 100644 --- a/threads.py +++ b/threads.py @@ -19,7 +19,7 @@ class ThreadStatus(Enum): UNDEFINED = auto() -class _BaseDownloadThread(QThread): +class BaseDownloadThread(QThread): def __init__(self, parent=None): super().__init__(parent) self.status = ThreadStatus.UNDEFINED @@ -29,7 +29,7 @@ class _BaseDownloadThread(QThread): self.wait() -class DownloadThread(_BaseDownloadThread): +class DownloadThread(BaseDownloadThread): def __init__(self): super().__init__() self.reason = 0 @@ -65,7 +65,13 @@ class DownloadThread(_BaseDownloadThread): self.status = ThreadStatus.OK -class UpdateSpaceWeatherThread(_BaseDownloadThread): +class _AsyncDownloader: + async def _download_resource(self, session, link): + resp = await session.get(link) + return await resp.read() + + +class UpdateSpaceWeatherThread(BaseDownloadThread, _AsyncDownloader): __properties = ("xray", "prot_el", "ak_index", "sgas", "geo_storm") @@ -73,20 +79,16 @@ class UpdateSpaceWeatherThread(_BaseDownloadThread): super().__init__() self.__space_weather_data = space_weather_data - async def __download_resource(self, session, link): - resp = await session.get(link) - return await resp.read() - async def __download_property(self, session, property_name): link = getattr(Constants, "SPACE_WEATHER_" + property_name.upper()) - data = await self.__download_resource(session, link) + data = await self._download_resource(session, link) setattr(self.__space_weather_data, property_name, str(data, 'utf-8')) async def __download_image(self, session, n): - im = await self.__download_resource(session, Constants.SPACE_WEATHER_IMGS[n]) + im = await self._download_resource(session, Constants.SPACE_WEATHER_IMGS[n]) self.__space_weather_data.images[n].loadFromData(im) - async def __download_resources(self, *links): + async def _download_resources(self): session = aiohttp.ClientSession() try: t = [] @@ -111,4 +113,53 @@ class UpdateSpaceWeatherThread(_BaseDownloadThread): def run(self): self.status = ThreadStatus.UNDEFINED - asyncio.run(self.__download_resources()) + asyncio.run(self._download_resources()) + + +class UpdateForecastThread(BaseDownloadThread, _AsyncDownloader): + + class _PropertyName(Enum): + FORECAST = auto() + PROBABILITIES = auto() + + def __init__(self, parent): + super().__init__() + self.parent = parent + + async def __download_property(self, session, link, prop_name): + resp = await self._download_resource(session, link) + resp = str(resp, 'utf-8') + if prop_name is self._PropertyName.FORECAST: + self.parent.forecast = resp + if prop_name is self._PropertyName.PROBABILITIES: + self.parent.probabilities = resp + + async def _download_resources(self): + session = aiohttp.ClientSession() + try: + await asyncio.gather( + asyncio.create_task( + self.__download_property( + session, + Constants.SPACE_WEATHER_GEO_STORM, + self._PropertyName.FORECAST + ) + ), + asyncio.create_task( + self.__download_property( + session, + Constants.FORECAST_PROBABILITIES, + self._PropertyName.PROBABILITIES + ) + ) + ) + except Exception: + self.status = ThreadStatus.UNKNOWN_ERR + else: + self.status = ThreadStatus.OK + finally: + await session.close() + + def run(self): + self.status = ThreadStatus.UNDEFINED + asyncio.run(self._download_resources()) diff --git a/weatherdata.py b/weatherdata.py new file mode 100644 index 0000000..90d6d35 --- /dev/null +++ b/weatherdata.py @@ -0,0 +1,314 @@ +import re +from PyQt5.QtGui import QPixmap +from PyQt5.QtCore import pyqtSlot, pyqtSignal, QObject +from threads import (BaseDownloadThread, + UpdateSpaceWeatherThread, + ThreadStatus, + UpdateForecastThread) +from constants import Constants +from switchable_label import MultiColorSwitchableLabel + + +class _BaseWeatherData(QObject): + update_complete = pyqtSignal(bool) + + def __init__(self): + super().__init__() + self._update_thread = BaseDownloadThread() + + @property + def is_updating(self): + return self._update_thread.isRunning() + + def update(self): + self._update_thread.start() + + def _parse_data(self): + pass + + @pyqtSlot() + def _parse_and_emit_signal(self): + status_ok = False + if self._update_thread.status is ThreadStatus.OK: + status_ok = True + self._parse_data() + self.update_complete.emit(status_ok) + + def _double_split(self, string): + return [i.split() for i in string.splitlines()] + + def shutdown_thread(self): + self._update_thread.terminate() + self._update_thread.wait() + + +class SpaceWeatherData(_BaseWeatherData): + def __init__(self): + super().__init__() + self.xray = '' + self.prot_el = '' + self.ak_index = '' + self.sgas = '' + self.geo_storm = '' + self.images = [ + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap() + ] + self._update_thread = UpdateSpaceWeatherThread(self) + self._update_thread.finished.connect(self._parse_and_emit_signal) + + def _parse_data(self): + self.xray = self._double_split(self.xray) + self.prot_el = self._double_split(self.prot_el) + self.ak_index = self._double_split(self.ak_index) + self.sgas = self._double_split(self.sgas) + self.geo_storm = self._double_split(self.geo_storm) + + def remove_data(self): + self.xray = '' + self.prot_el = '' + self.ak_index = '' + self.sgas = '' + self.geo_storm = '' + self.images = [ + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap(), + QPixmap() + ] + + +class ForecastData(_BaseWeatherData): + + ROW_KEYWORDS = { + "solar_row": "S1 or greater", + "event_row": "III. Event probabilities", + "rb_now_row": "R1-R2", + "ga_now_row": "Geomagnetic Activity Probabilities", + "kp_index_row": "NOAA Kp index breakdown" + } + + def __init__(self, parent): + super().__init__() + self.forecast = '' + self.probabilities = '' + self.labels_table = [] + self.solar_row = None + self.event_row = None + self.rb_now_row = None + self.ga_now_row = None + self.kp_index_row = None + self._update_thread = UpdateForecastThread(self) + self._update_thread.finished.connect(self._parse_and_emit_signal) + self.today_lbl = parent.today_lbl + self.today_p1_lbl = parent.today_p1_lbl + self.today_p2_lbl = parent.today_p2_lbl + self.__today_lbls = [] + self.__today_p1_lbls = [] + self.__today_p2_lbls = [] + self.__all_lbls = [] + flags = ['', 'p1_', 'p2_'] + for flag in flags: + title_lbl = getattr(self, "today_" + flag + "lbl") + title_lbl.setText("-") + for index in range(20): + label = getattr( + parent, + "forecast_today_" + flag + str(index) + "_lbl" + ) + label.setText(Constants.UNKNOWN) + if flag == flags[0]: + self.__today_lbls.append(label) + if flag == flags[1]: + self.__today_p1_lbls.append(label) + if flag == flags[2]: + self.__today_p2_lbls.append(label) + + self.__all_lbls = [ + self.__today_lbls, + self.__today_p1_lbls, + self.__today_p2_lbls + ] + + def _parse_data(self): + self.forecast = self.forecast.splitlines() + # Remove possible '(G\d)' from the kp_index table + self.probabilities = re.sub('(G\d)', lambda obj: '', self.probabilities) + self.probabilities = self.probabilities.splitlines() + + def __split_lists(self): + self.forecast = [i.split() for i in self.forecast] + self.probabilities = [i.split() for i in self.probabilities] + + def __find_row_with(self, data, text): + for i, row in enumerate(data): + if text in row: + return i + return None + + def __get_rows(self): + self.solar_row = self.__find_row_with( + self.forecast, + self.ROW_KEYWORDS["solar_row"] + ) + self.event_row = self.__find_row_with( + self.probabilities, + self.ROW_KEYWORDS["event_row"] + ) + self.rb_now_row = self.__find_row_with( + self.forecast, + self.ROW_KEYWORDS["rb_now_row"] + ) + self.ga_now_row = self.__find_row_with( + self.probabilities, + self.ROW_KEYWORDS["ga_now_row"] + ) + self.kp_index_row = self.__find_row_with( + self.forecast, + self.ROW_KEYWORDS["kp_index_row"] + ) + + is_none = lambda x: x is None + if any([ + is_none(self.solar_row), + is_none(self.event_row), + is_none(self.rb_now_row), + is_none(self.ga_now_row), + is_none(self.kp_index_row) + ]): + raise Exception + + def __set_dates(self): + month = self.forecast[self.solar_row - 1][0] + today = self.forecast[self.solar_row - 1][1] + today_p1 = self.forecast[self.solar_row - 1][3] + today_p2 = self.forecast[self.solar_row - 1][5] + self.today_lbl.setText(month + ' ' + today) + self.today_p1_lbl.setText(month + ' ' + today_p1) + self.today_p2_lbl.setText(month + ' ' + today_p2) + + def __make_labels_table(self): + get_first_split = lambda x: x.split("/")[0] + get_second_split = lambda x: x.split("/")[1] + get_third_split = lambda x: x.split("/")[2] + self.labels_table = [ + [ + [self.forecast, self.solar_row, 3, None], + [self.probabilities, self.event_row + 1, 2, get_first_split], + [self.probabilities, self.event_row + 2, 2, get_first_split], + [self.probabilities, self.event_row + 3, 1, get_first_split], + [self.forecast, self.rb_now_row, 1, None], + [self.forecast, self.rb_now_row + 1, 3, None], + [self.probabilities, self.ga_now_row + 2, 1, get_first_split], + [self.probabilities, self.ga_now_row + 3, 2, get_first_split], + [self.probabilities, self.ga_now_row + 4, 2, get_first_split], + [self.probabilities, self.ga_now_row + 6, 1, get_first_split], + [self.probabilities, self.ga_now_row + 7, 2, get_first_split], + [self.probabilities, self.ga_now_row + 8, 2, get_first_split], + [self.forecast, self.kp_index_row + 3, 1, None], + [self.forecast, self.kp_index_row + 4, 1, None], + [self.forecast, self.kp_index_row + 5, 1, None], + [self.forecast, self.kp_index_row + 6, 1, None], + [self.forecast, self.kp_index_row + 7, 1, None], + [self.forecast, self.kp_index_row + 8, 1, None], + [self.forecast, self.kp_index_row + 9, 1, None], + [self.forecast, self.kp_index_row + 10, 1, None] + ], + [ + [self.forecast, self.solar_row, 4, None], + [self.probabilities, self.event_row + 1, 2, get_second_split], + [self.probabilities, self.event_row + 2, 2, get_second_split], + [self.probabilities, self.event_row + 3, 1, get_second_split], + [self.forecast, self.rb_now_row, 2, None], + [self.forecast, self.rb_now_row + 1, 4, None], + [self.probabilities, self.ga_now_row + 2, 1, get_second_split], + [self.probabilities, self.ga_now_row + 3, 2, get_second_split], + [self.probabilities, self.ga_now_row + 4, 2, get_second_split], + [self.probabilities, self.ga_now_row + 6, 1, get_second_split], + [self.probabilities, self.ga_now_row + 7, 2, get_second_split], + [self.probabilities, self.ga_now_row + 8, 2, get_second_split], + [self.forecast, self.kp_index_row + 3, 2, None], + [self.forecast, self.kp_index_row + 4, 2, None], + [self.forecast, self.kp_index_row + 5, 2, None], + [self.forecast, self.kp_index_row + 6, 2, None], + [self.forecast, self.kp_index_row + 7, 2, None], + [self.forecast, self.kp_index_row + 8, 2, None], + [self.forecast, self.kp_index_row + 9, 2, None], + [self.forecast, self.kp_index_row + 10, 2, None] + ], + [ + [self.forecast, self.solar_row, 5, None], + [self.probabilities, self.event_row + 1, 2, get_third_split], + [self.probabilities, self.event_row + 2, 2, get_third_split], + [self.probabilities, self.event_row + 3, 1, get_third_split], + [self.forecast, self.rb_now_row, 3, None], + [self.forecast, self.rb_now_row + 1, 5, None], + [self.probabilities, self.ga_now_row + 2, 1, get_third_split], + [self.probabilities, self.ga_now_row + 3, 2, get_third_split], + [self.probabilities, self.ga_now_row + 4, 2, get_third_split], + [self.probabilities, self.ga_now_row + 6, 1, get_third_split], + [self.probabilities, self.ga_now_row + 7, 2, get_third_split], + [self.probabilities, self.ga_now_row + 8, 2, get_third_split], + [self.forecast, self.kp_index_row + 3, 3, None], + [self.forecast, self.kp_index_row + 4, 3, None], + [self.forecast, self.kp_index_row + 5, 3, None], + [self.forecast, self.kp_index_row + 6, 3, None], + [self.forecast, self.kp_index_row + 7, 3, None], + [self.forecast, self.kp_index_row + 8, 3, None], + [self.forecast, self.kp_index_row + 9, 3, None], + [self.forecast, self.kp_index_row + 10, 3, None] + ] + ] + + def __get_lbl_value(self, data, row, col, f = None): + val = data[row][col] + if f is not None: + val = f(val) + val = val.lstrip('0').rstrip('%') + return val + + def __is_integer(self, s): + try: + int(s) + except Exception: + return False + else: + return True + + def __set_labels_values(self): + for lbl_list, table in zip(self.__all_lbls, self.labels_table): + for lbl, row in zip(lbl_list, table): + lbl.switch_off() + value = self.__get_lbl_value(*row) + if self.__is_integer(value): + lbl.level = int(value) + if not isinstance(lbl, MultiColorSwitchableLabel): + value += '%' + lbl.setText(value) + lbl.switch_on() + + def update_all_labels(self): + try: + self.__get_rows() + self.__split_lists() + self.__make_labels_table() + self.__set_dates() + self.__set_labels_values() + except Exception: + pass + + def remove_data(self): + self.forecast = '' + self.probabilities = '' From 24309ae1851aef49042bcbe368ea08b1a6941155 Mon Sep 17 00:00:00 2001 From: alessandro90 Date: Sun, 12 May 2019 12:22:34 +0200 Subject: [PATCH 5/6] Make some variables provate in ForecastData --- weatherdata.py | 170 +++++++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 84 deletions(-) diff --git a/weatherdata.py b/weatherdata.py index 90d6d35..d3ebc20 100644 --- a/weatherdata.py +++ b/weatherdata.py @@ -104,12 +104,12 @@ class ForecastData(_BaseWeatherData): super().__init__() self.forecast = '' self.probabilities = '' - self.labels_table = [] - self.solar_row = None - self.event_row = None - self.rb_now_row = None - self.ga_now_row = None - self.kp_index_row = None + self.__labels_table = [] + self.__solar_row = None + self.__event_row = None + self.__rb_now_row = None + self.__ga_now_row = None + self.__kp_index_row = None self._update_thread = UpdateForecastThread(self) self._update_thread.finished.connect(self._parse_and_emit_signal) self.today_lbl = parent.today_lbl @@ -145,7 +145,9 @@ class ForecastData(_BaseWeatherData): def _parse_data(self): self.forecast = self.forecast.splitlines() # Remove possible '(G\d)' from the kp_index table - self.probabilities = re.sub('(G\d)', lambda obj: '', self.probabilities) + self.probabilities = re.sub( + '(G\d)', lambda obj: '', self.probabilities + ) self.probabilities = self.probabilities.splitlines() def __split_lists(self): @@ -159,42 +161,42 @@ class ForecastData(_BaseWeatherData): return None def __get_rows(self): - self.solar_row = self.__find_row_with( + self.__solar_row = self.__find_row_with( self.forecast, self.ROW_KEYWORDS["solar_row"] ) - self.event_row = self.__find_row_with( + self.__event_row = self.__find_row_with( self.probabilities, self.ROW_KEYWORDS["event_row"] ) - self.rb_now_row = self.__find_row_with( + self.__rb_now_row = self.__find_row_with( self.forecast, self.ROW_KEYWORDS["rb_now_row"] ) - self.ga_now_row = self.__find_row_with( + self.__ga_now_row = self.__find_row_with( self.probabilities, self.ROW_KEYWORDS["ga_now_row"] ) - self.kp_index_row = self.__find_row_with( + self.__kp_index_row = self.__find_row_with( self.forecast, self.ROW_KEYWORDS["kp_index_row"] ) is_none = lambda x: x is None if any([ - is_none(self.solar_row), - is_none(self.event_row), - is_none(self.rb_now_row), - is_none(self.ga_now_row), - is_none(self.kp_index_row) + is_none(self.__solar_row), + is_none(self.__event_row), + is_none(self.__rb_now_row), + is_none(self.__ga_now_row), + is_none(self.__kp_index_row) ]): - raise Exception + raise Exception('Missing Rows') def __set_dates(self): - month = self.forecast[self.solar_row - 1][0] - today = self.forecast[self.solar_row - 1][1] - today_p1 = self.forecast[self.solar_row - 1][3] - today_p2 = self.forecast[self.solar_row - 1][5] + month = self.forecast[self.__solar_row - 1][0] + today = self.forecast[self.__solar_row - 1][1] + today_p1 = self.forecast[self.__solar_row - 1][3] + today_p2 = self.forecast[self.__solar_row - 1][5] self.today_lbl.setText(month + ' ' + today) self.today_p1_lbl.setText(month + ' ' + today_p1) self.today_p2_lbl.setText(month + ' ' + today_p2) @@ -203,72 +205,72 @@ class ForecastData(_BaseWeatherData): get_first_split = lambda x: x.split("/")[0] get_second_split = lambda x: x.split("/")[1] get_third_split = lambda x: x.split("/")[2] - self.labels_table = [ + self.__labels_table = [ [ - [self.forecast, self.solar_row, 3, None], - [self.probabilities, self.event_row + 1, 2, get_first_split], - [self.probabilities, self.event_row + 2, 2, get_first_split], - [self.probabilities, self.event_row + 3, 1, get_first_split], - [self.forecast, self.rb_now_row, 1, None], - [self.forecast, self.rb_now_row + 1, 3, None], - [self.probabilities, self.ga_now_row + 2, 1, get_first_split], - [self.probabilities, self.ga_now_row + 3, 2, get_first_split], - [self.probabilities, self.ga_now_row + 4, 2, get_first_split], - [self.probabilities, self.ga_now_row + 6, 1, get_first_split], - [self.probabilities, self.ga_now_row + 7, 2, get_first_split], - [self.probabilities, self.ga_now_row + 8, 2, get_first_split], - [self.forecast, self.kp_index_row + 3, 1, None], - [self.forecast, self.kp_index_row + 4, 1, None], - [self.forecast, self.kp_index_row + 5, 1, None], - [self.forecast, self.kp_index_row + 6, 1, None], - [self.forecast, self.kp_index_row + 7, 1, None], - [self.forecast, self.kp_index_row + 8, 1, None], - [self.forecast, self.kp_index_row + 9, 1, None], - [self.forecast, self.kp_index_row + 10, 1, None] + [self.forecast, self.__solar_row, 3, None], + [self.probabilities, self.__event_row + 1, 2, get_first_split], + [self.probabilities, self.__event_row + 2, 2, get_first_split], + [self.probabilities, self.__event_row + 3, 1, get_first_split], + [self.forecast, self.__rb_now_row, 1, None], + [self.forecast, self.__rb_now_row + 1, 3, None], + [self.probabilities, self.__ga_now_row + 2, 1, get_first_split], + [self.probabilities, self.__ga_now_row + 3, 2, get_first_split], + [self.probabilities, self.__ga_now_row + 4, 2, get_first_split], + [self.probabilities, self.__ga_now_row + 6, 1, get_first_split], + [self.probabilities, self.__ga_now_row + 7, 2, get_first_split], + [self.probabilities, self.__ga_now_row + 8, 2, get_first_split], + [self.forecast, self.__kp_index_row + 3, 1, None], + [self.forecast, self.__kp_index_row + 4, 1, None], + [self.forecast, self.__kp_index_row + 5, 1, None], + [self.forecast, self.__kp_index_row + 6, 1, None], + [self.forecast, self.__kp_index_row + 7, 1, None], + [self.forecast, self.__kp_index_row + 8, 1, None], + [self.forecast, self.__kp_index_row + 9, 1, None], + [self.forecast, self.__kp_index_row + 10, 1, None] ], [ - [self.forecast, self.solar_row, 4, None], - [self.probabilities, self.event_row + 1, 2, get_second_split], - [self.probabilities, self.event_row + 2, 2, get_second_split], - [self.probabilities, self.event_row + 3, 1, get_second_split], - [self.forecast, self.rb_now_row, 2, None], - [self.forecast, self.rb_now_row + 1, 4, None], - [self.probabilities, self.ga_now_row + 2, 1, get_second_split], - [self.probabilities, self.ga_now_row + 3, 2, get_second_split], - [self.probabilities, self.ga_now_row + 4, 2, get_second_split], - [self.probabilities, self.ga_now_row + 6, 1, get_second_split], - [self.probabilities, self.ga_now_row + 7, 2, get_second_split], - [self.probabilities, self.ga_now_row + 8, 2, get_second_split], - [self.forecast, self.kp_index_row + 3, 2, None], - [self.forecast, self.kp_index_row + 4, 2, None], - [self.forecast, self.kp_index_row + 5, 2, None], - [self.forecast, self.kp_index_row + 6, 2, None], - [self.forecast, self.kp_index_row + 7, 2, None], - [self.forecast, self.kp_index_row + 8, 2, None], - [self.forecast, self.kp_index_row + 9, 2, None], - [self.forecast, self.kp_index_row + 10, 2, None] + [self.forecast, self.__solar_row, 4, None], + [self.probabilities, self.__event_row + 1, 2, get_second_split], + [self.probabilities, self.__event_row + 2, 2, get_second_split], + [self.probabilities, self.__event_row + 3, 1, get_second_split], + [self.forecast, self.__rb_now_row, 2, None], + [self.forecast, self.__rb_now_row + 1, 4, None], + [self.probabilities, self.__ga_now_row + 2, 1, get_second_split], + [self.probabilities, self.__ga_now_row + 3, 2, get_second_split], + [self.probabilities, self.__ga_now_row + 4, 2, get_second_split], + [self.probabilities, self.__ga_now_row + 6, 1, get_second_split], + [self.probabilities, self.__ga_now_row + 7, 2, get_second_split], + [self.probabilities, self.__ga_now_row + 8, 2, get_second_split], + [self.forecast, self.__kp_index_row + 3, 2, None], + [self.forecast, self.__kp_index_row + 4, 2, None], + [self.forecast, self.__kp_index_row + 5, 2, None], + [self.forecast, self.__kp_index_row + 6, 2, None], + [self.forecast, self.__kp_index_row + 7, 2, None], + [self.forecast, self.__kp_index_row + 8, 2, None], + [self.forecast, self.__kp_index_row + 9, 2, None], + [self.forecast, self.__kp_index_row + 10, 2, None] ], [ - [self.forecast, self.solar_row, 5, None], - [self.probabilities, self.event_row + 1, 2, get_third_split], - [self.probabilities, self.event_row + 2, 2, get_third_split], - [self.probabilities, self.event_row + 3, 1, get_third_split], - [self.forecast, self.rb_now_row, 3, None], - [self.forecast, self.rb_now_row + 1, 5, None], - [self.probabilities, self.ga_now_row + 2, 1, get_third_split], - [self.probabilities, self.ga_now_row + 3, 2, get_third_split], - [self.probabilities, self.ga_now_row + 4, 2, get_third_split], - [self.probabilities, self.ga_now_row + 6, 1, get_third_split], - [self.probabilities, self.ga_now_row + 7, 2, get_third_split], - [self.probabilities, self.ga_now_row + 8, 2, get_third_split], - [self.forecast, self.kp_index_row + 3, 3, None], - [self.forecast, self.kp_index_row + 4, 3, None], - [self.forecast, self.kp_index_row + 5, 3, None], - [self.forecast, self.kp_index_row + 6, 3, None], - [self.forecast, self.kp_index_row + 7, 3, None], - [self.forecast, self.kp_index_row + 8, 3, None], - [self.forecast, self.kp_index_row + 9, 3, None], - [self.forecast, self.kp_index_row + 10, 3, None] + [self.forecast, self.__solar_row, 5, None], + [self.probabilities, self.__event_row + 1, 2, get_third_split], + [self.probabilities, self.__event_row + 2, 2, get_third_split], + [self.probabilities, self.__event_row + 3, 1, get_third_split], + [self.forecast, self.__rb_now_row, 3, None], + [self.forecast, self.__rb_now_row + 1, 5, None], + [self.probabilities, self.__ga_now_row + 2, 1, get_third_split], + [self.probabilities, self.__ga_now_row + 3, 2, get_third_split], + [self.probabilities, self.__ga_now_row + 4, 2, get_third_split], + [self.probabilities, self.__ga_now_row + 6, 1, get_third_split], + [self.probabilities, self.__ga_now_row + 7, 2, get_third_split], + [self.probabilities, self.__ga_now_row + 8, 2, get_third_split], + [self.forecast, self.__kp_index_row + 3, 3, None], + [self.forecast, self.__kp_index_row + 4, 3, None], + [self.forecast, self.__kp_index_row + 5, 3, None], + [self.forecast, self.__kp_index_row + 6, 3, None], + [self.forecast, self.__kp_index_row + 7, 3, None], + [self.forecast, self.__kp_index_row + 8, 3, None], + [self.forecast, self.__kp_index_row + 9, 3, None], + [self.forecast, self.__kp_index_row + 10, 3, None] ] ] @@ -288,7 +290,7 @@ class ForecastData(_BaseWeatherData): return True def __set_labels_values(self): - for lbl_list, table in zip(self.__all_lbls, self.labels_table): + for lbl_list, table in zip(self.__all_lbls, self.__labels_table): for lbl, row in zip(lbl_list, table): lbl.switch_off() value = self.__get_lbl_value(*row) From a04baed916103826898bee57169840330d90a82f Mon Sep 17 00:00:00 2001 From: alessandro90 Date: Sun, 12 May 2019 19:57:03 +0200 Subject: [PATCH 6/6] Fix bug in space weather information displayed --- artemis.py | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/artemis.py b/artemis.py index ee2c3cc..0ef3187 100644 --- a/artemis.py +++ b/artemis.py @@ -617,33 +617,44 @@ class Artemis(QMainWindow, Ui_MainWindow): if k_index == 0: self.switchable_g_now_labels.switch_on(self.g0_now_lbl) self.k_storm_labels.switch_on(self.k_inactive_lbl) + self.expected_noise_lbl.setText(" S0 - S1 (<-120 dBm) ") elif k_index == 1: self.switchable_g_now_labels.switch_on(self.g0_now_lbl) self.k_storm_labels.switch_on(self.k_very_quiet_lbl) + self.expected_noise_lbl.setText(" S0 - S1 (<-120 dBm) ") elif k_index == 2: self.switchable_g_now_labels.switch_on(self.g0_now_lbl) self.k_storm_labels.switch_on(self.k_quiet_lbl) + self.expected_noise_lbl.setText(" S1 - S2 (-115 dBm) ") elif k_index == 3: self.switchable_g_now_labels.switch_on(self.g0_now_lbl) self.k_storm_labels.switch_on(self.k_unsettled_lbl) + self.expected_noise_lbl.setText(" S2 - S3 (-110 dBm) ") elif k_index == 4: self.switchable_g_now_labels.switch_on(self.g0_now_lbl) self.k_storm_labels.switch_on(self.k_active_lbl) + self.expected_noise_lbl.setText(" S3 - S4 (-100 dBm) ") elif k_index == 5: self.switchable_g_now_labels.switch_on(self.g1_now_lbl) self.k_storm_labels.switch_on(self.k_min_storm_lbl) + self.expected_noise_lbl.setText(" S4 - S6 (-90 dBm) ") elif k_index == 6: self.switchable_g_now_labels.switch_on(self.g2_now_lbl) self.k_storm_labels.switch_on(self.k_maj_storm_lbl) + self.expected_noise_lbl.setText(" S6 - S9 (-80 dBm) ") elif k_index == 7: self.switchable_g_now_labels.switch_on(self.g3_now_lbl) self.k_storm_labels.switch_on(self.k_sev_storm_lbl) + self.expected_noise_lbl.setText(" S9 - S20 (>-60 dBm) ") elif k_index == 8: self.switchable_g_now_labels.switch_on(self.g4_now_lbl) self.k_storm_labels.switch_on(self.k_very_sev_storm_lbl) + self.expected_noise_lbl.setText(" S20 - S30 (>-60 dBm) ") elif k_index == 9: self.switchable_g_now_labels.switch_on(self.g5_now_lbl) self.k_storm_labels.switch_on(self.k_ex_sev_storm_lbl) + self.expected_noise_lbl.setText(" S30+ (>>-60 dBm) ") + self.expected_noise_lbl.switch_on() if a_index >= 0 and a_index < 8: self.a_storm_labels.switch_on(self.a_quiet_lbl) @@ -662,35 +673,24 @@ class Artemis(QMainWindow, Ui_MainWindow): k_index_24_hmax = int(self.space_weather_data.geo_storm[6][index]) if k_index_24_hmax == 0: self.switchable_g_today_labels.switch_on(self.g0_today_lbl) - self.expected_noise_lbl.setText(" S0 - S1 (<-120 dBm) ") elif k_index_24_hmax == 1: self.switchable_g_today_labels.switch_on(self.g0_today_lbl) - self.expected_noise_lbl.setText(" S0 - S1 (<-120 dBm) ") elif k_index_24_hmax == 2: self.switchable_g_today_labels.switch_on(self.g0_today_lbl) - self.expected_noise_lbl.setText(" S1 - S2 (-115 dBm) ") elif k_index_24_hmax == 3: self.switchable_g_today_labels.switch_on(self.g0_today_lbl) - self.expected_noise_lbl.setText(" S2 - S3 (-110 dBm) ") elif k_index_24_hmax == 4: self.switchable_g_today_labels.switch_on(self.g0_today_lbl) - self.expected_noise_lbl.setText(" S3 - S4 (-100 dBm) ") elif k_index_24_hmax == 5: self.switchable_g_today_labels.switch_on(self.g1_today_lbl) - self.expected_noise_lbl.setText(" S4 - S6 (-90 dBm) ") elif k_index_24_hmax == 6: self.switchable_g_today_labels.switch_on(self.g2_today_lbl) - self.expected_noise_lbl.setText(" S6 - S9 (-80 dBm) ") elif k_index_24_hmax == 7: self.switchable_g_today_labels.switch_on(self.g3_today_lbl) - self.expected_noise_lbl.setText(" S9 - S20 (>-60 dBm) ") elif k_index_24_hmax == 8: self.switchable_g_today_labels.switch_on(self.g4_today_lbl) - self.expected_noise_lbl.setText(" S20 - S30 (>-60 dBm) ") elif k_index_24_hmax == 9: self.switchable_g_today_labels.switch_on(self.g5_today_lbl) - self.expected_noise_lbl.setText(" S30+ (>>-60 dBm) ") - self.expected_noise_lbl.switch_on() val = int(self.space_weather_data.ak_index[7][2].replace('.', '')) self.sfi_lbl.setText(f"{val}") @@ -767,7 +767,9 @@ class Artemis(QMainWindow, Ui_MainWindow): def set_initial_size(self): """Function to handle high resolution screens. The function sets bigger - sizes for all the relevant fixed-size widgets.""" + sizes for all the relevant fixed-size widgets. + Also by default it sets the size to 3/4 of the available space + both vertically and horizontally.""" d = QDesktopWidget().availableGeometry() w = d.width() h = d.height()