示例#1
0
 def compute(self, raw: TimeSeries) -> TimeSeriesDict:
     out = TimeSeriesDict()
     times = unique([60 * (t.value // 60) for t in raw.times])
     raw.name = raw.name + '.mean'
     out[raw.name] = TimeSeries(
         [raw.crop(t - 60, t).mean().value for t in times[1:]], times=times)
     out[raw.name].__metadata_finalize__(raw)
     return out
示例#2
0
def filter_gwe(data:TimeSeries):
    from gwpy.signal import filter_design

    bp = filter_design.bandpass(50, 250, data.sample_rate)
    notches = [filter_design.notch(line, data.sample_rate) for line in (60, 120, 180)]
    zpk = filter_design.concatenate_zpks(bp, *notches)
    filt = data.filter(zpk, filtfilt=True)
    data = data.crop(*data.span.contract(1))
    filt = filt.crop(*filt.span.contract(1))
    return filt
示例#3
0
def makesine(freq, amp):
    fs = 4096
    time = np.arange(0,3, 1.0/fs)
    y1 = amp*np.sin( 2*np.pi*freq*time )
    sig1 = TimeSeries(y1, dt=1.0/fs).taper() # ALS: Effect visible in plot: need to address or hide.
    plt.figure()
    fig_sig1 = sig1.crop(cropstart, cropend).plot()
    plt.xlim(cropstart, cropend)
    plt.ylim(-5,5)
    plt.title('Frequency {0} Hz - Amplitude {1}'.format(freq,amp))
    st.pyplot(fig_sig1, clear_figure=True)
    return(sig1)
示例#4
0
    def _get_tf_path(self, approximant='SEOBNRv4_opt', sample_rate=4096 * 4):
        """
        Get frequency track of an event based on GraceDb parameters.

        Parameters
        ----------
        approximant : str, optional
        f_lower : int, optional
        sample_rate : int, optional

        Returns
        -------
        tf_path : gwpy.timeseries.TimeSeries object
            Time series of frequency.
        """
        if not all(
                hasattr(self, x) for x in
            ['graceid', 'm1', 'm2', 's1z', 's2z', 'start_time', 'end_time']):
            return None
        hp, hc = get_td_waveform(approximant='SEOBNRv4_opt',
                                 mass1=self.m1,
                                 mass2=self.m2,
                                 spin1z=self.s1z,
                                 spin2z=self.s2z,
                                 delta_t=1.0 / sample_rate,
                                 f_lower=30,
                                 frame_axis=SIM_INSPIRAL_FRAME_AXIS_ORBITAL_L)
        foft = frequency_from_polarizations(hp, hc)
        try:
            foft = utils.trim_foft(foft)
        except:
            pass
        tf_path = TimeSeries(foft,
                             t0=self.end_time + float(foft.start_time),
                             dt=foft.delta_t)
        tf_path = tf_path.crop(self.start_time, self.end_time)
        tf_path.name = self.graceid + '_path'
        return tf_path