From 0aba3b01362f7a7500921f34ec46ecc016ba15d7 Mon Sep 17 00:00:00 2001 From: glidergeek Date: Sun, 25 Aug 2024 16:55:38 +0200 Subject: [PATCH 1/3] temporary fixes for uvalde wgc; need to figure out where permanent fixes land --- PySoar/analysis.py | 38 ++++++++++++++++++++++++++------------ PySoar/exportClass.py | 6 +++--- 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/PySoar/analysis.py b/PySoar/analysis.py index 7ec53c1..9e2a6a1 100644 --- a/PySoar/analysis.py +++ b/PySoar/analysis.py @@ -5,6 +5,7 @@ from opensoar.competition.soaringspot import SoaringSpotDaily from exportClass import ExcelExport +from opensoar.utilities.geojson_serializers import generate_geojson, task_to_geojson_features, trip_to_geojson_features, trace_to_geojson_features from performanceClass import Performance from settingsClass import Settings @@ -78,20 +79,33 @@ def run(self): for competitor in competition_day.competitors: + print('comp id:', competitor.competition_id) + if competitor.competition_id in failed_comp_ids: - continue + print('failed_comp_id:', failed_comp_ids) else: - try: - # put gps_altitude to False when nonzero pressure altitude is found - gps_altitude = True - for fix in competitor.trace: - if fix['pressure_alt'] != 0: - gps_altitude = False - - competitor.performance = Performance(competition_day.task, competitor.trip, competitor.phases, - gps_altitude) - except Exception: - failed_comp_ids.append(competitor.competition_id) + + import json + if competitor.competition_id == 'MG': + features = [ + *task_to_geojson_features(competition_day.task), + *trip_to_geojson_features(competitor.trip, "#062123"), + *trace_to_geojson_features(competitor.trace), + + ] + geojson_dct = generate_geojson(features) + with open('debug.json', 'w') as f: + json.dump(geojson_dct, f) + print('successfully dumped json') + + # put gps_altitude to False when nonzero pressure altitude is found + gps_altitude = True + for fix in competitor.trace: + if fix['pressure_alt'] != 0: + gps_altitude = False + + competitor.performance = Performance(competition_day.task, competitor.trip, competitor.phases, + gps_altitude) failed_competitors = [] for competitor in competition_day.competitors: diff --git a/PySoar/exportClass.py b/PySoar/exportClass.py index 74681fe..f5cfa9f 100644 --- a/PySoar/exportClass.py +++ b/PySoar/exportClass.py @@ -263,9 +263,9 @@ def write_perf_indics(self, leg, settings, competition_day): if perf_ind in ['t_start', 't_finish']: - timezone = competition_day.task.timezone - if timezone is not None: - content = add_times(content, datetime.timedelta(hours=timezone)) + # timezone = competition_day.task.timezone + # if timezone is not None: + # content = add_times(content, datetime.timedelta(hours=timezone)) content = content.strftime('%H:%M:%S') From b2837789db8ca785916050c6461d3f5a28a0a90b Mon Sep 17 00:00:00 2001 From: glidergeek Date: Thu, 29 Aug 2024 19:27:53 +0200 Subject: [PATCH 2/3] retore try, except, change time handling to all happen in local times --- PySoar/analysis.py | 48 +++++++++++++++++++++---------------------- PySoar/exportClass.py | 5 ----- 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/PySoar/analysis.py b/PySoar/analysis.py index 9e2a6a1..16d7111 100644 --- a/PySoar/analysis.py +++ b/PySoar/analysis.py @@ -1,11 +1,12 @@ import os from threading import Thread +import datetime import wx from opensoar.competition.soaringspot import SoaringSpotDaily +from opensoar.utilities.helper_functions import add_times from exportClass import ExcelExport -from opensoar.utilities.geojson_serializers import generate_geojson, task_to_geojson_features, trip_to_geojson_features, trace_to_geojson_features from performanceClass import Performance from settingsClass import Settings @@ -64,6 +65,15 @@ def run(self): self.download_progress(None, None) competition_day = daily_result_page.generate_competition_day(target_directory, self.download_progress) + # converting trace from UTC to local time + tz = competition_day.task.timezone + for competitor in competition_day.competitors: + for fix in competitor.trace: + fix['time'] = add_times(fix['time'], datetime.timedelta(hours=tz)) + + # converting start-time from UTC to local time + competition_day.task.start_opening = add_times(competition_day.task.start_opening, datetime.timedelta(hours=tz)) + if competition_day.task.multistart: txt = 'Multiple starting points not implemented!' if self._notify_window is None: @@ -79,33 +89,21 @@ def run(self): for competitor in competition_day.competitors: - print('comp id:', competitor.competition_id) - if competitor.competition_id in failed_comp_ids: print('failed_comp_id:', failed_comp_ids) + continue else: - - import json - if competitor.competition_id == 'MG': - features = [ - *task_to_geojson_features(competition_day.task), - *trip_to_geojson_features(competitor.trip, "#062123"), - *trace_to_geojson_features(competitor.trace), - - ] - geojson_dct = generate_geojson(features) - with open('debug.json', 'w') as f: - json.dump(geojson_dct, f) - print('successfully dumped json') - - # put gps_altitude to False when nonzero pressure altitude is found - gps_altitude = True - for fix in competitor.trace: - if fix['pressure_alt'] != 0: - gps_altitude = False - - competitor.performance = Performance(competition_day.task, competitor.trip, competitor.phases, - gps_altitude) + try: + # put gps_altitude to False when nonzero pressure altitude is found + gps_altitude = True + for fix in competitor.trace: + if fix['pressure_alt'] != 0: + gps_altitude = False + + competitor.performance = Performance(competition_day.task, competitor.trip, competitor.phases, + gps_altitude) + except Exception: + failed_comp_ids.append(competitor.competition_id) failed_competitors = [] for competitor in competition_day.competitors: diff --git a/PySoar/exportClass.py b/PySoar/exportClass.py index f5cfa9f..7abc02e 100644 --- a/PySoar/exportClass.py +++ b/PySoar/exportClass.py @@ -262,11 +262,6 @@ def write_perf_indics(self, leg, settings, competition_day): content = competitor.performance.leg[leg][perf_ind] if perf_ind in ['t_start', 't_finish']: - - # timezone = competition_day.task.timezone - # if timezone is not None: - # content = add_times(content, datetime.timedelta(hours=timezone)) - content = content.strftime('%H:%M:%S') style = self.style_dict[perf_format + self.style_addition(leg, perf_ind, competitor.competition_id)] From 80a07ee012c9d10916e280963dc20dd57442fbbb Mon Sep 17 00:00:00 2001 From: glidergeek Date: Thu, 29 Aug 2024 19:29:41 +0200 Subject: [PATCH 3/3] add changelog entry --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 07243f6..6c82c87 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,7 @@ Master [unreleased] +- convert UTC to local time to prevent timezone issues v0.68.0 - 2024-08-18 - use macos-13 on github runner