Skip to content
Snippets Groups Projects
Commit f0daacee authored by ChiWai Chan's avatar ChiWai Chan
Browse files

svd_bank_snr.py gstlal_inspiral_calc_snr: fix sanity check for --start and --end

parent b02d2108
No related branches found
No related tags found
No related merge requests found
Pipeline #55602 passed with warnings
......@@ -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)
......
......@@ -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 = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment