Skip to content

Commit

Permalink
Apply overrides to Surface
Browse files Browse the repository at this point in the history
  • Loading branch information
liuly12 committed Mar 2, 2024
1 parent 31808b8 commit bd7e9bd
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions wsimod/nodes/land.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,32 @@ def __init__(
self.inflows.append(self.simple_deposition)
self.processes = []
self.outflows = []

def apply_overrides(self, overrides = Dict[str, Any]):
"""Override parameters.
Enables a user to override any of the following parameters:
area and depth (both will update the capacity), pollutant_load (the
entire dict does not need to be redefined, only changed values need to
be included).
Args:
overrides (Dict[str, Any]): Dict describing which parameters should
be overridden (keys) and new values (values). Defaults to {}.
"""
self.surface = overrides.pop("surface",
self.surface)
self.area = overrides.pop("area",
self.area)
self.depth = overrides.pop("depth",
self.depth)
self.capacity = self.area * self.depth

pollutant_load = overrides.pop("pollutant_load", {})
for key, value in pollutant_load.items():
self.pollutant_load[key].update(value)
super().apply_overrides(overrides)

def run(self):
"""Call run function (called from Land node)."""
if "nitrite" in constants.POLLUTANTS:
Expand Down

0 comments on commit bd7e9bd

Please sign in to comment.