Bank Erosion Module#
The Bank Erosion module is responsible for calculating bank erosion based on hydrodynamic data and detected bank lines. It is one of the core components of the D-FAST Bank Erosion software.
Overview#
The Bank Erosion module calculates the amount of bank material that will be eroded during the first year and until equilibrium, based on hydrodynamic simulation results and detected bank lines. It takes into account various factors such as river geometry, discharge levels, and shipping parameters.
classDiagram
%% Main Classes
%% Generic Base Class
class BaseBank~T~ {
+T left
+T right
+Optional[int] id
+get_bank(int)
+from_column_arrays(Dict, Type, Tuple)
+__iter__()
}
class Erosion {
-ConfigFile config_file
-bool gui
-Path bank_dir
-Path output_dir
-bool debug
-dict plot_flags
-ErosionCalculator erosion_calculator
+__init__(ConfigFile, bool)
+run()
-_process_river_axis_by_center_line()
-_get_fairway_data(LineGeometry, MeshData)
+calculate_fairway_bank_line_distance(BankData, FairwayData, ErosionSimulationData)
-_prepare_initial_conditions(ConfigFile, List, FairwayData)
-_process_discharge_levels(array, tuple, ConfigFile, ErosionInputs, BankData, FairwayData)
-_postprocess_erosion_results(tuple, array, BankData, ErosionResults)
+compute_erosion_per_level(int, BankData, ErosionSimulationData, FairwayData, SingleLevelParameters, ErosionInputs, tuple, int, array)
-_write_bankline_shapefiles(list, list, ConfigFile)
-_write_volume_outputs(ErosionResults, array)
-_generate_plots(array, ErosionSimulationData, list, array, float, ErosionInputs, WaterLevelData, MeshData, BankData, ErosionResults)
}
class ErosionCalculator {
+comp_erosion_eq(array, array, array, SingleParameters, array, array, SingleErosion)
+compute_bank_erosion_dynamics(SingleCalculation, array, array, array, array, SingleParameters, float, array, SingleErosion)
+comp_hw_ship_at_bank(array, array, array, array, array, array, array)
}
class ConfigFile {
-ConfigParser config
-str path
+__init__(ConfigParser, Path)
+read(Path)
+write(str)
+make_paths_absolute()
+get_str(str, str, str)
+get_bool(str, str, bool)
+get_float(str, str, float, bool)
+get_int(str, str, int, bool)
+get_sim_file(str, str)
+get_start_end_stations()
+get_search_lines()
+read_bank_lines(str)
+get_parameter(str, str, List, Any, str, bool, List, bool)
+get_bank_search_distances(int)
+get_range(str, str)
+get_river_center_line()
+resolve(str)
+relative_to(str)
+get_plotting_flags(Path)
+get_output_dir(str)
}
%% Data Models - Bank Erosion
class ErosionRiverData {
-ConfigFile config_file
-LineString river_center_line
-Tuple station_bounds
+__init__(ConfigFile)
+simulation_data()
-_get_bank_output_dir()
-_get_bank_line_dir()
-_read_river_axis()
}
class ErosionSimulationData {
+compute_mesh_topology()
+apply_masked_indexing(array, array)
+calculate_bank_velocity(SingleBank, array)
+calculate_bank_height(SingleBank, array)
}
class BankData {
+List banks
+from_column_arrays(dict, Type, GeoDataFrame, int, Tuple)
+bank_line_coords()
+is_right_bank()
+bank_chainage_midpoints()
+num_stations_per_bank()
}
class SingleBank {
+LineString bank_line
+array face_indices
+array chainage
+bool is_right
+__post_init__()
-_segment_length()
-_dx()
-_dy()
+get_mid_points(bool, str)
}
class FairwayData {
+LineString fairway_axis
+Polygon fairway_polygon
+array fairway_initial_water_levels
+array fairway_velocities
+array fairway_chezy_coefficients
}
class ErosionInputs {
+List banks
+dict shipping_data
+from_column_arrays(dict, Type, Dict, array, Tuple)
+bank_protection_level()
+tauc()
}
class SingleErosion {
+array wave_fairway_distance_0
+array wave_fairway_distance_1
+array bank_protection_level
+array tauc
+array bank_type
}
class ErosionResults {
+int erosion_time
+List velocity
+List bank_height
+List water_level
+List chezy
+List vol_per_discharge
+List ship_wave_max
+List ship_wave_min
+List line_size
+List flow_erosion_dist
+List ship_erosion_dist
+List total_erosion_dist
+List total_eroded_vol
+List eq_erosion_dist
+List eq_eroded_vol
+array avg_erosion_rate
+array eq_eroded_vol_per_km
+array total_eroded_vol_per_km
}
class WaterLevelData {
+List water_levels
+array hfw_max
}
class MeshData {
+array x_node
+array y_node
+array n_nodes
+array face_node
+array face_x
+array face_y
+array face_area
+array face_nodes_count
+array face_nodes_indices
}
class DischargeLevels {
+List levels
+__init__(List)
+__getitem__(int)
+__len__()
+append(SingleDischargeLevel)
+get_max_hfw_level()
+total_erosion_volume()
+__iter__()
+accumulate(str, str)
-_accumulate_attribute_side(str, str)
-_get_attr_both_sides_level(str, object)
+get_attr_level(str)
+get_water_level_data(array)
}
class SingleDischargeLevel {
+List banks
+from_column_arrays(dict, Type, float, Tuple)
}
class SingleCalculation {
+array water_level
+array velocity
+array chezy
+array flow_erosion_dist
+array ship_erosion_dist
+array total_erosion_dist
+array total_eroded_vol
+array eq_erosion_dist
+array eq_eroded_vol
}
class SingleLevelParameters {
+List banks
}
class SingleParameters {
+float discharge
+float probability
+dict ship_parameters
}
%% Data Models - IO
class LineGeometry {
+LineString line
+dict data
+__init__(LineString, Tuple, str)
+as_array()
+add_data(Dict)
+to_file(str, Dict)
+mask(LineString, Tuple)
-_find_mask_index(float, array)
-_handle_bound(int, float, bool, array)
-_interpolate_point(int, float, array)
+intersect_with_line(array)
}
class BaseSimulationData {
+array x_node
+array y_node
+array n_nodes
+array face_node
+array bed_elevation_location
+array bed_elevation_values
+array water_level_face
+array water_depth_face
+array velocity_x_face
+array velocity_y_face
+array chezy_face
+float dry_wet_threshold
+__init__(array, array, array, array, array, array, array, array, array, array, array, float)
+read(str, str)
+clip(LineString, float)
}
class BaseRiverData {
-ConfigFile config_file
-LineString river_center_line
-Tuple station_bounds
+__init__(ConfigFile)
+get_bbox(array, float)
+get_erosion_sim_data(int)
}
%% Relationships
Erosion --> ConfigFile : uses
Erosion --> ErosionRiverData : uses
Erosion --> ErosionSimulationData : uses
Erosion --> BankData : uses
Erosion --> FairwayData : uses
Erosion --> ErosionInputs : uses
Erosion --> ErosionResults : uses
Erosion --> DischargeLevels : uses
Erosion --> WaterLevelData : uses
Erosion --> MeshData : uses
Erosion --> SingleCalculation : uses
Erosion --> SingleLevelParameters : uses
Erosion --> SingleDischargeLevel : uses
Erosion --> SingleParameters : uses
Erosion --> SingleErosion : uses
Erosion --> Debugger : uses
Erosion --> BankLinesProcessor : uses
Erosion --> LineGeometry : uses
Erosion --> ErosionCalculator : uses
ErosionRiverData --|> BaseRiverData : inherits
ErosionRiverData --> ConfigFile : uses
ErosionSimulationData --|> BaseSimulationData : inherits
ErosionSimulationData --> MeshData : uses
ErosionSimulationData --> SingleBank : uses
%% Inheritance relationships
BankData --|> BaseBank : inherits
BankData --|> BaseBank : inherits
ErosionInputs --|> BaseBank : inherits
SingleDischargeLevel --|> BaseBank : inherits
SingleLevelParameters --|> BaseBank : inherits
%% Containment relationships
BankData --> SingleBank : contains
ErosionInputs --> SingleErosion : contains
SingleDischargeLevel --> SingleCalculation : contains
SingleLevelParameters --> SingleParameters : contains
DischargeLevels --> SingleDischargeLevel : contains
BaseRiverData --> ConfigFile : uses
BaseRiverData --> LineGeometry : uses
Components#
The Bank Erosion module consists of the following components:
Main Classes#
dfastbe.bank_erosion.bank_erosion
#
Copyright (C) 2020 Stichting Deltares.
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation version 2.1.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, see http://www.gnu.org/licenses/.
contact: delft3d.support@deltares.nl Stichting Deltares P.O. Box 177 2600 MH Delft, The Netherlands
All indications and logos of, and references to, "Delft3D" and "Deltares" are registered trademarks of Stichting Deltares, and remain the property of Stichting Deltares. All rights reserved.
INFORMATION This file is part of D-FAST Bank Erosion: https://github.com/Deltares/D-FAST_Bank_Erosion
Erosion
#
Bases: BaseCalculator
Class to handle the bank erosion calculations.
Source code in src/dfastbe/bank_erosion/bank_erosion.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 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 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 318 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 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 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 |
|
__init__(config_file: ConfigFile, gui: bool = False)
#
Initialize the Erosion class.
Source code in src/dfastbe/bank_erosion/bank_erosion.py
77 78 79 80 81 82 83 84 85 86 87 |
|
calculate_fairway_bank_line_distance(bank_data: BankData, fairway_data: FairwayData, simulation_data: ErosionSimulationData)
#
Map bank data to fairway data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bank_data
|
BankData
|
|
required |
fairway_data
|
FairwayData
|
|
required |
simulation_data
|
ErosionSimulationData
|
|
required |
Returns:
Name | Type | Description |
---|---|---|
FairwayData |
The method updates the following attributes in the |
|
BankData |
the following attributes in the |
Source code in src/dfastbe/bank_erosion/bank_erosion.py
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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
|
compute_erosion_per_level(level_i: int, bank_data: BankData, simulation_data: ErosionSimulationData, fairway_data: FairwayData, single_parameters: SingleLevelParameters, erosion_inputs: ErosionInputs, km_bin: Tuple[float, float, float], num_km: int) -> Tuple[SingleDischargeLevel, np.ndarray]
#
Compute the bank erosion for a given level.
Source code in src/dfastbe/bank_erosion/bank_erosion.py
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 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 |
|
run() -> None
#
Run the bank erosion analysis for a specified configuration.
Source code in src/dfastbe/bank_erosion/bank_erosion.py
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 |
|
calculate_alpha(coords: np.ndarray, ind_1: int, ind_2: int, bp: Tuple[int, Any])
#
Calculate the alpha value for the bank erosion model.
Source code in src/dfastbe/bank_erosion/bank_erosion.py
727 728 729 730 731 732 733 734 735 736 737 |
|
Mesh data models#
dfastbe.bank_erosion.mesh.data_models
#
This module defines data structures and methods for handling mesh data and river segments.
Edges
dataclass
#
Dataclass to hold edge candidates for left and right edges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
left
|
int
|
Index of the left edge. |
required |
left_theta
|
float
|
Angle of the left edge in radians. |
required |
right
|
int
|
Index of the right edge. |
required |
right_theta
|
float
|
Angle of the right edge in radians. |
required |
found
|
bool
|
Flag indicating whether a valid edge pair was found. |
False
|
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
|
update_edges_by_angle(edge_index: int, dtheta: float, j, verbose: bool = False)
#
Update the left and right edges based on the angle difference.
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
86 87 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 |
|
MeshData
dataclass
#
Class to hold mesh-related data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x_face_coords
|
ndarray
|
X-coordinates of the mesh faces. |
required |
y_face_coords
|
ndarray
|
Y-coordinates of the mesh faces. |
required |
x_edge_coords
|
ndarray
|
X-coordinates of the mesh edges. |
required |
y_edge_coords
|
ndarray
|
Y-coordinates of the mesh edges. |
required |
face_node
|
ndarray
|
Node connectivity for each face. |
required |
n_nodes
|
ndarray
|
Number of nodes in the mesh. |
required |
edge_node
|
ndarray
|
Node connectivity for each edge. |
required |
edge_face_connectivity
|
ndarray
|
Per edge a list of the indices of the faces on the left and right side of that edge. |
required |
face_edge_connectivity
|
ndarray
|
Per face a list of indices of the edges that together form the boundary of that face. |
required |
boundary_edge_nrs
|
ndarray
|
List of edge indices that together form the boundary of the whole mesh. |
required |
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 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 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 318 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 |
|
calculate_edge_angle(edge: int, reverse: bool = False) -> float
#
Calculate the angle of a mesh edge in radians.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edge
|
int
|
The edge index. |
required |
reverse
|
bool
|
If True, computes the angle from end to start. |
False
|
Returns:
Name | Type | Description |
---|---|---|
float |
float
|
The angle of the edge in radians. |
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
|
calculate_edge_intersections(edges: np.ndarray, segment: RiverSegment, limit_relative_distance: bool = True) -> Tuple[np.ndarray, np.ndarray, np.ndarray]
#
Calculate the intersection of a line segment with multiple mesh edges.
This function determines where a line segment intersects a set of mesh edges. It calculates the relative distances along the segment and the edges where the intersections occur, and returns the indices of the intersected edges.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
edges
|
ndarray
|
Array containing the indices of the edges to check for intersections. |
required |
segment
|
RiverSegment
|
A |
required |
limit_relative_distance
|
bool
|
If True, limits the relative distance along the segment |
True
|
Returns:
Type | Description |
---|---|
Tuple[ndarray, ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray, np.ndarray]:
- a (np.ndarray): Relative distances along the edges where the
intersections occur.
- b (np.ndarray): Relative distances along the segment |
Raises:
Type | Description |
---|---|
ValueError
|
If the input data is invalid or inconsistent. |
Notes
- The function uses the
get_slices_ab
helper function to calculate the relative distancesa
andb
for each edge. - The
bmin
parameter is used to filter out intersections that occur too close to the starting point of the segment. - If
limit_relative_distance
is True, intersections beyond the endpoint of the segment are ignored.
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
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 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
|
find_edges(theta, node, verbose_index: int = None) -> Edges
#
Helper to find the left and right edges at a node based on the direction theta.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
theta
|
float
|
Direction angle of the segment. |
required |
node
|
int
|
The node index. |
required |
verbose_index
|
int
|
Step index for verbose output. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Edges |
Edges
|
A dataclass containing the left and right edge indices, their angle differences, and a found flag. |
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
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 |
|
find_segment_intersections(index: int, segment: RiverSegment) -> Tuple[np.ndarray, np.ndarray, np.ndarray]
#
Calculate the intersection of a line segment with the edges of a mesh face.
This function determines where a line segment (defined by two points) intersects the edges of a mesh face. It returns the relative distances along the segment and the edges where the intersections occur, as well as flags indicating whether the intersections occur at nodes.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index
|
int
|
Index of the current mesh face. If |
required |
segment
|
RiverSegment
|
A |
required |
Returns:
Type | Description |
---|---|
Tuple[ndarray, ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray, np.ndarray]:
- b (np.ndarray):
Relative distances along the segment |
Raises:
Type | Description |
---|---|
ValueError
|
If the input data is invalid or inconsistent. |
Notes
- If
index
is negative, the function assumes the segment intersects the boundary edges of the mesh. - The function uses the
get_slices_core
helper function to calculate the intersections. - Intersections at nodes are flagged in the
nodes
array, with the corresponding node indices.
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
215 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 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
|
get_face_by_index(index: int, as_polygon: bool = False) -> np.ndarray | Polygon
#
Returns the coordinates of the index-th mesh face as an (N, 2) array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
index
|
int
|
The face index. |
required |
as_polygon
|
bool
|
whither to return the face as a shapely polygon or not. Default is False |
False
|
Returns:
Type | Description |
---|---|
ndarray | Polygon
|
np.ndarray: Array of shape (n_nodes, 2) with x, y coordinates. |
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 |
|
locate_point(point: Point | np.ndarray | list | Tuple, face_index: int | np.ndarray) -> int | List[int]
#
Locate a point in the mesh faces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
point
|
Point | ndarray | list | Tuple
|
The point to check. |
required |
face_index
|
int | ndarray
|
The index of the mesh face. |
required |
Returns:
Name | Type | Description |
---|---|---|
indexes |
int | list[int]
|
index if the face that the point is located in, or a list of indexes if the point is on the edge of multiple faces. |
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
resolve_next_face_from_edges(node, edges: Edges, verbose_index: int = None) -> int
#
Helper to resolve the next face index when traversing between two edges at a node.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
node
|
int
|
The node index. |
required |
edges
|
Edges
|
The edges connecting the node, containing left and right edge indices. |
required |
verbose_index
|
int
|
Step index for verbose output. |
None
|
Returns:
Name | Type | Description |
---|---|---|
next_face_index |
int
|
The next face index. |
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
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 |
|
RiverSegment
dataclass
#
Represents a segment of a river line.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
min_relative_distance
|
float
|
The relative distance along the previous segment where the last intersection occurred. Used to filter intersections along the current segment. |
required |
current_point
|
ndarray
|
A 1D array of shape (2,) containing the x, y coordinates of the current point of the line segment. |
required |
previous_point
|
ndarray
|
A 1D array of shape (2,) containing the x, y coordinates of the previous point of the line segment. |
required |
Source code in src/dfastbe/bank_erosion/mesh/data_models.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 |
|
theta
property
#
Calculate the angle of the segment in radians.
is_length_zero() -> bool
#
Check if the segment has zero length.
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
36 37 38 |
|
select_first_intersection()
#
Select the first crossing from a set of edges and their associated distances.
line segment crosses the edge list multiple times - moving out of a cell at a corner node - moving into and out of the mesh from outside
Source code in src/dfastbe/bank_erosion/mesh/data_models.py
49 50 51 52 53 54 55 56 57 58 59 60 |
|
Mesh Processing#
dfastbe.bank_erosion.mesh.processor
#
module for processing mesh-related operations.
IntersectionState
dataclass
#
Source code in src/dfastbe/bank_erosion/mesh/processor.py
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 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 |
|
__init__(shape: Tuple[int, int] = (100, 2), verbose: bool = False)
#
Initialize the intersection results with given shape.
Source code in src/dfastbe/bank_erosion/mesh/processor.py
50 51 52 53 54 55 56 |
|
update(current_bank_point, shape_length: bool = None)
#
Finalize a segment
Enlarge arrays if needed, set coordinates and index, and increment ind.
Source code in src/dfastbe/bank_erosion/mesh/processor.py
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
|
update_index_and_log(status: Status, edge, faces)
#
Helper to update mesh index and log transitions for intersect_line_mesh.
Source code in src/dfastbe/bank_erosion/mesh/processor.py
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
|
MeshProcessor
#
Class to process bank lines and intersect them with a mesh.
Source code in src/dfastbe/bank_erosion/mesh/processor.py
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 |
|
__init__(river_data: ErosionRiverData, mesh_data: MeshData, verbose: bool = False)
#
Constructor for MeshProcessor.
Source code in src/dfastbe/bank_erosion/mesh/processor.py
487 488 489 490 491 492 |
|
get_bank_data() -> BankData
#
Intersect bank lines with a mesh and return bank data.
Returns:
Type | Description |
---|---|
BankData
|
BankData object containing bank line coordinates, face indices, and other bank-related data. |
Source code in src/dfastbe/bank_erosion/mesh/processor.py
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 |
|
MeshWrapper
#
A class for processing mesh-related operations.
Source code in src/dfastbe/bank_erosion/mesh/processor.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 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 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 318 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 |
|
determine_next_face_on_edge(segment: RiverSegment, next_point: List[float], edge, faces)
#
Determine the next face to continue along an edge based on the segment direction.
Source code in src/dfastbe/bank_erosion/mesh/processor.py
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 |
|
intersect_with_coords(given_coords: np.ndarray) -> Tuple[np.ndarray, np.ndarray]
#
Intersects a coords with an unstructured mesh and returns the intersection coordinates and mesh face indices.
This function determines where a given line (e.g., a bank line) intersects the faces of an unstructured mesh. It calculates the intersection points and identifies the mesh faces corresponding to each segment of the line.
Returns:
Type | Description |
---|---|
Tuple[ndarray, ndarray]
|
Tuple[np.ndarray, np.ndarray]:
A tuple containing:
- |
Raises:
Type | Description |
---|---|
Exception
|
If the line starts outside the mesh and cannot be associated with any mesh face, or if the line crosses ambiguous regions (e.g., edges shared by multiple faces). |
Notes
- The function uses Shapely geometry operations to determine whether points are inside polygons or on edges.
- The function handles cases where the line starts outside the mesh, crosses multiple edges, or ends on a node.
- Tiny segments shorter than
d_thresh
are removed from the output.
Source code in src/dfastbe/bank_erosion/mesh/processor.py
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 |
|
resolve_next_face_by_direction(theta: float, node, verbose_index: int = None)
#
Helper to resolve the next face index based on the direction theta at a node.
Source code in src/dfastbe/bank_erosion/mesh/processor.py
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 |
|
For more details, see Bank Erosion Mesh Processor.
Debugging Utilities#
dfastbe.bank_erosion.debugger
#
Bank Erosion Debugger.
Debugger
#
Class to handle debugging and output of bank erosion calculations.
Source code in src/dfastbe/bank_erosion/debugger.py
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 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
|
__init__(crs: str, output_dir: str)
#
Debugger constructor.
Source code in src/dfastbe/bank_erosion/debugger.py
23 24 25 26 |
|
last_discharge_level(bank_index: int, single_bank: SingleBank, fairway_data: FairwayData, erosion_inputs: SingleErosion, single_parameters: SingleParameters, single_calculation: SingleCalculation)
#
Write the last discharge level to a shapefile and CSV file.
Source code in src/dfastbe/bank_erosion/debugger.py
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 |
|
middle_levels(bank_ind: int, q_level: int, single_bank: SingleBank, fairway_data: FairwayData, erosion_inputs: SingleErosion, single_parameters: SingleParameters, single_calculation: SingleCalculation)
#
Write the middle levels to a shapefile and CSV file.
Source code in src/dfastbe/bank_erosion/debugger.py
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 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
For more details, see Bank Erosion Debugger.
Data Models#
The Bank Erosion module uses several data models to represent inputs, calculation parameters, and results:
Calculation Data Models#
dfastbe.bank_erosion.data_models.calculation
#
Erosion-related data structures.
BankData
dataclass
#
Bases: BaseBank[SingleBank]
Class to hold bank-related data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
is_right_bank
|
List[bool]
|
List indicating if the bank is right or not. |
required |
bank_chainage_midpoints
|
List[ndarray]
|
River chainage for the midpoints of each segment of the bank line |
required |
bank_line_coords
|
List[ndarray]
|
Coordinates of the bank lines. |
required |
bank_face_indices
|
List[ndarray]
|
Indices of the faces associated with the banks. |
required |
bank_lines
|
GeoDataFrame
|
GeoDataFrame containing the bank lines. |
GeoDataFrame()
|
n_bank_lines
|
int
|
Number of bank lines. |
0
|
bank_line_size
|
List[ndarray]
|
Size of each individual bank line. |
required |
fairway_distances
|
List[ndarray]
|
The distance of each bank line point to the closest fairway point. |
required |
fairway_face_indices
|
List[ndarray]
|
The face index of the closest fairway point for each bank line point. |
required |
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 318 319 320 321 322 323 324 325 326 327 |
|
bank_chainage_midpoints: List[np.ndarray]
property
#
Get the chainage midpoints of the bank lines.
bank_line_coords: List[np.ndarray]
property
#
Get the coordinates of the bank lines.
height: List[np.ndarray]
property
#
Get the bank height.
is_right_bank: List[bool]
property
#
Get the bank direction.
num_stations_per_bank: List[int]
property
#
Get the number of stations per bank.
BaseBank
dataclass
#
Bases: Generic[GenericType]
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
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 |
|
__iter__() -> Iterator[GenericType]
#
Iterate over the banks.
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
85 86 87 |
|
DischargeLevels
#
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
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 |
|
get_attr_level(attribute_name: str) -> List[List[np.ndarray]]
#
Get the attributes of the levels for both left and right bank.
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
542 543 544 |
|
ErosionInputs
dataclass
#
Bases: BaseBank[SingleErosion]
Class to hold erosion inputs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shipping_data
|
Dict[str, ndarray]
|
Data on all the vessels that travel through the river. |
dict()
|
wave_fairway_distance_0
|
List[ndarray]
|
Threshold fairway distance 0 for wave attenuation. |
required |
wave_fairway_distance_1
|
List[ndarray]
|
Threshold fairway distance 1 for wave attenuation. |
required |
bank_protection_level
|
List[ndarray]
|
Bank protection level. |
required |
tauc
|
List[ndarray]
|
Critical bank shear stress values. |
required |
bank_type
|
List[ndarray]
|
Integer representation of the bank type. Represents an index into the taucls_str array. |
(lambda: array([]))()
|
taucls
|
ndarray
|
Critical bank shear stress values for different bank types. |
required |
taucls_str
|
Tuple[str]
|
String representation for different bank types. |
required |
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
bank_protection_level: List[np.ndarray]
property
#
Get the bank protection level.
tauc: List[np.ndarray]
property
#
Get the critical bank shear stress values.
ErosionResults
dataclass
#
Class to hold erosion results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
eq_erosion_dist
|
List[ndarray]
|
Erosion distance at equilibrium for each bank line. |
required |
total_erosion_dist
|
List[ndarray]
|
Total erosion distance for each bank line. |
required |
flow_erosion_dist
|
List[ndarray]
|
Total erosion distance caused by flow for each bank line. |
required |
ship_erosion_dist
|
List[ndarray]
|
Total erosion distance caused by ship waves for each bank line. |
required |
eq_eroded_vol
|
List[ndarray]
|
Eroded volume at equilibrium for each bank line. |
required |
total_eroded_vol
|
List[ndarray]
|
Total eroded volume for each bank line. |
required |
erosion_time
|
int
|
Time over which erosion is calculated. |
required |
avg_erosion_rate
|
ndarray
|
Average erosion rate data. |
(lambda: empty(0))()
|
eq_eroded_vol_per_km
|
ndarray
|
Equilibrium eroded volume calculated per kilometer bin. |
(lambda: empty(0))()
|
total_eroded_vol_per_km
|
ndarray
|
Total eroded volume calculated per kilometer bin. |
(lambda: empty(0))()
|
Examples:
-
You can create an instance of the ErosionResults class as follows:
>>> from dfastbe.bank_erosion.data_models.calculation import ErosionResults >>> import numpy as np >>> erosion_results = ErosionResults( ... eq_erosion_dist=[np.array([0.1, 0.2])], ... total_erosion_dist=[np.array([0.3, 0.4])], ... flow_erosion_dist=[np.array([0.5, 0.6])], ... ship_erosion_dist=[np.array([0.7, 0.8])], ... eq_eroded_vol=[np.array([1.1, 1.2])], ... total_eroded_vol=[np.array([1.3, 1.4])], ... erosion_time=10, ... avg_erosion_rate=np.array([0.1, 0.2]), ... eq_eroded_vol_per_km=np.array([0.3, 0.4]), ... total_eroded_vol_per_km=np.array([0.5, 0.6]), ... ) >>> print(erosion_results) ErosionResults(eq_erosion_dist=[array([0.1, 0.2])], total_erosion_dist=[array([0.3, 0.4])], flow_erosion_dist=[array([0.5, 0.6])], ship_erosion_dist=[array([0.7, 0.8])], eq_eroded_vol=[array([1.1, 1.2])], total_eroded_vol=[array([1.3, 1.4])], erosion_time=10, avg_erosion_rate=array([0.1, 0.2]), eq_eroded_vol_per_km=array([0.3, 0.4]), total_eroded_vol_per_km=array([0.5, 0.6]))
-
The
avg_erosion_rate
,eq_eroded_vol_per_km
, andtotal_eroded_vol_per_km
attributes are optional and can be set to empty arrays if not needed.
>>> from dfastbe.bank_erosion.data_models.calculation import ErosionResults
>>> import numpy as np
>>> erosion_results = ErosionResults(
... eq_erosion_dist=[np.array([0.1, 0.2])],
... total_erosion_dist=[np.array([0.3, 0.4])],
... flow_erosion_dist=[np.array([0.5, 0.6])],
... ship_erosion_dist=[np.array([0.7, 0.8])],
... eq_eroded_vol=[np.array([1.1, 1.2])],
... total_eroded_vol=[np.array([1.3, 1.4])],
... erosion_time=10,
... )
>>> print(erosion_results)
ErosionResults(eq_erosion_dist=[array([0.1, 0.2])], total_erosion_dist=[array([0.3, 0.4])], flow_erosion_dist=[array([0.5, 0.6])], ship_erosion_dist=[array([0.7, 0.8])], eq_eroded_vol=[array([1.1, 1.2])], total_eroded_vol=[array([1.3, 1.4])], erosion_time=10, avg_erosion_rate=array([], dtype=float64), eq_eroded_vol_per_km=array([], dtype=float64), total_eroded_vol_per_km=array([], dtype=float64))
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
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 |
|
FairwayData
dataclass
#
Class to hold fairway-related data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
fairway_face_indices
|
ndarray
|
Mesh face indices matching to the fairway points. |
required |
intersection_coords
|
ndarray
|
The x, y coordinates of the intersection points of the fairway with the simulation mesh. |
required |
fairway_initial_water_levels
|
List[ndarray]
|
Reference water level at the fairway |
list()
|
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 |
|
SingleBank
dataclass
#
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 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 244 245 246 247 248 249 250 251 |
|
__post_init__()
#
Post-initialization to ensure bank_line_coords is a list of numpy arrays.
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
203 204 205 206 207 208 |
|
get_mid_points(as_geo_series: bool = False, crs: str = None) -> Union[GeoSeries, np.ndarray]
#
Band line midpoints.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
as_geo_series
|
bool
|
bool indicating if the output should be a GeoSeries or not. |
False
|
crs
|
str
|
coordinate reference system. |
None
|
Returns: the midpoints of the bank line coordinates as a GeoSeries or numpy array.
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
WaterLevelData
dataclass
#
Class to hold water level data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
hfw_max
|
float
|
Maximum water depth along the fairway. |
required |
water_level
|
List[List[ndarray]]
|
Water level data. |
required |
ship_wave_max
|
List[List[ndarray]]
|
Maximum bank height subject to ship waves [m] |
required |
ship_wave_min
|
List[List[ndarray]]
|
Minimum bank height subject to ship waves [m] |
required |
velocity
|
List[List[ndarray]]
|
Flow velocity magnitude along the bank [m/s] |
required |
bank_height
|
List[ndarray]
|
Bank height data. |
required |
chezy
|
List[List[ndarray]]
|
Chezy coefficient data. |
required |
vol_per_discharge
|
List[List[ndarray]]
|
Eroded volume per discharge level for each bank line. |
required |
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
|
For more details, see Bank Erosion Calculation Data Models.
Input Data Models#
dfastbe.bank_erosion.data_models.inputs
#
BankLinesResultsError
#
Bases: Exception
Custom exception for BankLine results errors.
Source code in src/dfastbe/bank_erosion/data_models/inputs.py
530 531 532 533 |
|
ErosionRiverData
#
Bases: BaseRiverData
Source code in src/dfastbe/bank_erosion/data_models/inputs.py
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 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 318 319 320 321 322 323 324 325 326 327 328 329 |
|
process_river_axis_by_center_line() -> LineGeometry
#
Process the river axis by the center line.
Intersect the river center line with the river axis to map the stations from the first to the latter then clip the river axis by the first and last station of the centerline.
Source code in src/dfastbe/bank_erosion/data_models/inputs.py
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 318 319 320 321 322 323 324 325 326 327 328 329 |
|
simulation_data() -> ErosionSimulationData
#
Simulation Data.
Source code in src/dfastbe/bank_erosion/data_models/inputs.py
247 248 249 250 251 252 253 254 255 256 257 |
|
ErosionSimulationData
#
Bases: BaseSimulationData
Source code in src/dfastbe/bank_erosion/data_models/inputs.py
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 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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
apply_masked_indexing(x0: np.array, idx: np.ma.masked_array) -> np.ma.masked_array
staticmethod
#
Index one array by another transferring the mask.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x0
|
np.ndarray A linear array. |
required | |
idx
|
np.ma.masked_array An index array with possibly masked indices. |
required |
Returns:
Name | Type | Description |
---|---|---|
x1 |
masked_array
|
np.ma.masked_array An array with same shape as idx, with mask. |
Source code in src/dfastbe/bank_erosion/data_models/inputs.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
compute_mesh_topology(verbose: bool = False) -> MeshData
#
Derive secondary topology arrays from the face-node connectivity of the mesh.
This function computes the edge-node, edge-face, and face-edge connectivity arrays, as well as the boundary edges of the mesh, based on the face-node connectivity provided in the simulation data.
Returns:
Name | Type | Description |
---|---|---|
MeshData |
MeshData
|
a dataclass containing the following attributes:
- |
Raises:
Type | Description |
---|---|
KeyError
|
If required keys (e.g., |
Notes
- The function identifies unique edges by sorting and comparing node indices.
- Boundary edges are identified as edges that belong to only one face.
- The function assumes that the mesh is well-formed, with consistent face-node connectivity.
Source code in src/dfastbe/bank_erosion/data_models/inputs.py
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 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 133 134 135 136 137 138 139 140 141 142 143 144 |
|
ShipsParameters
dataclass
#
Data for ships going through the fairway for bank erosion simulation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config_file
|
ConfigFile
|
Configuration file containing parameters. |
required |
velocity
|
List[ndarray]
|
Ship velocities for each bank. |
required |
number
|
List[ndarray]
|
Number of ships for each bank. |
required |
num_waves
|
List[ndarray]
|
Number of waves per ship for each bank. |
required |
draught
|
List[ndarray]
|
Draught of ships for each bank. |
required |
type
|
List[ndarray]
|
Type of ships for each bank. |
required |
slope
|
List[ndarray]
|
Slope values for each bank. |
required |
reed
|
List[ndarray]
|
Reed values for each bank. |
required |
Source code in src/dfastbe/bank_erosion/data_models/inputs.py
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 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 |
|
get_ship_data(num_stations_per_bank: List[int], config_file: ConfigFile) -> ShipsParameters
classmethod
#
Get ship parameters from the configuration file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
num_stations_per_bank
|
List[int]
|
The number of stations per bank. |
required |
config_file
|
ConfigFile
|
Configuration file containing parameters. |
required |
Returns:
Name | Type | Description |
---|---|---|
ShipsParameters |
ShipsParameters
|
An instance of ShipsParameters with parameters read from the config file. |
Source code in src/dfastbe/bank_erosion/data_models/inputs.py
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 |
|
read_discharge_parameters(level_i: int, num_stations_per_bank: List[int]) -> SingleLevelParameters
#
Read Discharge level parameters.
Read all discharge-specific input arrays for level_i.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
level_i
|
int
|
The index of the discharge level. |
required |
num_stations_per_bank
|
List[int]
|
The number of stations per bank. |
required |
Returns:
Name | Type | Description |
---|---|---|
SingleLevelParameters |
SingleLevelParameters
|
The discharge level parameters. |
Source code in src/dfastbe/bank_erosion/data_models/inputs.py
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 |
|
For more details, see Bank Erosion Input Data Models.
Workflow#
The typical workflow for bank erosion calculation is:
- Initialize the Erosion object with a configuration file
- Call the
run
method to start the erosion calculation process - The
run
method orchestrates the entire process: - Processes the river axis
- Gets fairway data
- Calculates bank-fairway distance
- Prepares initial conditions
- Processes discharge levels
- Computes erosion per level
- Post-processes results
- Writes output files
- Generates plots
Usage Example#
from dfastbe.io.config import ConfigFile
from dfastbe.bank_erosion.bank_erosion import Erosion
# Load configuration file
config_file = ConfigFile.read("config.cfg")
# Initialize Erosion object
erosion = Erosion(config_file)
# Run erosion calculation
erosion.run()
For more details on the specific methods and classes, refer to the API reference below.