Skip to content

Commit

Permalink
feat: support .bc files and more in lateral discharge
Browse files Browse the repository at this point in the history
Truly distinguish between a scalar float constant, keyword "realtime" and a .bc file.
  • Loading branch information
arthurvd committed Jun 3, 2022
1 parent 2197a1e commit d9d3fb1
Show file tree
Hide file tree
Showing 5 changed files with 540 additions and 4 deletions.
22 changes: 20 additions & 2 deletions hydrolib/core/io/ext/models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from enum import Enum
from pathlib import Path
from typing import Dict, List, Literal, Optional
from typing import Dict, List, Literal, Optional, Union

from pydantic import Field, root_validator, validator

Expand All @@ -13,6 +14,20 @@
from hydrolib.core.utils import str_is_empty_or_none


# TODO: to be moved into hydrolib.core.io.common, once PR #236 has been closed.
class RealTime(str, Enum):
realtime = "realtime"
"""str: Realtime data source, externally provided"""


ForcingData = Union[float, RealTime, ForcingModel]
"""Data type that selects from three different types of forcing data:
* a scalar float constant
* "realtime" keyword, indicating externally controlled.
* A ForcingModel coming from a .bc file.
"""


class Boundary(INIBasedModel):
"""
A `[Boundary]` block for use inside an external forcings file,
Expand Down Expand Up @@ -110,7 +125,10 @@ class Lateral(INIBasedModel):
numcoordinates: Optional[int] = Field(alias="numCoordinates")
xcoordinates: Optional[List[int]] = Field(alias="xCoordinates")
ycoordinates: Optional[List[int]] = Field(alias="yCoordinates")
discharge: str = Field(alias="discharge")
discharge: ForcingData = Field(alias="discharge")

def is_intermediate_link(self) -> bool:
return True

_split_to_list = get_split_string_on_delimiter_validator(
"xcoordinates", "ycoordinates"
Expand Down
Loading

0 comments on commit d9d3fb1

Please sign in to comment.