Skip to content

Commit

Permalink
Add reach filling as default derived quantity
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-kipawa committed Sep 16, 2024
1 parent 6ccadb4 commit 758251c
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions mikeio1d/quantities/derived/default_quantities/reach_filling.py
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

0 comments on commit 758251c

Please sign in to comment.