コード例 #1
0
ファイル: test_fftfilt.py プロジェクト: vapor36/kid_readout
def test_fftfilt_nd():
    np.random.seed(123)
    x = np.random.randn(2**16) + 1j * np.random.randn(2**16)
    b = np.random.randn(128)
    oned = fftfilt.fftfilt(b, x)
    nd = fftfilt.fftfilt_nd(b, x[:, None]).squeeze()
    assert np.allclose(oned, nd)

    x = x.reshape((2**12, 2**4))
    oned = np.zeros_like(x)
    for k in range(16):
        oned[:, k] = fftfilt.fftfilt(b, x[:, k])
    nd = fftfilt.fftfilt_nd(b, x)
    assert np.allclose(oned, nd)
コード例 #2
0
def test_fftfilt_nd():
    np.random.seed(123)
    x = np.random.randn(2 ** 16) + 1j * np.random.randn(2 ** 16)
    b = np.random.randn(128)
    oned = fftfilt.fftfilt(b, x)
    nd = fftfilt.fftfilt_nd(b, x[:, None]).squeeze()
    assert np.allclose(oned, nd)

    x = x.reshape((2 ** 12, 2 ** 4))
    oned = np.zeros_like(x)
    for k in range(16):
        oned[:, k] = fftfilt.fftfilt(b, x[:, k])
    nd = fftfilt.fftfilt_nd(b, x)
    assert np.allclose(oned, nd)
コード例 #3
0
def test_decimating_fir():
    np.random.seed(123)
    x = np.random.randn(2**16) + 1j * np.random.randn(2**16)
    dfir = decimating_fir.DecimatingFIR(downsample_factor=16, num_taps=1024)
    gold = fftfilt.fftfilt(dfir.coefficients.ravel(), x)[15::16]
    result = dfir.process(x)
    assert np.allclose(gold, result)
コード例 #4
0
def test_decimating_fir():
    np.random.seed(123)
    x = np.random.randn(2**16) + 1j*np.random.randn(2**16)
    dfir = decimating_fir.DecimatingFIR(downsample_factor=16,num_taps=1024)
    gold = fftfilt.fftfilt(dfir.coefficients.ravel(),x)[15::16]
    result = dfir.process(x)
    assert np.allclose(gold,result)
コード例 #5
0
ファイル: data_block.py プロジェクト: vapor36/kid_readout
 def mean(self):
     if self._mean is None:
         if self._lpf_data is None:
             self._lpf_data = fftfilt.fftfilt(
                 lpf, self.data)[len(lpf):] * self.wavenorm
         self._mean = self._lpf_data.mean(0, dtype='complex')
     return self._mean
コード例 #6
0
def low_pass_fir(data,
                 num_taps=256,
                 cutoff=1 / 256.,
                 nyquist_freq=1.0,
                 decimate_by=1):
    taps = scipy.signal.firwin(num_taps, cutoff / nyquist_freq)
    result = fftfilt(taps, data)[num_taps:]
    result = result[::decimate_by].copy(
    )  # add .copy to ensure we separate this from the full sized original data
    return result
コード例 #7
0
ファイル: data_block.py プロジェクト: ColumbiaCMB/kid_readout
 def mean_error(self):
     if self._std is None:
         if self._lpf_data is None:
             self._lpf_data = fftfilt.fftfilt(lpf,self.data)[len(lpf):]*self.wavenorm
         # the standard deviation is scaled by the number of independent samples
         # to compute the error on the mean.
         real_error = self._lpf_data.real.std(0)/np.sqrt(self._lpf_data.shape[0]/len(lpf))
         imag_error = self._lpf_data.imag.std(0)/np.sqrt(self._lpf_data.shape[0]/len(lpf))
         self._std = real_error + 1j*imag_error
     return self._std
コード例 #8
0
ファイル: despike.py プロジェクト: ColumbiaCMB/kid_readout
def deglitch_block(ts,thresh=5):
    tsl = np.roll(np.abs(fftfilt(scipy.signal.firwin(16,1/16.),ts)),-8)
    mask = medmadmask(tsl,thresh=thresh)
    mask[:-50] = mask[:-50] | mask[50:]
    mask[50:] = mask[50:] | mask[:-50]
    nmask = mask.sum()
#    print "rejecting",nmask/float(ts.shape[0])
    out = ts.copy()
    try:
        out[mask] = np.array(random.sample(ts[~mask],nmask))
    except ValueError:
        print "more masked values than samples to draw from!"    
    return out
コード例 #9
0
ファイル: data_block.py プロジェクト: vapor36/kid_readout
 def mean_error(self):
     if self._std is None:
         if self._lpf_data is None:
             self._lpf_data = fftfilt.fftfilt(
                 lpf, self.data)[len(lpf):] * self.wavenorm
         # the standard deviation is scaled by the number of independent samples
         # to compute the error on the mean.
         real_error = self._lpf_data.real.std(0) / np.sqrt(
             self._lpf_data.shape[0] / len(lpf))
         imag_error = self._lpf_data.imag.std(0) / np.sqrt(
             self._lpf_data.shape[0] / len(lpf))
         self._std = real_error + 1j * imag_error
     return self._std
コード例 #10
0
def deglitch_block(ts, thresh=5):
    tsl = np.roll(np.abs(fftfilt(scipy.signal.firwin(16, 1 / 16.), ts)), -8)
    mask = medmadmask(tsl, thresh=thresh)
    mask[:-50] = mask[:-50] | mask[50:]
    mask[50:] = mask[50:] | mask[:-50]
    nmask = mask.sum()
    #    print "rejecting",nmask/float(ts.shape[0])
    out = ts.copy()
    try:
        out[mask] = np.array(random.sample(ts[~mask], nmask))
    except ValueError:
        print "more masked values than samples to draw from!"
    return out
コード例 #11
0
ファイル: filters.py プロジェクト: ColumbiaCMB/kid_readout
def low_pass_fir(data, num_taps=256, cutoff=1/256.,nyquist_freq=1.0,decimate_by=1):
    taps = scipy.signal.firwin(num_taps,cutoff/nyquist_freq)
    result = fftfilt(taps,data)[num_taps:]
    result = result[::decimate_by].copy()  # add .copy to ensure we separate this from the full sized original data
    return result
コード例 #12
0
ファイル: despike.py プロジェクト: ColumbiaCMB/kid_readout
def lpf256(ts):
    return fftfilt(scipy.signal.firwin(256,1/256.),ts)
コード例 #13
0
def lpf256(ts):
    return fftfilt(scipy.signal.firwin(256, 1 / 256.), ts)
コード例 #14
0
ファイル: data_block.py プロジェクト: ColumbiaCMB/kid_readout
 def mean(self):
     if self._mean is None:
         if self._lpf_data is None:
             self._lpf_data = fftfilt.fftfilt(lpf,self.data)[len(lpf):]*self.wavenorm
         self._mean = self._lpf_data.mean(0,dtype='complex')
     return self._mean