<jupyter_start><jupyter_text>Climate Impact Lab Global Downscaled Projections for Climate Impacts ResearchThe Climate Impact Lab Downscaled Projections for Climate Impacts Research (CIL-GDPCR) collections contain bias corrected and downscaled 1/4° CMIP6 projections for temperature and precipitation.See the project homepage for more information: [github.com/ClimateImpactLab/downscaleCMIP6](https://github.com/ClimateImpactLab/downscaleCMIP6).This tutorial covers accessing the STAC API to explore the collections and open a dataset. Additional tutorials are available at [github.com/microsoft/PlanetaryComputerExamples](https://github.com/microsoft/PlanetaryComputerExamples/blob/main/datasets/cil-gdpcir).Try it live on Binder:[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/ClimateImpactLab/downscaleCMIP6-binder-env/main?urlpath=git-pull%3Frepo%3Dhttps%253A%252F%252Fgithub.com%252FClimateImpactLab%252FPlanetaryComputerExamples%26urlpath%3Dlab%252Ftree%252FPlanetaryComputerExamples%252Fdatasets%252Fcil-gdpcir%252Fcil-gdpcir-example.ipynb%26branch%3Dgdpcir-additional-notebooks)<jupyter_code>import planetary_computer
import pystac_client
import pystac<jupyter_output><empty_output><jupyter_text>STAC MetadataThe [CIL-GDPR datsets](https://planetarycomputer-staging.microsoft.com/dataset/group/cil-gdpcir) are grouped into several collections, depending on the license the data are provided under.- [CIL-GDPCIR-CC0](https://planetarycomputer-staging.microsoft.com/dataset/cil-gdpcir-cc0)- [CIL-GDPCIR-CC-BY](https://planetarycomputer-staging.microsoft.com/dataset/cil-gdpcir-cc-by)- [CIL-GDPCIR-CC-BY-SA](https://planetarycomputer-staging.microsoft.com/dataset/cil-gdpcir-cc-by-sa)The data assets in this collection are a set of [Zarr](https://zarr.readthedocs.io/) groups which can be opend by tools like [xarray](https://xarray.pydata.org/). Each Zarr group contains a single data variable (either `pr`, `tasmax`, or `tasmin`). The Planetary Computer provides a single STAC item per experiment, and each STAC item has one asset per data variable.<jupyter_code>item = pystac.read_file(
    "https://planetarycomputer-staging.microsoft.com/api/stac/v1/collections/cil-gdpcir-cc-by/items/cil-gdpcir-NUIST-NESM3-ssp585-r1i1p1f1-day"  # noqa
)
item.assets<jupyter_output><empty_output><jupyter_text>The STAC metadata includes all the required fields from the [CMIP 6 controlled vocabularies](https://wcrp-cmip.github.io/CMIP6_CVs/).<jupyter_code>item.properties["cmip6:source_id"]<jupyter_output><empty_output><jupyter_text>Querying the STAC APIUse the Planetary Computer STAC API to find the exact data you want. You'll most likely want to query on the controlled vocabularies fields, under the `cmip6:` prefix.. See the collection summary for the set of allowed values for each of those.<jupyter_code>item.get_collection().summaries.to_dict()
catalog = pystac_client.Client.open(
    "https://planetarycomputer-staging.microsoft.com/api/stac/v1"
)
search = catalog.search(
    collections=["cil-gdpcir-cc-by"],
    query={"cmip6:source_id": {"eq": "NESM3"}, "cmip6:experiment_id": {"eq": "ssp585"}},
)
items = search.get_all_items()
len(items)<jupyter_output><empty_output><jupyter_text>As usual, we sign the item before accessing the data. See [Using tokens for data access](https://planetarycomputer.microsoft.com/docs/concepts/sas/) for more.<jupyter_code>item = planetary_computer.sign(items[0])
item<jupyter_output><empty_output><jupyter_text>We can now load the assets with xarray:<jupyter_code>import xarray as xr

asset = item.assets["tasmax"]

ds = xr.open_dataset(asset.href, **asset.extra_fields["xarray:open_kwargs"])
ds<jupyter_output><empty_output><jupyter_text>And form a datacube with [`xarray.combine_by_coords`](https://docs.xarray.dev/en/stable/generated/xarray.combine_by_coords.html).<jupyter_code>import xarray as xr

asset = item.assets["tasmax"]
ds = xr.combine_by_coords(
    [
        xr.open_dataset(asset.href, **asset.extra_fields["xarray:open_kwargs"])
        for asset in item.assets.values()
    ],
    combine_attrs="drop_conflicts",
)
ds<jupyter_output><empty_output><jupyter_text>We'll load the data for a specific date and plot the result.<jupyter_code>tmax = ds.tasmax.isel(time=0).load()
tmax.plot(size=10);<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11763341067285382, 'fraction_numerical': 0.016473317865429233, 'mean_word_length': 6.711985688729874, 'pattern_counts': {'":': 4, '<': 33, '<?xml version=': 0, '>': 33, 'https://': 15, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '288635', 'license': 'MIT', 'n_tokens_mistral': 1540, 'n_tokens_neox': 1455, 'n_words': 285, 'path': 'datasets/cil-gdpcir/cil-gdpcir-example.ipynb', 'repo_name': 'RadiantMLHub/PlanetaryComputerExamples', 'size': '4310'}