From a39c1c73c3f3685d27271d9cca4724fb63c641dc Mon Sep 17 00:00:00 2001 From: Oliver Lopez Date: Sun, 3 Mar 2024 15:21:52 +0300 Subject: [PATCH] Custom ET estimation workflow --- geeet/eepredefined/landsat.py | 3 +- geeet/eepredefined/workflows.py | 64 +++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 geeet/eepredefined/workflows.py diff --git a/geeet/eepredefined/landsat.py b/geeet/eepredefined/landsat.py index 0dd8f6d..de2b3b2 100644 --- a/geeet/eepredefined/landsat.py +++ b/geeet/eepredefined/landsat.py @@ -252,6 +252,7 @@ def collection( Returns: ee.ImageCollection """ import ee + from .join import landsat_ecmwf from .parsers import feature_collection region = feature_collection(region) @@ -337,7 +338,7 @@ def collection( .select(*meteo_bands) .map(meteo_prep)) - collection = geeet.eepredefined.join.landsat_ecmwf( + collection = landsat_ecmwf( collection, meteo_collection) # Set ERA5 measuring heights (zU, zT) diff --git a/geeet/eepredefined/workflows.py b/geeet/eepredefined/workflows.py new file mode 100644 index 0000000..49efc67 --- /dev/null +++ b/geeet/eepredefined/workflows.py @@ -0,0 +1,64 @@ +""" +Custom workflows +""" + +def masked_et(cfmaskable_bands, + maskable_bands, + positive_le = True, + NDVI_BARE_GROUND = None, + fvc = None + ): + """ + Custom ET estimation workflow + + 1. Extrapolate LE (W/m²) -> ET (mm/day) + 2. Applies cloud-mask to cfmaskable_bands + 3. Adds the "feature_area" pixelArea band. + 4. Adds the "unobserved_area" pixelArea band. + + If positive_le is set to True: + 5. Adds a "positive_le_mask" + 6. Applies the "positive_le_mask" to maskable_bands + + If NDVI_BARE_GROUND is not None: + 7. Adds "vegetation_mask" + 8. Applies the "vegetation_mask" to maskable_bands + 9. Adds the "observed_vegetation_area" band. + + If fvc is not None: + 10. Adds the fractional vegetation cover (fvc) band. + 11. Adds the "unobserved_vegetation_area" band. + """ + from . import landsat + from . import pixel_area + from . import masks + + cfmask = landsat.cfmask(cfmaskable_bands) + lemask = masks.apply_static_mask("positive_le_mask", maskable_bands) + vegmask = masks.apply_static_mask("vegetation_mask", maskable_bands) + add_veg_mask = masks.Fndvi_mask(NDVI_BARE_GROUND) + add_fvc = masks.Ffvc(fvc) + + workflow = [landsat.extrapolate_LE, + cfmask, + pixel_area.feature_area, + pixel_area.unobserved_area + ] + + if positive_le: + workflow = workflow + [ + masks.positive_LE_mask, lemask + ] + + if NDVI_BARE_GROUND: + workflow = workflow + [ + add_veg_mask, vegmask, + pixel_area.observed_veg_area + ] + + if fvc: + workflow = workflow + [ + add_fvc, pixel_area.unobserved_veg_area, + ] + + return workflow \ No newline at end of file