Exemplo n.º 1
0
def test_google_cmip_col():
    try:
        import intake
    except ImportError:
        intake = None
    if intake is None:
        with pytest.raises(ImportError):
            col = google_cmip_col(catalog="main")
    else:
        col = google_cmip_col(catalog="main")
        assert (col.catalog_file ==
                "https://storage.googleapis.com/cmip6/pangeo-cmip6.csv")

        with pytest.raises(ValueError):
            col = google_cmip_col(catalog="wrong")
Exemplo n.º 2
0
def data(source_id,
         variable_id,
         experiment_id,
         grid_label,
         use_intake_esm,
         catalog="main"):
    zarr_kwargs = {
        "consolidated": True,
        # "decode_times": False,
        "decode_times": True,
        "use_cftime": True,
    }

    cat = google_cmip_col(catalog=catalog).search(
        source_id=source_id,
        experiment_id=experiment_id,
        variable_id=variable_id,
        # member_id="r1i1p1f1",
        table_id="Omon",
        grid_label=grid_label,
    )

    if len(cat.df["zstore"]) > 0:
        if use_intake_esm:
            ddict = cat.to_dataset_dict(
                zarr_kwargs=zarr_kwargs,
                preprocess=combined_preprocessing,
                storage_options={"token": "anon"},
            )
            _, ds = ddict.popitem()
        else:
            ##### debugging options
            # @charlesbluca suggested this to make this work in GHA
            # https://github.com/jbusecke/cmip6_preprocessing/pull/62#issuecomment-741928365
            mm = fsspec.get_mapper(
                cat.df["zstore"]
                [0])  # think you can pass in storage options here as well?
            ds_raw = xr.open_zarr(mm, **zarr_kwargs)
            ds = combined_preprocessing(ds_raw)
    else:
        ds = None

    return ds, cat
Exemplo n.º 3
0
def test_google_cmip_col():
    col = google_cmip_col(catalog="main")
    assert col.catalog_file == "https://storage.googleapis.com/cmip6/pangeo-cmip6.csv"
def all_models():
    df = google_cmip_col().df
    all_models = df["source_id"].unique()
    all_models = tuple(np.sort(all_models))
    # all_models = tuple(["EC-Earth3"])
    return all_models