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/badaH.py CHANGED
@@ -1,9 +1,5 @@
1
- # -*- coding: utf-8 -*-
2
1
  """
3
- pyBADA
4
2
  Generic BADAH aircraft performance module
5
- Developped @EUROCONTROL (EIH)
6
- 2024
7
3
  """
8
4
 
9
5
  import xml.etree.ElementTree as ET
@@ -13,7 +9,6 @@ import numpy as np
13
9
  from math import sqrt, pow, pi, cos, asin, radians, isnan
14
10
  import pandas as pd
15
11
 
16
- from scipy.optimize import minimize, Bounds
17
12
 
18
13
  from pyBADA import constants as const
19
14
  from pyBADA import conversions as conv
@@ -37,26 +32,30 @@ def checkArgument(argument, **kwargs):
37
32
 
38
33
 
39
34
  class Parser:
40
- """This class implements the BADAH parsing mechanism to parse xml BADAH files."""
35
+ """This class implements the BADAH parsing mechanism to parse xml BADAH
36
+ files."""
41
37
 
42
38
  def __init__(self):
43
39
  pass
44
40
 
45
41
  @staticmethod
46
42
  def parseXML(filePath, acName):
47
- """
48
- Parses the BADAH XML file for a specific aircraft model and extracts various parameters.
43
+ """Parses the BADAH XML file for a specific aircraft model and
44
+ extracts various parameters.
49
45
 
50
- This function parses the BADAH aircraft XML file for a given aircraft model (acName). It retrieves
51
- general information about the aircraft, engine type, aerodynamic configurations, performance parameters, and more.
46
+ This function parses the BADAH aircraft XML file for a given aircraft
47
+ model (acName). It retrieves general information about the aircraft,
48
+ engine type, aerodynamic configurations, performance parameters, and
49
+ more.
52
50
 
53
51
  :param filePath: The path to the folder containing the BADAH XML file.
54
- :param acName: The aircraft code name for which the XML file is being parsed.
52
+ :param acName: The aircraft code name for which the XML file is being
53
+ parsed.
55
54
  :type filePath: str
56
55
  :type acName: str
57
56
  :raises IOError: If the XML file cannot be found or parsed.
58
-
59
- :return: A pandas DataFrame containing the parsed data for the specified aircraft.
57
+ :return: A pandas DataFrame containing the parsed data for the
58
+ specified aircraft.
60
59
  :rtype: pd.DataFrame
61
60
  """
62
61
 
@@ -65,7 +64,7 @@ class Parser:
65
64
  try:
66
65
  tree = ET.parse(acXmlFile)
67
66
  root = tree.getroot()
68
- except:
67
+ except Exception:
69
68
  raise IOError(acXmlFile + " not found or in correct format")
70
69
 
71
70
  # Parse general aircraft data
@@ -160,19 +159,20 @@ class Parser:
160
159
 
161
160
  @staticmethod
162
161
  def readSynonym(filePath):
163
- """
164
- Parses the BADAH Synonym XML file and returns a dictionary mapping aircraft code names
165
- to their respective model files.
162
+ """Parses the BADAH Synonym XML file and returns a dictionary mapping
163
+ aircraft code names to their respective model files.
166
164
 
167
- :param filePath: Path to the directory containing the BADA4 synonym XML file.
165
+ :param filePath: Path to the directory containing the BADA4 synonym
166
+ XML file.
168
167
  :type filePath: str
169
- :returns: A dictionary where the keys are aircraft codes and the values are associated file names.
168
+ :returns: A dictionary where the keys are aircraft codes and the
169
+ values are associated file names.
170
170
  :rtype: dict
171
171
  :raises IOError: If the XML file is missing or has an invalid format.
172
-
173
- This function attempts to read the synonym XML file, parse its contents, and store the
174
- mappings in a dictionary. The file contains aircraft code, manufacturer, ICAO designation,
175
- and file name data for each aircraft in the synonym list.
172
+ This function attempts to read the synonym XML file, parse its
173
+ contents, and store the mappings in a dictionary. The file
174
+ contains aircraft code, manufacturer, ICAO designation, and file
175
+ name data for each aircraft in the synonym list.
176
176
  """
177
177
 
178
178
  filename = os.path.join(filePath, "SYNONYM.xml")
@@ -184,7 +184,7 @@ class Parser:
184
184
  try:
185
185
  tree = ET.parse(filename)
186
186
  root = tree.getroot()
187
- except:
187
+ except Exception:
188
188
  raise IOError(filename + " not found or in correct format")
189
189
 
190
190
  for child in root.iter("SYN"):
@@ -199,8 +199,8 @@ class Parser:
199
199
 
200
200
  @staticmethod
201
201
  def parseSynonym(filePath, acName):
202
- """
203
- Retrieves the file name associated with a given aircraft code from the BADAH synonym file.
202
+ """Retrieves the file name associated with a given aircraft code from
203
+ the BADAH synonym file.
204
204
 
205
205
  :param filePath: Path to the directory containing the BADAH synonym XML file.
206
206
  :param acName: The ICAO aircraft code or name to search for in the synonym file.
@@ -222,26 +222,31 @@ class Parser:
222
222
 
223
223
  @staticmethod
224
224
  def parseAll(badaVersion, filePath=None):
225
- """
226
- Parses all BADAH XML-formatted files and compiles the data into a single DataFrame.
225
+ """Parses all BADAH XML-formatted files and compiles the data into a
226
+ single DataFrame.
227
227
 
228
- This function reads the BADAH aircraft performance model data by parsing the XML files for each aircraft
229
- model found in the specified directory. If the synonym XML file is present, it maps synonyms (alternative
230
- names for aircraft) to their respective model files and includes them in the output DataFrame.
228
+ This function reads the BADAH aircraft performance model data by
229
+ parsing the XML files for each aircraft model found in the specified
230
+ directory. If the synonym XML file is present, it maps synonyms
231
+ (alternative names for aircraft) to their respective model files and
232
+ includes them in the output DataFrame.
231
233
 
232
234
  :param badaVersion: The version of BADAH being used (e.g., '1.1').
233
- :param filePath: Optional path to the directory containing the BADAH files. If not provided, it uses the default path.
235
+ :param filePath: Optional path to the directory containing the BADAH
236
+ files. If not provided, it uses the default path.
234
237
  :type badaVersion: str
235
238
  :type filePath: str, optional
236
- :returns: A pandas DataFrame containing all parsed BADAH model data, including any synonyms found.
239
+ :returns: A pandas DataFrame containing all parsed BADAH model data,
240
+ including any synonyms found.
237
241
  :rtype: pd.DataFrame
238
- :raises IOError: If an error occurs while reading or parsing the XML files.
239
-
240
- This function first checks if a synonym XML file exists to map synonyms to model files. Then, it parses
241
- all XML files in the directory and its subfolders, merges the parsed data into a final DataFrame, and returns it.
242
+ :raises IOError: If an error occurs while reading or parsing the XML
243
+ files. This function first checks if a synonym XML file exists to
244
+ map synonyms to model files. Then, it parses all XML files in the
245
+ directory and its subfolders, merges the parsed data into a final
246
+ DataFrame, and returns it.
242
247
  """
243
248
 
244
- if filePath == None:
249
+ if filePath is None:
245
250
  filePath = configuration.getBadaVersionPath(
246
251
  badaFamily="BADAH", badaVersion=badaVersion
247
252
  )
@@ -281,7 +286,8 @@ class Parser:
281
286
 
282
287
 
283
288
  class BADAH(Helicopter, Bada):
284
- """This class implements the part of BADAH performance model that will be used in other classes following the BADAH manual.
289
+ """This class implements the part of BADAH performance model that will be
290
+ used in other classes following the BADAH manual.
285
291
 
286
292
  :param AC: Aircraft object {BADAH}.
287
293
  :type AC: badaHAircraft.
@@ -292,11 +298,12 @@ class BADAH(Helicopter, Bada):
292
298
  self.AC = AC
293
299
 
294
300
  def mu(self, tas):
295
- """
296
- Computes the advance ratio (mu) for the aircraft based on true airspeed (TAS) and rotor speed.
301
+ """Computes the advance ratio (mu) for the aircraft based on true
302
+ airspeed (TAS) and rotor speed.
297
303
 
298
- The advance ratio is a non-dimensional parameter that relates the forward speed of the aircraft
299
- to the rotational speed of its main rotor.
304
+ The advance ratio is a non-dimensional parameter that relates the
305
+ forward speed of the aircraft to the rotational speed of its main
306
+ rotor.
300
307
 
301
308
  :param tas: True airspeed (TAS) in meters per second [m/s].
302
309
  :type tas: float
@@ -310,11 +317,11 @@ class BADAH(Helicopter, Bada):
310
317
  return mu
311
318
 
312
319
  def CT(self, mass, rho, phi):
313
- """
314
- Computes the thrust coefficient (CT) for the aircraft.
320
+ """Computes the thrust coefficient (CT) for the aircraft.
315
321
 
316
- The thrust coefficient is a dimensionless quantity that represents the thrust produced by the
317
- aircraft's rotor in relation to the air density, rotor radius, and rotor speed.
322
+ The thrust coefficient is a dimensionless quantity that represents the
323
+ thrust produced by the aircraft's rotor in relation to the air
324
+ density, rotor radius, and rotor speed.
318
325
 
319
326
  :param mass: Aircraft mass in kilograms [kg].
320
327
  :param rho: Air density in kilograms per cubic meter [kg/m³].
@@ -337,11 +344,12 @@ class BADAH(Helicopter, Bada):
337
344
  return CT
338
345
 
339
346
  def CPreq(self, mu, CT):
340
- """
341
- Computes the power required coefficient (CPreq) based on the advance ratio (mu) and thrust coefficient (CT).
347
+ """Computes the power required coefficient (CPreq) based on the
348
+ advance ratio (mu) and thrust coefficient (CT).
342
349
 
343
- The power required coefficient relates to the total power required to maintain flight,
344
- factoring in the aerodynamic performance of the rotor in different operating regimes.
350
+ The power required coefficient relates to the total power required to
351
+ maintain flight, factoring in the aerodynamic performance of the rotor
352
+ in different operating regimes.
345
353
 
346
354
  :param mu: Advance ratio [-].
347
355
  :param CT: Thrust coefficient [-].
@@ -364,14 +372,16 @@ class BADAH(Helicopter, Bada):
364
372
  return CPreq
365
373
 
366
374
  def Preq(self, sigma, tas, mass, phi=0.0):
367
- """
368
- Computes the power required for the aircraft to maintain flight based on various factors
369
- such as air density, true airspeed (TAS), aircraft mass, and bank angle.
375
+ """Computes the power required for the aircraft to maintain flight
376
+ based on various factors such as air density, true airspeed (TAS),
377
+ aircraft mass, and bank angle.
370
378
 
371
- :param sigma: Normalized air density [-], which is the ratio of the current air density to sea level air density.
379
+ :param sigma: Normalized air density [-], which is the ratio of the
380
+ current air density to sea level air density.
372
381
  :param tas: True airspeed (TAS) in meters per second [m/s].
373
382
  :param mass: Aircraft mass in kilograms [kg].
374
- :param phi: Bank angle in degrees [deg], default is 0 for straight flight.
383
+ :param phi: Bank angle in degrees [deg], default is 0 for straight
384
+ flight.
375
385
  :type sigma: float
376
386
  :type tas: float
377
387
  :type mass: float
@@ -399,15 +409,16 @@ class BADAH(Helicopter, Bada):
399
409
  return Preq
400
410
 
401
411
  def Peng_target(self, ROCD, mass, Preq, ESF, temp, DeltaTemp):
402
- """
403
- Computes the target engine power required to achieve a specific rate of climb or descent.
412
+ """Computes the target engine power required to achieve a specific
413
+ rate of climb or descent.
404
414
 
405
415
  :param ROCD: Rate of climb or descent in meters per second [m/s].
406
416
  :param mass: Aircraft mass in kilograms [kg].
407
417
  :param Preq: Power required in watts [W].
408
418
  :param ESF: Energy share factor, a dimensionless factor [-].
409
419
  :param temp: Atmospheric temperature in kelvins [K].
410
- :param DeltaTemp: Deviation from the International Standard Atmosphere (ISA) temperature in kelvins [K].
420
+ :param DeltaTemp: Deviation from the International Standard Atmosphere
421
+ (ISA) temperature in kelvins [K].
411
422
  :type ROCD: float
412
423
  :type mass: float
413
424
  :type Preq: float
@@ -424,9 +435,9 @@ class BADAH(Helicopter, Bada):
424
435
  return Peng_target
425
436
 
426
437
  def CPav(self, rating, delta, theta):
427
- """
428
- Computes the power available coefficient (CPav) based on engine type, throttle rating,
429
- normalized air pressure (delta), and normalized temperature (theta).
438
+ """Computes the power available coefficient (CPav) based on engine
439
+ type, throttle rating, normalized air pressure (delta), and normalized
440
+ temperature (theta).
430
441
 
431
442
  :param rating: Engine throttle setting, e.g., {MTKF, MCNT}.
432
443
  :param delta: Normalized air pressure [-].
@@ -488,14 +499,15 @@ class BADAH(Helicopter, Bada):
488
499
  return CPav
489
500
 
490
501
  def Pmax(self, rating):
491
- """
492
- Computes the maximum power available for all engines at a given throttle setting.
502
+ """Computes the maximum power available for all engines at a given
503
+ throttle setting.
493
504
 
494
505
  :param rating: Throttle setting, e.g., {MTKF, MCNT}.
495
506
  :type rating: str
496
507
  :return: Maximum all-engine power in watts [W].
497
508
  :rtype: float
498
- :raises ValueError: If the specified throttle setting is not recognized.
509
+ :raises ValueError: If the specified throttle setting is not
510
+ recognized.
499
511
  """
500
512
 
501
513
  if rating not in self.AC.Pmax_.keys():
@@ -503,19 +515,21 @@ class BADAH(Helicopter, Bada):
503
515
  return self.AC.Pmax_[rating]
504
516
 
505
517
  def Pav(self, rating, delta, theta):
506
- """
507
- Computes the power available at the given throttle setting, based on normalized pressure
508
- and temperature.
518
+ """Computes the power available at the given throttle setting, based
519
+ on normalized pressure and temperature.
509
520
 
510
521
  :param rating: Throttle setting, e.g., {MTKF, MCNT}.
511
- :param delta: Normalized pressure [-], ratio of actual pressure to standard sea level pressure.
512
- :param theta: Normalized temperature [-], ratio of actual temperature to standard sea level temperature.
522
+ :param delta: Normalized pressure [-], ratio of actual pressure to
523
+ standard sea level pressure.
524
+ :param theta: Normalized temperature [-], ratio of actual temperature
525
+ to standard sea level temperature.
513
526
  :type rating: str
514
527
  :type delta: float
515
528
  :type theta: float
516
529
  :return: Available power in watts [W].
517
530
  :rtype: float
518
- :raises ValueError: If the specified throttle setting is not recognized.
531
+ :raises ValueError: If the specified throttle setting is not
532
+ recognized.
519
533
  """
520
534
 
521
535
  Pmax = self.Pmax(rating=rating)
@@ -534,8 +548,8 @@ class BADAH(Helicopter, Bada):
534
548
  return Pav
535
549
 
536
550
  def Q(self, Peng):
537
- """
538
- Computes the torque value as a percentage of the reference torque (P0).
551
+ """Computes the torque value as a percentage of the reference torque
552
+ (P0).
539
553
 
540
554
  :param Peng: All-engine power in watts [W].
541
555
  :type Peng: float
@@ -548,8 +562,8 @@ class BADAH(Helicopter, Bada):
548
562
  return Q
549
563
 
550
564
  def CP(self, Peng):
551
- """
552
- Computes the engine power coefficient (CP) based on the given all-engine power.
565
+ """Computes the engine power coefficient (CP) based on the given all-
566
+ engine power.
553
567
 
554
568
  :param Peng: All-engine power in watts [W].
555
569
  :type Peng: float
@@ -567,11 +581,13 @@ class BADAH(Helicopter, Bada):
567
581
  return CP
568
582
 
569
583
  def ff(self, delta, CP):
570
- """
571
- Computes the fuel flow rate based on normalized pressure and power coefficient.
584
+ """Computes the fuel flow rate based on normalized pressure and power
585
+ coefficient.
572
586
 
573
- :param delta: Normalized pressure [-], which is the ratio of actual air pressure to standard sea-level pressure.
574
- :param CP: Power coefficient [-], representing the power output in relation to the engine's maximum power.
587
+ :param delta: Normalized pressure [-], which is the ratio of actual
588
+ air pressure to standard sea-level pressure.
589
+ :param CP: Power coefficient [-], representing the power output in
590
+ relation to the engine's maximum power.
575
591
  :type delta: float
576
592
  :type CP: float
577
593
  :return: Fuel flow rate in kilograms per second [kg/s].
@@ -605,15 +621,17 @@ class BADAH(Helicopter, Bada):
605
621
  return ff / 3600
606
622
 
607
623
  def ROCD(self, Peng, Preq, mass, ESF, theta, DeltaTemp):
608
- """
609
- Computes the Rate of Climb or Descent (ROCD) for an aircraft.
624
+ """Computes the Rate of Climb or Descent (ROCD) for an aircraft.
610
625
 
611
626
  :param Peng: All-engine power available [W].
612
627
  :param Preq: Power required for steady flight [W].
613
628
  :param mass: Aircraft's current mass [kg].
614
- :param ESF: Energy share factor [-], a multiplier used to adjust power distribution in different flight phases.
615
- :param theta: Normalized temperature [-], ratio of actual temperature to standard sea-level temperature.
616
- :param DeltaTemp: Deviation from the International Standard Atmosphere (ISA) temperature [K].
629
+ :param ESF: Energy share factor [-], a multiplier used to adjust power
630
+ distribution in different flight phases.
631
+ :param theta: Normalized temperature [-], ratio of actual temperature
632
+ to standard sea-level temperature.
633
+ :param DeltaTemp: Deviation from the International Standard Atmosphere
634
+ (ISA) temperature [K].
617
635
  :type Peng: float
618
636
  :type Preq: float
619
637
  :type mass: float
@@ -636,8 +654,8 @@ class BADAH(Helicopter, Bada):
636
654
 
637
655
 
638
656
  class FlightEnvelope(BADAH):
639
- """This class is a BADAH aircraft subclass and implements the flight envelope caclulations
640
- following the BADAH manual.
657
+ """This class is a BADAH aircraft subclass and implements the flight
658
+ envelope caclulations following the BADAH manual.
641
659
 
642
660
  :param AC: Aircraft object {BADAH}.
643
661
  :type AC: badaHAircraft.
@@ -647,8 +665,7 @@ class FlightEnvelope(BADAH):
647
665
  super().__init__(AC)
648
666
 
649
667
  def maxAltitude(self):
650
- """
651
- Computes the maximum operational altitude for the aircraft.
668
+ """Computes the maximum operational altitude for the aircraft.
652
669
 
653
670
  :return: Maximum altitude in meters [m].
654
671
  :rtype: float.
@@ -658,8 +675,8 @@ class FlightEnvelope(BADAH):
658
675
  return hMax
659
676
 
660
677
  def VMax(self):
661
- """
662
- Computes the maximum speed in Calibrated Airspeed (CAS) as limited by the flight envelope.
678
+ """Computes the maximum speed in Calibrated Airspeed (CAS) as limited
679
+ by the flight envelope.
663
680
 
664
681
  :return: Maximum CAS speed in meters per second [m/s].
665
682
  :rtype: float.
@@ -671,23 +688,25 @@ class FlightEnvelope(BADAH):
671
688
  def speedEnvelope_powerLimited(
672
689
  self, h, mass, DeltaTemp, rating="MCNT", rateOfTurn=0
673
690
  ):
674
- """
675
- Computes the maximum and minimum speeds (CAS) within the certified flight envelope,
676
- taking into account engine thrust limitations.
691
+ """Computes the maximum and minimum speeds (CAS) within the certified
692
+ flight envelope, taking into account engine thrust limitations.
677
693
 
678
694
  :param h: Altitude in meters [m].
679
695
  :param mass: Aircraft mass in kilograms [kg].
680
- :param DeltaTemp: Deviation from the International Standard Atmosphere (ISA) temperature [K].
681
- :param rating: Engine rating (e.g., "MTKF", "MCNT") determining the power output [-].
682
- :param rateOfTurn: Rate of turn in degrees per second, which affects bank angle [°/s].
696
+ :param DeltaTemp: Deviation from the International Standard Atmosphere
697
+ (ISA) temperature [K].
698
+ :param rating: Engine rating (e.g., "MTKF", "MCNT") determining the
699
+ power output [-].
700
+ :param rateOfTurn: Rate of turn in degrees per second, which affects
701
+ bank angle [°/s].
683
702
  :type h: float
684
703
  :type mass: float
685
704
  :type DeltaTemp: float
686
705
  :type rating: str
687
706
  :type rateOfTurn: float
688
- :return: A tuple containing the minimum and maximum thrust-limited CAS speeds [m/s].
707
+ :return: A tuple containing the minimum and maximum thrust- limited
708
+ CAS speeds [m/s].
689
709
  :rtype: tuple(float, float)
690
- :raises ValueError: If no valid CAS speeds are found within the power limits.
691
710
  """
692
711
 
693
712
  [theta, delta, sigma] = atm.atmosphereProperties(
@@ -726,9 +745,70 @@ class FlightEnvelope(BADAH):
726
745
 
727
746
  return (minCAS, maxCAS)
728
747
 
748
+ def Vx(self, h, mass, DeltaTemp, rating="MTKF", rateOfTurn=0):
749
+ """Computes the best angle climb speed (TAS) by finding the speed that
750
+ maximizes the excess power per unit speed within the helicopter's
751
+ performance envelope.
752
+
753
+ :param h: Altitude in meters [m].
754
+ :param mass: Aircraft mass in kilograms [kg].
755
+ :param DeltaTemp: Deviation from the International Standard Atmosphere
756
+ (ISA) temperature [K].
757
+ :param rating: Engine rating (e.g., "MTKF", "MCNT") determining the
758
+ power output [-].
759
+ :param rateOfTurn: Rate of turn in degrees per second, which affects
760
+ the bank angle [°/s].
761
+ :type h: float
762
+ :type mass: float
763
+ :type DeltaTemp: float
764
+ :type rating: str
765
+ :type rateOfTurn: float
766
+ :return: The true airspeed (TAS) corresponding to the best angle climb
767
+ speed [m/s].
768
+ :rtype: float
769
+ """
770
+ [theta, delta, sigma] = atm.atmosphereProperties(
771
+ h=h, DeltaTemp=DeltaTemp
772
+ )
773
+
774
+ VminCertified = 0 + 5 # putting some margin to not start at 0 speed
775
+ VmaxCertified = self.VMax()
776
+
777
+ excessPowerList = []
778
+ VxList = []
779
+
780
+ for CAS in np.linspace(
781
+ VminCertified, VmaxCertified, num=200, endpoint=True
782
+ ):
783
+ TAS = atm.cas2Tas(cas=CAS, delta=delta, sigma=sigma)
784
+ bankAngle = self.bankAngle(rateOfTurn=rateOfTurn, v=TAS)
785
+ Preq = self.Preq(sigma=sigma, tas=TAS, mass=mass, phi=bankAngle)
786
+ Pav = self.Pav(rating=rating, theta=theta, delta=delta)
787
+
788
+ tempConst = (theta * const.temp_0 - DeltaTemp) / (
789
+ theta * const.temp_0
790
+ )
791
+
792
+ excessPowerList.append(
793
+ (Pav - Preq) * tempConst / TAS
794
+ ) # including speed and impact of the temperature deviation from ISA conditions
795
+ VxList.append(CAS)
796
+
797
+ VxCAS = VxList[excessPowerList.index(max(excessPowerList))]
798
+ [VxM, VxCAS, VxTAS] = atm.convertSpeed(
799
+ v=conv.ms2kt(VxCAS),
800
+ speedType="CAS",
801
+ theta=theta,
802
+ delta=delta,
803
+ sigma=sigma,
804
+ )
805
+
806
+ return VxTAS
807
+
729
808
 
730
809
  class Optimization(BADAH):
731
- """This class implements the BADAH optimization following the BADAH manual.
810
+ """This class implements the BADAH optimization following the BADAH
811
+ manual.
732
812
 
733
813
  :param AC: Aircraft object {BADAH}.
734
814
  :type AC: badaHAircraft.
@@ -740,24 +820,29 @@ class Optimization(BADAH):
740
820
  self.flightEnvelope = FlightEnvelope(AC)
741
821
 
742
822
  def MRC(self, h, mass, DeltaTemp, wS):
743
- """
744
- Computes the True Airspeed (TAS) representing Maximum Range Cruise (MRC) for given flight conditions.
823
+ """Computes the True Airspeed (TAS) representing Maximum Range Cruise
824
+ (MRC) for given flight conditions.
745
825
 
746
- The Maximum Range Cruise speed is the speed that maximizes the aircraft's range per unit of fuel,
747
- which is determined by balancing the fuel flow rate and airspeed. The algorithm ensures that the
748
- computed TAS stays within the power available limitations of the aircraft.
826
+ The Maximum Range Cruise speed is the speed that maximizes the
827
+ aircraft's range per unit of fuel, which is determined by balancing
828
+ the fuel flow rate and airspeed. The algorithm ensures that the
829
+ computed TAS stays within the power available limitations of the
830
+ aircraft.
749
831
 
750
832
  :param h: Altitude in meters [m].
751
833
  :param mass: Aircraft mass in kilograms [kg].
752
- :param DeltaTemp: Deviation from International Standard Atmosphere (ISA) temperature in Kelvin [K].
834
+ :param DeltaTemp: Deviation from International Standard Atmosphere
835
+ (ISA) temperature in Kelvin [K].
753
836
  :param wS: Longitudinal wind speed (TAS) in meters per second [m/s].
754
837
  :type h: float
755
838
  :type mass: float
756
839
  :type DeltaTemp: float
757
840
  :type wS: float
758
- :return: Maximum Range Cruise (MRC) speed in True Airspeed (TAS) [m/s].
841
+ :return: Maximum Range Cruise (MRC) speed in True Airspeed (TAS)
842
+ [m/s].
759
843
  :rtype: float.
760
- :raises ValueError: If no valid MRC speed is found, the function will return NaN.
844
+ :raises ValueError: If no valid MRC speed is found, the function will
845
+ return NaN.
761
846
  """
762
847
 
763
848
  # NOTE: check for precision of algorithm needed. Possible local minima, instead of global minima
@@ -819,16 +904,19 @@ class Optimization(BADAH):
819
904
  return mrc
820
905
 
821
906
  def LRC(self, h, mass, DeltaTemp, wS):
822
- """
823
- Computes the True Airspeed (TAS) representing Long Range Cruise (LRC) for the given flight conditions.
907
+ """Computes the True Airspeed (TAS) representing Long Range Cruise
908
+ (LRC) for the given flight conditions.
824
909
 
825
- The Long Range Cruise speed is the speed that allows for 99% of the specific range (range per unit of fuel)
826
- of the Maximum Range Cruise (MRC) speed while offering a higher cruise speed. This function ensures that the
827
- computed TAS remains within the aircraft's power limitations.
910
+ The Long Range Cruise speed is the speed that allows for 99% of the
911
+ specific range (range per unit of fuel) of the Maximum Range Cruise
912
+ (MRC) speed while offering a higher cruise speed. This function
913
+ ensures that the computed TAS remains within the aircraft's power
914
+ limitations.
828
915
 
829
916
  :param h: Altitude in meters [m].
830
917
  :param mass: Aircraft mass in kilograms [kg].
831
- :param DeltaTemp: Deviation from International Standard Atmosphere (ISA) temperature in Kelvin [K].
918
+ :param DeltaTemp: Deviation from International Standard Atmosphere
919
+ (ISA) temperature in Kelvin [K].
832
920
  :param wS: Longitudinal wind speed (TAS) in meters per second [m/s].
833
921
  :type h: float
834
922
  :type mass: float
@@ -836,11 +924,11 @@ class Optimization(BADAH):
836
924
  :type wS: float
837
925
  :return: Long Range Cruise (LRC) speed in True Airspeed (TAS) [m/s].
838
926
  :rtype: float.
839
- :raises ValueError: If no valid LRC speed is found, the function will return NaN.
840
-
841
- The algorithm starts by computing the MRC speed. Using the MRC as a reference, it then calculates the
842
- LRC by finding the TAS that achieves 99% of the specific range of the MRC while staying within
843
- the aircraft’s thrust limitations.
927
+ :raises ValueError: If no valid LRC speed is found, the function will
928
+ return NaN. The algorithm starts by computing the MRC speed. Using
929
+ the MRC as a reference, it then calculates the LRC by finding the
930
+ TAS that achieves 99% of the specific range of the MRC while
931
+ staying within the aircraft’s thrust limitations.
844
932
  """
845
933
 
846
934
  # NOTE: check for precision of algorithm needed. Possible local minima, instead of global minima
@@ -914,27 +1002,30 @@ class Optimization(BADAH):
914
1002
  return lrc
915
1003
 
916
1004
  def MEC(self, h, mass, DeltaTemp, wS):
917
- """
918
- Computes the True Airspeed (TAS) representing Maximum Endurance Cruise (MEC) for the given flight conditions.
1005
+ """Computes the True Airspeed (TAS) representing Maximum Endurance
1006
+ Cruise (MEC) for the given flight conditions.
919
1007
 
920
- The Maximum Endurance Cruise speed is the speed that maximizes the time an aircraft can stay in the air
921
- for a given amount of fuel, making it ideal for loiter operations. This function minimizes fuel flow (ff)
922
- to determine the most fuel-efficient speed.
1008
+ The Maximum Endurance Cruise speed is the speed that maximizes the
1009
+ time an aircraft can stay in the air for a given amount of fuel,
1010
+ making it ideal for loiter operations. This function minimizes fuel
1011
+ flow (ff) to determine the most fuel-efficient speed.
923
1012
 
924
1013
  :param h: Altitude in meters [m].
925
1014
  :param mass: Aircraft weight in kilograms [kg].
926
- :param DeltaTemp: Deviation from the International Standard Atmosphere (ISA) temperature in Kelvin [K].
1015
+ :param DeltaTemp: Deviation from the International Standard Atmosphere
1016
+ (ISA) temperature in Kelvin [K].
927
1017
  :param wS: Longitudinal wind speed (TAS) in meters per second [m/s].
928
1018
  :type h: float
929
1019
  :type mass: float
930
1020
  :type DeltaTemp: float
931
1021
  :type wS: float
932
- :return: Maximum Endurance Cruise (MEC) speed in True Airspeed (TAS) [m/s].
1022
+ :return: Maximum Endurance Cruise (MEC) speed in True Airspeed (TAS)
1023
+ [m/s].
933
1024
  :rtype: float
934
- :raises: If no valid MEC speed is found, the function returns NaN.
935
-
936
- The algorithm iterates over possible True Airspeeds (TAS) and computes the fuel flow for each, aiming to
937
- minimize fuel consumption and return the TAS that achieves this.
1025
+ :raises: If no valid MEC speed is found, the function returns NaN. The
1026
+ algorithm iterates over possible True Airspeeds (TAS) and computes
1027
+ the fuel flow for each, aiming to minimize fuel consumption and
1028
+ return the TAS that achieves this.
938
1029
  """
939
1030
 
940
1031
  [theta, delta, sigma] = atm.atmosphereProperties(
@@ -980,17 +1071,18 @@ class Optimization(BADAH):
980
1071
  return mecTAS
981
1072
 
982
1073
  def parseOPT(self, filename):
983
- """
984
- Parses BADAH OPT ASCII formatted files and stores data for each available delta temperature in the file.
1074
+ """Parses BADAH OPT ASCII formatted files and stores data for each
1075
+ available delta temperature in the file.
985
1076
 
986
1077
  :param filename: Path to the ___.OPT ASCII formatted file.
987
1078
  :type filename: str
988
- :return: Dictionary of delta temperature values and corresponding data from the OPT file.
989
- :rtype: dict
990
-
991
- This function reads and processes a BADAH OPT file, extracting delta temperature values and the corresponding
992
- performance data. The data is stored in a dictionary where each delta temperature is mapped to its respective
993
- dataset of performance values.
1079
+ :return: Dictionary of delta temperature values and corresponding data
1080
+ from the OPT file.
1081
+ :rtype: dict This function reads and processes a BADAH OPT file,
1082
+ extracting delta temperature values and the corresponding
1083
+ performance data. The data is stored in a dictionary where each
1084
+ delta temperature is mapped to its respective dataset of
1085
+ performance values.
994
1086
  """
995
1087
 
996
1088
  file = open(filename, "r")
@@ -1049,21 +1141,21 @@ class Optimization(BADAH):
1049
1141
  return DeltaTempDict
1050
1142
 
1051
1143
  def findNearestIdx(self, value, array):
1052
- """
1053
- Finds the nearest index or indices for a given value in a sorted array.
1144
+ """Finds the nearest index or indices for a given value in a sorted
1145
+ array.
1054
1146
 
1055
- If the value is lower or higher than the array’s bounds, a single index is returned. If the value lies between
1056
- two elements, two closest indices (left and right) are returned.
1147
+ If the value is lower or higher than the array’s bounds, a single
1148
+ index is returned. If the value lies between two elements, two closest
1149
+ indices (left and right) are returned.
1057
1150
 
1058
1151
  :param value: The value to find the nearest match for.
1059
1152
  :param array: The sorted array of values.
1060
1153
  :type value: float
1061
1154
  :type array: list[float]
1062
1155
  :return: A list of nearest index or indices.
1063
- :rtype: list[float]
1064
-
1065
- The function uses binary search to efficiently find the nearest value or values, ensuring precise interpolation
1066
- when needed.
1156
+ :rtype: list[float] The function uses binary search to efficiently
1157
+ find the nearest value or values, ensuring precise interpolation
1158
+ when needed.
1067
1159
  """
1068
1160
 
1069
1161
  nearestIdx = list()
@@ -1082,23 +1174,24 @@ class Optimization(BADAH):
1082
1174
  return nearestIdx
1083
1175
 
1084
1176
  def calculateOPTparam(self, var_1, var_2, detaTauList):
1085
- """
1086
- Calculates the interpolated value of an OPT parameter based on two optimizing factors.
1177
+ """Calculates the interpolated value of an OPT parameter based on two
1178
+ optimizing factors.
1087
1179
 
1088
- If the exact values of the factors exist in the data, the function returns the corresponding OPT value.
1089
- Otherwise, it interpolates between the nearest two values to provide a more accurate result.
1180
+ If the exact values of the factors exist in the data, the function
1181
+ returns the corresponding OPT value. Otherwise, it interpolates
1182
+ between the nearest two values to provide a more accurate result.
1090
1183
 
1091
1184
  :param var_1: The first optimizing factor.
1092
1185
  :param var_2: The second optimizing factor.
1093
- :param detaTauList: List of values belonging to the specified delta temperature from the OPT file.
1186
+ :param detaTauList: List of values belonging to the specified delta
1187
+ temperature from the OPT file.
1094
1188
  :type var_1: float
1095
1189
  :type var_2: float
1096
1190
  :type detaTauList: list[float]
1097
1191
  :return: Interpolated or exact OPT value based on the input factors.
1098
- :rtype: float
1099
-
1100
- This function handles both single-index and two-index cases for the nearest values, ensuring correct interpolation
1101
- in the case of multiple values being found.
1192
+ :rtype: float This function handles both single-index and two- index
1193
+ cases for the nearest values, ensuring correct interpolation in
1194
+ the case of multiple values being found.
1102
1195
  """
1103
1196
 
1104
1197
  var_1_list = detaTauList[0]
@@ -1188,9 +1281,9 @@ class Optimization(BADAH):
1188
1281
  return interpVar_3
1189
1282
 
1190
1283
  def getOPTParam(self, optParam, var_1, var_2, DeltaTemp):
1191
- """
1192
- Retrieves the value of the specified optimization parameter (e.g., LRC, MEC, MRC) from the BADA OPT file,
1193
- either directly or through interpolation based on the given flight conditions.
1284
+ """Retrieves the value of the specified optimization parameter (e.g.,
1285
+ LRC, MEC, MRC) from the BADA OPT file, either directly or through
1286
+ interpolation based on the given flight conditions.
1194
1287
 
1195
1288
  The function searches for the requested optimization parameter value using two optimizing factors.
1196
1289
  If the exact DeltaTemp exists in the OPT file, it retrieves the value. Otherwise, the function interpolates
@@ -1261,8 +1354,8 @@ class Optimization(BADAH):
1261
1354
 
1262
1355
 
1263
1356
  class ARPM(BADAH):
1264
- """This class is a BADAH aircraft subclass and implements the Airline Procedure Model (ARPM)
1265
- following the BADAH user manual.
1357
+ """This class is a BADAH aircraft subclass and implements the Airline
1358
+ Procedure Model (ARPM) following the BADAH user manual.
1266
1359
 
1267
1360
  :param AC: Aircraft object {BADAH}.
1268
1361
  :type AC: badaHAircraft.
@@ -1283,8 +1376,8 @@ class ARPM(BADAH):
1283
1376
  speedLimit=None,
1284
1377
  ROCDDefault=None,
1285
1378
  ):
1286
- """
1287
- Computes various parameters for the aircraft takeoff phase using the ARPM model (or other specified engine ratings).
1379
+ """Computes various parameters for the aircraft takeoff phase using
1380
+ the ARPM model (or other specified engine ratings).
1288
1381
 
1289
1382
  This function calculates key takeoff parameters, including the available and required power, true airspeed, rate of climb (ROCD), and other
1290
1383
  performance metrics. It also checks for speed limitations based on the flight envelope and applies them as necessary.
@@ -1441,8 +1534,8 @@ class ARPM(BADAH):
1441
1534
  ROCDDefault=None,
1442
1535
  tasDefault=None,
1443
1536
  ):
1444
- """
1445
- Computes various parameters for the aircraft climb phase using the ARPM model or other engine ratings.
1537
+ """Computes various parameters for the aircraft climb phase using the
1538
+ ARPM model or other engine ratings.
1446
1539
 
1447
1540
  This function calculates key climb parameters, including available and required power, true airspeed (TAS),
1448
1541
  rate of climb (ROCD), and performance limitations. It takes into account speed envelope constraints
@@ -1603,8 +1696,8 @@ class ARPM(BADAH):
1603
1696
  pass
1604
1697
 
1605
1698
  def cruise(self, h, mass, DeltaTemp, speedLimit=None, tasDefault=None):
1606
- """
1607
- Computes various parameters for the aircraft cruise phase using the ARPM model or default speed.
1699
+ """Computes various parameters for the aircraft cruise phase using the
1700
+ ARPM model or default speed.
1608
1701
 
1609
1702
  This function calculates key cruise parameters, including available and required power, true airspeed (TAS),
1610
1703
  and potential limitations due to the flight envelope or engine power. The calculations take into account
@@ -1714,8 +1807,8 @@ class ARPM(BADAH):
1714
1807
  ROCDDefault=None,
1715
1808
  tasDefault=None,
1716
1809
  ):
1717
- """
1718
- Computes various parameters for the aircraft descent phase using the ARPM model or default speed.
1810
+ """Computes various parameters for the aircraft descent phase using
1811
+ the ARPM model or default speed.
1719
1812
 
1720
1813
  This function calculates key descent parameters, including available and required power, true airspeed (TAS),
1721
1814
  rate of descent (ROD), and potential performance limitations. The calculations take into account atmospheric
@@ -1844,8 +1937,8 @@ class ARPM(BADAH):
1844
1937
  ROCDDefault=None,
1845
1938
  tasDefault=None,
1846
1939
  ):
1847
- """
1848
- Computes various parameters for the aircraft approach phase using the ARPM model.
1940
+ """Computes various parameters for the aircraft approach phase using
1941
+ the ARPM model.
1849
1942
 
1850
1943
  This function calculates key approach parameters, including available and required power, true airspeed (TAS),
1851
1944
  rate of descent (ROCD), and potential performance limitations. The calculations take into account atmospheric
@@ -1968,8 +2061,8 @@ class ARPM(BADAH):
1968
2061
  ROCDDefault=None,
1969
2062
  tasDefault=None,
1970
2063
  ):
1971
- """
1972
- Computes various parameters for the final approach phase using the ARPM model.
2064
+ """Computes various parameters for the final approach phase using the
2065
+ ARPM model.
1973
2066
 
1974
2067
  This function calculates key final approach parameters, including available and required power, true airspeed (TAS),
1975
2068
  rate of descent (ROCD), and potential performance limitations. The calculations take into account atmospheric
@@ -2081,8 +2174,8 @@ class ARPM(BADAH):
2081
2174
  pass
2082
2175
 
2083
2176
  def landing(self, h, mass, DeltaTemp, ROCDDefault=None):
2084
- """
2085
- Computes various parameters for the landing phase using the ARPM model.
2177
+ """Computes various parameters for the landing phase using the ARPM
2178
+ model.
2086
2179
 
2087
2180
  This function calculates key landing parameters, including available and required power, true airspeed (TAS),
2088
2181
  rate of descent (ROCD), and potential performance limitations. The calculations take into account atmospheric
@@ -2154,8 +2247,8 @@ class ARPM(BADAH):
2154
2247
  return [Pav, Peng, Preq, tas, ROCD, ESF, limitation]
2155
2248
 
2156
2249
  def hover(self, h, mass, DeltaTemp):
2157
- """
2158
- Computes various parameters for the hover phase using the ARPM model.
2250
+ """Computes various parameters for the hover phase using the ARPM
2251
+ model.
2159
2252
 
2160
2253
  This function calculates key hover parameters, including available and required power, true airspeed (TAS),
2161
2254
  and any potential performance limitations. The calculations take into account atmospheric conditions, altitude,
@@ -2219,8 +2312,8 @@ class ARPM(BADAH):
2219
2312
  ROCDDefault=None,
2220
2313
  tasDefault=None,
2221
2314
  ):
2222
- """
2223
- Computes various parameters for different flight phases using the ARPM model.
2315
+ """Computes various parameters for different flight phases using the
2316
+ ARPM model.
2224
2317
 
2225
2318
  This function calculates the available power (Pav), engine power (Peng), required power (Preq),
2226
2319
  true airspeed (TAS), rate of climb or descent (ROCD), energy share factor (ESF), and any limitations
@@ -2348,7 +2441,8 @@ class ARPM(BADAH):
2348
2441
 
2349
2442
 
2350
2443
  class PTD(BADAH):
2351
- """This class implements the PTD file creator for BADAH aircraft following BADAH manual.
2444
+ """This class implements the PTD file creator for BADAH aircraft following
2445
+ BADAH manual.
2352
2446
 
2353
2447
  :param AC: Aircraft object {BADAH}.
2354
2448
  :type AC: badaHAircraft.
@@ -2361,9 +2455,8 @@ class PTD(BADAH):
2361
2455
  self.ARPM = ARPM(AC)
2362
2456
 
2363
2457
  def create(self, saveToPath, DeltaTemp):
2364
- """
2365
- Creates a BADAH PTD file based on aircraft performance data at different
2366
- mass levels, altitudes, and temperatures.
2458
+ """Creates a BADAH PTD file based on aircraft performance data at
2459
+ different mass levels, altitudes, and temperatures.
2367
2460
 
2368
2461
  This function calculates performance data for three different mass levels (low, medium, high), at various
2369
2462
  altitudes, and for different temperature deviations from the International Standard Atmosphere (ISA).
@@ -2467,14 +2560,15 @@ class PTD(BADAH):
2467
2560
  HOVERList,
2468
2561
  DeltaTemp,
2469
2562
  ):
2470
- """
2471
- Saves the computed performance data to a BADAH PTD file.
2563
+ """Saves the computed performance data to a BADAH PTD file.
2472
2564
 
2473
- This function saves the performance data generated during different flight phases (climb, cruise, descent,
2474
- hover) and for different engine ratings (ARPM, MTKF, MCNT) into a PTD file. The file is named based on
2565
+ This function saves the performance data generated during different
2566
+ flight phases (climb, cruise, descent, hover) and for different engine
2567
+ ratings (ARPM, MTKF, MCNT) into a PTD file. The file is named based on
2475
2568
  the aircraft name and ISA deviation.
2476
2569
 
2477
- :param saveToPath: Path to the directory where the PTD file should be saved.
2570
+ :param saveToPath: Path to the directory where the PTD file should be
2571
+ saved.
2478
2572
  :param CLList_ARPM: List of climb data for the BADA ARPM rating.
2479
2573
  :param CLList_MTKF: List of climb data for the BADA MTKF rating.
2480
2574
  :param CLList_MCNT: List of climb data for the BADA MCNT rating.
@@ -3126,13 +3220,14 @@ class PTD(BADAH):
3126
3220
  )
3127
3221
 
3128
3222
  def PTD_climb(self, mass, altitudeList, DeltaTemp, rating):
3129
- """
3130
- Calculates the BADAH PTD (Performance Table Data) for the climb phase.
3223
+ """Calculates the BADAH PTD (Performance Table Data) for the climb
3224
+ phase.
3131
3225
 
3132
- This function computes the aircraft's performance parameters during the climb phase for each
3133
- altitude level in the given altitude list. Parameters such as temperature, pressure, density,
3134
- true airspeed (TAS), and rate of climb/descent (ROCD) are calculated and returned in a list format
3135
- that can be used for generating PTD files.
3226
+ This function computes the aircraft's performance parameters during
3227
+ the climb phase for each altitude level in the given altitude list.
3228
+ Parameters such as temperature, pressure, density, true airspeed
3229
+ (TAS), and rate of climb/descent (ROCD) are calculated and returned in
3230
+ a list format that can be used for generating PTD files.
3136
3231
 
3137
3232
  :param mass: Aircraft mass [kg].
3138
3233
  :param altitudeList: List of altitude values [ft].
@@ -3239,13 +3334,14 @@ class PTD(BADAH):
3239
3334
  return CLList
3240
3335
 
3241
3336
  def PTD_descent(self, mass, altitudeList, DeltaTemp):
3242
- """
3243
- Calculates the BADAH PTD (Performance Table Data) for the descent phase.
3337
+ """Calculates the BADAH PTD (Performance Table Data) for the descent
3338
+ phase.
3244
3339
 
3245
- This function computes the aircraft's performance parameters during the descent phase for each
3246
- altitude level in the given altitude list. It calculates values such as temperature, pressure,
3247
- density, true airspeed (TAS), and rate of descent (ROD), and returns the data in a structured
3248
- list format for PTD file generation.
3340
+ This function computes the aircraft's performance parameters during
3341
+ the descent phase for each altitude level in the given altitude list.
3342
+ It calculates values such as temperature, pressure, density, true
3343
+ airspeed (TAS), and rate of descent (ROD), and returns the data in a
3344
+ structured list format for PTD file generation.
3249
3345
 
3250
3346
  :param mass: Aircraft mass [kg].
3251
3347
  :param altitudeList: List of altitude values [ft].
@@ -3343,13 +3439,14 @@ class PTD(BADAH):
3343
3439
  return DESList
3344
3440
 
3345
3441
  def PTD_cruise(self, mass, altitudeList, DeltaTemp):
3346
- """
3347
- Calculates the BADAH PTD (Performance Table Data) for the cruise phase.
3442
+ """Calculates the BADAH PTD (Performance Table Data) for the cruise
3443
+ phase.
3348
3444
 
3349
- This function computes the aircraft's performance parameters during the cruise phase for each
3350
- altitude level in the given altitude list. Key performance metrics like temperature, pressure,
3351
- density, TAS, and fuel consumption are calculated and stored in a structured list for PTD file
3352
- generation.
3445
+ This function computes the aircraft's performance parameters during
3446
+ the cruise phase for each altitude level in the given altitude list.
3447
+ Key performance metrics like temperature, pressure, density, TAS, and
3448
+ fuel consumption are calculated and stored in a structured list for
3449
+ PTD file generation.
3353
3450
 
3354
3451
  :param mass: Aircraft mass [kg].
3355
3452
  :param altitudeList: List of altitude values [ft].
@@ -3442,13 +3539,14 @@ class PTD(BADAH):
3442
3539
  return CRList
3443
3540
 
3444
3541
  def PTD_hover(self, mass, altitudeList, DeltaTemp):
3445
- """
3446
- Calculates the BADAH PTD (Performance Table Data) for the hover phase.
3542
+ """Calculates the BADAH PTD (Performance Table Data) for the hover
3543
+ phase.
3447
3544
 
3448
- This function computes the aircraft's performance parameters during the hover phase for each
3449
- altitude level in the given altitude list. It calculates values like temperature, pressure, density,
3450
- and fuel consumption during hover and returns the data in a structured list format for PTD
3451
- generation.
3545
+ This function computes the aircraft's performance parameters during
3546
+ the hover phase for each altitude level in the given altitude list. It
3547
+ calculates values like temperature, pressure, density, and fuel
3548
+ consumption during hover and returns the data in a structured list
3549
+ format for PTD generation.
3452
3550
 
3453
3551
  :param mass: Aircraft mass [kg].
3454
3552
  :param altitudeList: List of altitude values [ft].
@@ -3542,7 +3640,8 @@ class PTD(BADAH):
3542
3640
 
3543
3641
 
3544
3642
  class PTF(BADAH):
3545
- """This class implements the PTF file creator for BADAH aircraft following BADAH manual.
3643
+ """This class implements the PTF file creator for BADAH aircraft following
3644
+ BADAH manual.
3546
3645
 
3547
3646
  :param AC: Aircraft object {BADAH}.
3548
3647
  :type AC: badaHAircraft.
@@ -3555,10 +3654,10 @@ class PTF(BADAH):
3555
3654
  self.ARPM = ARPM(AC)
3556
3655
 
3557
3656
  def create(self, saveToPath, DeltaTemp):
3558
- """
3559
- Creates the BADAH PTF and saves it to the specified directory.
3657
+ """Creates the BADAH PTF and saves it to the specified directory.
3560
3658
 
3561
- :param saveToPath: Path to the directory where the PTF should be stored.
3659
+ :param saveToPath: Path to the directory where the PTF should be
3660
+ stored.
3562
3661
  :param DeltaTemp: Deviation from ISA temperature [K].
3563
3662
  :type saveToPath: str
3564
3663
  :type DeltaTemp: float
@@ -3612,10 +3711,10 @@ class PTF(BADAH):
3612
3711
  DeltaTemp,
3613
3712
  massList,
3614
3713
  ):
3615
- """
3616
- Saves the BADAH performance data to a PTF format.
3714
+ """Saves the BADAH performance data to a PTF format.
3617
3715
 
3618
- :param saveToPath: Path to the directory where the PTF should be stored.
3716
+ :param saveToPath: Path to the directory where the PTF should be
3717
+ stored.
3619
3718
  :param CLList: List of PTD data for CLIMB.
3620
3719
  :param CRList: List of PTD data for CRUISE.
3621
3720
  :param DESList: List of PTD data for DESCENT.
@@ -3629,10 +3728,9 @@ class PTF(BADAH):
3629
3728
  :type DeltaTemp: float
3630
3729
  :type massList: list(float)
3631
3730
  :returns: None
3632
- :rtype: None
3633
-
3634
- This function formats and writes the climb, cruise, and descent data for different mass levels
3635
- and altitudes into a .PTF file, adhering to the BADAH performance file format.
3731
+ :rtype: None This function formats and writes the climb, cruise, and
3732
+ descent data for different mass levels and altitudes into a .PTF
3733
+ file, adhering to the BADAH performance file format.
3636
3734
  """
3637
3735
 
3638
3736
  newpath = saveToPath
@@ -3726,8 +3824,7 @@ class PTF(BADAH):
3726
3824
  )
3727
3825
 
3728
3826
  def PTF_cruise(self, massList, altitudeList, DeltaTemp):
3729
- """
3730
- Calculates the BADAH PTF for the CRUISE phase of flight.
3827
+ """Calculates the BADAH PTF for the CRUISE phase of flight.
3731
3828
 
3732
3829
  :param massList: List of aircraft mass levels in kilograms [kg].
3733
3830
  :param altitudeList: List of aircraft altitudes in feet [ft].
@@ -3802,8 +3899,7 @@ class PTF(BADAH):
3802
3899
  return CRList
3803
3900
 
3804
3901
  def PTF_climb(self, massList, altitudeList, DeltaTemp, rating):
3805
- """
3806
- Calculates the BADAH PTF for the CLIMB phase of flight.
3902
+ """Calculates the BADAH PTF for the CLIMB phase of flight.
3807
3903
 
3808
3904
  :param massList: List of aircraft mass levels in kilograms [kg].
3809
3905
  :param altitudeList: List of aircraft altitudes in feet [ft].
@@ -3813,8 +3909,8 @@ class PTF(BADAH):
3813
3909
  :type altitudeList: list of int
3814
3910
  :type DeltaTemp: float
3815
3911
  :type rating: str
3816
- :returns: List of PTF CLIMB data, including True Airspeed, Rates of Climb,
3817
- and Fuel Flow for each mass level.
3912
+ :returns: List of PTF CLIMB data, including True Airspeed, Rates of
3913
+ Climb, and Fuel Flow for each mass level.
3818
3914
  :rtype: list
3819
3915
  """
3820
3916
 
@@ -3881,8 +3977,7 @@ class PTF(BADAH):
3881
3977
  return CLList
3882
3978
 
3883
3979
  def PTF_descent(self, massList, altitudeList, DeltaTemp):
3884
- """
3885
- Calculates the BADAH PTF for the DESCENT phase of flight.
3980
+ """Calculates the BADAH PTF for the DESCENT phase of flight.
3886
3981
 
3887
3982
  :param massList: List of aircraft mass levels in kilograms [kg].
3888
3983
  :param altitudeList: List of aircraft altitudes in feet [ft].
@@ -3951,26 +4046,27 @@ class PTF(BADAH):
3951
4046
 
3952
4047
 
3953
4048
  class BadaHAircraft(BADAH):
3954
- """
3955
- This class encapsulates the BADAH performance model for an aircraft, extending the BADAH base class.
4049
+ """This class encapsulates the BADAH performance model for an aircraft,
4050
+ extending the BADAH base class.
3956
4051
 
3957
4052
  :param badaVersion: The version of the BADAH model being used.
3958
4053
  :param acName: The ICAO designation or name of the aircraft.
3959
- :param filePath: (Optional) Path to the BADAH XML file. If not provided, a default path is used.
3960
- :param allData: (Optional) Dataframe containing pre-loaded aircraft data, typically used to
3961
- initialize the aircraft parameters without needing to parse XML files.
4054
+ :param filePath: (Optional) Path to the BADAH XML file. If not provided, a
4055
+ default path is used.
4056
+ :param allData: (Optional) Dataframe containing pre-loaded aircraft data,
4057
+ typically used to initialize the aircraft parameters without needing
4058
+ to parse XML files.
3962
4059
  :type badaVersion: str
3963
4060
  :type acName: str
3964
4061
  :type filePath: str, optional
3965
- :type allData: pd.DataFrame, optional
3966
-
3967
- This class initializes the aircraft's performance model using data from a dataframe or by
3968
- reading from XML files in the BADAH format.
4062
+ :type allData: pd.DataFrame, optional This class initializes the
4063
+ aircraft's performance model using data from a dataframe or by reading
4064
+ from XML files in the BADAH format.
3969
4065
  """
3970
4066
 
3971
4067
  def __init__(self, badaVersion, acName, filePath=None, allData=None):
3972
- """
3973
- Initializes the BADAHAircraft class by loading aircraft-specific data.
4068
+ """Initializes the BADAHAircraft class by loading aircraft-specific
4069
+ data.
3974
4070
 
3975
4071
  - If `allData` is provided and contains the aircraft's information, it will be used to
3976
4072
  initialize various parameters such as engine type, mass, thrust settings, and performance
@@ -3993,7 +4089,7 @@ class BadaHAircraft(BADAH):
3993
4089
  self.BADAVersion = badaVersion
3994
4090
  self.acName = acName
3995
4091
 
3996
- if filePath == None:
4092
+ if filePath is None:
3997
4093
  self.filePath = configuration.getBadaVersionPath(
3998
4094
  badaFamily="BADAH", badaVersion=badaVersion
3999
4095
  )
@@ -4056,7 +4152,7 @@ class BadaHAircraft(BADAH):
4056
4152
  )
4057
4153
 
4058
4154
  # if cannot find - look for full name (in sub folder names) based on acName (may not be ICAO designator)
4059
- if self.SearchedACName == None:
4155
+ if self.SearchedACName is None:
4060
4156
  self.SearchedACName = acName
4061
4157
  else:
4062
4158
  self.ACinSynonymFile = True
@@ -4136,7 +4232,9 @@ class BadaHAircraft(BADAH):
4136
4232
 
4137
4233
  else:
4138
4234
  # AC name cannot be found
4139
- raise ValueError(acName + " Cannot be found")
4235
+ raise ValueError(
4236
+ acName + " Cannot be found at: " + self.filePath
4237
+ )
4140
4238
 
4141
4239
  def __str__(self):
4142
4240
  return f"(BADAH, AC_name: {self.acName}, searched_AC_name: {self.SearchedACName}, model_ICAO: {self.ICAO}, ID: {id(self.AC)})"