Skip to content

Commit

Permalink
feat: ngen_cal_model_observation hook
Browse files Browse the repository at this point in the history
  • Loading branch information
aaraney committed Aug 5, 2024
1 parent f223020 commit 9fbff9c
Showing 1 changed file with 32 additions and 11 deletions.
43 changes: 32 additions & 11 deletions python/ngen_cal/src/ngen/cal/_hookspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
if TYPE_CHECKING:
from ngen.cal.configuration import General
from ngen.cal.meta import JobMeta
from pandas import Series
from pathlib import Path
import pandas as pd
from datetime import datetime

hookspec = pluggy.HookspecMarker(PROJECT_SLUG)

Expand Down Expand Up @@ -46,20 +46,41 @@ def ngen_cal_finish(exception: Exception | None) -> None:
`exception` will be non-none if an exception was raised during calibration.
"""


class ModelHooks:
@hookspec(firstresult=True)
def ngen_cal_model_output(self, id: str | None) -> Series:
def ngen_cal_model_observations(
self,
id: str,
start_time: datetime,
end_time: datetime,
simulation_interval: pd.Timedelta,
) -> pd.Series:
"""
Called during each calibration iteration to provide the model output in the form
of a pandas Series, indexed by time.
Output series should be in units of cubic meters per second.
Called during each calibration iteration to provide truth / observation
values in the form of a pandas Series, indexed by time with a record
every `simulation_interval`.
The returned pandas Series should be in units of cubic meters per
second.
`id`: USGS gage station id
`start_time`, `end_time`: inclusive simulation time range
`simulation_interval`: time (distance) between simulation values
"""

@hookspec(firstresult=True)
def ngen_cal_model_output(self, id: str | None) -> pd.Series:
"""
Called during each calibration iteration to provide the model output in
the form of a pandas Series, indexed by time.
Output series should be in units of cubic meters per second.
"""

@hookspec
def ngen_cal_model_iteration_finish(self, iteration: int, info: JobMeta) -> None:
"""
Called after each model iteration is completed and evaluated.
And before the next iteration is configured and started.
Currently called at the end of an Adjustable's check_point function
which writes out calibration/parameter state data each iteration.
"""
Called after each model iteration is completed and evaluated.
And before the next iteration is configured and started.
Currently called at the end of an Adjustable's check_point function
which writes out calibration/parameter state data each iteration.
"""

0 comments on commit 9fbff9c

Please sign in to comment.