From fd73812099277495f463fdc732d159e745d08c69 Mon Sep 17 00:00:00 2001 From: amsnyder <asnyder@usgs.gov> Date: Mon, 8 Apr 2024 13:06:33 -0500 Subject: [PATCH] fix crs var detection --- .../collection.json | 2 +- .../collection.json | 2 +- .../collection.json | 2 +- .../collection.json | 2 +- .../collection.json | 2 +- .../collection.json | 2 +- ...d_annual_create_collection_from_zarr.ipynb | 152 ++++++++++++---- ...ion_data_create_collection_from_zarr.ipynb | 160 +++++++++++++---- ...e_slices_create_collection_from_zarr.ipynb | 160 +++++++++++++---- ...d_annual_create_collection_from_zarr.ipynb | 160 +++++++++++++---- ...ion_data_create_collection_from_zarr.ipynb | 168 +++++++++++++----- ...e_slices_create_collection_from_zarr.ipynb | 156 ++++++++++++---- 12 files changed, 735 insertions(+), 233 deletions(-) diff --git a/catalog/TTU_2019_rcp45_gridded_annual/collection.json b/catalog/TTU_2019_rcp45_gridded_annual/collection.json index 76672c22..6ad26e12 100644 --- a/catalog/TTU_2019_rcp45_gridded_annual/collection.json +++ b/catalog/TTU_2019_rcp45_gridded_annual/collection.json @@ -320,7 +320,7 @@ }, "crs": { "dimensions": [], - "type": "data", + "type": "auxiliary", "description": null, "unit": null }, diff --git a/catalog/TTU_2019_rcp45_station_data/collection.json b/catalog/TTU_2019_rcp45_station_data/collection.json index 66e6647f..e011ce6d 100644 --- a/catalog/TTU_2019_rcp45_station_data/collection.json +++ b/catalog/TTU_2019_rcp45_station_data/collection.json @@ -68,7 +68,7 @@ }, "crs": { "dimensions": [], - "type": "data", + "type": "auxiliary", "description": null, "unit": null }, diff --git a/catalog/TTU_2019_rcp45_time_slices/collection.json b/catalog/TTU_2019_rcp45_time_slices/collection.json index f61855bd..92971f57 100644 --- a/catalog/TTU_2019_rcp45_time_slices/collection.json +++ b/catalog/TTU_2019_rcp45_time_slices/collection.json @@ -80,7 +80,7 @@ }, "crs": { "dimensions": [], - "type": "data", + "type": "auxiliary", "description": null, "unit": null }, diff --git a/catalog/TTU_2019_rcp85_gridded_annual/collection.json b/catalog/TTU_2019_rcp85_gridded_annual/collection.json index 1ce3aed4..689b2443 100644 --- a/catalog/TTU_2019_rcp85_gridded_annual/collection.json +++ b/catalog/TTU_2019_rcp85_gridded_annual/collection.json @@ -320,7 +320,7 @@ }, "crs": { "dimensions": [], - "type": "data", + "type": "auxiliary", "description": null, "unit": null }, diff --git a/catalog/TTU_2019_rcp85_station_data/collection.json b/catalog/TTU_2019_rcp85_station_data/collection.json index eb6782d6..32beafd9 100644 --- a/catalog/TTU_2019_rcp85_station_data/collection.json +++ b/catalog/TTU_2019_rcp85_station_data/collection.json @@ -68,7 +68,7 @@ }, "crs": { "dimensions": [], - "type": "data", + "type": "auxiliary", "description": null, "unit": null }, diff --git a/catalog/TTU_2019_rcp85_time_slices/collection.json b/catalog/TTU_2019_rcp85_time_slices/collection.json index 95cc8bb6..b1dcad86 100644 --- a/catalog/TTU_2019_rcp85_time_slices/collection.json +++ b/catalog/TTU_2019_rcp85_time_slices/collection.json @@ -80,7 +80,7 @@ }, "crs": { "dimensions": [], - "type": "data", + "type": "auxiliary", "description": null, "unit": null }, diff --git a/workflows/archive/TTU_2019_rcp45_gridded_annual_create_collection_from_zarr.ipynb b/workflows/archive/TTU_2019_rcp45_gridded_annual_create_collection_from_zarr.ipynb index b0615328..1b891a19 100644 --- a/workflows/archive/TTU_2019_rcp45_gridded_annual_create_collection_from_zarr.ipynb +++ b/workflows/archive/TTU_2019_rcp45_gridded_annual_create_collection_from_zarr.ipynb @@ -19,7 +19,9 @@ "cell_type": "code", "execution_count": null, "id": "201e0945-de55-45ff-b095-c2af009a4e62", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "import pystac\n", @@ -132,7 +134,9 @@ "cell_type": "code", "execution_count": null, "id": "708f2cf5-79ab-49af-8067-de31d0d13ee6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# open and view zarr dataset\n", @@ -154,7 +158,9 @@ "cell_type": "code", "execution_count": null, "id": "482d204d-b5b6-40e5-ac42-55b459be1097", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# description of STAC collection\n", @@ -188,7 +194,9 @@ "cell_type": "code", "execution_count": null, "id": "ab91268f-7200-4cb1-979a-c7d75531d2c0", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# dims_auto_extract = ['X', 'Y', 'T']\n", @@ -209,15 +217,29 @@ "## Get crs info" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "2d34fbc5-f0ce-4860-8cc5-9f3dcafb927d", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "crs_var = 'crs'" + ] + }, { "cell_type": "code", "execution_count": null, "id": "b03d52f3-1367-4255-a561-52ee4fc9e92d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# use pyproj to automatically extract crs info\n", - "crs = pyproj.CRS.from_cf(ds.crs.attrs)\n", + "crs = pyproj.CRS.from_cf(ds[crs_var].attrs)\n", "\n", "# alternatively, create the appropriate cartopy projection\n", "# crs = ccrs.LambertConformal(central_longitude=crs_info.longitude_of_central_meridian, \n", @@ -246,7 +268,9 @@ "cell_type": "code", "execution_count": null, "id": "d46805e0-8e94-4ebe-aa01-d9a2d7051459", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out lat/lon bbox for data\n", @@ -265,7 +289,9 @@ "cell_type": "code", "execution_count": null, "id": "cd7db627-4776-4780-ae42-413104c6a43a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "XX, YY = np.meshgrid(ds[dim_names_dict['X']].data, ds[dim_names_dict['Y']].data)" @@ -275,7 +301,9 @@ "cell_type": "code", "execution_count": null, "id": "4b3516fe-df9b-4855-be40-422f82a28ab0", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "transformer = Transformer.from_crs(crs, \"EPSG:4326\", always_xy=True)\n", @@ -286,7 +314,9 @@ "cell_type": "code", "execution_count": null, "id": "70c7d699-83d1-4ba7-9d46-7831d946f4c4", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(f'lower left coordinates (WGS84): {min(lon)}, {min(lat)}')\n", @@ -297,7 +327,9 @@ "cell_type": "code", "execution_count": null, "id": "8b4c75c9-0f03-4466-8df6-d2c78bdecbb5", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a spatial extent object \n", @@ -316,7 +348,9 @@ "cell_type": "code", "execution_count": null, "id": "41a84995-867c-4152-8c57-85e3758bbb77", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out first and last timestamps\n", @@ -336,7 +370,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1e37c4-5348-46ad-abc9-e005b5d6c02b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "collection_extent = pystac.Extent(spatial=spatial_extent, temporal=temporal_extent)" @@ -356,7 +392,9 @@ "cell_type": "code", "execution_count": null, "id": "adf6c59d-58cd-48b1-a5fd-3bb205a3ef56", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# define folder location where your STAC catalog json file is\n", @@ -369,7 +407,9 @@ "cell_type": "code", "execution_count": null, "id": "7e96811b-95ae-406a-9728-55fc429d4e1f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", @@ -398,7 +438,9 @@ "cell_type": "code", "execution_count": null, "id": "094832af-d22b-4359-b0f6-cf687acce5cc", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "asset_id = \"zarr-s3-osn\"\n", @@ -440,7 +482,9 @@ "cell_type": "code", "execution_count": null, "id": "fc00946d-2880-491d-9b3b-3aeeb4414d6c", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# instantiate extention on collection\n", @@ -459,7 +503,9 @@ "cell_type": "code", "execution_count": null, "id": "120a4914-3302-44a5-a282-0308ac84f040", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# list out dataset dimensions\n", @@ -473,7 +519,9 @@ "cell_type": "code", "execution_count": null, "id": "00a18a29-fb9a-4b56-8009-493122997b16", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# get x, y bounds for extent of those dimensions (required)\n", @@ -494,7 +542,9 @@ "cell_type": "code", "execution_count": null, "id": "ea452f62-5644-49b6-8a4e-7dc4f649fd1a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# print out crs information in dataset\n", @@ -505,7 +555,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1d05ff-8e43-44a7-8343-178b112c4ad6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # create the appropriate cartopy projection\n", @@ -546,7 +598,9 @@ "cell_type": "code", "execution_count": null, "id": "82f1e9bd-52ee-46f5-9e95-c2359d95fcf3", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "#time_step = pd.Timedelta(get_step(ds, dim_names_dict['T'], time_dim=True)).isoformat()\n", @@ -558,7 +612,9 @@ "cell_type": "code", "execution_count": null, "id": "64be65b2-de20-447a-a9c2-bd8eca3e440e", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for time steps: get all step values and locations\n", @@ -569,7 +625,9 @@ "cell_type": "code", "execution_count": null, "id": "bc8dff39-2a2e-44a0-9b30-987107c2d1e2", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for time steps, cont:\n", @@ -591,7 +649,9 @@ "cell_type": "code", "execution_count": null, "id": "a8ba7695-ca45-4db2-bd46-c465f4e37eff", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "x_step = stac_helpers.get_step(ds, dim_names_dict['X'])\n", @@ -602,7 +662,9 @@ "cell_type": "code", "execution_count": null, "id": "fac4c9f2-a952-4c7f-aa32-862957372d6f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps: get all step values and locations\n", @@ -615,7 +677,9 @@ "cell_type": "code", "execution_count": null, "id": "8d0b5a2d-dc58-4ad6-b890-859ce6bb08de", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -637,7 +701,9 @@ "cell_type": "code", "execution_count": null, "id": "7405583b-ecb9-44b0-8815-048e42e55a42", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "y_step = stac_helpers.get_step(ds, dim_names_dict['Y'])\n", @@ -648,7 +714,9 @@ "cell_type": "code", "execution_count": null, "id": "ece0fe37-b54c-4721-aa9b-33d2998d191b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps: get all step values and locations\n", @@ -661,7 +729,9 @@ "cell_type": "code", "execution_count": null, "id": "abdafb8f-5217-4b82-91b6-eec8183c9128", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -687,7 +757,9 @@ "cell_type": "code", "execution_count": null, "id": "acd45d3c-7845-47e6-9b7d-e35627a7ca9a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(dims)" @@ -697,7 +769,9 @@ "cell_type": "code", "execution_count": null, "id": "5a443497-67a9-4dce-a8e9-b08d31a88223", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a dictionary of datacube dimensions you would like to assign to this dataset\n", @@ -727,7 +801,9 @@ "cell_type": "code", "execution_count": null, "id": "e9272931-fc0b-4f2a-9546-283033e9cde8", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# drop metpy_crs coordinate we have added\n", @@ -750,7 +826,7 @@ "vars_dict={}\n", "for v in vars:\n", " unit = stac_helpers.get_unit(ds, v)\n", - " var_type = stac_helpers.get_var_type(ds, v)\n", + " var_type = stac_helpers.get_var_type(ds, v, crs_var)\n", " long_name = stac_helpers.get_long_name(ds, v)\n", " vars_dict[v] = pystac.extensions.datacube.Variable({'dimensions':list(ds[v].dims), 'type': var_type, 'description': long_name, 'unit': unit})" ] @@ -767,7 +843,9 @@ "cell_type": "code", "execution_count": null, "id": "10141fd4-91d6-491d-878b-02653720891d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# add dimesions and variables to collection extension\n", @@ -800,7 +878,9 @@ "cell_type": "code", "execution_count": null, "id": "4b75791b-6b2d-40be-b7c6-330a60888fb5", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", 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 f6c4fd1d..958ab8e3 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 @@ -19,7 +19,9 @@ "cell_type": "code", "execution_count": null, "id": "201e0945-de55-45ff-b095-c2af009a4e62", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "import pystac\n", @@ -55,7 +57,9 @@ "cell_type": "code", "execution_count": null, "id": "15ee060d-3127-4024-a1ad-6aa0648667e1", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# name for STAC collection - should match name of zarr dataset\n", @@ -128,7 +132,9 @@ "cell_type": "code", "execution_count": null, "id": "708f2cf5-79ab-49af-8067-de31d0d13ee6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# open and view zarr dataset\n", @@ -150,7 +156,9 @@ "cell_type": "code", "execution_count": null, "id": "482d204d-b5b6-40e5-ac42-55b459be1097", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# description of STAC collection\n", @@ -175,7 +183,9 @@ "cell_type": "code", "execution_count": null, "id": "ab91268f-7200-4cb1-979a-c7d75531d2c0", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# dims_auto_extract = ['X', 'Y', 'T']\n", @@ -195,15 +205,29 @@ "If there is no crs info that can be automatically extracted from the dataset with pyproj, you will need to manually identify the crs and create a crs object. This reference list of cartopy projections may be a helpful resource: https://scitools.org.uk/cartopy/docs/latest/reference/projections.html" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "d92e5107-4902-4cf7-8e38-28db2c840662", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "crs_var = 'crs'" + ] + }, { "cell_type": "code", "execution_count": null, "id": "b03d52f3-1367-4255-a561-52ee4fc9e92d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# use pyproj to automatically extract crs info\n", - "crs = pyproj.CRS.from_cf(ds.crs.attrs)\n", + "crs = pyproj.CRS.from_cf(ds[crs_var].attrs)\n", "\n", "# alternatively, create the appropriate cartopy projection\n", "# crs = ccrs.LambertConformal(central_longitude=crs_info.longitude_of_central_meridian, \n", @@ -223,7 +247,9 @@ "cell_type": "code", "execution_count": null, "id": "4cee13ba-487d-483e-a013-b65685137502", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "ds.crs" @@ -233,7 +259,9 @@ "cell_type": "code", "execution_count": null, "id": "f7bc73db-7717-450e-9679-525f7be0c910", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "crs.to_proj4()" @@ -260,7 +288,9 @@ "cell_type": "code", "execution_count": null, "id": "d46805e0-8e94-4ebe-aa01-d9a2d7051459", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out lat/lon bbox for data\n", @@ -279,7 +309,9 @@ "cell_type": "code", "execution_count": null, "id": "f16fdb9e-7ed8-40fb-a4f1-9ecabdebc0a1", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "XX, YY = np.meshgrid(ds[dim_names_dict['X']].data, ds[dim_names_dict['Y']].data)" @@ -289,7 +321,9 @@ "cell_type": "code", "execution_count": null, "id": "074fc23c-f4d9-4427-80d3-fbf691e6d411", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "transformer = Transformer.from_crs(crs, \"EPSG:4326\", always_xy=True)\n", @@ -300,7 +334,9 @@ "cell_type": "code", "execution_count": null, "id": "5345c975-9fe3-48e1-a663-0275cdf275dc", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(f'lower left coordinates (WGS84): {min(lon)}, {min(lat)}')\n", @@ -311,7 +347,9 @@ "cell_type": "code", "execution_count": null, "id": "e0a5a222-743d-403a-9411-2406374803cf", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a spatial extent object \n", @@ -330,7 +368,9 @@ "cell_type": "code", "execution_count": null, "id": "41a84995-867c-4152-8c57-85e3758bbb77", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out first and last timestamps\n", @@ -351,7 +391,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1e37c4-5348-46ad-abc9-e005b5d6c02b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "collection_extent = pystac.Extent(spatial=spatial_extent, temporal=temporal_extent)" @@ -369,7 +411,9 @@ "cell_type": "code", "execution_count": null, "id": "adf6c59d-58cd-48b1-a5fd-3bb205a3ef56", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# define folder location where your STAC catalog json file is\n", @@ -382,7 +426,9 @@ "cell_type": "code", "execution_count": null, "id": "7e96811b-95ae-406a-9728-55fc429d4e1f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", @@ -411,7 +457,9 @@ "cell_type": "code", "execution_count": null, "id": "094832af-d22b-4359-b0f6-cf687acce5cc", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "asset_id = \"zarr-s3-osn\"\n", @@ -453,7 +501,9 @@ "cell_type": "code", "execution_count": null, "id": "fc00946d-2880-491d-9b3b-3aeeb4414d6c", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# instantiate extention on collection\n", @@ -481,7 +531,9 @@ "cell_type": "code", "execution_count": null, "id": "ea452f62-5644-49b6-8a4e-7dc4f649fd1a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# print out crs information in dataset\n", @@ -492,7 +544,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1d05ff-8e43-44a7-8343-178b112c4ad6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # the datacube extension can accept reference_system information as a numerical EPSG code, \n", @@ -530,7 +584,9 @@ "cell_type": "code", "execution_count": null, "id": "82f1e9bd-52ee-46f5-9e95-c2359d95fcf3", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "#time_step = pd.Timedelta(get_step(ds, dim_names_dict['T'], time_dim=True)).isoformat()\n", @@ -542,7 +598,9 @@ "cell_type": "code", "execution_count": null, "id": "64be65b2-de20-447a-a9c2-bd8eca3e440e", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # optional debugging for time steps:\n", @@ -555,7 +613,9 @@ "cell_type": "code", "execution_count": null, "id": "bc8dff39-2a2e-44a0-9b30-987107c2d1e2", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for time steps, cont:\n", @@ -579,7 +639,9 @@ "cell_type": "code", "execution_count": null, "id": "a8ba7695-ca45-4db2-bd46-c465f4e37eff", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "x_step = stac_helpers.get_step(ds, dim_names_dict['X'])\n", @@ -593,7 +655,9 @@ "cell_type": "code", "execution_count": null, "id": "fac4c9f2-a952-4c7f-aa32-862957372d6f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # optional debugging for spatial steps:\n", @@ -608,7 +672,9 @@ "cell_type": "code", "execution_count": null, "id": "8d0b5a2d-dc58-4ad6-b890-859ce6bb08de", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -632,7 +698,9 @@ "cell_type": "code", "execution_count": null, "id": "7405583b-ecb9-44b0-8815-048e42e55a42", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "y_step = stac_helpers.get_step(ds, dim_names_dict['Y'])\n", @@ -646,7 +714,9 @@ "cell_type": "code", "execution_count": null, "id": "ece0fe37-b54c-4721-aa9b-33d2998d191b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # optional debugging for spatial steps:\n", @@ -661,7 +731,9 @@ "cell_type": "code", "execution_count": null, "id": "abdafb8f-5217-4b82-91b6-eec8183c9128", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -688,7 +760,9 @@ "cell_type": "code", "execution_count": null, "id": "acd45d3c-7845-47e6-9b7d-e35627a7ca9a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "dims = list(ds.dims)\n", @@ -699,7 +773,9 @@ "cell_type": "code", "execution_count": null, "id": "5a443497-67a9-4dce-a8e9-b08d31a88223", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a dictionary of datacube dimensions you would like to assign to this dataset\n", @@ -720,7 +796,9 @@ "cell_type": "code", "execution_count": null, "id": "15db7bae-e387-4377-852b-5f864c67ee69", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# make sure you added all the right dims\n", @@ -739,7 +817,9 @@ "cell_type": "code", "execution_count": null, "id": "e9272931-fc0b-4f2a-9546-283033e9cde8", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# drop metpy_crs coordinate we have added\n", @@ -762,7 +842,7 @@ "vars_dict={}\n", "for v in vars:\n", " unit = stac_helpers.get_unit(ds, v)\n", - " var_type = stac_helpers.get_var_type(ds, v)\n", + " var_type = stac_helpers.get_var_type(ds, v, crs_var)\n", " long_name = stac_helpers.get_long_name(ds, v)\n", " vars_dict[v] = pystac.extensions.datacube.Variable({'dimensions':list(ds[v].dims), 'type': var_type, 'description': long_name, 'unit': unit})" ] @@ -779,7 +859,9 @@ "cell_type": "code", "execution_count": null, "id": "10141fd4-91d6-491d-878b-02653720891d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# add dimesions and variables to collection extension\n", @@ -812,7 +894,9 @@ "cell_type": "code", "execution_count": null, "id": "4b75791b-6b2d-40be-b7c6-330a60888fb5", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", diff --git a/workflows/archive/TTU_2019_rcp45_time_slices_create_collection_from_zarr.ipynb b/workflows/archive/TTU_2019_rcp45_time_slices_create_collection_from_zarr.ipynb index f76a3fd5..2574cca9 100644 --- a/workflows/archive/TTU_2019_rcp45_time_slices_create_collection_from_zarr.ipynb +++ b/workflows/archive/TTU_2019_rcp45_time_slices_create_collection_from_zarr.ipynb @@ -19,7 +19,9 @@ "cell_type": "code", "execution_count": null, "id": "201e0945-de55-45ff-b095-c2af009a4e62", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "import pystac\n", @@ -55,7 +57,9 @@ "cell_type": "code", "execution_count": null, "id": "4572c6fa-c1da-4809-95e4-deea2119d5e6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# name for STAC collection - should match name of zarr dataset\n", @@ -130,7 +134,9 @@ "cell_type": "code", "execution_count": null, "id": "708f2cf5-79ab-49af-8067-de31d0d13ee6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# open and view zarr dataset\n", @@ -154,7 +160,9 @@ "cell_type": "code", "execution_count": null, "id": "482d204d-b5b6-40e5-ac42-55b459be1097", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# description of STAC collection\n", @@ -166,7 +174,9 @@ "cell_type": "code", "execution_count": null, "id": "a77517ef-a9cc-4b8c-9132-229580e192b1", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# license for dataset\n", @@ -186,7 +196,9 @@ "cell_type": "code", "execution_count": null, "id": "ab91268f-7200-4cb1-979a-c7d75531d2c0", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# dims_auto_extract = ['X', 'Y', 'T']\n", @@ -205,15 +217,29 @@ "## Get crs info" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "0f27113b-6488-4dad-961b-0ecb695bcd08", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "crs_var = 'crs'" + ] + }, { "cell_type": "code", "execution_count": null, "id": "b03d52f3-1367-4255-a561-52ee4fc9e92d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# use pyproj to automatically extract crs info\n", - "crs = pyproj.CRS.from_cf(ds.crs.attrs)\n", + "crs = pyproj.CRS.from_cf(ds[crs_var].attrs)\n", "\n", "# alternatively, create the appropriate cartopy projection\n", "# crs = ccrs.LambertConformal(central_longitude=crs_info.longitude_of_central_meridian, \n", @@ -242,7 +268,9 @@ "cell_type": "code", "execution_count": null, "id": "d46805e0-8e94-4ebe-aa01-d9a2d7051459", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out lat/lon bbox for data\n", @@ -261,7 +289,9 @@ "cell_type": "code", "execution_count": null, "id": "61dd5559-3284-4fc1-af8c-0db7258b7a18", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "XX, YY = np.meshgrid(ds[dim_names_dict['X']].data, ds[dim_names_dict['Y']].data)" @@ -271,7 +301,9 @@ "cell_type": "code", "execution_count": null, "id": "05af4c5e-1e6c-4589-b6f2-2e2fc1123b29", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "transformer = Transformer.from_crs(crs, \"EPSG:4326\", always_xy=True)\n", @@ -282,7 +314,9 @@ "cell_type": "code", "execution_count": null, "id": "3377c99a-434a-4e72-a997-644b495e5d95", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(f'lower left coordinates (WGS84): {min(lon)}, {min(lat)}')\n", @@ -293,7 +327,9 @@ "cell_type": "code", "execution_count": null, "id": "48d6f450-5833-44e4-a11d-6906aa3b2283", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a spatial extent object \n", @@ -312,7 +348,9 @@ "cell_type": "code", "execution_count": null, "id": "41a84995-867c-4152-8c57-85e3758bbb77", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out first and last timestamps\n", @@ -332,7 +370,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1e37c4-5348-46ad-abc9-e005b5d6c02b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "collection_extent = pystac.Extent(spatial=spatial_extent, temporal=temporal_extent)" @@ -352,7 +392,9 @@ "cell_type": "code", "execution_count": null, "id": "adf6c59d-58cd-48b1-a5fd-3bb205a3ef56", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# define folder location where your STAC catalog json file is\n", @@ -365,7 +407,9 @@ "cell_type": "code", "execution_count": null, "id": "7e96811b-95ae-406a-9728-55fc429d4e1f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", @@ -394,7 +438,9 @@ "cell_type": "code", "execution_count": null, "id": "094832af-d22b-4359-b0f6-cf687acce5cc", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "asset_id = \"zarr-s3-osn\"\n", @@ -436,7 +482,9 @@ "cell_type": "code", "execution_count": null, "id": "fc00946d-2880-491d-9b3b-3aeeb4414d6c", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# instantiate extention on collection\n", @@ -455,7 +503,9 @@ "cell_type": "code", "execution_count": null, "id": "120a4914-3302-44a5-a282-0308ac84f040", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# list out dataset dimensions\n", @@ -469,7 +519,9 @@ "cell_type": "code", "execution_count": null, "id": "00a18a29-fb9a-4b56-8009-493122997b16", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# get x, y bounds for extent of those dimensions (required)\n", @@ -490,7 +542,9 @@ "cell_type": "code", "execution_count": null, "id": "ea452f62-5644-49b6-8a4e-7dc4f649fd1a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# print out crs information in dataset\n", @@ -501,7 +555,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1d05ff-8e43-44a7-8343-178b112c4ad6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # create the appropriate cartopy projection\n", @@ -542,7 +598,9 @@ "cell_type": "code", "execution_count": null, "id": "82f1e9bd-52ee-46f5-9e95-c2359d95fcf3", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "#time_step = pd.Timedelta(get_step(ds, dim_names_dict['T'], time_dim=True)).isoformat()\n", @@ -554,7 +612,9 @@ "cell_type": "code", "execution_count": null, "id": "64be65b2-de20-447a-a9c2-bd8eca3e440e", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for time steps: get all step values and locations\n", @@ -565,7 +625,9 @@ "cell_type": "code", "execution_count": null, "id": "bc8dff39-2a2e-44a0-9b30-987107c2d1e2", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for time steps, cont:\n", @@ -587,7 +649,9 @@ "cell_type": "code", "execution_count": null, "id": "a8ba7695-ca45-4db2-bd46-c465f4e37eff", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "x_step = stac_helpers.get_step(ds, dim_names_dict['X'])\n", @@ -598,7 +662,9 @@ "cell_type": "code", "execution_count": null, "id": "fac4c9f2-a952-4c7f-aa32-862957372d6f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps: get all step values and locations\n", @@ -611,7 +677,9 @@ "cell_type": "code", "execution_count": null, "id": "8d0b5a2d-dc58-4ad6-b890-859ce6bb08de", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -633,7 +701,9 @@ "cell_type": "code", "execution_count": null, "id": "7405583b-ecb9-44b0-8815-048e42e55a42", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "y_step = stac_helpers.get_step(ds, dim_names_dict['Y'])\n", @@ -644,7 +714,9 @@ "cell_type": "code", "execution_count": null, "id": "ece0fe37-b54c-4721-aa9b-33d2998d191b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps: get all step values and locations\n", @@ -657,7 +729,9 @@ "cell_type": "code", "execution_count": null, "id": "abdafb8f-5217-4b82-91b6-eec8183c9128", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -683,7 +757,9 @@ "cell_type": "code", "execution_count": null, "id": "acd45d3c-7845-47e6-9b7d-e35627a7ca9a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(dims)" @@ -693,7 +769,9 @@ "cell_type": "code", "execution_count": null, "id": "5a443497-67a9-4dce-a8e9-b08d31a88223", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a dictionary of datacube dimensions you would like to assign to this dataset\n", @@ -723,7 +801,9 @@ "cell_type": "code", "execution_count": null, "id": "e9272931-fc0b-4f2a-9546-283033e9cde8", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# drop metpy_crs coordinate we have added\n", @@ -746,7 +826,7 @@ "vars_dict={}\n", "for v in vars:\n", " unit = stac_helpers.get_unit(ds, v)\n", - " var_type = stac_helpers.get_var_type(ds, v)\n", + " var_type = stac_helpers.get_var_type(ds, v, crs_var)\n", " long_name = stac_helpers.get_long_name(ds, v)\n", " vars_dict[v] = pystac.extensions.datacube.Variable({'dimensions':list(ds[v].dims), 'type': var_type, 'description': long_name, 'unit': unit})" ] @@ -763,7 +843,9 @@ "cell_type": "code", "execution_count": null, "id": "10141fd4-91d6-491d-878b-02653720891d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# add dimesions and variables to collection extension\n", @@ -796,7 +878,9 @@ "cell_type": "code", "execution_count": null, "id": "4b75791b-6b2d-40be-b7c6-330a60888fb5", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", diff --git a/workflows/archive/TTU_2019_rcp85_gridded_annual_create_collection_from_zarr.ipynb b/workflows/archive/TTU_2019_rcp85_gridded_annual_create_collection_from_zarr.ipynb index e67eff8e..0f5332dc 100644 --- a/workflows/archive/TTU_2019_rcp85_gridded_annual_create_collection_from_zarr.ipynb +++ b/workflows/archive/TTU_2019_rcp85_gridded_annual_create_collection_from_zarr.ipynb @@ -19,7 +19,9 @@ "cell_type": "code", "execution_count": null, "id": "201e0945-de55-45ff-b095-c2af009a4e62", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "import pystac\n", @@ -55,7 +57,9 @@ "cell_type": "code", "execution_count": null, "id": "4425c28a-50af-4cd6-ba99-7be2068833bd", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# name for STAC collection - should match name of zarr dataset\n", @@ -130,7 +134,9 @@ "cell_type": "code", "execution_count": null, "id": "708f2cf5-79ab-49af-8067-de31d0d13ee6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# open and view zarr dataset\n", @@ -152,7 +158,9 @@ "cell_type": "code", "execution_count": null, "id": "482d204d-b5b6-40e5-ac42-55b459be1097", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# description of STAC collection\n", @@ -164,7 +172,9 @@ "cell_type": "code", "execution_count": null, "id": "aa7ef52b-d89a-4d76-81a5-149bc95c32f5", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# license for dataset\n", @@ -184,7 +194,9 @@ "cell_type": "code", "execution_count": null, "id": "ab91268f-7200-4cb1-979a-c7d75531d2c0", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# dims_auto_extract = ['X', 'Y', 'T']\n", @@ -203,15 +215,29 @@ "## Get crs info" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "262f0882-9182-4470-a15a-4849b83ce3a9", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "crs_var = 'crs'" + ] + }, { "cell_type": "code", "execution_count": null, "id": "b03d52f3-1367-4255-a561-52ee4fc9e92d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# use pyproj to automatically extract crs info\n", - "crs = pyproj.CRS.from_cf(ds.crs.attrs)\n", + "crs = pyproj.CRS.from_cf(ds[crs_var].attrs)\n", "\n", "# alternatively, create the appropriate cartopy projection\n", "# crs = ccrs.LambertConformal(central_longitude=crs_info.longitude_of_central_meridian, \n", @@ -240,7 +266,9 @@ "cell_type": "code", "execution_count": null, "id": "d46805e0-8e94-4ebe-aa01-d9a2d7051459", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out lat/lon bbox for data\n", @@ -259,7 +287,9 @@ "cell_type": "code", "execution_count": null, "id": "f91e6693-e4be-4cb5-86d3-7386db1c0188", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "XX, YY = np.meshgrid(ds[dim_names_dict['X']].data, ds[dim_names_dict['Y']].data)" @@ -269,7 +299,9 @@ "cell_type": "code", "execution_count": null, "id": "8544a97d-62ea-4b26-9e8a-5d1663d3e632", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "transformer = Transformer.from_crs(crs, \"EPSG:4326\", always_xy=True)\n", @@ -280,7 +312,9 @@ "cell_type": "code", "execution_count": null, "id": "2bafc4d4-0401-4a2b-a025-2aa86bc5a15a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(f'lower left coordinates (WGS84): {min(lon)}, {min(lat)}')\n", @@ -291,7 +325,9 @@ "cell_type": "code", "execution_count": null, "id": "37fb3eb8-bc62-4179-9b70-6a17575e8f84", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a spatial extent object \n", @@ -310,7 +346,9 @@ "cell_type": "code", "execution_count": null, "id": "41a84995-867c-4152-8c57-85e3758bbb77", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out first and last timestamps\n", @@ -330,7 +368,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1e37c4-5348-46ad-abc9-e005b5d6c02b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "collection_extent = pystac.Extent(spatial=spatial_extent, temporal=temporal_extent)" @@ -350,7 +390,9 @@ "cell_type": "code", "execution_count": null, "id": "adf6c59d-58cd-48b1-a5fd-3bb205a3ef56", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# define folder location where your STAC catalog json file is\n", @@ -363,7 +405,9 @@ "cell_type": "code", "execution_count": null, "id": "7e96811b-95ae-406a-9728-55fc429d4e1f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", @@ -392,7 +436,9 @@ "cell_type": "code", "execution_count": null, "id": "094832af-d22b-4359-b0f6-cf687acce5cc", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "asset_id = \"zarr-s3-osn\"\n", @@ -434,7 +480,9 @@ "cell_type": "code", "execution_count": null, "id": "fc00946d-2880-491d-9b3b-3aeeb4414d6c", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# instantiate extention on collection\n", @@ -453,7 +501,9 @@ "cell_type": "code", "execution_count": null, "id": "120a4914-3302-44a5-a282-0308ac84f040", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# list out dataset dimensions\n", @@ -467,7 +517,9 @@ "cell_type": "code", "execution_count": null, "id": "00a18a29-fb9a-4b56-8009-493122997b16", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# get x, y bounds for extent of those dimensions (required)\n", @@ -488,7 +540,9 @@ "cell_type": "code", "execution_count": null, "id": "ea452f62-5644-49b6-8a4e-7dc4f649fd1a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# print out crs information in dataset\n", @@ -499,7 +553,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1d05ff-8e43-44a7-8343-178b112c4ad6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # create the appropriate cartopy projection\n", @@ -540,7 +596,9 @@ "cell_type": "code", "execution_count": null, "id": "82f1e9bd-52ee-46f5-9e95-c2359d95fcf3", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "#time_step = pd.Timedelta(get_step(ds, dim_names_dict['T'], time_dim=True)).isoformat()\n", @@ -552,7 +610,9 @@ "cell_type": "code", "execution_count": null, "id": "64be65b2-de20-447a-a9c2-bd8eca3e440e", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for time steps: get all step values and locations\n", @@ -563,7 +623,9 @@ "cell_type": "code", "execution_count": null, "id": "bc8dff39-2a2e-44a0-9b30-987107c2d1e2", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for time steps, cont:\n", @@ -585,7 +647,9 @@ "cell_type": "code", "execution_count": null, "id": "a8ba7695-ca45-4db2-bd46-c465f4e37eff", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "x_step = stac_helpers.get_step(ds, dim_names_dict['X'])\n", @@ -596,7 +660,9 @@ "cell_type": "code", "execution_count": null, "id": "fac4c9f2-a952-4c7f-aa32-862957372d6f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps: get all step values and locations\n", @@ -609,7 +675,9 @@ "cell_type": "code", "execution_count": null, "id": "8d0b5a2d-dc58-4ad6-b890-859ce6bb08de", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -631,7 +699,9 @@ "cell_type": "code", "execution_count": null, "id": "7405583b-ecb9-44b0-8815-048e42e55a42", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "y_step = stac_helpers.get_step(ds, dim_names_dict['Y'])\n", @@ -642,7 +712,9 @@ "cell_type": "code", "execution_count": null, "id": "ece0fe37-b54c-4721-aa9b-33d2998d191b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps: get all step values and locations\n", @@ -655,7 +727,9 @@ "cell_type": "code", "execution_count": null, "id": "abdafb8f-5217-4b82-91b6-eec8183c9128", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -681,7 +755,9 @@ "cell_type": "code", "execution_count": null, "id": "acd45d3c-7845-47e6-9b7d-e35627a7ca9a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(dims)" @@ -691,7 +767,9 @@ "cell_type": "code", "execution_count": null, "id": "5a443497-67a9-4dce-a8e9-b08d31a88223", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a dictionary of datacube dimensions you would like to assign to this dataset\n", @@ -721,7 +799,9 @@ "cell_type": "code", "execution_count": null, "id": "e9272931-fc0b-4f2a-9546-283033e9cde8", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# drop metpy_crs coordinate we have added\n", @@ -744,7 +824,7 @@ "vars_dict={}\n", "for v in vars:\n", " unit = stac_helpers.get_unit(ds, v)\n", - " var_type = stac_helpers.get_var_type(ds, v)\n", + " var_type = stac_helpers.get_var_type(ds, v, crs_var)\n", " long_name = stac_helpers.get_long_name(ds, v)\n", " vars_dict[v] = pystac.extensions.datacube.Variable({'dimensions':list(ds[v].dims), 'type': var_type, 'description': long_name, 'unit': unit})" ] @@ -761,7 +841,9 @@ "cell_type": "code", "execution_count": null, "id": "10141fd4-91d6-491d-878b-02653720891d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# add dimesions and variables to collection extension\n", @@ -794,7 +876,9 @@ "cell_type": "code", "execution_count": null, "id": "4b75791b-6b2d-40be-b7c6-330a60888fb5", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", 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 ac1d9963..22aa185e 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 @@ -19,7 +19,9 @@ "cell_type": "code", "execution_count": null, "id": "201e0945-de55-45ff-b095-c2af009a4e62", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "import pystac\n", @@ -55,7 +57,9 @@ "cell_type": "code", "execution_count": null, "id": "15ee060d-3127-4024-a1ad-6aa0648667e1", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# name for STAC collection - should match name of zarr dataset\n", @@ -128,7 +132,9 @@ "cell_type": "code", "execution_count": null, "id": "708f2cf5-79ab-49af-8067-de31d0d13ee6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# open and view zarr dataset\n", @@ -150,7 +156,9 @@ "cell_type": "code", "execution_count": null, "id": "482d204d-b5b6-40e5-ac42-55b459be1097", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# description of STAC collection\n", @@ -175,7 +183,9 @@ "cell_type": "code", "execution_count": null, "id": "ab91268f-7200-4cb1-979a-c7d75531d2c0", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# dims_auto_extract = ['X', 'Y', 'T']\n", @@ -195,15 +205,29 @@ "If there is no crs info that can be automatically extracted from the dataset with pyproj, you will need to manually identify the crs and create a crs object. This reference list of cartopy projections may be a helpful resource: https://scitools.org.uk/cartopy/docs/latest/reference/projections.html" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "aa8f1511-909c-422f-9be7-1d5c9a7e8054", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "crs_var = 'crs'" + ] + }, { "cell_type": "code", "execution_count": null, "id": "b03d52f3-1367-4255-a561-52ee4fc9e92d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# use pyproj to automatically extract crs info\n", - "crs = pyproj.CRS.from_cf(ds.crs.attrs)\n", + "crs = pyproj.CRS.from_cf(ds[crs_var].attrs)\n", "\n", "# alternatively, create the appropriate cartopy projection\n", "# crs = ccrs.LambertConformal(central_longitude=crs_info.longitude_of_central_meridian, \n", @@ -223,7 +247,9 @@ "cell_type": "code", "execution_count": null, "id": "4cee13ba-487d-483e-a013-b65685137502", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "ds.crs" @@ -233,7 +259,9 @@ "cell_type": "code", "execution_count": null, "id": "f7bc73db-7717-450e-9679-525f7be0c910", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "crs.to_proj4()" @@ -260,7 +288,9 @@ "cell_type": "code", "execution_count": null, "id": "d46805e0-8e94-4ebe-aa01-d9a2d7051459", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out lat/lon bbox for data\n", @@ -279,7 +309,9 @@ "cell_type": "code", "execution_count": null, "id": "f16fdb9e-7ed8-40fb-a4f1-9ecabdebc0a1", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "XX, YY = np.meshgrid(ds[dim_names_dict['X']].data, ds[dim_names_dict['Y']].data)" @@ -289,7 +321,9 @@ "cell_type": "code", "execution_count": null, "id": "074fc23c-f4d9-4427-80d3-fbf691e6d411", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "transformer = Transformer.from_crs(crs, \"EPSG:4326\", always_xy=True)\n", @@ -300,7 +334,9 @@ "cell_type": "code", "execution_count": null, "id": "5345c975-9fe3-48e1-a663-0275cdf275dc", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(f'lower left coordinates (WGS84): {min(lon)}, {min(lat)}')\n", @@ -311,7 +347,9 @@ "cell_type": "code", "execution_count": null, "id": "e0a5a222-743d-403a-9411-2406374803cf", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a spatial extent object \n", @@ -330,7 +368,9 @@ "cell_type": "code", "execution_count": null, "id": "41a84995-867c-4152-8c57-85e3758bbb77", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out first and last timestamps\n", @@ -351,7 +391,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1e37c4-5348-46ad-abc9-e005b5d6c02b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "collection_extent = pystac.Extent(spatial=spatial_extent, temporal=temporal_extent)" @@ -369,7 +411,9 @@ "cell_type": "code", "execution_count": null, "id": "adf6c59d-58cd-48b1-a5fd-3bb205a3ef56", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# define folder location where your STAC catalog json file is\n", @@ -382,7 +426,9 @@ "cell_type": "code", "execution_count": null, "id": "7e96811b-95ae-406a-9728-55fc429d4e1f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", @@ -411,7 +457,9 @@ "cell_type": "code", "execution_count": null, "id": "094832af-d22b-4359-b0f6-cf687acce5cc", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "asset_id = \"zarr-s3-osn\"\n", @@ -453,7 +501,9 @@ "cell_type": "code", "execution_count": null, "id": "fc00946d-2880-491d-9b3b-3aeeb4414d6c", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# instantiate extention on collection\n", @@ -481,7 +531,9 @@ "cell_type": "code", "execution_count": null, "id": "ea452f62-5644-49b6-8a4e-7dc4f649fd1a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# print out crs information in dataset\n", @@ -492,7 +544,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1d05ff-8e43-44a7-8343-178b112c4ad6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # the datacube extension can accept reference_system information as a numerical EPSG code, \n", @@ -530,7 +584,9 @@ "cell_type": "code", "execution_count": null, "id": "82f1e9bd-52ee-46f5-9e95-c2359d95fcf3", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "#time_step = pd.Timedelta(get_step(ds, dim_names_dict['T'], time_dim=True)).isoformat()\n", @@ -542,7 +598,9 @@ "cell_type": "code", "execution_count": null, "id": "64be65b2-de20-447a-a9c2-bd8eca3e440e", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # optional debugging for time steps:\n", @@ -555,7 +613,9 @@ "cell_type": "code", "execution_count": null, "id": "bc8dff39-2a2e-44a0-9b30-987107c2d1e2", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for time steps, cont:\n", @@ -579,7 +639,9 @@ "cell_type": "code", "execution_count": null, "id": "a8ba7695-ca45-4db2-bd46-c465f4e37eff", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "x_step = stac_helpers.get_step(ds, dim_names_dict['X'])\n", @@ -593,7 +655,9 @@ "cell_type": "code", "execution_count": null, "id": "fac4c9f2-a952-4c7f-aa32-862957372d6f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # optional debugging for spatial steps:\n", @@ -608,7 +672,9 @@ "cell_type": "code", "execution_count": null, "id": "8d0b5a2d-dc58-4ad6-b890-859ce6bb08de", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -632,7 +698,9 @@ "cell_type": "code", "execution_count": null, "id": "7405583b-ecb9-44b0-8815-048e42e55a42", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "y_step = stac_helpers.get_step(ds, dim_names_dict['Y'])\n", @@ -646,7 +714,9 @@ "cell_type": "code", "execution_count": null, "id": "ece0fe37-b54c-4721-aa9b-33d2998d191b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # optional debugging for spatial steps:\n", @@ -661,7 +731,9 @@ "cell_type": "code", "execution_count": null, "id": "abdafb8f-5217-4b82-91b6-eec8183c9128", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -688,7 +760,9 @@ "cell_type": "code", "execution_count": null, "id": "acd45d3c-7845-47e6-9b7d-e35627a7ca9a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "dims = list(ds.dims)\n", @@ -699,7 +773,9 @@ "cell_type": "code", "execution_count": null, "id": "5a443497-67a9-4dce-a8e9-b08d31a88223", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a dictionary of datacube dimensions you would like to assign to this dataset\n", @@ -720,7 +796,9 @@ "cell_type": "code", "execution_count": null, "id": "910cf68e-5d1d-43f9-baad-b8b5709dcbd7", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "dims_dict.keys()" @@ -730,7 +808,9 @@ "cell_type": "code", "execution_count": null, "id": "74cac855-7570-42d6-a8a6-5d233bc06ad7", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "list(dims_dict.keys()) == dims" @@ -740,7 +820,9 @@ "cell_type": "code", "execution_count": null, "id": "3d7d8551-13e2-4ec7-9f9c-b578d9780d66", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# make sure you added all the right dims\n", @@ -759,7 +841,9 @@ "cell_type": "code", "execution_count": null, "id": "e9272931-fc0b-4f2a-9546-283033e9cde8", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# drop metpy_crs coordinate we have added\n", @@ -782,7 +866,7 @@ "vars_dict={}\n", "for v in vars:\n", " unit = stac_helpers.get_unit(ds, v)\n", - " var_type = stac_helpers.get_var_type(ds, v)\n", + " var_type = stac_helpers.get_var_type(ds, v, crs_var)\n", " long_name = stac_helpers.get_long_name(ds, v)\n", " vars_dict[v] = pystac.extensions.datacube.Variable({'dimensions':list(ds[v].dims), 'type': var_type, 'description': long_name, 'unit': unit})" ] @@ -799,7 +883,9 @@ "cell_type": "code", "execution_count": null, "id": "10141fd4-91d6-491d-878b-02653720891d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# add dimesions and variables to collection extension\n", @@ -832,7 +918,9 @@ "cell_type": "code", "execution_count": null, "id": "4b75791b-6b2d-40be-b7c6-330a60888fb5", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", diff --git a/workflows/archive/TTU_2019_rcp85_time_slices_create_collection_from_zarr.ipynb b/workflows/archive/TTU_2019_rcp85_time_slices_create_collection_from_zarr.ipynb index 61d2f9d9..e0730e35 100644 --- a/workflows/archive/TTU_2019_rcp85_time_slices_create_collection_from_zarr.ipynb +++ b/workflows/archive/TTU_2019_rcp85_time_slices_create_collection_from_zarr.ipynb @@ -19,7 +19,9 @@ "cell_type": "code", "execution_count": null, "id": "201e0945-de55-45ff-b095-c2af009a4e62", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "import pystac\n", @@ -55,7 +57,9 @@ "cell_type": "code", "execution_count": null, "id": "a1e7b195-3e56-408a-b16b-52d79888728a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# name for STAC collection - should match name of zarr dataset\n", @@ -130,7 +134,9 @@ "cell_type": "code", "execution_count": null, "id": "708f2cf5-79ab-49af-8067-de31d0d13ee6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# open and view zarr dataset\n", @@ -152,7 +158,9 @@ "cell_type": "code", "execution_count": null, "id": "482d204d-b5b6-40e5-ac42-55b459be1097", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# description of STAC collection\n", @@ -186,7 +194,9 @@ "cell_type": "code", "execution_count": null, "id": "ab91268f-7200-4cb1-979a-c7d75531d2c0", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# dims_auto_extract = ['X', 'Y', 'T']\n", @@ -205,15 +215,29 @@ "## Get crs info" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "c2b5a003-a382-4887-8ca1-e51c54e9050b", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "crs_var = 'crs'" + ] + }, { "cell_type": "code", "execution_count": null, "id": "b03d52f3-1367-4255-a561-52ee4fc9e92d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# use pyproj to automatically extract crs info\n", - "crs = pyproj.CRS.from_cf(ds.crs.attrs)\n", + "crs = pyproj.CRS.from_cf(ds[crs_var].attrs)\n", "\n", "# alternatively, create the appropriate cartopy projection\n", "# crs = ccrs.LambertConformal(central_longitude=crs_info.longitude_of_central_meridian, \n", @@ -242,7 +266,9 @@ "cell_type": "code", "execution_count": null, "id": "d46805e0-8e94-4ebe-aa01-d9a2d7051459", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out lat/lon bbox for data\n", @@ -261,7 +287,9 @@ "cell_type": "code", "execution_count": null, "id": "e9ed6ff9-8ac0-4e8b-8641-9314f2d5e4e1", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "XX, YY = np.meshgrid(ds[dim_names_dict['X']].data, ds[dim_names_dict['Y']].data)" @@ -271,7 +299,9 @@ "cell_type": "code", "execution_count": null, "id": "797e274f-a9e6-4aa5-a9d9-070dada92a4f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "transformer = Transformer.from_crs(crs, \"EPSG:4326\", always_xy=True)\n", @@ -282,7 +312,9 @@ "cell_type": "code", "execution_count": null, "id": "1806104c-50b4-4266-a8dc-a0c67f554634", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(f'lower left coordinates (WGS84): {min(lon)}, {min(lat)}')\n", @@ -293,7 +325,9 @@ "cell_type": "code", "execution_count": null, "id": "18551939-abab-4cac-bc94-c6feb523fd4f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a spatial extent object \n", @@ -312,7 +346,9 @@ "cell_type": "code", "execution_count": null, "id": "41a84995-867c-4152-8c57-85e3758bbb77", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# pull out first and last timestamps\n", @@ -332,7 +368,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1e37c4-5348-46ad-abc9-e005b5d6c02b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "collection_extent = pystac.Extent(spatial=spatial_extent, temporal=temporal_extent)" @@ -352,7 +390,9 @@ "cell_type": "code", "execution_count": null, "id": "adf6c59d-58cd-48b1-a5fd-3bb205a3ef56", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# define folder location where your STAC catalog json file is\n", @@ -365,7 +405,9 @@ "cell_type": "code", "execution_count": null, "id": "7e96811b-95ae-406a-9728-55fc429d4e1f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", @@ -394,7 +436,9 @@ "cell_type": "code", "execution_count": null, "id": "094832af-d22b-4359-b0f6-cf687acce5cc", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "asset_id = \"zarr-s3-osn\"\n", @@ -436,7 +480,9 @@ "cell_type": "code", "execution_count": null, "id": "fc00946d-2880-491d-9b3b-3aeeb4414d6c", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# instantiate extention on collection\n", @@ -455,7 +501,9 @@ "cell_type": "code", "execution_count": null, "id": "120a4914-3302-44a5-a282-0308ac84f040", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# list out dataset dimensions\n", @@ -469,7 +517,9 @@ "cell_type": "code", "execution_count": null, "id": "00a18a29-fb9a-4b56-8009-493122997b16", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# get x, y bounds for extent of those dimensions (required)\n", @@ -490,7 +540,9 @@ "cell_type": "code", "execution_count": null, "id": "ea452f62-5644-49b6-8a4e-7dc4f649fd1a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# print out crs information in dataset\n", @@ -501,7 +553,9 @@ "cell_type": "code", "execution_count": null, "id": "1b1d05ff-8e43-44a7-8343-178b112c4ad6", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # create the appropriate cartopy projection\n", @@ -542,7 +596,9 @@ "cell_type": "code", "execution_count": null, "id": "82f1e9bd-52ee-46f5-9e95-c2359d95fcf3", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "#time_step = pd.Timedelta(get_step(ds, dim_names_dict['T'], time_dim=True)).isoformat()\n", @@ -554,7 +610,9 @@ "cell_type": "code", "execution_count": null, "id": "64be65b2-de20-447a-a9c2-bd8eca3e440e", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for time steps: get all step values and locations\n", @@ -565,7 +623,9 @@ "cell_type": "code", "execution_count": null, "id": "bc8dff39-2a2e-44a0-9b30-987107c2d1e2", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for time steps, cont:\n", @@ -587,7 +647,9 @@ "cell_type": "code", "execution_count": null, "id": "a8ba7695-ca45-4db2-bd46-c465f4e37eff", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "x_step = stac_helpers.get_step(ds, dim_names_dict['X'])\n", @@ -598,7 +660,9 @@ "cell_type": "code", "execution_count": null, "id": "fac4c9f2-a952-4c7f-aa32-862957372d6f", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps: get all step values and locations\n", @@ -611,7 +675,9 @@ "cell_type": "code", "execution_count": null, "id": "8d0b5a2d-dc58-4ad6-b890-859ce6bb08de", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -633,7 +699,9 @@ "cell_type": "code", "execution_count": null, "id": "7405583b-ecb9-44b0-8815-048e42e55a42", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "y_step = stac_helpers.get_step(ds, dim_names_dict['Y'])\n", @@ -644,7 +712,9 @@ "cell_type": "code", "execution_count": null, "id": "ece0fe37-b54c-4721-aa9b-33d2998d191b", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps: get all step values and locations\n", @@ -657,7 +727,9 @@ "cell_type": "code", "execution_count": null, "id": "abdafb8f-5217-4b82-91b6-eec8183c9128", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# # debugging for spatial steps, cont:\n", @@ -683,7 +755,9 @@ "cell_type": "code", "execution_count": null, "id": "acd45d3c-7845-47e6-9b7d-e35627a7ca9a", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "print(dims)" @@ -693,7 +767,9 @@ "cell_type": "code", "execution_count": null, "id": "5a443497-67a9-4dce-a8e9-b08d31a88223", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# create a dictionary of datacube dimensions you would like to assign to this dataset\n", @@ -723,7 +799,9 @@ "cell_type": "code", "execution_count": null, "id": "e9272931-fc0b-4f2a-9546-283033e9cde8", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# drop metpy_crs coordinate we have added\n", @@ -746,7 +824,7 @@ "vars_dict={}\n", "for v in vars:\n", " unit = stac_helpers.get_unit(ds, v)\n", - " var_type = stac_helpers.get_var_type(ds, v)\n", + " var_type = stac_helpers.get_var_type(ds, v, crs_var)\n", " long_name = stac_helpers.get_long_name(ds, v)\n", " vars_dict[v] = pystac.extensions.datacube.Variable({'dimensions':list(ds[v].dims), 'type': var_type, 'description': long_name, 'unit': unit})" ] @@ -763,7 +841,9 @@ "cell_type": "code", "execution_count": null, "id": "10141fd4-91d6-491d-878b-02653720891d", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "# add dimesions and variables to collection extension\n", @@ -796,7 +876,9 @@ "cell_type": "code", "execution_count": null, "id": "4b75791b-6b2d-40be-b7c6-330a60888fb5", - "metadata": {}, + "metadata": { + "tags": [] + }, "outputs": [], "source": [ "if catalog.get_child(collection_id):\n", -- GitLab