pangeo-data/climpred

`verify(reference="uninitialized", dim="init")` for multi-member `uninitialized` same skill for all members

aaronspring opened this issue · 2 comments

Describe the bug
A clear and concise description of what the bug is.

Code Sample

v = "SST"
from climpred.tutorial import load_dataset
from climpred import HindcastEnsemble
from climpred.stats import rm_poly
hind = load_dataset("CESM-DP-SST")[v]
hind.lead.attrs["units"] = "years"

hist = load_dataset("CESM-LE")[v]
hist = hist - hist.mean()

obs = load_dataset("ERSST")[v]
obs = obs - obs.mean()

hindcast = HindcastEnsemble(hind).add_uninitialized(hist)
hindcast=hindcast.add_observations(obs)
hindcast = hindcast.map(rm_poly, dim="init_or_time", deg=2)

hindcast.verify(dim='init',metric="mse",
        comparison="m2o", reference='uninitialized',
        alignment="maximize").SST.isel(skill=-1).plot(hue='member')

image

Expected behavior
member variance

source:

lforecast = lforecast.mean("member")

how fixed

if not metric.requires_member_dim and metric.probabilistic: # require probabilistic to solve https://github.com/pangeo-data/climpred/issues/735
        if "member" in lforecast.dims and "member" not in dim:
            lforecast = lforecast.mean(
                "member"
            )

in classses.py:

# fix #735
if r=='uninitialized' and 'member' in dim and 'member' in ref.dims:
    ref = ref.mean("member")