pyBADA 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
pyBADA/geodesic.py CHANGED
@@ -1,9 +1,5 @@
1
- # -*- coding: utf-8 -*-
2
1
  """
3
- pyBADA
4
2
  Geodesic calculation module
5
- Developped @EUROCONTROL (EIH)
6
- 2024
7
3
  """
8
4
 
9
5
  from math import (
@@ -18,15 +14,14 @@ from math import (
18
14
  pi,
19
15
  log,
20
16
  log2,
21
- acos,
22
17
  )
23
18
  from pyBADA.aircraft import Airplane as airplane
24
- from pyBADA import conversions as conv
25
19
  from pyBADA import constants as const
26
20
 
27
21
 
28
22
  class Haversine:
29
- """This class implements the geodesic calculations on sherical earth (ignoring ellipsoidal effects).
23
+ """This class implements the geodesic calculations on sherical earth
24
+ (ignoring ellipsoidal effects).
30
25
 
31
26
  .. note::
32
27
  https://www.movable-type.co.uk/scripts/latlong.html
@@ -37,10 +32,12 @@ class Haversine:
37
32
 
38
33
  @staticmethod
39
34
  def distance(LAT_init, LON_init, LAT_final, LON_final):
40
- """Calculate the great-circle distance between two points on the Earth's surface using the haversine formula.
35
+ """Calculate the great-circle distance between two points on the
36
+ Earth's surface using the haversine formula.
41
37
 
42
- The great-circle distance is the shortest distance between two points over the Earth's surface,
43
- ignoring elevation changes (i.e., hills or mountains).
38
+ The great-circle distance is the shortest distance between two points
39
+ over the Earth's surface, ignoring elevation changes (i.e., hills or
40
+ mountains).
44
41
 
45
42
  :param LAT_init: Initial latitude in degrees.
46
43
  :param LON_init: Initial longitude in degrees.
@@ -71,12 +68,15 @@ class Haversine:
71
68
 
72
69
  @staticmethod
73
70
  def destinationPoint(LAT_init, LON_init, distance, bearing):
74
- """Calculate the destination point given an initial point, distance, and bearing.
71
+ """Calculate the destination point given an initial point, distance,
72
+ and bearing.
75
73
 
76
- Given an initial latitude and longitude, this function calculates the destination point
77
- after traveling the specified distance along the given initial bearing (direction).
74
+ Given an initial latitude and longitude, this function calculates the
75
+ destination point after traveling the specified distance along the
76
+ given initial bearing (direction).
78
77
 
79
- Note that the bearing may vary along the path, but this calculation assumes a constant bearing.
78
+ Note that the bearing may vary along the path, but this calculation
79
+ assumes a constant bearing.
80
80
 
81
81
  :param LAT_init: Initial latitude in degrees.
82
82
  :param LON_init: Initial longitude in degrees.
@@ -86,7 +86,8 @@ class Haversine:
86
86
  :type LON_init: float
87
87
  :type distance: float
88
88
  :type bearing: float
89
- :returns: Tuple containing the destination latitude and longitude in degrees.
89
+ :returns: Tuple containing the destination latitude and longitude in
90
+ degrees.
90
91
  :rtype: (float, float)
91
92
  """
92
93
 
@@ -111,10 +112,12 @@ class Haversine:
111
112
 
112
113
  @staticmethod
113
114
  def bearing(LAT_init, LON_init, LAT_final, LON_final):
114
- """Calculate the initial bearing between two points along a great-circle path.
115
+ """Calculate the initial bearing between two points along a great-
116
+ circle path.
115
117
 
116
- The initial bearing (forward azimuth) is the direction one would need to travel
117
- in a straight line along the great-circle arc from the start point to the end point.
118
+ The initial bearing (forward azimuth) is the direction one would need
119
+ to travel in a straight line along the great-circle arc from the start
120
+ point to the end point.
118
121
 
119
122
  This bearing is measured clockwise from true north.
120
123
 
@@ -143,20 +146,21 @@ class Haversine:
143
146
  return bearing
144
147
 
145
148
 
146
- class Vincenty(object):
147
- """This class implements the vincenty calculations of geodesics on the ellipsoid-model earth
149
+ class Vincenty:
150
+ """This class implements the vincenty calculations of geodesics on the
151
+ ellipsoid-model earth.
148
152
 
149
153
  .. note::
150
154
  https://www.movable-type.co.uk/scripts/latlong-vincenty.html
151
-
152
155
  """
153
156
 
154
157
  @staticmethod
155
158
  def distance_bearing(LAT_init, LON_init, LAT_final, LON_final):
156
- """Calculate the geodesic distance, initial bearing, and final bearing between two points on the Earth's surface.
159
+ """Calculate the geodesic distance, initial bearing, and final bearing
160
+ between two points on the Earth's surface.
157
161
 
158
- This method uses the Vincenty formula to account for the Earth's ellipsoidal shape, providing accurate
159
- calculations for long distances.
162
+ This method uses the Vincenty formula to account for the Earth's
163
+ ellipsoidal shape, providing accurate calculations for long distances.
160
164
 
161
165
  :param LAT_init: Initial latitude in degrees.
162
166
  :param LON_init: Initial longitude in degrees.
@@ -166,7 +170,8 @@ class Vincenty(object):
166
170
  :type LON_init: float
167
171
  :type LAT_final: float
168
172
  :type LON_final: float
169
- :returns: Tuple containing distance in meters, initial bearing in degrees, and final bearing in degrees.
173
+ :returns: Tuple containing distance in meters, initial bearing in
174
+ degrees, and final bearing in degrees.
170
175
  :rtype: (float, float, float)
171
176
  """
172
177
 
@@ -280,10 +285,12 @@ class Vincenty(object):
280
285
 
281
286
  @staticmethod
282
287
  def distance(LAT_init, LON_init, LAT_final, LON_final):
283
- """Calculate the geodesic distance between two latitude/longitude points on the Earth's surface.
288
+ """Calculate the geodesic distance between two latitude/longitude
289
+ points on the Earth's surface.
284
290
 
285
- This method uses an accurate ellipsoidal model (Vincenty's formula) for calculating the distance,
286
- which is particularly useful for long distances across the globe.
291
+ This method uses an accurate ellipsoidal model (Vincenty's formula)
292
+ for calculating the distance, which is particularly useful for long
293
+ distances across the globe.
287
294
 
288
295
  :param LAT_init: Initial latitude in degrees.
289
296
  :param LON_init: Initial longitude in degrees.
@@ -304,10 +311,12 @@ class Vincenty(object):
304
311
 
305
312
  @staticmethod
306
313
  def bearing_initial(LAT_init, LON_init, LAT_final, LON_final):
307
- """Calculate the initial bearing (forward azimuth) from the initial point to the final point.
314
+ """Calculate the initial bearing (forward azimuth) from the initial
315
+ point to the final point.
308
316
 
309
- This function returns the initial bearing that, if followed in a straight line along a great-circle path,
310
- will take you from the start point to the end point.
317
+ This function returns the initial bearing that, if followed in a
318
+ straight line along a great-circle path, will take you from the start
319
+ point to the end point.
311
320
 
312
321
  :param LAT_init: Initial latitude in degrees.
313
322
  :param LON_init: Initial longitude in degrees.
@@ -328,10 +337,12 @@ class Vincenty(object):
328
337
 
329
338
  @staticmethod
330
339
  def bearing_final(LAT_init, LON_init, LAT_final, LON_final):
331
- """Calculate the final bearing (reverse azimuth) from the final point to the initial point.
340
+ """Calculate the final bearing (reverse azimuth) from the final point
341
+ to the initial point.
332
342
 
333
- This function calculates the final bearing at the destination point, which is the direction one
334
- would need to take to return to the initial point along the great-circle path.
343
+ This function calculates the final bearing at the destination point,
344
+ which is the direction one would need to take to return to the initial
345
+ point along the great-circle path.
335
346
 
336
347
  :param LAT_init: Initial latitude in degrees.
337
348
  :param LON_init: Initial longitude in degrees.
@@ -352,7 +363,8 @@ class Vincenty(object):
352
363
 
353
364
  @staticmethod
354
365
  def destinationPoint_finalBearing(LAT_init, LON_init, distance, bearing):
355
- """Calculate the destination point and final bearing given an initial point, distance, and bearing.
366
+ """Calculate the destination point and final bearing given an initial
367
+ point, distance, and bearing.
356
368
 
357
369
  This method calculates the latitude and longitude of the destination point after traveling a specified
358
370
  distance along the given bearing from the starting point. It also returns the final bearing at the
@@ -452,20 +464,24 @@ class Vincenty(object):
452
464
 
453
465
  @staticmethod
454
466
  def destinationPoint(LAT_init, LON_init, distance, bearing):
455
- """Calculate the destination point after traveling a specified distance on a given bearing.
467
+ """Calculate the destination point after traveling a specified
468
+ distance on a given bearing.
456
469
 
457
- This method returns the latitude and longitude of the destination point after traveling the given
458
- distance on the specified initial bearing, following a great-circle path.
470
+ This method returns the latitude and longitude of the destination
471
+ point after traveling the given distance on the specified initial
472
+ bearing, following a great-circle path.
459
473
 
460
474
  :param LAT_init: Initial latitude in degrees.
461
475
  :param LON_init: Initial longitude in degrees.
462
- :param distance: Distance to be traveled from the initial point in meters.
476
+ :param distance: Distance to be traveled from the initial point in
477
+ meters.
463
478
  :param bearing: Initial bearing (direction) in degrees.
464
479
  :type LAT_init: float
465
480
  :type LON_init: float
466
481
  :type distance: float
467
482
  :type bearing: float
468
- :returns: Tuple containing the destination latitude and longitude in degrees.
483
+ :returns: Tuple containing the destination latitude and longitude in
484
+ degrees.
469
485
  :rtype: (float, float)
470
486
  """
471
487
 
@@ -476,22 +492,22 @@ class Vincenty(object):
476
492
  return (dest[0], dest[1])
477
493
 
478
494
 
479
- class RhumbLine(object):
480
- """This class implements the rhumb line (loxodrome) calculations of geodesics on the ellipsoid-model earth
495
+ class RhumbLine:
496
+ """This class implements the rhumb line (loxodrome) calculations of
497
+ geodesics on the ellipsoid-model earth.
481
498
 
482
499
  .. note::
483
500
  https://github.com/SpyrosMouselinos/distancly/blob/master/distancly/rhumbline.py
484
-
485
501
  """
486
502
 
487
503
  @staticmethod
488
504
  def simple_project(latitiude: float) -> float:
489
- """
490
- Applies a projection to the latitude for use in rhumbline calculations.
505
+ """Applies a projection to the latitude for use in rhumbline
506
+ calculations.
491
507
 
492
- The projection is based on the Mercator projection, where latitudes are projected
493
- to account for the curvature of the Earth. This formula ensures that the calculations
494
- along the rhumbline are accurate.
508
+ The projection is based on the Mercator projection, where latitudes
509
+ are projected to account for the curvature of the Earth. This formula
510
+ ensures that the calculations along the rhumbline are accurate.
495
511
 
496
512
  :param latitiude: Latitude in radians.
497
513
  :return: The projected latitude in radians.
@@ -501,13 +517,15 @@ class RhumbLine(object):
501
517
 
502
518
  @staticmethod
503
519
  def distance(LAT_init, LON_init, LAT_final, LON_final) -> float:
504
- """
505
- Calculates the rhumbline distance between two geographical points in meters.
520
+ """Calculates the rhumbline distance between two geographical points
521
+ in meters.
506
522
 
507
- The rhumbline is a path of constant bearing that crosses all meridians at the same angle,
508
- unlike a great-circle route which is the shortest distance between two points on the Earth's surface.
523
+ The rhumbline is a path of constant bearing that crosses all meridians
524
+ at the same angle, unlike a great-circle route which is the shortest
525
+ distance between two points on the Earth's surface.
509
526
 
510
- This method adjusts for longitudes that span more than half of the globe.
527
+ This method adjusts for longitudes that span more than half of the
528
+ globe.
511
529
 
512
530
  :param LAT_init: Initial latitude in degrees.
513
531
  :param LON_init: Initial longitude in degrees.
@@ -547,11 +565,12 @@ class RhumbLine(object):
547
565
 
548
566
  @staticmethod
549
567
  def bearing(LAT_init, LON_init, LAT_final, LON_final) -> float:
550
- """
551
- Calculates the rhumbline bearing from the initial point to the final point.
568
+ """Calculates the rhumbline bearing from the initial point to the
569
+ final point.
552
570
 
553
- This returns the constant bearing (direction) required to travel along a rhumbline
554
- between the two points. The bearing is adjusted for longitudes that cross the 180-degree meridian.
571
+ This returns the constant bearing (direction) required to travel along
572
+ a rhumbline between the two points. The bearing is adjusted for
573
+ longitudes that cross the 180-degree meridian.
555
574
 
556
575
  :param LAT_init: Initial latitude in degrees.
557
576
  :param LON_init: Initial longitude in degrees.
@@ -581,17 +600,20 @@ class RhumbLine(object):
581
600
 
582
601
  @staticmethod
583
602
  def destinationPoint(LAT_init, LON_init, bearing, distance) -> tuple:
584
- """
585
- Calculates the destination point given an initial point, a bearing, and a distance traveled.
603
+ """Calculates the destination point given an initial point, a bearing,
604
+ and a distance traveled.
586
605
 
587
- This method computes the final latitude and longitude after traveling along a rhumbline
588
- for a given distance in meters from the initial point at a constant bearing.
606
+ This method computes the final latitude and longitude after traveling
607
+ along a rhumbline for a given distance in meters from the initial
608
+ point at a constant bearing.
589
609
 
590
610
  :param LAT_init: Initial latitude in degrees.
591
611
  :param LON_init: Initial longitude in degrees.
592
612
  :param bearing: The constant bearing in degrees.
593
- :param distance: The distance to travel from the initial point in meters.
594
- :return: A tuple containing the destination latitude and longitude in degrees.
613
+ :param distance: The distance to travel from the initial point in
614
+ meters.
615
+ :return: A tuple containing the destination latitude and longitude in
616
+ degrees.
595
617
  """
596
618
 
597
619
  lat_a = radians(LAT_init)
@@ -629,17 +651,19 @@ class RhumbLine(object):
629
651
  def loxodromic_mid_point(
630
652
  LAT_init, LON_init, LAT_final, LON_final
631
653
  ) -> tuple:
632
- """
633
- Calculates the midpoint along a rhumbline between two geographical points.
654
+ """Calculates the midpoint along a rhumbline between two geographical
655
+ points.
634
656
 
635
- The midpoint is calculated using the rhumbline path between the initial and final points.
636
- This takes into account the Earth's curvature by projecting the latitudes.
657
+ The midpoint is calculated using the rhumbline path between the
658
+ initial and final points. This takes into account the Earth's
659
+ curvature by projecting the latitudes.
637
660
 
638
661
  :param LAT_init: Initial latitude in degrees.
639
662
  :param LON_init: Initial longitude in degrees.
640
663
  :param LAT_final: Final latitude in degrees.
641
664
  :param LON_final: Final longitude in degrees.
642
- :return: A tuple representing the midpoint's latitude and longitude in degrees.
665
+ :return: A tuple representing the midpoint's latitude and longitude in
666
+ degrees.
643
667
  """
644
668
 
645
669
  lat_a = radians(LAT_init)
@@ -673,18 +697,21 @@ class RhumbLine(object):
673
697
  def loxodromic_power_interpolation(
674
698
  LAT_init, LON_init, LAT_final, LON_final, n_points: int
675
699
  ) -> list:
676
- """
677
- Generates a specified number of points between two geographical locations along a rhumbline path.
700
+ """Generates a specified number of points between two geographical
701
+ locations along a rhumbline path.
678
702
 
679
- This method recursively calculates intermediate points between two points on the Earth's surface,
680
- following a constant bearing rhumbline path. The number of points should be a power of 2 minus 1.
703
+ This method recursively calculates intermediate points between two
704
+ points on the Earth's surface, following a constant bearing rhumbline
705
+ path. The number of points should be a power of 2 minus 1.
681
706
 
682
707
  :param LAT_init: Initial latitude in degrees.
683
708
  :param LON_init: Initial longitude in degrees.
684
709
  :param LAT_final: Final latitude in degrees.
685
710
  :param LON_final: Final longitude in degrees.
686
- :param n_points: Number of intermediate points to generate. Must be a power of 2 minus 1.
687
- :return: A list of tuples, where each tuple represents an interpolated point's latitude and longitude in degrees.
711
+ :param n_points: Number of intermediate points to generate. Must be a
712
+ power of 2 minus 1.
713
+ :return: A list of tuples, where each tuple represents an interpolated
714
+ point's latitude and longitude in degrees.
688
715
  """
689
716
 
690
717
  n_points = int(n_points)
@@ -721,8 +748,8 @@ class RhumbLine(object):
721
748
  return decoupled_points
722
749
 
723
750
 
724
- class Turn(object):
725
- """This class implements the calculations of geodesics turns"""
751
+ class Turn:
752
+ """This class implements the calculations of geodesics turns."""
726
753
 
727
754
  @staticmethod
728
755
  def destinationPoint_finalBearing(
@@ -735,11 +762,14 @@ class Turn(object):
735
762
  directionOfTurn,
736
763
  centerPoint=None,
737
764
  ):
738
- """Calculates the destination point and final bearing after traveling for a given time with a specified turn.
765
+ """Calculates the destination point and final bearing after traveling
766
+ for a given time with a specified turn.
739
767
 
740
- This function computes the aircraft's final position and bearing after making a turn at a specified rate
741
- of turn, direction, and true airspeed (TAS). If TAS is zero, the aircraft rotates in place. The calculation
742
- accounts for turning radius and bank angle.
768
+ This function computes the aircraft's final position and bearing
769
+ after making a turn at a specified rate of turn, direction, and
770
+ true airspeed (TAS). If TAS is zero, the aircraft rotates in
771
+ place. The calculation accounts for turning radius and bank
772
+ angle.
743
773
 
744
774
  :param LAT_init: Initial latitude [deg].
745
775
  :param LON_init: Initial longitude [deg].
@@ -748,7 +778,8 @@ class Turn(object):
748
778
  :param TAS: True Airspeed (TAS) [m/s].
749
779
  :param rateOfTurn: Rate of turn [deg/s].
750
780
  :param directionOfTurn: Direction of turn ('LEFT' or 'RIGHT').
751
- :param centerPoint: Optional latitude and longitude of the rotation center (defaults to None) [deg, deg].
781
+ :param centerPoint: Optional latitude and longitude of the
782
+ rotation center (defaults to None) [deg, deg].
752
783
  :type LAT_init: float.
753
784
  :type LON_init: float.
754
785
  :type timeOfTurn: float.
@@ -757,7 +788,8 @@ class Turn(object):
757
788
  :type rateOfTurn: float.
758
789
  :type directionOfTurn: str.
759
790
  :type centerPoint: tuple(float, float).
760
- :returns: Destination point's latitude, longitude, and final bearing [deg, deg, deg].
791
+ :returns: Destination point's latitude, longitude, and final
792
+ bearing [deg, deg, deg].
761
793
  :rtype: tuple(float, float, float).
762
794
  """
763
795
 
@@ -829,10 +861,12 @@ class Turn(object):
829
861
 
830
862
  @staticmethod
831
863
  def distance(rateOfTurn, TAS, timeOfTurn):
832
- """Calculates the distance traveled during a turn based on the rate of turn, true airspeed, and time.
864
+ """Calculates the distance traveled during a turn based on the rate of
865
+ turn, true airspeed, and time.
833
866
 
834
- This function computes the total distance traveled during a constant turn, based on the aircraft's rate
835
- of turn, true airspeed, and the duration of the turn.
867
+ This function computes the total distance traveled during a constant
868
+ turn, based on the aircraft's rate of turn, true airspeed, and the
869
+ duration of the turn.
836
870
 
837
871
  :param rateOfTurn: Rate of turn [deg/s].
838
872
  :param TAS: True Airspeed (TAS) [m/s].
pyBADA/magnetic.py CHANGED
@@ -1,9 +1,5 @@
1
- # -*- coding: utf-8 -*-
2
1
  """
3
- pyBADA
4
2
  Magnetic declination module
5
- Developped @EUROCONTROL (EIH)
6
- 2024
7
3
  """
8
4
 
9
5
  import json
@@ -54,7 +50,8 @@ class Grid:
54
50
 
55
51
  :param LAT_target: Target latitude to search for.
56
52
  :type LAT_target: float
57
- :return: The closest latitude from the grid or None if the target is out of bounds.
53
+ :return: The closest latitude from the grid or None if the target is
54
+ out of bounds.
58
55
  :rtype: float or None
59
56
  """
60
57
 
@@ -82,7 +79,8 @@ class Grid:
82
79
 
83
80
  :param LON_target: Target longitude to search for.
84
81
  :type LON_target: float
85
- :return: The closest longitude from the grid or None if the target is out of bounds.
82
+ :return: The closest longitude from the grid or None if the target is
83
+ out of bounds.
86
84
  :rtype: float or None
87
85
  """
88
86
 
@@ -106,13 +104,15 @@ class Grid:
106
104
  return closest
107
105
 
108
106
  def getClosestIdx(self, LAT_target, LON_target):
109
- """Finds the index of the closest grid point for a given latitude and longitude.
107
+ """Finds the index of the closest grid point for a given latitude and
108
+ longitude.
110
109
 
111
110
  :param LAT_target: Target latitude.
112
111
  :param LON_target: Target longitude.
113
112
  :type LAT_target: float
114
113
  :type LON_target: float
115
- :return: Index of the closest point in the grid or None if no point is found.
114
+ :return: Index of the closest point in the grid or None if no point is
115
+ found.
116
116
  :rtype: int or None
117
117
  """
118
118
 
@@ -137,13 +137,15 @@ class Grid:
137
137
  return None
138
138
 
139
139
  def getMagneticDeclination(self, LAT_target, LON_target):
140
- """Returns the magnetic declination for the closest grid point to the target coordinates.
140
+ """Returns the magnetic declination for the closest grid point to the
141
+ target coordinates.
141
142
 
142
143
  :param LAT_target: Target latitude.
143
144
  :param LON_target: Target longitude.
144
145
  :type LAT_target: float
145
146
  :type LON_target: float
146
- :return: Magnetic declination at the closest grid point or None if no point is found.
147
+ :return: Magnetic declination at the closest grid point or None if no
148
+ point is found.
147
149
  :rtype: float or None
148
150
  """
149
151