Skip to content

Commit a151eb4

Browse files
authored
Merge pull request #29 from crim-ca/cmip6_impl_fixes
Fix "source_id" terms for CMIP6 CV
2 parents 59c9b36 + d9f40b2 commit a151eb4

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
IMP_DIR = STACpopulator/implementations
22
STAC_HOST = http://localhost:8880/stac
3+
# CATALOG = https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/catalog/birdhouse/testdata/xclim/cmip6/catalog.html
4+
CATALOG = https://daccs.cs.toronto.edu/twitcher/ows/proxy/thredds/catalog/datasets/CMIP6/catalog.html
5+
# CATALOG = https://daccs.cs.toronto.edu/twitcher/ows/proxy/thredds/catalog/datasets/CMIP6/CMIP/NOAA-GFDL/catalog.html
6+
# CATALOG = https://daccs.cs.toronto.edu/twitcher/ows/proxy/thredds/catalog/datasets/CMIP6/CMIP/AS-RCEC/catalog.html
37

48
testcmip6:
5-
python $(IMP_DIR)/CMIP6_UofT/add_CMIP6.py $(STAC_HOST) https://pavics.ouranos.ca/twitcher/ows/proxy/thredds/catalog/birdhouse/testdata/xclim/cmip6/catalog.html
9+
python $(IMP_DIR)/CMIP6_UofT/add_CMIP6.py $(STAC_HOST) $(CATALOG)
610

711
delcmip6:
812
curl --location --request DELETE '$(STAC_HOST)/collections/CMIP6_UofT'

STACpopulator/implementations/CMIP6_UofT/add_CMIP6.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
InstitutionID = collection2literal(CV.institution_id)
3737
NominalResolution = collection2literal(CV.nominal_resolution)
3838
Realm = collection2literal(CV.realm)
39-
SourceID = collection2literal(CV.source_id)
39+
SourceID = collection2literal(CV.source_id, "source_id")
4040
SourceType = collection2literal(CV.source_type)
4141
SubExperimentID = collection2literal(CV.sub_experiment_id)
4242
TableID = collection2literal(CV.table_id)
@@ -74,7 +74,7 @@ class CMIP6ItemProperties(STACItemProperties, validate_assignment=True):
7474
physics_index: int
7575
realization_index: int
7676
forcing_index: int
77-
tracking_id: str = ""
77+
tracking_id: str = Field("")
7878
version: str = Field("")
7979
product: str
8080
license: str
@@ -162,7 +162,7 @@ def create_stac_item(self, item_name: str, item_data: MutableMapping[str, Any])
162162
dchelper = DataCubeHelper(item_data)
163163
dc_ext = DatacubeExtension.ext(item, add_if_missing=True)
164164
dc_ext.apply(dimensions=dchelper.dimensions, variables=dchelper.variables)
165-
except:
165+
except Exception:
166166
LOGGER.warning(f"Failed to add Datacube extension to item {item_name}")
167167

168168
# print(json.dumps(item.to_dict()))

STACpopulator/populator_base.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,5 @@ def ingest(self) -> None:
120120
for item_name, item_data in self._ingest_pipeline:
121121
LOGGER.info(f"Creating STAC representation for {item_name}")
122122
stac_item = self.create_stac_item(item_name, item_data)
123-
post_stac_item(self.stac_host, self.collection_id, item_name, stac_item, self.update)
123+
if stac_item != -1:
124+
post_stac_item(self.stac_host, self.collection_id, item_name, stac_item, self.update)

STACpopulator/stac_utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ def load_collection_configuration() -> MutableMapping[str, Any]:
7474
return collection_info
7575

7676

77-
def collection2literal(collection):
78-
terms = tuple(term.label for term in collection)
77+
def collection2literal(collection, property="label"):
78+
terms = tuple(getattr(term, property) for term in collection)
7979
return Literal[terms]
8080

8181

0 commit comments

Comments
 (0)