diff --git a/catalog/Red_River_MPI-ESM-LR_future/collection.json b/catalog/Red_River_MPI-ESM-LR_future/collection.json index b70203aefdf7ac4b1235b6733be8428f70ade8f2..32fa32881ed3d6f6d0716a53c6bbd9f8e6d51a55 100644 --- a/catalog/Red_River_MPI-ESM-LR_future/collection.json +++ b/catalog/Red_River_MPI-ESM-LR_future/collection.json @@ -62,7 +62,7 @@ "cube:variables": { "crs": { "dimensions": [], - "type": "data", + "type": "auxiliary", "description": null, "unit": null }, diff --git a/catalog/Red_River_MPI-ESM-LR_historical/collection.json b/catalog/Red_River_MPI-ESM-LR_historical/collection.json index d62d21f041b4994febc3149aa8429876fda2a7e7..6f8471be7807642f8f405a637ece12cda3ae26e2 100644 --- a/catalog/Red_River_MPI-ESM-LR_historical/collection.json +++ b/catalog/Red_River_MPI-ESM-LR_historical/collection.json @@ -62,7 +62,7 @@ "cube:variables": { "crs": { "dimensions": [], - "type": "data", + "type": "auxiliary", "description": null, "unit": null }, diff --git a/catalog/Red_River_historical/collection.json b/catalog/Red_River_historical/collection.json index f02ff0deb452d8dca393b2d4717918a081213698..e2bd2b9868b8fbf8c15a318252c5974dd46bb435 100644 --- a/catalog/Red_River_historical/collection.json +++ b/catalog/Red_River_historical/collection.json @@ -62,7 +62,7 @@ "cube:variables": { "crs": { "dimensions": [], - "type": "data", + "type": "auxiliary", "description": null, "unit": null }, diff --git a/workflows/archive/Red_River_MPI-ESM-LR_future_create_collection_from_zarr.ipynb b/workflows/archive/Red_River_MPI-ESM-LR_future_create_collection_from_zarr.ipynb index e8080acf45beb5ae8012ca59cb280bdb945455be..e3555e1661e3263e8b16e05decb41b0406b1294c 100644 --- a/workflows/archive/Red_River_MPI-ESM-LR_future_create_collection_from_zarr.ipynb +++ b/workflows/archive/Red_River_MPI-ESM-LR_future_create_collection_from_zarr.ipynb @@ -207,6 +207,18 @@ "## Get crs info" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "1a5e0bed-68f9-4b99-8d96-0831e9348a4e", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "crs_var = 'crs'" + ] + }, { "cell_type": "code", "execution_count": null, @@ -215,7 +227,7 @@ "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", @@ -771,7 +783,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})" ] diff --git a/workflows/archive/Red_River_MPI-ESM-LR_historical_create_collection_from_zarr.ipynb b/workflows/archive/Red_River_MPI-ESM-LR_historical_create_collection_from_zarr.ipynb index 81de48c3dd15c39bd49ec7f2da162d76c2ec167f..1ed66e419bbff061d044691aa55258c295902029 100644 --- a/workflows/archive/Red_River_MPI-ESM-LR_historical_create_collection_from_zarr.ipynb +++ b/workflows/archive/Red_River_MPI-ESM-LR_historical_create_collection_from_zarr.ipynb @@ -207,6 +207,18 @@ "## Get crs info" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "0206f01c-02bb-42d8-885d-6b1644fba9cc", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "crs_var = 'crs'" + ] + }, { "cell_type": "code", "execution_count": null, @@ -215,7 +227,7 @@ "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", @@ -771,7 +783,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})" ] diff --git a/workflows/archive/Red_River_historical_create_collection_from_zarr.ipynb b/workflows/archive/Red_River_historical_create_collection_from_zarr.ipynb index 7558fc13f755b5a0220ce47dd632164a5de9f537..2d992eafb634744a0d4beec3c4ed40191b8d7168 100644 --- a/workflows/archive/Red_River_historical_create_collection_from_zarr.ipynb +++ b/workflows/archive/Red_River_historical_create_collection_from_zarr.ipynb @@ -207,6 +207,18 @@ "## Get crs info" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "840c5128-1928-4011-a52b-e9b35ab313d5", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "crs_var = 'crs'" + ] + }, { "cell_type": "code", "execution_count": null, @@ -215,7 +227,7 @@ "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", @@ -771,7 +783,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})" ] diff --git a/workflows/stac_helpers.py b/workflows/stac_helpers.py index a246630548f10b910a09f7ddb07e911255d997ed..55801bc9c7eb320ca7fcfa3fd4ee40d2da38c1eb 100644 --- a/workflows/stac_helpers.py +++ b/workflows/stac_helpers.py @@ -99,8 +99,8 @@ def get_unit(ds, v): assert cfunits.Units(unit).isvalid return unit -def get_var_type(ds, v): - if v in ds.coords: +def get_var_type(ds, v, crs_var): + if v in ds.coords or v==crs_var: # type = auxiliary for a variable that contains coordinate data, but isn't a dimension in cube:dimensions. # For example, the values of the datacube might be provided in the projected coordinate reference system, # but the datacube could have a variable lon with dimensions (y, x), giving the longitude at each point.