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
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
30
31
32
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 | 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):
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(alias="branchId")
chainage: Optional[float] = Field(alias="chainage")
numcoordinates: Optional[int] = Field(alias="numCoordinates")
xcoordinates: Optional[List[float]] = Field(alias="xCoordinates")
ycoordinates: Optional[List[float]] = Field(alias="yCoordinates")
_split_to_list = get_split_string_on_delimiter_validator(
"xcoordinates", "ycoordinates"
)
@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(
validate_node=False,
minimum_num_coordinates=2,
validate_location_type=False,
),
)
def _get_identifier(self, data: dict) -> Optional[str]:
return data.get("name")
|
validate_that_location_specification_is_correct(values)
Validates that the correct location specification is given.
Source code in hydrolib\core\dflowfm\obscrosssection\models.py
75
76
77
78
79
80
81
82
83
84
85 | @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(
validate_node=False,
minimum_num_coordinates=2,
validate_location_type=False,
),
)
|
ObservationCrossSectionGeneral
Bases: INIGeneral
The observation cross section file's [General] section with file meta data.
Source code in hydrolib\core\dflowfm\obscrosssection\models.py
14
15
16
17
18
19
20
21
22
23
24
25
26
27 | class ObservationCrossSectionGeneral(INIGeneral):
"""The observation cross section file's `[General]` section with file meta data."""
class Comments(INIBasedModel.Comments):
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")
|
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
| 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.