From 557083019c7b7cbbb45d698a778ccd7957ddbf33 Mon Sep 17 00:00:00 2001 From: bwinkel Date: Sat, 20 Apr 2019 22:05:36 +0200 Subject: [PATCH] gui: implement some of the ui functionality (auto update, generic paths) --- pycraf/gui/gui.py | 12 +++++++++++ pycraf/gui/workers.py | 46 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 6 deletions(-) diff --git a/pycraf/gui/gui.py b/pycraf/gui/gui.py index 754c61675..ccb334b22 100644 --- a/pycraf/gui/gui.py +++ b/pycraf/gui/gui.py @@ -153,6 +153,12 @@ def __init__(self, **kwargs): self.setup_gui() + # want that at start, user is presented with a plot + self.timer = QtCore.QTimer() + self.timer.setSingleShot(True) + self.timer.timeout.connect(self.on_any_param_changed) + self.timer.start(10) + @QtCore.pyqtSlot() def setup_gui(self): @@ -351,10 +357,16 @@ def on_any_param_changed(self): job_dict = self._get_parameters() self.geo_job_triggered.emit(job_dict) + if self.ui.pathprofAutoUpdateCheckBox.isChecked(): + self.on_pathprof_compute_pressed() + @QtCore.pyqtSlot() def on_pathprof_compute_pressed(self): job_dict = self._get_parameters() + job_dict['do_generic'] = ( + not self.ui.pathprofIncludeHeightCheckBox.isChecked() + ) # self.geo_job_triggered.emit(job_dict) self.pp_job_triggered.emit(job_dict) diff --git a/pycraf/gui/workers.py b/pycraf/gui/workers.py index 252daca8c..eed04dc05 100644 --- a/pycraf/gui/workers.py +++ b/pycraf/gui/workers.py @@ -23,6 +23,29 @@ def cached_height_path_data(*args, **kwargs): return pathprof.height_path_data(*args, **kwargs) +# @lru_cache(maxsize=10, typed=False) +# def cached_height_path_data_generic(*args, **kwargs): +# # height_path_data_generic has a different signature; +# # need to find mid point +# lon_t, lat_t, lon_r, lat_r, step = args +# distance, bearing, _ = pathprof.geoid_inverse( +# lon_t, lat_t, lon_r, lat_r +# ) +# lon_mid, lat_mid, _ = pathprof.geoid_direct( +# lon_t, lat_r, bearing, distance / 2, +# ) +# args = distance, step, lon_mid, lat_mid +# return pathprof.height_path_data_generic(*args, **kwargs) + + +@lru_cache(maxsize=10, typed=False) +def cached_height_path_data_generic(*args, **kwargs): + # height_path_data_generic has no backbearings, etc. + res = pathprof.height_path_data(*args, **kwargs) + res['heights'][...] = 0 + return res + + @lru_cache(maxsize=10, typed=False) def cached_height_map_data(*args, **kwargs): return pathprof.height_map_data(*args, **kwargs) @@ -135,12 +158,23 @@ def do_job(self): jdict = self.job_dict print('doing job', jdict) - hprof_data = cached_height_path_data( - jdict['tx_lon'] * u.deg, jdict['tx_lat'] * u.deg, - jdict['rx_lon'] * u.deg, jdict['rx_lat'] * u.deg, - jdict['stepsize'] * u.m, - zone_t=jdict['tx_clutter'], zone_r=jdict['rx_clutter'], - ) + if jdict['do_generic']: + + hprof_data = cached_height_path_data_generic( + jdict['tx_lon'] * u.deg, jdict['tx_lat'] * u.deg, + jdict['rx_lon'] * u.deg, jdict['rx_lat'] * u.deg, + jdict['stepsize'] * u.m, + zone_t=jdict['tx_clutter'], zone_r=jdict['rx_clutter'], + ) + + else: + + hprof_data = cached_height_path_data( + jdict['tx_lon'] * u.deg, jdict['tx_lat'] * u.deg, + jdict['rx_lon'] * u.deg, jdict['rx_lat'] * u.deg, + jdict['stepsize'] * u.m, + zone_t=jdict['tx_clutter'], zone_r=jdict['rx_clutter'], + ) results = pathprof.atten_path_fast( jdict['freq'] * u.GHz,