Skip to content

Commit

Permalink
Fixed Streamflow outputs that cause a NaN (#12)
Browse files Browse the repository at this point in the history
* added lower bound to streamflow predictions
  • Loading branch information
taddyb authored Feb 19, 2024
1 parent 6955a85 commit 342ef5d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .idea/marquette.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -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`

6 changes: 4 additions & 2 deletions marquette/merit/_streamflow_conversion_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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,
Expand Down

0 comments on commit 342ef5d

Please sign in to comment.