{ "cells": [ { "cell_type": "code", "execution_count": null, "id": "006f8288", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Sentinel-1 images count: 782\n", "Sentinel-2 images count: 466\n", "PALSAR-2 images count: 110\n", "PALSAR-2 Observation Mode Counts:\n", "ScanSAR VBD: 5\n", "ScanSAR WBD: 95\n", "ScanSAR WBS: 10\n", "Sentinel-1 Images by Hour and Minute\n", "Hour: 05, Minute: 34 → 80\n", "Hour: 05, Minute: 35 → 180\n", "Hour: 05, Minute: 42 → 35\n", "Hour: 05, Minute: 43 → 227\n", "Hour: 17, Minute: 22 → 77\n", "Hour: 17, Minute: 23 → 183\n", "Sentinel-2 Images by Hour and Minute\n", "Hour: 10, Minute: 37 → 32\n", "Hour: 10, Minute: 38 → 434\n" ] } ], "source": [ "# plot when images are available in a graph for thes colection\n", "# s1_col = (ee.ImageCollection('COPERNICUS/S1_GRD')\n", " # .filterBounds(roi)\n", " # .filterDate(DATE_START, DATE_END)\n", " # .filter(ee.Filter.eq('instrumentMode', 'IW'))\n", " # .map(lambda img: img.select(['VV', 'VH']).clip(roi).toFloat())\n", " # )\n", " # s2_raw = (ee.ImageCollection(\"COPERNICUS/S2_SR_HARMONIZED\")\n", " # .filterBounds(roi)\n", " # .filterDate(DATE_START, DATE_END))\n", "# and for the ee.ImageCollection(\"JAXA/ALOS/PALSAR-2/Level2_2/ScanSAR\") collelction\n", "\n", "\n", "import ee\n", "import datetime\n", "import pandas as pd\n", "\n", "ee.Authenticate()\n", "ee.Initialize()\n", "\n", "roi = ee.Geometry.Polygon([\n", " [[7.472076, 46.371332],\n", " [7.472076, 46.395963],\n", " [7.558594, 46.395963],\n", " [7.558594, 46.371332]]\n", " ]) \n", "DATE_START = '2020-01-01'\n", "DATE_END = '2025-12-31'\n", "\n", "s1_col = (ee.ImageCollection('COPERNICUS/S1_GRD')\n", " .filterBounds(roi) \n", " .filterDate(DATE_START, DATE_END)\n", " \n", " .filter(ee.Filter.eq('instrumentMode', 'IW'))\n", ")\n", "s2_raw = (ee.ImageCollection(\"COPERNICUS/S2_SR_HARMONIZED\")\n", " .filterBounds(roi)\n", " .filterDate(DATE_START, DATE_END)\n", ")\n", "\n", "palsar2_col = (ee.ImageCollection(\"JAXA/ALOS/PALSAR-2/Level2_2/ScanSAR\")\n", " .filterBounds(roi)\n", " .filterDate(DATE_START, DATE_END)\n", " # .filter(ee.Filter.eq('ObservationMode', 'ScanSAR WBD'))\n", ")\n", "\n", "print(f'Sentinel-1 images count: {s1_col.size().getInfo()}')\n", "print(f'Sentinel-2 images count: {s2_raw.size().getInfo()}')\n", "print(f'PALSAR-2 images count: {palsar2_col.size().getInfo()}')\n", "\n", "def get_dates(image):\n", " date = ee.Date(image.get('system:time_start')).format('YYYY-MM-dd')\n", " return ee.Feature(None, {'date': date})\n", "\n", "s1_dates = s1_col.map(get_dates).distinct('date').aggregate_array('date').getInfo()\n", "s2_dates = s2_raw.map(get_dates).distinct('date').aggregate_array('date').getInfo()\n", "palsar2_dates = palsar2_col.map(get_dates).distinct('date').aggregate_array('date').getInfo()\n", "\n", "# Convert string dates to datetime objects\n", "s1_dates = [datetime.datetime.strptime(date, '%Y-%m-%d') for date in s1_dates]\n", "s2_dates = [datetime.datetime.strptime(date, '%Y-%m-%d') for date in s2_dates]\n", "palsar2_dates = [datetime.datetime.strptime(date, '%Y-%m-%d') for date in palsar2_dates]\n", "\n", "# Create a DataFrame for plotting\n", "df_s1 = pd.DataFrame({'Date': s1_dates, 'Collection': 'Sentinel-1'})\n", "df_s2 = pd.DataFrame({'Date': s2_dates, 'Collection': 'Sentinel-2'})\n", "df_palsar2 = pd.DataFrame({'Date': palsar2_dates, 'Collection': 'PALSAR-2'})\n", "df = pd.concat([df_s1, df_s2, df_palsar2])\n", "df['Count'] = 1\n", "\n", "\n", "\n", "\n", "# Plotting using plotly calendar heatmap\n", "import plotly.express as px\n", "fig = px.density_heatmap(df, x='Date', y='Collection', z='Count', \n", " histfunc='sum', nbinsx=12*6, nbinsy=3,\n", " title='Image Availability Calendar Heatmap',\n", " labels={'Date': 'Date', 'Collection': 'Satellite Collection', 'Count': 'Number of Images'},\n", " color_continuous_scale='Viridis')\n", "fig.update_layout(yaxis={'categoryorder':'array', 'categoryarray':['Sentinel-1', 'Sentinel-2', 'PALSAR-2']})\n", "fig.show(renderer=\"browser\")\n" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.12.7" } }, "nbformat": 4, "nbformat_minor": 5 }