Skip to content

Observation cross section files

Observation cross section files come in two flavours:

Observation cross section .ini files

The obscrosssection module provides the specific logic for accessing observation cross section .ini files. for a D-Flow FM model.

Generic parsing and serializing functionality comes from the generic hydrolib.core.dflowfm.ini modules.

An observation cross section .ini file is described by the classes below.

Model

Observation cross section model definitions for D-Flow FM.

ObservationCrossSection

Bases: INIBasedModel

The observation cross section that is included in the observation cross section file.

All lowercased attributes match with the observation cross section output as described in [UM Sec.F2.4.1] (https://content.oss.deltares.nl/delft3dfm1d2d/D-Flow_FM_User_Manual_1D2D.pdf#subsubsection.F.2.4.1)

Source code in hydrolib/core/dflowfm/obscrosssection/models.py
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
class ObservationCrossSection(INIBasedModel):
    """The observation cross section that is included in the observation cross section file.

    All lowercased attributes match with the observation cross section output as described
    in [UM Sec.F2.4.1]
    (https://content.oss.deltares.nl/delft3dfm1d2d/D-Flow_FM_User_Manual_1D2D.pdf#subsubsection.F.2.4.1)
    """

    class Comments(INIBasedModel.Comments):
        """Comments for the ObservationCrossSection section fields."""

        name: Optional[str] = "Name of the cross section (max. 255 characters)."
        branchid: Optional[str] = Field(
            "(optional) Branch on which the cross section is located.", alias="branchId"
        )
        chainage: Optional[str] = "(optional) Location on the branch (m)."
        numcoordinates: Optional[str] = Field(
            "(optional) Number of values in xCoordinates and yCoordinates. "
            "This value should be greater than or equal to 2.",
            alias="numCoordinates",
        )
        xcoordinates: Optional[str] = Field(
            "(optional) x-coordinates of the cross section line. "
            "(number of values = numCoordinates)",
            alias="xCoordinates",
        )
        ycoordinates: Optional[str] = Field(
            "(optional) y-coordinates of the cross section line. "
            "(number of values = numCoordinates)",
            alias="yCoordinates",
        )

    comments: Comments = Comments()
    _header: Literal["ObservationCrossSection"] = "ObservationCrossSection"
    name: str = Field(max_length=255, alias="name")
    branchid: Optional[str] = Field(None, alias="branchId")
    chainage: Optional[float] = Field(None, alias="chainage")
    numcoordinates: Optional[int] = Field(None, alias="numCoordinates")
    xcoordinates: Optional[List[float]] = Field(None, alias="xCoordinates")
    ycoordinates: Optional[List[float]] = Field(None, alias="yCoordinates")

    @field_validator("xcoordinates", "ycoordinates", mode="before")
    @classmethod
    def _split_to_list(cls, v, info: ValidationInfo):
        return split_string_on_delimiter(cls, v, info)

    @model_validator(mode="after")
    def validate_that_location_specification_is_correct(
        self,
    ) -> "ObservationCrossSection":
        """Validates that the correct location specification is given."""
        validate_location_specification(
            self.model_dump(),
            config=LocationValidationConfiguration(
                validate_node=False,
                minimum_num_coordinates=2,
                validate_location_type=False,
            ),
        )
        return self

    def _get_identifier(self, data: dict) -> Optional[str]:
        return data.get("name")

Comments

Bases: Comments

Comments for the ObservationCrossSection section fields.

Source code in hydrolib/core/dflowfm/obscrosssection/models.py
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class Comments(INIBasedModel.Comments):
    """Comments for the ObservationCrossSection section fields."""

    name: Optional[str] = "Name of the cross section (max. 255 characters)."
    branchid: Optional[str] = Field(
        "(optional) Branch on which the cross section is located.", alias="branchId"
    )
    chainage: Optional[str] = "(optional) Location on the branch (m)."
    numcoordinates: Optional[str] = Field(
        "(optional) Number of values in xCoordinates and yCoordinates. "
        "This value should be greater than or equal to 2.",
        alias="numCoordinates",
    )
    xcoordinates: Optional[str] = Field(
        "(optional) x-coordinates of the cross section line. "
        "(number of values = numCoordinates)",
        alias="xCoordinates",
    )
    ycoordinates: Optional[str] = Field(
        "(optional) y-coordinates of the cross section line. "
        "(number of values = numCoordinates)",
        alias="yCoordinates",
    )

validate_that_location_specification_is_correct()

Validates that the correct location specification is given.

Source code in hydrolib/core/dflowfm/obscrosssection/models.py
79
80
81
82
83
84
85
86
87
88
89
90
91
92
@model_validator(mode="after")
def validate_that_location_specification_is_correct(
    self,
) -> "ObservationCrossSection":
    """Validates that the correct location specification is given."""
    validate_location_specification(
        self.model_dump(),
        config=LocationValidationConfiguration(
            validate_node=False,
            minimum_num_coordinates=2,
            validate_location_type=False,
        ),
    )
    return self

ObservationCrossSectionGeneral

Bases: INIGeneral

The observation cross section file's [General] section with file meta data.

Source code in hydrolib/core/dflowfm/obscrosssection/models.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class ObservationCrossSectionGeneral(INIGeneral):
    """The observation cross section file's `[General]` section with file meta data."""

    class Comments(INIBasedModel.Comments):
        """Comments for the ObservationCrossSectionGeneral section fields."""

        fileversion: Optional[str] = Field(
            "File version. Do not edit this.", alias="fileVersion"
        )
        filetype: Optional[str] = Field(
            "File type. Should be 'obsCross'. Do not edit this.", alias="fileType"
        )

    comments: Comments = Comments()
    fileversion: str = Field("2.00", alias="fileVersion")
    filetype: Literal["obsCross"] = Field("obsCross", alias="fileType")

Comments

Bases: Comments

Comments for the ObservationCrossSectionGeneral section fields.

Source code in hydrolib/core/dflowfm/obscrosssection/models.py
18
19
20
21
22
23
24
25
26
class Comments(INIBasedModel.Comments):
    """Comments for the ObservationCrossSectionGeneral section fields."""

    fileversion: Optional[str] = Field(
        "File version. Do not edit this.", alias="fileVersion"
    )
    filetype: Optional[str] = Field(
        "File type. Should be 'obsCross'. Do not edit this.", alias="fileType"
    )

ObservationCrossSectionModel

Bases: INIModel

The overall observation cross section model that contains the contents of one observation cross section file.

Source code in hydrolib/core/dflowfm/obscrosssection/models.py
 98
 99
100
101
102
class ObservationCrossSectionModel(INIModel):
    """The overall observation cross section model that contains the contents of one observation cross section file."""

    general: ObservationCrossSectionGeneral = ObservationCrossSectionGeneral()
    observationcrosssection: List[ObservationCrossSection] = []

Legacy observation cross section .pli files

Legacy .pli files for observation points are supported via the generic polyfile module.

For details on the polyfile format and classes (Description, Metadata, Point, PolyObject, PolyFile), see the Polyfile documentation.