Config#
The schema of a YAML run configuration. Each block below is one top-level key of the file; the
rules tying them together — which blocks a given spatial_resolution requires, and which it
refuses — live on RunConfig.
Build a model from a file with
Catchment.from_yaml.
RunConfig#
hapi.config.RunConfig
#
Bases: BaseModel
The full input set for one Catchment build.
Attributes:
| Name | Type | Description |
|---|---|---|
catchment |
CatchmentConfig
|
Constructor arguments. |
meteo |
MeteoConfig
|
The meteorological drivers. |
conceptual_model |
ConceptualModelConfig
|
The lumped conceptual model. |
parameters |
ParametersConfig | None
|
Where the conceptual-model parameters live. Omit for a calibration, which
derives them from the bounds handed to |
gauges |
GaugesConfig | None
|
The observed discharge. Omit for a run that is not scored against gauges. |
flow_network |
FlowNetworkConfig | None
|
The routing network. Required for a distributed run and refused for a lumped one, which has no grid to put it on. |
outputs |
OutputsConfig | None
|
Where to write results. |
Source code in src/hapi/config.py
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 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | |
CatchmentConfig#
hapi.config.CatchmentConfig
#
Bases: BaseModel
The Catchment constructor arguments.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Catchment name. |
start |
str
|
Start date, parsed with |
end |
str
|
End date, parsed with |
fmt |
str
|
|
spatial_resolution |
Literal['lumped', 'distributed']
|
|
temporal_resolution |
Literal['daily', 'hourly']
|
|
routing_method |
Literal['muskingum', 'maxbas']
|
|
Source code in src/hapi/config.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | |
MeteoConfig#
hapi.config.MeteoConfig
#
Bases: BaseModel
The meteorological drivers: a distributed grid or a lumped CSV.
Attributes:
| Name | Type | Description |
|---|---|---|
source |
Literal['rasters', 'netcdf', 'netcdf_files']
|
Which |
precipitation |
str | None
|
Rainfall folder ( |
temperature |
str | None
|
As |
evapotranspiration |
str | None
|
As |
path |
str | None
|
The combined NetCDF ( |
variable |
str | None
|
Which variable to take from each file, |
start |
str | None
|
Window start; |
end |
str | None
|
Window end; |
fmt |
str
|
|
glob |
str
|
Raster glob, |
regex_string |
str
|
Date regex within file names, |
file_name_data_fmt |
str | None
|
|
per_variable |
dict[str, dict[str, Any]] | None
|
Per-folder overrides of the reader arguments, |
gdal_env |
dict[str, str] | None
|
GDAL environment overrides for the raster read, |
Source code in src/hapi/config.py
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 | |
FlowNetworkConfig#
hapi.config.FlowNetworkConfig
#
Bases: BaseModel
The routing network. Distributed runs only.
Attributes:
| Name | Type | Description |
|---|---|---|
flow_accumulation |
str
|
Path to the flow-accumulation raster. |
flow_direction |
str | None
|
Path to the flow-direction raster. Muskingum needs it; MAXBAS sends every cell straight to the outlet and never reads one, so it may be omitted. |
Source code in src/hapi/config.py
374 375 376 377 378 379 380 381 382 383 384 385 386 | |
ParametersConfig#
hapi.config.ParametersConfig
#
Bases: BaseModel
Where the conceptual-model parameters live.
Attributes:
| Name | Type | Description |
|---|---|---|
path |
str
|
Folder of parameter rasters (distributed) or a single file (lumped). |
snow |
bool
|
Whether the parameter set includes the snow routine (15 parameters against 10). |
maxbas |
bool
|
Whether the set carries the triangular-routing parameter. It describes the
parameter set rather than the run, but |
Source code in src/hapi/config.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 | |
ConceptualModelConfig#
hapi.config.ConceptualModelConfig
#
Bases: BaseModel
The lumped conceptual model, run per cell (distributed) or per catchment (lumped).
Attributes:
| Name | Type | Description |
|---|---|---|
model_class |
str
|
Name of the conceptual model, e.g. |
catchment_area |
float
|
Catchment area, km2. |
initial_condition |
list[float]
|
|
q_init |
float | None
|
Initial discharge; |
Source code in src/hapi/config.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 | |
GaugesConfig#
hapi.config.GaugesConfig
#
Bases: BaseModel
The observed discharge the run is scored against.
Attributes:
| Name | Type | Description |
|---|---|---|
discharge |
str
|
Folder of one CSV per gauge id (distributed) or a single CSV (lumped). |
table |
str | None
|
Gauge locations and properties. Distributed only; a lumped run has no grid to locate gauges on. |
column |
str
|
Gauge-table column naming the columns of the resulting hydrograph frame. It
does not select the discharge file names -- |
delimiter |
str
|
Discharge CSV delimiter. |
fmt |
str
|
|
table_fmt |
str | None
|
|
Source code in src/hapi/config.py
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 | |
OutputsConfig#
hapi.config.OutputsConfig
#
Bases: BaseModel
Where to write results after the run.
Attributes:
| Name | Type | Description |
|---|---|---|
results_dir |
str | None
|
Folder |
Source code in src/hapi/config.py
459 460 461 462 463 464 465 466 467 468 | |