diff --git a/pyleoclim/core/ensembleseries.py b/pyleoclim/core/ensembleseries.py index 42ef22d3..c84fc871 100644 --- a/pyleoclim/core/ensembleseries.py +++ b/pyleoclim/core/ensembleseries.py @@ -469,7 +469,10 @@ def quantiles(self, qs=[0.05, 0.5, 0.95], axis = 'value'): vals = [] for ts in self.series_list: if not np.array_equal(ts.time, time): - raise ValueError('Time axis not consistent across the ensemble!') + raise ValueError( + 'Time axis not consistent across the ensemble! ' + 'Apply common_time() first to place all members on a shared time axis.' + ) vals.append(ts.value) diff --git a/pyleoclim/tests/test_core_EnsembleSeries.py b/pyleoclim/tests/test_core_EnsembleSeries.py index 56b9686f..4eca73a1 100644 --- a/pyleoclim/tests/test_core_EnsembleSeries.py +++ b/pyleoclim/tests/test_core_EnsembleSeries.py @@ -286,6 +286,18 @@ def test_quantiles_t0(self): ens_qs = ts_ens.quantiles() + def test_quantiles_mismatched_time_axes(self): + """axis='value' requires a shared time axis; the error must name the fix""" + nt = 50 + t, v = pyleo.utils.gen_ts(model="colored_noise", nt=nt, alpha=1.0) + base = pyleo.Series(t, v, verbose=False) + shifted = pyleo.Series(t + 1, v, verbose=False) + + ts_ens = pyleo.EnsembleSeries([base, shifted]) + + with pytest.raises(ValueError, match="common_time"): + ts_ens.quantiles(axis="value") + def test_quantiles_t1(self): nn = 30 # number of age models