From f0daacee58129f7be294ca1094cf79779f45c51a Mon Sep 17 00:00:00 2001 From: ChiWai Chan <chiwai.chan@ligo.org> Date: Sun, 31 Mar 2019 21:54:43 +0900 Subject: [PATCH] svd_bank_snr.py gstlal_inspiral_calc_snr: fix sanity check for --start and --end --- gstlal-inspiral/bin/gstlal_inspiral_calc_snr | 5 ++-- gstlal-inspiral/python/svd_bank_snr.py | 27 +++++++++++--------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/gstlal-inspiral/bin/gstlal_inspiral_calc_snr b/gstlal-inspiral/bin/gstlal_inspiral_calc_snr index 680a63fe20..09ed6cc46d 100755 --- a/gstlal-inspiral/bin/gstlal_inspiral_calc_snr +++ b/gstlal-inspiral/bin/gstlal_inspiral_calc_snr @@ -147,8 +147,9 @@ def parse_command_line(): options, args = parser.parse_args() # Check SNR series output - if options.start >= options.end: - raise ValueError("--start must less than --end.") + if options.start and options.end: + if options.start >= options.end: + raise ValueError("--start must less than --end.") # Setting up GW data gw_data_source_info = datasource.GWDataSourceInfo(options) diff --git a/gstlal-inspiral/python/svd_bank_snr.py b/gstlal-inspiral/python/svd_bank_snr.py index 6f40d7573d..36432b44d6 100644 --- a/gstlal-inspiral/python/svd_bank_snr.py +++ b/gstlal-inspiral/python/svd_bank_snr.py @@ -122,22 +122,25 @@ class SNR_Pipeline(object): def get_snr_series(self, COMPLEX = False, row_number = None, start = None, end = None): gps_start = self.snr_info["epoch"].gpsSeconds + self.snr_info["epoch"].gpsNanoSeconds * 10.**-9 gps = gps_start + numpy.arange(len(self.snr_info["data"])) * self.snr_info["deltaT"] + if start and end: + if start >= end: + raise ValueError("Start time must be less than end time.") - if start >= end: - raise ValueError("Start time must be less than end time.") + if start - gps[0] >= 0 and start - gps[-1] <= 0: + s = abs(gps - start).argmin() + else: + raise ValueError("Invalid choice of start time %f." % start) - if start - gps[0] >= 0 and start - gps[-1] <= 0: - s = abs(gps - start).argmin() - else: - raise ValueError("Invalid choice of start time %f." % start) + if end - gps[0] >= 0 and end - gps[-1] <= 0: + e = abs(gps - end).argmin() + else: + raise ValueError("Invalid choice of end time %f." % end) - if end - gps[0] >= 0 and end - gps[-1] <= 0: - e = abs(gps - end).argmin() + self.snr_info["epoch"] = gps[s] + self.snr_info["data"] = self.snr_info["data"][s:e].T else: - raise ValueError("Invalid choice of end time %f." % end) - - self.snr_info["epoch"] = gps[s] - self.snr_info["data"] = self.snr_info["data"][s:e].T + self.snr_info["epoch"] = gps[0] + self.snr_info["data"] = self.snr_info["data"].T if row_number is None: temp = [] -- GitLab