Skip to content

Commit d907ee0

Browse files
author
Joe Hamman
committed
add check to insure that all forcing values are non-fill-values inside routing mask
1 parent d449fb8 commit d907ee0

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

rvic/convolution.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def convolution_init(config_file):
151151
options['CALENDAR'], data_model.secs_per_step)
152152
time_handle.end = data_model.end
153153

154-
data_model.start(time_handle.timestamp)
154+
data_model.start(time_handle.timestamp, rout_var)
155155
# ---------------------------------------------------------------- #
156156

157157
# ---------------------------------------------------------------- #
@@ -353,4 +353,3 @@ def convolution_final(time_handle, hist_tapes):
353353
# ---------------------------------------------------------------- #
354354
return
355355
# -------------------------------------------------------------------- #
356-

rvic/core/read_forcing.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def __init__(self, path, file_str, time_fld, lat_fld, liq_flds,
158158
# ---------------------------------------------------------------- #
159159

160160
# ---------------------------------------------------------------- #
161-
def start(self, timestamp):
161+
def start(self, timestamp, rout_var):
162162
""" Initialize the first files inputs"""
163163
# ------------------------------------------------------------ #
164164
# find and open first file
@@ -205,6 +205,26 @@ def start(self, timestamp):
205205
else:
206206
raise ValueError('unknown forcing units')
207207
# ------------------------------------------------------------ #
208+
209+
# ------------------------------------------------------------ #
210+
# Compare rout_var mask to forcing mask
211+
for fld in self.liq_flds:
212+
self.current_fhdl.variables[fld].set_auto_maskandscale(False)
213+
try:
214+
fill_val = getattr(self.current_fhdl.variables[fld],
215+
'_FillValue')
216+
fmask = np.squeeze(self.current_fhdl.variables[fld][0]) == fill_val
217+
218+
if np.any(fmask[rout_var.source_y_ind, rout_var.source_x_ind]):
219+
log.error('There are fill values in the routing domain')
220+
log.error('Can not continue...')
221+
raise ValueError('Exiting now due to fill values being '
222+
'inside the domain defined by the RVIC '
223+
'parameter file')
224+
225+
except AttributeError:
226+
pass
227+
# ------------------------------------------------------------ #
208228
# ---------------------------------------------------------------- #
209229

210230
# ---------------------------------------------------------------- #

0 commit comments

Comments
 (0)