From 0f8cfee54db2f63d26efe6e45c077709fa5ffcdb Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bayle <j2b.bayle@gmail.com> Date: Wed, 29 Jun 2022 17:35:06 +0200 Subject: [PATCH] Implements GW files v2.0 --- lisainstrument/instrument.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py index e13c032..fe62ed6 100755 --- a/lisainstrument/instrument.py +++ b/lisainstrument/instrument.py @@ -682,10 +682,14 @@ class Instrument: logger.debug("Using GW file version %s", version) if version.is_devrelease: logger.warning("You are using a GW file in a development version") - if version in SpecifierSet('~= 0.1', True) or version in SpecifierSet('~= 1.0', True): - self.gws = ForEachMOSA(lambda mosa: InterpolatedUnivariateSpline( - gwf['t'][:], gwf[f'l_{mosa}'][:], k=5, ext='zeros')(self.physics_t) - ) + if version in SpecifierSet('== 0.1', True) or version in SpecifierSet('== 1.*', True): + interpolate = lambda data, t: InterpolatedUnivariateSpline(gwf['t'][:], data, k=5, ext='zeros')(t) + self.gws = ForEachMOSA(lambda mosa: interpolate(gwf[f'l_{mosa}'][:], self.physics_t)) + if version in SpecifierSet('== 2.*', True): + times = gwf.attrs['t0'] + np.arange(gwf.attrs['size']) * gwf.attrs['dt'] + interpolate = lambda data, t: InterpolatedUnivariateSpline(times, data, k=5, ext='zeros')(t) + link_index = {'12': 0, '23': 1, '31': 2, '13': 3, '32': 4, '21': 5} + self.gws = ForEachMOSA(lambda mosa: interpolate(gwf['tcb/y'][:, link_index[mosa]], self.physics_t)) else: raise ValueError(f"unsupported GW file version '{version}'") elif gws is None: -- GitLab