diff --git a/notebooks/compositing_debug.ipynb b/notebooks/compositing_debug.ipynb new file mode 100644 index 0000000..661128e --- /dev/null +++ b/notebooks/compositing_debug.ipynb @@ -0,0 +1,141 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 2, + "id": "10573c5d", + "metadata": {}, + "outputs": [], + "source": [ + "import xarray as xr\n", + "import rioxarray\n", + "import matplotlib.pyplot as plt\n", + "import numpy as np\n", + "\n", + "from pixelverse.download.sentinel2 import get_s2_times_series" + ] + }, + { + "cell_type": "code", + "execution_count": 39, + "id": "64c5aaf1", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "The autoreload extension is already loaded. To reload it, use:\n", + " %reload_ext autoreload\n" + ] + } + ], + "source": [ + "%load_ext autoreload\n", + "%autoreload 2" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0901d96c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Found 2 items for month 6\n", + "scene level percent cloud cover: [25.208652, 45.391417]\n" + ] + } + ], + "source": [ + "SAMPLE_AOI_BBOX = (34.30401965358922, 0.483473285913126, 34.3178177763533, 0.497271408677202)\n", + "# Get items (lazily loaded)\n", + "items_by_month = get_s2_times_series(bbox=SAMPLE_AOI_BBOX, year=2023, cloudcover_max=60, months=[6])" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "ecb54b08", + "metadata": {}, + "outputs": [], + "source": [ + "items_by_month " + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "id": "af82a807", + "metadata": {}, + "outputs": [], + "source": [ + "rgb = items_by_month[[\"red\", \"green\", \"blue\"]].isel(time=0)\n", + "rgb_scaled = (255 * rgb / 3000).clip(0, 255).astype(\"uint8\")\n", + "rgb_scaled.rio.to_raster('./s2_rgb_month_test.tif')" + ] + }, + { + "cell_type": "code", + "execution_count": 35, + "id": "dc860c00", + "metadata": {}, + "outputs": [], + "source": [ + "# Display RGB composite scaled to 3000\n", + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "rgb = items_by_month[[\"red\", \"green\", \"blue\"]].isel(time=0)\n", + "rgb_array = np.stack([rgb[\"red\"].values, rgb[\"green\"].values, rgb[\"blue\"].values], axis=-1)\n", + "rgb_scaled = np.clip(rgb_array / 3000, 0, 1)\n", + "\n", + "plt.figure(figsize=(10, 10))\n", + "plt.imshow(rgb_scaled)\n", + "plt.axis('off')\n", + "plt.title('RGB Composite - Month 1')\n", + "plt.tight_layout()\n", + "plt.show()\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "4b798a20", + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "bd858d7e", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "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.13.7" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/notebooks/sample_embeddings_generation.ipynb b/notebooks/sample_embeddings_generation.ipynb index 19a0ece..4f91962 100644 --- a/notebooks/sample_embeddings_generation.ipynb +++ b/notebooks/sample_embeddings_generation.ipynb @@ -10,13 +10,14 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 1, "id": "1", "metadata": {}, "outputs": [], "source": [ "import torch\n", "import xarray as xr\n", + "import rioxarray\n", "\n", "from pixelverse.download.sentinel2 import get_s2_times_series\n", "from pixelverse.models.registry import create_model" @@ -24,7 +25,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 2, "id": "2", "metadata": {}, "outputs": [], @@ -34,7 +35,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 3, "id": "3", "metadata": {}, "outputs": [], @@ -46,7 +47,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 4, "id": "4", "metadata": {}, "outputs": [ @@ -548,13 +549,13 @@ " nir (time, y, x) float64 2MB dask.array<chunksize=(1, 153, 154), meta=np.ndarray>\n", " nir08 (time, y, x) float64 2MB dask.array<chunksize=(1, 153, 154), meta=np.ndarray>\n", " swir16 (time, y, x) float64 2MB dask.array<chunksize=(1, 153, 154), meta=np.ndarray>\n", - " swir22 (time, y, x) float64 2MB dask.array<chunksize=(1, 153, 154), meta=np.ndarray>