pyBADA 0.1.5__py3-none-any.whl → 0.1.6__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/bada3.py CHANGED
@@ -1,32 +1,19 @@
1
1
  """Generic BADA3 aircraft performance module."""
2
2
 
3
- from math import sqrt, isnan, asin, atan
4
- import numpy as np
5
-
6
3
  import os
7
- from datetime import date
8
4
  import xml.etree.ElementTree as ET
5
+ from datetime import date
6
+ from math import asin, atan, isnan, sqrt
7
+
8
+ import numpy as np
9
9
  import pandas as pd
10
10
 
11
- from pyBADA import constants as const
12
- from pyBADA import conversions as conv
11
+ from pyBADA import utils
13
12
  from pyBADA import atmosphere as atm
14
13
  from pyBADA import configuration as configuration
15
- from pyBADA.aircraft import Airplane, BadaFamily, Bada
16
-
17
-
18
- def proper_round(num, dec=0):
19
- num = str(num)[: str(num).index(".") + dec + 2]
20
- if num[-1] >= "5":
21
- return float(num[: -2 - (not dec)] + str(int(num[-2 - (not dec)]) + 1))
22
- return float(num[:-1])
23
-
24
-
25
- def checkArgument(argument, **kwargs):
26
- if kwargs.get(argument) is not None:
27
- return kwargs.get(argument)
28
- else:
29
- raise TypeError("Missing " + argument + " argument")
14
+ from pyBADA import constants as const
15
+ from pyBADA import conversions as conv
16
+ from pyBADA.aircraft import Airplane, Bada, BadaFamily
30
17
 
31
18
 
32
19
  class Parser:
@@ -1758,11 +1745,11 @@ class BADA3(Airplane, Bada):
1758
1745
 
1759
1746
  elif rating == "ADAPTED":
1760
1747
  # ADAPTED
1761
- ROCD = checkArgument("ROCD", **kwargs)
1762
- mass = checkArgument("mass", **kwargs)
1763
- v = checkArgument("v", **kwargs)
1764
- acc = checkArgument("acc", **kwargs)
1765
- Drag = checkArgument("Drag", **kwargs)
1748
+ ROCD = utils.checkArgument("ROCD", **kwargs)
1749
+ mass = utils.checkArgument("mass", **kwargs)
1750
+ v = utils.checkArgument("v", **kwargs)
1751
+ acc = utils.checkArgument("acc", **kwargs)
1752
+ Drag = utils.checkArgument("Drag", **kwargs)
1766
1753
  T = self.TAdapted(
1767
1754
  h=h,
1768
1755
  DeltaTemp=DeltaTemp,
@@ -3895,22 +3882,22 @@ class PTD(BADA3):
3895
3882
  * 60
3896
3883
  )
3897
3884
 
3898
- FL_complet.append(proper_round(FL))
3899
- T_complet.append(theta * const.temp_0)
3900
- p_complet.append(delta * const.p_0)
3901
- rho_complet.append(sigma * const.rho_0)
3902
- a_complet.append(a)
3903
- TAS_complet.append(conv.ms2kt(tas))
3904
- CAS_complet.append(conv.ms2kt(cas))
3905
- M_complet.append(M)
3906
- mass_complet.append(mass)
3907
- Thrust_complet.append(Thrust)
3908
- Drag_complet.append(Drag)
3909
- ff_comlet.append(ff)
3910
- ESF_complet.append(ESF)
3911
- ROCD_complet.append(ROCD)
3912
- TDC_complet.append(TDC)
3913
- PWC_complet.append(CPowRed)
3885
+ FL_complet.append(utils.proper_round(FL))
3886
+ T_complet.append(utils.proper_round(theta * const.temp_0))
3887
+ p_complet.append(utils.proper_round(delta * const.p_0))
3888
+ rho_complet.append(utils.proper_round(sigma * const.rho_0,3))
3889
+ a_complet.append(utils.proper_round(a))
3890
+ TAS_complet.append(utils.proper_round(conv.ms2kt(tas),2))
3891
+ CAS_complet.append(utils.proper_round(conv.ms2kt(cas),2))
3892
+ M_complet.append(utils.proper_round(M,2))
3893
+ mass_complet.append(utils.proper_round(mass))
3894
+ Thrust_complet.append(utils.proper_round(Thrust))
3895
+ Drag_complet.append(utils.proper_round(Drag))
3896
+ ff_comlet.append(utils.proper_round(ff,1))
3897
+ ESF_complet.append(utils.proper_round(ESF,2))
3898
+ ROCD_complet.append(utils.proper_round(ROCD))
3899
+ TDC_complet.append(utils.proper_round(TDC))
3900
+ PWC_complet.append(utils.proper_round(CPowRed,2))
3914
3901
 
3915
3902
  CLList = [
3916
3903
  FL_complet,
@@ -4082,22 +4069,22 @@ class PTD(BADA3):
4082
4069
  else:
4083
4070
  gamma = conv.rad2deg(asin(dhdt / tas))
4084
4071
 
4085
- FL_complet.append(proper_round(FL))
4086
- T_complet.append(theta * const.temp_0)
4087
- p_complet.append(delta * const.p_0)
4088
- rho_complet.append(sigma * const.rho_0)
4089
- a_complet.append(a)
4090
- TAS_complet.append(conv.ms2kt(tas))
4091
- CAS_complet.append(conv.ms2kt(cas))
4092
- M_complet.append(M)
4093
- mass_complet.append(mass)
4094
- Thrust_complet.append(Thrust)
4095
- Drag_complet.append(Drag)
4096
- ff_comlet.append(ff)
4097
- ESF_complet.append(ESF)
4098
- ROCD_complet.append(-1 * ROCD)
4099
- TDC_complet.append(TDC)
4100
- gamma_complet.append(gamma)
4072
+ FL_complet.append(utils.proper_round(FL))
4073
+ T_complet.append(utils.proper_round(theta * const.temp_0))
4074
+ p_complet.append(utils.proper_round(delta * const.p_0))
4075
+ rho_complet.append(utils.proper_round(sigma * const.rho_0,3))
4076
+ a_complet.append(utils.proper_round(a))
4077
+ TAS_complet.append(utils.proper_round(conv.ms2kt(tas),2))
4078
+ CAS_complet.append(utils.proper_round(conv.ms2kt(cas),2))
4079
+ M_complet.append(utils.proper_round(M,2))
4080
+ mass_complet.append(utils.proper_round(mass))
4081
+ Thrust_complet.append(utils.proper_round(Thrust))
4082
+ Drag_complet.append(utils.proper_round(Drag))
4083
+ ff_comlet.append(utils.proper_round(ff,1))
4084
+ ESF_complet.append(utils.proper_round(ESF,2))
4085
+ ROCD_complet.append(utils.proper_round(-1 * ROCD))
4086
+ TDC_complet.append(utils.proper_round(TDC))
4087
+ gamma_complet.append(utils.proper_round(gamma,2))
4101
4088
 
4102
4089
  DESList = [
4103
4090
  FL_complet,
@@ -4320,7 +4307,7 @@ class PTF(BADA3):
4320
4307
  DESList = Nan2Zero(DESList)
4321
4308
 
4322
4309
  for k in range(0, len(altitudeList)):
4323
- FL = proper_round(altitudeList[k] / 100)
4310
+ FL = utils.proper_round(altitudeList[k] / 100)
4324
4311
  if FL < 30:
4325
4312
  file.write(
4326
4313
  "%3.0f | | %3.0f %5.0f %5.0f %5.0f %5.1f | %3.0f %5.0f %5.1f \n"
@@ -4428,10 +4415,10 @@ class PTF(BADA3):
4428
4415
  self.ff(flightPhase="Cruise", v=tas, h=H_m, T=Thrust) * 60
4429
4416
  )
4430
4417
 
4431
- TAS_CR_complet.append(conv.ms2kt(tas_nominal))
4432
- FF_CR_LO_complet.append(ff[0])
4433
- FF_CR_NOM_complet.append(ff[1])
4434
- FF_CR_HI_complet.append(ff[2])
4418
+ TAS_CR_complet.append(utils.proper_round(conv.ms2kt(tas_nominal)))
4419
+ FF_CR_LO_complet.append(utils.proper_round(ff[0],1))
4420
+ FF_CR_NOM_complet.append(utils.proper_round(ff[1],1))
4421
+ FF_CR_HI_complet.append(utils.proper_round(ff[2],1))
4435
4422
 
4436
4423
  CRList = [
4437
4424
  TAS_CR_complet,
@@ -4552,11 +4539,11 @@ class PTF(BADA3):
4552
4539
  tas_list.append(tas)
4553
4540
  ff_list.append(ff)
4554
4541
 
4555
- TAS_CL_complet.append(conv.ms2kt(tas_list[1]))
4556
- ROCD_CL_LO_complet.append(ROC[0])
4557
- ROCD_CL_NOM_complet.append(ROC[1])
4558
- ROCD_CL_HI_complet.append(ROC[2])
4559
- FF_CL_NOM_complet.append(ff_list[1])
4542
+ TAS_CL_complet.append(utils.proper_round(conv.ms2kt(tas_list[1])))
4543
+ ROCD_CL_LO_complet.append(utils.proper_round(ROC[0]))
4544
+ ROCD_CL_NOM_complet.append(utils.proper_round(ROC[1]))
4545
+ ROCD_CL_HI_complet.append(utils.proper_round(ROC[2]))
4546
+ FF_CL_NOM_complet.append(utils.proper_round(ff_list[1],1))
4560
4547
 
4561
4548
  CLList = [
4562
4549
  TAS_CL_complet,
@@ -4693,9 +4680,9 @@ class PTF(BADA3):
4693
4680
  * 60
4694
4681
  )
4695
4682
 
4696
- TAS_DES_complet.append(conv.ms2kt(tas_nominal))
4697
- ROCD_DES_NOM_complet.append(ROCD)
4698
- FF_DES_NOM_complet.append(ff_nominal)
4683
+ TAS_DES_complet.append(utils.proper_round(conv.ms2kt(tas_nominal)))
4684
+ ROCD_DES_NOM_complet.append(utils.proper_round(ROCD))
4685
+ FF_DES_NOM_complet.append(utils.proper_round(ff_nominal,1))
4699
4686
 
4700
4687
  DESList = [TAS_DES_complet, ROCD_DES_NOM_complet, FF_DES_NOM_complet]
4701
4688