Ejemplo n.º 1
0
 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),
     ])
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
 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)
Ejemplo n.º 5
0
 def test_derive(self):
     #based on FDS TestTCASRAWarningDuration()
     values_mapping = {
         0: 'A',
         1: 'B',
         2: 'Drop Track',
         3: 'Altitude Lost',
         4: 'Up Advisory Corrective',
         5: 'Down Advisory Corrective',
         6: 'G',
     }
     tcas = M(
         'TCAS Combined Control',
         array=np.ma.array([0, 1, 2, 3, 4, 5, 4, 5, 6]),
         values_mapping=values_mapping,
         frequency=1,
         offset=0,
     )
     #                                                                                       _,_, a,a,a,a,a,a,_
     #                                                                                                   u,d,u,d
     #                                                                                                3.5 4.5 5.5
     airborne = buildsection('Airborne', 2, 7)
     node = TCASRAStart()
     node.derive(
         tcas,
         airborne)  # create_ktis_on_state_change() offsets times by 0.5
     expected = [
         KeyTimeInstance(index=3.5, name='TCAS RA Start'),
     ]
     self.assertEqual(expected, node)
 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)
Ejemplo n.º 7
0
 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)
Ejemplo n.º 8
0
 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)
Ejemplo n.º 9
0
    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)
Ejemplo n.º 10
0
    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)
Ejemplo n.º 11
0
    TCASCombinedControl,
    TCASUpAdvisory,
    TCASDownAdvisory,
    TCASVerticalControl,
)
'''
TCASSensitivityAtTCASRAStart,
VerticalSpeedAtTCASRAStart,
AltitudeQNHAtTCASRAStart,
'''

### fixtures
_ra = np.ma.hstack([np.ma.zeros(16), np.ma.ones(4), np.ma.zeros(16)])
ra = P('TCAS RA', _ra, frequency=1.0, offset=0.0)
off = KTI(items=[
    KeyTimeInstance(index=2, name='Liftoff'),
])
td = KTI(items=[
    KeyTimeInstance(index=34, name='Touchdown'),
])
tcas_ra_sections = TCASRASections()
tcas_ra_sections.derive(ra, off, td)

#based on FDS TestTCASRAWarningDuration()
values_mapping = {
    0: 'A',
    1: 'B',
    2: 'Drop Track',
    3: 'Altitude Lost',
    4: 'Up Advisory Corrective',
    5: 'Down Advisory Corrective',
Ejemplo n.º 12
0
 def test_derive(self):
     k = SimplerKTI()
     k.derive(self.start_datetime)
     expected = [KeyTimeInstance(index=700., name='My Simpler KTI')]
     self.assertEqual(k, expected)
Ejemplo n.º 13
0
    def test_derive(self):
        '''
        Tests every flow, but does not test every conceivable set of arguments.
        '''
        type_node = FlightType()
        type_node.set_flight_attr = Mock()
        # Liftoff and Touchdown.
        fast = S('Fast', items=[slice(5,10)])
        liftoffs = KTI('Liftoff', items=[KeyTimeInstance(5, 'a')])
        touchdowns = KTI('Touchdown', items=[KeyTimeInstance(10, 'x')])
        type_node.derive(None, fast, None, liftoffs, touchdowns, None, None, None)
        type_node.set_flight_attr.assert_called_once_with(
            FlightType.Type.COMPLETE)
        # Would be 'COMPLETE', but 'AFR Type' overrides it.
        afr_type = A('AFR Type', value=FlightType.Type.FERRY)
        type_node.set_flight_attr = Mock()
        type_node.derive(afr_type, fast, None, liftoffs, touchdowns, None, None, None)
        type_node.set_flight_attr.assert_called_once_with(FlightType.Type.FERRY)
        # Liftoff missing.
        empty_liftoffs = KTI('Liftoff')
        type_node.set_flight_attr = Mock()
        try:
            type_node.derive(None, fast, None, empty_liftoffs, touchdowns, None, None, None)
        except InvalidFlightType as err:
            self.assertEqual(err.flight_type, 'TOUCHDOWN_ONLY')
        # Touchdown missing.
        empty_touchdowns = KTI('Touchdown')
        type_node.set_flight_attr = Mock()
        try:
            type_node.derive(None, fast, None, liftoffs, empty_touchdowns, None, None, None)
        except InvalidFlightType as err:
            self.assertEqual(err.flight_type, 'LIFTOFF_ONLY')

        # Liftoff and Touchdown missing, only Fast.
        type_node.set_flight_attr = Mock()
        type_node.derive(None, fast, None, empty_liftoffs, empty_touchdowns, None,
                         None, None)
        type_node.set_flight_attr.assert_called_once_with(
            FlightType.Type.INCOMPLETE)
        # Liftoff, Touchdown and Fast missing.
        empty_fast = fast = S('Fast')
        type_node.set_flight_attr = Mock()
        type_node.derive(None, empty_fast, None, empty_liftoffs, empty_touchdowns,
                         None, None, None)
        type_node.set_flight_attr.assert_called_once_with(
            FlightType.Type.INCOMPLETE)
        # Liftoff, Touchdown and Fast missing, RTO.
        rto = buildsection('Rejected Takeoff', 5, 10)
        type_node.set_flight_attr = Mock()
        type_node.derive(None, empty_fast, None, empty_liftoffs, empty_touchdowns,
                         None, rto, None)
        type_node.set_flight_attr.assert_called_once_with(
            FlightType.Type.REJECTED_TAKEOFF)
        # Liftoff after Touchdown.
        late_liftoffs = KTI('Liftoff', items=[KeyTimeInstance(20, 'a')])
        type_node.set_flight_attr = Mock()
        try:
            type_node.derive(None, fast, None, late_liftoffs, touchdowns, None, None, None)
        except InvalidFlightType as err:
            self.assertEqual(err.flight_type, 'TOUCHDOWN_BEFORE_LIFTOFF')
        # Touch and Go before Touchdown.
        afr_type = A('AFR Type', value=FlightType.Type.TRAINING)
        touch_and_gos = KTI('Touch And Go', items=[KeyTimeInstance(7, 'a')])
        type_node.set_flight_attr = Mock()
        type_node.derive(afr_type, fast, None, liftoffs, touchdowns, touch_and_gos,
                         None, None)
        type_node.set_flight_attr.assert_called_once_with(
            FlightType.Type.TRAINING)
        # Touch and Go after Touchdown.
        afr_type = A('AFR Type', value=FlightType.Type.TRAINING)
        touch_and_gos = KTI('Touch And Go', items=[KeyTimeInstance(15, 'a')])
        type_node.set_flight_attr = Mock()
        try:
            type_node.derive(afr_type, fast, None, liftoffs, touchdowns,
                             touch_and_gos, None, None)
        except InvalidFlightType as err:
            self.assertEqual(err.flight_type, 'LIFTOFF_ONLY')
Ejemplo n.º 14
0
KTI_JSONDICT = {
    "__class__": "KeyTimeInstance",
    "datetime": {
        "type": "datetime",
        "value": "2014-04-12T14:47:56.813991+00:00",
    },
    "index": 419.81399082568805,
    "latitude": 16.137181286511073,
    "longitude": -22.888522004372511,
    "name": "35 Ft Climbing",
}

KTI = KeyTimeInstance(
    KTI_JSONDICT['index'],
    KTI_JSONDICT['name'],
    parse(KTI_JSONDICT['datetime']['value']),
    KTI_JSONDICT['latitude'],
    KTI_JSONDICT['longitude'],
)

PROCESS_FLIGHT_JSON = {
    'approach': {},
    'flight': {},
    'kpv': {},
    'kti': {
        KTI_NAME: [sort_dict(KTI_JSONDICT)]
    },
    'phases': {},
    'version': '0.1',
}
 def derive(self, start_datetime=A('Start Datetime')):
     #print 'in SimpleKTI'
     kti = KeyTimeInstance(
         index=700.,
         name='My Simpler KTI')  #freq=1hz and offset=0 by default
     self.append(kti)
Ejemplo n.º 16
0
def build_kti(name, *args):
    return KTI(items=[KeyTimeInstance(a, name) for a in args if a])