From b021ba38b1b2a09a6fe90c78004bfc3f3b1d2711 Mon Sep 17 00:00:00 2001
From: amsnyder <asnyder@usgs.gov>
Date: Thu, 11 Jan 2024 14:33:14 -0600
Subject: [PATCH] add in coord_bounds type check

---
 .../create_collection_from_zarr_conus404-daily.ipynb     | 9 +++++----
 .../examples/create_item_from_zarr_conus404-daily.ipynb  | 9 +++++----
 2 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/workflows/examples/create_collection_from_zarr_conus404-daily.ipynb b/workflows/examples/create_collection_from_zarr_conus404-daily.ipynb
index abd25f02..351132b1 100644
--- a/workflows/examples/create_collection_from_zarr_conus404-daily.ipynb
+++ b/workflows/examples/create_collection_from_zarr_conus404-daily.ipynb
@@ -274,7 +274,8 @@
    "id": "69f0d837-68a5-4fed-9a14-5d75cfbb0da4",
    "metadata": {},
    "source": [
-    "### Spatial Extent"
+    "### Spatial Extent\n",
+    "##### WARNING - make sure data type is **float** NOT **numpy.float64**"
    ]
   },
   {
@@ -287,13 +288,13 @@
     "# pull out lat/lon bbox for data\n",
     "# coordinates must be from WGS 84 datum\n",
     "# left, bottom, right, top\n",
-    "# Note: I'm not sure why but I have some trouble getting the data type right here - \n",
-    "# I've included all the options I've had to run to get it to not be a regular float rather \n",
-    "# than a numpy float below - switch the commented line if you have this issue\n",
+    "\n",
+    "# Note: try changing around the commented out lines below to get type float ratherthan a numpy float\n",
     "#coord_bounds = [ds.lon.data.min().compute().astype(float), ds.lat.data.min().compute().astype(float), ds.lon.data.max().compute().astype(float), ds.lat.data.max().compute().astype(float)]\n",
     "#coord_bounds = [ds.lon.data.min().compute().astype(float).tolist(), ds.lat.data.min().compute().astype(float).tolist(), ds.lon.data.max().compute().astype(float).tolist(), ds.lat.data.max().compute().astype(float).tolist()]\n",
     "coord_bounds = [ds.lon.data.min().astype(float).item(), ds.lat.data.min().astype(float).item(), ds.lon.data.max().astype(float).item(), ds.lat.data.max().astype(float).item()]\n",
     "print(coord_bounds)\n",
+    "print(f'\\ncoord_bounds data type: {type(coord_bounds[0])}')\n",
     "# create a spatial extent object \n",
     "spatial_extent = pystac.SpatialExtent(bboxes=[coord_bounds])"
    ]
diff --git a/workflows/examples/create_item_from_zarr_conus404-daily.ipynb b/workflows/examples/create_item_from_zarr_conus404-daily.ipynb
index 656c4dfb..dc10f78b 100644
--- a/workflows/examples/create_item_from_zarr_conus404-daily.ipynb
+++ b/workflows/examples/create_item_from_zarr_conus404-daily.ipynb
@@ -286,7 +286,8 @@
    "id": "69f0d837-68a5-4fed-9a14-5d75cfbb0da4",
    "metadata": {},
    "source": [
-    "### Spatial - Geometry and bbox"
+    "### Spatial - Geometry and bbox\n",
+    "##### WARNING - make sure data type is **float** NOT **numpy.float64**"
    ]
   },
   {
@@ -301,13 +302,13 @@
     "# pull out lat/lon bbox for data\n",
     "# coordinates must be from WGS 84 datum\n",
     "# left, bottom, right, top\n",
-    "# Note: I'm not sure why but I have some trouble getting the data type right here - \n",
-    "# I've included all the options I've had to run to get it to not be a regular float rather \n",
-    "# than a numpy float below - switch the commented line if you have this issue\n",
+    "\n",
+    "# Note: try changing around the commented out lines below to get type float ratherthan a numpy float\n",
     "#coord_bounds = [ds.lon.data.min().compute().astype(float), ds.lat.data.min().compute().astype(float), ds.lon.data.max().compute().astype(float), ds.lat.data.max().compute().astype(float)]\n",
     "#coord_bounds = [ds.lon.data.min().compute().astype(float).tolist(), ds.lat.data.min().compute().astype(float).tolist(), ds.lon.data.max().compute().astype(float).tolist(), ds.lat.data.max().compute().astype(float).tolist()]\n",
     "coord_bounds = [ds.lon.data.min().astype(float).item(), ds.lat.data.min().astype(float).item(), ds.lon.data.max().astype(float).item(), ds.lat.data.max().astype(float).item()]\n",
     "print(coord_bounds)\n",
+    "print(f'\\ncoord_bounds data type: {type(coord_bounds[0])}')\n",
     "# create a geometry object \n",
     "footprint = mapping(Polygon([\n",
     "            [coord_bounds[0], coord_bounds[1]],\n",
-- 
GitLab