From d06eff1936db2be56086c029b9faba0ed6692a13 Mon Sep 17 00:00:00 2001 From: Timothy Smith Date: Thu, 19 Oct 2023 21:35:03 -0600 Subject: [PATCH] Remove spinup from sample indices (#44) --- xesn/driver.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/xesn/driver.py b/xesn/driver.py index c1babaa..98cda83 100644 --- a/xesn/driver.py +++ b/xesn/driver.py @@ -243,7 +243,7 @@ def get_samples(self, xda, n_samples, n_steps, n_spinup, random_seed=None, sampl else: assert len(sample_indices) == n_samples, f"Driver.get_samples: found different values for len(sample_indices) and n_samples" - samples = [xda.isel(time=slice(ridx, ridx+n_steps+n_spinup+1)) + samples = [xda.isel(time=slice(ridx-n_spinup, ridx+n_steps+1)) for ridx in sample_indices] return samples, sample_indices @@ -265,7 +265,9 @@ def get_sample_indices(self, data_length, n_samples, n_steps, n_spinup, random_s rstate = np.random.RandomState(seed=random_seed) n_valid = data_length - (n_steps + n_spinup) sample_indices = rstate.choice(n_valid, n_samples, replace=False) - sample_indices = list(int(x) for x in sample_indices) + + # add spinup here to get initial condition of the prediction, not including spinup + sample_indices = list(int(x+n_spinup) for x in sample_indices) return sample_indices