From bb450d0b2a3e6db836a25e3df4764b339ed76a1a Mon Sep 17 00:00:00 2001 From: Tisham Dhar Date: Fri, 16 Jul 2021 13:41:58 +0930 Subject: [PATCH 1/3] #795 Add animated NDVI support Signed-off-by: Tisham Dhar --- dev/services/wms/inventory.json | 1 + .../wms/ows_refactored/c3/style_c3_cfg.py | 116 ++++++++++++++++++ 2 files changed, 117 insertions(+) diff --git a/dev/services/wms/inventory.json b/dev/services/wms/inventory.json index c923d002c..68bec7ff6 100644 --- a/dev/services/wms/inventory.json +++ b/dev/services/wms/inventory.json @@ -975,6 +975,7 @@ "true_colour", "false_colour", "ndvi", + "ndvi_animated", "ndwi", "mndwi", "blue", diff --git a/dev/services/wms/ows_refactored/c3/style_c3_cfg.py b/dev/services/wms/ows_refactored/c3/style_c3_cfg.py index 61576e695..df77d0a29 100644 --- a/dev/services/wms/ows_refactored/c3/style_c3_cfg.py +++ b/dev/services/wms/ows_refactored/c3/style_c3_cfg.py @@ -177,6 +177,121 @@ ], } +style_c3_ndvi_anim = { + "name": "ndvi_animated", + "title": "Normalised Difference Vegetation Index (Animated) - Red, NIR", + "abstract": "Normalised Difference Vegetation Index - a derived index that correlates well with the existence of vegetation", + "index_function": { + "function": "datacube_ows.band_utils.norm_diff", + "mapped_bands": True, + "kwargs": {"band1": "nbart_nir", "band2": "nbart_red"}, + }, + "needed_bands": ["nbart_red", "nbart_nir"], + "color_ramp": [ + {"value": -0.0, "color": "#8F3F20", "alpha": 0.0}, + {"value": 0.0, "color": "#8F3F20", "alpha": 1.0}, + {"value": 0.1, "color": "#A35F18"}, + {"value": 0.2, "color": "#B88512"}, + {"value": 0.3, "color": "#CEAC0E"}, + {"value": 0.4, "color": "#E5D609"}, + {"value": 0.5, "color": "#FFFF0C"}, + {"value": 0.6, "color": "#C3DE09"}, + {"value": 0.7, "color": "#88B808"}, + {"value": 0.8, "color": "#529400"}, + {"value": 0.9, "color": "#237100"}, + {"value": 1.0, "color": "#114D04"}, + ], + "pq_masks": [ + { + "band": "oa_fmask", + "enum": 0, + "invert": True, + }, + { + "band": "oa_fmask", + "enum": 2, + "invert": True, + }, + { + "band": "oa_fmask", + "enum": 3, + "invert": True, + }, + { + "band": "land", + "invert": True, + "enum": 1, + }, + ], + "legend": legend_idx_0_1_5ticks, + # Define behaviour(s) for multi-date requests. If not declared, style only supports single-date requests. + "multi_date": [ + # A multi-date handler. Different handlers can be declared for different numbers of dates in a request. + { + # The count range for which this handler is to be used - a tuple of two ints, the smallest and + # largest date counts for which this handler will be used. Required. + "allowed_count_range": [2, 10], + # Preserve user date order + "preserve_user_date_order": True, + # A function, expressed in the standard format as described elsewhere in this example file. + # The function is assumed to take one arguments, an xarray Dataset. + # The function returns an xarray Dataset with a single band, which is the input to the + # colour ramp defined below. + "aggregator_function": { + "function": "datacube_ows.band_utils.multi_date_pass" + }, + "animate" : True, + "color_ramp": [ + {"value": -0.0, "color": "#8F3F20", "alpha": 0.0}, + {"value": 0.0, "color": "#8F3F20", "alpha": 1.0}, + {"value": 0.1, "color": "#A35F18"}, + {"value": 0.2, "color": "#B88512"}, + {"value": 0.3, "color": "#CEAC0E"}, + {"value": 0.4, "color": "#E5D609"}, + {"value": 0.5, "color": "#FFFF0C"}, + {"value": 0.6, "color": "#C3DE09"}, + {"value": 0.7, "color": "#88B808"}, + {"value": 0.8, "color": "#529400"}, + {"value": 0.9, "color": "#237100"}, + {"value": 1.0, "color": "#114D04"}, + ], + "pq_masks": [ + { + "band": "oa_fmask", + "enum": 0, + "invert": True, + }, + { + "band": "oa_fmask", + "enum": 2, + "invert": True, + }, + { + "band": "oa_fmask", + "enum": 3, + "invert": True, + }, + { + "band": "land", + "invert": True, + "enum": 1, + }, + ], + "legend": { + "begin": "-1.0", + "end": "1.0", + "ticks": [ + "-1.0", + "0.0", + "1.0", + ], + }, + # The feature info label for the multi-date index value. + "feature_info_label": "ndvi_animate", + } + ], +} + style_c3_ndwi = { "name": "ndwi", "title": "Normalised Difference Water Index - Green, NIR", @@ -690,6 +805,7 @@ style_c3_true_colour, style_c3_false_colour, style_c3_ndvi, + style_c3_ndvi_anim, style_c3_ndwi, style_c3_mndwi, style_c3_nbr, From 687ea71cb46142a281b1de82ceb9e41626b19902 Mon Sep 17 00:00:00 2001 From: Tisham Dhar Date: Fri, 16 Jul 2021 13:54:27 +0930 Subject: [PATCH 2/3] Make flake8 happy Signed-off-by: Tisham Dhar --- dev/services/wms/ows_refactored/c3/style_c3_cfg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/services/wms/ows_refactored/c3/style_c3_cfg.py b/dev/services/wms/ows_refactored/c3/style_c3_cfg.py index df77d0a29..032197334 100644 --- a/dev/services/wms/ows_refactored/c3/style_c3_cfg.py +++ b/dev/services/wms/ows_refactored/c3/style_c3_cfg.py @@ -240,7 +240,7 @@ "aggregator_function": { "function": "datacube_ows.band_utils.multi_date_pass" }, - "animate" : True, + "animate": True, "color_ramp": [ {"value": -0.0, "color": "#8F3F20", "alpha": 0.0}, {"value": 0.0, "color": "#8F3F20", "alpha": 1.0}, From 692c752fd0dfd35496ac1feb6fb5caa1c88fffa6 Mon Sep 17 00:00:00 2001 From: Tisham Dhar Date: Fri, 16 Jul 2021 14:08:46 +0930 Subject: [PATCH 3/3] Realign inventory Signed-off-by: Tisham Dhar --- dev/services/wms/inventory.json | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/dev/services/wms/inventory.json b/dev/services/wms/inventory.json index 68bec7ff6..391ee445e 100644 --- a/dev/services/wms/inventory.json +++ b/dev/services/wms/inventory.json @@ -902,11 +902,12 @@ "product": [ "ga_ls8c_ard_3" ], - "styles_count": 15, + "styles_count": 16, "styles_list": [ "true_colour", "false_colour", "ndvi", + "ndvi_animated", "ndwi", "mndwi", "blue", @@ -925,11 +926,12 @@ "product": [ "ga_ls7e_ard_3" ], - "styles_count": 14, + "styles_count": 15, "styles_list": [ "true_colour", "false_colour", "ndvi", + "ndvi_animated", "ndwi", "mndwi", "blue", @@ -947,11 +949,12 @@ "product": [ "ga_ls5t_ard_3" ], - "styles_count": 13, + "styles_count": 14, "styles_list": [ "true_colour", "false_colour", "ndvi", + "ndvi_animated", "ndwi", "mndwi", "blue", @@ -970,7 +973,7 @@ "ga_ls7e_ard_3", "ga_ls5t_ard_3" ], - "styles_count": 13, + "styles_count": 14, "styles_list": [ "true_colour", "false_colour",