From 43ef67a859005bc6652b2c1cc825d476f121bfa5 Mon Sep 17 00:00:00 2001 From: Craig Stephenson Date: Fri, 31 Jul 2026 11:31:00 -0800 Subject: [PATCH 1/2] Fix JSON vs. CSV Blaskey-adjusted discrepancy. --- routes/arctic_hydrology.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/routes/arctic_hydrology.py b/routes/arctic_hydrology.py index ad9bd216..1f525e6c 100644 --- a/routes/arctic_hydrology.py +++ b/routes/arctic_hydrology.py @@ -823,6 +823,14 @@ def run_get_arctic_hydrology_modeled_climatology(stream_id): data_dict = populate_feature_attributes(data_dict, gdf) data_dict = prune_nulls_with_max_intensity(data_dict) + # apply GCM-projected changes to Blaskey climatology if source is "gcm_diff_applied_to_blaskey" + # PGW models without a 1990-2021 historical era are silently absent from this source; + # they are only available via source=original_gcm. + if source == "gcm_diff_applied_to_blaskey": + data_dict["data"] = calculate_and_apply_gcm_diffs_to_blaskey_climatology( + data_dict["data"] + ) + if request.args.get("format") == "csv": try: return create_csv( @@ -837,14 +845,6 @@ def run_get_arctic_hydrology_modeled_climatology(stream_id): except Exception: return render_template("500/server_error.html"), 500 - # apply GCM-projected changes to Blaskey climatology if source is "gcm_diff_applied_to_blaskey" - # PGW models without a 1990-2021 historical era are silently absent from this source; - # they are only available via source=original_gcm. - if source == "gcm_diff_applied_to_blaskey": - data_dict["data"] = calculate_and_apply_gcm_diffs_to_blaskey_climatology( - data_dict["data"] - ) - return jsonify(data_dict) except Exception as exc: @@ -966,6 +966,11 @@ def run_get_arctic_hydrology_wt_modeled_climatology(stream_id): data_dict = populate_feature_attributes(data_dict, gdf) data_dict = prune_nulls_with_max_intensity(data_dict) + if source == "gcm_diff_applied_to_blaskey": + data_dict["data"] = calculate_and_apply_gcm_diffs_to_blaskey_wt_climatology( + data_dict["data"] + ) + if request.args.get("format") == "csv": try: return create_csv( @@ -980,11 +985,6 @@ def run_get_arctic_hydrology_wt_modeled_climatology(stream_id): except Exception: return render_template("500/server_error.html"), 500 - if source == "gcm_diff_applied_to_blaskey": - data_dict["data"] = calculate_and_apply_gcm_diffs_to_blaskey_wt_climatology( - data_dict["data"] - ) - return jsonify(data_dict) except Exception as exc: From 19813204e60392d13a806c799f076ced86699e24 Mon Sep 17 00:00:00 2001 From: Craig Stephenson Date: Tue, 4 Aug 2026 11:12:31 -0800 Subject: [PATCH 2/2] Move historical model above the others in CSVs. --- routes/arctic_hydrology.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/routes/arctic_hydrology.py b/routes/arctic_hydrology.py index 1f525e6c..9427c2d2 100644 --- a/routes/arctic_hydrology.py +++ b/routes/arctic_hydrology.py @@ -400,6 +400,10 @@ def package_stats_data(stream_id, ds): if not np.isnan(v) } + # Move the historical model above the rest. + historical_data = stats_dict["data"].pop("historical") + stats_dict["data"] = {"historical": historical_data, **stats_dict["data"]} + return stats_dict @@ -467,6 +471,10 @@ def package_hydrograph_data(stream_id, datasets): model_dict[era] = rows + # Move the historical model above the rest. + historical_data = hydrograph_dict["data"].pop("historical") + hydrograph_dict["data"] = {"historical": historical_data, **hydrograph_dict["data"]} + return hydrograph_dict