Exemple #1
0
    def test_invert_sbas(self):
        # Fake pixel phases from unwrapped igrams
        actual_phases = np.array([0.0, 2.0, 14.0, 16.0]).reshape((-1, 1))
        actual_velocity_array = np.array([1, 2, .5]).reshape((-1, 1))

        delta_phis = np.array([2, 14, 12, 14, 2]).reshape((-1, 1))

        geolist = timeseries.read_geolist(self.geolist_path)
        intlist = timeseries.read_intlist(self.intlist_path)

        timediffs = timeseries.find_time_diffs(geolist)
        B = timeseries.build_B_matrix(geolist, intlist)
        velocity_array, phases = timeseries.invert_sbas(delta_phis, timediffs, B)

        assert_array_almost_equal(velocity_array, actual_velocity_array)
        assert_array_almost_equal(phases, actual_phases)

        # Now test multiple phase time series as columns
        # stack is column-wise stack by laying vertical rows, then transpose
        actual_phases = np.hstack((actual_phases, 2 * actual_phases))
        actual_velocity_array = np.hstack((actual_velocity_array, 2 * actual_velocity_array))
        delta_phis = np.hstack((delta_phis, 2 * delta_phis))

        velocity_array, phases = timeseries.invert_sbas(delta_phis, timediffs, B)
        assert_array_almost_equal(velocity_array, actual_velocity_array)
        assert_array_almost_equal(phases, actual_phases)
Exemple #2
0
 def test_build_B_matrix(self):
     geolist = timeseries.read_geolist(self.geolist_path)
     intlist = timeseries.read_intlist(self.intlist_path)
     expected_B = np.array([
         [2, 0, 0],
         [2, 6, 0],
         [0, 6, 0],
         [0, 6, 4],
         [0, 0, 4],
     ])
     B = timeseries.build_B_matrix(geolist, intlist)
     assert_array_equal(expected_B, B)
Exemple #3
0
    def test_read_intlist(self):
        intlist = timeseries.read_intlist(self.intlist_path)
        expected = [
            (date(2018, 4, 20), date(2018, 4, 22)),
            (date(2018, 4, 20), date(2018, 4, 28)),
            (date(2018, 4, 22), date(2018, 4, 28)),
            (date(2018, 4, 22), date(2018, 5, 2)),
            (date(2018, 4, 28), date(2018, 5, 2)),
        ]
        self.assertEqual(intlist, expected)

        expected = [
            'data/sbas_test/20180420_20180422.int', 'data/sbas_test/20180420_20180428.int',
            'data/sbas_test/20180422_20180428.int', 'data/sbas_test/20180422_20180502.int',
            'data/sbas_test/20180428_20180502.int'
        ]

        igram_files = timeseries.read_intlist(self.intlist_path, parse=False)
        # Remove all but last part to ignore where we are running this
        igram_files = [os.sep.join(f.split(os.sep)[-3:]) for f in igram_files]
        self.assertEqual(igram_files, expected)
Exemple #4
0
 def test_build_A_matrix(self):
     geolist = timeseries.read_geolist(self.geolist_path)
     intlist = timeseries.read_intlist(self.intlist_path)
     expected_A = np.array([
         [1, 0, 0],
         [0, 1, 0],
         [-1, 1, 0],
         [-1, 0, 1],
         [0, -1, 1],
     ])
     A = timeseries.build_A_matrix(geolist, intlist)
     assert_array_equal(expected_A, A)
Exemple #5
0
    def test_animate_stack(self):
        try:
            # Commands to turn off interactive for travis tests
            plt.ioff()

            temp_dir = tempfile.mkdtemp()
            plotting.animate_stack(self.stack, display=False)

            igram_files = timeseries.read_intlist(join(self.igram_path,
                                                       'intlist'),
                                                  parse=False)
            plotting.animate_stack(self.stack,
                                   display=False,
                                   titles=igram_files)

        finally:
            shutil.rmtree(temp_dir)