Skip to content

Commit

Permalink
add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerkuou committed Mar 18, 2024
1 parent 3a04282 commit 8795e63
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion tests/test_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_stack_pointselection_some(self, synthetic_dataset):
synthetic_dataset = synthetic_dataset.slcstack._get_phase()
stm = synthetic_dataset.slcstack.point_selection(
threshold=0.2, method="amplitude_dispersion"
) # select all
) # select some
assert stm.space.shape[0] == 4
assert set([k for k in stm.coords.keys()]).issubset(
["time", "azimuth", "range"]
Expand All @@ -81,6 +81,35 @@ def test_stack_pointselection_some(self, synthetic_dataset):
["complex", "amplitude", "phase"]
)

def test_stack_pointselection_nan(self):
data = np.random.rand(10, 10, 10) + 1j * np.random.rand(10, 10, 10)
data[0, 0, 0] = np.nan # introduce a nan
ds_nan = xr.Dataset(
{
"complex": (
("azimuth", "range", "time"),
data,
)
},
coords={
"azimuth": np.arange(600, 610, 1, dtype=int),
"range": np.arange(1400, 1410, 1, dtype=int),
"time": np.arange(1, 11, 1, dtype=int),
},
)
ds_nan = ds_nan.slcstack._get_amplitude()
ds_nan = ds_nan.slcstack._get_phase()
stm = ds_nan.slcstack.point_selection(
threshold=100, method="amplitude_dispersion"
)
assert stm.space.shape[0] == 99 # only the nan is removed
assert set([k for k in stm.coords.keys()]).issubset(
["time", "azimuth", "range"]
)
assert set([d for d in stm.data_vars.keys()]).issubset(
["complex", "amplitude", "phase"]
)


class TestStackMultiLook:
def test_stack_multi_look_mean(self, synthetic_dataset):
Expand Down

0 comments on commit 8795e63

Please sign in to comment.