Bank Erosion Calculation Data Models#
The Bank Erosion Calculation Data Models module provides data structures for representing calculation parameters, inputs, and results in the D-FAST Bank Erosion software.
Overview#
The Bank Erosion Calculation Data Models module contains classes that represent various aspects of bank erosion calculations, such as bank data, erosion inputs, calculation parameters, and results. These data models are used by the Bank Erosion module to process and analyze bank erosion.
Components#
The Bank Erosion Calculation Data Models module consists of the following components:
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
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 |
|
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
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 |
|
__iter__() -> Iterator[GenericType]
#
Iterate over the banks.
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
69 70 71 |
|
DischargeLevels
#
Source code in src/dfastbe/bank_erosion/data_models/calculation.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 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 |
|
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
567 568 569 |
|
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
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 |
|
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
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 |
|
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
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 |
|
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/data_models/calculation.py
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 |
|
SingleBank
dataclass
#
Source code in src/dfastbe/bank_erosion/data_models/calculation.py
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 |
|
__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
227 228 229 230 231 232 |
|
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
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
|
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
145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
|
The data models component provides classes for representing various types of data related to bank erosion calculations, such as:
- BaseBank: Generic base class for representing paired bank data (left and right banks)
- SingleErosion: Represents erosion inputs for a single bank
- ErosionInputs: Represents inputs for erosion calculations
- WaterLevelData: Represents water level data for erosion calculations
- MeshData: Represents mesh data for erosion calculations
- SingleBank: Represents a single bank for erosion calculations
- BankData: Represents bank data for erosion calculations
- FairwayData: Represents fairway data for erosion calculations
- ErosionResults: Represents results of erosion calculations
- SingleParameters: Represents parameters for each bank
- SingleLevelParameters: Represents parameters for discharge levels
- SingleCalculation: Represents parameters for discharge calculations
- SingleDischargeLevel: Represents a calculation level for erosion calculations
- DischargeLevels: Represents discharge levels for erosion calculations
Usage Example#
from dfastbe.bank_erosion.data_models.calculation import BankData, ErosionInputs, ErosionResults
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)
# Access bank data
bank_data = erosion.bl_processor.intersect_with_mesh(erosion.simulation_data.mesh_data)
# Print bank data properties
print(f"Number of bank lines: {bank_data.n_bank_lines}")
print(f"Left bank is right bank: {bank_data.left.is_right}")
print(f"Right bank is right bank: {bank_data.right.is_right}")
For more details on the specific classes and their properties, refer to the API reference below.