Utilities Module#
The Utilities module provides general utility functions used across the D-FAST Bank Erosion software. These functions support various operations in the Bank Lines and Bank Erosion modules.
Overview#
The Utilities module contains a collection of helper functions that are used by multiple components of the D-FAST Bank Erosion software. These functions handle common tasks such as geometric operations, data processing, and visualization support.
Components#
The Utilities module consists of the following components:
General Utilities#
dfastbe.utils
#
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
get_zoom_extends(km_min: float, km_max: float, zoom_km_step: float, bank_crds: List[np.ndarray], bank_km: List[np.ndarray]) -> tuple[list[tuple[float, float]], list[tuple[float, float, float, float]]]
#
Zoom.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
km_min
|
float
|
Minimum value for the chainage range of interest. |
required |
km_max
|
float
|
Maximum value for the chainage range of interest. |
required |
zoom_km_step
|
float
|
Preferred chainage length of zoom box. |
required |
bank_crds
|
List[ndarray]
|
List of N x 2 np arrays of coordinates per bank. |
required |
bank_km
|
List[ndarray]
|
List of N np arrays of chainage values per bank. |
required |
Returns:
Name | Type | Description |
---|---|---|
station_zoom |
List[Tuple[float, float]]
|
Zoom ranges for plots with chainage along x-axis. |
coords_zoom |
List[Tuple[float, float, float, float]]
|
Zoom ranges for xy-plots. |
Source code in src/dfastbe/utils.py
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 |
|
on_right_side(line_xy: np.ndarray, ref_xy: np.ndarray) -> bool
#
Determine whether line_xy is to the left or right of ref_xy.
Left and right are relative to the path along ref_xy from the first to the last node. It is assumed that line_xy can be uniquely identified as on the left or right side of ref_xy, i.e., the lines may not cross each other or themselves. Also, line_xy should be alongside ref_xy and not "before" or "after" ref_xy. The typical use case is to relate a bank line line_xy to a center line ref_xy.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
line_xy
|
np.ndarray Array containing the x,y coordinates of a line. |
required | |
ref_xy
|
np.ndarray Array containing the x,y,chainage data. |
required |
Returns:
Name | Type | Description |
---|---|---|
right_side |
bool
|
bool Flag indicating whether the line is on the right side. |
Source code in src/dfastbe/utils.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 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 |
|
The general utilities component provides functions for various common tasks, such as:
- Geometric operations (e.g., checking if a point is on the right side of a line)
- Visualization support (e.g., getting zoom extents for plots)
- Data processing (e.g., interpolation, filtering)
Usage Example#
from dfastbe.utils import get_zoom_extends, on_right_side
# Check if a point is on the right side of a line
is_on_right = on_right_side(line_start, line_end, point)
# Get zoom extents for plotting
x_min, x_max, y_min, y_max = get_zoom_extends(x, y, margin=0.1)
For more details on the specific functions, refer to the API reference below.