-
Notifications
You must be signed in to change notification settings - Fork 7
correction for altitudes based on takeoff altitude #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -71,15 +71,23 @@ def __init__(self, current_version, latest_version): | |||||
| self.url_input = wx.TextCtrl(panel) | ||||||
| my_sizer.Add(self.url_input, 0, wx.ALL | wx.EXPAND, 5) | ||||||
|
|
||||||
| to_elevation_sizer = wx.BoxSizer(wx.HORIZONTAL) | ||||||
|
|
||||||
| text = wx.StaticText(panel, label="Field elevation:") | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe nice to add a unit: is this above MSL?
Suggested change
|
||||||
| to_elevation_sizer.Add(text, 0, wx.ALL, 5) | ||||||
| self.to_elevation_input = wx.TextCtrl(panel) | ||||||
| to_elevation_sizer.Add(self.to_elevation_input, 0, wx.ALL | wx.EXPAND, 5) | ||||||
|
|
||||||
| status_sizer = wx.BoxSizer(wx.VERTICAL) | ||||||
| self.status = wx.StaticText(panel, label="") | ||||||
| my_sizer.Add(self.status) | ||||||
| status_sizer.Add(self.status) | ||||||
|
|
||||||
| self.download_status = wx.StaticText(panel, label="") | ||||||
| my_sizer.Add(self.download_status) | ||||||
| status_sizer.Add(self.download_status) | ||||||
|
|
||||||
| self.analyse_status = wx.StaticText(panel, label="") | ||||||
| my_sizer.Add(self.analyse_status) | ||||||
|
|
||||||
| status_sizer.Add(self.analyse_status) | ||||||
| buttons_sizer = wx.BoxSizer(wx.HORIZONTAL) | ||||||
|
|
||||||
| self.start_analysis = wx.Button(panel, label='Start analysis') | ||||||
|
|
@@ -96,6 +104,8 @@ def __init__(self, current_version, latest_version): | |||||
| buttons_sizer.Add(bug_report) | ||||||
|
|
||||||
| complete_sizer.Add(my_sizer, 0, wx.ALL | wx.EXPAND, 5) | ||||||
| complete_sizer.Add(to_elevation_sizer, 0, wx.ALL | wx.LEFT, 5) | ||||||
| complete_sizer.Add(status_sizer, 0, wx.ALL | wx.LEFT, 5) | ||||||
| complete_sizer.Add(buttons_sizer, 0, wx.ALL | wx.CENTER, 5) | ||||||
|
|
||||||
| panel.SetSizer(complete_sizer) | ||||||
|
|
@@ -159,7 +169,12 @@ def on_press(self, event): | |||||
|
|
||||||
| url = self.url_input.GetValue() | ||||||
| if url_format_correct(url, self.update_status): | ||||||
| args = (url, get_url_source(url), self.set_download_status, self.set_analyse_status, | ||||||
| try: | ||||||
| to_elevation = int(self.to_elevation_input.GetValue()) | ||||||
| except: | ||||||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When using a bare except clause, this also catches a i prefer to only catch the instances of
Suggested change
|
||||||
| to_elevation = None | ||||||
|
|
||||||
| args = (url, get_url_source(url), to_elevation, self.set_download_status, self.set_analyse_status, | ||||||
| self.after_successful_run, self.after_unsuccessful_run) | ||||||
| x = Thread(target=run, args=args) | ||||||
| x.start() | ||||||
|
|
@@ -188,7 +203,9 @@ def run_commandline_program(sys_argv, current_version, latest_version): | |||||
| def print_help(): | ||||||
| print('There are two options for running PySoar from the commandline:\n' | ||||||
| '1. `python main_python` for GUI\n' | ||||||
| '2. `python main_pysoar [url]` - where [url] is the daily competition url') | ||||||
| '2. `python main_pysoar [url] <takeoff elevation>` - where:\n' \ | ||||||
| ' - [url] is the daily competition url,\n'\ | ||||||
| ' - <takeoff elevation> (optional) is the elevation of the takeoff field to be used in altitude corrections') | ||||||
|
|
||||||
| def status_handle(message): | ||||||
| print(message) | ||||||
|
|
@@ -216,15 +233,17 @@ def analysis_handle(new, total=None): | |||||
| if latest_version and latest_version.lstrip('v') != current_version: | ||||||
| print('Latest version is %s! Current: %s' % (latest_version, current_version)) | ||||||
|
|
||||||
| if len(sys_argv) == 2: | ||||||
| if len(sys_argv) >= 2: | ||||||
| if sys_argv[1] == '--help': | ||||||
| print_help() | ||||||
| else: | ||||||
| url = sys_argv[1] | ||||||
| to_elevation = None if len(sys_argv) == 2 else int(sys_argv[2]) | ||||||
| if url_format_correct(url, status_handle): | ||||||
| source = get_url_source(url) | ||||||
| run(url, | ||||||
| source, | ||||||
| to_elevation, | ||||||
| download_progress=download_handle, | ||||||
| analysis_progress=analysis_handle, | ||||||
| on_success=on_success, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,57 +9,68 @@ class Performance(object): | |
| 'v_turn_avg', 'LD_avg', 'turn_percentage', 'h_loss_turn', 's_glide_avg', 'dh_cruise_avg', | ||
| 's_extra', 'tsk_v'] | ||
|
|
||
| def __init__(self, task, trip, phases, gps_altitude): | ||
| def __init__(self, task, trip, phases, gps_altitude, elevation_correction): | ||
|
|
||
| self.all = None | ||
| self.leg = None | ||
|
|
||
| self.tsk_distance_all = sum(trip.distances) | ||
| self.tsk_distance_leg = trip.distances | ||
| self.trip = trip | ||
| self.gps_altitude = gps_altitude | ||
| self.elevation_correction = elevation_correction | ||
|
|
||
| # why not use phases directly? pass in functions as argument? | ||
| self.no_cruises_leg = [len(phases.cruises(leg)) for leg in range(trip.started_legs())] | ||
| self.no_cruises = len(phases.cruises(leg='all')) | ||
| self.no_thermals_leg = [len(phases.thermals(leg)) for leg in range(trip.started_legs())] | ||
| self.no_thermals = len(phases.thermals(leg='all')) | ||
|
|
||
| self.init_all(trip, gps_altitude) | ||
| self.init_leg(trip, gps_altitude) | ||
| self.init_all() | ||
| self.init_leg() | ||
|
|
||
| self.determine_performance(task, trip, phases, gps_altitude) | ||
|
|
||
| def init_all(self, trip, gps_altitude): | ||
| start_h = trip.fixes[0]['gps_alt'] if gps_altitude else trip.fixes[0]['pressure_alt'] | ||
| start_t = trip.refined_start_time | ||
| def get_height(self, trip_index): | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice improvement |
||
| if (self.gps_altitude): | ||
| # return gps altitude corrected for start elevation | ||
| return self.trip.fixes[trip_index]['gps_alt'] - self.elevation_correction | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think it is clearer if the elevation correction is simply added here and that the value can be both negative and positive. if this is changed, the calculation should be changed too. also there might be other places where this is used. |
||
| else: | ||
| # return pressure altitude corrected for start elevation | ||
| return self.trip.fixes[trip_index]['pressure_alt'] - self.elevation_correction | ||
|
|
||
| def init_all(self): | ||
| start_h = self.get_height(0) | ||
| start_t = self.trip.refined_start_time | ||
|
|
||
| if len(trip.fixes) == 1: | ||
| if len(self.trip.fixes) == 1: | ||
| finish_h = None | ||
| finish_t = None | ||
| else: | ||
| finish_h = trip.fixes[-1]['gps_alt'] if gps_altitude else trip.fixes[-1]['pressure_alt'] | ||
| finish_t = trip.fixes[-1]['time'] | ||
| finish_h = self.get_height(-1) | ||
| finish_t = self.trip.fixes[-1]['time'] | ||
|
|
||
| s_flown_task_all = sum(trip.distances) / 1000 | ||
| s_flown_task_all = sum(self.trip.distances) / 1000 | ||
|
|
||
| self.all = {"t_start": start_t, | ||
| "t_finish": finish_t, | ||
| "h_start": start_h, | ||
| "h_finish": finish_h, | ||
| "s_flown_task": s_flown_task_all} | ||
|
|
||
| def init_leg(self, trip, gps_altitude): | ||
| def init_leg(self): | ||
| leg_values = [] | ||
|
|
||
| for leg in range(len(trip.distances)): | ||
| if trip.outlanding_fix is not None and leg == trip.outlanding_leg(): | ||
| start_h = trip.fixes[leg]['gps_alt'] if gps_altitude else trip.fixes[leg]['pressure_alt'] | ||
| start_t = trip.refined_start_time if leg == 0 else trip.fixes[leg]['time'] | ||
| for leg in range(len(self.trip.distances)): | ||
| if self.trip.outlanding_fix is not None and leg == self.trip.outlanding_leg(): | ||
| start_h = self.get_height(leg) | ||
| start_t = self.trip.refined_start_time if leg == 0 else self.trip.fixes[leg]['time'] | ||
|
|
||
| finish_t = 0 | ||
| finish_h = 0 | ||
|
|
||
| s_flown_task_leg = trip.distances[-1] / 1000 | ||
| elif trip.outlanding_fix is not None and leg > trip.outlanding_leg(): | ||
| s_flown_task_leg = self.trip.distances[-1] / 1000 | ||
| elif self.trip.outlanding_fix is not None and leg > self.trip.outlanding_leg(): | ||
| start_t = 0 | ||
| start_h = 0 | ||
|
|
||
|
|
@@ -68,13 +79,13 @@ def init_leg(self, trip, gps_altitude): | |
|
|
||
| s_flown_task_leg = 0 | ||
| else: | ||
| start_h = trip.fixes[leg]['gps_alt'] if gps_altitude else trip.fixes[leg]['pressure_alt'] | ||
| start_t = trip.refined_start_time if leg == 0 else trip.fixes[leg]['time'] | ||
| start_h = self.get_height(leg) | ||
| start_t = self.trip.refined_start_time if leg == 0 else self.trip.fixes[leg]['time'] | ||
|
|
||
| finish_t = trip.fixes[leg+1]['time'] | ||
| finish_h = trip.fixes[leg+1]['gps_alt'] if gps_altitude else trip.fixes[leg+1]['pressure_alt'] | ||
| finish_t = self.trip.fixes[leg+1]['time'] | ||
| finish_h = self.get_height(leg+1) | ||
|
|
||
| s_flown_task_leg = trip.distances[leg] / 1000 | ||
| s_flown_task_leg = self.trip.distances[leg] / 1000 | ||
|
|
||
| leg_values.append({"t_start": start_t, | ||
| "t_finish": finish_t, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,7 +18,7 @@ def determine_performance_dictionary(self): | |
| self.set_performance_entry("t_start", "Start time", "text", "neutral", "[local time]", True, True, True, True) | ||
| self.set_performance_entry("t_finish", "Finish time", "text", "neutral", "[local time]", True, False, True, True) | ||
| self.set_performance_entry("h_start", "Start height", "number", "high", "[m]", True, True, True, True) | ||
| self.set_performance_entry("h_finish", "Finish height", "number", "high", "[m]", True, False, True, False) | ||
| self.set_performance_entry("h_finish", "Finish height", "number", "low", "[m]", True, False, True, True) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is it really umambiguous that a lower finish height is always better? i guess it makes sense for the last leg, but for others along the task this really depends? (for instance if you round a turnpoint downwind). now that i think of this, the same goes for the start height... |
||
| self.set_performance_entry("vario_gem", "Average rate of climb", "number", "high", "[m/s]", False, False, True, True) | ||
| self.set_performance_entry("v_glide_avg", "Average cruise speed (GS)", "number", "high", "[km/h]", True, False, True, True) | ||
| self.set_performance_entry("v_turn_avg", "Average thermal speed (GS)", "number", "low", "[km/h]", False, False, True, True) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think it helps to explicitly show the optional behavior of
to_elevation: