From 8f6048dbfe0ff9736d2772e3c4de5a39b99ebaa2 Mon Sep 17 00:00:00 2001 From: Adam Wlostowski <66840445+awlostowski-noaa@users.noreply.github.com> Date: Wed, 16 Mar 2022 10:52:33 -0400 Subject: [PATCH] update logic becuase the waterbody_types_df_sub may be empty for sims without waterbodies" (#538) Co-authored-by: awlostowski-noaa --- src/troute-routing/troute/routing/compute.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/troute-routing/troute/routing/compute.py b/src/troute-routing/troute/routing/compute.py index 53e6693cf..a84761ec2 100644 --- a/src/troute-routing/troute/routing/compute.py +++ b/src/troute-routing/troute/routing/compute.py @@ -166,7 +166,8 @@ def _prep_reservoir_da_dataframes(reservoir_usgs_df, reservoir_usace_df, waterbo else: reservoir_usgs_df_sub = pd.DataFrame() reservoir_usgs_df_time = pd.DataFrame().to_numpy().reshape(0,) - waterbody_types_df_sub.loc[waterbody_types_df_sub['reservoir_type'] == 2] = 1 + if not waterbody_types_df_sub.empty: + waterbody_types_df_sub.loc[waterbody_types_df_sub['reservoir_type'] == 2] = 1 # select USACE reservoir DA data waterbodies in sub-domain if not reservoir_usace_df.empty: @@ -178,7 +179,8 @@ def _prep_reservoir_da_dataframes(reservoir_usgs_df, reservoir_usace_df, waterbo else: reservoir_usace_df_sub = pd.DataFrame() reservoir_usace_df_time = pd.DataFrame().to_numpy().reshape(0,) - waterbody_types_df_sub.loc[waterbody_types_df_sub['reservoir_type'] == 3] = 1 + if not waterbody_types_df_sub.empty: + waterbody_types_df_sub.loc[waterbody_types_df_sub['reservoir_type'] == 3] = 1 return reservoir_usgs_df_sub, reservoir_usgs_df_time, reservoir_usace_df_sub, reservoir_usace_df_time, waterbody_types_df_sub