Utility functions
AngleAnnotation
Bases: Arc
Draws an arc between two vectors which appears circular in display space. Implementation of class Arc
Source code in a2gUtils.py
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 496 497 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 | |
__init__(xy, p1, p2, size=75, unit='points', ax=None, text='', textposition='inside', text_kw=None, **kwargs)
Parameters
xy, p1, p2 : tuple or array of two floats Center position and two points. Angle annotation is drawn between the two vectors connecting p1 and p2 with xy, respectively. Units are data coordinates.
float
Diameter of the angle annotation in units specified by unit.
str
One of the following strings to specify the unit of size:
- "pixels": pixels
- "points": points, use points instead of pixels to not have a dependence on the DPI
- "axes width", "axes height": relative units of Axes width, height
- "axes min", "axes max": minimum or maximum of relative Axes width, height
matplotlib.axes.Axes
The Axes to add the angle annotation to.
str
The text to mark the angle with.
{"inside", "outside", "edge"}
Whether to show the text in- or outside the arc. "edge" can be used for custom positions anchored at the arc's edge.
dict
Dictionary of arguments passed to the Annotation.
**kwargs
Further parameters are passed to matplotlib.patches.Arc. Use this
to specify, color, linewidth etc. of the arc.
Source code in a2gUtils.py
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 | |
get_center_in_pixels()
GpsOnMap
Bases: object
Source code in a2gUtils.py
__init__(path_to_osmpbf, canvas=None, fig=None, ax=None, air_coord=None, gnd_coord=None)
This is a handler for the canvas element where gps coords are plot
It requires an .osm.pbf picture of the map get from https://extract.bbbike.org/
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path_to_osmpbf |
str
|
path to .osm.pbf file |
required |
canvas |
widget
|
canvas widget from app. Defaults to None. |
None
|
fig |
fig
|
description. Defaults to None. |
None
|
ax |
ax
|
description. Defaults to None. |
None
|
air_coord |
dictionary
|
the keys of the dictionary should be "LAT" and "LON". Defaults to None. |
None
|
gnd_coord |
dictionary
|
the keys of the dictionary should be "LAT" and "LON". Defaults to None. |
None
|
Source code in a2gUtils.py
show_air_moving(lat, lon)
azimuth_difference_between_coordinates(heading, lat_origin, lon_origin, lat_dest, lon_dest)
This is the angle difference between the heading direction (angle w.r.t the North) of the node behaving as the origin and the destination node direction (w.r.t the origin node).
The following picture provides an illustration of the angle to be computed (named here theta).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
heading |
float
|
angle between [0, 2*pi] (rads) corresponding to the heading direction of the line between the two antennas connected to Septentrio's receiver in the origin node. Defaults to None. |
required |
lat_origin |
float
|
latitude of the origin node. |
required |
lon_origin |
float
|
longitude of the origin node. |
required |
lat_dest |
float
|
latitude of the destination node. |
required |
lon_dest |
float
|
longitude of the destination node. |
required |
Returns: yaw_to_set (int): azimuth angle difference.
Source code in a2gUtils.py
compute_block_mean_2d_array(array, block_length)
Compute the block mean of a matrix by assuming the matrix consists of blocks of size block_length-by-array.shape[1].
'array' should be a matrix, and 'block_length' should be less than array.shape[1].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array |
ndarray
|
description |
required |
block_length |
int
|
description |
required |
Source code in a2gUtils.py
convert_dB_to_valid_hex_sivers_register_values(rx_bb_gain_1, rx_bb_gain_2, rx_bb_gain_3, rx_bfrf_gain, tx_bb_gain, tx_bb_iq_gain, tx_bb_phase, tx_bfrf_gain)
Converts the dB gain values (all of them) the user has input in the "Sivers settings" panel to the actual values required for the Sivers EVK registers.
Returns:
| Name | Type | Description |
|---|---|---|
tx_signal_values |
dict
|
dictionary with the Tx gain values to be set at the Tx Sivers EVK registers. |
rx_signal_values |
dict
|
dictionary with the Rx gain values to be set at the RX Sivers EVK registers. |
Source code in a2gUtils.py
elevation_difference_between_coordinates(lat_origin, lon_origin, h_origin, lat_dest, lon_dest, h_dest)
Elevation angle difference between the origin node and the destination node.
The following picture provides an illustration of the angle to be computed (named here theta).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat_origin |
float
|
latitude of the origin node. |
required |
lon_origin |
float
|
longitude of the origin node. |
required |
h_origin |
float
|
height of the origin node. |
required |
lat_dest |
float
|
latitude of the destination node. |
required |
lon_dest |
float
|
longitude of the destination node. |
required |
h_dest |
float
|
height of the destination node. |
required |
Returns: pitch_to_set (int): elevation angle difference.
Source code in a2gUtils.py
geocentric2geodetic(X, Y, Z, EPSG_GEODETIC=4979, EPSG_GEOCENTRIC=4978)
Given Geocentric coordinates referred to a datum (given by EPSG_GEOCENTRIC), convert them to Geodetic (lat, lon, height) in the datum given by EPSG_GEODETIC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X |
float
|
geocentric X coordinate. |
required |
Y |
float
|
geocentric Y coordinate. |
required |
Z |
float
|
geocentric Z coordinate. |
required |
EPSG_GEODETIC |
int
|
description. Defaults to 4979, that corresponds to WSG84 (geodetic) |
4979
|
EPSG_GEOCENTRIC |
int
|
description. Defaults to 4978, that corresponds to WSG84 (geocentric). |
4978
|
Source code in a2gUtils.py
geodetic2geocentric(lat, lon, height, EPSG_GEODETIC=4979, EPSG_GEOCENTRIC=4978)
Given Geodetic coordinates (lat, lon, h), convert them to Geocentric in the datum given by EPSG_GEOCENTRIC.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lat |
float
|
latitude (N) |
required |
lon |
float
|
longitude (E). |
required |
height |
float
|
height in meters. |
required |
EPSG_GEODETIC |
int
|
description. Defaults to 4979, that corresponds to WSG84 (geodetic) |
4979
|
EPSG_GEOCENTRIC |
int
|
description. Defaults to 4978, that corresponds to WSG84 (geocentric). |
4978
|
Source code in a2gUtils.py
make_flight_graph_coordinates(flight_graph, number_stops_per_edge)
Calculates the intermediate coordinates for the flight graph provided with the given number of stops per edge.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flight_graph |
numpy 2d-array
|
the provided array rows MUST be ordered according to the order of the planned stops of the drone. For example: 1st row corresponds to the first stop of the drone, 2nd row corresponds to the second stop of the drone, and so on. |
required |
number_stops_per_edge |
int
|
number of stops per edge. It includes both vertexes of the edge. |
required |
Raises:
| Type | Description |
|---|---|
Exception
|
description |
Returns:
| Name | Type | Description |
|---|---|---|
intermediate_coords |
dict
|
a dictionary whose structure is as follows: {'EDGE_1': {'LAT': [], 'LON':[]}, 'EDGE_2': {'LAT': [], 'LON':[]}, ...} |