From 1d490f02268c02a8e236fbf2301a5f24898a1e38 Mon Sep 17 00:00:00 2001 From: glidergeek Date: Sun, 25 Aug 2024 16:54:28 +0200 Subject: [PATCH] temporary changes to facilitate wgc analyses; need to figure out where this should land --- opensoar/competition/soaringspot.py | 13 ++++++++++--- opensoar/thermals/flight_phases.py | 2 ++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/opensoar/competition/soaringspot.py b/opensoar/competition/soaringspot.py index ff7acaa..10a0dda 100644 --- a/opensoar/competition/soaringspot.py +++ b/opensoar/competition/soaringspot.py @@ -17,7 +17,7 @@ from opensoar.task.race_task import RaceTask from opensoar.task.task import Task from opensoar.task.waypoint import Waypoint -from opensoar.utilities.helper_functions import dm2dd, subtract_times +from opensoar.utilities.helper_functions import dm2dd, subtract_times, add_times from opensoar.competition.daily_results_page import DailyResultsPage @@ -84,8 +84,9 @@ def get_info_from_comment_lines(parsed_igc_file: dict, start_time_buffer: int=0) timezone = int(line.split(':')[3]) if start_opening is not None: - # convert start opening to UTC time - start_opening = subtract_times(start_opening, datetime.timedelta(hours=timezone)) + pass + # not converting start opening to UTC + # start_opening = subtract_times(start_opening, datetime.timedelta(hours=timezone)) if len(lcu_lines) == 0 or len(lseeyou_lines) == 0: # somehow some IGC files do not contain the LCU or LSEEYOU lines with task information @@ -358,11 +359,17 @@ def generate_competition_day(self, target_directory: str, download_progress=None print('{} is skipped because of invalid trace'.format(competition_id)) continue + + # get info from file task, contest_information, competitor_information = get_info_from_comment_lines(parsed_igc_file, start_time_buffer) plane_model = competitor_information.get('plane_model', None) pilot_name = competitor_information.get('pilot_name', None) + tz = task.timezone + for fix in trace: + fix['time'] = add_times(fix['time'], datetime.timedelta(hours=tz)) + competitor = Competitor(trace, competition_id, plane_model, ranking, pilot_name) competitors.append(competitor) diff --git a/opensoar/thermals/flight_phases.py b/opensoar/thermals/flight_phases.py index 051beba..797684a 100644 --- a/opensoar/thermals/flight_phases.py +++ b/opensoar/thermals/flight_phases.py @@ -165,8 +165,10 @@ def _get_phase_within_leg(self, phase: Phase, leg: int) -> Phase: else: end_fix = phase.fixes[-1] + phase_start_index = phase.fixes.index(start_fix) phase_end_index = phase.fixes.index(end_fix) + return Phase(phase.is_cruise, phase.fixes[phase_start_index:phase_end_index + 1]) def _get_phase_within_trip(self, phase):