def test_segment_type_and_slice_1(self):
     # Unmasked fast Airspeed at the beginning of the data which is difficult
     # to validate should be ignored in segment type identification.
     speed_array = load_compressed(
         os.path.join(test_data_path, 'segment_type_and_slice_1_speed.npz'))
     heading_array = load_compressed(
         os.path.join(test_data_path,
                      'segment_type_and_slice_1_heading.npz'))
     eng_arrays = load_compressed(
         os.path.join(test_data_path,
                      'segment_type_and_slice_1_eng_arrays.npz'))
     aircraft_info = {'Aircraft Type': 'aeroplane'}
     thresholds = {
         'hash_min_samples': 64,
         'speed_threshold': 80,
         'min_split_duration': 100,
         'min_duration': 180
     }
     hdf = mock.Mock()
     hdf.superframe_present = False
     segment_type, segment, array_start_secs = _segment_type_and_slice(
         speed_array, 1, heading_array, 1, 0, 11824, eng_arrays,
         aircraft_info, thresholds, hdf)
     self.assertEqual(segment_type, 'START_AND_STOP')
     self.assertEqual(segment, slice(0, 11824))
     self.assertEqual(array_start_secs, 0)
    def test_segment_type_and_slice_2(self):
        # Gear on Ground is used instead of Eng (1) Nr
        speed_array = load_compressed(
            os.path.join(test_data_path, 'segment_type_and_slice_2_speed.npz'))
        heading_array = load_compressed(
            os.path.join(test_data_path,
                         'segment_type_and_slice_2_heading.npz'))
        eng_arrays = load_compressed(
            os.path.join(test_data_path,
                         'segment_type_and_slice_2_eng_arrays.npz'))
        aircraft_info = {'Aircraft Type': 'helicopter'}
        thresholds = {
            'hash_min_samples': 64,
            'speed_threshold': 90,
            'min_split_duration': 100,
            'min_duration': 180
        }

        def get(key):
            array = load_compressed(
                os.path.join(test_data_path,
                             'segment_type_and_slice_2_gog.npz'))
            return Parameter('Gear on Ground', array=array)

        hdf = mock.MagicMock()
        hdf.get.side_effect = get
        hdf.superframe_present = False
        segment_type, segment, array_start_secs = _segment_type_and_slice(
            speed_array, 1, heading_array, 1, 0, 5736, eng_arrays,
            aircraft_info, thresholds, hdf)
        self.assertEqual(segment_type, 'START_AND_STOP')
        self.assertEqual(segment, slice(0, 5736))
        self.assertEqual(array_start_secs, 0)
    def test__get_normalised_split_params(self):
        hdf = mock.Mock()
        hdf.get = mock.Mock()
        hdf.get.return_value = None
        hdf.reliable_frame_counter = False

        arrays = {
            'Eng (1) N1':
            load_compressed(
                os.path.join(test_data_path,
                             'split_segments_eng_1_n1_slowslice.npz')),
            'Eng (2) N1':
            load_compressed(
                os.path.join(test_data_path,
                             'split_segments_eng_2_n1_slowslice.npz')),
            'Groundspeed':
            load_compressed(
                os.path.join(test_data_path,
                             'split_segments_groundspeed_slowslice.npz'))
        }

        def hdf_getitem(self, key, **kwargs):
            return Parameter(key, array=arrays[key], frequency=1)

        hdf.__getitem__ = hdf_getitem

        norm_array, freq = _get_normalised_split_params(hdf)
        # find split which without Groundspeed and averaging of the
        # normalised parameters would not work properly due to a single
        # engine taxi. Before using groundspeed and averaging, the minimum of
        # the engine only parameters would split too early, during the taxi_in
        self.assertEqual(np.ma.argmin(norm_array), 715)
Example #4
0
 def test_segment_type_and_slice_1(self):
     # Unmasked fast Airspeed at the beginning of the data which is difficult
     # to validate should be ignored in segment type identification.
     speed_array = load_compressed(os.path.join(test_data_path, 'segment_type_and_slice_1_speed.npz'))
     heading_array = load_compressed(os.path.join(test_data_path, 'segment_type_and_slice_1_heading.npz'))
     eng_arrays = load_compressed(os.path.join(test_data_path, 'segment_type_and_slice_1_eng_arrays.npz'))
     aircraft_info = {'Aircraft Type': 'aeroplane'}
     thresholds = {'hash_min_samples': 64, 'speed_threshold': 80, 'min_split_duration': 100, 'min_duration': 180}
     hdf = mock.Mock()
     hdf.superframe_present = False
     segment_type, segment, array_start_secs = _segment_type_and_slice(
         speed_array, 1, heading_array, 1, 0, 11824, eng_arrays, 
         aircraft_info, thresholds, hdf)
     self.assertEqual(segment_type, 'START_AND_STOP')
     self.assertEqual(segment, slice(0, 11824))
     self.assertEqual(array_start_secs, 0)
 def __call__(self, path):
     self.path = path
     if path == 'slow':
         self.airspeed = np.ma.arange(10, 20).repeat(5)
     else:
         self.airspeed = np.ma.array(
             load_compressed(os.path.join(test_data_path, 'airspeed_sample.npz')))
     self.duration = len(self.airspeed)
     return self
 def get(key):
     array = load_compressed(
         os.path.join(test_data_path,
                      'segment_type_and_slice_2_gog.npz'))
     return Parameter('Gear on Ground', array=array)
def load_array(filename):
    return load_compressed(os.path.join(test_data_path, filename))
def load_array(filename):
    return load_compressed(os.path.join(test_data_path, filename))