pangeo-data/climpred

ValueError 'init' because it is not a variable or dimension in this dataset

semvijverberg opened this issue · 2 comments

Describe the bug
When executing he.verify(), it raises a ValueError that 'init' is not a variable or dimension in this dataset. However, when looking at the he object (and the input), init is a dimension. Is this correct behavior? Or am I doing something wrong?

Code Sample

he = climpred.HindcastEnsemble(init).add_observations(obs)

model_edges = (
    init
    # .groupby("init.month")
    .quantile(q=[1/2], dim=["init", "member"], skipna=False).rename(
        {"quantile": "category_edge"}
    )
)

obs_edges = obs.quantile(q=[1/2], dim=["time"], skipna=False).rename(
    {"quantile": "category_edge"}
)
# %%

skill = he.verify(
    metric="rps",
    comparison="m2o",
    alignment="same_inits",
    dim=["member", "init"],
    category_edges=(obs_edges, model_edges),
)

raises:
image

he object:
image

Expected behavior
That it does not raise this error ;).

Output of climpred.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 3.8.13 | packaged by conda-forge | (default, Mar 25 2022, 06:05:47) [Clang 12.0.1 ] python-bits: 64 OS: Darwin OS-release: 20.6.0 machine: x86_64 processor: i386 byteorder: little LC_ALL: None LANG: nl_NL.UTF-8 LOCALE: nl_NL.UTF-8

climpred: 2.3.0
xarray: 2023.1.0
pandas: 1.4.2
numpy: 1.23.2
scipy: 1.8.0
cftime: 1.6.0
netcdf4: None
nc_time_axis: 1.4.1
matplotlib: 3.5.1
...
pip: 22.0.4
conda: None
IPython: 7.32.0
sphinx: 4.5.0

Sorry, I found the error. My model_edges mist the dimension 'init'!

Thanks for raising it though