Skip to content

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/dflowfm/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.

Generic attribute for models that have children fields that could contain files.

Source code in hydrolib/core/dflowfm/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

[General] block with file metadata.

boundary List[Boundary]

List of [Boundary] blocks for all boundary conditions.

lateral List[Lateral]

List of [Lateral] blocks for all lateral discharges.

meteo List[Meteo]

List of [Meteo] blocks for all meteorological forcings.

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.

Generic attribute for models that have children fields that could contain files.

Source code in hydrolib/core/dflowfm/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/dflowfm/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

validate_that_location_specification_is_correct(values: Dict) -> Dict classmethod

Validates that the correct location specification is given.

Source code in hydrolib/core/dflowfm/ext/models.py
@root_validator(allow_reuse=True)
def validate_that_location_specification_is_correct(cls, values: Dict) -> Dict:
    """Validates that the correct location specification is given."""
    return validate_location_specification(
        values, config=LocationValidationConfiguration(minimum_num_coordinates=1)
    )

Meteo (INIBasedModel) pydantic-model

A [Meteo] block for use inside an external forcings file, i.e., a ExtModel.

All lowercased attributes match with the meteo input as described in UM Sec.C.5.2.3.

Generic attribute for models that have children fields that could contain files.

Source code in hydrolib/core/dflowfm/ext/models.py
def is_intermediate_link(self) -> bool:
    return True

MeteoForcingFileType (str, Enum)

Enum class containing the valid values for the forcingFileType attribute in Meteo class.

bcascii

str: Space-uniform time series in <*.bc> file.

netcdf

str: NetCDF, either with gridded data, or multiple station time series.

uniform

str: Space-uniform time series in <*.tim> file.

MeteoInterpolationMethod (str, Enum)

Enum class containing the valid values for the interpolationMethod attribute in Meteo class.

nearestnb

str: Nearest-neighbour interpolation, only with station-data in forcingFileType=netcdf

Back to top