pyBADA 0.1.1__py3-none-any.whl → 0.1.2__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/aircraft.py CHANGED
@@ -21,30 +21,55 @@ def checkArgument(argument, **kwargs):
21
21
  raise TypeError("Missing " + argument + " argument")
22
22
 
23
23
 
24
- class BadaFamily(object):
25
- """This class sets the token for the respected BADA Family."""
24
+ class Bada(object):
25
+ """This class implements the mechanisms applicable across all BADA families."""
26
26
 
27
- def __init__(self, BADA3=False, BADA4=False, BADAH=False, BADAE=False):
28
- self.BADA3 = BADA3
29
- self.BADA4 = BADA4
30
- self.BADAH = BADAH
31
- self.BADAE = BADAE
27
+ def __init__(self):
28
+ pass
32
29
 
30
+ @staticmethod
31
+ def getBADAParameters(df, acName, parameters):
32
+ """
33
+ Retrieves specified parameters for a given aircraft name from a DataFrame.
34
+
35
+ :param df: DataFrame containing BADA aircraft data.
36
+ :param acName: Name of the aircraft or list of aircraft names to search for.
37
+ :param parameters: List of column names (or a single column name) to retrieve.
38
+ :type df: pd.DataFrame
39
+ :type acName: list or str
40
+ :type parameters: list or str
41
+ :returns: A DataFrame containing the specified parameters for the given aircraft.
42
+ :rtype: pd.DataFrame
43
+ :raises ValueError: If any of the specified columns or aircraft names are not found.
44
+ """
33
45
 
34
- class Airplane(object):
35
- """This is a generic airplane class based on a three-degrees-of-freedom point mass model (where all the forces
36
- are applied at the center of gravity).
46
+ # Ensure parameters is a list
47
+ if isinstance(parameters, str):
48
+ parameters = [parameters]
37
49
 
38
- .. note::this generic class only implements basic aircraft dynamics
39
- calculations, aircraft performance and optimisation can be obtained
40
- from its inherited classes
50
+ # Ensure acName is a list
51
+ if isinstance(acName, str):
52
+ acName = [acName]
41
53
 
42
- """
54
+ # Ensure all requested parameters exist in the DataFrame
55
+ missing_cols = [col for col in parameters if col not in df.columns]
56
+ if missing_cols:
57
+ raise ValueError(
58
+ f"The following parameters are not in the DataFrame columns: {missing_cols}"
59
+ )
43
60
 
44
- __metaclass__ = abc.ABCMeta
61
+ # Filter rows where 'acName' matches any of the specified aircraft names
62
+ filtered_df = df[df["acName"].isin(acName)]
45
63
 
46
- def __init__(self):
47
- pass
64
+ # Check if any rows were found
65
+ if filtered_df.empty:
66
+ raise ValueError(f"No entries found for aircraft(s): {acName}.")
67
+ else:
68
+ # Select the required columns
69
+ result_df = filtered_df[["acName"] + parameters].reset_index(
70
+ drop=True
71
+ )
72
+ return result_df
48
73
 
49
74
  @staticmethod
50
75
  def loadFactor(fi):
@@ -81,6 +106,21 @@ class Airplane(object):
81
106
  BA = atan((ROT * v) / const.g)
82
107
  return conv.rad2deg(BA)
83
108
 
109
+ @staticmethod
110
+ def rateOfTurn(v, nz=1.0):
111
+ """
112
+ Computes the rate of turn based on true airspeed (TAS) and load factor.
113
+
114
+ :param v: True airspeed (TAS) in meters per second (m/s).
115
+ :param nz: Load factor (default is 1.0), dimensionless.
116
+ :type v: float
117
+ :type nz: float
118
+ :returns: Rate of turn in degrees per second (deg/s).
119
+ :rtype: float
120
+ """
121
+
122
+ return degrees((const.g / v) * sqrt(nz * nz - 1))
123
+
84
124
  @staticmethod
85
125
  def rateOfTurn_bankAngle(TAS, bankAngle):
86
126
  """
@@ -98,21 +138,6 @@ class Airplane(object):
98
138
 
99
139
  return degrees(ROT)
100
140
 
101
- @staticmethod
102
- def rateOfTurn(v, nz=1.0):
103
- """
104
- Computes the rate of turn based on true airspeed (TAS) and load factor.
105
-
106
- :param v: True airspeed (TAS) in meters per second (m/s).
107
- :param nz: Load factor (default is 1.0), dimensionless.
108
- :type v: float
109
- :type nz: float
110
- :returns: Rate of turn in degrees per second (deg/s).
111
- :rtype: float
112
- """
113
-
114
- return degrees((const.g / v) * sqrt(nz * nz - 1))
115
-
116
141
  @staticmethod
117
142
  def turnRadius(v, nz=1.0):
118
143
  """
@@ -160,6 +185,30 @@ class Airplane(object):
160
185
 
161
186
  return tas * cos(radians(gamma)) + Ws
162
187
 
188
+
189
+ class BadaFamily(object):
190
+ """This class sets the token for the respected BADA Family."""
191
+
192
+ def __init__(self, BADA3=False, BADA4=False, BADAH=False, BADAE=False):
193
+ self.BADA3 = BADA3
194
+ self.BADA4 = BADA4
195
+ self.BADAH = BADAH
196
+ self.BADAE = BADAE
197
+
198
+
199
+ class Airplane(object):
200
+ """This is a generic airplane class based on a three-degrees-of-freedom point mass model (where all the forces
201
+ are applied at the center of gravity).
202
+
203
+ .. note::this generic class only implements basic aircraft dynamics
204
+ calculations, aircraft performance and optimisation can be obtained
205
+ from its inherited classes
206
+
207
+ """
208
+
209
+ def __init__(self):
210
+ pass
211
+
163
212
  @staticmethod
164
213
  def esf(**kwargs):
165
214
  """
@@ -278,90 +327,9 @@ class Helicopter(object):
278
327
 
279
328
  """
280
329
 
281
- __metaclass__ = abc.ABCMeta
282
-
283
330
  def __init__(self):
284
331
  pass
285
332
 
286
- @staticmethod
287
- def loadFactor(fi):
288
- """
289
- Computes the load factor from a given bank angle.
290
-
291
- The load factor is calculated based on the cosine of the bank angle,
292
- which is expressed in degrees. A small rounding operation is applied
293
- to avoid precision issues with small decimal places.
294
-
295
- :param fi: Bank angle in degrees.
296
- :type fi: float
297
- :returns: The load factor (dimensionless).
298
- :rtype: float
299
- """
300
-
301
- return 1 / round(cos(radians(fi)), 10)
302
-
303
- @staticmethod
304
- def rateOfTurn(v, nz=1.0):
305
- """
306
- Computes the rate of turn based on true airspeed (TAS) and load factor.
307
-
308
- :param v: True airspeed (TAS) in meters per second (m/s).
309
- :param nz: Load factor (default is 1.0), dimensionless.
310
- :type v: float
311
- :type nz: float
312
- :returns: Rate of turn in degrees per second (deg/s).
313
- :rtype: float
314
- """
315
-
316
- return degrees((const.g / v) * sqrt(nz * nz - 1))
317
-
318
- @staticmethod
319
- def rateOfTurn_bankAngle(TAS, bankAngle):
320
- """
321
- Computes the rate of turn based on true airspeed (TAS) and bank angle.
322
-
323
- :param TAS: True airspeed (TAS) in meters per second (m/s).
324
- :param bankAngle: Bank angle in degrees.
325
- :type TAS: float
326
- :type bankAngle: float
327
- :returns: Rate of turn in degrees per second (deg/s).
328
- :rtype: float
329
- """
330
-
331
- ROT = tan(radians(bankAngle)) * const.g / TAS
332
-
333
- return degrees(ROT)
334
-
335
- @staticmethod
336
- def turnRadius(v, nz=1.0):
337
- """
338
- Computes the turn radius based on true airspeed (TAS) and load factor.
339
-
340
- :param v: True airspeed (TAS) in meters per second (m/s).
341
- :param nz: Load factor (default is 1.0), dimensionless.
342
- :type v: float
343
- :type nz: float
344
- :returns: Turn radius in meters.
345
- :rtype: float
346
- """
347
-
348
- return (v * v / const.g) * (1 / sqrt(nz * nz - 1))
349
-
350
- @staticmethod
351
- def turnRadius_bankAngle(v, ba):
352
- """
353
- Computes the turn radius based on true airspeed (TAS) and bank angle.
354
-
355
- :param v: True airspeed (TAS) in meters per second (m/s).
356
- :param ba: Bank angle in degrees.
357
- :type v: float
358
- :type ba: float
359
- :returns: Turn radius in meters.
360
- :rtype: float
361
- """
362
-
363
- return (v * v / const.g) * (1 / tan(conv.deg2rad(ba)))
364
-
365
333
  @staticmethod
366
334
  def esf(**kwargs):
367
335
  """
@@ -429,21 +397,3 @@ class Helicopter(object):
429
397
  ESF = float("Nan")
430
398
 
431
399
  return ESF
432
-
433
- @staticmethod
434
- def bankAngle(rateOfTurn, v):
435
- """
436
- Computes the bank angle based on true airspeed (TAS) and rate of turn.
437
-
438
- :param v: True airspeed (TAS) in meters per second (m/s).
439
- :param rateOfTurn: Rate of turn in degrees per second (deg/s).
440
- :type v: float
441
- :type rateOfTurn: float
442
- :returns: Bank angle in degrees.
443
- :rtype: float
444
- """
445
-
446
- ROT = conv.deg2rad(rateOfTurn)
447
-
448
- BA = atan((ROT * v) / const.g)
449
- return conv.rad2deg(BA)