-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add reach flooding as default derived quantity
- Loading branch information
1 parent
d75caf9
commit 6ccadb4
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
mikeio1d/quantities/derived/default_quantities/reach_flooding.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING | ||
|
||
if TYPE_CHECKING: | ||
from typing import List | ||
|
||
import pandas as pd | ||
|
||
from mikeio1d.result_network import ResultLocation | ||
|
||
from ..derived_quantity import DerivedQuantity | ||
from ...timeseries_id import TimeSeriesIdGroup | ||
|
||
|
||
class ReachFlooding(DerivedQuantity): | ||
_NAME = "ReachFlooding" | ||
_GROUPS = {TimeSeriesIdGroup.REACH} | ||
_SOURCE_QUANTITY = "WaterLevel" | ||
|
||
def derive(self, df_source: pd.DataFrame, locations: List[ResultLocation]): | ||
ground_levels = tuple( | ||
gridpoint.result_reach.interpolate_reach_ground_level(gridpoint.chainage) | ||
for gridpoint in locations | ||
) | ||
df_derived = df_source - ground_levels | ||
return df_derived |