helpers
bearing_to_direction
bearing_to_direction(bearing: ndarray) -> ndarray
Convert bearing angle to cardinal direction name Args: bearing (np.ndarray): Bearing angle in decimal degrees
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Cardinal direction name |
Source code in src/mechaphlowers/data/geography/helpers.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
distances_to_gps
distances_to_gps(
lat_a: ndarray,
lon_a: ndarray,
x_meters: ndarray,
y_meters: ndarray,
) -> tuple[ndarray, ndarray]
Calculate GPS coordinates of point B given point A's coordinates and x,y distances in meters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
Latitude of point A in decimal degrees |
required |
|
ndarray
|
Longitude of point A in decimal degrees |
required |
|
ndarray
|
Distance from west to east in meters (positive = east, negative = west) |
required |
|
ndarray
|
Distance from south to north in meters (positive = north, negative = south) |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: tuple containing the latitude and longitude of point B |
Source code in src/mechaphlowers/data/geography/helpers.py
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 | |
gps_to_bearing_two_points
gps_to_bearing_two_points(
lat1: ndarray,
lon1: ndarray,
lat2: ndarray,
lon2: ndarray,
unit: Literal['rad', 'deg'] = 'rad',
) -> ndarray
Calculate the bearing between two points Returns bearing in degrees from north Args: lat1 (np.ndarray): Latitude of point A (in radians by default) lon1 (np.ndarray): Longitude of point A (in radians by default) lat2 (np.ndarray): Latitude of point B (in radians by default) lon2 (np.ndarray): Longitude of point B (in radians by default) unit (Literal["rad", "deg"]): Select the unit to use for both inputs and output. Defaults to "rad"
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Bearing angle in degrees from north, anti clockwise (in radians by default) |
Source code in src/mechaphlowers/data/geography/helpers.py
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 | |
gps_to_lambert93
gps_to_lambert93(
latitude: Union[float64, ndarray],
longitude: Union[float64, ndarray],
) -> tuple[ndarray, ndarray]
Convert GPS coordinates (WGS84) to Lambert 93 coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Union[float64, ndarray]
|
Latitude in decimal degrees (WGS84). Can be scalar or numpy array. |
required |
|
Union[float64, ndarray]
|
Longitude in decimal degrees (WGS84). Can be scalar or numpy array. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: (X, Y) coordinates in Lambert 93 projection (in meters) |
Source code in src/mechaphlowers/data/geography/helpers.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 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 | |
haversine
haversine(
lat1: ndarray,
lon1: ndarray,
lat2: ndarray,
lon2: ndarray,
unit: Literal['rad', 'deg'] = 'rad',
) -> ndarray
Calculate the great circle distance between two points on the earth Args: lat1 (np.ndarray): Latitude of point A (in radians by default) lon1 (np.ndarray): Longitude of point A (in radians by default) lat2 (np.ndarray): Latitude of point B (in radians by default) lon2 (np.ndarray): Longitude of point B (in radians by default) unit (Literal["rad", "deg"]): Select the unit to use for angle inputs. Defaults to "rad"
Returns:
| Type | Description |
|---|---|
ndarray
|
np.ndarray: Distance in meters |
Source code in src/mechaphlowers/data/geography/helpers.py
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 | |
lambert93_to_gps
lambert93_to_gps(
lambert_e: Union[float64, ndarray],
lambert_n: Union[float64, ndarray],
) -> tuple[ndarray, ndarray]
Convert Lambert 93 coordinates to WGS84 (longitude, latitude)
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
Union[float64, ndarray]
|
Lambert 93 Easting coordinate. Can be scalar or numpy array. |
required |
|
Union[float64, ndarray]
|
Lambert 93 Northing coordinate. Can be scalar or numpy array. |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: (latitude, longitude) in decimal degrees |
Source code in src/mechaphlowers/data/geography/helpers.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 | |
reverse_haversine
reverse_haversine(
lat: ndarray,
lon: ndarray,
bearing: ndarray,
distance: ndarray,
) -> tuple[ndarray, ndarray]
Implementation of the reverse of Haversine formula. Takes one set of latitude/longitude as a start point, a bearing, and a distance, and returns the resultant lat/long pair.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
Starting latitude in decimal degrees |
required |
|
ndarray
|
Starting longitude in decimal degrees |
required |
|
ndarray
|
Bearing in decimal degrees |
required |
|
ndarray
|
Distance in meters |
required |
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.ndarray, np.ndarray]: tuple containing the latitude and longitude of the result |
Source code in src/mechaphlowers/data/geography/helpers.py
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 | |
reverse_haversine_float
reverse_haversine_float(
lat_rad: float,
lon_rad: float,
bearing: float,
distance: float,
) -> tuple[float, float]
Reverse of haversine with floats.
Returns next coordinates in lat/lon according to bearing and distance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
float
|
starting latitude in radians |
required |
|
float
|
starting longitude in radians |
required |
|
float
|
bearing angle: orientation of the line in radians, anticlockwise, towards north = 0 |
required |
|
float
|
distance with the next point |
required |
Returns:
| Type | Description |
|---|---|
tuple[float, float]
|
tuple[float, float]: (lat2, lon2): GPS coordinates of next point |
Source code in src/mechaphlowers/data/geography/helpers.py
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 | |
support_distances_to_gps
support_distances_to_gps(
support_bases_x_meters: ndarray,
support_bases_y_meters: ndarray,
first_support_lat: float64,
first_support_lon: float64,
) -> tuple[ndarray, ndarray]
Parse support distances to calculate gps coordinates in the form: Args: support_bases_x_meters (np.typing.NDArray[np.float64]): Array of x distances from first support base to support bases excluding the first support base support_bases_y_meters (np.typing.NDArray[np.float64]): Array of y distances from first support base to support bases excluding the first support base first_support_lat (np.float64): Latitude of the first support base first_support_lon (np.float64): Longitude of the first support base
Returns:
| Type | Description |
|---|---|
tuple[ndarray, ndarray]
|
tuple[np.typing.NDArray[np.float64], np.typing.NDArray[np.float64]]: tuple containing the latitude and longitude of the support bases |
Source code in src/mechaphlowers/data/geography/helpers.py
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 | |