Skip to content

Commit

Permalink
fix: allow netcdf forcing
Browse files Browse the repository at this point in the history
  • Loading branch information
aaraney committed Jul 31, 2024
1 parent a692856 commit 853595e
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions python/ngen_cal/src/ngen/cal/ngen.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,14 +437,16 @@ def __init__(self, **kwargs):
#Need to fix the forcing definition or ngen will not work
#for individual catchment configs, it doesn't apply pattern resolution
#and will read the directory `path` key as the file key and will segfault
pattern = catchment_realizations[id].forcing.file_pattern
path = catchment_realizations[id].forcing.path
pattern = catchment_realizations[id].forcing.file_pattern
catchment_realizations[id].forcing.file_pattern = None
pattern = pattern.replace("{{id}}", id)
pattern = re.compile(pattern.replace("{{ID}}", id))
for f in path.iterdir():
if pattern.match(f.name):
catchment_realizations[id].forcing.path = f.resolve()
# case when we have a pattern
if pattern is not None:
pattern = pattern.replace("{{id}}", id)
pattern = re.compile(pattern.replace("{{ID}}", id))
for f in path.iterdir():
if pattern.match(f.name):
catchment_realizations[id].forcing.path = f.resolve()


self.ngen_realization.catchments = catchment_realizations
Expand Down

0 comments on commit 853595e

Please sign in to comment.