Skip to content

Commit

Permalink
feat: Tour changes (#204)
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasmllr authored Nov 15, 2024
1 parent 4ba9bf0 commit 38a80d0
Show file tree
Hide file tree
Showing 17 changed files with 231 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ <h6 class="card-header text-center" style="background-color: #758fa8; color: #FF
</div>
<div id="csv-data-table-footer">
<small class="text-small">
If no uncertainty data is provided, missing values will be filled in as 0.05 (5%).
If no uncertainty data is provided, missing values will be filled in as 0.1 (10%).
</small>
</div>
<div id="error-messages">
Expand Down Expand Up @@ -184,7 +184,7 @@ <h6 class="card-header text-center" style="background-color: #758fa8; color: #FF
{
element: "#form-header-row",
title: "Import Walkthrough",
content: "Field data can be uploaded using a csv file with example column names specified on the right. When importing data, select which row has these column headings by adjusting the header. Choose the correct separator symbol between values in rows. If uncertainty data is uploaded, missing values will be filled in as 0.05 (5%)."
content: "Field data can be uploaded using a csv file with example column names specified on the right. When importing data, select which row has these column headings by adjusting the header. Choose the correct separator symbol between values in rows. If uncertainty data is uploaded, missing values will be filled in as 0.1 (10%)."
},
{
element: "#enter-data-button",
Expand Down
132 changes: 15 additions & 117 deletions frontend/rctool/templates/rctool/rctool/tour/rctool_tour_intro.html

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions frontend/rctool/templates/rctool/rctool/tour/slide1.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{% load static %}

<div class="carousel-item active" style="margin-bottom:15px;">
<h6 style="color: #003466; margin-bottom: 10px; font-weight:bold;">Let's Get Started</h6>
<small class='text-description'>
Hydrometric field work involves regular visits to a hydrometric gauging station across a range of streamflow conditions. A hydrometric gauging station typically consists of a stage sensor and benchmarks or reference gauge from which water level is referenced. Each field visit should collect three basic observations: reference of stage, measurement of discharge, and control observation. These observations are required to convert stage into discharge through the development of a hydrometric rating curve. (Note: Safety should be considered when collecting these observations, do not attempt any unsafe field work!).
</br><br>The Hydrometric Rating Application (HydRA) is a tool for developing hydrometric rating curves based on observations of stage and discharge. HydRA allows the user to upload observations of stage and discharge and automatically fits a rating curve. Users can adjust the fit according to onsite observations. It then generates a rating equation that can be used for converting stage datasets into discharge.
</small>
<div style="display: flex; align-items: center; justify-content: center;">
<img src="{% static 'images/intro00.jpg' %}" class="slideshow-figure">
</div>
</div>
17 changes: 17 additions & 0 deletions frontend/rctool/templates/rctool/rctool/tour/slide2.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{% load static %}

<div class="carousel-item" style="margin-bottom:15px;">
<h6 style="color: #003466; margin-bottom: 10px; font-weight:bold;">Uploading Data</h6>
<small class='text-description'>
Users may input their hydrometric observations by uploading a .csv file.
Use the comments section to indicate meta-data such as measurement quality or control condition.
If the uncertainty field is left blank, HydRA assumes discharge measurement uncertainty of 10%.
HydRA will plot all stage and discharge observations and then automatically fit a rating curve using the rating equation.
</small>
<div style="display: flex; align-items: center; justify-content: center;">
<img src="{% static 'images/intro01_table.jpg' %}" class="slideshow-figure" style="height: 200px;">
</div>
<div style="display: flex; align-items: center; justify-content: center;">
<img src="{% static 'images/intro01_graph.jpg' %}" class="slideshow-figure" style="height: 200px;">
</div>
</div>
30 changes: 30 additions & 0 deletions frontend/rctool/templates/rctool/rctool/tour/slide3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% load static %}

<div class="carousel-item">
<div class="text-box" style="margin-bottom:20px;">
<h6 style="color: #003466; margin-bottom: 10px; font-weight:bold;">The Rating Equation</h6>
<small class='text-description'>Stage-discharge ratings are generally based on Manning's simplified hydraulic equation below where <em>Q</em> is </small>
<a class='key-term' style="font-weight:normal;" href='#' data-toggle="tooltip" data-placement="bottom" title="Volume of water transported in a certain amount of time.">discharge</a>
<small class='text-description'>, <em>H</em> is </small>
<a class='key-term' style="font-weight:normal;" href='#' data-toggle="tooltip" data-placement="bottom" title="Water height above the bed.">stage</a>
<small class='text-description'>, <em>h<sub>0</sub></em> is the </small>
<a class='key-term' style="font-weight:normal;" href='#' data-toggle="tooltip" data-placement="bottom" title="Gauge height at zero flow.">offset</a>
<small class='text-description'>, C is the </small>
<a class='key-term' style="font-weight:normal;" href='#' data-toggle="tooltip" data-placement="bottom" title="Calibration parameter influenced by channel characteristics.">coefficient</a>
<small class='text-description'>, and b is the </small>
<a class='key-term' style="font-weight:normal;" href='#' data-toggle="tooltip" data-placement="bottom" title="Calibration parameter influenced by the control geometry.">exponent.</a>
</div>
<div style="text-align:center;">
<small class='text-equation'>Q = C ( H - h<sub>0</sub> ) <sup>b</sup></small>
</div>
<div class="text-box" style="margin-top:20px; margin-bottom:20px;">
<a class='key-term' href='#' data-toggle="tooltip" data-placement="bottom" title="Gauge height at zero flow."><em>h<sub>0</sub></em> - offset:</a>
<small class='text-description'>Gauge height at zero flow. This is typically set by the user as the height of the bed.</small><br>
<a class='key-term' href='#' data-toggle="tooltip" data-placement="bottom" title="Calibration parameter influenced by channel characteristics."><em>C</em> - coefficient:</a>
<small class='text-description'>Calibration parameter influenced by channel characteristics such as width, slope, bed roughness.</small><br>
<a class='key-term' href='#' data-toggle="tooltip" data-placement="bottom" title="Calibration parameter influenced by the control geometry."><em>b</em> - exponent:</a>
<small class='text-description'>Calibration parameter influenced by the control geometry. </small>
<a class='key-term' href='#' data-toggle="tooltip" data-placement="bottom" title="Features downstream of the gauge which influence flow.">Controls</a>
<small class='text-description'> are natural or constructed features located downstream of the gauge which influence flow.</small>
</div>
</div>
20 changes: 20 additions & 0 deletions frontend/rctool/templates/rctool/rctool/tour/slide4.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% load static %}


<div class="carousel-item" style="margin-bottom:15px;">
<h6 style="color: #003466; margin-bottom: 10px; font-weight:bold;">Fit for a Stream</h6>
<small class='text-description'>
The HydRA app offers the option to auto-fit rating curves by finding the best equation describing the uploaded field data. The auto-fit function uses a power law model with weights based on discharge measurement uncertainty. A least square method is used to define the auto-fit, this fit may be optimized by adjusting applicable measurements or offsets.
</small>
<br>
<small class='text-description'>
The uncertainty for each discharge measurement is used to weigh the importance of each measurement in the fit.
Implementation details of the power law model can be found in the <a href="https://github.com/bcgov/nr-hydrometric-rating-curve">open source code</a> of HydRA
and the documentation for the <a href="https://lmfit.github.io/lmfit-py/builtin_models.html#lmfit.models.PowerLawModel" target="_blank">lmfit</a> library and its
<a href="https://lmfit.github.io/lmfit-py/model.html#lmfit.model.weights">weights</a>.
</small>

<div style="display: flex; align-items: center; justify-content: center;">
<img src="{% static 'images/intro01_graph.jpg' %}" class="slideshow-figure" style="height: 200px;">
</div>
</div>
43 changes: 43 additions & 0 deletions frontend/rctool/templates/rctool/rctool/tour/slide5.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{% load static %}


<div class="carousel-item" style="margin-bottom:15px;">
<h6 style="color: #003466; margin-bottom: 10px; font-weight:bold;">To Fit and to Fiddle</h6>
<div style="margin-bottom:5px;">
<small class='text-description'>
Common metrics can be used to assess the performance of your hydrometric rating curve. These include the following:
</small>
</div>
<div style="margin-bottom:15px;">
<a class='key-term' href='#' data-toggle="tooltip" data-placement="top" title="The square root of the mean of the squared differences between observed and predicted values.">Root Mean Square Error</a><br>
<small class='text-description'>
The Root Mean Square Error (RMSE) is given by the equation below where <em>Q</em> is discharge and <em>N</em> is number of measurements.
This provides an indication of the average error between observed and predicted discharge values.<br>
In general, a lower RMSE means a better “fit” of the dataset.
HydRA auto-fits the rating curve parameters to, in part, minimize the RMSE. However, there are many sources of uncertainty in hydrometric data and many ways to adjust the “fit” of a rating curve.
Multiple rating curve parameter interpretations may be compared using the RMSE to assess which is the best fit.
</small>
</div>
<div style="display: flex; align-items: center; justify-content: center;">
<img src="{% static 'images/RMSE.png' %}" style="height:60px">
</div>
<div style="margin-bottom:15px;">
<a class='key-term' href='#' "The difference between the predicted and the observed value, divided by the observed value, then multiplied by 100.">Percent Error</a><br>
<small class='text-description'>Percent error is calculated by the following equation where <em>Q</em> is discharge and an example is shown by the figure below. This plot is useful for analyzing the error distribution and identifying outliers.</small>
</div>
<div style="display: flex; align-items: center; justify-content: center;">
<img src="{% static 'images/QPE.png' %}" style="height:60px; margin-bottom:10px;">
</div>
<div style="display: flex; align-items: center; justify-content: center;">
<img src="{% static 'images/fig_rating_error_legend.JPG' %}" class="slideshow-figure">
</div>
<div style="margin-bottom:15px;">
<a class='key-term' href='#'>Mean Average Percentage Error</a><br>
<small class='text-description'>
The Mean Average Percentage Error (MAPE) is calculated similarly to the Percent Error, but averaged over all observed values.
</small>
<div style="display: flex; align-items: center; justify-content: center;">
<img src="{% static 'images/MAPE.png' %}" style="height:60px">
</div>
</div>
</div>
18 changes: 18 additions & 0 deletions frontend/rctool/templates/rctool/rctool/tour/slide6.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{% load static %}


<div class="carousel-item" style="margin-bottom:15px;">
<h6 style="color: #003466; margin-bottom: 10px; font-weight:bold;">Time for a Break</h6>
<small class='text-description'>Stage-discharge relations may have multiple rating</small>
<a class='key-term' href='#' data-toggle="tooltip" data-placement="top" title="Region of a stage-discharge relation.">segments</a>
<small class='text-description'>divided by</small>
<a class='key-term' href='#' data-toggle="tooltip" data-placement="top" title="The transition point of connecting segments.">breakpoints</a>
<small class='text-description'>
. Each segment is a rating equation governed by unique hydraulic controls.
In the example figure below, segment 1 applies to stage between 0.32 m and 0.52 m and is likely influenced by section controls such as channel constrictions, woody debris, or rock ledges. Segment 2 applies to stage values between 0.52 m and 1.4 m and is likely affected by channel
controls such as channel geometry and bed roughness.
</small>
<div style="display: flex; align-items: center; justify-content: center;">
<img src="{% static 'images/fig_breakpoint_example_slide3_greylabels.JPG' %}" class="slideshow-figure" style="height:550px;">
</div>
</div>
38 changes: 38 additions & 0 deletions frontend/rctool/templates/rctool/rctool/tour/slide7.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{% load static %}


<div class="carousel-item" style="margin-bottom:15px;">
<h6 style="color: #003466; margin-bottom: 10px; font-weight:bold;">If the curve fits, use it</h6>
<p>
<small class='text-description'>
<b>Step 1: </b>
Upload field visit information for your period of interest including all relevant fields
</small>
</p>
<p>
<small class='text-description'>
<b>Step 2: </b>
Input the offset as the gauge height, or stage, at zero flow
</small>
</p>
<p>
<small class='text-description'>
<b>Step 3: </b>
Assess the quality of the auto-fit by adjusting curve parameters such as: end points, applicable measurements, offsets. Consult field visit notes, photos and discharge measurement meta-data to assess further. If applicable, add any breakpoints to account for channel complexity at higher or lower stages. Consider comparing multiple interpretations of the fit using the RMSE and MAPE parameters
<br>
<i>*Note: this may take some time, session settings can be saved in the export tab </i>
</small>
</p>
<p>
<small class='text-description'>
<b>Step 4: </b>
Export rating curve parameters as a .pdf or .csv
</small>
</p>
<p>
<small class='text-description'>
<b>Step 5: </b>
Use input values of stage with your rating curve equation to produce modelled discharge, remember to grade your output dataset according to provincial hydrometric RISC standards
</small>
</p>
</div>
14 changes: 14 additions & 0 deletions frontend/rctool/templates/rctool/rctool/tour/slide8.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{% load static %}

<div class="carousel-item" style="margin-bottom:25px;">
<div class="col-md-8 mx-auto">
<div class="text-box" style="margin-bottom: 20px;">
<h6 style="color: #003466; margin-bottom: 10px; font-weight:bold;">Data Review</h6>
<small class='text-description'>HydRA is designed to ONLY produce a rating curve equation and summary report. The complete hydrometric data review process should include the review, correction, and grading of the input stage dataset and the output discharge dataset according to the <a href="https://www2.gov.bc.ca/assets/gov/environment/natural-resource-stewardship/nr-laws-policy/risc/man_bc_hydrometric_stand_v2.pdf" target="_blank">2018 BC Hydrometric RISC standards</a>
</br></br>Applying RISC grades to the output discharge dataset may depend on the performance of the rating equation in predicting discharge or the range of discharge observed during the rating period. All hydrometric data should be reviewed and graded by a qualified professional according to the RISC standards. For more information, consult RISC Table 1-1.</small>
</div>
<div>
<a class="btn btn-secondary btn-block custom-button" style="background-color: #6c747e !important; border-color: #FFFFFF;" href="{% url 'rctool_import' 1 %}"><small>Get Started</small></a>
</div>
</div>
</div>
20 changes: 20 additions & 0 deletions frontend/rctool/templates/rctool/rctool/tour/slide9.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% load static %}


<div class="carousel-item" style="margin-bottom:25px;">
<div class="col-md-8 mx-auto">
<div class="text-box" style="margin-bottom: 20px;">
<h6 style="color: #003466; margin-bottom: 10px; font-weight:bold;">Overview Complete</h6>
<small class='text-description'>All done! Proceed to a walkthrough of the HydRA platform from importing stage-discharge data to development, optimization, saving and exporting a session. Navigate with the arrows to revisit any topics previously covered.</small>
</div>
<div class="text-box" style="margin-bottom: 20px;">
<small class='text-description'>
Please provide any feedback about the use of the tool <a class="text-danger" href="https://submit.digital.gov.bc.ca/app/form/submit?f=b12ba0e1-8e03-40f5-84be-1b705c001efc" target="_blank">here!</a>
The link is also displayed in the footer of all pages.
</small>
</div>
<div>
<a class="btn btn-secondary btn-block custom-button" style="background-color: #6c747e !important; border-color: #FFFFFF;" href="{% url 'rctool_import' 1 %}"><small>Get Started</small></a>
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions frontend/rctool/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,8 @@ def rctool_develop_initialize(request):

# fill in missing uncertainty values
if "uncertainty" not in field_df_raw:
field_df_raw["uncertainty"] = 0.05
field_df_raw.fillna({"uncertainty": 0.05}, inplace=True)
field_df_raw["uncertainty"] = 0.10
field_df_raw.fillna({"uncertainty": 0.10}, inplace=True)

field_df_raw["uncertainty"] = field_df_raw["uncertainty"].round(decimals=3)
field_df_raw["datetime"] = field_df_raw["datetime"].apply(str)
Expand Down
Binary file added frontend/static/images/MAPE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/static/images/QPE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/static/images/RMSE.JPG
Binary file not shown.
Binary file modified frontend/static/images/RMSE.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed frontend/static/images/error_percent.JPG
Binary file not shown.

0 comments on commit 38a80d0

Please sign in to comment.