Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rvic/convolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ def convolution_init(config):
forcings['LATITUDE_VAR'],
forcings['DATL_LIQ_FLDS'],
forcings['START'],
forcings['END'])
forcings['END'],
options,)
# ---------------------------------------------------------------- #

# ---------------------------------------------------------------- #
Expand Down
20 changes: 14 additions & 6 deletions rvic/core/read_forcing.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class DataModel(object):
# ---------------------------------------------------------------- #
# Initialize
def __init__(self, path, file_str, time_fld, lat_fld, liq_flds,
start, end):
start, end, options):

self.path = path
self.time_fld = time_fld
Expand Down Expand Up @@ -125,7 +125,15 @@ def __init__(self, path, file_str, time_fld, lat_fld, liq_flds,

if i == 0:
# get the calendar and units information
self.calendar = f.variables[self.time_fld].calendar
if "calendar" in f.variables[self.time_fld].ncattrs():
self.calendar = f.variables[self.time_fld].calendar
use_default_calendar = False
else:
self.calendar = options["CALENDAR"]
use_default_calendar = True # this is a fix for missing calendar attributes in netCDF files.
# We'll ignore the future checks for same calendar
log.warning('Initial file has no calendar information - using default')

self.time_units = f.variables[self.time_fld].units
time_series = f.variables[self.time_fld][:]

Expand All @@ -144,11 +152,11 @@ def __init__(self, path, file_str, time_fld, lat_fld, liq_flds,
# check that the units match the first file
if f.variables[self.time_fld].units != self.time_units:
raise ValueError('Units do not match in input files')
if f.variables[self.time_fld].calendar != self.calendar:
if not use_default_calendar and f.variables[self.time_fld].calendar != self.calendar:
# only check if it's a mismatch if we're not using the default calendar
raise ValueError('Calendars do not match in input files')

time_series = np.append(time_series,
f.variables[self.time_fld][:])
time_series = np.append(time_series, f.variables[self.time_fld][:])

f.close()

Expand Down Expand Up @@ -212,7 +220,7 @@ def start(self, timestamp, rout_var):
if units in ['kg/m2*s', 'kg m-2 s-1', 'kg m^-2 s^-1',
'kg*m-2*s-1', 'kg s-1 m-2']:
self.fld_mult[fld] = 1.0
elif units in ['mm', 'MM', 'milimeters', 'Milimeters']:
elif units in ['mm', 'MM', 'milimeters', 'Milimeters', 'mm/day']:
self.fld_mult[fld] = WATERDENSITY / MMPERMETER / self.secs_per_step
elif units in ['m', 'M', 'meters', 'Meters']:
self.fld_mult[fld] = WATERDENSITY / self.secs_per_step
Expand Down