Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
has_dataset(
self._datasets['control'], 'control', 'compute a persistence forecast'
)
input_dict = {
'ensemble': self._datasets['initialized'],
'control': self._datasets['control'],
'init': True,
}
res = self._apply_climpred_function(
compute_persistence,
input_dict=input_dict,
metric=metric,
alignment='same_inits',
)
if self._temporally_smoothed:
res = _reset_temporal_axis(res, self._temporally_smoothed, dim='lead')
return res
'compute an uninitialized metric',
)
input_dict = {
'ensemble': self._datasets['uninitialized'],
'control': self._datasets['control'],
'init': False,
}
res = self._apply_climpred_function(
compute_perfect_model,
input_dict=input_dict,
metric=metric,
comparison=comparison,
**metric_kwargs,
)
if self._temporally_smoothed:
res = _reset_temporal_axis(res, self._temporally_smoothed, dim='lead')
return res
metric=metric,
comparison=comparison,
alignment=alignment,
dim=dim,
hist=hist,
reference=reference,
**metric_kwargs,
)
if self._temporally_smoothed:
if isinstance(res, dict) and not isinstance(res, xr.Dataset):
for res_key, res_item in res.items():
res[res_key] = _reset_temporal_axis(
res_item, self._temporally_smoothed, dim='lead'
)
else:
res = _reset_temporal_axis(res, self._temporally_smoothed, dim='lead')
return res
"""
has_dataset(self._datasets['control'], 'control', 'compute a metric')
input_dict = {
'ensemble': self._datasets['initialized'],
'control': self._datasets['control'],
'init': True,
}
init_skill = self._apply_climpred_function(
compute_perfect_model,
input_dict=input_dict,
metric=metric,
comparison=comparison,
**metric_kwargs,
)
if self._temporally_smoothed:
init_skill = _reset_temporal_axis(
init_skill, self._temporally_smoothed, dim='lead'
)
if isinstance(reference, str):
reference = [reference]
elif reference is None:
return init_skill
skill_labels = ['init']
if 'historical' in reference:
uninit_skill = self.compute_uninitialized(
metric=metric, comparison=comparison, **metric_kwargs
)
skill_labels.append('historical')
elif 'uninitialized' in reference:
uninit_skill = self.compute_uninitialized(
metric=metric, comparison=comparison, **metric_kwargs
)
}
res = self._apply_climpred_function(
_verify,
input_dict=input_dict,
metric=metric,
comparison=comparison,
alignment=alignment,
dim=dim,
hist=hist,
reference=reference,
**metric_kwargs,
)
if self._temporally_smoothed:
if isinstance(res, dict) and not isinstance(res, xr.Dataset):
for res_key, res_item in res.items():
res[res_key] = _reset_temporal_axis(
res_item, self._temporally_smoothed, dim='lead'
)
else:
res = _reset_temporal_axis(res, self._temporally_smoothed, dim='lead')
return res