Skip to content

Commit

Permalink
Merge pull request #14 from BYU-Hydroinformatics/ui-updates
Browse files Browse the repository at this point in the history
Interface rework
  • Loading branch information
rileyhales authored Oct 23, 2020
2 parents ba7c188 + c4df3b2 commit 6a91f76
Show file tree
Hide file tree
Showing 20 changed files with 699 additions and 398 deletions.
2 changes: 1 addition & 1 deletion install.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This file should be committed to your app code.
version: 1.5.1
version: 1.7
# This should match the app - package name in your setup.py
name: geoglows_hydroviewer

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@

setup(
name=release_package,
version='1.5.1',
version='1.7',
description='Interfaces with the GEOGloWS ECMWF Streamflow model developed by the BYU Hydroinformatics lab.',
long_description='Contains an interactive map interface for retrieving data using the ESRI Dynamic Mapping Service '
'retrieved from the Living Atlas. Includes tools for extracting a subset of the delineated '
' shapefiles and creating a customized hydroviewer interface.',
keywords='geoglows, ',
keywords='geoglows, ecmwf, streamflow',
author='Riley Hales, Kyler Ashby',
author_email='',
url='',
Expand Down
46 changes: 26 additions & 20 deletions tethysapp/geoglows_hydroviewer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ class GeoglowsHydroviewer(TethysAppBase):
"""
Tethys app class for the GEOGloWS ECMWF Streamflow Hydroviewer
"""

name = 'GEOGloWS ECMWF Streamflow Hydroviewer'
index = 'geoglows_hydroviewer:home'
icon = 'geoglows_hydroviewer/images/water.jpeg'
Expand All @@ -20,7 +19,6 @@ class GeoglowsHydroviewer(TethysAppBase):

def url_maps(self):
UrlMap = url_map_maker(self.root_url)

return (
# the geoglows hydroviewer page (home page)
UrlMap(name='home',
Expand All @@ -31,15 +29,18 @@ def url_maps(self):
controller=f'{self.package}.controllers.hydroshare_view'),

# handles the requests to get the various plots in the app modals
UrlMap(name='get_streamflow',
url=f'{self.root_url}/hydroviewer/getStreamflow',
controller=f'{self.package}.controllers.get_streamflow'),
UrlMap(name='getForecastData',
url=f'{self.root_url}/hydroviewer/getForecastData',
controller=f'{self.package}.controllers.get_forecast_data'),
UrlMap(name='getHistoricalData',
url=f'{self.root_url}/hydroviewer/getHistoricalData',
controller=f'{self.package}.controllers.get_historical_data'),
UrlMap(name='getBiasAdjusted',
url=f'{self.root_url}/hydroviewer/getBiasAdjusted',
controller=f'{self.package}.controllers.get_bias_adjusted'),
UrlMap(name='upload_new_observations',
url=f'{self.root_url}/hydroviewer/upload_new_observations',
controller=f'{self.package}.manage_uploaded_observations.upload_new_observations'),
UrlMap(name='correct_bias',
url=f'{self.root_url}/hydroviewer/correctBias',
controller=f'{self.package}.controllers.correct_bias'),

# some other utilities
UrlMap(name='find_reach_id',
Expand All @@ -51,7 +52,7 @@ def url_maps(self):
url=f'{self.root_url}/getGaugeGeoJSON',
controller=f'{self.package}.controllers.get_gauge_geojson'),

# geoglows hydroviewer creator main pages
# geoglows hydroviewer creator main pages (navigable)
UrlMap(name='geoglows_hydroviewer_creator',
url=f'{self.root_url}/creator',
controller=f'{self.package}.controllers_creator.home'),
Expand All @@ -62,15 +63,15 @@ def url_maps(self):
url=f'{self.root_url}/creator/render',
controller=f'{self.package}.controllers_creator.render_hydroviewer'),

# creator pages and urls for adding/deleting projects
# urls for adding/deleting projects (non-navigable)
UrlMap(name='add_new_project',
url=f'{self.root_url}/creator/add-new-project',
controller=f'{self.package}.controllers_creator.add_new_project'),
UrlMap(name='delete_existing_project',
url=f'{self.root_url}/creator/delete_existing_project',
controller=f'{self.package}.controllers_creator.delete_existing_project'),

# geoprocessing shapefiles urls
# geoprocessing shapefiles urls (non-navigable)
UrlMap(name='geoprocess_idregion',
url=f'{self.root_url}/creator/project/geoprocessing/geoprocess_idregion',
controller=f'{self.package}.controllers_creator_geoprocess.geoprocess_hydroviewer_idregion'),
Expand All @@ -81,24 +82,28 @@ def url_maps(self):
url=f'{self.root_url}/creator/project/geoprocessing/geoprocess_zip_shapefiles',
controller=f'{self.package}.controllers_creator_geoprocess.geoprocess_zip_shapefiles'),

# project editing urls and pages
# project boundary editing pages (navigable)
UrlMap(name='draw_boundaries',
url=f'{self.root_url}/creator/project/edit/draw_boundaries',
controller=f'{self.package}.controllers_creator.draw_hydroviewer_boundaries'),
UrlMap(name='choose_boundaries',
url=f'{self.root_url}/creator/project/edit/choose_boundaries',
controller=f'{self.package}.controllers_creator.choose_hydroviewer_boundaries'),
UrlMap(name='upload_boundaries',
url=f'{self.root_url}/creator/project/edit/upload_boundaries',
controller=f'{self.package}.controllers_creator.upload_boundary'),
controller=f'{self.package}.controllers_creator.draw_boundaries'),
UrlMap(name='choose_boundary_country',
url=f'{self.root_url}/creator/project/edit/choose_boundary_country',
controller=f'{self.package}.controllers_creator.choose_boundary_country'),
UrlMap(name='boundary_by_outlet',
url=f'{self.root_url}/creator/project/edit/boundary_by_outlet',
controller=f'{self.package}.controllers_creator.boundary_by_outlet'),
# project boundary save/retrieve urls (non-navigable)
UrlMap(name='save_boundaries',
url=f'{self.root_url}/creator/project/edit/save_boundaries',
controller=f'{self.package}.controllers_creator.save_boundaries'),
UrlMap(name='find_upstream_boundaries',
url=f'{self.root_url}/creator/project/edit/find_upstream_boundaries',
controller=f'{self.package}.controllers_creator.find_upstream_boundaries'),
UrlMap(name='retrieve_boundaries',
url=f'{self.root_url}/creator/project/edit/retrieve_boundaries',
controller=f'{self.package}.controllers_creator.retrieve_hydroviewer_boundaries'),

# project and shapefile exporting options
# project and shapefile exporting options (non-navigable)
UrlMap(name='export_zipfile',
url=f'{self.root_url}/creator/project/export/zipfile',
controller=f'{self.package}.controllers_creator_export.export_zipfile'),
Expand All @@ -113,6 +118,7 @@ def url_maps(self):
controller=f'{self.package}.controllers_creator_export.export_html'),
)


def custom_settings(self):
return (
CustomSetting(
Expand Down
42 changes: 25 additions & 17 deletions tethysapp/geoglows_hydroviewer/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
('North America', 'north_america-geoglows', '43ae93136e10439fbf2530e02156caf0'),
)

gsf.ENDPOINT = gsf.AZURE


def home(request):
"""
Expand Down Expand Up @@ -63,11 +65,9 @@ def home(request):
context = {
# constants
'endpoint': gsf.ENDPOINT,

# uploaded data
'uploaded_observations': uploaded_observations,
'upload_new_observation': upload_new_observation,

# gauge_networks
'gauge_networks': gauge_networks,
}
Expand Down Expand Up @@ -125,49 +125,57 @@ def hydroshare_view(request):
context = {
# constants
'endpoint': gsf.ENDPOINT,

# uploaded data
'uploaded_observations': uploaded_observations,
'upload_new_observation': upload_new_observation,

# gauge_networks
'gauge_networks': gauge_networks,

# controls
'watersheds_select_input': watersheds_select_input,
}

return render(request, 'geoglows_hydroviewer/geoglows_hydroviewer.html', context)


def get_streamflow(request):
def get_forecast_data(request):
# get data
s = requests.Session()
s.get(gsf.ENDPOINT.replace('api/', ''))
reach_id = request.GET['reach_id']
stats = gsf.forecast_stats(reach_id, s=s)
# rec = gsf.forecast_records(reach_id)
ens = gsf.forecast_ensembles(reach_id, s=s)
rper = gsf.return_periods(reach_id, s=s)
s.close()
# process data
title_headers = {'Reach ID': reach_id}
# return json of plot html
return JsonResponse(dict(
plot=gpp.forecast_stats(stats, rper, titles=title_headers, outformat='plotly_html'),
table=gpp.probabilities_table(stats, ens, rper),
))


def get_historical_data(request):
# get data
s = requests.Session()
reach_id = request.GET['reach_id']
hist = gsf.historic_simulation(reach_id, s=s)
rper = gsf.return_periods(reach_id)
rper = gsf.return_periods(reach_id, s=s)
s.close()
# process data
dayavg = hydrostats.data.daily_average(hist, rolling=True)
monavg = hydrostats.data.monthly_average(hist)
title_headers = {'Reach ID': reach_id}
# return json of plot html
return JsonResponse(dict(
# fp=gpp.hydroviewer(rec, stats, ens, rper, titles=title_headers, outformat='plotly_html', record_days=0),
fp=gpp.forecast_stats(stats, rper, titles=title_headers, outformat='plotly_html'),
hp=gpp.historic_simulation(hist, rper, titles=title_headers, outformat='plotly_html'),
dp=gpp.daily_averages(dayavg, titles=title_headers, outformat='plotly_html'),
mp=gpp.monthly_averages(monavg, titles=title_headers, outformat='plotly_html'),
plot=gpp.historic_simulation(hist, rper, titles=title_headers, outformat='plotly_html'),
table=gpp.return_periods_table(rper),
dayavg=gpp.daily_averages(dayavg, titles=title_headers, outformat='plotly_html'),
monavg=gpp.monthly_averages(monavg, titles=title_headers, outformat='plotly_html'),
fdp=gpp.flow_duration_curve(hist, titles=title_headers, outformat='plotly_html'),
prob_table=gpp.probabilities_table(stats, ens, rper),
rp_table=gpp.return_periods_table(rper),
))


def correct_bias(request):
def get_bias_adjusted(request):
# accept the parameters from the user
data = request.GET.dict()
network = data.get('gauge_network', False)
Expand Down
Loading

0 comments on commit 6a91f76

Please sign in to comment.