diff --git a/openap/gen.py b/openap/gen.py index a000b7c..8b20743 100644 --- a/openap/gen.py +++ b/openap/gen.py @@ -80,6 +80,8 @@ def climb(self, **kwargs) -> pd.DataFrame: cas_const_cl: Constant CAS for climb (kt). mach_const_cl: Constant Mach for climb. alt_cr: Target cruise altitude (ft). + airport_elevation: Airport elevation (ft). + random: Generate trajectory with random parameters. Defaults to False. Returns: @@ -119,6 +121,11 @@ def climb(self, **kwargs) -> pd.DataFrame: / aero.ft, ) + airport_elevation = kwargs.get( + "airport_elevation", + 0 + ) + vs_pre_constcas = self.rng.uniform( self.wrap.climb_vs_pre_concas()["minimum"], self.wrap.climb_vs_pre_concas()["maximum"], @@ -147,6 +154,11 @@ def climb(self, **kwargs) -> pd.DataFrame: alt_cr = kwargs.get( "alt_cr", self.wrap.cruise_alt()["default"] * 1000 / aero.ft ) + + airport_elevation = kwargs.get( + "airport_elevation", + 0 + ) * aero.ft vs_pre_constcas = self.wrap.climb_vs_pre_concas()["default"] vs_constcas = self.wrap.climb_vs_concas()["default"] vs_constmach = self.wrap.climb_vs_conmach()["default"] @@ -164,7 +176,7 @@ def climb(self, **kwargs) -> pd.DataFrame: # intitial conditions t = 0 tcr = 0 - h = 0 + h = airport_elevation s = 0 v = 0 vs = 0 @@ -181,7 +193,7 @@ def climb(self, **kwargs) -> pd.DataFrame: v = v + a_tof * dt vs = 0 seg = "TO" - elif h < 1500 * aero.ft: + elif h < airport_elevation + 1500 * aero.ft: v = v + a * dt if aero.tas2cas(v, h) >= vcas_const: v = aero.cas2tas(vcas_const, h) @@ -237,11 +249,13 @@ def climb(self, **kwargs) -> pd.DataFrame: def descent(self, **kwargs) -> pd.DataFrame: """Generate descent trajectory based on WRAP model. + Keyword Args: dt: Time step in seconds. Defaults to 1. cas_const_de: Constant CAS for descent (kt). mach_const_de: Constant Mach for descent. alt_cr: Top of descent altitude (ft). + arr_airport_elevation (float): airport elevation(ft). random: Generate trajectory with random parameters. Defaults to False. withcr: Include a short cruise segment of 60 seconds. Defaults to True. @@ -284,6 +298,11 @@ def descent(self, **kwargs) -> pd.DataFrame: / aero.kts, ) + arr_airport_elevation = kwargs.get( + "arr_airport_elevation", + 0 + ) * aero.ft + vs_constmach = self.rng.uniform( self.wrap.descent_vs_conmach()["minimum"], self.wrap.descent_vs_conmach()["maximum"], @@ -309,6 +328,12 @@ def descent(self, **kwargs) -> pd.DataFrame: alt_cr = kwargs.get( "alt_cr", self.wrap.cruise_alt()["default"] * 1000 / aero.ft ) + + arr_airport_elevation = kwargs.get( + "arr_airport_elevation", + 0 + ) * aero.ft + vs_constmach = self.wrap.descent_vs_conmach()["default"] vs_constcas = self.wrap.descent_vs_concas()["default"] vs_post_constcas = self.wrap.descent_vs_post_concas()["default"] @@ -350,18 +375,18 @@ def descent(self, **kwargs) -> pd.DataFrame: v = aero.cas2tas(vcas_const, h) vs = vs_constcas seg = "CAS" - elif h > 1000 * aero.ft: + elif h > arr_airport_elevation + 1000 * aero.ft: v = v + a * dt if aero.tas2cas(v, h) < v_app: v = aero.cas2tas(v_app, h) vs = vs_post_constcas seg = "POST-CAS" - elif h > 0: + elif h > arr_airport_elevation: v = v_app vs = vs_fa seg = "FA" else: - h = 0 + h = arr_airport_elevation vs = 0 v = v + a_lnd * dt seg = "LD" @@ -492,7 +517,7 @@ def cruise(self, **kwargs) -> pd.DataFrame: def complete(self, **kwargs) -> pd.DataFrame: """Generate a complete trajectory based on WRAP model. - + Keyword Args: dt: Time step in seconds. Defaults to 1. cas_const_cl: Constant CAS for climb (kt). @@ -502,6 +527,8 @@ def complete(self, **kwargs) -> pd.DataFrame: range_cr: Cruise range (km). alt_cr: Target cruise altitude (ft). mach_cr: Cruise Mach number. + airport_elevation (float): Airport elevation (ft). + arr_airport_elevation(float): Arrival airport elevation(ft). random: Generate trajectory with random parameters. Defaults to False. Returns: