Example #1
0
 def test_1d_shorts(self):
     s1, p1 = strat._compute_elevation_to_preservation(np.array([1]))
     s15, p15 = strat._compute_elevation_to_preservation(np.array([5]))
     s2, p2 = strat._compute_elevation_to_preservation(np.array([1, 2]))
     s3, p3 = strat._compute_elevation_to_preservation(np.array([1, 2, 3]))
     assert np.all(s1 == np.array([1]))
     assert np.all(s15 == np.array([5]))
     assert np.all(p1 == np.array([False]))
     assert np.all(s2 == np.array([1, 2]))
     assert np.all(p2 == np.array([True, True]))
     assert np.all(s3 == np.array([1, 2, 3]))
     assert np.all(p3 == np.array([True, True, True]))
Example #2
0
 def test_onedim_traj_upsanddowns_negatives(self):
     # e = np.array([0, 0, -1, -4, -2, 3, 3.5, 3, 3, 4, 4])
     e = xr.DataArray([0, 0, -1, -4, -2, 3, 3.5, 3, 3, 4, 4])
     z = strat._determine_strat_coordinates(e, dz=0.5)  # vert coordinates
     s, p = strat._compute_elevation_to_preservation(e)
     sc, dc = strat._compute_preservation_to_cube(s, z)
     c = self.take_var_time(s, z, sc, dc)
     assert np.all(p.nonzero()[0] == (4, 5, 9))
Example #3
0
 def test_2d_different_walks(self):
     e = np.array([[0, 3, 4], [1, 3, 3], [1, 4, 4], [2, 4.5, 3],
                   [3, 5, 4.5]])
     s, p = strat._compute_elevation_to_preservation(e)
     assert np.all(s == np.array([[0, 3, 3], [1, 3, 3], [1, 4, 3],
                                  [2, 4.5, 3], [3, 5, 4.5]]))
     assert np.all(p == np.array([[True, False, False], [
         True, False, False
     ], [False, True, False], [True, True, False], [True, True, True]]))
Example #4
0
 def test_onedim_traj_drop_at_end_to_zero(self):
     e = np.array([0, 1, 1, 0])
     # e = np.expand_dims(e, axis=(1,2))
     z = strat._determine_strat_coordinates(e, dz=0.5)  # vert coordinates
     s, p = strat._compute_elevation_to_preservation(e)
     sc, dc = strat._compute_preservation_to_cube(s, z)
     c = self.take_var_time(s, z, sc, dc)
     assert len(z) == 3
     assert np.all(np.isnan(c[:]))
     assert np.all(p == np.array([False, False, False, False]))
Example #5
0
 def test_onedim_traj_upsanddowns(self):
     e = np.array([0, 0, 1, 4, 6, 5, 3.5, 5, 7, 5, 6])
     # e = np.expand_dims(e, axis=(1,2))
     z = strat._determine_strat_coordinates(e, dz=0.5)  # vert coordinates
     s, p = strat._compute_elevation_to_preservation(e)
     sc, dc = strat._compute_preservation_to_cube(s, z)
     c = self.take_var_time(s, z, sc, dc)
     assert z[-1] == 7
     assert s[-1] == 6
     assert np.all(p.nonzero()[0] == (2, 3, 7, 10))
     assert c[0] == 1
Example #6
0
 def test_onedim_traj_drop_at_end(self):
     e = np.array([0, 1, 2, 3, 1])
     z = strat._determine_strat_coordinates(e, dz=0.5)  # vert coordinates
     assert z[0] == 0
     assert z[-1] == 3
     assert len(z) == 7
     s, p = strat._compute_elevation_to_preservation(e)
     sc, dc = strat._compute_preservation_to_cube(s, z)
     lst = np.argmin(s[:, ...] < s[-1, ...], axis=0)  # last elevation idx
     c = self.take_var_time(s, z, sc, dc)
     assert s[-1] == e[-1]
     assert s[-1] == e[-1]
     assert np.all(np.isnan(c[2:]))  # from z>=1 to z==3
     assert np.all(c[:2] == 0)
     assert lst == 1
Example #7
0
 def test_3d_different_walks_return_valid_only_check(self):
     e = np.random.rand(51, 120, 240)
     s, p = strat._compute_elevation_to_preservation(e)
     assert s.shape == (51, 120, 240)
     assert np.all(s[-1, ...] == e[-1, ...])
     assert np.all(s[0, ...] == np.min(e, axis=0))
Example #8
0
 def test_3d_all_aggrade(self):
     e = np.tile(np.arange(0, 3), (2, 2, 1)).T
     s, p = strat._compute_elevation_to_preservation(e)
     assert np.all(s == np.array([[[0, 0], [0, 0]], [[1, 1], [1, 1]],
                                  [[2, 2], [2, 2]]]))
     assert np.all(p == np.ones((3, 2, 2), dtype=bool))
Example #9
0
 def test_3d_all_zeros(self):
     s, p = strat._compute_elevation_to_preservation(np.zeros((6, 4, 4)))
     assert np.all(s == np.zeros((6, 4, 4)))
     assert np.all(p == np.zeros((6, 4, 4), dtype=bool))
Example #10
0
 def test_1d_up_down_down(self):
     s, p = strat._compute_elevation_to_preservation(
         np.array([0, 1, 2, 1, 0]))
     assert np.all(s == np.array([0, 0, 0, 0, 0]))
     assert np.all(p == np.array([False, False, False, False, False]))
Example #11
0
 def test_1d_all_erode_negative(self):
     s, p = strat._compute_elevation_to_preservation(
         np.array([0, -1, -2, -3]))
     assert np.all(s == np.array([-3, -3, -3, -3]))
     assert np.all(p == np.array([False, False, False, False]))
Example #12
0
 def test_1d_all_erode_positive(self):
     s, p = strat._compute_elevation_to_preservation(np.array([3, 2, 1, 0]))
     assert np.all(s == np.array([0, 0, 0, 0]))
     assert np.all(p == np.array([False, False, False, False]))
Example #13
0
 def test_1d_all_aggrade(self):
     s, p = strat._compute_elevation_to_preservation(np.array([0, 1, 2, 3]))
     assert np.all(s == np.array([0, 1, 2, 3]))
     assert np.all(p == np.array([True, True, True, True]))
     assert np.all(s[1:] - s[:-1] == 1)
Example #14
0
 def test_1d_all_ones(self):
     s, p = strat._compute_elevation_to_preservation(np.array([1, 1, 1, 1]))
     assert np.all(s == np.array([1, 1, 1, 1]))
     assert np.all(p == np.array([False, False, False, False]))