From 537f350f57f98b47c8c4bb7e0a2dd5712e98fc0c Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bayle <j2b.bayle@gmail.com> Date: Mon, 17 Jan 2022 18:26:31 -0800 Subject: [PATCH] Accept development versions for orbit, GW and glitch files --- lisainstrument/instrument.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py index 3161772..b23a56e 100644 --- a/lisainstrument/instrument.py +++ b/lisainstrument/instrument.py @@ -17,6 +17,7 @@ from h5py import File from scipy.signal import lfilter, kaiserord, firwin from scipy.interpolate import InterpolatedUnivariateSpline from scipy.integrate import cumulative_trapezoid +from packaging.version import Version from packaging.specifiers import SpecifierSet from lisaconstants import c @@ -498,9 +499,11 @@ class Instrument: self.orbit_file = orbits self.orbit_dataset = orbit_dataset with File(self.orbit_file, 'r') as orbitf: - version = orbitf.attrs['version'] + version = Version(orbitf.attrs['version']) logger.debug("Using orbit file version %s", version) - if version in SpecifierSet('~= 1.0'): + if version.is_devrelease: + logger.warning("You are using an orbit file in a development version") + if version in SpecifierSet('~= 1.0', True): self.init_orbits_file_1_0(orbitf) else: raise ValueError(f"unsupported orbit file version '{version}'") @@ -561,9 +564,11 @@ class Instrument: logger.info("Interpolating gravitational-wave responses from GW file '%s'", gws) self.gw_file = gws with File(self.gw_file, 'r') as gwf: - version = gwf.attrs['version'] + version = Version(gwf.attrs['version']) logger.debug("Using GW file version %s", version) - if version in SpecifierSet('~= 0.1') or version in SpecifierSet('~= 1.0'): + 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) ) @@ -591,9 +596,11 @@ class Instrument: self.glitch_file = glitches logger.info("Interpolating glitch signals from glitch file '%s'", self.glitch_file) with File(self.glitch_file, 'r') as glitchf: - version = glitchf.attrs['version'] + version = Version(glitchf.attrs['version']) logger.debug("Using glitch file version %s", version) - if version in SpecifierSet('~= 1.0'): + if version.is_devrelease: + logger.warning("You are using a glitch file in a development version") + if version in SpecifierSet('~= 1.0', True): self.glitch_tms = ForEachMOSA(lambda mosa: 0 if f'tm_{mosa}' not in glitchf else \ InterpolatedUnivariateSpline( -- GitLab