diff --git a/pyerrors/correlators.py b/pyerrors/correlators.py index 694dc9a5..cb40be1a 100644 --- a/pyerrors/correlators.py +++ b/pyerrors/correlators.py @@ -376,6 +376,24 @@ class Corr: """Reverse the time ordering of the Corr""" return Corr(self.content[:: -1]) + def thin(self, spacing=2, offset=0): + """Thin out a correlator to suppress correlations + + Parameters + ---------- + spacing : int + Keep only every 'spacing'th entry of the correlator + offset : int + Offset the equal spacing + """ + new_content = [] + for t in range(self.T): + if (offset + t) % spacing != 0: + new_content.append(None) + else: + new_content.append(self.content[t]) + return Corr(new_content) + def correlate(self, partner): """Correlate the correlator with another correlator or Obs diff --git a/tests/correlators_test.py b/tests/correlators_test.py index 1a394d63..2bbea0b5 100644 --- a/tests/correlators_test.py +++ b/tests/correlators_test.py @@ -283,3 +283,11 @@ def test_hankel(): corr.Hankel(2) corr.Hankel(6, periodic=True) + +def test_thin(): + c = pe.Corr([pe.pseudo_Obs(i, .1, 'test') for i in range(10)]) + c *= pe.cov_Obs(1., .1, '#ren') + thin = c.thin() + thin.fit(lambda a, x: a[0] * x) + c.thin(offset=1) + c.thin(3, offset=1)