Skip to content

Commit

Permalink
gui: implement some of the ui functionality (auto update, generic paths)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwinkel committed Apr 20, 2019
1 parent d7cab91 commit 5570830
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 6 deletions.
12 changes: 12 additions & 0 deletions pycraf/gui/gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down Expand Up @@ -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)

Expand Down
46 changes: 40 additions & 6 deletions pycraf/gui/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 5570830

Please sign in to comment.