Example #1
0
    def test_calculate_connect_and_ntrees_small_data(self):
        ifg_instance = IfgList(small_ifg_file_list())
        ifg_list, _ = get_nml(ifg_instance, nodata_value=0)
        edges = get_sub_structure(ifg_list,
                                  np.zeros(len(ifg_list.id), dtype=bool))
        mst, connected, ntrees = matlab_mst_kruskal(edges, ntrees=True)

        self.assertTrue(connected[0].all())
        self.assertEqual(ntrees, 1)
        self.assertEqual(len(connected[0]), len(mst) + 1)
Example #2
0
 def test_assert_is_not_tree(self):
     non_overlapping = [1, 2, 5, 6, 12, 13, 14, 15, 16, 17]
     small_files = small_ifg_file_list()
     datafiles = [
         f for i, f in enumerate(small_files) if i + 1 in non_overlapping
     ]
     non_overlapping_ifg_isntance = IfgList(datafiles)
     ifg_list, _ = get_nml(non_overlapping_ifg_isntance, nodata_value=0)
     edges = get_sub_structure(ifg_list,
                               np.zeros(len(ifg_list.id), dtype=bool))
     mst, connected, ntrees = matlab_mst_kruskal(edges, ntrees=True)
     self.assertEqual(connected.shape[0], 4)
     self.assertEqual(ntrees, 4)
Example #3
0
    def test_assert_two_trees_overlapping(self):
        overlapping = [3, 4, 5, 6, 7, 8, 9, 10, 11, 16, 17]

        small_files = small_ifg_file_list()
        datafiles = [
            f for i, f in enumerate(small_files) if i + 1 in overlapping
        ]
        overlapping_ifg_isntance = IfgList(datafiles)
        ifg_list, _ = get_nml(overlapping_ifg_isntance, nodata_value=0)
        edges = get_sub_structure(ifg_list,
                                  np.zeros(len(ifg_list.id), dtype=bool))
        mst, connected, ntrees = matlab_mst_kruskal(edges, ntrees=True)
        self.assertEqual(connected.shape[0], 2)
        self.assertEqual(ntrees, 2)
Example #4
0
def time_series_interpolation(ifg_instance_updated, params):

    edges = matlab_mst.get_sub_structure(
        ifg_instance_updated, np.zeros(len(ifg_instance_updated.id),
                                       dtype=bool))

    _, _, ntrees = matlab_mst.matlab_mst_kruskal(edges, ntrees=True)
    # if ntrees=1, no interpolation; otherwise interpolate
    if ntrees > 1:
        params[cf.TIME_SERIES_INTERP] = 1
    else:
        params[cf.TIME_SERIES_INTERP] = 0

    return params
Example #5
0
    def test_matlab_mst_kruskal(self):
        """
        test that the matlab and python mst algos outputs are the same
        """
        ifg_instance = IfgList(datafiles=self.ifg_file_list)
        ifg_list, _ = get_nml(ifg_instance, nodata_value=0)
        edges = get_sub_structure(ifg_list,
                                  np.zeros(len(ifg_list.id), dtype=bool))
        ifg_list_mst_id = matlab_mst_kruskal(edges)

        self.assertEquals(len(self.matlab_mst_list), len(ifg_list_mst_id))

        for i in ifg_list_mst_id:
            self.assertIn(
                os.path.split(ifg_list.nml[i])[-1], self.matlab_mst_list)
Example #6
0
 def test_mst_kruskal_matlab(self):
     edges = get_sub_structure(self.ifg_list,
                               np.zeros(len(self.ifg_list.id), dtype=bool))
     ifg_list_mst = matlab_mst_kruskal(edges)
     ifg_list_mst = [i + 1 for i in ifg_list_mst]  # add 1 to each index
     self.assertSequenceEqual(ifg_list_mst, self.ifg_list_mst_matlab)