From 342ef5d0d1bc7bb664583b1d40c46af913c39fc8 Mon Sep 17 00:00:00 2001 From: Tadd Bindas Date: Sun, 18 Feb 2024 20:44:17 -0500 Subject: [PATCH] Fixed Streamflow outputs that cause a NaN (#12) * added lower bound to streamflow predictions --- .idea/marquette.iml | 2 +- .idea/misc.xml | 2 +- README.md | 9 ++++----- marquette/merit/_streamflow_conversion_functions.py | 6 ++++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.idea/marquette.iml b/.idea/marquette.iml index 2bd4486..a81d4e2 100644 --- a/.idea/marquette.iml +++ b/.idea/marquette.iml @@ -2,7 +2,7 @@ - + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index 39c947b..d37b035 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -3,7 +3,7 @@ - + diff --git a/README.md b/README.md index e26a60d..c3b89ad 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,12 @@ # Marquette [![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff) [![Python](https://img.shields.io/pypi/pyversions/msmhelper)]() - ![image](https://github.com/taddyb/marquette/assets/16233925/4a7b8745-7576-4150-bf4a-9469d44a9425) A river mapping library to take .shp files and create River Network CSVs -## Quick Start -1. clone -2. set up env from `environment.yml` -3. put your data files into the `data/` folder (if it's not there, then create it), then reference them from your config +## Quick Start: +1. `conda create -n marquette python=3.11` +2. `conda activate marquette` +3. `pip install -r requirements.txt` diff --git a/marquette/merit/_streamflow_conversion_functions.py b/marquette/merit/_streamflow_conversion_functions.py index 37d33e8..c8b132d 100644 --- a/marquette/merit/_streamflow_conversion_functions.py +++ b/marquette/merit/_streamflow_conversion_functions.py @@ -124,6 +124,7 @@ def calculate_merit_flow(cfg: DictConfig) -> None: streamflow_predictions_root = zarr.open( Path(cfg.create_streamflow.predictions), mode="r" ) + log.info("Reading Zarr Store") runoff = streamflow_predictions_root.Runoff[:] log.info("Creating areas areas_array") @@ -139,8 +140,9 @@ def calculate_merit_flow(cfg: DictConfig) -> None: log.info("Converting runoff data") streamflow_m3_s_data = runoff * areas_array - mask = np.any(np.isnan(runoff), axis=0) - streamflow_m3_s_data[:, mask] = 0.0 + streamflow_m3_s_data = np.nan_to_num( + streamflow_m3_s_data, nan=1e-6, posinf=1e-6, neginf=1e-6 + ) date_range = pd.date_range( start=cfg.create_streamflow.start_date,