diff --git a/lisainstrument/instrument.py b/lisainstrument/instrument.py index 3161772d86380753e733034e601383a39376ef92..b23a56ee9eaca1706c580a3e7b92899ce6ca94dc 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(