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

Geomedian notebook #1148

Merged
merged 24 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
2e4221d
Geomedian notebook
margaretharrison Nov 7, 2023
005ec26
update GeoMAD with latest version
JM-GA Jun 14, 2024
36a24fe
update tests to use new GeoMAD products
JM-GA Jun 17, 2024
2a6975f
update export netcdf notebook with new GeoMAD
JM-GA Jun 17, 2024
edd03c5
Merge branch 'develop' into geomedian
JM-GA Jun 18, 2024
cb424ef
Update setup_test_datacube.sh
JM-GA Jun 18, 2024
38c1177
Update setup_test_datacube.sh
JM-GA Jun 18, 2024
e2d0fa4
Update setup_test_datacube.sh
JM-GA Jun 18, 2024
bf1ce5d
Update to new c3 grid path rows
JM-GA Jun 18, 2024
555e3e9
Update loading_data notebook to use new GeoMAD
JM-GA Jun 18, 2024
c3651fc
update plotting notebook with new GeoMAD
JM-GA Jun 20, 2024
02ed2dc
Update parallel processing notebook with new GeoMAD
JM-GA Jun 21, 2024
b4b992a
update Animated_timeseries with new GeoMAD
JM-GA Jun 21, 2024
09d81c7
Update DEA_Intertidal with new GeoMAD
JM-GA Jun 21, 2024
6025419
Update DEA_GeoMAD.ipynb
JM-GA Jun 21, 2024
1e69dc2
Expand GeoMAD test tiles
JM-GA Jun 25, 2024
ddf6b7c
Update 1_Extract_training_data.ipynb
JM-GA Jun 27, 2024
cf4f524
Update 04_Loading_data.ipynb
JM-GA Jun 27, 2024
0cf8ac8
Update 09_Parallel_processing_with_Dask.ipynb
JM-GA Jun 27, 2024
b956e10
Update DEA_Intertidal.ipynb
JM-GA Jun 27, 2024
65ba42e
Update Exporting_NetCDFs.ipynb
JM-GA Jun 27, 2024
2b0fdf7
Update Animated_timeseries.ipynb
JM-GA Jun 27, 2024
3a8233a
Update 05_Plotting.ipynb
JM-GA Jun 27, 2024
14d2302
Update 09_Parallel_processing_with_Dask.ipynb
JM-GA Jun 28, 2024
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
3,494 changes: 1,912 additions & 1,582 deletions Beginners_guide/04_Loading_data.ipynb

Large diffs are not rendered by default.

5,912 changes: 3,055 additions & 2,857 deletions Beginners_guide/05_Plotting.ipynb

Large diffs are not rendered by default.

1,801 changes: 1,013 additions & 788 deletions Beginners_guide/09_Parallel_processing_with_Dask.ipynb
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @JM-GA, everything looks awesome here, great work. One tiny minor comment is that the new data now includes a chunk of nodata here - might be good to add in a call to datacube.utils.masking import mask_invalid_data to this example so that users can correctly treat nodata values in their analysis. But not a major issue!

image

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @robbibt - good idea! I have added in handing of no data pixels into the notebook

Large diffs are not rendered by default.

1,007 changes: 1,007 additions & 0 deletions DEA_products/DEA_GeoMAD.ipynb

Large diffs are not rendered by default.

493 changes: 247 additions & 246 deletions DEA_products/DEA_Intertidal.ipynb

Large diffs are not rendered by default.

4,733 changes: 2,407 additions & 2,326 deletions How_to_guides/Animated_timeseries.ipynb

Large diffs are not rendered by default.

741 changes: 370 additions & 371 deletions How_to_guides/Exporting_NetCDFs.ipynb

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Binary file added Supplementary_data/DEA_GeoMAD/TMADS_rgb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Supplementary_data/DEA_GeoMAD/widget.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 23 additions & 21 deletions Tests/setup_test_datacube.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ for metadata_yaml in $(find ./dea-config/product_metadata -name '*.yaml'); do
done

# Index products we care about for dea-notebooks
for prod_def_yaml in $(find ./dea-config/products -name '*.yaml' -regex '.*\(ga_ls7e_nbart_gm_cyear_3\|ga_ls8c_nbart_gm_cyear_3\|ga_ls_fc_3\|ga_ls_wo_3\|ga_ls_wo_fq_cyear_3\|ga_ls_landcover_class_cyear_2\|high_tide_comp_20p\|low_tide_comp_20p\|ga_s2am_ard_3\|ga_s2bm_ard_3\|ga_ls5t_ard_3\|ga_ls7e_ard_3\|ga_ls8c_ard_3\|ga_ls9c_ard_3\|ga_ls_mangrove_cover_cyear_3\|ga_s2ls_intertidal_cyear_3\).*'); do
for prod_def_yaml in $(find ./dea-config/products -name '*.yaml' -regex '.*\(ga_ls7e_gm_cyear_3\|ga_ls8cls9c_gm_cyear_3\|ga_ls_fc_3\|ga_ls_wo_3\|ga_ls_wo_fq_cyear_3\|ga_ls_landcover_class_cyear_2\|high_tide_comp_20p\|low_tide_comp_20p\|ga_s2am_ard_3\|ga_s2bm_ard_3\|ga_ls5t_ard_3\|ga_ls7e_ard_3\|ga_ls8c_ard_3\|ga_ls9c_ard_3\|ga_ls_mangrove_cover_cyear_3\|ga_s2ls_intertidal_cyear_3\).*'); do
datacube product add $prod_def_yaml
done

Expand All @@ -35,26 +35,28 @@ s3-to-dc 's3://dea-public-data/derivative/ga_s2ls_intertidal_cyear_3/1-0-0/x080/
s3-to-dc 's3://dea-public-data/derivative/ga_ls_mangrove_cover_cyear_3/3-0-0/x33/y39/*/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls_mangrove_cover_cyear_3'

# Index GeoMAD
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x08/y27/2018--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x08/y27/2019--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x08/y27/2020--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x49/y24/2017--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls7e_nbart_gm_cyear_3/3-0-0/x49/y23/2015--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls7e_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls7e_nbart_gm_cyear_3/3-0-0/x49/y24/2015--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls7e_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x49/y23/2013--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x49/y23/2014--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x49/y23/2016--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x49/y23/2017--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x49/y24/2013--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x49/y24/2014--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x49/y24/2015--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x49/y24/2016--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x38/y19/2017--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x38/y19/2018--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x38/y19/2016--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x38/y19/2015--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x38/y19/2019--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8c_nbart_gm_cyear_3/3-0-0/x38/y19/2020--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8c_nbart_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x35/y51/2020--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x59/y32/2015--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x67/y39/2017--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x67/y38/2013--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x67/y38/2014--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x67/y38/2016--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x67/y38/2017--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x67/y39/2013--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x67/y39/2014--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x67/y39/2015--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x67/y39/2016--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x56/y34/2017--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x56/y34/2018--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x56/y34/2016--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x56/y34/2015--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x56/y34/2019--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x56/y34/2020--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x26/y42/2018--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x26/y42/2019--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls8cls9c_gm_cyear_3/4-0-0/x26/y42/2020--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls8cls9c_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls7e_gm_cyear_3/4-0-0/x67/y38/2015--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls7e_gm_cyear_3'
s3-to-dc 's3://dea-public-data/derivative/ga_ls7e_gm_cyear_3/4-0-0/x67/y39/2015--P1Y/*.odc-metadata.yaml' --no-sign-request --skip-lineage 'ga_ls7e_gm_cyear_3'

# Index FC
s3-to-dc 's3://dea-public-data/derivative/ga_ls_fc_3/2-5-0/096/084/1993/10/30/*.json' --no-sign-request --skip-lineage --stac 'ga_ls_fc_3'
Expand Down
126 changes: 126 additions & 0 deletions Tools/dea_tools/app/geomedian.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
"""
Geomedian widget: generates an interactive visualisation of
the geomedian summary statistic.
"""

# Load modules
import ipywidgets as widgets
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import xarray as xr
from odc.algo import xr_geomedian

def run_app():

"""
An interactive app that allows users to visualise the difference between the median and geomedian time-series summary statistics. By modifying the red-green-blue values of three timesteps for a given pixel, the user changes the output summary statistics.

This allows a visual representation of the difference through the output values, RGB colour, as well as showing values plotted as a vector on a 3-dimensional space.

Last modified: December 2021
"""

# Define the red-green-blue sliders for timestep 1
p1r = widgets.IntSlider(description='Red', max=255, value=58)
p1g = widgets.IntSlider(description='Green', max=255, value=153)
p1b = widgets.IntSlider(description='Blue', max=255, value=68)

# Define the red-green-blue sliders for timestep 2
p2r = widgets.IntSlider(description='Red', max=255, value=208)
p2g = widgets.IntSlider(description='Green', max=255, value=221)
p2b = widgets.IntSlider(description='Blue', max=255, value=203)

# Define the red-green-blue sliders for timestep 3
p3r = widgets.IntSlider(description='Red', max=255, value=202)
p3g = widgets.IntSlider(description='Green', max=255, value=82)
p3b = widgets.IntSlider(description='Blue', max=255, value=33)

# Define the median calculation for the timesteps
def f(p1r, p1g, p1b, p2r, p2g, p2b, p3r, p3g, p3b):
print('Red Median = {}'.format(np.median([p1r, p2r, p3r])))
print('Green Median = {}'.format(np.median([p1g, p2g, p3g])))
print('Blue Median = {}'.format(np.median([p1b, p2b, p3b])))

# Define the geomedian calculation for the timesteps
def g(p1r, p1g, p1b, p2r, p2g, p2b, p3r, p3g, p3b):
print('Red Geomedian = {:.2f}'.format(xr_geomedian(xr.Dataset({"red": (("x", "y", "time"), [[[np.float32(p1r), np.float32(p2r), np.float32(p3r)]]]), "green": (("x", "y", "time"), [[[np.float32(p1g), np.float32(p2g), np.float32(p3g)]]]), "blue": (("x", "y", "time"), [[[np.float32(p1b), np.float32(p2b), np.float32(p3b)]]])})).red.values.ravel()[0]))
print('Green Geomedian = {:.2f}'.format(xr_geomedian(xr.Dataset({"red": (("x", "y", "time"), [[[np.float32(p1r), np.float32(p2r), np.float32(p3r)]]]), "green": (("x", "y", "time"), [[[np.float32(p1g), np.float32(p2g), np.float32(p3g)]]]), "blue": (("x", "y", "time"), [[[np.float32(p1b), np.float32(p2b), np.float32(p3b)]]])})).green.values.ravel()[0]))
print('Blue Geomedian = {:.2f}'.format(xr_geomedian(xr.Dataset({"red": (("x", "y", "time"), [[[np.float32(p1r), np.float32(p2r), np.float32(p3r)]]]), "green": (("x", "y", "time"), [[[np.float32(p1g), np.float32(p2g), np.float32(p3g)]]]), "blue": (("x", "y", "time"), [[[np.float32(p1b), np.float32(p2b), np.float32(p3b)]]])})).blue.values.ravel()[0]))

# Define the Timestep 1 box colour
def h(p1r, p1g, p1b):
fig1, axes1 = plt.subplots(figsize=(2,2))
fig1 = plt.imshow([[(p1r, p1g, p1b)]])
axes1.set_title('Timestep 1')
axes1.axis('off')
plt.show(fig1)

# Define the Timestep 2 box colour
def hh(p2r, p2g, p2b):
fig2, axes2 = plt.subplots(figsize=(2,2))
fig2 = plt.imshow([[(p2r, p2g, p2b)]])
axes2.set_title('Timestep 2')
axes2.axis('off')
plt.show(fig2)

# Define the Timestep 3 box colour
def hhh(p3r, p3g, p3b):
fig3, axes3 = plt.subplots(figsize=(2,2))
fig3 = plt.imshow([[(p3r, p3g, p3b)]])
axes3.set_title('Timestep 3')
axes3.axis('off')
plt.show(fig3)

# Define the Median RGB colour box
def i(p1r, p1g, p1b, p2r, p2g, p2b, p3r, p3g, p3b):
fig4, axes4 = plt.subplots(figsize=(3,3))
fig4 = plt.imshow([[(int(np.median([p1r, p2r, p3r])), int(np.median([p1g, p2g, p3g])), int(np.median([p1b, p2b, p3b])))]])
axes4.set_title('Median RGB - All timesteps')
axes4.axis('off')
plt.show(fig4)

# Define the Geomedian RGB colour box
def ii(p1r, p1g, p1b, p2r, p2g, p2b, p3r, p3g, p3b):
fig5, axes5 = plt.subplots(figsize=(3,3))
fig5 = plt.imshow([[(int(xr_geomedian(xr.Dataset({"red": (("x", "y", "time"), [[[np.float32(p1r), np.float32(p2r), np.float32(p3r)]]]), "green": (("x", "y", "time"), [[[np.float32(p1g), np.float32(p2g), np.float32(p3g)]]]), "blue": (("x", "y", "time"), [[[np.float32(p1b), np.float32(p2b), np.float32(p3b)]]])})).red.values.ravel()[0]), int(xr_geomedian(xr.Dataset({"red": (("x", "y", "time"), [[[np.float32(p1r), np.float32(p2r), np.float32(p3r)]]]), "green": (("x", "y", "time"), [[[np.float32(p1g), np.float32(p2g), np.float32(p3g)]]]), "blue": (("x", "y", "time"), [[[np.float32(p1b), np.float32(p2b), np.float32(p3b)]]])})).green.values.ravel()[0]), int(xr_geomedian(xr.Dataset({"red": (("x", "y", "time"), [[[np.float32(p1r), np.float32(p2r), np.float32(p3r)]]]), "green": (("x", "y", "time"), [[[np.float32(p1g), np.float32(p2g), np.float32(p3g)]]]), "blue": (("x", "y", "time"), [[[np.float32(p1b), np.float32(p2b), np.float32(p3b)]]])})).blue.values.ravel()[0]))]])
axes5.set_title('Geomedian RGB - All timesteps')
axes5.axis('off')
plt.show(fig5)

# Define 3-D axis to display vectors on
def j(p1r, p1g, p1b, p2r, p2g, p2b, p3r, p3g, p3b):
fig6 = plt.figure()
axes6 = fig6.add_subplot(111, projection='3d')
x = [p1r, p2r, p3r, int(np.median([p1r, p2r, p3r])), int(xr_geomedian(xr.Dataset({"red": (("x", "y", "time"), [[[np.float32(p1r), np.float32(p2r), np.float32(p3r)]]]), "green": (("x", "y", "time"), [[[np.float32(p1g), np.float32(p2g), np.float32(p3g)]]]), "blue": (("x", "y", "time"), [[[np.float32(p1b), np.float32(p2b), np.float32(p3b)]]])})).red.values.ravel()[0])]
y = [p1g, p2g, p3g, int(np.median([p1g, p2g, p3g])), int(xr_geomedian(xr.Dataset({"red": (("x", "y", "time"), [[[np.float32(p1r), np.float32(p2r), np.float32(p3r)]]]), "green": (("x", "y", "time"), [[[np.float32(p1g), np.float32(p2g), np.float32(p3g)]]]), "blue": (("x", "y", "time"), [[[np.float32(p1b), np.float32(p2b), np.float32(p3b)]]])})).green.values.ravel()[0])]
z = [p1b, p2b, p3b, int(np.median([p1b, p2b, p3b])), int(xr_geomedian(xr.Dataset({"red": (("x", "y", "time"), [[[np.float32(p1r), np.float32(p2r), np.float32(p3r)]]]), "green": (("x", "y", "time"), [[[np.float32(p1g), np.float32(p2g), np.float32(p3g)]]]), "blue": (("x", "y", "time"), [[[np.float32(p1b), np.float32(p2b), np.float32(p3b)]]])})).blue.values.ravel()[0])]
labels = [' 1', ' 2', ' 3', ' median', ' geomedian']
axes6.scatter(x, y, z, c=['black','black','black','r', 'blue'], marker='o')
axes6.set_xlabel('Red')
axes6.set_ylabel('Green')
axes6.set_zlabel('Blue')
axes6.set_xlim3d(0, 255)
axes6.set_ylim3d(0, 255)
axes6.set_zlim3d(0, 255)
for ax, ay, az, label in zip(x, y, z, labels):
axes6.text(ax, ay, az, label)
plt.title('Each band represents a dimension.')
plt.show()

# Define outputs
outf = widgets.interactive_output(f, {'p1r': p1r, 'p2r': p2r,'p3r': p3r, 'p1g': p1g, 'p2g': p2g,'p3g': p3g, 'p1b': p1b, 'p2b': p2b,'p3b': p3b})
outg = widgets.interactive_output(g, {'p1r': p1r, 'p2r': p2r,'p3r': p3r, 'p1g': p1g, 'p2g': p2g,'p3g': p3g, 'p1b': p1b, 'p2b': p2b,'p3b': p3b})

outh = widgets.interactive_output(h, {'p1r': p1r, 'p1g': p1g, 'p1b': p1b})
outhh = widgets.interactive_output(hh, {'p2r': p2r, 'p2g': p2g, 'p2b': p2b})
outhhh = widgets.interactive_output(hhh, {'p3r': p3r, 'p3g': p3g, 'p3b': p3b})

outi = widgets.interactive_output(i, {'p1r': p1r, 'p2r': p2r,'p3r': p3r, 'p1g': p1g, 'p2g': p2g,'p3g': p3g, 'p1b': p1b, 'p2b': p2b,'p3b': p3b})
outii = widgets.interactive_output(ii, {'p1r': p1r, 'p2r': p2r,'p3r': p3r, 'p1g': p1g, 'p2g': p2g,'p3g': p3g, 'p1b': p1b, 'p2b': p2b,'p3b': p3b})

outj = widgets.interactive_output(j, {'p1r': p1r, 'p2r': p2r,'p3r': p3r, 'p1g': p1g, 'p2g': p2g,'p3g': p3g, 'p1b': p1b, 'p2b': p2b,'p3b': p3b})

app_output = widgets.HBox([widgets.VBox([widgets.HBox([outh, widgets.VBox([ p1r, p1g, p1b])]), widgets.HBox([outhh, widgets.VBox([p2r, p2g, p2b])]), widgets.HBox([outhhh, widgets.VBox([ p3r, p3g, p3b])])]), widgets.VBox([widgets.HBox([widgets.VBox([outf, outi]), widgets.VBox([outg, outii])]), outj])])

return app_output
2 changes: 1 addition & 1 deletion Tools/dea_tools/app/widgetconstructors.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def create_dea_wms_layer(product, date, **params):
----------
product : string
The Digital Earth Australia product to load
(e.g. 'ga_ls8c_nbart_gm_cyear_3')
(e.g. 'ga_ls8cls9c_gm_cyear_3')
date : string (yyyy-mm-dd format)
The date to load the product for

Expand Down
Loading