fix systemd timer, handle when noaa gives bad data
This commit is contained in:
parent
86626495c2
commit
e9ecf793a9
|
@ -5,10 +5,9 @@ EarthData which is done through Selenium and the Chrome browser.
|
|||
|
||||
## Install
|
||||
|
||||
1. Create an account at <https://urs.earthdata.nasa.gov>
|
||||
2. `pip install -r requirements.txt`
|
||||
3. `sudo apt-get install redis-server`
|
||||
4. `sudo systemctl enable --now redis-server`
|
||||
1. `pip install -r requirements.txt`
|
||||
2. `sudo apt-get install redis-server`
|
||||
3. `sudo systemctl enable --now redis-server`
|
||||
|
||||
## Run
|
||||
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
import logging
|
||||
import time
|
||||
import traceback
|
||||
|
||||
import cartopy.crs as ccrs
|
||||
import matplotlib.pyplot as plt
|
||||
|
@ -12,13 +14,19 @@ from scipy.interpolate import griddata
|
|||
|
||||
|
||||
def get_latest_glotec():
|
||||
r = requests.get('https://services.swpc.noaa.gov/experimental/products/glotec/geojson_2d_urt.json')
|
||||
r.raise_for_status()
|
||||
index_json = r.json()[-1]
|
||||
data_url = 'https://services.swpc.noaa.gov' + index_json['url']
|
||||
r2 = requests.get(data_url)
|
||||
r2.raise_for_status()
|
||||
return r2.json()
|
||||
try:
|
||||
r = requests.get('https://services.swpc.noaa.gov/experimental/products/glotec/geojson_2d_urt.json')
|
||||
r.raise_for_status()
|
||||
index_json = r.json()[-1]
|
||||
data_url = 'https://services.swpc.noaa.gov' + index_json['url']
|
||||
r2 = requests.get(data_url)
|
||||
r2.raise_for_status()
|
||||
return r2.json()
|
||||
except:
|
||||
logging.basicConfig()
|
||||
logger = logging.getLogger(__name__)
|
||||
logger.error(traceback.format_exc())
|
||||
return None
|
||||
|
||||
|
||||
def plot_glotec_map(data: dict, lon_range: list, lat_range: list):
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
paho-mqtt==1.5.0
|
||||
chromedriver-autoinstaller==0.6.4
|
||||
selenium==4.23.1
|
||||
requests==2.32.3
|
||||
matplotlib==3.9.2
|
||||
cartopy==0.23.0
|
||||
|
@ -9,7 +7,6 @@ redis==5.0.8
|
|||
async-timeout==4.0.3
|
||||
Pillow
|
||||
flask==3.0.3
|
||||
schedule==1.2.2
|
||||
gunicorn==23.0.0
|
||||
python-dateutil==2.9.0.post0
|
||||
scipy==1.14.1
|
|
@ -1,6 +1,6 @@
|
|||
[Unit]
|
||||
Description=Space Weather Cache
|
||||
After=network.target space-weather-cache.service
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[Unit]
|
||||
Description=Space Weather MQTT
|
||||
After=network.target
|
||||
After=network.target space-weather-cache.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
|
|
|
@ -4,6 +4,7 @@ Description=Space Weather MQTT timer
|
|||
[Timer]
|
||||
OnCalendar=hourly
|
||||
Persistent=true
|
||||
Unit=space-weather-mqtt.service
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
Loading…
Reference in New Issue