External forcings file¶
The external forcing .ext file contains the forcing data for a D-Flow FM model.
This includes open boundaries, lateral discharges and meteorological forcings.
The documentation below only concerns the 'new' format (ExtForceFileNew
in the MDU file).
Model¶
Boundary (INIBasedModel)
pydantic-model
¶
A [Boundary]
block for use inside an external forcings file,
i.e., a ExtModel.
All lowercased attributes match with the boundary input as described in UM Sec.C.5.2.1.
check_nodeid_or_locationfile_present(values: Dict)
classmethod
¶
Verifies that either nodeid or locationfile properties have been set.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values |
Dict |
Dictionary with values already validated. |
required |
Exceptions:
Type | Description |
---|---|
ValueError |
When none of the values are present. |
Returns:
Type | Description |
---|---|
Dict |
Validated dictionary of values for Boundary. |
Source code in hydrolib/core/io/ext/models.py
@root_validator
@classmethod
def check_nodeid_or_locationfile_present(cls, values: Dict):
"""
Verifies that either nodeid or locationfile properties have been set.
Args:
values (Dict): Dictionary with values already validated.
Raises:
ValueError: When none of the values are present.
Returns:
Dict: Validated dictionary of values for Boundary.
"""
node_id = values.get("nodeid", None)
location_file = values.get("locationfile", None)
if str_is_empty_or_none(node_id) and not cls._is_valid_locationfile_data(
location_file
):
raise ValueError(
"Either nodeId or locationFile fields should be specified."
)
return values
forcing: ForcingBase
property
readonly
¶
Retrieves the corresponding forcing data for this boundary.
Returns:
Type | Description |
---|---|
ForcingBase |
The corresponding forcing data. None when this boundary does not have a forcing file or when the data cannot be found. |
is_intermediate_link(self) -> bool
¶
Generic attribute for models that have children fields that could contain files.
Source code in hydrolib/core/io/ext/models.py
def is_intermediate_link(self) -> bool:
return True
ExtGeneral (INIGeneral)
pydantic-model
¶
The external forcing file's [General]
section with file meta data.
ExtModel (INIModel)
pydantic-model
¶
The overall external forcings model that contains the contents of one external forcings file (new format).
This model is typically referenced under a FMModel.external_forcing.extforcefilenew
.
Attributes:
Name | Type | Description |
---|---|---|
general |
ExtGeneral |
|
boundary |
List[Boundary] |
List of |
lateral |
List[Lateral] |
List of |
Lateral (INIBasedModel)
pydantic-model
¶
A [Lateral]
block for use inside an external forcings file,
i.e., a ExtModel.
All lowercased attributes match with the lateral input as described in UM Sec.C.5.2.2.
is_intermediate_link(self) -> bool
¶
Generic attribute for models that have children fields that could contain files.
Source code in hydrolib/core/io/ext/models.py
def is_intermediate_link(self) -> bool:
return True
validate_location_type(v: str) -> str
classmethod
¶
Method to validate whether the specified location type is correct.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
v |
str |
Given value for the locationtype field. |
required |
Exceptions:
Type | Description |
---|---|
ValueError |
When the value given for locationtype is unknown. |
Returns:
Type | Description |
---|---|
str |
Validated locationtype string. |
Source code in hydrolib/core/io/ext/models.py
@validator("locationtype")
@classmethod
def validate_location_type(cls, v: str) -> str:
"""
Method to validate whether the specified location type is correct.
Args:
v (str): Given value for the locationtype field.
Raises:
ValueError: When the value given for locationtype is unknown.
Returns:
str: Validated locationtype string.
"""
possible_values = ["1d", "2d", "all"]
if v.lower() not in possible_values:
raise ValueError(
"Value given ({}) not accepted, should be one of: {}".format(
v, ", ".join(possible_values)
)
)
return v