Skip to content

Commit

Permalink
Add reach flooding 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 d75caf9 commit 6ccadb4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions mikeio1d/quantities/derived/default_quantities/reach_flooding.py
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

0 comments on commit 6ccadb4

Please sign in to comment.