-
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 filling as default derived quantity
- Loading branch information
1 parent
6ccadb4
commit 758251c
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
mikeio1d/quantities/derived/default_quantities/reach_filling.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,25 @@ | ||
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 ReachFilling(DerivedQuantity): | ||
_NAME = "ReachFilling" | ||
_GROUPS = {TimeSeriesIdGroup.REACH} | ||
_SOURCE_QUANTITY = "WaterLevel" | ||
|
||
def derive(self, df_source: pd.DataFrame, locations: List[ResultLocation]): | ||
bottom_levels = tuple(gridpoint.bottom_level for gridpoint in locations) | ||
heights = tuple(gridpoint.result_reach.height for gridpoint in locations) | ||
df_derived = (df_source - bottom_levels) / heights | ||
return df_derived |