Skip to content

Commit

Permalink
Fix broken code on unstable Sandbox image (#1274)
Browse files Browse the repository at this point in the history
* Updates for pyTMD

* Fix contours bug due to groupby squeeze

* Try loosening pyTMD requirements

* Update tests to pass on both stable and unstable sandbox

* Fix pansharpening bug
  • Loading branch information
robbibt authored Oct 9, 2024
1 parent 262bd5c commit fe36b0e
Show file tree
Hide file tree
Showing 6 changed files with 288 additions and 173 deletions.
93 changes: 41 additions & 52 deletions How_to_guides/Pansharpening.ipynb

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions Tests/dea_tools/test_coastal.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def test_model_tides_ensemble():
assert modelled_tides_df.columns.tolist() == ["tide_model", "tide_m"]
assert set(modelled_tides_df.tide_model) == set(models)
assert np.allclose(
modelled_tides_df.tide_m,
modelled_tides_df.tide_m.values,
[
-2.819,
-1.850,
Expand All @@ -352,7 +352,7 @@ def test_model_tides_ensemble():
-0.071,
-0.0158,
],
rtol=0.02,
atol=0.10,
)

# One-to-one mode
Expand Down Expand Up @@ -420,7 +420,7 @@ def test_model_tides_ensemble():

# Check values are expected
assert np.allclose(
modelled_tides_df.ensemble, [-2.819, 0.0730, -1.850, -0.069], rtol=0.01
modelled_tides_df.ensemble.values, [-2.819, 0.0730, -1.850, -0.069], atol=0.10
)

# Wide mode, custom functions
Expand Down Expand Up @@ -558,9 +558,9 @@ def test_pixel_tides(satellite_ds, measured_tides_ds, resolution):
longitude=x_coords, latitude=y_coords, time="2020-02-14", method="nearest"
)

# Test if extracted tides match expected results (to within ~3 cm)
# Test if extracted tides match expected results (to within ~12 cm)
expected_tides = [-1.82249, -1.977088, -1.973618, -2.071242]
assert np.allclose(extracted_tides.values, expected_tides, atol=0.03)
assert np.allclose(extracted_tides.values, expected_tides, atol=0.12)


def test_pixel_tides_quantile(satellite_ds):
Expand Down Expand Up @@ -603,7 +603,7 @@ def test_pixel_tides_quantile(satellite_ds):
longitude=x_coords, latitude=y_coords, method="nearest"
)

# Test if extracted tides match expected results (to within ~3 cm)
# Test if extracted tides match expected results (to within ~10 cm)
expected_tides = np.array(
[
[-1.83, -1.98, -1.98, -2.07],
Expand All @@ -614,7 +614,7 @@ def test_pixel_tides_quantile(satellite_ds):
[1.58, 1.61, 1.62, 1.64],
]
)
assert np.allclose(extracted_tides.values, expected_tides, atol=0.03)
assert np.allclose(extracted_tides.values, expected_tides, atol=0.10)


# Run test with quantile calculation off and on
Expand Down Expand Up @@ -793,7 +793,7 @@ def test_tidal_stats(satellite_ds, modelled_freq):
# Calculate tidal stats
tidal_stats_df = tidal_stats(satellite_ds, modelled_freq=modelled_freq)

# Compare outputs to expected results (within 5% or 0.05 m)
# Compare outputs to expected results (within 10% or 0.10 m)
expected_results = pd.Series(
{
"tidepost_lat": -18.001,
Expand All @@ -811,7 +811,7 @@ def test_tidal_stats(satellite_ds, modelled_freq):
"high_tide_offset": 0.308,
}
)
assert np.allclose(tidal_stats_df, expected_results, atol=0.05)
assert np.allclose(tidal_stats_df, expected_results, atol=0.10)


def test_glint_angle(angle_metadata_ds):
Expand Down
Loading

0 comments on commit fe36b0e

Please sign in to comment.