Skip to content

Commit

Permalink
rename ObsInNode -> ObsInFlowNode and PassThroughNode -> PassThroughF…
Browse files Browse the repository at this point in the history
…lowNode
  • Loading branch information
jmccreight committed Oct 22, 2024
1 parent e3d4001 commit b878c37
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 31 deletions.
4 changes: 2 additions & 2 deletions autotest/test_obsin_flow_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pywatershed.base.flow_graph import FlowGraph
from pywatershed.base.parameters import Parameters
from pywatershed.constants import nan, zero
from pywatershed.hydrology.obsin_node import ObsInNodeMaker
from pywatershed.hydrology.obsin_flow_node import ObsInFlowNodeMaker
from pywatershed.hydrology.prms_channel_flow_graph import (
HruSegmentFlowAdapter,
PRMSChannelFlowNodeMaker,
Expand Down Expand Up @@ -125,7 +125,7 @@ def advance(self) -> None:
"prms_channel": PRMSChannelFlowNodeMaker(
discretization_prms, parameters_prms
),
"obsin": ObsInNodeMaker(obsin_params, obsin_data),
"obsin": ObsInFlowNodeMaker(obsin_params, obsin_data),
}
nnodes = parameters_prms.dims["nsegment"] + npoi
node_maker_name = ["prms_channel"] * nnodes
Expand Down
6 changes: 4 additions & 2 deletions autotest/test_pass_through_flow_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
from pywatershed.base.model import Model
from pywatershed.base.parameters import Parameters
from pywatershed.constants import nan, zero
from pywatershed.hydrology.pass_through_node import PassThroughNodeMaker
from pywatershed.hydrology.pass_through_flow_node import (
PassThroughFlowNodeMaker,
)
from pywatershed.hydrology.prms_channel_flow_graph import (
HruSegmentFlowAdapter,
PRMSChannelFlowNodeMaker,
Expand Down Expand Up @@ -121,7 +123,7 @@ def node_maker_dict(parameters_prms, discretization_prms):
"prms_channel": PRMSChannelFlowNodeMaker(
discretization_prms, parameters_prms
),
"pass_throughs": PassThroughNodeMaker(),
"pass_throughs": PassThroughFlowNodeMaker(),
}


Expand Down
4 changes: 2 additions & 2 deletions autotest/test_prms_channel_flow_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from utils_compare import compare_in_memory

from pywatershed import (
PassThroughNodeMaker,
PassThroughFlowNodeMaker,
PRMSChannel,
PRMSGroundwater,
PRMSRunoff,
Expand Down Expand Up @@ -456,7 +456,7 @@ def test_prms_channel_flow_graph_to_model_dict(
prms_channel_dis=discretization,
prms_channel_dis_name="dis_both",
prms_channel_params=parameters,
new_nodes_maker_dict={"pass": PassThroughNodeMaker()},
new_nodes_maker_dict={"pass": PassThroughFlowNodeMaker()},
new_nodes_maker_names=check_names,
new_nodes_maker_indices=check_indices,
new_nodes_maker_ids=check_ids,
Expand Down
8 changes: 5 additions & 3 deletions autotest/test_starfit_flow_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
from pywatershed.base.control import Control
from pywatershed.base.parameters import Parameters
from pywatershed.constants import nan, zero
from pywatershed.hydrology.pass_through_node import PassThroughNodeMaker
from pywatershed.hydrology.pass_through_flow_node import (
PassThroughFlowNodeMaker,
)
from pywatershed.hydrology.prms_channel_flow_graph import (
prms_channel_flow_graph_postprocess,
prms_channel_flow_graph_to_model_dict,
Expand Down Expand Up @@ -190,7 +192,7 @@ def add_disconnected_node_data(ds: xr.Dataset) -> xr.Dataset:
budget_type="error",
compute_daily=compute_daily,
),
"pass_through": PassThroughNodeMaker(),
"pass_through": PassThroughFlowNodeMaker(),
},
new_nodes_maker_names=new_nodes_maker_names,
new_nodes_maker_indices=new_nodes_maker_indices,
Expand Down Expand Up @@ -375,7 +377,7 @@ def test_starfit_flow_graph_model_dict(
budget_type="error",
compute_daily=compute_daily,
),
"pass_through": PassThroughNodeMaker(),
"pass_through": PassThroughFlowNodeMaker(),
}
new_nodes_maker_names = ["starfit", "pass_through"]
new_nodes_maker_indices = [0, 0]
Expand Down
15 changes: 9 additions & 6 deletions pywatershed/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@
from .base.parameters import Parameters
from .base.process import Process
from .base.timeseries import TimeseriesArray
from .hydrology.obsin_node import ObsInNode, ObsInNodeMaker
from .hydrology.pass_through_node import PassThroughNode, PassThroughNodeMaker
from .hydrology.obsin_flow_node import ObsInFlowNode, ObsInFlowNodeMaker
from .hydrology.pass_through_flow_node import (
PassThroughFlowNode,
PassThroughFlowNodeMaker,
)
from .hydrology.prms_canopy import PRMSCanopy
from .hydrology.prms_channel import PRMSChannel
from .hydrology.prms_channel_flow_graph import (
Expand Down Expand Up @@ -70,10 +73,10 @@
"Parameters",
"Process",
"TimeseriesArray",
"ObsInNode",
"ObsInNodeMaker",
"PassThroughNode",
"PassThroughNodeMaker",
"ObsInFlowNode",
"ObsInFlowNodeMaker",
"PassThroughFlowNode",
"PassThroughFlowNodeMaker",
"StarfitFlowNode",
"StarfitFlowNodeMaker",
"PRMSCanopy",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pywatershed.constants import nan, zero


class ObsInNode(FlowNode):
class ObsInFlowNode(FlowNode):
"""A FlowNode that takes inflows but returns observed/specified flows.
This FlowNode replicates the obsin and obsout seg functionality in PRMS but
Expand All @@ -22,7 +22,7 @@ def __init__(
control: Control,
node_obs_data: pd.Series,
):
"""Initialize an ObsInNode.
"""Initialize an ObsInFlowNode.
Args:
control: a Control object.
Expand Down Expand Up @@ -90,8 +90,8 @@ def sink_source(self):
return self._sink_source


class ObsInNodeMaker(FlowNodeMaker):
"""A FlowNodeMaker for ObsInNode.
class ObsInFlowNodeMaker(FlowNodeMaker):
"""A FlowNodeMaker for ObsInFlowNode.
See :class:`FlowGraph` for related examples and discussion.
"""
Expand All @@ -101,17 +101,17 @@ def __init__(
parameters: Parameters,
obs_data: pd.DataFrame,
) -> None:
"""Initialize a ObsinNodeMaker.
"""Initialize a ObsInFlowNodeMaker.
Args:
parameters: A pywatershed Parameters object.
obs_data: A pandas DataFrame of observations given by
pyPRMS.Streamflow.
"""
self.name = "PassThroughNodeMaker"
self.name = "ObsInNodeMaker"
self._parameters = parameters
self._obs_data = obs_data

def get_node(self, control: Control, index: int):
node_poi_id = self._parameters.parameters["poi_gage_id"][index]
return ObsInNode(control, self._obs_data[node_poi_id])
return ObsInFlowNode(control, self._obs_data[node_poi_id])
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
from ..constants import nan, zero


class PassThroughNode(FlowNode):
class PassThroughFlowNode(FlowNode):
"""A FlowNode instance that gives what it takes and dosent store.
See :class:`FlowGraph` for a worked example using PassThroughNode.
See :class:`FlowGraph` for a worked example using PassThroughFlowNode.
"""

def __init__(self, control: Control):
"""Initialize a PassThroughNode.
"""Initialize a PassThroughFlowNode.
Args:
control: A control object.
Expand Down Expand Up @@ -61,17 +61,17 @@ def sink_source(self):
return zero


class PassThroughNodeMaker(FlowNodeMaker):
"""A FlowNodeMaker of PassThroughNodes.
class PassThroughFlowNodeMaker(FlowNodeMaker):
"""A FlowNodeMaker of PassThroughFlowNodes.
See :class:`FlowGraph` for a worked example using PassThroughNode.
See :class:`FlowGraph` for a worked example using PassThroughFlowNode.
"""

def __init__(
self,
) -> None:
"""Initialize a PassThroughNodeMaker."""
self.name = "PassThroughNodeMaker"
"""Initialize a PassThroughFlowNodeMaker."""
self.name = "PassThroughFlowNodeMaker"

def get_node(self, control: Control, index: int):
return PassThroughNode(control)
return PassThroughFlowNode(control)

0 comments on commit b878c37

Please sign in to comment.