def derive(self, takeoffs=S('Takeoff'), climb_starts=KTI('Climb Start'), tocs=KTI('Top Of Climb'), alt=P('Altitude STD'), ac_type=A('Aircraft Type')): pass
def derive(self, liftoff=KTI('Liftoff'), rto=S('Rejected Takeoff'), off_blocks=KTI('Off Blocks'), start_dt=A('Start Datetime')): if liftoff: # Flight - use first liftoff index first_liftoff = liftoff.get_first() liftoff_index = first_liftoff.index frequency = liftoff.frequency elif rto: # RTO - use start index of first RTO first_rto = rto.get_first() liftoff_index = first_rto.slice.start frequency = rto.frequency elif off_blocks: # Ground Only - use first off blocks index first_off_blocks = off_blocks.get_first() liftoff_index = first_off_blocks.index frequency = off_blocks.frequency else: # Incomplete - use start of data liftoff_index = 0 frequency = 1 takeoff_dt = datetime_of_index(start_dt.value, liftoff_index, frequency=frequency) self.set_flight_attr(takeoff_dt)
def derive(self, toffs=KTI('Takeoff Acceleration Start'), lifts=KTI('Liftoff'), eng_np=P('Eng (*) Np Avg'), duration=A('HDF Duration'), eng_type=A('Engine Propulsion'), ac_type=A('Aircraft Type')): pass
def derive(self, afr_type=A('AFR Type'), fast=S('Fast'), liftoffs=KTI('Liftoff'), touchdowns=KTI('Touchdown'), touch_and_gos=S('Touch And Go'), groundspeed=P('Groundspeed')): ''' TODO: Detect MID_FLIGHT. ''' afr_type = afr_type.value if afr_type else None if liftoffs and not touchdowns: # In the air without having touched down. self.warning("'Liftoff' KTI exists without 'Touchdown'.") raise InvalidFlightType('LIFTOFF_ONLY') #self.set_flight_attr('LIFTOFF_ONLY') #return elif not liftoffs and touchdowns: # In the air without having lifted off. self.warning("'Touchdown' KTI exists without 'Liftoff'.") raise InvalidFlightType('TOUCHDOWN_ONLY') #self.set_flight_attr('TOUCHDOWN_ONLY') #return if liftoffs and touchdowns: first_touchdown = touchdowns.get_first() first_liftoff = liftoffs.get_first() if first_touchdown.index < first_liftoff.index: # Touchdown before having lifted off, data must be INCOMPLETE. self.warning("'Touchdown' KTI index before 'Liftoff'.") raise InvalidFlightType('TOUCHDOWN_BEFORE_LIFTOFF') #self.set_flight_attr('TOUCHDOWN_BEFORE_LIFTOFF') #return last_touchdown = touchdowns.get_last() # TODO: Delete line. if touch_and_gos: last_touchdown = touchdowns.get_last() last_touch_and_go = touch_and_gos.get_last() if last_touchdown.index <= last_touch_and_go.index: self.warning("A 'Touch And Go' KTI exists after the last " "'Touchdown'.") raise InvalidFlightType('LIFTOFF_ONLY') #self.set_flight_attr('LIFTOFF_ONLY') #return if afr_type in [FlightType.Type.FERRY, FlightType.Type.LINE_TRAINING, FlightType.Type.POSITIONING, FlightType.Type.TEST, FlightType.Type.TRAINING]: flight_type = afr_type else: flight_type = FlightType.Type.COMPLETE elif fast: flight_type = FlightType.Type.REJECTED_TAKEOFF elif groundspeed and groundspeed.array.ptp() > 10: # The aircraft moved on the ground. flight_type = FlightType.Type.GROUND_RUN else: flight_type = FlightType.Type.ENGINE_RUN_UP self.set_flight_attr(flight_type)
def derive(self, afr_type=A('AFR Type'), fast=S('Fast'), mobile=S('Mobile'), liftoffs=KTI('Liftoff'), touchdowns=KTI('Touchdown'), touch_and_gos=S('Touch And Go'), rejected_to=S('Rejected Takeoff'), eng_start=KTI('Eng Start'), seg_type=A('Segment Type')): pass
def setUp(self): self.node_class = TakeoffDatetime self.takeoff_datetime = self.node_class() self.takeoff_datetime.set_flight_attr = Mock() self.start_dt = A('Start Datetime', value=datetime(1970, 1, 1)) self.liftoff = KTI(name='Liftoff', frequency=2, items=[ KeyTimeInstance(index=64), ]) self.rto = buildsection('Rejected Takeoff', 15, 20) self.off_blocks = KTI(name='Off Blocks', frequency=0.25, items=[ KeyTimeInstance(index=3), ])
def derive(self, alt_aal=P('Altitude AAL For Flight Phases'), initial_climbs=S('Initial Climb'), alt_climbing=KTI('Altitude When Climbing'), spd_sel=P('Airspeed Selected'), spd_sel_fmc=P('Airspeed Selected (FMC)'), eng_type=A('Engine Propulsion'), eng_np=P('Eng (*) Np Max'), throttle=P('Throttle Levers'), spd=P('Airspeed'), flap=KTI('Flap Lever Set')): pass
def derive(self, ra=M('TCAS RA'), off=KTI('Liftoff'), td=KTI('Touchdown') ): ras_local = ra.array ras_slices = library.runs_of_ones(ras_local) # put together runs separated by short drop-outs ras_slicesb = library.slices_remove_small_gaps(ras_slices, time_limit=2, hz=1) for ra_slice in ras_slicesb: is_post_liftoff = (ra_slice.start - off.get_first().index) > 10 is_pre_touchdown = (td.get_first().index - ra_slice.start ) > 10 duration = ra_slice.stop-ra_slice.start if is_post_liftoff and is_pre_touchdown and 3.0 <= duration < 300.0: #ignore if too short to do anything #print ' ra section', ra_slice self.create_phase( ra_slice ) return
def test_derive(self): landing_datetime = LandingDatetime() landing_datetime.set_flight_attr = Mock() start_datetime = A('Start Datetime', datetime(1970, 1, 1)) touchdown = KTI('Touchdown', items=[KeyTimeInstance(12, 'a'), KeyTimeInstance(30, 'b')]) touchdown.frequency = 0.5 landing_datetime.derive(start_datetime, touchdown) expected_datetime = datetime(1970, 1, 1, 0, 1) landing_datetime.set_flight_attr.assert_called_once_with( expected_datetime) touchdown = KTI('Touchdown') landing_datetime.set_flight_attr = Mock() landing_datetime.derive(start_datetime, touchdown) landing_datetime.set_flight_attr.assert_called_once_with(None)
def derive(self, alt_aal=P('Altitude AAL'), alt_agl=P('Altitude AGL'), ac_type=A('Aircraft Type'), app=S('Approach And Landing'), hdg=P('Heading Continuous'), lat=P('Latitude Prepared'), lon=P('Longitude Prepared'), ils_loc=P('ILS Localizer'), ils_gs=S('ILS Glideslope'), ils_freq=P('ILS Frequency'), land_afr_apt=A('AFR Landing Airport'), land_afr_rwy=A('AFR Landing Runway'), lat_land=KPV('Latitude At Touchdown'), lon_land=KPV('Longitude At Touchdown'), precision=A('Precise Positioning'), fast=S('Fast'), u=P('Airspeed'), gspd=P('Groundspeed'), height_from_rig=P('Altitude ADH'), hdot=P('Vertical Speed'), roll=P('Roll'), heading=P('Heading'), distance_land=P('Distance To Landing'), tdwns=KTI('Touchdown'), offshore=M('Offshore'), takeoff=S('Takeoff')): pass
def derive(self, pilot_flying=M('Pilot Flying'), pitch_capt=P('Pitch (Capt)'), pitch_fo=P('Pitch (FO)'), roll_capt=P('Roll (Capt)'), roll_fo=P('Roll (FO)'), cc_capt=P('Control Column Force (Capt)'), cc_fo=P('Control Column Force (FO)'), ap1_eng=M('AP (1) Engaged'), ap2_eng=M('AP (2) Engaged'), landings=S('Landing'), touchdowns=KTI('Touchdown'), afr_landing_pilot=A('AFR Landing Pilot')): if afr_landing_pilot and afr_landing_pilot.value: self.set_flight_attr(afr_landing_pilot.value.replace('_', ' ').title()) return phase = landings.get_last() if landings else None tdwn = touchdowns.get_last() if touchdowns else None if tdwn and ap1_eng and ap2_eng: # check AP state at the floored index (just before tdwn) ap1 = ap1_eng.array[int(tdwn.index)] == 'Engaged' ap2 = ap2_eng.array[int(tdwn.index)] == 'Engaged' else: ap1 = ap2 = None args = (pilot_flying, pitch_capt, pitch_fo, roll_capt, roll_fo, cc_capt, cc_fo, phase, ap1, ap2) self.set_flight_attr(self._determine_pilot(*args))
def test_derive(self): expected = KTI(items=[ KeyTimeInstance(index=16., name='TCAS RA Start'), ]) node = TCASRAStart() node.derive(tcas_ra_sections) self.assertEqual(expected, node)
def derive(self, pilot_flying=M('Pilot Flying'), pitch_capt=P('Pitch (Capt)'), pitch_fo=P('Pitch (FO)'), roll_capt=P('Roll (Capt)'), roll_fo=P('Roll (FO)'), cc_capt=P('Control Column Force (Capt)'), cc_fo=P('Control Column Force (FO)'), ap1_eng=M('AP (1) Engaged'), ap2_eng=M('AP (2) Engaged'), takeoffs=S('Takeoff'), liftoffs=KTI('Liftoff'), rejected_toffs=S('Rejected Takeoff')): #TODO: Tidy phase = takeoffs or rejected_toffs or None if phase is None: # Nothing to do as no attempt to takeoff return lift = liftoffs.get_first() if liftoffs else None if lift and ap1_eng and ap2_eng: # check AP state at the floored index (just before lift) ap1 = ap1_eng.array[lift.index] == 'Engaged' ap2 = ap2_eng.array[lift.index] == 'Engaged' else: ap1 = ap2 = None args = (pilot_flying, pitch_capt, pitch_fo, roll_capt, roll_fo, cc_capt, cc_fo, phase.get_first(), ap1, ap2) self.set_flight_attr(self._determine_pilot(*args))
def test_derive(self): '''[[[State]]] 0 = SL = 0 (Automatic) 1 = SL = 1 (Standby) 2 = SL = 2 (TA Only) 3 = SL = 3 ... ''' values_mapping = { 0: '0', 1: '1', } tcas_sens = M('TCAS Sensitivity Level', array=np.ma.array([0, 0, 1, 0, 0]), values_mapping=values_mapping, frequency=.25, offset=0.) start = KTI(items=[ KeyTimeInstance(index=2, name='TCAS RA Start'), ]) node = tcas.TCASSensitivityAtTCASRAStart() node.derive(tcas_sens, start) expected = [ KeyPointValue(index=2, value=1, name='TCAS RA Start Pilot Sensitivity Mode'), ] self.assertEqual(expected, node)
def derive(self, offshores=M('Offshore'), liftoffs=KTI('Liftoff'), hovers=S('Hover'), nose_downs=S('Nose Down Attitude Adoption'), rad_alt=P('Altitude Radio'), alt_aal=P('Altitude AAL For Flight Phases')): pass
def derive(self, liftoff=KTI('Liftoff'), start_dt=A('Start Datetime')): first_liftoff = liftoff.get_first() if not first_liftoff: self.set_flight_attr(None) return liftoff_index = first_liftoff.index takeoff_dt = datetime_of_index(start_dt.value, liftoff_index, frequency=liftoff.frequency) self.set_flight_attr(takeoff_dt)
def derive(self, ap_offs=KTI('AP Disengaged Selection'), ras=S('TCAS RA Sections') ): for ra_section in ras: ra = ra_section.slice ap_off = ap_offs.get_next(ra.start, within_slice=ra) if not ap_off: continue index = ap_off.index duration = (index - ra.start) / self.frequency self.create_kpv(index, duration)
def derive(self, on_blocks=KTI('On Blocks'), start_datetime=A('Start Datetime')): last_on_blocks = on_blocks.get_last() if last_on_blocks: on_blocks_datetime = datetime_of_index(start_datetime.value, last_on_blocks.index) self.set_flight_attr(on_blocks_datetime) else: self.set_flight_attr(None)
def derive(self, off_blocks=KTI('Off Blocks'), start_datetime=A('Start Datetime')): first_off_blocks = off_blocks.get_first() if first_off_blocks: off_blocks_datetime = datetime_of_index(start_datetime.value, first_off_blocks.index) self.set_flight_attr(off_blocks_datetime) else: self.set_flight_attr(None)
def derive(self, accel_lon=P('Acceleration Longitudinal Offset Removed'), eng_running=M('Eng (*) All Running'), groundeds=S('Grounded'), eng_n1=P('Eng (*) N1 Max'), toff_acc=KTI('Takeoff Acceleration Start'), toff_rwy_hdg=S('Takeoff Runway Heading'), seg_type=A('Segment Type'), toga=M('Takeoff And Go Around')): pass
def derive(self, start_datetime=A('Start Datetime'), touchdown=KTI('Touchdown')): last_touchdown = touchdown.get_last() if not last_touchdown: self.set_flight_attr(None) return landing_datetime = datetime_of_index(start_datetime.value, last_touchdown.index, frequency=touchdown.frequency) self.set_flight_attr(landing_datetime)
def test_derive(self): d = 1.0/60.0 lat = P('Latitude', array=[0.0, d/2.0, d]) lon = P('Longitude', array=[0.0, 0.0, 0.0]) alt = P('Altitude AAL', array=[200, 100, 0.0]) tdn = KTI('Touchdown', items=[KeyTimeInstance(2, 'Touchdown'),]) ar = ApproachRange() ar.derive(alt, lat, lon, tdn) result = ar.array # Strictly, 1nm is 1852m, but this error arises from the haversine function. self.assertEqual(int(result[0]), 1853)
def test_derive(self): ra_sections = buildsections('TCAS RA Sections', [2, 4]) ap_dis = KTI(items=[ KeyTimeInstance(index=3, name='AP Disengaged Selection'), ]) expected = [ KeyPointValue(index=3, value=1.0, name='TCAS RA Time To AP Disengage'), ] k = self.klass() k.derive(ap_dis, ra_sections) self.assertEqual(k, expected)
def derive(self, pilot_flying=M('Pilot Flying'), pitch_capt=P('Pitch (Capt)'), pitch_fo=P('Pitch (FO)'), roll_capt=P('Roll (Capt)'), roll_fo=P('Roll (FO)'), cc_capt=P('Control Column Force (Capt)'), cc_fo=P('Control Column Force (FO)'), ap1_eng=M('AP (1) Engaged'), ap2_eng=M('AP (2) Engaged'), landings=S('Landing'), touchdowns=KTI('Touchdown'), afr_landing_pilot=A('AFR Landing Pilot')): pass
def test_derive(self): start = KTI(items=[ KeyTimeInstance(index=2, name='TCAS RA Start'), ]) param = P('AP Engaged', array=np.ma.arange(10) * 1.0, frequency=1., offset=0.) expected = [ KeyPointValue(index=2, value=2.0, name='TCAS RA Start Autopilot'), ] k = self.klass() k.derive(param, start) self.assertEqual(k, expected)
def derive(self, gear=M('Gear Down'), alt_aal=P('Altitude AAL'), touchdowns=KTI('Touchdown')): for touchdown in touchdowns: rough_index = index_at_value(gear.array.data, 0.5, slice(touchdown.index, 0, -1)) # index_at_value tries to be precise, but in this case we really # just want the index at the new flap setting. if rough_index: last_index = np.round(rough_index) alt_last = value_at_index(alt_aal.array, last_index) self.create_kpv(last_index, alt_last)
def derive(self, pilot_flying=M('Pilot Flying'), pitch_capt=P('Pitch (Capt)'), pitch_fo=P('Pitch (FO)'), roll_capt=P('Roll (Capt)'), roll_fo=P('Roll (FO)'), cc_capt=P('Control Column Force (Capt)'), cc_fo=P('Control Column Force (FO)'), ap1_eng=M('AP (1) Engaged'), ap2_eng=M('AP (2) Engaged'), takeoffs=S('Takeoff'), liftoffs=KTI('Liftoff'), rejected_toffs=S('Rejected Takeoff'), afr_takeoff_pilot=A('AFR Takeoff Pilot')): pass
def test_derive(self): start = KTI(items=[ KeyTimeInstance(index=2, name='TCAS RA Start'), ]) alt = P('Altitude QNH', array=np.ma.arange(10) * 10.0, frequency=1., offset=0.) expected = [ KeyPointValue(index=2, value=20.0, name='TCAS RA Start Altitude QNH'), ] k = self.klass() k.derive(alt, start) self.assertEqual(k, expected)
def test_derive(self): start = KTI(items=[ KeyTimeInstance(index=2, name='TCAS RA Start'), ]) vspd = P('Vertical Speed', array=np.ma.arange(10) * 10.0, frequency=1., offset=0.) expected = [ KeyPointValue(index=2, value=20.0, name='TCAS RA Start Vertical Speed'), ] k = self.klass() k.derive(vspd, start) self.assertEqual(k, expected)
def derive(self, cas=P('Airspeed'), vref=P('Vref (Recorded then Lookup)'), altitude=P('Altitude AAL'), touchdowns=KTI('Touchdown'), approaches=S('Approach And Landing')): for app in approaches: if vref is not None and vref.array is not None: cas_run = sustained_min(cas, _slice=app) cas_vref = cas_run.data - vref.array[app.slice] x = np.ma.zeros(len(cas.array)) x.data[app.slice] = cas_vref self.create_kpvs_within_slices( x, altitude.slices_from_to(500, 50), min_value) else: return