`PerfectModel_persistence_from_initialized_lead_0=True` fails for other `reference` than `persistence`
aaronspring opened this issue · 0 comments
aaronspring commented
Describe the bug
kwargs not properly passed
Code Sample
for b in [False, True]: # True fails
with climpred.set_options(PerfectModel_persistence_from_initialized_lead_0=b):
pm.verify(metric='rmse', comparison='m2e', dim=['member','init'], reference=['persistence','climatology'], skipna=True)[v].plot(hue='skill',label=b)
plt.legend()
/Users/aaron.spring/Coding/climpred/climpred/classes.py:683: UserWarning: Error due to verification/control/uninitialized: xr.sel((), {'init': slice('1990', '2000', None)}) failed
KeyError: 'init is not a valid dimension or coordinate'
warnings.warn(
/Users/aaron.spring/Coding/climpred/climpred/classes.py:683: UserWarning: Error due to verification/control/uninitialized: xr.sel((), {'init': slice('1990', '2000', None)}) failed
KeyError: 'init is not a valid dimension or coordinate'
warnings.warn(
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Input In [25], in <module>
2 for b in [False, True]:
3 with climpred.set_options(PerfectModel_persistence_from_initialized_lead_0=b):
----> 4 pm.sel(init=slice('1990','2000')).verify(metric='rmse', comparison='m2e', dim=['member','init'], reference=['persistence','climatology'], skipna=True)[v].plot(hue='skill',label=b)
5 plt.legend()
File ~/Coding/climpred/climpred/classes.py:1371, in PerfectModelEnsemble.verify(self, metric, comparison, dim, reference, groupby, **metric_kwargs)
1366 if (
1367 not OPTIONS["PerfectModel_persistence_from_initialized_lead_0"]
1368 and r != "persistence"
1369 ):
1370 ref_compute_kwargs["comparison"] = comparison
-> 1371 ref = getattr(self, f"_compute_{r}")(**ref_compute_kwargs)
1372 result = xr.concat([result, ref], dim="skill", **CONCAT_KWARGS)
1373 result = result.assign_coords(skill=["initialized"] + reference)
File ~/Coding/climpred/climpred/classes.py:1556, in PerfectModelEnsemble._compute_climatology(self, metric, comparison, dim, **metric_kwargs)
1554 if dim is None:
1555 dim = list(self.get_initialized().isel(lead=0).dims)
-> 1556 res = self._apply_climpred_function(
1557 compute_climatology,
1558 input_dict=input_dict,
1559 metric=metric,
1560 comparison=comparison,
1561 dim=dim,
1562 **metric_kwargs,
1563 )
1564 if self._temporally_smoothed:
1565 res = _reset_temporal_axis(res, self._temporally_smoothed, dim="lead")
File ~/Coding/climpred/climpred/classes.py:1157, in PerfectModelEnsemble._apply_climpred_function(self, func, input_dict, **kwargs)
1155 if control:
1156 control = control.drop_vars(ctrl_vars)
-> 1157 return func(ensemble, control, **kwargs)
File ~/Coding/climpred/climpred/reference.py:242, in compute_climatology(initialized, verif, metric, comparison, alignment, dim, **metric_kwargs)
239 if "iteration" in initialized.dims:
240 initialized = initialized.isel(iteration=0, drop=True)
--> 242 if comparison.hindcast:
243 kind = "hindcast"
244 else:
AttributeError: 'NoneType' object has no attribute 'hindcast'
Expected behavior
should work