Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: create and pass hypy.Catchment object when creating hypy.Nexus #141

Merged
merged 1 commit into from
Jul 31, 2024
Merged
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
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 @@ -24,8 +24,9 @@
from .calibration_set import CalibrationSet, UniformCalibrationSet
from .ngen_hooks.ngen_output import TrouteOutput, NgenSaveOutput
#HyFeatures components
from hypy.hydrolocation import NWISLocation # type: ignore
from hypy.nexus import Nexus # type: ignore
from hypy.hydrolocation import NWISLocation
from hypy.nexus import Nexus
from hypy.catchment import Catchment

class NgenStrategy(str, Enum):
"""
Expand Down Expand Up @@ -336,7 +337,7 @@ def __init__(self, **kwargs):

#establish the hydro location for the observation nexus associated with this catchment
location = NWISLocation(nwis, nexus_data.name, nexus_data.geometry)
nexus = Nexus(nexus_data.name, location, (), id)
nexus = Nexus(nexus_data.name, location, (), Catchment(id, {}))
output_var = catchment.formulations[0].params.main_output_variable
#read params from the realization calibration definition
params = {model:[Parameter(**p) for p in params] for model, params in catchment.calibration.items()}
Expand Down Expand Up @@ -419,13 +420,13 @@ def __init__(self, **kwargs):
if nwis is not None:
#establish the hydro location for the observation nexus associated with this catchment
location = NWISLocation(nwis, nexus_data.name, nexus_data.geometry)
nexus = Nexus(nexus_data.name, location, (), id)
nexus = Nexus(nexus_data.name, location, (), Catchment(id, {}))
eval_nexus.append( nexus ) # FIXME why did I make this a tuple???
else:
#in this case, we don't care if all nexus are observable, just need one downstream
#FIXME use the graph to work backwards from an observable nexus to all upstream catchments
#and create independent "sets"
nexus = Nexus(nexus_data.name, None, (), id)
nexus = Nexus(nexus_data.name, None, (), Catchment(id, {}))
#FIXME pick up params per catchmment somehow???
params = _map_params_to_realization(self.params, catchment)
catchments.append(AdjustableCatchment(self.workdir, id, nexus, params))
Expand Down Expand Up @@ -469,6 +470,7 @@ def __init__(self, **kwargs):
eval_nexus = []

for id, toid in self._catchment_hydro_fabric['toid'].items():
assert isinstance(id, str), f"id expected to be str subtype. is type: {type(id)}"
#look for an observable nexus
nexus_data = self._nexus_hydro_fabric.loc[toid]
nwis = None
Expand All @@ -482,7 +484,7 @@ def __init__(self, **kwargs):
continue
#establish the hydro location for the observation nexus associated with this catchment
location = NWISLocation(nwis, nexus_data.name, nexus_data.geometry)
nexus = Nexus(nexus_data.name, location, (), id)
nexus = Nexus(nexus_data.name, location, (), Catchment(id, {}))
eval_nexus.append( nexus )

if self.eval_feature:
Expand Down
Loading