DIMR xml files¶
The input to the Deltares Integrated Model Runner (DIMR) is a single XML file, represented by the classes below.
Model¶
Dimr models.
Component
¶
Bases: BaseModel
, ABC
Specification of a BMI-compliant model component instance that will be executed by DIMR.
Attributes:
Name | Type | Description |
---|---|---|
library |
str
|
The library name of the compoment. |
name |
str
|
The component name. |
workingDir |
Path
|
The working directory. |
inputFile |
Path
|
The name of the input file. |
process |
Optional[int]
|
Number of subprocesses in the component. |
setting |
Optional[List[KeyValuePair]]
|
A list of variables that are provided to the BMI model before initialization. |
parameter |
Optional[List[KeyValuePair]]
|
A list of variables that are provided to the BMI model after initialization. |
mpiCommunicator |
Optional[str]
|
The MPI communicator value. |
model |
Optional[FileModel]
|
The model represented by this component. |
Source code in hydrolib/core/dimr/models.py
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 |
|
ComponentOrCouplerRef
¶
Bases: BaseModel
Reference to a BMI-compliant model component instance.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the reference to a BMI-compliant model component instance. |
Source code in hydrolib/core/dimr/models.py
171 172 173 174 175 176 177 178 179 180 181 182 |
|
ControlModel
¶
Bases: BaseModel
Control Model.
Overrides to make sure that the control elements in the DIMR are parsed and serialized correctly.
Source code in hydrolib/core/dimr/models.py
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
dict(*args, **kwargs)
¶
Add control element prefixes for serialized data.
Source code in hydrolib/core/dimr/models.py
274 275 276 277 278 |
|
validate(v)
classmethod
¶
Remove control element prefixes from parsed data.
Source code in hydrolib/core/dimr/models.py
280 281 282 283 284 285 286 287 288 |
|
CoupledItem
¶
Bases: BaseModel
Specification of an item that has to be exchanged.
Attributes:
Name | Type | Description |
---|---|---|
sourceName |
str
|
Name of the item at the source component. |
targetName |
str
|
Name of the item at the target component. |
Source code in hydrolib/core/dimr/models.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
|
Coupler
¶
Bases: BaseModel
Specification of the coupling actions to be performed between two BMI-compliant model components.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
The name of the coupler. |
sourceComponent |
str
|
The component that provides the data to has to be exchanged. |
targetComponent |
str
|
The component that consumes the data to has to be exchanged. |
item |
List[CoupledItem]
|
A list of items that have to be exchanged. |
logger |
Optional[Logger]
|
Logger for logging the values that get exchanged. |
Source code in hydrolib/core/dimr/models.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
|
DIMR
¶
Bases: ParsableFileModel
DIMR model representation.
Attributes:
Name | Type | Description |
---|---|---|
documentation |
Documentation
|
File metadata. |
control |
List[Union[Start, Parallel]]
|
The |
component |
List[Union[RRComponent, FMComponent, Component]]
|
List of
|
coupler |
Optional[List[Coupler]]
|
optional list of |
waitFile |
Optional[str]
|
Optional waitfile name for debugging. |
global_settings |
Optional[GlobalSettings]
|
Optional global DIMR settings. |
Source code in hydrolib/core/dimr/models.py
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
|
Documentation
¶
Bases: BaseModel
Information on the present DIMR configuration file.
Attributes:
Name | Type | Description |
---|---|---|
fileVersion |
str
|
The DIMR file version. |
createdBy |
str
|
Creators of the DIMR file. |
creationDate |
datetime
|
The creation date of the DIMR file. |
Source code in hydrolib/core/dimr/models.py
145 146 147 148 149 150 151 152 153 154 155 156 157 |
|
FMComponent
¶
Bases: Component
Component to include the D-Flow FM program in a DIMR control flow.
Source code in hydrolib/core/dimr/models.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
|
validate_process(value, values)
¶
Validation for the process Attribute.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
The value which is to be validated for process. |
required | |
values
|
FMComponent used to retrieve the name of the component. |
required |
Returns:
Name | Type | Description |
---|---|---|
int |
Union[None, int]
|
The process as int, when given value is None, None is returned. |
Raises:
Type | Description |
---|---|
ValueError
|
When value is set to 0 or negative. |
ValueError
|
When value is not int or None. |
Source code in hydrolib/core/dimr/models.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
|
GlobalSettings
¶
Bases: BaseModel
Global settings for the DIMR configuration.
Attributes:
Name | Type | Description |
---|---|---|
logger_ncFormat |
int
|
NetCDF format type for logging. |
Source code in hydrolib/core/dimr/models.py
160 161 162 163 164 165 166 167 168 |
|
KeyValuePair
¶
Bases: BaseModel
Key value pair to specify settings and parameters.
Attributes:
Name | Type | Description |
---|---|---|
key |
str
|
The key. |
value |
str
|
The value. |
Source code in hydrolib/core/dimr/models.py
25 26 27 28 29 30 31 32 33 34 |
|
Logger
¶
Bases: BaseModel
Logger.
Used to log values to the specified file in workingdir for each timestep
Attributes:
Name | Type | Description |
---|---|---|
workingDir |
Path
|
Directory where the log file is written. |
outputFile |
Path
|
Name of the log file. |
Source code in hydrolib/core/dimr/models.py
202 203 204 205 206 207 208 209 210 211 212 213 |
|
Parallel
¶
Bases: ControlModel
Parallel control flow.
Specification of a parallel control flow: one main component and a group of related components and couplers. Step wise execution order according to order in parallel control flow.
Attributes:
Name | Type | Description |
---|---|---|
startGroup |
StartGroup
|
Group of components and couplers to be executed. |
start |
ComponentOrCouplerRef
|
Main component to be executed step wise (provides start time, end time and time step). |
Source code in hydrolib/core/dimr/models.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
RRComponent
¶
Bases: Component
Component to include the RainfallRunoff program in a DIMR control flow.
Source code in hydrolib/core/dimr/models.py
135 136 137 138 139 140 141 142 |
|
Start
¶
Bases: ControlModel
Specification of a serial control flow: one main component.
Attributes:
Name | Type | Description |
---|---|---|
name |
str
|
Name of the reference to a BMI-compliant model component instance |
Source code in hydrolib/core/dimr/models.py
307 308 309 310 311 312 313 314 315 316 |
|
StartGroup
¶
Bases: BaseModel
Specification of model components and couplers to be executed with a certain frequency.
Attributes:
Name | Type | Description |
---|---|---|
time |
str
|
Time frame specification for the present group: start time, stop time and frequency. Expressed in terms of the time frame of the main component. |
start |
List[ComponentOrCouplerRef]
|
Ordered list of components to be executed. |
coupler |
List[ComponentOrCouplerRef]
|
Oredered list of couplers to be executed. |
Source code in hydrolib/core/dimr/models.py
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
|
Parser¶
DIMR Parser.
DIMRParser
¶
A parser for DIMR xml files.
Source code in hydrolib/core/dimr/parser.py
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 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 |
|
parse(path)
staticmethod
¶
Parses a DIMR file to a dictionary.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path
|
Path to the DIMR configuration file. |
required |
Source code in hydrolib/core/dimr/parser.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Serializer¶
DIMR Serializer.
DIMRSerializer
¶
A serializer for DIMR files.
Source code in hydrolib/core/dimr/serializer.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 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 89 90 91 92 93 94 95 96 |
|
serialize(path, data, config, save_settings)
staticmethod
¶
Serializes the DIMR data to the file at the specified path.
Attributes:
Name | Type | Description |
---|---|---|
path |
Path
|
The path to the destination file. |
data |
Dict
|
The data to be serialized. |
config |
SerializerConfig
|
The serialization configuration. |
save_settings |
ModelSaveSettings
|
The model save settings. |
Source code in hydrolib/core/dimr/serializer.py
17 18 19 20 21 22 23 24 25 26 27 28 29 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 |
|