From 0c8c528e23c97b37e3e69ec88bb4dd64a578c363 Mon Sep 17 00:00:00 2001 From: Julia Signell Date: Wed, 20 Aug 2025 13:24:36 -0400 Subject: [PATCH 1/2] Update how to read tutorial --- .../how-to-read-data-from-stac.ipynb | 6507 ++++++++++++++++- 1 file changed, 6221 insertions(+), 286 deletions(-) diff --git a/docs/tutorials/how-to-read-data-from-stac.ipynb b/docs/tutorials/how-to-read-data-from-stac.ipynb index 8e10f3ba5..30b1e12aa 100644 --- a/docs/tutorials/how-to-read-data-from-stac.ipynb +++ b/docs/tutorials/how-to-read-data-from-stac.ipynb @@ -11,10 +11,17 @@ "\n", "## tl;dr\n", "\n", - "For any PySTAC object that can be represented as an ndimensional dataset you can read the data using the following command:\n", + "For any PySTAC asset that can be represented as an xarray dataset you can read the data using the following command:\n", "\n", "```python\n", - "xr.open_dataset(object)\n", + "xr.open_dataset(asset)\n", + "```\n", + "\n", + "If you want to load multiple assets from the same item and/or many items at once use:\n", + "\n", + "\n", + "```python\n", + "odc.stac.load([items])\n", "```\n", "\n", "## Dependencies\n", @@ -25,18 +32,18 @@ "- fsspec - to access data from remote storage\n", "- pystac - STAC object structures\n", "- xarray, rioxarray - data structures\n", - "- xpystac, stackstac - helper for loading pystac into xarray objects" + "- xpystac, odc-stac - helper for loading pystac into xarray objects" ] }, { "cell_type": "code", - "execution_count": 1, + "execution_count": null, "id": "11dddb09-6313-4822-90ba-26eb6e5c143b", "metadata": {}, "outputs": [], "source": [ "!pip install adlfs dask 'fsspec[http]' planetary_computer --quiet\n", - "!pip install stackstac xarray xpystac zarr --quiet" + "!pip install odc-stac rioxarray xarray xpystac zarr --quiet" ] }, { @@ -49,11 +56,22 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "id": "2a8afebd-b397-4e7a-b448-0f59cc030e66", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-20T17:17:44.979834Z", + "iopub.status.busy": "2025-08-20T17:17:44.979658Z", + "iopub.status.idle": "2025-08-20T17:17:46.778292Z", + "shell.execute_reply": "2025-08-20T17:17:46.777723Z", + "shell.execute_reply.started": "2025-08-20T17:17:44.979821Z" + } + }, "outputs": [], "source": [ + "import odc.stac\n", + "import planetary_computer\n", + "import rioxarray\n", "import xarray as xr\n", "\n", "import pystac" @@ -74,17 +92,3666 @@ "id": "30da7cfd-2861-4095-b15b-9952a7d824d9", "metadata": {}, "source": [ - "### COGs\n", + "### COGs\n", + "\n", + "Read all the data from the COGs referenced by the assets on an item." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "id": "c77432e6-8b0d-44d2-a947-ec74a529b8cb", + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-20T17:17:51.773842Z", + "iopub.status.busy": "2025-08-20T17:17:51.773533Z", + "iopub.status.idle": "2025-08-20T17:17:52.924235Z", + "shell.execute_reply": "2025-08-20T17:17:52.923772Z", + "shell.execute_reply.started": "2025-08-20T17:17:51.773819Z" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.Dataset> Size: 2GB\n",
+       "Dimensions:      (y: 7801, x: 7761, time: 1)\n",
+       "Coordinates:\n",
+       "  * y            (y) float64 62kB -3.713e+06 -3.713e+06 ... -3.947e+06\n",
+       "  * x            (x) float64 62kB 3.774e+05 3.774e+05 ... 6.102e+05 6.102e+05\n",
+       "    spatial_ref  int32 4B 32656\n",
+       "  * time         (time) datetime64[ns] 8B 2023-04-08T23:37:51.630731\n",
+       "Data variables: (12/19)\n",
+       "    qa           (time, y, x) int16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    red          (time, y, x) uint16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    blue         (time, y, x) uint16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    drad         (time, y, x) int16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    emis         (time, y, x) int16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    emsd         (time, y, x) int16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    ...           ...\n",
+       "    swir16       (time, y, x) uint16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    swir22       (time, y, x) uint16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    coastal      (time, y, x) uint16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    qa_pixel     (time, y, x) uint16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    qa_radsat    (time, y, x) uint16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n",
+       "    qa_aerosol   (time, y, x) uint8 61MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>
" + ], + "text/plain": [ + " Size: 2GB\n", + "Dimensions: (y: 7801, x: 7761, time: 1)\n", + "Coordinates:\n", + " * y (y) float64 62kB -3.713e+06 -3.713e+06 ... -3.947e+06\n", + " * x (x) float64 62kB 3.774e+05 3.774e+05 ... 6.102e+05 6.102e+05\n", + " spatial_ref int32 4B 32656\n", + " * time (time) datetime64[ns] 8B 2023-04-08T23:37:51.630731\n", + "Data variables: (12/19)\n", + " qa (time, y, x) int16 121MB dask.array\n", + " red (time, y, x) uint16 121MB dask.array\n", + " blue (time, y, x) uint16 121MB dask.array\n", + " drad (time, y, x) int16 121MB dask.array\n", + " emis (time, y, x) int16 121MB dask.array\n", + " emsd (time, y, x) int16 121MB dask.array\n", + " ... ...\n", + " swir16 (time, y, x) uint16 121MB dask.array\n", + " swir22 (time, y, x) uint16 121MB dask.array\n", + " coastal (time, y, x) uint16 121MB dask.array\n", + " qa_pixel (time, y, x) uint16 121MB dask.array\n", + " qa_radsat (time, y, x) uint16 121MB dask.array\n", + " qa_aerosol (time, y, x) uint8 61MB dask.array" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "landsat_item = pystac.Item.from_file(\n", + " \"https://planetarycomputer.microsoft.com/api/stac/v1/collections/landsat-c2-l2/items/LC09_L2SP_088084_20230408_02_T2\",\n", + ")\n", + "\n", + "ds = odc.stac.load(\n", + " [landsat_item], chunks={\"x\": 1024, \"y\": 1024}, patch_url=planetary_computer.sign\n", + ")\n", + "ds" + ] + }, + { + "cell_type": "markdown", + "id": "db92558d-4d8c-4afd-873e-76de202048b7", + "metadata": {}, + "source": [ + "Let's prove that we really can access the data within the COGs." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "id": "add6347a-df37-495e-9794-7d86795d18f8", + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-20T17:17:54.197240Z", + "iopub.status.busy": "2025-08-20T17:17:54.196768Z", + "iopub.status.idle": "2025-08-20T17:18:06.879330Z", + "shell.execute_reply": "2025-08-20T17:18:06.878865Z", + "shell.execute_reply.started": "2025-08-20T17:17:54.197215Z" + } + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CPU times: user 2.54 s, sys: 612 ms, total: 3.16 s\n", + "Wall time: 12.7 s\n" + ] + }, + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.DataArray 'blue' ()> Size: 8B\n",
+       "array(13940.01841915)\n",
+       "Coordinates:\n",
+       "    spatial_ref  int32 4B 32656
" + ], + "text/plain": [ + " Size: 8B\n", + "array(13940.01841915)\n", + "Coordinates:\n", + " spatial_ref int32 4B 32656" + ] + }, + "execution_count": 3, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "%%time\n", + "ds.blue.mean().compute()" + ] + }, + { + "cell_type": "markdown", + "id": "65ed7b6d-2e24-46cf-a61f-bc17df20588c", + "metadata": {}, + "source": [ + "For more control over the individual COGs referenced by the assets, you can grab the href off the asset, sign it and then use it directly." + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "5873b326-820b-4eec-8ba3-c3207bf8f9ce", + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-20T17:18:09.967776Z", + "iopub.status.busy": "2025-08-20T17:18:09.967613Z", + "iopub.status.idle": "2025-08-20T17:18:10.637580Z", + "shell.execute_reply": "2025-08-20T17:18:10.637048Z", + "shell.execute_reply.started": "2025-08-20T17:18:09.967764Z" + } + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "
<xarray.DataArray (band: 1, y: 122, x: 122)> Size: 30kB\n",
+       "[14884 values with dtype=uint16]\n",
+       "Coordinates:\n",
+       "  * band         (band) int64 8B 1\n",
+       "  * x            (x) float64 976B 3.783e+05 3.802e+05 ... 6.074e+05 6.093e+05\n",
+       "  * y            (y) float64 976B -3.714e+06 -3.716e+06 ... -3.946e+06\n",
+       "    spatial_ref  int64 8B 0\n",
+       "Attributes:\n",
+       "    AREA_OR_POINT:  Point\n",
+       "    _FillValue:     0\n",
+       "    scale_factor:   1.0\n",
+       "    add_offset:     0.0
" + ], + "text/plain": [ + " Size: 30kB\n", + "[14884 values with dtype=uint16]\n", + "Coordinates:\n", + " * band (band) int64 8B 1\n", + " * x (x) float64 976B 3.783e+05 3.802e+05 ... 6.074e+05 6.093e+05\n", + " * y (y) float64 976B -3.714e+06 -3.716e+06 ... -3.946e+06\n", + " spatial_ref int64 8B 0\n", + "Attributes:\n", + " AREA_OR_POINT: Point\n", + " _FillValue: 0\n", + " scale_factor: 1.0\n", + " add_offset: 0.0" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "landsat_asset = landsat_item.assets[\"blue\"]\n", + "landsat_asset_href = planetary_computer.sign(landsat_asset).href\n", "\n", - "Read all the data from the COGs referenced by the assets on an item." + "da = rioxarray.open_rasterio(landsat_asset_href, overview_level=5)\n", + "da" ] }, { "cell_type": "code", - "execution_count": 3, - "id": "c77432e6-8b0d-44d2-a947-ec74a529b8cb", - "metadata": {}, + "execution_count": 5, + "id": "156a1c68-2d3f-48f1-8833-92d014b148c1", + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-20T17:18:11.867204Z", + "iopub.status.busy": "2025-08-20T17:18:11.867010Z", + "iopub.status.idle": "2025-08-20T17:18:12.061524Z", + "shell.execute_reply": "2025-08-20T17:18:12.060622Z", + "shell.execute_reply.started": "2025-08-20T17:18:11.867192Z" + } + }, "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "CPU times: user 1.92 ms, sys: 1.89 ms, total: 3.81 ms\n", + "Wall time: 184 ms\n" + ] + }, { "data": { "text/html": [ @@ -108,27 +3775,76 @@ " */\n", "\n", ":root {\n", - " --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n", - " --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n", - " --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n", - " --xr-border-color: var(--jp-border-color2, #e0e0e0);\n", - " --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n", - " --xr-background-color: var(--jp-layout-color0, white);\n", - " --xr-background-color-row-even: var(--jp-layout-color1, white);\n", - " --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n", - "}\n", - "\n", - "html[theme=dark],\n", - "body[data-theme=dark],\n", + " --xr-font-color0: var(\n", + " --jp-content-font-color0,\n", + " var(--pst-color-text-base rgba(0, 0, 0, 1))\n", + " );\n", + " --xr-font-color2: var(\n", + " --jp-content-font-color2,\n", + " var(--pst-color-text-base, rgba(0, 0, 0, 0.54))\n", + " );\n", + " --xr-font-color3: var(\n", + " --jp-content-font-color3,\n", + " var(--pst-color-text-base, rgba(0, 0, 0, 0.38))\n", + " );\n", + " --xr-border-color: var(\n", + " --jp-border-color2,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 10))\n", + " );\n", + " --xr-disabled-color: var(\n", + " --jp-layout-color3,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 40))\n", + " );\n", + " --xr-background-color: var(\n", + " --jp-layout-color0,\n", + " var(--pst-color-on-background, white)\n", + " );\n", + " --xr-background-color-row-even: var(\n", + " --jp-layout-color1,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 5))\n", + " );\n", + " --xr-background-color-row-odd: var(\n", + " --jp-layout-color2,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 15))\n", + " );\n", + "}\n", + "\n", + "html[theme=\"dark\"],\n", + "html[data-theme=\"dark\"],\n", + "body[data-theme=\"dark\"],\n", "body.vscode-dark {\n", - " --xr-font-color0: rgba(255, 255, 255, 1);\n", - " --xr-font-color2: rgba(255, 255, 255, 0.54);\n", - " --xr-font-color3: rgba(255, 255, 255, 0.38);\n", - " --xr-border-color: #1F1F1F;\n", - " --xr-disabled-color: #515151;\n", - " --xr-background-color: #111111;\n", - " --xr-background-color-row-even: #111111;\n", - " --xr-background-color-row-odd: #313131;\n", + " --xr-font-color0: var(\n", + " --jp-content-font-color0,\n", + " var(--pst-color-text-base, rgba(255, 255, 255, 1))\n", + " );\n", + " --xr-font-color2: var(\n", + " --jp-content-font-color2,\n", + " var(--pst-color-text-base, rgba(255, 255, 255, 0.54))\n", + " );\n", + " --xr-font-color3: var(\n", + " --jp-content-font-color3,\n", + " var(--pst-color-text-base, rgba(255, 255, 255, 0.38))\n", + " );\n", + " --xr-border-color: var(\n", + " --jp-border-color2,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 10))\n", + " );\n", + " --xr-disabled-color: var(\n", + " --jp-layout-color3,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 40))\n", + " );\n", + " --xr-background-color: var(\n", + " --jp-layout-color0,\n", + " var(--pst-color-on-background, #111111)\n", + " );\n", + " --xr-background-color-row-even: var(\n", + " --jp-layout-color1,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 5))\n", + " );\n", + " --xr-background-color-row-odd: var(\n", + " --jp-layout-color2,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 15))\n", + " );\n", "}\n", "\n", ".xr-wrap {\n", @@ -169,7 +3885,7 @@ ".xr-sections {\n", " padding-left: 0 !important;\n", " display: grid;\n", - " grid-template-columns: 150px auto auto 1fr 20px 20px;\n", + " grid-template-columns: 150px auto auto 1fr 0 20px 0 20px;\n", "}\n", "\n", ".xr-section-item {\n", @@ -177,11 +3893,14 @@ "}\n", "\n", ".xr-section-item input {\n", - " display: none;\n", + " display: inline-block;\n", + " opacity: 0;\n", + " height: 0;\n", "}\n", "\n", ".xr-section-item input + label {\n", " color: var(--xr-disabled-color);\n", + " border: 2px solid transparent !important;\n", "}\n", "\n", ".xr-section-item input:enabled + label {\n", @@ -189,6 +3908,10 @@ " color: var(--xr-font-color2);\n", "}\n", "\n", + ".xr-section-item input:focus + label {\n", + " border: 2px solid var(--xr-font-color0) !important;\n", + "}\n", + "\n", ".xr-section-item input:enabled + label:hover {\n", " color: var(--xr-font-color0);\n", "}\n", @@ -210,7 +3933,7 @@ "\n", ".xr-section-summary-in + label:before {\n", " display: inline-block;\n", - " content: '►';\n", + " content: \"►\";\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", @@ -221,7 +3944,7 @@ "}\n", "\n", ".xr-section-summary-in:checked + label:before {\n", - " content: '▼';\n", + " content: \"▼\";\n", "}\n", "\n", ".xr-section-summary-in:checked + label > span {\n", @@ -293,15 +4016,15 @@ "}\n", "\n", ".xr-dim-list:before {\n", - " content: '(';\n", + " content: \"(\";\n", "}\n", "\n", ".xr-dim-list:after {\n", - " content: ')';\n", + " content: \")\";\n", "}\n", "\n", ".xr-dim-list li:not(:last-child):after {\n", - " content: ',';\n", + " content: \",\";\n", " padding-right: 5px;\n", "}\n", "\n", @@ -318,7 +4041,9 @@ ".xr-var-item label,\n", ".xr-var-item > .xr-var-name span {\n", " background-color: var(--xr-background-color-row-even);\n", + " border-color: var(--xr-background-color-row-odd);\n", " margin-bottom: 0;\n", + " padding-top: 2px;\n", "}\n", "\n", ".xr-var-item > .xr-var-name:hover span {\n", @@ -329,6 +4054,7 @@ ".xr-var-list > li:nth-child(odd) > label,\n", ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n", " background-color: var(--xr-background-color-row-odd);\n", + " border-color: var(--xr-background-color-row-even);\n", "}\n", "\n", ".xr-var-name {\n", @@ -378,8 +4104,15 @@ ".xr-var-data,\n", ".xr-index-data {\n", " display: none;\n", - " background-color: var(--xr-background-color) !important;\n", - " padding-bottom: 5px !important;\n", + " border-top: 2px dotted var(--xr-background-color);\n", + " padding-bottom: 20px !important;\n", + " padding-top: 10px !important;\n", + "}\n", + "\n", + ".xr-var-attrs-in + label,\n", + ".xr-var-data-in + label,\n", + ".xr-index-data-in + label {\n", + " padding: 0 1px;\n", "}\n", "\n", ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n", @@ -392,6 +4125,12 @@ " float: right;\n", "}\n", "\n", + ".xr-var-data > pre,\n", + ".xr-index-data > pre,\n", + ".xr-var-data > table > tbody > tr {\n", + " background-color: transparent !important;\n", + "}\n", + "\n", ".xr-var-name span,\n", ".xr-var-data,\n", ".xr-index-name div,\n", @@ -451,104 +4190,34 @@ " stroke: currentColor;\n", " fill: currentColor;\n", "}\n", - "
<xarray.Dataset>\n",
-       "Dimensions:                      (time: 1, y: 7802, x: 7762, band: 19)\n",
-       "Coordinates: (12/32)\n",
-       "  * time                         (time) datetime64[ns] 2023-04-08T23:37:51.63...\n",
-       "    id                           (time) <U31 ...\n",
-       "  * x                            (x) float64 3.774e+05 3.774e+05 ... 6.102e+05\n",
-       "  * y                            (y) float64 -3.713e+06 ... -3.947e+06\n",
-       "    proj:shape                   object ...\n",
-       "    sci:doi                      <U16 ...\n",
-       "    ...                           ...\n",
-       "    raster:bands                 (band) object ...\n",
-       "    classification:bitfields     (band) object ...\n",
-       "    common_name                  (band) object ...\n",
-       "    center_wavelength            (band) object ...\n",
-       "    full_width_half_max          (band) object ...\n",
-       "    epsg                         int64 ...\n",
-       "Dimensions without coordinates: band\n",
-       "Data variables: (12/19)\n",
-       "    qa                           (time, y, x) float64 ...\n",
-       "    red                          (time, y, x) float64 ...\n",
-       "    blue                         (time, y, x) float64 ...\n",
-       "    drad                         (time, y, x) float64 ...\n",
-       "    emis                         (time, y, x) float64 ...\n",
-       "    emsd                         (time, y, x) float64 ...\n",
-       "    ...                           ...\n",
-       "    swir16                       (time, y, x) float64 ...\n",
-       "    swir22                       (time, y, x) float64 ...\n",
-       "    coastal                      (time, y, x) float64 ...\n",
-       "    qa_pixel                     (time, y, x) float64 ...\n",
-       "    qa_radsat                    (time, y, x) float64 ...\n",
-       "    qa_aerosol                   (time, y, x) float64 ...\n",
-       "Attributes:\n",
-       "    spec:        RasterSpec(epsg=32656, bounds=(377370.0, -3947130.0, 610230....\n",
-       "    crs:         epsg:32656\n",
-       "    transform:   | 30.00, 0.00, 377370.00|\\n| 0.00,-30.00,-3713070.00|\\n| 0.0...\n",
-       "    resolution:  30.0
" + "\n", + ".xr-var-attrs-in:checked + label > .xr-icon-file-text2,\n", + ".xr-var-data-in:checked + label > .xr-icon-database,\n", + ".xr-index-data-in:checked + label > .xr-icon-database {\n", + " color: var(--xr-font-color0);\n", + " filter: drop-shadow(1px 1px 5px var(--xr-font-color2));\n", + " stroke-width: 0.8px;\n", + "}\n", + "
<xarray.DataArray ()> Size: 8B\n",
+       "array(14472.21996775)\n",
+       "Coordinates:\n",
+       "    spatial_ref  int64 8B 0
" ], "text/plain": [ - "\n", - "Dimensions: (time: 1, y: 7802, x: 7762, band: 19)\n", - "Coordinates: (12/32)\n", - " * time (time) datetime64[ns] 2023-04-08T23:37:51.63...\n", - " id (time) Size: 8B\n", + "array(14472.21996775)\n", + "Coordinates:\n", + " spatial_ref int64 8B 0" ] }, - "execution_count": 3, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "landsat_item = pystac.Item.from_file(\n", - " \"https://planetarycomputer.microsoft.com/api/stac/v1/collections/landsat-c2-l2/items/LC09_L2SP_088084_20230408_02_T2\"\n", - ")\n", - "xr.open_dataset(landsat_item)" + "%%time\n", + "da.mean()" ] }, { @@ -563,9 +4232,17 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "id": "5176680b-3d58-4c72-bf58-d80051f6de75", - "metadata": {}, + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-20T17:18:15.271889Z", + "iopub.status.busy": "2025-08-20T17:18:15.271708Z", + "iopub.status.idle": "2025-08-20T17:18:18.088984Z", + "shell.execute_reply": "2025-08-20T17:18:18.088572Z", + "shell.execute_reply.started": "2025-08-20T17:18:15.271877Z" + } + }, "outputs": [ { "data": { @@ -590,27 +4267,76 @@ " */\n", "\n", ":root {\n", - " --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n", - " --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n", - " --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n", - " --xr-border-color: var(--jp-border-color2, #e0e0e0);\n", - " --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n", - " --xr-background-color: var(--jp-layout-color0, white);\n", - " --xr-background-color-row-even: var(--jp-layout-color1, white);\n", - " --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n", - "}\n", - "\n", - "html[theme=dark],\n", - "body[data-theme=dark],\n", + " --xr-font-color0: var(\n", + " --jp-content-font-color0,\n", + " var(--pst-color-text-base rgba(0, 0, 0, 1))\n", + " );\n", + " --xr-font-color2: var(\n", + " --jp-content-font-color2,\n", + " var(--pst-color-text-base, rgba(0, 0, 0, 0.54))\n", + " );\n", + " --xr-font-color3: var(\n", + " --jp-content-font-color3,\n", + " var(--pst-color-text-base, rgba(0, 0, 0, 0.38))\n", + " );\n", + " --xr-border-color: var(\n", + " --jp-border-color2,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 10))\n", + " );\n", + " --xr-disabled-color: var(\n", + " --jp-layout-color3,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 40))\n", + " );\n", + " --xr-background-color: var(\n", + " --jp-layout-color0,\n", + " var(--pst-color-on-background, white)\n", + " );\n", + " --xr-background-color-row-even: var(\n", + " --jp-layout-color1,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 5))\n", + " );\n", + " --xr-background-color-row-odd: var(\n", + " --jp-layout-color2,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 15))\n", + " );\n", + "}\n", + "\n", + "html[theme=\"dark\"],\n", + "html[data-theme=\"dark\"],\n", + "body[data-theme=\"dark\"],\n", "body.vscode-dark {\n", - " --xr-font-color0: rgba(255, 255, 255, 1);\n", - " --xr-font-color2: rgba(255, 255, 255, 0.54);\n", - " --xr-font-color3: rgba(255, 255, 255, 0.38);\n", - " --xr-border-color: #1F1F1F;\n", - " --xr-disabled-color: #515151;\n", - " --xr-background-color: #111111;\n", - " --xr-background-color-row-even: #111111;\n", - " --xr-background-color-row-odd: #313131;\n", + " --xr-font-color0: var(\n", + " --jp-content-font-color0,\n", + " var(--pst-color-text-base, rgba(255, 255, 255, 1))\n", + " );\n", + " --xr-font-color2: var(\n", + " --jp-content-font-color2,\n", + " var(--pst-color-text-base, rgba(255, 255, 255, 0.54))\n", + " );\n", + " --xr-font-color3: var(\n", + " --jp-content-font-color3,\n", + " var(--pst-color-text-base, rgba(255, 255, 255, 0.38))\n", + " );\n", + " --xr-border-color: var(\n", + " --jp-border-color2,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 10))\n", + " );\n", + " --xr-disabled-color: var(\n", + " --jp-layout-color3,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 40))\n", + " );\n", + " --xr-background-color: var(\n", + " --jp-layout-color0,\n", + " var(--pst-color-on-background, #111111)\n", + " );\n", + " --xr-background-color-row-even: var(\n", + " --jp-layout-color1,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 5))\n", + " );\n", + " --xr-background-color-row-odd: var(\n", + " --jp-layout-color2,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 15))\n", + " );\n", "}\n", "\n", ".xr-wrap {\n", @@ -651,7 +4377,7 @@ ".xr-sections {\n", " padding-left: 0 !important;\n", " display: grid;\n", - " grid-template-columns: 150px auto auto 1fr 20px 20px;\n", + " grid-template-columns: 150px auto auto 1fr 0 20px 0 20px;\n", "}\n", "\n", ".xr-section-item {\n", @@ -659,11 +4385,14 @@ "}\n", "\n", ".xr-section-item input {\n", - " display: none;\n", + " display: inline-block;\n", + " opacity: 0;\n", + " height: 0;\n", "}\n", "\n", ".xr-section-item input + label {\n", " color: var(--xr-disabled-color);\n", + " border: 2px solid transparent !important;\n", "}\n", "\n", ".xr-section-item input:enabled + label {\n", @@ -671,6 +4400,10 @@ " color: var(--xr-font-color2);\n", "}\n", "\n", + ".xr-section-item input:focus + label {\n", + " border: 2px solid var(--xr-font-color0) !important;\n", + "}\n", + "\n", ".xr-section-item input:enabled + label:hover {\n", " color: var(--xr-font-color0);\n", "}\n", @@ -692,7 +4425,7 @@ "\n", ".xr-section-summary-in + label:before {\n", " display: inline-block;\n", - " content: '►';\n", + " content: \"►\";\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", @@ -703,7 +4436,7 @@ "}\n", "\n", ".xr-section-summary-in:checked + label:before {\n", - " content: '▼';\n", + " content: \"▼\";\n", "}\n", "\n", ".xr-section-summary-in:checked + label > span {\n", @@ -775,15 +4508,15 @@ "}\n", "\n", ".xr-dim-list:before {\n", - " content: '(';\n", + " content: \"(\";\n", "}\n", "\n", ".xr-dim-list:after {\n", - " content: ')';\n", + " content: \")\";\n", "}\n", "\n", ".xr-dim-list li:not(:last-child):after {\n", - " content: ',';\n", + " content: \",\";\n", " padding-right: 5px;\n", "}\n", "\n", @@ -800,7 +4533,9 @@ ".xr-var-item label,\n", ".xr-var-item > .xr-var-name span {\n", " background-color: var(--xr-background-color-row-even);\n", + " border-color: var(--xr-background-color-row-odd);\n", " margin-bottom: 0;\n", + " padding-top: 2px;\n", "}\n", "\n", ".xr-var-item > .xr-var-name:hover span {\n", @@ -811,6 +4546,7 @@ ".xr-var-list > li:nth-child(odd) > label,\n", ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n", " background-color: var(--xr-background-color-row-odd);\n", + " border-color: var(--xr-background-color-row-even);\n", "}\n", "\n", ".xr-var-name {\n", @@ -860,8 +4596,15 @@ ".xr-var-data,\n", ".xr-index-data {\n", " display: none;\n", - " background-color: var(--xr-background-color) !important;\n", - " padding-bottom: 5px !important;\n", + " border-top: 2px dotted var(--xr-background-color);\n", + " padding-bottom: 20px !important;\n", + " padding-top: 10px !important;\n", + "}\n", + "\n", + ".xr-var-attrs-in + label,\n", + ".xr-var-data-in + label,\n", + ".xr-index-data-in + label {\n", + " padding: 0 1px;\n", "}\n", "\n", ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n", @@ -874,6 +4617,12 @@ " float: right;\n", "}\n", "\n", + ".xr-var-data > pre,\n", + ".xr-index-data > pre,\n", + ".xr-var-data > table > tbody > tr {\n", + " background-color: transparent !important;\n", + "}\n", + "\n", ".xr-var-name span,\n", ".xr-var-data,\n", ".xr-index-name div,\n", @@ -933,26 +4682,34 @@ " stroke: currentColor;\n", " fill: currentColor;\n", "}\n", - "
<xarray.Dataset>\n",
+       "\n",
+       ".xr-var-attrs-in:checked + label > .xr-icon-file-text2,\n",
+       ".xr-var-data-in:checked + label > .xr-icon-database,\n",
+       ".xr-index-data-in:checked + label > .xr-icon-database {\n",
+       "  color: var(--xr-font-color0);\n",
+       "  filter: drop-shadow(1px 1px 5px var(--xr-font-color2));\n",
+       "  stroke-width: 0.8px;\n",
+       "}\n",
+       "
<xarray.Dataset> Size: 69GB\n",
        "Dimensions:                  (time: 14965, y: 584, x: 284, nv: 2)\n",
        "Coordinates:\n",
-       "    lat                      (y, x) float32 ...\n",
-       "    lon                      (y, x) float32 ...\n",
-       "  * time                     (time) datetime64[ns] 1980-01-01T12:00:00 ... 20...\n",
-       "  * x                        (x) float32 -5.802e+06 -5.801e+06 ... -5.519e+06\n",
-       "  * y                        (y) float32 -3.9e+04 -4e+04 ... -6.21e+05 -6.22e+05\n",
+       "    lat                      (y, x) float32 663kB dask.array<chunksize=(584, 284), meta=np.ndarray>\n",
+       "    lon                      (y, x) float32 663kB dask.array<chunksize=(584, 284), meta=np.ndarray>\n",
+       "  * time                     (time) datetime64[ns] 120kB 1980-01-01T12:00:00 ...\n",
+       "  * x                        (x) float32 1kB -5.802e+06 ... -5.519e+06\n",
+       "  * y                        (y) float32 2kB -3.9e+04 -4e+04 ... -6.22e+05\n",
        "Dimensions without coordinates: nv\n",
        "Data variables:\n",
-       "    dayl                     (time, y, x) float32 ...\n",
-       "    lambert_conformal_conic  int16 ...\n",
-       "    prcp                     (time, y, x) float32 ...\n",
-       "    srad                     (time, y, x) float32 ...\n",
-       "    swe                      (time, y, x) float32 ...\n",
-       "    time_bnds                (time, nv) datetime64[ns] ...\n",
-       "    tmax                     (time, y, x) float32 ...\n",
-       "    tmin                     (time, y, x) float32 ...\n",
-       "    vp                       (time, y, x) float32 ...\n",
-       "    yearday                  (time) int16 ...\n",
+       "    dayl                     (time, y, x) float32 10GB dask.array<chunksize=(365, 584, 284), meta=np.ndarray>\n",
+       "    lambert_conformal_conic  int16 2B ...\n",
+       "    prcp                     (time, y, x) float32 10GB dask.array<chunksize=(365, 584, 284), meta=np.ndarray>\n",
+       "    srad                     (time, y, x) float32 10GB dask.array<chunksize=(365, 584, 284), meta=np.ndarray>\n",
+       "    swe                      (time, y, x) float32 10GB dask.array<chunksize=(365, 584, 284), meta=np.ndarray>\n",
+       "    time_bnds                (time, nv) datetime64[ns] 239kB dask.array<chunksize=(365, 2), meta=np.ndarray>\n",
+       "    tmax                     (time, y, x) float32 10GB dask.array<chunksize=(365, 584, 284), meta=np.ndarray>\n",
+       "    tmin                     (time, y, x) float32 10GB dask.array<chunksize=(365, 584, 284), meta=np.ndarray>\n",
+       "    vp                       (time, y, x) float32 10GB dask.array<chunksize=(365, 584, 284), meta=np.ndarray>\n",
+       "    yearday                  (time) int16 30kB dask.array<chunksize=(365,), meta=np.ndarray>\n",
        "Attributes:\n",
        "    Conventions:       CF-1.6\n",
        "    Version_data:      Daymet Data Version 4.0\n",
@@ -960,12 +4717,1066 @@
        "    citation:          Please see http://daymet.ornl.gov/ for current Daymet ...\n",
        "    references:        Please see http://daymet.ornl.gov/ for current informa...\n",
        "    source:            Daymet Software Version 4.0\n",
-       "    start_year:        1980
  • x
    PandasIndex
    PandasIndex(Index([-5802250.0, -5801250.0, -5800250.0, -5799250.0, -5798250.0, -5797250.0,\n",
    +       "       -5796250.0, -5795250.0, -5794250.0, -5793250.0,\n",
    +       "       ...\n",
    +       "       -5528250.0, -5527250.0, -5526250.0, -5525250.0, -5524250.0, -5523250.0,\n",
    +       "       -5522250.0, -5521250.0, -5520250.0, -5519250.0],\n",
    +       "      dtype='float32', name='x', length=284))
  • y
    PandasIndex
    PandasIndex(Index([ -39000.0,  -40000.0,  -41000.0,  -42000.0,  -43000.0,  -44000.0,\n",
    +       "        -45000.0,  -46000.0,  -47000.0,  -48000.0,\n",
    +       "       ...\n",
    +       "       -613000.0, -614000.0, -615000.0, -616000.0, -617000.0, -618000.0,\n",
    +       "       -619000.0, -620000.0, -621000.0, -622000.0],\n",
    +       "      dtype='float32', name='y', length=584))
  • Conventions :
    CF-1.6
    Version_data :
    Daymet Data Version 4.0
    Version_software :
    Daymet Software Version 4.0
    citation :
    Please see http://daymet.ornl.gov/ for current Daymet data citation information
    references :
    Please see http://daymet.ornl.gov/ for current information on Daymet references
    source :
    Daymet Software Version 4.0
    start_year :
    1980
  • " ], "text/plain": [ - "\n", + " Size: 69GB\n", "Dimensions: (time: 14965, y: 584, x: 284, nv: 2)\n", "Coordinates:\n", - " lat (y, x) float32 ...\n", - " lon (y, x) float32 ...\n", - " * time (time) datetime64[ns] 1980-01-01T12:00:00 ... 20...\n", - " * x (x) float32 -5.802e+06 -5.801e+06 ... -5.519e+06\n", - " * y (y) float32 -3.9e+04 -4e+04 ... -6.21e+05 -6.22e+05\n", + " lat (y, x) float32 663kB dask.array\n", + " lon (y, x) float32 663kB dask.array\n", + " * time (time) datetime64[ns] 120kB 1980-01-01T12:00:00 ...\n", + " * x (x) float32 1kB -5.802e+06 ... -5.519e+06\n", + " * y (y) float32 2kB -3.9e+04 -4e+04 ... -6.22e+05\n", "Dimensions without coordinates: nv\n", "Data variables:\n", - " dayl (time, y, x) float32 ...\n", - " lambert_conformal_conic int16 ...\n", - " prcp (time, y, x) float32 ...\n", - " srad (time, y, x) float32 ...\n", - " swe (time, y, x) float32 ...\n", - " time_bnds (time, nv) datetime64[ns] ...\n", - " tmax (time, y, x) float32 ...\n", - " tmin (time, y, x) float32 ...\n", - " vp (time, y, x) float32 ...\n", - " yearday (time) int16 ...\n", + " dayl (time, y, x) float32 10GB dask.array\n", + " lambert_conformal_conic int16 2B ...\n", + " prcp (time, y, x) float32 10GB dask.array\n", + " srad (time, y, x) float32 10GB dask.array\n", + " swe (time, y, x) float32 10GB dask.array\n", + " time_bnds (time, nv) datetime64[ns] 239kB dask.array\n", + " tmax (time, y, x) float32 10GB dask.array\n", + " tmin (time, y, x) float32 10GB dask.array\n", + " vp (time, y, x) float32 10GB dask.array\n", + " yearday (time) int16 30kB dask.array\n", "Attributes:\n", " Conventions: CF-1.6\n", " Version_data: Daymet Data Version 4.0\n", @@ -1019,7 +5830,7 @@ " start_year: 1980" ] }, - "execution_count": 4, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -1029,8 +5840,10 @@ " \"https://planetarycomputer.microsoft.com/api/stac/v1/collections/daymet-daily-hi\"\n", ")\n", "daymet_asset = daymet_collection.assets[\"zarr-abfs\"]\n", + "daymet_asset_signed = planetary_computer.sign(daymet_asset)\n", "\n", - "xr.open_dataset(daymet_asset)" + "ds = xr.open_dataset(daymet_asset_signed, chunks={})\n", + "ds" ] }, { @@ -1040,14 +5853,28 @@ "source": [ "### Reference file\n", "\n", - "If the collection has a reference file we can use that" + "If the collection has a reference file we can use that.\n", + "\n", + "
    \n", + " \n", + "This will not work for kerchunk>=0.2.8 and xpystac<=0.2.0. Track the xpystac ticket here: [xpystac #48](https://github.com/stac-utils/xpystac/issues/48)\n", + " \n", + "
    " ] }, { "cell_type": "code", - "execution_count": 5, - "id": "00efc688-a8b8-4b45-8ee8-1aa076a870f4", - "metadata": {}, + "execution_count": 8, + "id": "e69db448-c493-4972-ab1d-a8fb3f8ab71f", + "metadata": { + "execution": { + "iopub.execute_input": "2025-08-20T17:18:25.902934Z", + "iopub.status.busy": "2025-08-20T17:18:25.902580Z", + "iopub.status.idle": "2025-08-20T17:19:42.773064Z", + "shell.execute_reply": "2025-08-20T17:19:42.772407Z", + "shell.execute_reply.started": "2025-08-20T17:18:25.902903Z" + } + }, "outputs": [ { "data": { @@ -1072,27 +5899,76 @@ " */\n", "\n", ":root {\n", - " --xr-font-color0: var(--jp-content-font-color0, rgba(0, 0, 0, 1));\n", - " --xr-font-color2: var(--jp-content-font-color2, rgba(0, 0, 0, 0.54));\n", - " --xr-font-color3: var(--jp-content-font-color3, rgba(0, 0, 0, 0.38));\n", - " --xr-border-color: var(--jp-border-color2, #e0e0e0);\n", - " --xr-disabled-color: var(--jp-layout-color3, #bdbdbd);\n", - " --xr-background-color: var(--jp-layout-color0, white);\n", - " --xr-background-color-row-even: var(--jp-layout-color1, white);\n", - " --xr-background-color-row-odd: var(--jp-layout-color2, #eeeeee);\n", - "}\n", - "\n", - "html[theme=dark],\n", - "body[data-theme=dark],\n", + " --xr-font-color0: var(\n", + " --jp-content-font-color0,\n", + " var(--pst-color-text-base rgba(0, 0, 0, 1))\n", + " );\n", + " --xr-font-color2: var(\n", + " --jp-content-font-color2,\n", + " var(--pst-color-text-base, rgba(0, 0, 0, 0.54))\n", + " );\n", + " --xr-font-color3: var(\n", + " --jp-content-font-color3,\n", + " var(--pst-color-text-base, rgba(0, 0, 0, 0.38))\n", + " );\n", + " --xr-border-color: var(\n", + " --jp-border-color2,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 10))\n", + " );\n", + " --xr-disabled-color: var(\n", + " --jp-layout-color3,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 40))\n", + " );\n", + " --xr-background-color: var(\n", + " --jp-layout-color0,\n", + " var(--pst-color-on-background, white)\n", + " );\n", + " --xr-background-color-row-even: var(\n", + " --jp-layout-color1,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 5))\n", + " );\n", + " --xr-background-color-row-odd: var(\n", + " --jp-layout-color2,\n", + " hsl(from var(--pst-color-on-background, white) h s calc(l - 15))\n", + " );\n", + "}\n", + "\n", + "html[theme=\"dark\"],\n", + "html[data-theme=\"dark\"],\n", + "body[data-theme=\"dark\"],\n", "body.vscode-dark {\n", - " --xr-font-color0: rgba(255, 255, 255, 1);\n", - " --xr-font-color2: rgba(255, 255, 255, 0.54);\n", - " --xr-font-color3: rgba(255, 255, 255, 0.38);\n", - " --xr-border-color: #1F1F1F;\n", - " --xr-disabled-color: #515151;\n", - " --xr-background-color: #111111;\n", - " --xr-background-color-row-even: #111111;\n", - " --xr-background-color-row-odd: #313131;\n", + " --xr-font-color0: var(\n", + " --jp-content-font-color0,\n", + " var(--pst-color-text-base, rgba(255, 255, 255, 1))\n", + " );\n", + " --xr-font-color2: var(\n", + " --jp-content-font-color2,\n", + " var(--pst-color-text-base, rgba(255, 255, 255, 0.54))\n", + " );\n", + " --xr-font-color3: var(\n", + " --jp-content-font-color3,\n", + " var(--pst-color-text-base, rgba(255, 255, 255, 0.38))\n", + " );\n", + " --xr-border-color: var(\n", + " --jp-border-color2,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 10))\n", + " );\n", + " --xr-disabled-color: var(\n", + " --jp-layout-color3,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 40))\n", + " );\n", + " --xr-background-color: var(\n", + " --jp-layout-color0,\n", + " var(--pst-color-on-background, #111111)\n", + " );\n", + " --xr-background-color-row-even: var(\n", + " --jp-layout-color1,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 5))\n", + " );\n", + " --xr-background-color-row-odd: var(\n", + " --jp-layout-color2,\n", + " hsl(from var(--pst-color-on-background, #111111) h s calc(l + 15))\n", + " );\n", "}\n", "\n", ".xr-wrap {\n", @@ -1133,7 +6009,7 @@ ".xr-sections {\n", " padding-left: 0 !important;\n", " display: grid;\n", - " grid-template-columns: 150px auto auto 1fr 20px 20px;\n", + " grid-template-columns: 150px auto auto 1fr 0 20px 0 20px;\n", "}\n", "\n", ".xr-section-item {\n", @@ -1141,11 +6017,14 @@ "}\n", "\n", ".xr-section-item input {\n", - " display: none;\n", + " display: inline-block;\n", + " opacity: 0;\n", + " height: 0;\n", "}\n", "\n", ".xr-section-item input + label {\n", " color: var(--xr-disabled-color);\n", + " border: 2px solid transparent !important;\n", "}\n", "\n", ".xr-section-item input:enabled + label {\n", @@ -1153,6 +6032,10 @@ " color: var(--xr-font-color2);\n", "}\n", "\n", + ".xr-section-item input:focus + label {\n", + " border: 2px solid var(--xr-font-color0) !important;\n", + "}\n", + "\n", ".xr-section-item input:enabled + label:hover {\n", " color: var(--xr-font-color0);\n", "}\n", @@ -1174,7 +6057,7 @@ "\n", ".xr-section-summary-in + label:before {\n", " display: inline-block;\n", - " content: '►';\n", + " content: \"►\";\n", " font-size: 11px;\n", " width: 15px;\n", " text-align: center;\n", @@ -1185,7 +6068,7 @@ "}\n", "\n", ".xr-section-summary-in:checked + label:before {\n", - " content: '▼';\n", + " content: \"▼\";\n", "}\n", "\n", ".xr-section-summary-in:checked + label > span {\n", @@ -1257,15 +6140,15 @@ "}\n", "\n", ".xr-dim-list:before {\n", - " content: '(';\n", + " content: \"(\";\n", "}\n", "\n", ".xr-dim-list:after {\n", - " content: ')';\n", + " content: \")\";\n", "}\n", "\n", ".xr-dim-list li:not(:last-child):after {\n", - " content: ',';\n", + " content: \",\";\n", " padding-right: 5px;\n", "}\n", "\n", @@ -1282,7 +6165,9 @@ ".xr-var-item label,\n", ".xr-var-item > .xr-var-name span {\n", " background-color: var(--xr-background-color-row-even);\n", + " border-color: var(--xr-background-color-row-odd);\n", " margin-bottom: 0;\n", + " padding-top: 2px;\n", "}\n", "\n", ".xr-var-item > .xr-var-name:hover span {\n", @@ -1293,6 +6178,7 @@ ".xr-var-list > li:nth-child(odd) > label,\n", ".xr-var-list > li:nth-child(odd) > .xr-var-name span {\n", " background-color: var(--xr-background-color-row-odd);\n", + " border-color: var(--xr-background-color-row-even);\n", "}\n", "\n", ".xr-var-name {\n", @@ -1342,8 +6228,15 @@ ".xr-var-data,\n", ".xr-index-data {\n", " display: none;\n", - " background-color: var(--xr-background-color) !important;\n", - " padding-bottom: 5px !important;\n", + " border-top: 2px dotted var(--xr-background-color);\n", + " padding-bottom: 20px !important;\n", + " padding-top: 10px !important;\n", + "}\n", + "\n", + ".xr-var-attrs-in + label,\n", + ".xr-var-data-in + label,\n", + ".xr-index-data-in + label {\n", + " padding: 0 1px;\n", "}\n", "\n", ".xr-var-attrs-in:checked ~ .xr-var-attrs,\n", @@ -1356,6 +6249,12 @@ " float: right;\n", "}\n", "\n", + ".xr-var-data > pre,\n", + ".xr-index-data > pre,\n", + ".xr-var-data > table > tbody > tr {\n", + " background-color: transparent !important;\n", + "}\n", + "\n", ".xr-var-name span,\n", ".xr-var-data,\n", ".xr-index-name div,\n", @@ -1415,22 +6314,30 @@ " stroke: currentColor;\n", " fill: currentColor;\n", "}\n", - "
    <xarray.Dataset>\n",
    +       "\n",
    +       ".xr-var-attrs-in:checked + label > .xr-icon-file-text2,\n",
    +       ".xr-var-data-in:checked + label > .xr-icon-database,\n",
    +       ".xr-index-data-in:checked + label > .xr-icon-database {\n",
    +       "  color: var(--xr-font-color0);\n",
    +       "  filter: drop-shadow(1px 1px 5px var(--xr-font-color2));\n",
    +       "  stroke-width: 0.8px;\n",
    +       "}\n",
    +       "
    <xarray.Dataset> Size: 738GB\n",
            "Dimensions:  (time: 23741, lat: 600, lon: 1440)\n",
            "Coordinates:\n",
    -       "  * lat      (lat) float64 -59.88 -59.62 -59.38 -59.12 ... 89.38 89.62 89.88\n",
    -       "  * lon      (lon) float64 0.125 0.375 0.625 0.875 ... 359.1 359.4 359.6 359.9\n",
    -       "  * time     (time) datetime64[us] 1950-01-01T12:00:00 ... 2014-12-31T12:00:00\n",
    +       "  * lon      (lon) float64 12kB 0.125 0.375 0.625 0.875 ... 359.4 359.6 359.9\n",
    +       "  * lat      (lat) float64 5kB -59.88 -59.62 -59.38 -59.12 ... 89.38 89.62 89.88\n",
    +       "  * time     (time) datetime64[us] 190kB 1950-01-01T12:00:00 ... 2014-12-31T1...\n",
            "Data variables:\n",
    -       "    hurs     (time, lat, lon) float32 ...\n",
    -       "    huss     (time, lat, lon) float32 ...\n",
    -       "    pr       (time, lat, lon) float32 ...\n",
    -       "    rlds     (time, lat, lon) float32 ...\n",
    -       "    rsds     (time, lat, lon) float32 ...\n",
    -       "    sfcWind  (time, lat, lon) float32 ...\n",
    -       "    tas      (time, lat, lon) float32 ...\n",
    -       "    tasmax   (time, lat, lon) float32 ...\n",
    -       "    tasmin   (time, lat, lon) float32 ...\n",
    +       "    hurs     (time, lat, lon) float32 82GB dask.array<chunksize=(1, 600, 1440), meta=np.ndarray>\n",
    +       "    huss     (time, lat, lon) float32 82GB dask.array<chunksize=(1, 600, 1440), meta=np.ndarray>\n",
    +       "    pr       (time, lat, lon) float32 82GB dask.array<chunksize=(1, 600, 1440), meta=np.ndarray>\n",
    +       "    rlds     (time, lat, lon) float32 82GB dask.array<chunksize=(1, 600, 1440), meta=np.ndarray>\n",
    +       "    rsds     (time, lat, lon) float32 82GB dask.array<chunksize=(1, 600, 1440), meta=np.ndarray>\n",
    +       "    sfcWind  (time, lat, lon) float32 82GB dask.array<chunksize=(1, 600, 1440), meta=np.ndarray>\n",
    +       "    tas      (time, lat, lon) float32 82GB dask.array<chunksize=(1, 600, 1440), meta=np.ndarray>\n",
    +       "    tasmax   (time, lat, lon) float32 82GB dask.array<chunksize=(1, 600, 1440), meta=np.ndarray>\n",
    +       "    tasmin   (time, lat, lon) float32 82GB dask.array<chunksize=(1, 600, 1440), meta=np.ndarray>\n",
            "Attributes: (12/22)\n",
            "    Conventions:           CF-1.7\n",
            "    activity:              NEX-GDDP-CMIP6\n",
    @@ -1444,21 +6351,1047 @@
            "    title:                 ACCESS-CM2, r1i1p1f1, historical, global downscale...\n",
            "    tracking_id:           16d27564-470f-41ea-8077-f4cc3efa5bfe\n",
            "    variant_label:         r1i1p1f1\n",
    -       "    version:               1.0
  • Conventions :
    CF-1.7
    activity :
    NEX-GDDP-CMIP6
    cmip6_institution_id :
    CSIRO-ARCCSS
    cmip6_license :
    CC-BY-SA 4.0
    cmip6_source_id :
    ACCESS-CM2
    contact :
    Dr. Rama Nemani: rama.nemani@nasa.gov, Dr. Bridget Thrasher: bridget@climateanalyticsgroup.org
    creation_date :
    2021-10-04T13:59:21.654137+00:00
    disclaimer :
    This data is considered provisional and subject to change. This data is provided as is without any warranty of any kind, either express or implied, arising by law or otherwise, including but not limited to warranties of completeness, non-infringement, accuracy, merchantability, or fitness for a particular purpose. The user assumes all risk associated with the use of, or inability to use, this data.
    external_variables :
    areacella
    frequency :
    day
    history :
    2021-10-04T13:59:21.654137+00:00: install global attributes
    institution :
    NASA Earth Exchange, NASA Ames Research Center, Moffett Field, CA 94035
    product :
    output
    realm :
    atmos
    references :
    BCSD method: Thrasher et al., 2012, Hydrol. Earth Syst. Sci.,16, 3309-3314. Ref period obs: latest version of the Princeton Global Meteorological Forcings (http://hydrology.princeton.edu/data.php), based on Sheffield et al., 2006, J. Climate, 19 (13), 3088-3111.
    resolution_id :
    0.25 degree
    scenario :
    historical
    source :
    BCSD
    title :
    ACCESS-CM2, r1i1p1f1, historical, global downscaled CMIP6 climate projection data
    tracking_id :
    16d27564-470f-41ea-8077-f4cc3efa5bfe
    variant_label :
    r1i1p1f1
    version :
    1.0
  • " ], "text/plain": [ - "\n", + " Size: 738GB\n", "Dimensions: (time: 23741, lat: 600, lon: 1440)\n", "Coordinates:\n", - " * lat (lat) float64 -59.88 -59.62 -59.38 -59.12 ... 89.38 89.62 89.88\n", - " * lon (lon) float64 0.125 0.375 0.625 0.875 ... 359.1 359.4 359.6 359.9\n", - " * time (time) datetime64[us] 1950-01-01T12:00:00 ... 2014-12-31T12:00:00\n", + " * lon (lon) float64 12kB 0.125 0.375 0.625 0.875 ... 359.4 359.6 359.9\n", + " * lat (lat) float64 5kB -59.88 -59.62 -59.38 -59.12 ... 89.38 89.62 89.88\n", + " * time (time) datetime64[us] 190kB 1950-01-01T12:00:00 ... 2014-12-31T1...\n", "Data variables:\n", - " hurs (time, lat, lon) float32 ...\n", - " huss (time, lat, lon) float32 ...\n", - " pr (time, lat, lon) float32 ...\n", - " rlds (time, lat, lon) float32 ...\n", - " rsds (time, lat, lon) float32 ...\n", - " sfcWind (time, lat, lon) float32 ...\n", - " tas (time, lat, lon) float32 ...\n", - " tasmax (time, lat, lon) float32 ...\n", - " tasmin (time, lat, lon) float32 ...\n", + " hurs (time, lat, lon) float32 82GB dask.array\n", + " huss (time, lat, lon) float32 82GB dask.array\n", + " pr (time, lat, lon) float32 82GB dask.array\n", + " rlds (time, lat, lon) float32 82GB dask.array\n", + " rsds (time, lat, lon) float32 82GB dask.array\n", + " sfcWind (time, lat, lon) float32 82GB dask.array\n", + " tas (time, lat, lon) float32 82GB dask.array\n", + " tasmax (time, lat, lon) float32 82GB dask.array\n", + " tasmin (time, lat, lon) float32 82GB dask.array\n", "Attributes: (12/22)\n", " Conventions: CF-1.7\n", " activity: NEX-GDDP-CMIP6\n", @@ -1504,7 +7437,7 @@ " version: 1.0" ] }, - "execution_count": 5, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -1514,8 +7447,10 @@ " \"https://planetarycomputer.microsoft.com/api/stac/v1/collections/nasa-nex-gddp-cmip6\"\n", ")\n", "cmip6_asset = cmip6_collection.assets[\"ACCESS-CM2.historical\"]\n", + "cmip6_asset_signed = planetary_computer.sign(cmip6_asset)\n", "\n", - "xr.open_dataset(cmip6_asset)" + "ds = xr.open_dataset(cmip6_asset_signed, chunks={}, patch_url=planetary_computer.sign)\n", + "ds" ] } ], @@ -1535,7 +7470,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.8.15" + "version": "3.11.11" } }, "nbformat": 4, From fbbc55840d6df05913a60fa4910e6084085f2376 Mon Sep 17 00:00:00 2001 From: Julia Signell Date: Thu, 21 Aug 2025 15:59:28 -0400 Subject: [PATCH 2/2] Remove pip install from notebook --- .../how-to-read-data-from-stac.ipynb | 236 +- pyproject.toml | 6 + uv.lock | 4532 +++++++++++------ 3 files changed, 2982 insertions(+), 1792 deletions(-) diff --git a/docs/tutorials/how-to-read-data-from-stac.ipynb b/docs/tutorials/how-to-read-data-from-stac.ipynb index 30b1e12aa..ec262c1f8 100644 --- a/docs/tutorials/how-to-read-data-from-stac.ipynb +++ b/docs/tutorials/how-to-read-data-from-stac.ipynb @@ -29,23 +29,11 @@ "There are lots of optional dependencies depending on where and how the data you are interested in are stored. Here are some of the libraries that you will probably need:\n", "\n", "- dask - to delay data loading until access\n", - "- fsspec - to access data from remote storage\n", "- pystac - STAC object structures\n", "- xarray, rioxarray - data structures\n", "- xpystac, odc-stac - helper for loading pystac into xarray objects" ] }, - { - "cell_type": "code", - "execution_count": null, - "id": "11dddb09-6313-4822-90ba-26eb6e5c143b", - "metadata": {}, - "outputs": [], - "source": [ - "!pip install adlfs dask 'fsspec[http]' planetary_computer --quiet\n", - "!pip install odc-stac rioxarray xarray xpystac zarr --quiet" - ] - }, { "cell_type": "markdown", "id": "ad3fb6dc-3529-47bd-a5b3-f5260f23db88", @@ -60,11 +48,11 @@ "id": "2a8afebd-b397-4e7a-b448-0f59cc030e66", "metadata": { "execution": { - "iopub.execute_input": "2025-08-20T17:17:44.979834Z", - "iopub.status.busy": "2025-08-20T17:17:44.979658Z", - "iopub.status.idle": "2025-08-20T17:17:46.778292Z", - "shell.execute_reply": "2025-08-20T17:17:46.777723Z", - "shell.execute_reply.started": "2025-08-20T17:17:44.979821Z" + "iopub.execute_input": "2025-08-21T19:55:58.808745Z", + "iopub.status.busy": "2025-08-21T19:55:58.808345Z", + "iopub.status.idle": "2025-08-21T19:56:01.983744Z", + "shell.execute_reply": "2025-08-21T19:56:01.983228Z", + "shell.execute_reply.started": "2025-08-21T19:55:58.808709Z" } }, "outputs": [], @@ -103,11 +91,11 @@ "id": "c77432e6-8b0d-44d2-a947-ec74a529b8cb", "metadata": { "execution": { - "iopub.execute_input": "2025-08-20T17:17:51.773842Z", - "iopub.status.busy": "2025-08-20T17:17:51.773533Z", - "iopub.status.idle": "2025-08-20T17:17:52.924235Z", - "shell.execute_reply": "2025-08-20T17:17:52.923772Z", - "shell.execute_reply.started": "2025-08-20T17:17:51.773819Z" + "iopub.execute_input": "2025-08-21T19:56:03.945808Z", + "iopub.status.busy": "2025-08-21T19:56:03.945372Z", + "iopub.status.idle": "2025-08-21T19:56:05.448439Z", + "shell.execute_reply": "2025-08-21T19:56:05.448060Z", + "shell.execute_reply.started": "2025-08-21T19:56:03.945773Z" } }, "outputs": [ @@ -577,9 +565,9 @@ " coastal (time, y, x) uint16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n", " qa_pixel (time, y, x) uint16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n", " qa_radsat (time, y, x) uint16 121MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>\n", - " qa_aerosol (time, y, x) uint8 61MB dask.array<chunksize=(1, 1024, 1024), meta=np.ndarray>