Skip to content

Commit 8f6048d

Browse files
awlostowski-noaaawlostowski-noaa
andauthored
update logic becuase the waterbody_types_df_sub may be empty for sims without waterbodies" (#538)
Co-authored-by: awlostowski-noaa <[email protected]>
1 parent 29897f2 commit 8f6048d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/troute-routing/troute/routing/compute.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,8 @@ def _prep_reservoir_da_dataframes(reservoir_usgs_df, reservoir_usace_df, waterbo
166166
else:
167167
reservoir_usgs_df_sub = pd.DataFrame()
168168
reservoir_usgs_df_time = pd.DataFrame().to_numpy().reshape(0,)
169-
waterbody_types_df_sub.loc[waterbody_types_df_sub['reservoir_type'] == 2] = 1
169+
if not waterbody_types_df_sub.empty:
170+
waterbody_types_df_sub.loc[waterbody_types_df_sub['reservoir_type'] == 2] = 1
170171

171172
# select USACE reservoir DA data waterbodies in sub-domain
172173
if not reservoir_usace_df.empty:
@@ -178,7 +179,8 @@ def _prep_reservoir_da_dataframes(reservoir_usgs_df, reservoir_usace_df, waterbo
178179
else:
179180
reservoir_usace_df_sub = pd.DataFrame()
180181
reservoir_usace_df_time = pd.DataFrame().to_numpy().reshape(0,)
181-
waterbody_types_df_sub.loc[waterbody_types_df_sub['reservoir_type'] == 3] = 1
182+
if not waterbody_types_df_sub.empty:
183+
waterbody_types_df_sub.loc[waterbody_types_df_sub['reservoir_type'] == 3] = 1
182184

183185
return reservoir_usgs_df_sub, reservoir_usgs_df_time, reservoir_usace_df_sub, reservoir_usace_df_time, waterbody_types_df_sub
184186

0 commit comments

Comments
 (0)