minisky.geo¶
Geodesy helpers for distances, bearings, positions, and magnetic variation.
geo
¶
Geodesy utilities for MiniSky.
Provides bearing and great-circle distance calculations on the WGS'84 ellipsoid (qdrdist, latlondist), fast flat-earth approximations for short distances (the kwik* functions), position projection from a reference position with bearing and distance (qdrpos, kwikpos), local earth radius and gravity according to WGS'84, and magnetic declination lookup from a WMM data table (magdec).
Matrix variants (suffixed with _matrix) operate on vectors of positions
and return results for every combination of the input positions.
MagneticDeclination
¶
Bases: Protocol
__call__
¶
__call__(latd: LatitudeDeg[float], lond: LongitudeDeg[float]) -> MagneticDeclinationDeg[float]
Source code in packages/minisky/minisky/geo.py
475 476 477 | |
MagneticDeclinationGrid
¶
MagneticDeclinationGrid(declinations: MagneticDeclinationDeg[ndarray])
Bases: MagneticDeclination
Source code in packages/minisky/minisky/geo.py
481 482 483 484 | |
load_default
classmethod
¶
load_default() -> Self
Load the magnetic-declination grid bundled with MiniSky core.
Based on the data table calculated from: https://www.ngdc.noaa.gov/geomag/calculators/magcalc.shtml#igrfgrid with the following input: Southern most lat: 90 S Northern most lat: 90 N Lat Step Size: 1.0 Western most long: 180 W Eastern most long: 179 E Lon Step Size: 1.0 Elevation: Mean sea level 0 Feet Magnetic component: Declination Model: WMM (2019-2024) Start Date: 2020 09 20 End Date: 2020 09 20 Step size: 1.0 The grid size can be adjusted but the (1 deg by 1 deg) size should suffice for practical purpose, as long as the the grids cover the entire Earth surface. The interpolation is performed at sea-level, but no significant difference would be noticed up to FL600 or beyond. Based on original version created by : Yaofu Zhou Modified to read at init and use linear interpolation by J.M. Hoekstra
Source code in packages/minisky/minisky/geo.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 | |
from_csv
classmethod
¶
Read a NOAA/WMM CSV (a 181x361 lookup grid).
The source table is expected to contain one row per whole-degree point for latitude +89 through -90 and longitude -180 through +179, with declination in the fifth column. The +90 latitude row and +180 longitude column are derived from the adjacent/wrapped source values.
Source code in packages/minisky/minisky/geo.py
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 | |
__call__
¶
__call__(latd: LatitudeDeg[float], lond: LongitudeDeg[float]) -> MagneticDeclinationDeg[float]
Source code in packages/minisky/minisky/geo.py
533 534 535 536 | |
rwgs84
¶
rwgs84(latd: LatitudeDeg) -> LengthM
Calculate the Earth radius from the WGS'84 ellipsoid.
Source code in packages/minisky/minisky/geo.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | |
rwgs84_matrix
¶
rwgs84_matrix(latd: LatitudeDeg) -> LengthM[ndarray]
Calculate the Earth radius from the WGS'84 ellipsoid (vectorized).
Source code in packages/minisky/minisky/geo.py
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |
qdrdist
¶
qdrdist(latd1: LatitudeDeg, lond1: LongitudeDeg, latd2: LatitudeDeg, lond2: LongitudeDeg) -> tuple[BearingDeg, DistanceM]
Calculate initial bearing and great-circle distance, using WGS'84.
The distance uses the WGS'84 earth radius at the average latitude of the two positions, with a correction when the positions lie on different hemispheres. Bearing formula from http://www.movable-type.co.uk/scripts/latlong.html
Source code in packages/minisky/minisky/geo.py
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 | |
qdrdist_matrix
¶
qdrdist_matrix(lat1: LatitudeDeg, lon1: LongitudeDeg, lat2: LatitudeDeg, lon2: LongitudeDeg) -> tuple[BearingDeg[ndarray], DistanceM[ndarray]]
Calculate bearing and distance matrices between position vectors, using WGS'84.
Computes bearing and haversine distance for every combination of a position in vectors 1 and a position in vectors 2.
Source code in packages/minisky/minisky/geo.py
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 | |
latlondist
¶
latlondist(latd1: LatitudeDeg, lond1: LongitudeDeg, latd2: LatitudeDeg, lond2: LongitudeDeg) -> DistanceM
Calculates only distance using haversine notation of the same formulae and average r from wgs'84.
Source code in packages/minisky/minisky/geo.py
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 | |
latlondist_matrix
¶
latlondist_matrix(lat1: LatitudeDeg, lon1: LongitudeDeg, lat2: LatitudeDeg, lon2: LongitudeDeg) -> DistanceM[ndarray]
Calculates distance matrix using haversine formulae and average r from wgs'84.
Source code in packages/minisky/minisky/geo.py
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 | |
wgsg
¶
wgsg(latd: LatitudeDeg) -> GravitationalAccelerationMps2
Gravity acceleration at a given latitude according to WGS'84.
Source code in packages/minisky/minisky/geo.py
299 300 301 302 303 304 305 306 307 308 | |
qdrpos
¶
qdrpos(latd1: LatitudeDeg, lond1: LongitudeDeg, qdr: BearingDeg, dist: DistanceM) -> tuple[LatitudeDeg, LongitudeDeg]
Calculate vector with positions from vectors of reference position, bearing and distance.
Great-circle projection using the WGS'84 earth radius at the reference latitude. Ref for qdrpos: http://www.movable-type.co.uk/scripts/latlong.html
Source code in packages/minisky/minisky/geo.py
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 | |
kwikdist
¶
kwikdist(lata: LatitudeDeg, lona: LongitudeDeg, latb: LatitudeDeg, lonb: LongitudeDeg) -> DistanceM
Quick and dirty distance calculation.
Equirectangular (flat-earth) approximation with the mean earth radius; fast, but accurate for short distances only.
Source code in packages/minisky/minisky/geo.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
kwikdist_matrix
¶
kwikdist_matrix(lata: LatitudeDeg[ndarray], lona: LongitudeDeg[ndarray], latb: LatitudeDeg[ndarray], lonb: LongitudeDeg[ndarray]) -> DistanceM[ndarray]
Quick and dirty distance matrix between two sets of positions.
Equirectangular (flat-earth) approximation with the mean earth radius; fast, but accurate for short distances only.
Source code in packages/minisky/minisky/geo.py
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 | |
kwikqdrdist
¶
kwikqdrdist(lata: LatitudeDeg, lona: LongitudeDeg, latb: LatitudeDeg, lonb: LongitudeDeg) -> tuple[BearingDeg, DistanceM]
Quick bearing/distance using a flat-earth approximation.
Uses the mean earth radius and does not work well close to the poles.
Bearings are normalized to [0, 360).
Source code in packages/minisky/minisky/geo.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 | |
kwikqdrdist_matrix
¶
kwikqdrdist_matrix(lata: LatitudeDeg[ndarray], lona: LongitudeDeg[ndarray], latb: LatitudeDeg[ndarray], lonb: LongitudeDeg[ndarray]) -> tuple[BearingDeg[ndarray], DistanceM[ndarray]]
Quick bearing/distance matrices using a flat-earth approximation.
Uses the mean earth radius and does not work well close to the poles.
Bearings are normalized to [0, 360).
Source code in packages/minisky/minisky/geo.py
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 | |
kwikpos
¶
kwikpos(latd1: LatitudeDeg, lond1: LongitudeDeg, qdr: BearingDeg, dist: DistanceM) -> tuple[LatitudeDeg, LongitudeDeg]
Fast, but quick and dirty, position calculation from vectors of reference position, bearing and distance using flat earth approximation.
Use for flat earth purposes e.g. flat display.
Longitude is wrapped to [-180, 180).
Source code in packages/minisky/minisky/geo.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | |