{ "cells": [ { "cell_type": "markdown", "id": "30681e56", "metadata": {}, "source": [ "# 🧪 Test Planetary Computer Connection\n", "\n", "Notebook này test kết nối và load dữ liệu từ Microsoft Planetary Computer" ] }, { "cell_type": "code", "execution_count": null, "id": "e32c8eca", "metadata": {}, "outputs": [], "source": [ "import sys\n", "sys.path.insert(0, '/media/x79/2A7D-FAA0/remote-sensing')\n", "\n", "from load_data_no_odc import load_sentinel2_stac, load_sentinel1_stac\n", "import matplotlib.pyplot as plt\n", "\n", "print(\"✅ Module imported successfully\")" ] }, { "cell_type": "code", "execution_count": null, "id": "501dd8ef", "metadata": {}, "outputs": [], "source": [ "# Small test area (1 month, small bbox)\n", "bbox = (105.8, 9.5, 106.0, 9.7) # Small area in Mekong Delta\n", "date_range = (\"2023-01-01\", \"2023-01-31\") # 1 month only\n", "\n", "print(f\"Test parameters:\")\n", "print(f\" Bbox: {bbox}\")\n", "print(f\" Date: {date_range}\")" ] }, { "cell_type": "code", "execution_count": null, "id": "187e2c1a", "metadata": {}, "outputs": [], "source": [ "# Test Sentinel-2\n", "print(\"\\n\" + \"=\" * 70)\n", "print(\"Testing Sentinel-2 L2A\")\n", "print(\"=\" * 70)\n", "\n", "data_s2 = load_sentinel2_stac(\n", " bbox=bbox,\n", " date_range=date_range,\n", " bands=['red', 'green', 'blue', 'nir08', 'SCL'],\n", " resolution=60 # Lower resolution for faster test\n", ")\n", "\n", "if data_s2 is not None:\n", " print(f\"\\n✅ SUCCESS! Sentinel-2 loaded\")\n", " print(f\" Dims: {dict(data_s2.dims)}\")\n", " print(f\" Vars: {list(data_s2.data_vars)}\")\n", "else:\n", " print(\"\\n❌ Failed to load Sentinel-2\")" ] }, { "cell_type": "code", "execution_count": null, "id": "e688f3b9", "metadata": {}, "outputs": [], "source": [ "# Test Sentinel-1\n", "print(\"\\n\" + \"=\" * 70)\n", "print(\"Testing Sentinel-1 RTC\")\n", "print(\"=\" * 70)\n", "\n", "data_s1 = load_sentinel1_stac(\n", " bbox=bbox,\n", " date_range=date_range,\n", " bands=['vv', 'vh'],\n", " resolution=60 # Lower resolution for faster test\n", ")\n", "\n", "if data_s1 is not None:\n", " print(f\"\\n✅ SUCCESS! Sentinel-1 loaded\")\n", " print(f\" Dims: {dict(data_s1.dims)}\")\n", " print(f\" Vars: {list(data_s1.data_vars)}\")\n", "else:\n", " print(\"\\n❌ Failed to load Sentinel-1\")" ] }, { "cell_type": "code", "execution_count": null, "id": "211796a7", "metadata": {}, "outputs": [], "source": [ "# Visualize if data loaded successfully\n", "if data_s2 is not None:\n", " print(\"\\n📊 Visualizing Sentinel-2 RGB composite...\")\n", " \n", " # Select first timestep\n", " rgb = data_s2[['red', 'green', 'blue']].isel(time=0)\n", " \n", " # Plot\n", " fig, axes = plt.subplots(1, 3, figsize=(15, 5))\n", " \n", " rgb['red'].plot(ax=axes[0], cmap='Reds')\n", " axes[0].set_title('Red band')\n", " \n", " rgb['green'].plot(ax=axes[1], cmap='Greens')\n", " axes[1].set_title('Green band')\n", " \n", " rgb['blue'].plot(ax=axes[2], cmap='Blues')\n", " axes[2].set_title('Blue band')\n", " \n", " plt.tight_layout()\n", " plt.show()\n", " \n", " print(\"✅ Visualization complete!\")" ] }, { "cell_type": "markdown", "id": "d4e29a09", "metadata": {}, "source": [ "## ✅ Results\n", "\n", "Nếu cả 2 tests đều pass:\n", "- ✅ Kết nối Planetary Computer OK\n", "- ✅ Load Sentinel-2 OK\n", "- ✅ Load Sentinel-1 OK\n", "- ✅ Sẵn sàng sử dụng cho training!\n", "\n", "Next step: Sử dụng `01.train_DecisionTree_PlanetaryComputer.ipynb` để train model" ] } ], "metadata": { "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }