Coordinate System
Coordinate System.
This code provides the definition of, and the functionality for, all the main coordinate systems that are used in pyELQ. Each coordinate system has relevant methods for features that are commonly required. Also provided is a set of conversions between each of the systems, alongside some functionality for interpolation.
Coordinate
dataclass
Bases: ABC
Abstract base class for coordinate transformations.
Attributes:
Name | Type | Description |
---|---|---|
use_degrees |
bool
|
Flag if reference uses degrees (True) or radians (False). Defaults to True. |
ellipsoid |
Ellipsoid
|
Definition of the Ellipsoid used in the coordinate system, for which the default is WGS84. See: https://en.wikipedia.org/wiki/World_Geodetic_System. |
Source code in src/pyelq/coordinate_system.py
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 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 |
|
nof_observations
abstractmethod
property
Number of observations contained in the class instance, implemented as dependent property.
from_array(array)
abstractmethod
Unstack a numpy array into the corresponding coordinates.
The method has no return as it sets the corresponding attributes of the coordinate class instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
Numpy array of size [n x dim] with n>0 containing the coordinates stacked into a single array |
required |
Source code in src/pyelq/coordinate_system.py
69 70 71 72 73 74 75 76 77 78 79 |
|
to_array(dim=3)
abstractmethod
Stacks coordinates together into a numpy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
Number of dimensions to use, which is either 2 or 3. |
3
|
Returns:
Type | Description |
---|---|
ndarray
|
np.ndarray: Numpy array of size [n x dim] with n>0 containing the coordinates stacked into a single array |
Source code in src/pyelq/coordinate_system.py
81 82 83 84 85 86 87 88 89 90 91 |
|
to_lla()
abstractmethod
Source code in src/pyelq/coordinate_system.py
93 94 95 |
|
to_ecef()
abstractmethod
Source code in src/pyelq/coordinate_system.py
97 98 99 |
|
to_enu(ref_latitude=None, ref_longitude=None, ref_altitude=None)
abstractmethod
Converts coordinates to East North Up system.
If a reference is not provided, the minimum of coordinates in Lat/Lon/Alt is used as the reference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_latitude
|
float
|
reference latitude for ENU |
None
|
ref_longitude
|
float
|
reference longitude for ENU |
None
|
ref_altitude
|
float
|
reference altitude for ENU |
None
|
Returns:
Type | Description |
---|---|
ENU
|
East North Up coordinate object |
Source code in src/pyelq/coordinate_system.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
|
to_object_type(coordinate_object)
Converts current object to same class as input coordinate_object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
coordinate_object
|
Coordinate
|
An coordinate object which provides the coordinate system to convert self to |
required |
Returns:
Type | Description |
---|---|
Coordinate
|
The converted coordinate object |
Source code in src/pyelq/coordinate_system.py
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 |
|
interpolate(values, locations, dim=3, **kwargs)
Interpolate data using coordinate object.
If locations coordinate system does not match self's coordinate system it will be converted to same type as self. In the ENU case extra checking needs to take place to check reference locations match up.
If only 1 value is provided which needs to be interpolated to many other locations we just set the value at all these locations to the single input value
Parameters:
Name | Type | Description | Default |
---|---|---|---|
values
|
ndarray
|
Values to interpolate, consistent with location in self |
required |
locations
|
Coordinate
|
Coordinate object containing locations to which you want to interpolate |
required |
dim
|
int
|
Number of dimensions to use for interpolation (2 or 3) |
3
|
**kwargs
|
dict
|
Other arguments available in scipy.interpolate.griddata e.g. method, fill_value |
{}
|
Returns:
Name | Type | Description |
---|---|---|
Result |
ndarray
|
Interpolated values at requested locations. |
Source code in src/pyelq/coordinate_system.py
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 |
|
make_grid(bounds, grid_type='rectangular', shape=(5, 5, 1))
Generates grid of values locations based on specified inputs.
If the grid type is 'spherical', we scale the latitude and longitude from -90/90 and -180/180 to 0/1 for the use in temp_lat_rad and temp_lon_rad.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bounds
|
ndarray
|
Limits of the grid on which to generate the grid of size [dim x 2] if dim == 2 we assume the third dimension will be zeros |
required |
grid_type
|
str
|
Type of grid to generate, default 'rectangular': rectangular == rectangular grid of shape grd_shape, spherical == grid of shape grid_shape taking into account a spherical spacing |
'rectangular'
|
shape
|
Union[tuple, ndarray]
|
(tuple, optional): Number of grid cells to generate in each dimension, total number of grid cells will be the product of the entries of this tuple |
(5, 5, 1)
|
Returns np.ndarray: gridded of locations
Source code in src/pyelq/coordinate_system.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 |
|
create_tree()
Create KD tree for the purpose of fast distance computation.
Returns:
Name | Type | Description |
---|---|---|
KDTree |
KDTree
|
Spatial KD tree |
Source code in src/pyelq/coordinate_system.py
248 249 250 251 252 253 254 255 |
|
LLA
dataclass
Bases: Coordinate
Defines the properties and functionality of the latitude/ longitude/ altitude coordinate system.
Attributes:
Name | Type | Description |
---|---|---|
latitude |
ndarray
|
Latitude values in degrees. |
longitude |
ndarray
|
Longitude values in degrees. |
altitude |
ndarray
|
Altitude values in meters with respect to a spheroid. |
Source code in src/pyelq/coordinate_system.py
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 |
|
nof_observations
property
Number of observations contained in the class instance, implemented as dependent property.
from_array(array)
Unstack a numpy array into the corresponding coordinates.
The method has no return as it sets the corresponding attributes of the coordinate class instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
Numpy array of size [n x dim] with n>0 containing the coordinates stacked into a single array |
required |
Source code in src/pyelq/coordinate_system.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
|
to_array(dim=3)
Stacks coordinates together into a numpy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
Number of dimensions to use, which is either 2 or 3. |
3
|
Returns:
Type | Description |
---|---|
ndarray
|
Numpy array of size [n x dim] with n>0 containing the coordinates stacked into a single array |
Source code in src/pyelq/coordinate_system.py
297 298 299 300 301 302 303 304 305 306 307 308 309 |
|
to_lla()
Source code in src/pyelq/coordinate_system.py
311 312 313 |
|
to_ecef()
Source code in src/pyelq/coordinate_system.py
315 316 317 318 319 320 321 322 323 324 |
|
to_enu(ref_latitude=None, ref_longitude=None, ref_altitude=None)
Converts coordinates to East North Up system.
If a reference is not provided, the minimum of coordinates in Lat/Lon/Alt is used as the reference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_latitude
|
float
|
reference latitude for ENU |
None
|
ref_longitude
|
float
|
reference longitude for ENU |
None
|
ref_altitude
|
float
|
reference altitude for ENU |
None
|
Returns:
Type | Description |
---|---|
ENU
|
East North Up coordinate object |
Source code in src/pyelq/coordinate_system.py
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 |
|
ENU
dataclass
Bases: Coordinate
Defines the properties and functionality of a local East-North-Up coordinate system.
Positions relative to some reference location in metres.
Attributes:
Name | Type | Description |
---|---|---|
ref_latitude |
float
|
Reference latitude for current ENU system. |
ref_longitude |
float
|
Reference longitude for current ENU system. |
ref_altitude |
float
|
Reference altitude for current ENU system. |
east |
ndarray
|
East values. |
north |
ndarray
|
North values. |
up |
ndarray
|
(np.ndarray): Up values. |
Source code in src/pyelq/coordinate_system.py
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 |
|
nof_observations
property
Number of observations contained in the class instance, implemented as dependent property.
from_array(array)
Unstack a numpy array into the corresponding coordinates.
The method has no return as it sets the corresponding attributes of the coordinate class instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
Numpy array of size [n x dim] with n>0 containing the coordinates stacked into a single array |
required |
Source code in src/pyelq/coordinate_system.py
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 |
|
to_array(dim=3)
Stacks coordinates together into a numpy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
Number of dimensions to use, which is either 2 or 3. |
3
|
Returns:
Type | Description |
---|---|
ndarray
|
Numpy array of size [n x dim] with n>0 containing the coordinates stacked into a single array |
Source code in src/pyelq/coordinate_system.py
415 416 417 418 419 420 421 422 423 424 425 426 427 |
|
to_enu(ref_latitude=None, ref_longitude=None, ref_altitude=None)
Converts coordinates to East North Up system.
If a reference is not provided, the minimum of coordinates in Lat/Lon/Alt is used as the reference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_latitude
|
float
|
reference latitude for ENU |
None
|
ref_longitude
|
float
|
reference longitude for ENU |
None
|
ref_altitude
|
float
|
reference altitude for ENU |
None
|
Returns:
Type | Description |
---|---|
ENU
|
East North Up coordinate object |
Source code in src/pyelq/coordinate_system.py
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 |
|
to_lla()
Source code in src/pyelq/coordinate_system.py
463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
|
to_ecef()
Source code in src/pyelq/coordinate_system.py
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
|
ECEF
dataclass
Bases: Coordinate
Defines the properties and functionality of an Earth-Centered, Earth-Fixed coordinate system.
See: https://en.wikipedia.org/wiki/Earth-centered,_Earth-fixed_coordinate_system
Attributes:
Name | Type | Description |
---|---|---|
x |
ndarray
|
Eastings values [metres] |
y |
ndarray
|
Northings values [metres] |
z |
ndarray
|
Altitude values [metres] |
Source code in src/pyelq/coordinate_system.py
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 |
|
nof_observations
property
Number of observations contained in the class instance, implemented as dependent property.
from_array(array)
Unstack a numpy array into the corresponding coordinates.
The method has no return as it sets the corresponding attributes of the coordinate class instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
array
|
ndarray
|
Numpy array of size [n x dim] with n>0 containing the coordinates stacked into a single array |
required |
Source code in src/pyelq/coordinate_system.py
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 |
|
to_array(dim=3)
Stacks coordinates together into a numpy array.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dim
|
int
|
Number of dimensions to use, which is either 2 or 3. |
3
|
Returns:
Type | Description |
---|---|
ndarray
|
Numpy array of size [n x dim] with n>0 containing the coordinates stacked into a single array |
Source code in src/pyelq/coordinate_system.py
539 540 541 542 543 544 545 546 547 548 549 550 551 |
|
to_ecef()
Source code in src/pyelq/coordinate_system.py
553 554 555 |
|
to_lla()
Source code in src/pyelq/coordinate_system.py
557 558 559 560 561 562 563 564 565 |
|
to_enu(ref_latitude=None, ref_longitude=None, ref_altitude=None)
Converts coordinates to East North Up system.
If a reference is not provided, the minimum of coordinates in Lat/Lon/Alt is used as the reference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_latitude
|
float
|
reference latitude for ENU |
None
|
ref_longitude
|
float
|
reference longitude for ENU |
None
|
ref_altitude
|
float
|
reference altitude for ENU |
None
|
Returns:
Type | Description |
---|---|
ENU
|
East North Up coordinate object |
Source code in src/pyelq/coordinate_system.py
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 |
|
make_latin_hypercube(bounds, nof_samples)
Latin Hypercube samples.
Draw samples according to a Latin Hypercube design within the specified bounds.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
bounds
|
ndarray
|
Limits of the resulting hypercube of size [dim x 2] |
required |
nof_samples
|
int
|
Number of samples to draw |
required |
Returns:
Name | Type | Description |
---|---|---|
array |
ndarray
|
Samples forming the Latin Hypercube |
Source code in src/pyelq/coordinate_system.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
|