Пример #1
0
    def xcorr_norm(self):
        """The cross-correlation between every pairwise combination time-series
        in the object, where the zero lag correlation is normalized to be equal
        to the correlation coefficient between the time-series

        Returns
        -------

        TimeSeries: the time-dependent cross-correlation, with zero-lag
        at time=0"""

        tseries_length = self.input.data.shape[0]
        t_points = self.input.data.shape[-1]
        xcorr = np.zeros((tseries_length,
                          tseries_length,
                          t_points*2-1))
         
        for i in xrange(tseries_length): 
            for j in xrange(i,tseries_length):
                xcorr[i,j] = tsu.xcorr(self.input.data[i],self.input.data[j])
                xcorr[i,j] /= (xcorr[i,j,t_points])
                xcorr[i,j] *= self.output[i,j]

        idx = tsu.tril_indices(tseries_length,-1)
        xcorr[idx[0],idx[1],...] = xcorr[idx[1],idx[0],...]

        return ts.TimeSeries(xcorr,
                                sampling_interval=self.input.sampling_interval,
                                t0=-self.input.sampling_interval*t_points)
Пример #2
0
    def xcorr(self):
        """The cross-correlation between every pairwise combination time-series
        in the object. Uses np.correlation('full').

        Returns
        -------

        TimeSeries: the time-dependent cross-correlation, with zero-lag
        at time=0"""
        tseries_length = self.input.data.shape[0]
        t_points = self.input.data.shape[-1]
        xcorr = np.zeros((tseries_length,
                          tseries_length,
                          t_points*2-1))
         
        for i in xrange(tseries_length): 
            for j in xrange(i,tseries_length):
                xcorr[i][j] = tsu.xcorr(self.input.data[i],self.input.data[j])

        idx = tsu.tril_indices(tseries_length,-1)
        xcorr[idx[0],idx[1],...] = xcorr[idx[1],idx[0],...]

        return ts.TimeSeries(xcorr,
                                sampling_interval=self.input.sampling_interval,
                                t0=-self.input.sampling_interval*t_points)