From 12886b76f40f6e5ebe1cf034c056e0cf052bcce3 Mon Sep 17 00:00:00 2001 From: Gregory Ashton <gregory.ashton@ligo.org> Date: Sun, 3 Mar 2019 17:06:12 -0600 Subject: [PATCH] Minor fixes to the bilby loading of frame files - Recent changes to gw_data_find require an interfer to be passed for the strt and end time. This fixes that - Fixes bug where the pre-loaded channel name was ignored --- bilby/gw/detector.py | 4 ++-- bilby/gw/utils.py | 37 +++++++++++++++++++------------------ 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/bilby/gw/detector.py b/bilby/gw/detector.py index 2d685599..30bf7443 100644 --- a/bilby/gw/detector.py +++ b/bilby/gw/detector.py @@ -757,7 +757,7 @@ class InterferometerStrainData(object): sampling_frequency=sampling_frequency, start_time=start_time) - logger.info('Reading data from frame') + logger.info('Reading data from frame file {}'.format(frame_file)) strain = gwutils.read_frame_file( frame_file, start_time=start_time, end_time=start_time + duration, buffer_time=buffer_time, channel=channel, @@ -1591,7 +1591,7 @@ class Interferometer(object): df=(self.frequency_array[1] - self.frequency_array[0])), color='C2', label='Signal') - ax.grid('on') + ax.grid(True) ax.set_ylabel(r'strain [strain/$\sqrt{\rm Hz}$]') ax.set_xlabel(r'frequency [Hz]') ax.set_xlim(20, 2000) diff --git a/bilby/gw/utils.py b/bilby/gw/utils.py index 82d6c57b..d52a1a43 100644 --- a/bilby/gw/utils.py +++ b/bilby/gw/utils.py @@ -416,22 +416,23 @@ def read_frame_file(file_name, start_time, end_time, channel=None, buffer_time=0 except RuntimeError: logger.warning('Channel {} not found. Trying preset channel names'.format(channel)) - ligo_channel_types = ['GDS-CALIB_STRAIN', 'DCS-CALIB_STRAIN_C01', 'DCS-CALIB_STRAIN_C02', - 'DCH-CLEAN_STRAIN_C02'] - virgo_channel_types = ['Hrec_hoft_V1O2Repro2A_16384Hz', 'FAKE_h_16384Hz_4R'] - channel_types = dict(H1=ligo_channel_types, L1=ligo_channel_types, V1=virgo_channel_types) - for detector in channel_types.keys(): - for channel_type in channel_types[detector]: - if loaded: - break - channel = '{}:{}'.format(detector, channel_type) - try: - strain = TimeSeries.read(source=file_name, channel=channel, start=start_time, end=end_time, - **kwargs) - loaded = True - logger.info('Successfully read strain data for channel {}.'.format(channel)) - except RuntimeError: - pass + if loaded is False: + ligo_channel_types = ['GDS-CALIB_STRAIN', 'DCS-CALIB_STRAIN_C01', 'DCS-CALIB_STRAIN_C02', + 'DCH-CLEAN_STRAIN_C02'] + virgo_channel_types = ['Hrec_hoft_V1O2Repro2A_16384Hz', 'FAKE_h_16384Hz_4R'] + channel_types = dict(H1=ligo_channel_types, L1=ligo_channel_types, V1=virgo_channel_types) + for detector in channel_types.keys(): + for channel_type in channel_types[detector]: + if loaded: + break + channel = '{}:{}'.format(detector, channel_type) + try: + strain = TimeSeries.read(source=file_name, channel=channel, start=start_time, end=end_time, + **kwargs) + loaded = True + logger.info('Successfully read strain data for channel {}.'.format(channel)) + except RuntimeError: + pass if loaded: return strain @@ -542,8 +543,8 @@ def gw_data_find(observatory, gps_start_time, duration, calibration, cl_list = ['gw_data_find'] cl_list.append('--observatory {}'.format(observatory_code)) - cl_list.append('--gps-start-time {}'.format(gps_start_time)) - cl_list.append('--gps-end-time {}'.format(gps_end_time)) + cl_list.append('--gps-start-time {}'.format(int(np.floor(gps_start_time)))) + cl_list.append('--gps-end-time {}'.format(int(np.ceil(gps_end_time)))) cl_list.append('--type {}'.format(query_type)) cl_list.append('--output {}'.format(output_cache_file)) cl_list.append('--url-type file') -- GitLab