Skip to content
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

PR: Add the possibility to show or hide GLUE water level results in the tool to visualize water level data. #205

Merged
merged 4 commits into from
May 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 43 additions & 16 deletions gwhat/HydroCalc2.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def __init__(self, datamanager, parent=None):
self.dmngr.wxdsetChanged.connect(self.set_wxdset)

self.rechg_eval_widget = RechgEvalWidget(parent=self)
self.rechg_eval_widget.sig_new_gluedf.connect(self.draw_glue_wl)

self.config_brf = BRFManager(parent=self)
self.config_brf.btn_seldata.clicked.connect(self.aToolbarBtn_isClicked)
Expand Down Expand Up @@ -207,6 +208,9 @@ def __initFig__(self):
self.h_brf1 = ax0.axvline(0, color='orange')
self.h_brf2 = ax0.axvline(0, color='orange')

# Predicted GLUE water levels
self.glue_plt, = ax0.plot([], [])

# Vertical guide line under cursor :
self.vguide = ax0.axvline(-1, color='red', zorder=40)
self.vguide.set_visible(False)
Expand Down Expand Up @@ -253,11 +257,10 @@ def _setup_toolbar(self):
self.btn_zoom_to_rect.sig_value_changed.connect(
self.zoom_is_active_changed)

self.btn_Waterlvl_lineStyle = QToolButtonNormal(
icons.get_icon('showDataDots'))
self.btn_Waterlvl_lineStyle.setToolTip(
self.btn_wl_style = OnOffToolButton('showDataDots')
self.btn_wl_style.setToolTip(
'<p>Show water lvl data as dots instead of a continuous line</p>')
self.btn_Waterlvl_lineStyle.clicked.connect(self.aToolbarBtn_isClicked)
self.btn_wl_style.sig_value_changed.connect(self.setup_wl_style)

self.btn_strati = QToolButtonNormal(icons.get_icon('stratigraphy'))
self.btn_strati.setToolTip('Toggle on and off the display of the soil'
Expand All @@ -272,11 +275,18 @@ def _setup_toolbar(self):
# dformat: 0 -> Excel Numeric Date Format
# 1 -> Matplotlib Date Format

self.btn_show_glue = OnOffToolButton('show_glue_wl')
self.btn_show_glue.setToolTip(
"""Show or hide GLUE water level 05/95 envelope.""")
self.btn_show_glue.sig_value_changed.connect(self.draw_glue_wl)
self.btn_show_glue.setValue(True, silent=True)

# Setup the layout.

toolbar = ToolBarWidget()
for btn in [self.btn_home, self.btn_pan, self.btn_zoom_to_rect, None,
self.btn_Waterlvl_lineStyle, self.btn_dateFormat]:
self.btn_wl_style, self.btn_dateFormat, None,
self.btn_show_glue]:
toolbar.addWidget(btn)

return toolbar
Expand Down Expand Up @@ -422,7 +432,6 @@ def set_wldset(self, wldset):

# Reset UI :

self.btn_Waterlvl_lineStyle.setAutoRaise(True)
self.toolbar.update()

def set_wxdset(self, wxdset):
Expand Down Expand Up @@ -783,8 +792,6 @@ def aToolbarBtn_isClicked(self):
sender = self.sender()
if sender == self.btn_MRCalc:
self.btn_MRCalc_isClicked()
elif sender == self.btn_Waterlvl_lineStyle:
self.change_waterlvl_lineStyle()
elif sender == self.btn_home:
self.home()
elif sender == self.btn_save_interp:
Expand Down Expand Up @@ -967,6 +974,7 @@ def init_hydrograph(self):

self.plt_wlpre, = ax0.plot([], [], color='red', clip_on=True,
ls='-', zorder=10, marker='None')
self.draw_glue_wl()

# Strati :

Expand Down Expand Up @@ -1124,20 +1132,18 @@ def display_soil_layer(self):

self.draw()

# ============================================== Water Level Linestyle ====

def change_waterlvl_lineStyle(self):
if self.btn_Waterlvl_lineStyle.autoRaise():
self.btn_Waterlvl_lineStyle.setAutoRaise(False)

def setup_wl_style(self):
"""
Setup the line and marker style of the obeserved water level data.
"""
if self.btn_wl_style.value():
self.h1_ax0.set_linestyle('None')
self.h1_ax0.set_marker('.')
self.h1_ax0.set_markerfacecolor('blue')
self.h1_ax0.set_markeredgewidth(1.5)
self.h1_ax0.set_markeredgecolor('blue')
self.h1_ax0.set_markeredgewidth(1.5)
self.h1_ax0.set_markersize(5)
else:
self.btn_Waterlvl_lineStyle.setAutoRaise(True)
self.h1_ax0.set_linestyle('-')
self.h1_ax0.set_marker('None')
self.draw()
Expand All @@ -1150,6 +1156,27 @@ def draw(self):
self.canvas.draw()
self.__figbckground = self.fig.canvas.copy_from_bbox(self.fig.bbox)

def draw_glue_wl(self):
"""Draw or hide the water level envelope estimated with GLUE."""
if self.wldset is not None and self.btn_show_glue.value():
gluedf = self.wldset.get_glue_at(-1)
if gluedf is not None:
self.glue_plt.set_visible(True)
xlstime = (gluedf['water levels']['time'] +
self.dt4xls2mpl * self.dformat)
wl05 = gluedf['water levels']['predicted'][:, 0]/1000
wl95 = gluedf['water levels']['predicted'][:, 2]/1000

self.glue_plt.remove()
self.glue_plt = self.fig.axes[0].fill_between(
xlstime, wl95, wl05, facecolor='0.85', lw=1,
edgecolor='0.65', zorder=0)
else:
self.glue_plt.set_visible(False)
else:
self.glue_plt.set_visible(False)
self.draw()

# ----- Handlers: Mouse events

def is_all_btn_raised(self):
Expand Down
3 changes: 2 additions & 1 deletion gwhat/common/icons.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@
'fill_all_data': 'fill_all_data',
'showGrid': 'grid',
'export_data': 'export-data',
'zoom_to_rect': 'zoom_to_rect'}
'zoom_to_rect': 'zoom_to_rect',
'show_glue_wl': 'show_glue_wl'}

ICON_SIZES = {'iconSize': (32, 32),
'iconSize2': (20, 20)}
Expand Down
Binary file added gwhat/ressources/icons_png/show_glue_wl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions gwhat/ressources/icons_scalable/show_glue_wl.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.