fix timezone
This commit is contained in:
parent
c77659da57
commit
4b4c4d4491
|
@ -2,7 +2,7 @@ import io
|
|||
import logging
|
||||
import pickle
|
||||
import time
|
||||
from datetime import datetime, timedelta
|
||||
from datetime import datetime
|
||||
|
||||
import schedule
|
||||
from PIL import Image
|
||||
|
@ -19,14 +19,6 @@ LON_RANGE_MIN = -180
|
|||
LON_RANGE_MAX = 180
|
||||
|
||||
|
||||
def get_utc_offset():
|
||||
timestamp = time.time()
|
||||
local_time = datetime.fromtimestamp(timestamp)
|
||||
utc_time = datetime.utcfromtimestamp(timestamp)
|
||||
delta = local_time - utc_time
|
||||
return delta.total_seconds() / 3600
|
||||
|
||||
|
||||
def main():
|
||||
redis = Redis(host='localhost', port=6379, db=0)
|
||||
|
||||
|
@ -42,7 +34,7 @@ def main():
|
|||
|
||||
for tecmap, epoch in ionex_data:
|
||||
if epoch.hour == utc_hr:
|
||||
plt = plot_tec_map(tecmap, [float(LON_RANGE_MIN), float(LON_RANGE_MAX)], [float(LAT_RANGE_MIN), float(LAT_RANGE_MAX)], timestamp=epoch - timedelta(hours=get_utc_offset()))[1]
|
||||
plt = plot_tec_map(tecmap, [float(LON_RANGE_MIN), float(LON_RANGE_MAX)], [float(LAT_RANGE_MIN), float(LAT_RANGE_MAX)], timestamp_utc=epoch)[1]
|
||||
buf = io.BytesIO()
|
||||
plt.savefig(buf, format='png', bbox_inches='tight', pad_inches=0.1, dpi=110)
|
||||
plt.close()
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import re
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
import cartopy.crs as ccrs
|
||||
import matplotlib.pyplot as plt
|
||||
import numpy as np
|
||||
from dateutil.tz import tzutc, tzlocal
|
||||
from mpl_toolkits.axes_grid1 import make_axes_locatable
|
||||
|
||||
"""
|
||||
|
@ -32,7 +34,7 @@ def get_tecmaps(ionex: str):
|
|||
yield parse_map(tecmap), epoch
|
||||
|
||||
|
||||
def plot_tec_map(tecmap, lon_range: list, lat_range: list, timestamp: datetime = None):
|
||||
def plot_tec_map(tecmap, lon_range: list, lat_range: list, timestamp_utc: datetime = None):
|
||||
proj = ccrs.PlateCarree()
|
||||
f, ax = plt.subplots(1, 1, subplot_kw=dict(projection=proj))
|
||||
|
||||
|
@ -54,8 +56,9 @@ def plot_tec_map(tecmap, lon_range: list, lat_range: list, timestamp: datetime =
|
|||
|
||||
# Make graph pretty
|
||||
ax.coastlines()
|
||||
if timestamp:
|
||||
plt.title(timestamp.strftime('%H:%M %d-%m-%Y'), fontsize=12, y=1.04)
|
||||
if timestamp_utc:
|
||||
timestamp_local = timestamp_utc.replace(tzinfo=tzutc()).astimezone(tzlocal())
|
||||
plt.title(timestamp_local.strftime(f'%H:%M %m-%d-%Y {time.tzname[0]}'), fontsize=12, y=1.04)
|
||||
plt.suptitle('Vertical Total Electron Count', fontsize=16, y=0.87)
|
||||
divider = make_axes_locatable(ax)
|
||||
ax_cb = divider.new_horizontal(size='5%', pad=0.1, axes_class=plt.Axes)
|
||||
|
|
|
@ -10,4 +10,5 @@ async-timeout==4.0.3
|
|||
Pillow
|
||||
flask==3.0.3
|
||||
schedule==1.2.2
|
||||
gunicorn==23.0.0
|
||||
gunicorn==23.0.0
|
||||
python-dateutil==2.9.0.post0
|
Loading…
Reference in New Issue