Skip to content

Commit

Permalink
Merge pull request #243 from amoodie/add_hooks
Browse files Browse the repository at this point in the history
add two more "after" hooks
  • Loading branch information
Andrew Moodie committed Mar 16, 2022
2 parents 2171c99 + d9b33cc commit b8c6167
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyDeltaRCM/_version.py
Expand Up @@ -4,4 +4,4 @@ def __version__():
Private version declaration, gets assigned to pyDeltaRCM.__version__
during import
"""
return '2.1.2'
return '2.1.3'
22 changes: 22 additions & 0 deletions pyDeltaRCM/hook_tools.py
Expand Up @@ -247,6 +247,15 @@ def hook_init_output_file(self):
"""
pass

def hook_after_create_domain(self):
"""Hook called *after* :obj:`~pyDeltaRCM.init_tools.init_tools.create_domain`.
Unlike the standard model hooks, this hook is called *after* the
domain has been created with the
method :obj:`~pyDeltaRCM.init_tools.init_tools.create_domain`
"""
pass

def hook_after_route_water(self):
"""Hook called *after* :obj:`~pyDeltaRCM.water_tools.water_tools.route_water`.
Expand All @@ -264,3 +273,16 @@ def hook_after_route_sediment(self):
method :obj:`~pyDeltaRCM.sed_tools.sed_tools.route_sediment`
"""
pass

def hook_after_finalize_timestep(self):
"""Hook called *after* :obj:`~pyDeltaRCM.iteration_tools.finalize_timestep`.
Unlike the standard model hooks, this hook is called *after* the
finalize timestep method has completed.
.. hint::
This is the last method called before logging and outputting data
for each timestep.
"""
pass
2 changes: 2 additions & 0 deletions pyDeltaRCM/model.py
Expand Up @@ -113,6 +113,7 @@ def __init__(self, input_file=None, defer_output=False, **kwargs):
# create the model domain based on configuration
self.hook_create_domain()
self.create_domain()
self.hook_after_create_domain()

# initialize the sediment router classes
self.init_sediment_routers()
Expand Down Expand Up @@ -194,6 +195,7 @@ def update(self):

self.hook_finalize_timestep()
self.finalize_timestep()
self.hook_after_finalize_timestep()

# update time-tracking fields
self._time += self.dt
Expand Down

0 comments on commit b8c6167

Please sign in to comment.