From 0eeaafec43c6fccf197f2b7e9eb3827a79b3e3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20M=C3=BCller?= Date: Fri, 8 Mar 2024 00:52:01 -0800 Subject: [PATCH] Pdf fixes and other recent issues (#73) * min width in tour template * slide changes Jon requested * updated sample data * removed header for sample data, so it can be imported quickly * fixed tooltip for rating error rounding incorrectly * added bold line in error plot to clearly show optimization target * made compare curve input smaller * added notes and more info by Jons request * hope to fix problem of 0 Q from autofit. needs testing * increased sig figs on tooltip * auto formatting and fixing PDF plots * unabbridged equation in pdf --- HydRA Test Curves_20240115/RC_LCR2122.csv | 20 -- HydRA Test Curves_20240115/RC_Lizard.csv | 6 - HydRA Test Curves_20240115/RC_cook1.csv | 20 -- HydRA Test Curves_20240115/RC_cook2.csv | 10 - HydRA Test Curves_20240115/RC_grand.csv | 24 -- HydRA Test Curves_20240115/RC_random.csv | 22 -- HydRA Test Curves_20240115/RC_shelly.csv | 11 - .../rctool/develop/develop_table_rating.html | 42 ++- .../rctool/rctool/develop/rctool_develop.html | 2 + .../rctool/develop/rctool_develop_js.html | 39 +- .../rctool/rctool/export/rctool_export.html | 3 +- .../rctool/export/rctool_export_pdf.html | 4 +- .../rctool/rctool/tour/rctool_tour_intro.html | 33 +- frontend/rctool/views.py | 340 ++++++++++++------ frontend/static/images/RMSE.JPG | Bin 21493 -> 25698 bytes frontend/static/sample_data/sample_data.csv | 35 +- 16 files changed, 336 insertions(+), 275 deletions(-) delete mode 100644 HydRA Test Curves_20240115/RC_LCR2122.csv delete mode 100644 HydRA Test Curves_20240115/RC_Lizard.csv delete mode 100644 HydRA Test Curves_20240115/RC_cook1.csv delete mode 100644 HydRA Test Curves_20240115/RC_cook2.csv delete mode 100644 HydRA Test Curves_20240115/RC_grand.csv delete mode 100644 HydRA Test Curves_20240115/RC_random.csv delete mode 100644 HydRA Test Curves_20240115/RC_shelly.csv diff --git a/HydRA Test Curves_20240115/RC_LCR2122.csv b/HydRA Test Curves_20240115/RC_LCR2122.csv deleted file mode 100644 index 2917e17..0000000 --- a/HydRA Test Curves_20240115/RC_LCR2122.csv +++ /dev/null @@ -1,20 +0,0 @@ -datetime,discharge,stage,uncertainty,comments -2021-11-24 10:27,0.9085,0.492,8,"23 panels, max 9.2%" -2021-12-07 11:15,1.751439049,0.501,3.11, -2021-12-16 10:59,1.1704,0.457,8,"22 panels, max 7.4%" -2022-01-14 11:05,4.891958877,0.73,2.67, -2022-02-07 11:38,1.127406583,0.459,3.27, -2022-03-23 10:16,2.319489087,0.55,2.65, -2022-03-30 14:45,0.843988357,0.515,2.94, -2022-04-22 13:56,0.569,0.397,,"20 panels, max 13.8%" -2022-05-03 17:29,0.465,0.377,,"20 panels, max 13.6%" -2022-05-18 14:37,0.981925337,0.437,3.23, -2022-07-19 9:53,0.131,0.277,,"20 panels, max 14.3%" -2022-07-19 10:09,0.1472,0.278,3, -2022-08-04 9:54,0.152,0.283,,"20 panels, max 11.9%" -2022-08-04 12:30,0.183566024,0.286,3.17, -2022-08-31 11:51,0.111,0.263,,"20 panels, max 9.2%" -2022-09-09 10:02,0.101913626,0.261,2.59, -2022-10-20 8:40,0.0813,0.243,2.9, -2022-12-12 10:55,1.672120912,0.4875,3.13, -2022-12-12 11:02,1.631,0.485,2.7, diff --git a/HydRA Test Curves_20240115/RC_Lizard.csv b/HydRA Test Curves_20240115/RC_Lizard.csv deleted file mode 100644 index 4a2e620..0000000 --- a/HydRA Test Curves_20240115/RC_Lizard.csv +++ /dev/null @@ -1,6 +0,0 @@ -datetime,discharge,stage,uncertainty,comments -2021-08-19 11:45,0.364,0.302,0.05,"old control, do not use MMT" -2022-07-20 8:54,0.612,0.225,0.05,suggested PZF -0.150 -2022-07-27 15:27,0.482,0.193,0.05, -2022-09-07 11:00,0.383,0.125,0.05, -2022-10-18 11:33,0.201,0.097,0.05, diff --git a/HydRA Test Curves_20240115/RC_cook1.csv b/HydRA Test Curves_20240115/RC_cook1.csv deleted file mode 100644 index 49fc7fe..0000000 --- a/HydRA Test Curves_20240115/RC_cook1.csv +++ /dev/null @@ -1,20 +0,0 @@ -datetime,discharge,stage,uncertainty,comments -2023-07-25 10:50:08,0.024789663,9.0635,0.099,approx PZF 9.0 -2023-05-08 13:23:17,0.468793188,9.193,0.031, -2023-04-18 12:45:02,1.0337748,9.263,0.042, -2023-02-06 12:00:00,1.080884219,9.27,0.032, -2022-08-18 10:15:00,0.028,9.037,0.049, -2022-07-19 10:11:16,0.093839378,9.065,0.03, -2022-07-19 10:45:00,0.088,9.065,0.033, -2022-04-13 13:00:00,0.557,9.177,0.03, -2022-03-09 11:00:00,0.406728145,9.16,0.03, -,,,, -,,,, -,,,, -,,,, -,,,, -,,,, -,,,, -,,,, -,,,, -,,,, diff --git a/HydRA Test Curves_20240115/RC_cook2.csv b/HydRA Test Curves_20240115/RC_cook2.csv deleted file mode 100644 index 9525aee..0000000 --- a/HydRA Test Curves_20240115/RC_cook2.csv +++ /dev/null @@ -1,10 +0,0 @@ -datetime,discharge,stage,stage_raw,uncertainty,comments -2023-07-25 10:50,0.024789663,0.3085,9.0635,0.099,approx PZF .245 -2023-05-08 13:23,0.468793188,0.438,9.193,0.031, -2023-04-18 12:45,1.0337748,0.508,9.263,0.042, -2023-02-06 12:00,1.080884219,0.515,9.27,0.032, -2022-08-18 10:15,0.028,0.282,9.037,0.049, -2022-07-19 10:11,0.093839378,0.31,9.065,0.03, -2022-07-19 10:45,0.088,0.31,9.065,0.033, -2022-04-13 13:00,0.557,0.422,9.177,0.03, -2022-03-09 11:00,0.406728145,0.405,9.16,0.03, diff --git a/HydRA Test Curves_20240115/RC_grand.csv b/HydRA Test Curves_20240115/RC_grand.csv deleted file mode 100644 index 5caaf45..0000000 --- a/HydRA Test Curves_20240115/RC_grand.csv +++ /dev/null @@ -1,24 +0,0 @@ -datetime,stage,discharge,Uncertainty,Comments -2023-07-26 12:57:30,0.186,0.002772154,,"PZF 0.018 , BP @ 0.395M" -2023-05-26 13:02:30,0.198,0.005309356,,minor debris -2023-04-19 13:51:15,0.2965,0.039120759,6.8,section -2023-03-03 15:42:40,0.442,0.161655436,3.7,submerged -2023-02-12 15:15:00,0.368,0.066844777,3.683071598,section -2022-11-04 13:00:00,0.24,0.016708148,8, -2022-09-19 16:00:00,0.188,0.00292457,8, -2022-08-17 10:00:00,0.19,0.003312321,5, -2022-07-18 15:00:00,0.21,0.004,, -2021-08-17 09:00:00,0.285,0.002114971,,debris -2019-09-19 13:45:00,0.23,0.01125648,10, -2019-07-29 11:15:00,0.196,0.003352529,10, -2019-06-10 10:40:00,0.209,0.00646972,8, -2018-06-05 12:00:00,0.218,0.007823333,8, -2017-11-27 13:30:00,0.54,0.4602,3.6, -2017-07-12 13:30:00,0.205,0.004951,8, -2017-06-13 16:00:00,0.215,0.007517333,8, -2014-12-19 11:30:00,0.498,0.2883,,submerged -2014-02-17 13:00:00,0.658,1.063,8,submerged -2013-10-03 12:00:00,0.318,0.0388,5, -2013-06-25 09:30:00,0.247,0.0162,8, -2012-10-11 15:00:00,0.203,0.00382,5, -2012-09-12 13:00:00,0.198,0.002749,8, diff --git a/HydRA Test Curves_20240115/RC_random.csv b/HydRA Test Curves_20240115/RC_random.csv deleted file mode 100644 index 8d8e49e..0000000 --- a/HydRA Test Curves_20240115/RC_random.csv +++ /dev/null @@ -1,22 +0,0 @@ -date,time,DateTime,discharge,stage,uncertainty,comments -2022-03-25,12:00:00,2022-03-25 12:00,2.796,0.759,0.004, -2021-06-25,0:48:23,2021-06-25 0:48,2.827,0.774,0.008, -2020-11-04,14:45:54,2020-11-04 14:45,3.816,2.792,0.060, -2020-09-23,6:43:37,2020-09-23 6:43,3.530,1.838,0.095, -2020-08-22,3:12:13,2020-08-22 3:12,4.587,5.577,0.041, -2020-03-24,11:10:33,2020-03-24 11:10,4.328,3.894,0.001, -2019-05-30,3:34:14,2019-05-30 3:34,3.805,2.830,0.098, -2018-08-31,12:10:31,2018-08-31 12:10,3.588,1.945,0.022, -2017-09-15,2:11:41,2017-09-15 2:11,3.808,2.590,0.023, -2017-06-13,5:36:18,2017-06-13 5:36,4.358,4.321,0.004, -2016-06-18,14:06:14,2016-06-18 14:06,5.582,8.625,0.029, -2016-02-14,8:54:33,2016-02-14 8:54,5.537,9.343,0.021, -2015-06-18,1:21:39,2015-06-18 1:21,5.468,8.690,0.063, -2015-02-16,13:05:51,2015-02-16 13:05,2.377,0.349,0.047, -2014-09-30,0:54:20,2014-09-30 0:54,5.054,9.185,0.080, -2014-03-14,22:27:11,2014-03-14 22:27,5.047,9.827,0.001, -2013-03-26,21:35:10,2013-03-26 21:35,4.690,6.033,0.064, -2013-03-04,0:46:13,2013-03-04 0:46,4.009,3.816,0.046, -2012-05-21,21:36:24,2012-05-21 21:36,5.416,9.181,0.018, -,,,,,, -,,,,,, diff --git a/HydRA Test Curves_20240115/RC_shelly.csv b/HydRA Test Curves_20240115/RC_shelly.csv deleted file mode 100644 index 64f1f98..0000000 --- a/HydRA Test Curves_20240115/RC_shelly.csv +++ /dev/null @@ -1,11 +0,0 @@ -datetime,discharge,stage,uncertainty,comments -2021-11-22 10:00,0.13,0.33,0.05,"21 panels, some snow on ground" -2021-04-06 14:00,0.01,0.24,0.05,19 panels -2021-03-08 9:00,0.05,0.28,0.03,"35 panels, recent high flow event in December" -2021-02-24 13:00,0.03,0.27,0.05,"21 panels, rain overnight" -2021-01-28 14:00,0.12,0.32,0.04,"21 panels, good mmt" -2021-01-11 10:00,0.18,0.39,0.04,"21 panels, recent high flows after consistent rain. High turbidity" -2020-12-30 11:30,0.36,0.45,0.03,"24 panels, recent high flows and heavy rains" -2020-11-24 13:30,0.03,0.26,0.04,21 panels. Rain overnight -2021-12-13 8:00,0.29,0.4,0.04,20 panels -2020-01-12 17:00,0.67,0.55,0.03,"23 panels, recent rain on snow event, creek rising during mmt" diff --git a/frontend/rctool/templates/rctool/rctool/develop/develop_table_rating.html b/frontend/rctool/templates/rctool/rctool/develop/develop_table_rating.html index eebdab3..6640bd6 100644 --- a/frontend/rctool/templates/rctool/rctool/develop/develop_table_rating.html +++ b/frontend/rctool/templates/rctool/rctool/develop/develop_table_rating.html @@ -9,8 +9,8 @@ coefficient exponent offset - start point - end point + start point
(stage in m) + end point
(stage in m) RMSE

compare

@@ -40,32 +40,52 @@ {% endif %} - + - + - + - + - + - + -

+

- +
diff --git a/frontend/rctool/templates/rctool/rctool/develop/rctool_develop.html b/frontend/rctool/templates/rctool/rctool/develop/rctool_develop.html index ac85361..74f99b2 100644 --- a/frontend/rctool/templates/rctool/rctool/develop/rctool_develop.html +++ b/frontend/rctool/templates/rctool/rctool/develop/rctool_develop.html @@ -207,7 +207,9 @@

|
", onEnd: function (tour) { sessionStorage.setItem("tourStatus", false); $('#tour_request_status_id').val("1") diff --git a/frontend/rctool/templates/rctool/rctool/develop/rctool_develop_js.html b/frontend/rctool/templates/rctool/rctool/develop/rctool_develop_js.html index f095bea..ea5f282 100644 --- a/frontend/rctool/templates/rctool/rctool/develop/rctool_develop_js.html +++ b/frontend/rctool/templates/rctool/rctool/develop/rctool_develop_js.html @@ -215,6 +215,13 @@ rcDict = {'data':rcData, 'parameters':rcParam}; // 3.5 Update HTML equation parameters and user input fields + // make sure all bounds for Q are at minimum 0.001: + if (rcParam[0].seg_bounds[0][1] < 0.001) { + rcParam[0].seg_bounds[0][1] = 0.001; + } + if (rcParam[0].seg_bounds[1][1] < 0.001) { + rcParam[0].seg_bounds[1][1] = 0.001; + } var segNumStr = String(idx + 1); document.getElementById('segment' + segNumStr + '-const').innerHTML = C.toFixed(2); document.getElementById('segment' + segNumStr + '-exp').innerHTML = slope.toFixed(2); @@ -501,7 +508,6 @@ ----------------------------------------------------------------------------------------------------------------------------------------------*/ function setEndpoints(segEP, pointEP, coordEP, valueEP) { - // 1. COLLECT AND INITIATE PARAMETERS if (rcParam.length == 2) { var newSegBounds = [rcParam[0].seg_bounds, rcParam[1].seg_bounds]; @@ -1289,12 +1295,12 @@ } } } - label.push(['H: ' + h_field.toFixed(2) + ' m']); - label.push(['Q: ' + q_field.toFixed(2) + ' m³/s']); + label.push(['H: ' + h_field.toFixed(3) + ' m']); + label.push(['Q: ' + q_field.toFixed(3) + ' m³/s']); label.push(['date: ' + fielddatacsv.datetime[idx]]); if (h_model !== null) { - label.push(['H shift: ' + (h_model - h_field).toFixed(2) + ' m']) - label.push(['H shift: ' + (h_model - h_field).toFixed(2) + ' m']) + label.push(['H shift: ' + (h_model - h_field).toFixed(3) + ' m']) + label.push(['H shift: ' + (h_model - h_field).toFixed(3) + ' m']) } //if (q_model !== null){ // label.push(['Q model: ' + q_model.toFixed(2) + ' m³/s']); @@ -1457,14 +1463,20 @@ display: true, text: 'Q rated vs Q field (% change)' }, - beginAtZero: false + beginAtZero: true, + // make zero tick thicker: + grid: { + color: function(context) { + return context.tick.value === 0 ? 'black' : 'rgba(0,0,0,0.1)'; + }, + }, }, y: { title: { display: true, text: 'Stage H (m)' }, - beginAtZero: false + beginAtZero: false, } }, @@ -1502,21 +1514,17 @@ let q_model = calc_q_model(h_field, rcParam[seg].const, rcParam[seg].exp, rcParam[seg].offset) // r_percent = 100 * (q_field - q_model) / q_field let q_field = - 100 * q_model / (r_percent - 100) - let q_field_rounded = Math.round(q_field * 100) / 100 + let q_field_rounded = Math.round(q_field * 1000) / 1000 let h_model = calc_h_model(q_field, rcParam[seg].const, rcParam[seg].exp, rcParam[seg].offset) let r_volumetric = r_percent/100 * q_field - for (var idx in fielddatacsv.stage) { if (fielddatacsv.stage[idx] == h_field && fielddatacsv.discharge[idx] == q_field_rounded) { - label.push(['H: ' + h_field.toFixed(2) + ' m']); - label.push(['Q: ' + q_field.toFixed(2) + ' m³/s']); + label.push(['H: ' + h_field.toFixed(3) + ' m']); + label.push(['Q: ' + q_field.toFixed(3) + ' m³/s']); label.push(['date: ' + fielddatacsv.datetime[idx]]); if (h_model !== null) { - label.push(['H shift: ' + (h_model - h_field).toFixed(2) + ' m']) + label.push(['H shift: ' + (h_model - h_field).toFixed(3) + ' m']) } - //if (q_model !== null){ - // label.push(['Q model: ' + q_model.toFixed(2) + ' m³/s']); - //} if (r_percent !== null){ if (r_percent > 0){ // show + sign for positive values @@ -1527,6 +1535,7 @@ label.push(['R volume:' + r_volumetric.toFixed(2) + ' m3/s']); } } + break; } } } diff --git a/frontend/rctool/templates/rctool/rctool/export/rctool_export.html b/frontend/rctool/templates/rctool/rctool/export/rctool_export.html index 5017638..72da451 100644 --- a/frontend/rctool/templates/rctool/rctool/export/rctool_export.html +++ b/frontend/rctool/templates/rctool/rctool/export/rctool_export.html @@ -18,7 +18,8 @@
Export
-
+
+

Note: The rating curve generated by HydRA produces an equation ONLY. All input (stage) and output (discharge) datasets including any discrete measurements of stage and discharge must be reviewed and graded according to the provincial hydrometric RISC standards.

{% csrf_token %} diff --git a/frontend/rctool/templates/rctool/rctool/export/rctool_export_pdf.html b/frontend/rctool/templates/rctool/rctool/export/rctool_export_pdf.html index 9b46e60..898b4db 100644 --- a/frontend/rctool/templates/rctool/rctool/export/rctool_export_pdf.html +++ b/frontend/rctool/templates/rctool/rctool/export/rctool_export_pdf.html @@ -109,7 +109,7 @@
Model Parameters
{{ rc.parameters.0.label }} - Q = {{ rc.parameters.0.const|floatformat:3 }} ( H {{ offsets_val.0 }} ){{ rc.parameters.0.exp|floatformat:3 }} + Q = {{ rc.parameters.0.const }} ( H {{ offsets_val.0 }} ){{ rc.parameters.0.exp }} {{ rc.parameters.0.seg_bounds.0.0|floatformat:3 }} , {{ rc.parameters.0.seg_bounds.1.0|floatformat:3}} {{ rc.parameters.0.rmse|floatformat:3 }} @@ -117,7 +117,7 @@
Model Parameters
{% if rc.parameters.1 %} {{ rc.parameters.1.label }} - Q = {{ rc.parameters.1.const|floatformat:3 }}( H {{ offsets_val.1 }}){{ rc.parameters.1.exp|floatformat:3 }} + Q = {{ rc.parameters.1.const }}( H {{ offsets_val.1 }}){{ rc.parameters.1.exp }} {{ rc.parameters.1.seg_bounds.0.0|floatformat:3 }} , {{ rc.parameters.1.seg_bounds.1.0|floatformat:3 }} {{ rc.parameters.1.rmse|floatformat:3 }} diff --git a/frontend/rctool/templates/rctool/rctool/tour/rctool_tour_intro.html b/frontend/rctool/templates/rctool/rctool/tour/rctool_tour_intro.html index 8be589b..34ab337 100644 --- a/frontend/rctool/templates/rctool/rctool/tour/rctool_tour_intro.html +++ b/frontend/rctool/templates/rctool/rctool/tour/rctool_tour_intro.html @@ -32,7 +32,8 @@
Let's Get Started
- 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!). 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. + 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!). +

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.
@@ -50,22 +51,6 @@
Uploading Dat
-