Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish latest changes to the DEA Sandbox and User Guide #1144

Merged
merged 13 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 49 additions & 28 deletions DEA_products/DEA_Landsat_Surface_Reflectance.ipynb

Large diffs are not rendered by default.

52 changes: 26 additions & 26 deletions DEA_products/DEA_Mangroves.ipynb

Large diffs are not rendered by default.

104 changes: 57 additions & 47 deletions DEA_products/DEA_Water_Observations.ipynb

Large diffs are not rendered by default.

1,104 changes: 995 additions & 109 deletions How_to_guides/Imagery_on_web_map.ipynb

Large diffs are not rendered by default.

744 changes: 482 additions & 262 deletions How_to_guides/Tidal_modelling.ipynb

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Real_world_examples/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ More complex case study-based workflows demonstrating how DEA can be used to add
Turbidity_animated_timeseries.ipynb
Urban_change_detection.ipynb
Vegetation_phenology.ipynb
Water_quality_suspended_matter.ipynb
Wetness_stream_gauge_correlations.ipynb
Scalable_machine_learning/README.rst

Expand Down
975 changes: 975 additions & 0 deletions Real_world_examples/Water_quality_suspended_matter.ipynb

Large diffs are not rendered by default.

98 changes: 95 additions & 3 deletions Tests/dea_tools/test_coastal.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ def test_model_tides(measured_tides_ds, x, y, crs, method):

# Test that modelled tides contain correct headings and have same
# number of timesteps
assert modelled_tides_df.columns.tolist() == ["x", "y", "tide_model", "tide_m"]
assert modelled_tides_df.index.names == ["time", "x", "y"]
assert modelled_tides_df.columns.tolist() == ["tide_model", "tide_m"]
assert len(modelled_tides_df.index) == len(measured_tides_ds.time)

# Test that modelled tides meet expected accuracy
Expand Down Expand Up @@ -169,7 +170,8 @@ def test_model_tides_multiplemodels(measured_tides_ds, models, output_format):

if output_format == "long":
# Verify output has correct columns
assert modelled_tides_df.columns.tolist() == ["x", "y", "tide_model", "tide_m"]
assert modelled_tides_df.index.names == ["time", "x", "y"]
assert modelled_tides_df.columns.tolist() == ["tide_model", "tide_m"]

# Verify tide model column contains correct values
assert modelled_tides_df.tide_model.unique().tolist() == models
Expand All @@ -180,7 +182,8 @@ def test_model_tides_multiplemodels(measured_tides_ds, models, output_format):

elif output_format == "wide":
# Verify output has correct columns
assert modelled_tides_df.columns[2:].tolist() == models
assert modelled_tides_df.index.names == ["time", "x", "y"]
assert modelled_tides_df.columns.tolist() == models

# Verify output has same length as orginal timesteps
assert len(modelled_tides_df.index) == len(measured_tides_ds.time)
Expand Down Expand Up @@ -209,6 +212,95 @@ def test_model_tides_units(measured_tides_ds, units, expected_range, expected_dt
assert modelled_tides_df.tide_m.dtype == expected_dtype


# Run test for each combination of mode, output format, and one or
# multiple tide models
@pytest.mark.parametrize(
"mode, models, output_format",
[
("one-to-many", ["FES2014"], "long"),
("one-to-one", ["FES2014"], "long"),
("one-to-many", ["FES2014"], "wide"),
("one-to-one", ["FES2014"], "wide"),
("one-to-many", ["FES2014", "HAMTIDE11"], "long"),
("one-to-one", ["FES2014", "HAMTIDE11"], "long"),
("one-to-many", ["FES2014", "HAMTIDE11"], "wide"),
("one-to-one", ["FES2014", "HAMTIDE11"], "wide"),
],
)
def test_model_tides_mode(mode, models, output_format):
# Input params
x = [122.14, 122.30, 122.12]
y = [-17.91, -17.92, -18.07]
times = pd.date_range("2020", "2021", periods=3)

# Model tides
modelled_tides_df = model_tides(
x=x,
y=y,
time=times,
mode=mode,
output_format=output_format,
model=models,
)

if mode == "one-to-one":
if output_format == "wide":
# Should have the same number of rows as input x, y, times
assert len(modelled_tides_df.index) == len(x)
assert len(modelled_tides_df.index) == len(times)

# Output indexes should match order of input x, y, times
assert all(modelled_tides_df.index.get_level_values("time") == times)
assert all(modelled_tides_df.index.get_level_values("x") == x)
assert all(modelled_tides_df.index.get_level_values("y") == y)

elif output_format == "long":
# In "long" format, the number of x, y points multiplied by
# the number of tide models
assert len(modelled_tides_df.index) == len(x) * len(models)

# Verify index values match expected x, y, time order
assert all(
modelled_tides_df.index.get_level_values("time")
== np.tile(times, len(models))
)
assert all(
modelled_tides_df.index.get_level_values("x") == np.tile(x, len(models))
)
assert all(
modelled_tides_df.index.get_level_values("y") == np.tile(y, len(models))
)

if mode == "one-to-many":
if output_format == "wide":
# In "wide" output format, the number of rows should equal
# the number of x, y points multiplied by timesteps
assert len(modelled_tides_df.index) == len(x) * len(times)

# TODO: Work out what order rows should be returned in in
# "one-to-many" and "wide" mode

elif output_format == "long":
# In "long" output format, the number of rows should equal
# the number of x, y points multiplied by timesteps and
# the number of tide models
assert len(modelled_tides_df.index) == len(x) * len(times) * len(models)

# Verify index values match expected x, y, time order
assert all(
modelled_tides_df.index.get_level_values("time")
== np.tile(times, len(x) * len(models))
)
assert all(
modelled_tides_df.index.get_level_values("x")
== np.tile(np.repeat(x, len(times)), len(models))
)
assert all(
modelled_tides_df.index.get_level_values("y")
== np.tile(np.repeat(y, len(times)), len(models))
)


# Run tests for default and custom resolutions
@pytest.mark.parametrize("resolution", [None, "custom"])
def test_pixel_tides(satellite_ds, measured_tides_ds, resolution):
Expand Down
Loading
Loading