From cd8038d1822b42c059acf1f392754d051dddc673 Mon Sep 17 00:00:00 2001 From: hrodmn Date: Tue, 12 May 2026 11:33:08 -0500 Subject: [PATCH] chore: fix a few cells in the new notebook --- docs/notebooks/cmr-lpcloud-fix-assets.ipynb | 138 ++++++++++---------- 1 file changed, 72 insertions(+), 66 deletions(-) diff --git a/docs/notebooks/cmr-lpcloud-fix-assets.ipynb b/docs/notebooks/cmr-lpcloud-fix-assets.ipynb index 966c7b6..f2c5070 100644 --- a/docs/notebooks/cmr-lpcloud-fix-assets.ipynb +++ b/docs/notebooks/cmr-lpcloud-fix-assets.ipynb @@ -12,11 +12,12 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 1, "id": "d4e34fc4-7766-411f-871e-852a840024c6", "metadata": {}, "outputs": [], "source": [ + "import json\n", "import math\n", "import os\n", "from pathlib import Path\n", @@ -41,12 +42,12 @@ "id": "80a39efd-b8ce-4317-ae41-3c4e33bec636", "metadata": {}, "source": [ - "Start by writing a CMR STAC query to stac-geoparquet" + "Start by writing a CMR STAC query that writes the result to a local stac-geoparquet file." ] }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 4, "id": "4199d977-0403-4826-a630-8a486bfd1e09", "metadata": {}, "outputs": [ @@ -84,24 +85,42 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 5, "id": "ce607f7a-cd76-499f-aaa3-d09665618d37", "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "dict_keys(['browse', 'thumbnail_0', 'thumbnail_1', 'thumbnail_2', 'thumbnail_3', 'thumbnail_4', 'thumbnail_5', 'thumbnail_6', 'thumbnail_7', 'thumbnail_8', 'thumbnail_9', '002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_NDVI', '002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_NDVI-UQ', '002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_albedo', '002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_albedo-UQ', 's3_002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_NDVI', 's3_002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_NDVI-UQ', 's3_002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_albedo', 's3_002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_albedo-UQ', 'metadata'])" - ] - }, - "execution_count": 42, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "[\n", + " \"browse\",\n", + " \"thumbnail_0\",\n", + " \"thumbnail_1\",\n", + " \"thumbnail_2\",\n", + " \"thumbnail_3\",\n", + " \"thumbnail_4\",\n", + " \"thumbnail_5\",\n", + " \"thumbnail_6\",\n", + " \"thumbnail_7\",\n", + " \"thumbnail_8\",\n", + " \"thumbnail_9\",\n", + " \"002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_NDVI\",\n", + " \"002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_NDVI-UQ\",\n", + " \"002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_albedo\",\n", + " \"002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_albedo-UQ\",\n", + " \"s3_002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_NDVI\",\n", + " \"s3_002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_NDVI-UQ\",\n", + " \"s3_002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_albedo\",\n", + " \"s3_002/ECOv002_L2T_STARS_15TWL_20180729_0712_01/ECOv002_L2T_STARS_15TWL_20180729_0712_01_albedo-UQ\",\n", + " \"metadata\"\n", + "]\n" + ] } ], "source": [ "items = rustac.search_sync(RAW_PARQUET, max_items=1, limit=1)\n", - "items[0][\"assets\"].keys()" + "print(json.dumps(list(items[0][\"assets\"].keys()), indent=2))" ] }, { @@ -114,19 +133,25 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 6, "id": "ebc33cb1-0ada-4ecc-bb77-eb0a297400ae", "metadata": {}, "outputs": [ { - "data": { - "text/plain": [ - "dict_keys(['NDVI', 'NDVI-UQ', 'albedo', 'albedo-UQ', 'NDVI-s3', 'NDVI-UQ-s3', 'albedo-s3', 'albedo-UQ-s3'])" - ] - }, - "execution_count": 43, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "[\n", + " \"NDVI\",\n", + " \"NDVI-UQ\",\n", + " \"albedo\",\n", + " \"albedo-UQ\",\n", + " \"NDVI-s3\",\n", + " \"NDVI-UQ-s3\",\n", + " \"albedo-s3\",\n", + " \"albedo-UQ-s3\"\n", + "]\n" + ] } ], "source": [ @@ -144,7 +169,7 @@ " items.append(item)\n", "\n", "sample_item = items[0]\n", - "sample_item[\"assets\"].keys()" + "print(json.dumps(list(sample_item[\"assets\"].keys()), indent=2))" ] }, { @@ -157,17 +182,17 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 7, "id": "8a778413-8625-41f7-a2ff-a3ed3eaf26ad", "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'e_tag': '3f3e47-651a0cca01dc8-28779', 'version': None}" + "{'e_tag': '3f43b4-651a1608ae614-28779', 'version': None}" ] }, - "execution_count": 44, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -191,7 +216,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 9, "id": "40da4912-2261-4ba6-84eb-978a56e8e50a", "metadata": {}, "outputs": [], @@ -223,37 +248,17 @@ ")" ] }, - { - "cell_type": "code", - "execution_count": 55, - "id": "d78786ab-49bf-41d2-804b-f668289fc0b2", - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "BoundingBox(left=499980.0, bottom=4990240.0, right=609740.0, top=5100000.0)\n", - "BoundingBox(left=499980.0, bottom=5090260.0, right=609740.0, top=5200020.0)\n", - "[499980.0, 4990240.0, 609740.0, 5200020.0]\n" - ] - } - ], - "source": [ - "dst_crs = \"epsg:5070\"" - ] - }, { "cell_type": "markdown", "id": "cb5ae3eb-27f9-4881-aae9-fb2bc1882a5c", "metadata": {}, "source": [ - "Inspect one of the geotiffs assets to get some information about the extent/resolution of the underlying data. Based on the query I want to run (a single this is a " + "Inspect one of the geotiffs assets to get some information about the extent/resolution of the underlying data." ] }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 10, "id": "a5aca1a2-b56c-4b7b-a502-4743eb0090b9", "metadata": {}, "outputs": [ @@ -306,7 +311,7 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 11, "id": "d02e1a65-adaf-4025-9dee-893449452a24", "metadata": {}, "outputs": [ @@ -316,7 +321,7 @@ "(229320.0, 2455740.0, 349370.0, 2670570.0)" ] }, - "execution_count": 61, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -351,6 +356,7 @@ " math.ceil(_dst_bbox[2] / resolution) * resolution,\n", " math.ceil(_dst_bbox[3] / resolution) * resolution,\n", ")\n", + "\n", "dst_bbox" ] }, @@ -364,7 +370,7 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 12, "id": "d3a44503-9b68-4c6d-9198-1d4f76ddce48", "metadata": {}, "outputs": [ @@ -935,18 +941,18 @@ " spatial:registration: pixel\n", " _stac_backend: MultiBandStacBackendArray(bands=['NDVI', 'albedo...\n", " _stac_time_coords: 2018-07-28 … 2026-02-24 (n=869)\n", - " proj:code: EPSG:5070
  • grid_mapping :
    spatial_ref
    zarr_conventions :
    [{'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md', 'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f', 'name': 'proj:', 'description': 'Coordinate reference system information for geospatial data'}, {'schema_url': 'https://raw.githubusercontent.com/zarr-conventions/spatial/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-conventions/spatial/blob/v1/README.md', 'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', 'name': 'spatial:', 'description': 'Spatial coordinate information'}]
    spatial:dimensions :
    ['y', 'x']
    spatial:bbox :
    (229320.0, 2455740.0, 349370.0, 2670570.0)
    spatial:transform_type :
    affine
    spatial:transform :
    [70.0, 0.0, 229320.0, 0.0, -70.0, 2670570.0]
    spatial:shape :
    [3069, 1715]
    spatial:registration :
    pixel
    _stac_backend :
    MultiBandStacBackendArray(bands=['NDVI', 'albedo'], shape=(2, 869, 3069, 1715))
    _stac_time_coords :
    2018-07-28 … 2026-02-24 (n=869)
    proj:code :
    EPSG:5070
  • " ], "text/plain": [ " Size: 37GB\n", @@ -974,7 +980,7 @@ " proj:code: EPSG:5070" ] }, - "execution_count": 65, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -1005,7 +1011,7 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 13, "id": "c450e893-34f3-43aa-904d-82ab00cb566f", "metadata": {}, "outputs": [ @@ -1573,9 +1579,9 @@ " spatial:registration: pixel\n", " _stac_backend: MultiBandStacBackendArray(bands=['NDVI', 'albedo...\n", " _stac_time_coords: 2018-07-28 … 2026-02-24 (n=869)\n", - " proj:code: EPSG:5070
  • grid_mapping :
    spatial_ref
    zarr_conventions :
    [{'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md', 'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f', 'name': 'proj:', 'description': 'Coordinate reference system information for geospatial data'}, {'schema_url': 'https://raw.githubusercontent.com/zarr-conventions/spatial/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-conventions/spatial/blob/v1/README.md', 'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', 'name': 'spatial:', 'description': 'Spatial coordinate information'}]
    spatial:dimensions :
    ['y', 'x']
    spatial:bbox :
    (229320.0, 2455740.0, 349370.0, 2670570.0)
    spatial:transform_type :
    affine
    spatial:transform :
    [70.0, 0.0, 229320.0, 0.0, -70.0, 2670570.0]
    spatial:shape :
    [3069, 1715]
    spatial:registration :
    pixel
    _stac_backend :
    MultiBandStacBackendArray(bands=['NDVI', 'albedo'], shape=(2, 869, 3069, 1715))
    _stac_time_coords :
    2018-07-28 … 2026-02-24 (n=869)
    proj:code :
    EPSG:5070
  • " ], "text/plain": [ " Size: 7kB\n", @@ -1600,7 +1606,7 @@ " proj:code: EPSG:5070" ] }, - "execution_count": 67, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -1615,7 +1621,7 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 14, "id": "d2bac22b-5439-4662-8273-283657d94cd2", "metadata": {}, "outputs": [ @@ -2191,7 +2197,7 @@ " spatial:registration: pixel\n", " _stac_backend: MultiBandStacBackendArray(bands=['NDVI', 'albedo...\n", " _stac_time_coords: 2018-07-28 … 2026-02-24 (n=869)\n", - " proj:code: EPSG:5070
  • grid_mapping :
    spatial_ref
    zarr_conventions :
    [{'schema_url': 'https://raw.githubusercontent.com/zarr-experimental/geo-proj/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-experimental/geo-proj/blob/v1/README.md', 'uuid': 'f17cb550-5864-4468-aeb7-f3180cfb622f', 'name': 'proj:', 'description': 'Coordinate reference system information for geospatial data'}, {'schema_url': 'https://raw.githubusercontent.com/zarr-conventions/spatial/refs/tags/v1/schema.json', 'spec_url': 'https://github.com/zarr-conventions/spatial/blob/v1/README.md', 'uuid': '689b58e2-cf7b-45e0-9fff-9cfc0883d6b4', 'name': 'spatial:', 'description': 'Spatial coordinate information'}]
    spatial:dimensions :
    ['y', 'x']
    spatial:bbox :
    (229320.0, 2455740.0, 349370.0, 2670570.0)
    spatial:transform_type :
    affine
    spatial:transform :
    [70.0, 0.0, 229320.0, 0.0, -70.0, 2670570.0]
    spatial:shape :
    [3069, 1715]
    spatial:registration :
    pixel
    _stac_backend :
    MultiBandStacBackendArray(bands=['NDVI', 'albedo'], shape=(2, 869, 3069, 1715))
    _stac_time_coords :
    2018-07-28 … 2026-02-24 (n=869)
    proj:code :
    EPSG:5070
  • " ], "text/plain": [ " Size: 160B\n", @@ -2238,7 +2244,7 @@ " proj:code: EPSG:5070" ] }, - "execution_count": 68, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" }