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)
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)
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)
def test_read_geolist(self): geolist = timeseries.read_geolist(self.geolist_path) expected = [date(2018, 4, 20), date(2018, 4, 22), date(2018, 4, 28), date(2018, 5, 2)] self.assertEqual(geolist, expected)
def test_time_diff(self): geolist = timeseries.read_geolist(self.geolist_path) time_diffs = timeseries.find_time_diffs(geolist) assert_array_equal(self.actual_time_diffs, time_diffs)