From d738a6cba484540a850308325d25b18a8f18dbe7 Mon Sep 17 00:00:00 2001 From: Robbi Bishop-Taylor Date: Tue, 16 Jul 2024 05:52:42 +0000 Subject: [PATCH 1/4] Add multidate handling --- .../intertidal_c3/style_intertidal_cfg.py | 27 +++++++++++++++++++ .../intertidal_c3/utils_intertidal.py | 9 +++++++ 2 files changed, 36 insertions(+) diff --git a/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/style_intertidal_cfg.py b/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/style_intertidal_cfg.py index bc00d6299..0c282ec22 100644 --- a/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/style_intertidal_cfg.py +++ b/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/style_intertidal_cfg.py @@ -163,6 +163,33 @@ "hot": "ta_hot", }, }, + "multi_date": [ + { + "allowed_count_range": [2, 2], + "animate": False, + "preserve_user_date_order": True, + "pass_raw_data": True, + "aggregator_function": { + "function": "ows_refactored.sea_ocean_coast.intertidal_c3.utils_intertidal.multi_date_raw_elevation", + "mapped_bands": True, + "kwargs": { + "band": "elevation", + } + }, + "mpl_ramp": "RdBu", + "range": [-0.5, 0.5], + "legend": { + "begin": "-0.5", + "end": "0.5", + "ticks": [ + "-0.5", + "0.0", + "0.5", + ] + }, + "feature_info_label": "elevation_difference", + }, + ], "include_in_feature_info": False, "needed_bands": ["elevation", "ta_lot", "ta_hot"], "mpl_ramp": "viridis", diff --git a/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py b/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py index c75adf353..a63847a3e 100644 --- a/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py +++ b/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py @@ -41,3 +41,12 @@ def uncertainty_adaptive(data, band, lot, hot, band_mapper=None): proportion_array = data[band] / otr return proportion_array + + +def multi_date_raw_elevation(data, band, band_mapper=None): + """ + Compares two elevation layers and calculates difference in elevation. + """ + data1, data2 = (data.sel(time=dt) for dt in data.coords["time"].values) + + return data2[band] - data1[band] From 472f08a9aa95831ded877cf98816ccf4fd9bf453 Mon Sep 17 00:00:00 2001 From: Robbi Bishop-Taylor Date: Tue, 16 Jul 2024 16:02:47 +1000 Subject: [PATCH 2/4] Update utils_intertidal.py --- .../sea_ocean_coast/intertidal_c3/utils_intertidal.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py b/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py index a63847a3e..41c7ebde5 100644 --- a/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py +++ b/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py @@ -47,6 +47,9 @@ def multi_date_raw_elevation(data, band, band_mapper=None): """ Compares two elevation layers and calculates difference in elevation. """ + if date_mapper is not None: + band = band_mapper(band) + data1, data2 = (data.sel(time=dt) for dt in data.coords["time"].values) return data2[band] - data1[band] From 8f1429a1adb1d128050db500fc9d011fb5d54e02 Mon Sep 17 00:00:00 2001 From: Robbi Bishop-Taylor Date: Tue, 16 Jul 2024 16:28:01 +1000 Subject: [PATCH 3/4] Fix code --- .../sea_ocean_coast/intertidal_c3/utils_intertidal.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py b/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py index 41c7ebde5..fcd46b3cb 100644 --- a/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py +++ b/dev/services/wms/ows_refactored/sea_ocean_coast/intertidal_c3/utils_intertidal.py @@ -47,9 +47,9 @@ def multi_date_raw_elevation(data, band, band_mapper=None): """ Compares two elevation layers and calculates difference in elevation. """ - if date_mapper is not None: + if band_mapper is not None: band = band_mapper(band) - + data1, data2 = (data.sel(time=dt) for dt in data.coords["time"].values) return data2[band] - data1[band] From 80406834163b28770b2707e77b0c62f3321fc23a Mon Sep 17 00:00:00 2001 From: Robbi Bishop-Taylor Date: Tue, 16 Jul 2024 16:57:04 +1000 Subject: [PATCH 4/4] Update terria-cube-v8.json --- dev/terria/terria-cube-v8.json | 1 + 1 file changed, 1 insertion(+) diff --git a/dev/terria/terria-cube-v8.json b/dev/terria/terria-cube-v8.json index da1d482f3..45683a4a9 100644 --- a/dev/terria/terria-cube-v8.json +++ b/dev/terria/terria-cube-v8.json @@ -1093,6 +1093,7 @@ "linkedWcsUrl": "https://ows.dea.ga.gov.au/", "linkedWcsCoverage": "ga_s2ls_intertidal_cyear_3", "dateFormat": "'Year: 'yyyy", + "availableDiffStyles": ["intertidal_elevation_adaptive"], "leafletUpdateInterval": 750, "tileErrorHandlingOptions": { "ignoreUnknownTileErrors": true