diff --git a/pycbc/psd/__init__.py b/pycbc/psd/__init__.py index 42faa6da1a1..83afe0551d0 100644 --- a/pycbc/psd/__init__.py +++ b/pycbc/psd/__init__.py @@ -318,17 +318,17 @@ def insert_psd_option_group_multi_ifo(parser): "mean, median or median-mean.") psd_options.add_argument("--psd-segment-length", type=float, nargs="+", action=MultiDetOptionAction, metavar='IFO:LENGTH', - help="(Required for --psd-estimation) The segment " - "length for PSD estimation (s)") + help="(Required for --psd-estimation) The " + "segment length for PSD estimation (s)") psd_options.add_argument("--psd-segment-stride", type=float, nargs="+", action=MultiDetOptionAction, metavar='IFO:STRIDE', - help="(Required for --psd-estimation) The separation" - " between consecutive segments (s)") + help="(Required for --psd-estimation) The " + "separation between consecutive segments (s)") psd_options.add_argument("--psd-num-segments", type=int, nargs="+", default=None, action=MultiDetOptionAction, metavar='IFO:NUM', - help="(Optional, used only with --psd-estimation). " - "If given PSDs will be estimated using only " + help="(Optional, used only with --psd-estimation)" + " If given PSDs will be estimated using only " "this number of segments. If more data is " "given than needed to make this number of " "segments than excess data will not be used in " @@ -336,8 +336,8 @@ def insert_psd_option_group_multi_ifo(parser): "the code will fail.") psd_options.add_argument("--psd-inverse-length", type=float, nargs="+", action=MultiDetOptionAction, metavar='IFO:LENGTH', - help="(Optional) The maximum length of the impulse" - " response of the overwhitening filter (s)") + help="(Optional) The maximum length of the " + "impulse response of the overwhitening filter(s)") psd_options.add_argument("--invpsd-trunc-method", default=None, choices=["hann"], help="(Optional) What truncation method to use " diff --git a/pycbc/psd/read.py b/pycbc/psd/read.py index 592f1afd294..4d0f7ed9aec 100644 --- a/pycbc/psd/read.py +++ b/pycbc/psd/read.py @@ -23,7 +23,7 @@ import scipy.interpolate from ligo import segments -from pycbc.types import FrequencySeries, load_frequencyseries, zeros, float32 +from pycbc.types import FrequencySeries, load_frequencyseries, zeros import pycbc.psd @@ -52,7 +52,8 @@ def from_numpy_arrays(freq_data, noise_data, length, delta_f, low_freq_cutoff): # Only include points above the low frequency cutoff if freq_data[0] > low_freq_cutoff: raise ValueError('Lowest frequency in input data ' - ' is higher than requested low-frequency cutoff ' + str(low_freq_cutoff)) + ' is higher than requested low-frequency cutoff ' + + str(low_freq_cutoff)) kmin = int(low_freq_cutoff / delta_f) flow = kmin * delta_f @@ -194,8 +195,13 @@ def from_xml(filename, length, delta_f, low_freq_cutoff, ifo_string=None, low_freq_cutoff) -class PrecomputedTimeVaryingPSD(object): +class PrecomputedTimeVaryingPSD: + '''Class to read merge psd like files and to attach + appropriate PSD to the data segment + ''' + def __init__(self, file_name, length=None, delta_f=None, f_low=None): + with h5py.File(file_name, 'r') as f: self.file_name = file_name detector = tuple(f.keys())[0] @@ -244,6 +250,8 @@ def assosiate_psd_to_inspiral_segment(self, inp_seg, delta_f=None): return best_psd def get_psd(self, index, delta_f=None): + '''fetch psd based on index corresponding to times. + ''' group = self.detector + '/psds/' + str(index) psd = load_frequencyseries(self.file_name, group=group) if delta_f is not None and psd.delta_f != delta_f: