account for utc offset

This commit is contained in:
Cyberes 2024-09-03 17:34:23 -06:00
parent 63d642ef50
commit a03540605e
1 changed files with 11 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import io
import logging
import pickle
import time
from datetime import datetime
from datetime import datetime, timedelta
import schedule
from PIL import Image
@ -12,12 +12,21 @@ from lib.tecmap import plot_tec_map
logging.basicConfig(level=logging.INFO)
# Entire planet
LAT_RANGE_MIN = -90
LAT_RANGE_MAX = 90
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)
@ -33,7 +42,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)[1]
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]
buf = io.BytesIO()
plt.savefig(buf, format='png', bbox_inches='tight', pad_inches=0, dpi=110)
plt.close()