From 5ea435254d42aceea7e51bb62f3da2b13b3bab37 Mon Sep 17 00:00:00 2001
From: amelia <asnyder@usgs.gov>
Date: Mon, 8 Apr 2024 10:08:36 -0500
Subject: [PATCH] add station data workflows and catalog entries

---
 .../collection.json                           | 10 +++++++
 .../collection.json                           | 10 +++++++
 ...ion_data_create_collection_from_zarr.ipynb | 17 +++++++++--
 ...ion_data_create_collection_from_zarr.ipynb | 28 +++++++++++++++++--
 4 files changed, 60 insertions(+), 5 deletions(-)

diff --git a/catalog/TTU_2019_rcp45_station_data/collection.json b/catalog/TTU_2019_rcp45_station_data/collection.json
index 0a546332..66e6647f 100644
--- a/catalog/TTU_2019_rcp45_station_data/collection.json
+++ b/catalog/TTU_2019_rcp45_station_data/collection.json
@@ -35,6 +35,16 @@
         0,
         1
       ]
+    },
+    "stations": {
+      "type": "geometry",
+      "description": null,
+      "bbox": [
+        220.3289031982422,
+        24.55500030517578,
+        293.0080871582031,
+        59.51190185546875
+      ]
     }
   },
   "cube:variables": {
diff --git a/catalog/TTU_2019_rcp85_station_data/collection.json b/catalog/TTU_2019_rcp85_station_data/collection.json
index 223dcc47..eb6782d6 100644
--- a/catalog/TTU_2019_rcp85_station_data/collection.json
+++ b/catalog/TTU_2019_rcp85_station_data/collection.json
@@ -35,6 +35,16 @@
         0,
         1
       ]
+    },
+    "stations": {
+      "type": "geometry",
+      "description": null,
+      "bbox": [
+        220.3289031982422,
+        24.55500030517578,
+        293.0080871582031,
+        59.51190185546875
+      ]
     }
   },
   "cube:variables": {
diff --git a/workflows/archive/TTU_2019_rcp45_station_data_create_collection_from_zarr.ipynb b/workflows/archive/TTU_2019_rcp45_station_data_create_collection_from_zarr.ipynb
index de27ed27..f6c4fd1d 100644
--- a/workflows/archive/TTU_2019_rcp45_station_data_create_collection_from_zarr.ipynb
+++ b/workflows/archive/TTU_2019_rcp45_station_data_create_collection_from_zarr.ipynb
@@ -166,7 +166,9 @@
    "metadata": {},
    "source": [
     "## Identify x, y, t dimensions of dataset\n",
-    "May require user input if dimensions cannot be auto-detected."
+    "May require user input if dimensions cannot be auto-detected.\n",
+    "\n",
+    "**WARNING: no x, y dims in this dataset, but we will still include lat/lon as dims in our dict so we can use the same code snippets as usual to get a bbox for the dataset**"
    ]
   },
   {
@@ -710,10 +712,21 @@
     "# note that the extent of each dimension should be pulled from the dataset\n",
     "dims_dict = {dim_names_dict['T']: pystac.extensions.datacube.Dimension({'type': 'temporal', 'description': stac_helpers.get_long_name(ds, dim_names_dict['T']), 'extent': [temporal_extent_lower.strftime('%Y-%m-%dT%XZ'), temporal_extent_upper.strftime('%Y-%m-%dT%XZ')], 'step':time_step}),\n",
     "             'nv': pystac.extensions.datacube.Dimension({'type': 'count', 'description': stac_helpers.get_long_name(ds, 'nv'), 'extent': [ds.nv.min().item(), ds.nv.max().item()]}),\n",
-    "#             'stations': pystac.extensions.datacube.Dimension({'type': 'spatial', 'description': stac_helpers.get_long_name(ds, 'bottom_top')}),\n",
+    "             'stations': pystac.extensions.datacube.Dimension({'type': 'geometry', 'description': stac_helpers.get_long_name(ds, 'stations'), 'bbox': spatial_bounds}),\n",
     "            }"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "15db7bae-e387-4377-852b-5f864c67ee69",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "# make sure you added all the right dims\n",
+    "assert list(dims_dict.keys()) == dims"
+   ]
+  },
   {
    "cell_type": "markdown",
    "id": "0f277883-a3fd-425f-966a-ca2140d0ef2f",
diff --git a/workflows/archive/TTU_2019_rcp85_station_data_create_collection_from_zarr.ipynb b/workflows/archive/TTU_2019_rcp85_station_data_create_collection_from_zarr.ipynb
index 1e12d094..ac1d9963 100644
--- a/workflows/archive/TTU_2019_rcp85_station_data_create_collection_from_zarr.ipynb
+++ b/workflows/archive/TTU_2019_rcp85_station_data_create_collection_from_zarr.ipynb
@@ -166,7 +166,9 @@
    "metadata": {},
    "source": [
     "## Identify x, y, t dimensions of dataset\n",
-    "May require user input if dimensions cannot be auto-detected."
+    "May require user input if dimensions cannot be auto-detected.\n",
+    "\n",
+    "**WARNING: no x, y dims in this dataset, but we will still include lat/lon as dims in our dict so we can use the same code snippets as usual to get a bbox for the dataset**"
    ]
   },
   {
@@ -710,10 +712,30 @@
     "# note that the extent of each dimension should be pulled from the dataset\n",
     "dims_dict = {dim_names_dict['T']: pystac.extensions.datacube.Dimension({'type': 'temporal', 'description': stac_helpers.get_long_name(ds, dim_names_dict['T']), 'extent': [temporal_extent_lower.strftime('%Y-%m-%dT%XZ'), temporal_extent_upper.strftime('%Y-%m-%dT%XZ')], 'step':time_step}),\n",
     "             'nv': pystac.extensions.datacube.Dimension({'type': 'count', 'description': stac_helpers.get_long_name(ds, 'nv'), 'extent': [ds.nv.min().item(), ds.nv.max().item()]}),\n",
-    "#             'stations': pystac.extensions.datacube.Dimension({'type': 'count', 'description': stac_helpers.get_long_name(ds, 'stations')}),\n",
+    "             'stations': pystac.extensions.datacube.Dimension({'type': 'geometry', 'description': stac_helpers.get_long_name(ds, 'stations'), 'bbox': spatial_bounds}),\n",
     "            }"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "910cf68e-5d1d-43f9-baad-b8b5709dcbd7",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "dims_dict.keys()"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "id": "74cac855-7570-42d6-a8a6-5d233bc06ad7",
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "list(dims_dict.keys()) == dims"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": null,
@@ -722,7 +744,7 @@
    "outputs": [],
    "source": [
     "# make sure you added all the right dims\n",
-    "assert dims_dict.keys() == dims"
+    "assert list(dims_dict.keys()) == dims"
    ]
   },
   {
-- 
GitLab