Skip to content

Commit 4426ab1

Browse files
feat(extforce_convert): enhance parameter and prefix quantity handling (#976)
feat(extforce_convert): enhance parameter and prefix quantity handling - Added `waqfunction` as a parameter quantity and improved prefix matching with lowercase normalization - Moved additional parameter-related quantities to the prefix section - Removed `waqfunction` from default quantities to avoid duplication - Marked lateral quantities as unsupported to enable debug mode execution ref: #973
1 parent c8d1e5b commit 4426ab1

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

hydrolib/core/dflowfm/extold/data/old-external-forcing-data.yaml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,12 @@ Parameter:
100100
IBotLevType: ibotlevtype
101101
# Missing in the converter
102102
FloeDiameter: floe_diameter
103-
WaqFunction: waqfunction
104103
WaqParameter: waqparameter
105-
WaqSegmentFunction: waqsegmentfunction
106-
WaqSegmentNumber: waqsegmentnumber
104+
prefixes:
105+
# Missing in the converter
106+
- waqfunction
107+
- waqsegmentfunction
108+
- waqsegmentnumber
107109

108110

109111
InitialConditions:
@@ -150,6 +152,12 @@ Structure:
150152
valve1D: valve1d
151153

152154

155+
Lateral:
156+
LateralDischarge: lateraldischarge
157+
LateralDischarge1D: lateraldischarge1d
158+
LateralDischarge2D: lateraldischarge2d
159+
160+
153161
Misellaneous:
154162
ShiptXY: shiptxy
155163
MovingStationXY: movingstationxy

hydrolib/core/dflowfm/extold/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ def _missing_(cls, value):
8686
ExtOldParametersQuantity = StrEnum(
8787
"ExtOldParametersQuantity", QUANTITIES_DATA["Parameter"]["quantity_names"]
8888
)
89+
PARAMETER_QUANTITIES_VALID_PREFIXES = tuple(QUANTITIES_DATA["Parameter"]["prefixes"])
8990
ExtOldMeteoQuantity = StrEnum(
9091
"ExtOldMeteoQuantity",
9192
QUANTITIES_DATA["Meteo"]["quantity_names"],
9293
)
94+
ExtOldLateralQuantity = StrEnum("ExtOldLateralQuantity", QUANTITIES_DATA["Lateral"])
9395

9496

9597
INITIAL_CONDITION_QUANTITIES_VALID_PREFIXES = tuple(
@@ -141,11 +143,13 @@ def _missing_(cls, value):
141143
| QUANTITIES_DATA["SourceSink"]
142144
| QUANTITIES_DATA["Structure"]
143145
| QUANTITIES_DATA["Misellaneous"]
146+
| QUANTITIES_DATA["Lateral"]
144147
)
145148

146149
ALL_PREFIXES = (
147150
BOUNDARY_CONDITION_QUANTITIES_VALID_PREFIXES
148151
+ INITIAL_CONDITION_QUANTITIES_VALID_PREFIXES
152+
+ PARAMETER_QUANTITIES_VALID_PREFIXES
149153
)
150154

151155
ExtOldQuantity = StrEnum("ExtOldQuantity", ALL_QUANTITIES)

hydrolib/tools/extforce_convert/data/data.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ external_forcing:
4747
- totalwaveenergydissipation
4848
# do not convert for now
4949
- bedrock_surface_elevation
50+
# Lateral quantities are supported in the kernel, but not yet in the converter
51+
- lateraldischarge
52+
- lateraldischarge1d
53+
- lateraldischarge2d
5054
unsupported_prefixes:
5155
# initial conditions
5256
- initialsediment

hydrolib/tools/extforce_convert/main_converter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ def update(
323323
total=num_quantities, desc="Converting forcings", unit="forcing"
324324
) as progress_bar:
325325
for forcing in self.extold_model.forcing:
326-
if forcing.quantity in self.un_supported_quantities:
326+
if forcing.quantity.lower() in self.un_supported_quantities:
327327
print(
328328
f"The quantity {forcing.quantity} is not supported, and the debug mode is {self.debug}. "
329329
"So the forcing will not be converted (stay in the old external forcing file)."

0 commit comments

Comments
 (0)