コード例 #1
0
ファイル: tracker.py プロジェクト: bshaw1975/chirp
 def matched_spectrogram(self, signal, Fs):
     """
     Calculate a spectrogram of a signal using the same parameters
     as the template.  Returns spectrogram, time grid, and freq grid.
     """
     options = self.options
     spec = libtfr.tfr_spec(signal, options['nfft'], options['shift'], options['winsize'],
                            options['tfr_order'], options['tfr_tm'], options['tfr_flock'],
                            options['tfr_tlock'], fgrid=self.template.fgrid)
     return spec, libtfr.tgrid(spec, Fs, options['shift']), self.template.fgrid * Fs
コード例 #2
0
def test_tfr():
    nfft = 256
    Np = 201
    shift = 10
    K = 6
    tm = 6.0
    flock = 0.01
    tlock = 5
    Z = libtfr.tfr_spec(sig, nfft, shift, Np, K, tm, flock, tlock)
    assert_tuple_equal(Z.shape, (nfft//2 + 1, (sig.size - Np + 1)// shift))
    assert_equal(Z.dtype, libtfr.DTYPE)
コード例 #3
0
ファイル: test_libtfr.py プロジェクト: mtoqeerpk/libtfr
def test_tfr():
    nfft = 256
    Np = 201
    shift = 10
    K = 6
    tm = 6.0
    flock = 0.01
    tlock = 5
    Z = libtfr.tfr_spec(sig, nfft, shift, Np, K, tm, flock, tlock)
    assert_tuple_equal(Z.shape, (nfft // 2 + 1, (sig.size - Np) // shift + 1))
    assert_equal(Z.dtype, libtfr.DTYPE)
コード例 #4
0
ファイル: signal.py プロジェクト: bshaw1975/chirp
 def linspect(self, signal, Fs, nfft=None):
     """ Calculate the spectrogram on a linear power scale.  """
     import numpy as nx
     from libtfr import stft, tfr_spec, tgrid
     shift = int(self.options['window_shift'] * Fs)
     if not nfft:
         Np = int(Fs * self.options['window_len'])
         nfft = int(2 ** nx.ceil(nx.log2(Np)))
     else:
         Np = nfft
     if self.options['spec_method'] == 'tfr':
         S = tfr_spec(signal, nfft, shift, Np,
                      K=self.options['tfr_order'], tm=self.options['tfr_tm'],
                      flock=self.options['tfr_flock'], tlock=self.options['tfr_tlock'])
     else:
         try:
             wfun = getattr(nx, self.options['spec_method'])
             w = wfun(Np)
         except Exception, e:
             raise Error("invalid window function {}: {}".format(self.options['spec_method'], e))
         S = stft(signal, w, shift, nfft)
コード例 #5
0
def mgram(signal):
	mt = tfr.tfr_spec(signal,NF,T_STEP,NF)
	mt[mt==0] = np.amin(mt[mt>0])
	return mt