pyBADA 0.1.3__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/TCL.py CHANGED
@@ -1,16 +1,12 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Trajectory Computation Light (TCL) for BADAH/BADAE/BADA3/BADA4 aircraft performance module
4
- """
1
+ """Trajectory Computation Light (TCL) for BADAH/BADAE/BADA3/BADA4 aircraft
2
+ performance module."""
5
3
 
6
- import os
7
4
  import numpy as np
8
5
  from pyBADA.geodesic import Vincenty as vincenty
9
6
  from pyBADA.geodesic import RhumbLine as rhumb
10
7
  from pyBADA.geodesic import Turn as turn
11
8
 
12
9
  from dataclasses import dataclass
13
- import importlib.util
14
10
  import itertools
15
11
  import warnings
16
12
 
@@ -57,10 +53,9 @@ def constantSpeedLevel(
57
53
  magneticDeclinationGrid=None,
58
54
  **kwargs,
59
55
  ):
60
- """
61
- Calculates the time, fuel consumption, and other parameters for a level flight
62
- segment at a constant speed for a given aircraft in the BADA model. It supports step-climb,
63
- constant heading (true or magnetic), and turns.
56
+ """Calculates the time, fuel consumption, and other parameters for a level
57
+ flight segment at a constant speed for a given aircraft in the BADA model.
58
+ It supports step-climb, constant heading (true or magnetic), and turns.
64
59
 
65
60
  The function handles different BADA families (BADA3, BADA4, BADAH, BADAE), and computes various
66
61
  parameters such as altitude, speed, fuel consumption, power, heading, and mass based on aircraft
@@ -176,7 +171,7 @@ def constantSpeedLevel(
176
171
  magneticHeading = trueHeading - magneticDeclination
177
172
  elif magneticHeading is not None and trueHeading is None:
178
173
  # fly MAGNETIC Heading
179
- if constantHeading == True:
174
+ if constantHeading is True:
180
175
  headingToFly = "MAGNETIC"
181
176
  trueHeading = magneticHeading + magneticDeclination
182
177
  else:
@@ -536,7 +531,6 @@ def constantSpeedLevel(
536
531
  and Lon_i is not None
537
532
  and (HDGMagnetic_i is not None or HDGTrue is not None)
538
533
  ):
539
-
540
534
  if headingToFly == "TRUE":
541
535
  if not turnFlight:
542
536
  if not constantHeading:
@@ -1190,9 +1184,10 @@ def constantSpeedROCD(
1190
1184
  magneticDeclinationGrid=None,
1191
1185
  **kwargs,
1192
1186
  ):
1193
- """
1194
- Computes the time, fuel consumption, and other parameters required for an aircraft to climb or descend
1195
- from a given initial altitude (Hp_init) to a final altitude (Hp_final) at a constant speed and rate of climb/descent (ROCD).
1187
+ """Computes the time, fuel consumption, and other parameters required for
1188
+ an aircraft to climb or descend from a given initial altitude (Hp_init) to
1189
+ a final altitude (Hp_final) at a constant speed and rate of climb/descent
1190
+ (ROCD).
1196
1191
 
1197
1192
  The function handles multiple BADA families (BADA3, BADA4, BADAH, BADAE), computing various parameters
1198
1193
  such as altitude, speed, fuel consumption, power, heading, and mass based on the aircraft's performance
@@ -1309,7 +1304,7 @@ def constantSpeedROCD(
1309
1304
  magneticHeading = trueHeading - magneticDeclination
1310
1305
  elif magneticHeading is not None and trueHeading is None:
1311
1306
  # fly MAGNETIC Heading
1312
- if constantHeading == True:
1307
+ if constantHeading is True:
1313
1308
  headingToFly = "MAGNETIC"
1314
1309
  trueHeading = magneticHeading + magneticDeclination
1315
1310
  else:
@@ -2229,10 +2224,10 @@ def constantSpeedROCD_time(
2229
2224
  magneticDeclinationGrid=None,
2230
2225
  **kwargs,
2231
2226
  ):
2232
- """
2233
- Computes the time, fuel consumption, and performance parameters required for an aircraft to
2234
- perform a climb or descent based on a set amount of time, while maintaining a constant speed and constant
2235
- rate of climb/descent (ROCD).
2227
+ """Computes the time, fuel consumption, and performance parameters
2228
+ required for an aircraft to perform a climb or descent based on a set
2229
+ amount of time, while maintaining a constant speed and constant rate of
2230
+ climb/descent (ROCD).
2236
2231
 
2237
2232
  The function supports various BADA families (BADA3, BADA4, BADAH, BADAE), with different handling for mass changes,
2238
2233
  aerodynamic configurations, and energy consumption. It calculates parameters such as fuel consumption, power
@@ -2343,7 +2338,7 @@ def constantSpeedROCD_time(
2343
2338
  magneticHeading = trueHeading - magneticDeclination
2344
2339
  elif magneticHeading is not None and trueHeading is None:
2345
2340
  # fly MAGNETIC Heading
2346
- if constantHeading == True:
2341
+ if constantHeading is True:
2347
2342
  headingToFly = "MAGNETIC"
2348
2343
  trueHeading = magneticHeading + magneticDeclination
2349
2344
  else:
@@ -3246,9 +3241,10 @@ def constantSpeedSlope(
3246
3241
  magneticDeclinationGrid=None,
3247
3242
  **kwargs,
3248
3243
  ):
3249
- """
3250
- Calculates time, fuel consumption, and other parameters required for an aircraft to perform a climb or descent
3251
- from an initial altitude (Hp_init) to a final altitude (Hp_final) while maintaining a constant speed and a constant slope.
3244
+ """Calculates time, fuel consumption, and other parameters required for an
3245
+ aircraft to perform a climb or descent from an initial altitude (Hp_init)
3246
+ to a final altitude (Hp_final) while maintaining a constant speed and a
3247
+ constant slope.
3252
3248
 
3253
3249
  It uses different models for BADA (Base of Aircraft Data) families (BADA3, BADA4, BADAH, BADAE) to compute key flight parameters
3254
3250
  such as energy consumption, rate of climb/descent (ROCD), fuel burn, mass changes, and power requirements. The function also supports
@@ -3359,7 +3355,7 @@ def constantSpeedSlope(
3359
3355
  magneticHeading = trueHeading - magneticDeclination
3360
3356
  elif magneticHeading is not None and trueHeading is None:
3361
3357
  # fly MAGNETIC Heading
3362
- if constantHeading == True:
3358
+ if constantHeading is True:
3363
3359
  headingToFly = "MAGNETIC"
3364
3360
  trueHeading = magneticHeading + magneticDeclination
3365
3361
  else:
@@ -4277,8 +4273,9 @@ def constantSpeedSlope_time(
4277
4273
  magneticDeclinationGrid=None,
4278
4274
  **kwargs,
4279
4275
  ):
4280
- """
4281
- Computes the time, fuel, and trajectory parameters required by an aircraft to climb or descend at constant speed and slope over a given duration.
4276
+ """Computes the time, fuel, and trajectory parameters required by an
4277
+ aircraft to climb or descend at constant speed and slope over a given
4278
+ duration.
4282
4279
 
4283
4280
  This function models a trajectory with constant speed (either CAS, TAS, or Mach) and a specified slope (degrees). The aircraft's dynamics are modeled based on BADA family data (BADA3, BADA4, BADAH, BADAE), supporting various aircraft types including electric models. It also accounts for turns, heading changes, and wind effects.
4284
4281
 
@@ -4388,7 +4385,7 @@ def constantSpeedSlope_time(
4388
4385
  magneticHeading = trueHeading - magneticDeclination
4389
4386
  elif magneticHeading is not None and trueHeading is None:
4390
4387
  # fly MAGNETIC Heading
4391
- if constantHeading == True:
4388
+ if constantHeading is True:
4392
4389
  headingToFly = "MAGNETIC"
4393
4390
  trueHeading = magneticHeading + magneticDeclination
4394
4391
  else:
@@ -5300,9 +5297,10 @@ def constantSpeedRating(
5300
5297
  initRating=None,
5301
5298
  **kwargs,
5302
5299
  ):
5303
- """
5304
- Calculates time, fuel consumption, and other parameters required for an aircraft to perform a climb or descent
5305
- from an initial altitude (Hp_init) to a final altitude (Hp_final) while maintaining a constant speed and engine rating.
5300
+ """Calculates time, fuel consumption, and other parameters required for an
5301
+ aircraft to perform a climb or descent from an initial altitude (Hp_init)
5302
+ to a final altitude (Hp_final) while maintaining a constant speed and
5303
+ engine rating.
5306
5304
 
5307
5305
  It uses different models for BADA (Base of Aircraft Data) families (BADA3, BADA4, BADAH, BADAE) to compute key flight parameters
5308
5306
  such as fuel burn, rate of climb/descent (ROCD), thrust, drag, and energy requirements. The function also supports
@@ -5413,7 +5411,7 @@ def constantSpeedRating(
5413
5411
  magneticHeading = trueHeading - magneticDeclination
5414
5412
  elif magneticHeading is not None and trueHeading is None:
5415
5413
  # fly MAGNETIC Heading
5416
- if constantHeading == True:
5414
+ if constantHeading is True:
5417
5415
  headingToFly = "MAGNETIC"
5418
5416
  trueHeading = magneticHeading + magneticDeclination
5419
5417
  else:
@@ -5813,7 +5811,12 @@ def constantSpeedRating(
5813
5811
  CL = AC.CL(M=M_i, delta=delta, mass=mass_i, nz=nz)
5814
5812
  # compute drag coefficient
5815
5813
  CD = AC.CD(
5816
- M=M_i, CL=CL, HLid=HLid_i, LG=LG_i, speedBrakes=speedBrakes
5814
+ M=M_i,
5815
+ CL=CL,
5816
+ HLid=HLid_i,
5817
+ LG=LG_i,
5818
+ speedBrakes=speedBrakes,
5819
+ expedite=expedite,
5817
5820
  )
5818
5821
  # compute drag force
5819
5822
  Drag = AC.D(M=M_i, delta=delta, CD=CD)
@@ -6244,9 +6247,9 @@ def constantSpeedRating_time(
6244
6247
  initRating=None,
6245
6248
  **kwargs,
6246
6249
  ):
6247
- """
6248
- Calculates the time, fuel consumption, and other flight parameters required for an aircraft to perform
6249
- a climb or descent at constant speed and engine rating for a specified duration.
6250
+ """Calculates the time, fuel consumption, and other flight parameters
6251
+ required for an aircraft to perform a climb or descent at constant speed
6252
+ and engine rating for a specified duration.
6250
6253
 
6251
6254
  It uses different models for BADA (Base of Aircraft Data) families (BADA3, BADA4, BADAH, BADAE) to compute key parameters
6252
6255
  such as rate of climb/descent (ROCD), thrust, drag, fuel burn, and power requirements. The function also supports complex
@@ -6359,7 +6362,7 @@ def constantSpeedRating_time(
6359
6362
  magneticHeading = trueHeading - magneticDeclination
6360
6363
  elif magneticHeading is not None and trueHeading is None:
6361
6364
  # fly MAGNETIC Heading
6362
- if constantHeading == True:
6365
+ if constantHeading is True:
6363
6366
  headingToFly = "MAGNETIC"
6364
6367
  trueHeading = magneticHeading + magneticDeclination
6365
6368
  else:
@@ -6750,7 +6753,12 @@ def constantSpeedRating_time(
6750
6753
  CL = AC.CL(M=M_i, delta=delta, mass=mass_i, nz=nz)
6751
6754
  # compute drag coefficient
6752
6755
  CD = AC.CD(
6753
- M=M_i, CL=CL, HLid=HLid_i, LG=LG_i, speedBrakes=speedBrakes
6756
+ M=M_i,
6757
+ CL=CL,
6758
+ HLid=HLid_i,
6759
+ LG=LG_i,
6760
+ speedBrakes=speedBrakes,
6761
+ expedite=expedite,
6754
6762
  )
6755
6763
  # compute drag force
6756
6764
  Drag = AC.D(M=M_i, delta=delta, CD=CD)
@@ -7178,10 +7186,10 @@ def accDec(
7178
7186
  magneticDeclinationGrid=None,
7179
7187
  **kwargs,
7180
7188
  ):
7181
- """
7182
- Calculates the time, fuel consumption, and other key flight parameters required for an aircraft
7183
- to perform an acceleration or deceleration from an initial speed (v_init) to a final speed (v_final)
7184
- during the climb, cruise, or descent phases of flight.
7189
+ """Calculates the time, fuel consumption, and other key flight parameters
7190
+ required for an aircraft to perform an acceleration or deceleration from
7191
+ an initial speed (v_init) to a final speed (v_final) during the climb,
7192
+ cruise, or descent phases of flight.
7185
7193
 
7186
7194
  The flight parameters are calculated using different models for the BADA (Base of Aircraft Data) families (BADA3, BADA4, BADAH, BADAE).
7187
7195
  The function can also accommodate different control laws, vertical evolution phases, wind conditions, and complex flight dynamics like turns.
@@ -7304,7 +7312,7 @@ def accDec(
7304
7312
  magneticHeading = trueHeading - magneticDeclination
7305
7313
  elif magneticHeading is not None and trueHeading is None:
7306
7314
  # fly MAGNETIC Heading
7307
- if constantHeading == True:
7315
+ if constantHeading is True:
7308
7316
  headingToFly = "MAGNETIC"
7309
7317
  trueHeading = magneticHeading + magneticDeclination
7310
7318
  else:
@@ -8460,10 +8468,10 @@ def accDec_time(
8460
8468
  magneticDeclinationGrid=None,
8461
8469
  **kwargs,
8462
8470
  ):
8463
- """
8464
- Calculates the time, fuel consumption, and other key flight parameters required for an aircraft
8465
- to perform an acceleration or deceleration from an initial speed (v_init) over a set period of time
8466
- during the climb, cruise, or descent phases of flight.
8471
+ """Calculates the time, fuel consumption, and other key flight parameters
8472
+ required for an aircraft to perform an acceleration or deceleration from
8473
+ an initial speed (v_init) over a set period of time during the climb,
8474
+ cruise, or descent phases of flight.
8467
8475
 
8468
8476
  The flight parameters are calculated using different models for the BADA (Base of Aircraft Data) families (BADA3, BADA4, BADAH, BADAE).
8469
8477
  The function can also accommodate different control laws, vertical evolution phases, wind conditions, and complex flight dynamics like turns.
@@ -8587,7 +8595,7 @@ def accDec_time(
8587
8595
  magneticHeading = trueHeading - magneticDeclination
8588
8596
  elif magneticHeading is not None and trueHeading is None:
8589
8597
  # fly MAGNETIC Heading
8590
- if constantHeading == True:
8598
+ if constantHeading is True:
8591
8599
  headingToFly = "MAGNETIC"
8592
8600
  trueHeading = magneticHeading + magneticDeclination
8593
8601
  else:
@@ -8978,7 +8986,6 @@ def accDec_time(
8978
8986
  if P_i < Pmin:
8979
8987
  P_i = Pmin
8980
8988
  if ESFc is not None:
8981
-
8982
8989
  ROCD_i = (
8983
8990
  conv.m2ft(
8984
8991
  AC.ROCD(
pyBADA/aircraft.py CHANGED
@@ -1,9 +1,5 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Generic airplane/helicopter performance module
4
- """
1
+ """Generic airplane/helicopter performance module."""
5
2
 
6
- import abc
7
3
  from math import sqrt, pow, cos, radians, atan, tan, degrees
8
4
 
9
5
  from pyBADA import constants as const
@@ -18,26 +14,31 @@ def checkArgument(argument, **kwargs):
18
14
  raise TypeError("Missing " + argument + " argument")
19
15
 
20
16
 
21
- class Bada(object):
22
- """This class implements the mechanisms applicable across all BADA families."""
17
+ class Bada:
18
+ """This class implements the mechanisms applicable across all BADA
19
+ families."""
23
20
 
24
21
  def __init__(self):
25
22
  pass
26
23
 
27
24
  @staticmethod
28
25
  def getBADAParameters(df, acName, parameters):
29
- """
30
- Retrieves specified parameters for a given aircraft name from a DataFrame.
26
+ """Retrieves specified parameters for a given aircraft name from a
27
+ DataFrame.
31
28
 
32
29
  :param df: DataFrame containing BADA aircraft data.
33
- :param acName: Name of the aircraft or list of aircraft names to search for.
34
- :param parameters: List of column names (or a single column name) to retrieve.
30
+ :param acName: Name of the aircraft or list of aircraft names to
31
+ search for.
32
+ :param parameters: List of column names (or a single column name) to
33
+ retrieve.
35
34
  :type df: pd.DataFrame
36
35
  :type acName: list or str
37
36
  :type parameters: list or str
38
- :returns: A DataFrame containing the specified parameters for the given aircraft.
37
+ :returns: A DataFrame containing the specified parameters for the
38
+ given aircraft.
39
39
  :rtype: pd.DataFrame
40
- :raises ValueError: If any of the specified columns or aircraft names are not found.
40
+ :raises ValueError: If any of the specified columns or aircraft names
41
+ are not found.
41
42
  """
42
43
 
43
44
  # Ensure parameters is a list
@@ -70,8 +71,7 @@ class Bada(object):
70
71
 
71
72
  @staticmethod
72
73
  def loadFactor(fi):
73
- """
74
- Computes the load factor from a given bank angle.
74
+ """Computes the load factor from a given bank angle.
75
75
 
76
76
  The load factor is calculated based on the cosine of the bank angle,
77
77
  which is expressed in degrees. A small rounding operation is applied
@@ -87,8 +87,8 @@ class Bada(object):
87
87
 
88
88
  @staticmethod
89
89
  def bankAngle(rateOfTurn, v):
90
- """
91
- Computes the bank angle based on true airspeed (TAS) and rate of turn.
90
+ """Computes the bank angle based on true airspeed (TAS) and rate of
91
+ turn.
92
92
 
93
93
  :param v: True airspeed (TAS) in meters per second (m/s).
94
94
  :param rateOfTurn: Rate of turn in degrees per second (deg/s).
@@ -105,8 +105,8 @@ class Bada(object):
105
105
 
106
106
  @staticmethod
107
107
  def rateOfTurn(v, nz=1.0):
108
- """
109
- Computes the rate of turn based on true airspeed (TAS) and load factor.
108
+ """Computes the rate of turn based on true airspeed (TAS) and load
109
+ factor.
110
110
 
111
111
  :param v: True airspeed (TAS) in meters per second (m/s).
112
112
  :param nz: Load factor (default is 1.0), dimensionless.
@@ -120,8 +120,8 @@ class Bada(object):
120
120
 
121
121
  @staticmethod
122
122
  def rateOfTurn_bankAngle(TAS, bankAngle):
123
- """
124
- Computes the rate of turn based on true airspeed (TAS) and bank angle.
123
+ """Computes the rate of turn based on true airspeed (TAS) and bank
124
+ angle.
125
125
 
126
126
  :param TAS: True airspeed (TAS) in meters per second (m/s).
127
127
  :param bankAngle: Bank angle in degrees.
@@ -137,8 +137,8 @@ class Bada(object):
137
137
 
138
138
  @staticmethod
139
139
  def turnRadius(v, nz=1.0):
140
- """
141
- Computes the turn radius based on true airspeed (TAS) and load factor.
140
+ """Computes the turn radius based on true airspeed (TAS) and load
141
+ factor.
142
142
 
143
143
  :param v: True airspeed (TAS) in meters per second (m/s).
144
144
  :param nz: Load factor (default is 1.0), dimensionless.
@@ -152,8 +152,8 @@ class Bada(object):
152
152
 
153
153
  @staticmethod
154
154
  def turnRadius_bankAngle(v, ba):
155
- """
156
- Computes the turn radius based on true airspeed (TAS) and bank angle.
155
+ """Computes the turn radius based on true airspeed (TAS) and bank
156
+ angle.
157
157
 
158
158
  :param v: True airspeed (TAS) in meters per second (m/s).
159
159
  :param ba: Bank angle in degrees.
@@ -167,8 +167,8 @@ class Bada(object):
167
167
 
168
168
  @staticmethod
169
169
  def GS(tas, gamma, Ws):
170
- """
171
- Computes the ground speed based on true airspeed (TAS), flight path angle, and wind speed.
170
+ """Computes the ground speed based on true airspeed (TAS), flight path
171
+ angle, and wind speed.
172
172
 
173
173
  :param tas: True airspeed (TAS) in meters per second (m/s).
174
174
  :param gamma: Flight path angle in degrees.
@@ -183,7 +183,7 @@ class Bada(object):
183
183
  return tas * cos(radians(gamma)) + Ws
184
184
 
185
185
 
186
- class BadaFamily(object):
186
+ class BadaFamily:
187
187
  """This class sets the token for the respected BADA Family."""
188
188
 
189
189
  def __init__(self, BADA3=False, BADA4=False, BADAH=False, BADAE=False):
@@ -193,14 +193,14 @@ class BadaFamily(object):
193
193
  self.BADAE = BADAE
194
194
 
195
195
 
196
- class Airplane(object):
197
- """This is a generic airplane class based on a three-degrees-of-freedom point mass model (where all the forces
198
- are applied at the center of gravity).
196
+ class Airplane:
197
+ """This is a generic airplane class based on a three-degrees-of-freedom
198
+ point mass model (where all the forces are applied at the center of
199
+ gravity).
199
200
 
200
201
  .. note::this generic class only implements basic aircraft dynamics
201
202
  calculations, aircraft performance and optimisation can be obtained
202
203
  from its inherited classes
203
-
204
204
  """
205
205
 
206
206
  def __init__(self):
@@ -208,12 +208,12 @@ class Airplane(object):
208
208
 
209
209
  @staticmethod
210
210
  def esf(**kwargs):
211
- """
212
- Computes the energy share factor based on flight conditions.
211
+ """Computes the energy share factor based on flight conditions.
213
212
 
214
213
  :param h: Altitude in meters.
215
214
  :param DeltaTemp: Temperature deviation with respect to ISA in Kelvin.
216
- :param flightEvolution: Type of flight evolution [constM/constCAS/acc/dec].
215
+ :param flightEvolution: Type of flight evolution
216
+ [constM/constCAS/acc/dec].
217
217
  :param phase: Phase of flight [cl/des].
218
218
  :param v: Constant speed (Mach number).
219
219
  :type h: float
@@ -315,13 +315,12 @@ class Airplane(object):
315
315
  return ESF
316
316
 
317
317
 
318
- class Helicopter(object):
318
+ class Helicopter:
319
319
  """This is a generic helicopter class based on a Total-Energy Model (TEM)
320
320
 
321
321
  .. note::this generic class only implements basic aircraft dynamics
322
322
  calculations, aircraft performance and optimisation can be obtained
323
323
  from its inherited classes
324
-
325
324
  """
326
325
 
327
326
  def __init__(self):
@@ -329,12 +328,12 @@ class Helicopter(object):
329
328
 
330
329
  @staticmethod
331
330
  def esf(**kwargs):
332
- """
333
- Computes the energy share factor based on flight conditions.
331
+ """Computes the energy share factor based on flight conditions.
334
332
 
335
333
  :param h: Altitude in meters.
336
334
  :param DeltaTemp: Temperature deviation with respect to ISA in Kelvin.
337
- :param flightEvolution: Type of flight evolution [constTAS/constCAS/acc/dec].
335
+ :param flightEvolution: Type of flight evolution
336
+ [constTAS/constCAS/acc/dec].
338
337
  :param phase: Phase of flight [Climb/Descent].
339
338
  :param v: Constant speed (Mach number).
340
339
  :type h: float