Skip to content

Commit 6b4d409

Browse files
committed
reinstating try/except for time series
1 parent ea6cebf commit 6b4d409

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

enacts/wat_bal/maproom_monit.py

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -381,37 +381,34 @@ def wat_bal_ts(
381381
planting_year=None,
382382
time_coord="T",
383383
):
384-
water_balance_outputs = wat_bal(
385-
precip,
386-
et,
387-
taw,
388-
planting_day,
389-
planting_month,
390-
kc_init_length,
391-
kc_veg_length,
392-
kc_mid_length,
393-
kc_late_length,
394-
kc_init,
395-
kc_veg,
396-
kc_mid,
397-
kc_late,
398-
kc_end,
399-
planting_year=planting_year,
400-
time_coord=time_coord,
401-
)
402-
for wbo in water_balance_outputs:
403-
if map_choice == "paw" and wbo.name == "sm":
404-
ts = 100 * wbo / taw
405-
elif map_choice == "water_excess" and wbo.name == "sm":
406-
ts = xr.DataArray(
407-
np.isclose(wbo, taw).cumsum(),
408-
dims="T",
409-
coords={"T": wbo["T"]},
410-
)
411-
elif map_choice == "peff":
412-
ts = precip_effective
413-
elif (wbo.name == map_choice):
414-
ts = wbo
384+
try:
385+
water_balance_outputs = wat_bal(
386+
precip, et, taw,
387+
planting_day, planting_month,
388+
kc_init_length,
389+
kc_veg_length,
390+
kc_mid_length,
391+
kc_late_length,
392+
kc_init, kc_veg, kc_mid, kc_late, kc_end,
393+
planting_year=planting_year,
394+
time_coord=time_coord,
395+
)
396+
for wbo in water_balance_outputs:
397+
if map_choice == "paw" and wbo.name == "sm":
398+
ts = 100 * wbo / taw
399+
elif map_choice == "water_excess" and wbo.name == "sm":
400+
ts = xr.DataArray(
401+
np.isclose(wbo, taw).cumsum(),
402+
dims="T",
403+
coords={"T": wbo["T"]},
404+
)
405+
elif map_choice == "peff":
406+
ts = precip_effective
407+
elif (wbo.name == map_choice):
408+
ts = wbo
409+
except TypeError:
410+
#Later tested to return error image rather than broken one
411+
ts = None
415412
return ts
416413

417414

0 commit comments

Comments
 (0)