diff --git a/notebooks/AI4FOOD_PeakValley_Detection_NDVI_S2/peakvalley_detection.ipynb b/notebooks/AI4FOOD_PeakValley_Detection_NDVI_S2/peakvalley_detection.ipynb index e2334f1..5afdba5 100644 --- a/notebooks/AI4FOOD_PeakValley_Detection_NDVI_S2/peakvalley_detection.ipynb +++ b/notebooks/AI4FOOD_PeakValley_Detection_NDVI_S2/peakvalley_detection.ipynb @@ -1333,12 +1333,22 @@ "outputs": [], "source": [ "# download the data if it doesn't exist yet\n", - "\n", + "scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\"])\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + " bands=[\"B04\", \"B08\"])\n", + "s2 = s2.mask(cloud_mask)\n", "ndvi_cube = s2.ndvi(red=\"B04\", nir=\"B08\", target_band='NDVI')\n", "\n", "if not os.path.exists('./s2_meadow.nc'):\n", diff --git a/notebooks/AI4FOOD_Whittaker_OpenEO_NDVI_S2.ipynb b/notebooks/AI4FOOD_Whittaker_OpenEO_NDVI_S2.ipynb index 88dc85c..ed08623 100644 --- a/notebooks/AI4FOOD_Whittaker_OpenEO_NDVI_S2.ipynb +++ b/notebooks/AI4FOOD_Whittaker_OpenEO_NDVI_S2.ipynb @@ -94,11 +94,22 @@ "metadata": {}, "outputs": [], "source": [ + "scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\",\"B08\",\"SCL\"])\n", - "s2_cloudmasked = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + " bands=[\"B04\",\"B08\"])\n", + "s2_cloudmasked = s2.mask(cloud_mask)\n", "ndvi_cube = s2.ndvi(red=\"B04\", nir=\"B08\")\n", "ndvi_cube_cloudmasked = s2_cloudmasked.ndvi(red=\"B04\", nir=\"B08\")" ] @@ -332,4 +343,4 @@ }, "nbformat": 4, "nbformat_minor": 5 -} \ No newline at end of file +} diff --git a/notebooks/Local/FuseTS - MOGPR.ipynb b/notebooks/Local/FuseTS - MOGPR.ipynb index bc45741..78d5ac9 100644 --- a/notebooks/Local/FuseTS - MOGPR.ipynb +++ b/notebooks/Local/FuseTS - MOGPR.ipynb @@ -215,11 +215,22 @@ "VV = s1_asc.band(\"VV\")\n", "rvi_asc_cube = (VH + VH) / (VV + VH)\n", "\n", + "scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\"])\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + " bands=[\"B04\", \"B08\"])\n", + "s2 = s2.mask(cloud_mask=cloud_mask)\n", "ndvi_cube = s2.ndvi(red=\"B04\", nir=\"B08\")" ] }, diff --git a/notebooks/Local/FuseTS - Peak Valley Detection.ipynb b/notebooks/Local/FuseTS - Peak Valley Detection.ipynb index 5f8245b..4e9bebf 100644 --- a/notebooks/Local/FuseTS - Peak Valley Detection.ipynb +++ b/notebooks/Local/FuseTS - Peak Valley Detection.ipynb @@ -57,7 +57,8 @@ "More information on the usage of openEO's Python client can be found on [GitHub](https://github.com/Open-EO/openeo-python-client).\n", "\n", "The first step is to connect to an openEO compatible backend.\n" - ] + ], + "id": "ccc826d7e3e794ad" }, { "cell_type": "code", @@ -74,14 +75,16 @@ ], "source": [ "connection = openeo.connect(\"openeo.vito.be\").authenticate_oidc()" - ] + ], + "id": "e6ad5560fc9b30dc" }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next we define the area of interest, in this case an extent, for which we would like to fetch time series data.\n" - ] + ], + "id": "efbacd1f48fedc4a" }, { "cell_type": "code", @@ -98,14 +101,16 @@ ")\n", "spat_ext = dict(west=minx, east=maxx, north=maxy, south=miny, crs=4326)\n", "temp_ext = [\"2021-01-01\", \"2021-12-31\"]" - ] + ], + "id": "10a0472a737b4773" }, { "cell_type": "markdown", "metadata": {}, "source": [ "We will create an openEO process to calculate the NDVI time series for our area of interest. We'll begin by using the SENTINEL2_L2A_SENTINELHUB collection, and apply a cloud masking algorithm to remove any interfering clouds before calculating the NDVI values.\n" - ] + ], + "id": "df3ee7d1a70f77ee" }, { "cell_type": "code", @@ -114,22 +119,37 @@ "outputs": [], "source": [ "# define openEO pipeline\n", + "scl = connection.load_collection(\n", + " \"SENTINEL2_L2A_SENTINELHUB\",\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"],\n", + ")\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection(\n", " \"SENTINEL2_L2A_SENTINELHUB\",\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\"],\n", + " bands=[\"B04\", \"B08\"],\n", ")\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + "s2 = s2.mask(cloud_mask)\n", "ndvi_cube = s2.ndvi(red=\"B04\", nir=\"B08\", target_band=\"NDVI\")" - ] + ], + "id": "5d862b567ae6f299" }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now that we have calculated the NDVI time series for our area of interest, we can request openEO to download the result to our local storage. This will allow us to access the file and use it for further analysis in this notebook. However, if we have already downloaded the file, we can use the existing time series to continue our analysis without the need for a new download.\n" - ] + ], + "id": "d7c22a63e09838e8" }, { "cell_type": "code", @@ -174,7 +194,8 @@ "metadata": {}, "source": [ "### Plot Image Chips Across Time\n" - ] + ], + "id": "63390c062b62fadc" }, { "cell_type": "code", @@ -209,14 +230,16 @@ " ax.set_title(img.t.dt.date.to_numpy())\n", "\n", "plt.tight_layout()" - ] + ], + "id": "efc69fe5bfb141e5" }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Plot Time Series for Specific Polygon Area\n" - ] + ], + "id": "a7ed4de53954b38f" }, { "cell_type": "code", @@ -258,7 +281,8 @@ "ax.plot(*np.array(geometry[\"coordinates\"][0]).T, \"C3\", lw=2, ls=\"dashed\")\n", "ax.set_title(ndvi_filtered.isel(t=7).t.dt.date.to_numpy())\n", "ax.set_aspect(\"auto\")" - ] + ], + "id": "b09851b79009b1f3" }, { "cell_type": "code", @@ -299,7 +323,8 @@ "ax.imshow(ndvi_masked.isel(t=7), extent=[minx, maxx, miny, maxy])\n", "ax.set_title(ndvi_masked.isel(t=7).t.dt.date.to_numpy())\n", "ax.set_aspect(\"auto\")" - ] + ], + "id": "26f11754efa62e6b" }, { "cell_type": "code", @@ -356,7 +381,8 @@ "ax.plot([], [], \"C0\", label=\"NDVI series of random pixels\")\n", "ax.axvspan(None, None, color=\"C3\", alpha=0.5, label=\"Detected peak-valley events\")\n", "ax.legend()" - ] + ], + "id": "1546c3e816acc487" } ], "metadata": { diff --git a/notebooks/Local/FuseTS - Peak Valley Detection_holoviews.ipynb b/notebooks/Local/FuseTS - Peak Valley Detection_holoviews.ipynb index f6394c7..7393b37 100644 --- a/notebooks/Local/FuseTS - Peak Valley Detection_holoviews.ipynb +++ b/notebooks/Local/FuseTS - Peak Valley Detection_holoviews.ipynb @@ -1469,13 +1469,26 @@ "metadata": {}, "outputs": [], "source": [ + "scl = connection.load_collection(\n", + " \"SENTINEL2_L2A_SENTINELHUB\",\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"],\n", + ")\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection(\n", " \"SENTINEL2_L2A_SENTINELHUB\",\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\"],\n", + " bands=[\"B04\", \"B08\"],\n", ")\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + "s2 = s2.mask(cloud_mask)\n", "ndvi_cube = s2.ndvi(red=\"B04\", nir=\"B08\", target_band=\"NDVI\")" ] }, diff --git a/notebooks/Local/FuseTS - Phenology.ipynb b/notebooks/Local/FuseTS - Phenology.ipynb index 07bcd87..455de09 100644 --- a/notebooks/Local/FuseTS - Phenology.ipynb +++ b/notebooks/Local/FuseTS - Phenology.ipynb @@ -159,11 +159,22 @@ }, "outputs": [], "source": [ + "scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\",\"B08\",\"SCL\"])\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + " bands=[\"B04\",\"B08\"])\n", + "s2 = s2.mask(cloud_mask)\n", "s2 = s2.mask_polygon(spat_ext)\n", "ndvi_cube = s2.ndvi(red=\"B04\", nir=\"B08\", target_band='NDVI')" ] diff --git a/notebooks/Local/FuseTS - Whittaker Smoothing.ipynb b/notebooks/Local/FuseTS - Whittaker Smoothing.ipynb index 721579e..0dcaea1 100644 --- a/notebooks/Local/FuseTS - Whittaker Smoothing.ipynb +++ b/notebooks/Local/FuseTS - Whittaker Smoothing.ipynb @@ -857,11 +857,22 @@ }, "outputs": [], "source": [ + "scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B02\", \"B03\", \"B04\",\"SCL\"])\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + " bands=[\"B02\", \"B03\", \"B04\"])\n", + "s2 = s2.mask(cloud_mask)\n", "\n", "B02 = s2.band('B02')\n", "B03 = s2.band('B03')\n", diff --git a/notebooks/MOGPR Process Chain Demo.ipynb b/notebooks/MOGPR Process Chain Demo.ipynb index 7ef5a67..b126f7a 100644 --- a/notebooks/MOGPR Process Chain Demo.ipynb +++ b/notebooks/MOGPR Process Chain Demo.ipynb @@ -89,11 +89,22 @@ "VV = s1_asc.band(\"VV\")\n", "rvi_asc_cube = (VH + VH) / (VV + VH)\n", "\n", + "scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\",\"B08\",\"SCL\"])\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + " bands=[\"B04\",\"B08\"])\n", + "s2 = s2.mask(cloud_mask)\n", "ndvi_cube = s2.ndvi(red=\"B04\", nir=\"B08\")" ] }, diff --git a/notebooks/OpenEO/FuseTS - MOGPR Multi Source Fusion.ipynb b/notebooks/OpenEO/FuseTS - MOGPR Multi Source Fusion.ipynb index cb03ef9..3b56e30 100644 --- a/notebooks/OpenEO/FuseTS - MOGPR Multi Source Fusion.ipynb +++ b/notebooks/OpenEO/FuseTS - MOGPR Multi Source Fusion.ipynb @@ -67,8 +67,8 @@ "Requirement already satisfied: packaging>=21.3 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from xarray>=0.12.3->openeo) (23.1)\n", "Requirement already satisfied: six>=1.5 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from python-dateutil>=2.8.2->pandas>0.20.0->openeo) (1.16.0)\n", "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m24.0\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m24.0\u001B[0m\n", + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\n" ] } ], @@ -279,11 +279,22 @@ "metadata": {}, "outputs": [], "source": [ + "scl = connection.load_collection('SENTINEL2_L2A',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "base_s2 = connection.load_collection('SENTINEL2_L2A',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\"])\n", - "base_s2 = base_s2.process(\"mask_scl_dilation\", data=base_s2, scl_band_name=\"SCL\")\n", + " bands=[\"B04\", \"B08\"])\n", + "base_s2 = base_s2.mask(cloud_mask)\n", "base_s2 = base_s2.ndvi(red=\"B04\", nir=\"B08\", target_band='NDVI')\n", "base_s2 = base_s2.filter_bands(bands=['NDVI'])\n", "base_s2 = base_s2.mask_polygon(spat_ext)" diff --git a/notebooks/OpenEO/FuseTS - MOGPR.ipynb b/notebooks/OpenEO/FuseTS - MOGPR.ipynb index 5ceaf48..94bb65a 100644 --- a/notebooks/OpenEO/FuseTS - MOGPR.ipynb +++ b/notebooks/OpenEO/FuseTS - MOGPR.ipynb @@ -160,11 +160,22 @@ "metadata": {}, "outputs": [], "source": [ + "scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "base = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\"])\n", - "base_cloudmasked = base.process(\"mask_scl_dilation\", data=base, scl_band_name=\"SCL\")\n", + " bands=[\"B04\", \"B08\"])\n", + "base_cloudmasked = base.mask(cloud_mask)\n", "base_ndvi = base_cloudmasked.ndvi(red=\"B04\", nir=\"B08\")" ] }, diff --git a/notebooks/OpenEO/FuseTS - Peak Valley Detection.ipynb b/notebooks/OpenEO/FuseTS - Peak Valley Detection.ipynb index 8d0ff43..0bb377b 100644 --- a/notebooks/OpenEO/FuseTS - Peak Valley Detection.ipynb +++ b/notebooks/OpenEO/FuseTS - Peak Valley Detection.ipynb @@ -178,11 +178,22 @@ }, "outputs": [], "source": [ + "scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\"])\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + " bands=[\"B04\", \"B08\"])\n", + "s2 = s2.mask(cloud_mask)\n", "base_ndvi = s2.ndvi(red=\"B04\", nir=\"B08\", target_band='NDVI').band('NDVI')" ] }, diff --git a/notebooks/OpenEO/FuseTS - Phenology.ipynb b/notebooks/OpenEO/FuseTS - Phenology.ipynb index df9e45d..a928fa1 100644 --- a/notebooks/OpenEO/FuseTS - Phenology.ipynb +++ b/notebooks/OpenEO/FuseTS - Phenology.ipynb @@ -130,11 +130,22 @@ "metadata": {}, "outputs": [], "source": [ + "scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\"])\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + " bands=[\"B04\", \"B08\"])\n", + "s2 = s2.mask(cloud_mask)\n", "s2 = s2.mask_polygon(spat_ext)\n", "base_ndvi = s2.ndvi(red=\"B04\", nir=\"B08\")" ] diff --git a/notebooks/OpenEO/FuseTS - Whittaker.ipynb b/notebooks/OpenEO/FuseTS - Whittaker.ipynb index 915cff2..16a3f52 100644 --- a/notebooks/OpenEO/FuseTS - Whittaker.ipynb +++ b/notebooks/OpenEO/FuseTS - Whittaker.ipynb @@ -172,11 +172,22 @@ "metadata": {}, "outputs": [], "source": [ + "scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"])\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "base = connection.load_collection('SENTINEL2_L2A_SENTINELHUB',\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\"])\n", - "base_cloudmasked = base.process(\"mask_scl_dilation\", data=base, scl_band_name=\"SCL\")\n", + " bands=[\"B04\", \"B08\"])\n", + "base_cloudmasked = base.mask(cloud_mask)\n", "base_ndvi = base_cloudmasked.ndvi(red=\"B04\", nir=\"B08\")" ] }, diff --git a/src/fusets/openeo/__init__.py b/src/fusets/openeo/__init__.py index e9adada..24cb8e1 100644 --- a/src/fusets/openeo/__init__.py +++ b/src/fusets/openeo/__init__.py @@ -72,10 +72,20 @@ def load_xarray(collection_id, spatial_extent, temporal_extent, properties=None, if openeo_connection == None: openeo_connection = openeo.connect("openeo.cloud").authenticate_oidc() print(spatial_extent) + scl = openeo_connection.load_collection( + collection_id, temporal_extent=temporal_extent, bands=["SCL"] + ).filter_bbox(spatial_extent) + cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) data = openeo_connection.load_collection( - collection_id, temporal_extent=temporal_extent, bands=["B02", "B03", "B04", "SCL"] + collection_id, temporal_extent=temporal_extent, bands=["B02", "B03", "B04"] ).filter_bbox(spatial_extent) - data = data.process("mask_scl_dilation", data=data, scl_band_name="SCL") + data = data.mask(cloud_mask) job = data.execute_batch(out_format="netCDF") results = job.get_results() base_path = Path(job.job_id) diff --git a/src/fusets/openeo/services/descriptions/mogpr.md b/src/fusets/openeo/services/descriptions/mogpr.md index e407284..92e28b4 100644 --- a/src/fusets/openeo/services/descriptions/mogpr.md +++ b/src/fusets/openeo/services/descriptions/mogpr.md @@ -29,11 +29,22 @@ service = 'mogpr' namespace = 'u:fusets' ## Creation of the base NDVI data cube upon which the mogpr is executed +scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB', + spatial_extent=spat_ext, + temporal_extent=temp_ext, + bands=["SCL"]) +cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB', spatial_extent=spat_ext, temporal_extent=temp_ext, - bands=["B04", "B08", "SCL"]) -s2 = s2.process("mask_scl_dilation", data=s2, scl_band_name="SCL") + bands=["B04", "B08"]) +s2 = s2.mask(cloud_mask) base_ndvi = s2.ndvi(red="B04", nir="B08", target_band='NDVI').band('NDVI') ## Creation mogpr data cube diff --git a/src/fusets/openeo/services/descriptions/peakvalley.md b/src/fusets/openeo/services/descriptions/peakvalley.md index adaa3b0..5086250 100644 --- a/src/fusets/openeo/services/descriptions/peakvalley.md +++ b/src/fusets/openeo/services/descriptions/peakvalley.md @@ -23,11 +23,22 @@ service = 'peakvalley' namespace = 'u:fusets' ## Creation of the base NDVI data cube upon which the peak valley detection is executed +scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB', + spatial_extent=spat_ext, + temporal_extent=temp_ext, + bands=["SCL"]) +cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB', spatial_extent=spat_ext, temporal_extent=temp_ext, - bands=["B04", "B08", "SCL"]) -s2 = s2.process("mask_scl_dilation", data=s2, scl_band_name="SCL") + bands=["B04", "B08"]) +s2 = s2.mask(cloud_mask) base_ndvi = s2.ndvi(red="B04", nir="B08", target_band='NDVI').band('NDVI') ## Creation peak valley detection data cube diff --git a/src/fusets/openeo/services/descriptions/phenology.md b/src/fusets/openeo/services/descriptions/phenology.md index 6420439..eae0006 100644 --- a/src/fusets/openeo/services/descriptions/phenology.md +++ b/src/fusets/openeo/services/descriptions/phenology.md @@ -56,11 +56,22 @@ namespace = 'u:fusets' ## Setup of the base NDVI data cube upon which to execute the phenology calculation. ## To improve results, a smoothed data cube can be constructed. +scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB', + spatial_extent=spat_ext, + temporal_extent=temp_ext, + bands=["SCL"]) +cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) s2 = connection.load_collection('SENTINEL2_L2A_SENTINELHUB', spatial_extent=spat_ext, temporal_extent=temp_ext, - bands=["B04", "B08", "SCL"]) -s2 = s2.process("mask_scl_dilation", data=s2, scl_band_name="SCL") + bands=["B04", "B08"]) +s2 = s2.mask(cloud_mask) s2 = s2.mask_polygon(spat_ext) base_ndvi = s2.ndvi(red="B04", nir="B08") diff --git a/src/fusets/openeo/services/descriptions/whittaker.md b/src/fusets/openeo/services/descriptions/whittaker.md index 9bbc685..7a984e7 100644 --- a/src/fusets/openeo/services/descriptions/whittaker.md +++ b/src/fusets/openeo/services/descriptions/whittaker.md @@ -61,11 +61,22 @@ service = 'whittaker' namespace = 'u:fusets' ## Create a base NDVI datacube that can be used as input for the service +scl = connection.load_collection('SENTINEL2_L2A_SENTINELHUB', + spatial_extent=spat_ext, + temporal_extent=temp_ext, + bands=["SCL"]) +cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) base = connection.load_collection('SENTINEL2_L2A_SENTINELHUB', spatial_extent=spat_ext, temporal_extent=temp_ext, - bands=["B04", "B08", "SCL"]) -base_cloudmasked = base.process("mask_scl_dilation", data=base, scl_band_name="SCL") + bands=["B04", "B08"]) +base_cloudmasked = base.mask(cloud_mask) base_ndvi = base_cloudmasked.ndvi(red="B04", nir="B08") ## Create a processing graph from the Whittaker process using an active openEO connection diff --git a/src/fusets/openeo/services/publish_mogpr.py b/src/fusets/openeo/services/publish_mogpr.py index 03a51f8..d0791da 100644 --- a/src/fusets/openeo/services/publish_mogpr.py +++ b/src/fusets/openeo/services/publish_mogpr.py @@ -29,10 +29,20 @@ def execute_udf(): temp_ext = ["2023-01-01", "2023-03-31"] # Setup NDVI cube + scl = connection.load_collection( + "SENTINEL2_L2A", spatial_extent=spat_ext, temporal_extent=temp_ext, bands=["SCL"] + ) + cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) base_s2 = connection.load_collection( - "SENTINEL2_L2A", spatial_extent=spat_ext, temporal_extent=temp_ext, bands=["B04", "B08", "SCL"] + "SENTINEL2_L2A", spatial_extent=spat_ext, temporal_extent=temp_ext, bands=["B04", "B08"] ) - base_s2 = base_s2.process("mask_scl_dilation", data=base_s2, scl_band_name="SCL") + base_s2 = base_s2.mask(cloud_mask) base_s2 = base_s2.ndvi(red="B04", nir="B08", target_band="NDVI") base_s2 = base_s2.filter_bands(bands=["NDVI"]) base_s2 = base_s2.mask_polygon(spat_ext) diff --git a/src/fusets/openeo/services/publish_mogpr_s1_s2.py b/src/fusets/openeo/services/publish_mogpr_s1_s2.py index eddaae9..e43c153 100644 --- a/src/fusets/openeo/services/publish_mogpr_s1_s2.py +++ b/src/fusets/openeo/services/publish_mogpr_s1_s2.py @@ -151,10 +151,20 @@ def _load_ndvi(connection, polygon, date): :param date: :return: """ + scl = connection.load_collection( + "SENTINEL2_L2A", spatial_extent=polygon, temporal_extent=date, bands=["SCL"] + ) + cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) base_s2 = connection.load_collection( - "SENTINEL2_L2A", spatial_extent=polygon, temporal_extent=date, bands=["B04", "B08", "SCL"] + "SENTINEL2_L2A", spatial_extent=polygon, temporal_extent=date, bands=["B04", "B08"] ) - base_s2 = base_s2.process("mask_scl_dilation", data=base_s2, scl_band_name="SCL") + base_s2 = base_s2.mask(cloud_mask) ndvi = base_s2.ndvi(red="B04", nir="B08", target_band="NDVI") ndvi = ndvi.filter_bands(bands=["NDVI"]) return ndvi.mask_polygon(polygon) @@ -182,13 +192,26 @@ def _load_evi(connection, polygon, date): :param date: Time of interest :return: """ + scl = connection.load_collection( + collection_id="SENTINEL2_L2A", + spatial_extent=polygon, + temporal_extent=date, + bands=["SCL"], + ) + cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) base_s2 = connection.load_collection( collection_id="SENTINEL2_L2A", spatial_extent=polygon, temporal_extent=date, - bands=["B02", "B04", "B08", "SCL"], + bands=["B02", "B04", "B08"], ) - base_s2 = base_s2.process("mask_scl_dilation", data=base_s2, scl_band_name="SCL") + base_s2 = base_s2.mask(cloud_mask) B02 = base_s2.band("B04") B04 = base_s2.band("B04") diff --git a/src/fusets/openeo/services/publish_phenology.py b/src/fusets/openeo/services/publish_phenology.py index 2851198..a7acc94 100644 --- a/src/fusets/openeo/services/publish_phenology.py +++ b/src/fusets/openeo/services/publish_phenology.py @@ -50,10 +50,20 @@ def test_udf(): } temp_ext = ["2022-01-01", "2022-12-31"] smoothing_lambda = 10000 + scl = connection.load_collection( + "SENTINEL2_L2A_SENTINELHUB", spatial_extent=spat_ext, temporal_extent=temp_ext, bands=["SCL"] + ) + cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) base = connection.load_collection( - "SENTINEL2_L2A_SENTINELHUB", spatial_extent=spat_ext, temporal_extent=temp_ext, bands=["B04", "B08", "SCL"] + "SENTINEL2_L2A_SENTINELHUB", spatial_extent=spat_ext, temporal_extent=temp_ext, bands=["B04", "B08"] ) - base_cloudmasked = base.process("mask_scl_dilation", data=base, scl_band_name="SCL") + base_cloudmasked = base.mask(cloud_mask) base_ndvi = base_cloudmasked.ndvi(red="B04", nir="B08") phenology = base_ndvi.apply_dimension( process=lambda x: run_udf(x, udf=load_phenology_udf(), runtime="Python"), diff --git a/tests/conftest.py b/tests/conftest.py index 693b715..e7d9607 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -112,11 +112,20 @@ def wetland_sentinel2_ndvi(areas): import openeo openeo_connection = openeo.connect("openeo-dev.vito.be").authenticate_oidc() - + scl = openeo_connection.load_collection( + "SENTINEL2_L2A", temporal_extent=("2020-01-01", "2021-01-01"), bands=["SCL"] + ).filter_bbox(areas["wetland"]) + cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) data = openeo_connection.load_collection( - "SENTINEL2_L2A", temporal_extent=("2020-01-01", "2021-01-01"), bands=["B08", "B04", "SCL"] + "SENTINEL2_L2A", temporal_extent=("2020-01-01", "2021-01-01"), bands=["B08", "B04"] ).filter_bbox(areas["wetland"]) - data = data.process("mask_scl_dilation", data=data, scl_band_name="SCL") + data = data.mask(cloud_mask) return data.ndvi(nir="B08", red="B04") diff --git a/tests/fusets_openeo_tests/test_performance.py b/tests/fusets_openeo_tests/test_performance.py index e3124ac..2edd443 100644 --- a/tests/fusets_openeo_tests/test_performance.py +++ b/tests/fusets_openeo_tests/test_performance.py @@ -41,13 +41,26 @@ def start_job(data, context: dict, **kwargs) -> openeo.BatchJob: **context["jobinfo"], ) else: + scl = connection.load_collection( + "SENTINEL2_L2A", + spatial_extent=aoi, + temporal_extent=context["params"]["temp-ext"], + bands=["SCL"], + ) + cloud_mask = scl.process( + "to_scl_dilation_mask", + data=scl, + kernel1_size=17, kernel2_size=77, + mask1_values=[2, 4, 5, 6, 7], + mask2_values=[3, 8, 9, 10, 11], + erosion_kernel_size=3) base = connection.load_collection( "SENTINEL2_L2A", spatial_extent=aoi, temporal_extent=context["params"]["temp-ext"], - bands=["B04", "B08", "SCL"], + bands=["B04", "B08"], ) - base_cloudmasked = base.process("mask_scl_dilation", data=base, scl_band_name="SCL") + base_cloudmasked = base.mask(cloud_mask) base_ndvi = base_cloudmasked.ndvi(red="B04", nir="B08") service_dc = connection.datacube_from_process(data=base_ndvi, **context["jobinfo"]) diff --git a/workshops/BIDS/workshop/BiDS_Tutorial_FuseTS.ipynb b/workshops/BIDS/workshop/BiDS_Tutorial_FuseTS.ipynb index 1d3044f..6e87fb7 100644 --- a/workshops/BIDS/workshop/BiDS_Tutorial_FuseTS.ipynb +++ b/workshops/BIDS/workshop/BiDS_Tutorial_FuseTS.ipynb @@ -68,13 +68,13 @@ "Requirement already satisfied: numpy==1.23.5 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (1.23.5)\n", "Requirement already satisfied: cython in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (3.0.0)\n", "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.3.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m23.3.1\u001B[0m\n", + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\n", "Processing /Users/bramjanssen/projects/vito/FuseTS\n", - " Installing build dependencies ... \u001b[?25ldone\n", - "\u001b[?25h Getting requirements to build wheel ... \u001b[?25ldone\n", - "\u001b[?25h Preparing metadata (pyproject.toml) ... \u001b[?25ldone\n", - "\u001b[?25hRequirement already satisfied: xarray>=0.20.2 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from fusets==2.0.2a1) (2023.1.0)\n", + " Installing build dependencies ... \u001B[?25ldone\n", + "\u001B[?25h Getting requirements to build wheel ... \u001B[?25ldone\n", + "\u001B[?25h Preparing metadata (pyproject.toml) ... \u001B[?25ldone\n", + "\u001B[?25hRequirement already satisfied: xarray>=0.20.2 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from fusets==2.0.2a1) (2023.1.0)\n", "Requirement already satisfied: vam.whittaker==2.0.2 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from fusets==2.0.2a1) (2.0.2)\n", "Requirement already satisfied: matplotlib>=3.3.4 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from fusets==2.0.2a1) (3.7.2)\n", "Requirement already satisfied: lcmap-pyccd==2021.7.19 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from fusets==2.0.2a1) (2021.7.19)\n", @@ -111,8 +111,8 @@ "Requirement already satisfied: threadpoolctl>=2.0.0 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from scikit-learn>=0.18->lcmap-pyccd==2021.7.19->fusets==2.0.2a1) (3.2.0)\n", "Requirement already satisfied: joblib>=1.1.1 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from scikit-learn>=0.18->lcmap-pyccd==2021.7.19->fusets==2.0.2a1) (1.3.2)\n", "Building wheels for collected packages: fusets\n", - " Building wheel for fusets (pyproject.toml) ... \u001b[?25ldone\n", - "\u001b[?25h Created wheel for fusets: filename=fusets-2.0.2a1-py3-none-any.whl size=50107 sha256=388a609844113d072d217e270fe817a18c922e37692d4e695057d1019c8ea04b\n", + " Building wheel for fusets (pyproject.toml) ... \u001B[?25ldone\n", + "\u001B[?25h Created wheel for fusets: filename=fusets-2.0.2a1-py3-none-any.whl size=50107 sha256=388a609844113d072d217e270fe817a18c922e37692d4e695057d1019c8ea04b\n", " Stored in directory: /private/var/folders/50/09_2zmx12zj6ks4fdl4y9wgc0000gn/T/pip-ephem-wheel-cache-ndrdi4kc/wheels/b6/19/a9/92d4c884045c0183e2ee3ed4eee80cb741354972e677065ddb\n", "Successfully built fusets\n", "Installing collected packages: fusets\n", @@ -122,8 +122,8 @@ " Successfully uninstalled fusets-2.0.2a1\n", "Successfully installed fusets-2.0.2a1\n", "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.3.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n", + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m23.3.1\u001B[0m\n", + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\n", "Requirement already satisfied: ipyleaflet in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (0.17.3)\n", "Requirement already satisfied: dask in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from -r requirements.txt (line 2)) (2023.5.0)\n", "Requirement already satisfied: netCDF4 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from -r requirements.txt (line 3)) (1.6.4)\n", @@ -171,8 +171,8 @@ "Requirement already satisfied: executing>=1.2.0 in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from stack-data->ipython>=6.1.0->ipywidgets<9,>=7.6.0->ipyleaflet->-r requirements.txt (line 1)) (1.2.0)\n", "Requirement already satisfied: six in /Users/bramjanssen/projects/vito/FuseTS/venv_clean_v2/lib/python3.8/site-packages (from asttokens>=2.1.0->stack-data->ipython>=6.1.0->ipywidgets<9,>=7.6.0->ipyleaflet->-r requirements.txt (line 1)) (1.16.0)\n", "\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m A new release of pip available: \u001b[0m\u001b[31;49m22.3.1\u001b[0m\u001b[39;49m -> \u001b[0m\u001b[32;49m23.3.1\u001b[0m\n", - "\u001b[1m[\u001b[0m\u001b[34;49mnotice\u001b[0m\u001b[1;39;49m]\u001b[0m\u001b[39;49m To update, run: \u001b[0m\u001b[32;49mpip install --upgrade pip\u001b[0m\n" + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m A new release of pip available: \u001B[0m\u001B[31;49m22.3.1\u001B[0m\u001B[39;49m -> \u001B[0m\u001B[32;49m23.3.1\u001B[0m\n", + "\u001B[1m[\u001B[0m\u001B[34;49mnotice\u001B[0m\u001B[1;39;49m]\u001B[0m\u001B[39;49m To update, run: \u001B[0m\u001B[32;49mpip install --upgrade pip\u001B[0m\n" ] } ], @@ -404,13 +404,26 @@ }, "outputs": [], "source": [ + "scl = connection.load_collection(\n", + " \"SENTINEL2_L2A\",\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[ \"SCL\"],\n", + ")\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection(\n", " \"SENTINEL2_L2A\",\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\", \"CLM\"],\n", + " bands=[\"B04\", \"B08\", \"CLM\"],\n", ")\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + "s2 = s2.mask(cloud_mask)\n", "s2 = s2.mask_polygon(spat_ext)\n", "ndvi_cube = s2.ndvi(red=\"B04\", nir=\"B08\", target_band=\"NDVI\")" ] @@ -41267,9 +41280,7 @@ "output_type": "execute_result" } ], - "source": [ - "connection.describe_process(\"mask_scl_dilation\")" - ] + "source": "connection.describe_process(\"to_scl_dilation_mask\")" }, { "cell_type": "markdown", diff --git a/workshops/FOSS4G/demo/foss4g_tutorial.ipynb b/workshops/FOSS4G/demo/foss4g_tutorial.ipynb index 4050de6..51a1fd7 100644 --- a/workshops/FOSS4G/demo/foss4g_tutorial.ipynb +++ b/workshops/FOSS4G/demo/foss4g_tutorial.ipynb @@ -201,13 +201,26 @@ }, "outputs": [], "source": [ + "scl = connection.load_collection(\n", + " \"SENTINEL2_L2A_SENTINELHUB\",\n", + " spatial_extent=spat_ext,\n", + " temporal_extent=temp_ext,\n", + " bands=[\"SCL\"],\n", + ")\n", + "cloud_mask = scl.process(\n", + " \"to_scl_dilation_mask\",\n", + " data=scl,\n", + " kernel1_size=17, kernel2_size=77,\n", + " mask1_values=[2, 4, 5, 6, 7],\n", + " mask2_values=[3, 8, 9, 10, 11],\n", + " erosion_kernel_size=3)\n", "s2 = connection.load_collection(\n", " \"SENTINEL2_L2A_SENTINELHUB\",\n", " spatial_extent=spat_ext,\n", " temporal_extent=temp_ext,\n", - " bands=[\"B04\", \"B08\", \"SCL\", \"CLM\"],\n", + " bands=[\"B04\", \"B08\", \"CLM\"],\n", ")\n", - "s2 = s2.process(\"mask_scl_dilation\", data=s2, scl_band_name=\"SCL\")\n", + "s2 = s2.mask(cloud_mask)\n", "s2 = s2.mask_polygon(spat_ext)\n", "ndvi_cube = s2.ndvi(red=\"B04\", nir=\"B08\", target_band=\"NDVI\")" ] @@ -227,9 +240,7 @@ "id": "84bf974e", "metadata": {}, "outputs": [], - "source": [ - "connection.describe_process(\"mask_scl_dilation\")" - ] + "source": "connection.describe_process(\"to_scl_dilation_mask\")" }, { "attachments": {},