当前位置: 首页>>代码示例>>Python>>正文


Python mlab.psd方法代码示例

本文整理汇总了Python中matplotlib.mlab.psd方法的典型用法代码示例。如果您正苦于以下问题:Python mlab.psd方法的具体用法?Python mlab.psd怎么用?Python mlab.psd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.mlab的用法示例。


在下文中一共展示了mlab.psd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: update

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def update(self, *args):
        # save center freq. since we're gonna be changing it
        start_fc = self.sdr.fc

        # prepare space in buffer
        # TODO: use indexing to avoid recreating buffer each time
        self.image_buffer = np.roll(self.image_buffer, 1, axis=0)

        for scan_num, start_ind in enumerate(range(0, NUM_SCANS_PER_SWEEP*NFFT, NFFT)):
            self.sdr.fc += self.sdr.rs*scan_num

            # estimate PSD for one scan
            samples = self.sdr.read_samples(NUM_SAMPLES_PER_SCAN)
            psd_scan, f = psd(samples, NFFT=NFFT)

            self.image_buffer[0, start_ind: start_ind+NFFT] = 10*np.log10(psd_scan)

        # plot entire sweep
        self.image.set_array(self.image_buffer)

        # restore original center freq.
        self.sdr.fc = start_fc

        return self.image, 
开发者ID:sailoog,项目名称:openplotter,代码行数:26,代码来源:SDR_AIS_waterfall.py

示例2: test_psd_csd_equal

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_psd_csd_equal(self):
        freqs = self.freqs_density
        Pxx, freqsxx = mlab.psd(x=self.y,
                                NFFT=self.NFFT_density,
                                Fs=self.Fs,
                                noverlap=self.nover_density,
                                pad_to=self.pad_to_density,
                                sides=self.sides)
        Pxy, freqsxy = mlab.csd(x=self.y, y=self.y,
                                NFFT=self.NFFT_density,
                                Fs=self.Fs,
                                noverlap=self.nover_density,
                                pad_to=self.pad_to_density,
                                sides=self.sides)
        assert_array_equal(Pxx, Pxy)
        assert_array_equal(freqsxx, freqsxy) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:18,代码来源:test_mlab.py

示例3: test_specgram_auto_default_equal

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_specgram_auto_default_equal(self):
        '''test that mlab.specgram without mode and with mode 'default' and
        'psd' are all the same'''
        freqs = self.freqs_specgram
        speca, freqspeca, ta = mlab.specgram(x=self.y,
                                             NFFT=self.NFFT_specgram,
                                             Fs=self.Fs,
                                             noverlap=self.nover_specgram,
                                             pad_to=self.pad_to_specgram,
                                             sides=self.sides)
        specb, freqspecb, tb = mlab.specgram(x=self.y,
                                             NFFT=self.NFFT_specgram,
                                             Fs=self.Fs,
                                             noverlap=self.nover_specgram,
                                             pad_to=self.pad_to_specgram,
                                             sides=self.sides,
                                             mode='default')
        assert_array_equal(speca, specb)
        assert_array_equal(freqspeca, freqspecb)
        assert_array_equal(ta, tb) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:22,代码来源:test_mlab.py

示例4: test_specgram_auto_psd_equal

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_specgram_auto_psd_equal(self):
        '''test that mlab.specgram without mode and with mode 'default' and
        'psd' are all the same'''
        freqs = self.freqs_specgram
        speca, freqspeca, ta = mlab.specgram(x=self.y,
                                             NFFT=self.NFFT_specgram,
                                             Fs=self.Fs,
                                             noverlap=self.nover_specgram,
                                             pad_to=self.pad_to_specgram,
                                             sides=self.sides)
        specc, freqspecc, tc = mlab.specgram(x=self.y,
                                             NFFT=self.NFFT_specgram,
                                             Fs=self.Fs,
                                             noverlap=self.nover_specgram,
                                             pad_to=self.pad_to_specgram,
                                             sides=self.sides,
                                             mode='psd')
        assert_array_equal(speca, specc)
        assert_array_equal(freqspeca, freqspecc)
        assert_array_equal(ta, tc) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:22,代码来源:test_mlab.py

示例5: test_psd_windowarray_equal

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_psd_windowarray_equal(self):
        freqs = self.freqs_density
        win = mlab.window_hanning(np.ones(self.NFFT_density_real))
        speca, fspa = mlab.psd(x=self.y,
                               NFFT=self.NFFT_density,
                               Fs=self.Fs,
                               noverlap=self.nover_density,
                               pad_to=self.pad_to_density,
                               sides=self.sides,
                               window=win)
        specb, fspb = mlab.psd(x=self.y,
                               NFFT=self.NFFT_density,
                               Fs=self.Fs,
                               noverlap=self.nover_density,
                               pad_to=self.pad_to_density,
                               sides=self.sides)
        assert_array_equal(fspa, fspb)
        assert_allclose(speca, specb, atol=1e-08) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:20,代码来源:test_mlab.py

示例6: test_psd_csd_equal

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_psd_csd_equal(self):
        freqs = self.freqs_density
        Pxx, freqsxx = mlab.psd(x=self.y,
                                NFFT=self.NFFT_density,
                                Fs=self.Fs,
                                noverlap=self.nover_density,
                                pad_to=self.pad_to_density,
                                sides=self.sides)
        Pxy, freqsxy = mlab.csd(x=self.y, y=self.y,
                                NFFT=self.NFFT_density,
                                Fs=self.Fs,
                                noverlap=self.nover_density,
                                pad_to=self.pad_to_density,
                                sides=self.sides)
        assert_array_almost_equal_nulp(Pxx, Pxy)
        assert_array_equal(freqsxx, freqsxy) 
开发者ID:holzschu,项目名称:python3_ios,代码行数:18,代码来源:test_mlab.py

示例7: test_psd_windowarray_equal

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_psd_windowarray_equal(self):
        freqs = self.freqs_density
        win = mlab.window_hanning(np.ones(self.NFFT_density_real))
        speca, fspa = mlab.psd(x=self.y,
                               NFFT=self.NFFT_density,
                               Fs=self.Fs,
                               noverlap=self.nover_density,
                               pad_to=self.pad_to_density,
                               sides=self.sides,
                               window=win)
        specb, fspb = mlab.psd(x=self.y,
                               NFFT=self.NFFT_density,
                               Fs=self.Fs,
                               noverlap=self.nover_density,
                               pad_to=self.pad_to_density,
                               sides=self.sides)
        assert_array_equal(fspa, fspb)
        assert_allclose(speca, specb, atol=1e-08)


# extra test for cohere... 
开发者ID:holzschu,项目名称:python3_ios,代码行数:23,代码来源:test_mlab.py

示例8: __capture

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def __capture(self, data, _sdr):
        timestamp = time.time()
        dst = ctypes.byref(self._capture, 0)
        ctypes.memmove(dst, data, len(data))

        iq = self.__stream_to_complex(self._capture)
        l, f = psd(iq, BINS, SAMPLE_RATE,
                   scale_by_freq=False,
                   noverlap=-SAMPLES / 64)
        f /= 1e6
        f += self._freq

        event = Event(Events.SCAN_DATA, timestamp=timestamp, l=l, f=f)
        post_event(self._eventHandler, event) 
开发者ID:EarToEarOak,项目名称:RF-Monitor,代码行数:16,代码来源:receive.py

示例9: __on_freq

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def __on_freq(self, freq):
        _l, freqs = psd(numpy.zeros(2, dtype=numpy.complex64),
                        BINS, SAMPLE_RATE)
        freqs /= 1e6
        freqs += freq
        self._freqs = freqs.tolist()

        if self._receive is not None:
            self._receive.set_frequency(freq) 
开发者ID:EarToEarOak,项目名称:RF-Monitor,代码行数:11,代码来源:gui.py

示例10: test_single_spectrum_helper_raises_mode_psd

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_single_spectrum_helper_raises_mode_psd(self):
        # test that mode 'psd' cannot be used with _single_spectrum_helper
        assert_raises(ValueError, mlab._single_spectrum_helper,
                      x=self.y, mode='psd') 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:6,代码来源:test_mlab.py

示例11: test_spectral_helper_psd

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_spectral_helper_psd(self):
        freqs = self.freqs_density
        spec, fsp, t = mlab._spectral_helper(x=self.y, y=self.y,
                                             NFFT=self.NFFT_density,
                                             Fs=self.Fs,
                                             noverlap=self.nover_density,
                                             pad_to=self.pad_to_density,
                                             sides=self.sides,
                                             mode='psd')

        assert_allclose(fsp, freqs, atol=1e-06)
        assert_allclose(t, self.t_density, atol=1e-06)

        assert_equal(spec.shape[0], freqs.shape[0])
        assert_equal(spec.shape[1], self.t_specgram.shape[0]) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:17,代码来源:test_mlab.py

示例12: test_psd

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_psd(self):
        freqs = self.freqs_density
        spec, fsp = mlab.psd(x=self.y,
                             NFFT=self.NFFT_density,
                             Fs=self.Fs,
                             noverlap=self.nover_density,
                             pad_to=self.pad_to_density,
                             sides=self.sides)
        assert_equal(spec.shape, freqs.shape)
        self.check_freqs(spec, freqs, fsp, self.fstims) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:12,代码来源:test_mlab.py

示例13: test_psd_detrend_mean_func_offset

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_psd_detrend_mean_func_offset(self):
        if self.NFFT_density is None:
            return
        freqs = self.freqs_density
        ydata = np.zeros(self.NFFT_density)
        ydata1 = ydata+5
        ydata2 = ydata+3.3
        ydata = np.vstack([ydata1, ydata2])
        ydata = np.tile(ydata, (20, 1))
        ydatab = ydata.T.flatten()
        ydata = ydata.flatten()
        ycontrol = np.zeros_like(ydata)
        spec_g, fsp_g = mlab.psd(x=ydata,
                                 NFFT=self.NFFT_density,
                                 Fs=self.Fs,
                                 noverlap=0,
                                 sides=self.sides,
                                 detrend=mlab.detrend_mean)
        spec_b, fsp_b = mlab.psd(x=ydatab,
                                 NFFT=self.NFFT_density,
                                 Fs=self.Fs,
                                 noverlap=0,
                                 sides=self.sides,
                                 detrend=mlab.detrend_mean)
        spec_c, fsp_c = mlab.psd(x=ycontrol,
                                 NFFT=self.NFFT_density,
                                 Fs=self.Fs,
                                 noverlap=0,
                                 sides=self.sides)
        assert_array_equal(fsp_g, fsp_c)
        assert_array_equal(fsp_b, fsp_c)
        assert_allclose(spec_g, spec_c, atol=1e-08)
        # these should not be almost equal
        assert_raises(AssertionError,
                      assert_allclose, spec_b, spec_c, atol=1e-08) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:37,代码来源:test_mlab.py

示例14: test_psd_detrend_mean_str_offset

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_psd_detrend_mean_str_offset(self):
        if self.NFFT_density is None:
            return
        freqs = self.freqs_density
        ydata = np.zeros(self.NFFT_density)
        ydata1 = ydata+5
        ydata2 = ydata+3.3
        ydata = np.vstack([ydata1, ydata2])
        ydata = np.tile(ydata, (20, 1))
        ydatab = ydata.T.flatten()
        ydata = ydata.flatten()
        ycontrol = np.zeros_like(ydata)
        spec_g, fsp_g = mlab.psd(x=ydata,
                                 NFFT=self.NFFT_density,
                                 Fs=self.Fs,
                                 noverlap=0,
                                 sides=self.sides,
                                 detrend='mean')
        spec_b, fsp_b = mlab.psd(x=ydatab,
                                 NFFT=self.NFFT_density,
                                 Fs=self.Fs,
                                 noverlap=0,
                                 sides=self.sides,
                                 detrend='mean')
        spec_c, fsp_c = mlab.psd(x=ycontrol,
                                 NFFT=self.NFFT_density,
                                 Fs=self.Fs,
                                 noverlap=0,
                                 sides=self.sides)
        assert_array_equal(fsp_g, fsp_c)
        assert_array_equal(fsp_b, fsp_c)
        assert_allclose(spec_g, spec_c, atol=1e-08)
        # these should not be almost equal
        assert_raises(AssertionError,
                      assert_allclose, spec_b, spec_c, atol=1e-08) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:37,代码来源:test_mlab.py

示例15: test_psd_detrend_linear_str_trend

# 需要导入模块: from matplotlib import mlab [as 别名]
# 或者: from matplotlib.mlab import psd [as 别名]
def test_psd_detrend_linear_str_trend(self):
        if self.NFFT_density is None:
            return
        freqs = self.freqs_density
        ydata = np.arange(self.NFFT_density)
        ydata1 = ydata+5
        ydata2 = ydata+3.3
        ydata = np.vstack([ydata1, ydata2])
        ydata = np.tile(ydata, (20, 1))
        ydatab = ydata.T.flatten()
        ydata = ydata.flatten()
        ycontrol = np.zeros_like(ydata)
        spec_g, fsp_g = mlab.psd(x=ydata,
                                 NFFT=self.NFFT_density,
                                 Fs=self.Fs,
                                 noverlap=0,
                                 sides=self.sides,
                                 detrend='linear')
        spec_b, fsp_b = mlab.psd(x=ydatab,
                                 NFFT=self.NFFT_density,
                                 Fs=self.Fs,
                                 noverlap=0,
                                 sides=self.sides,
                                 detrend='linear')
        spec_c, fsp_c = mlab.psd(x=ycontrol,
                                 NFFT=self.NFFT_density,
                                 Fs=self.Fs,
                                 noverlap=0,
                                 sides=self.sides)
        assert_array_equal(fsp_g, fsp_c)
        assert_array_equal(fsp_b, fsp_c)
        assert_allclose(spec_g, spec_c, atol=1e-08)
        # these should not be almost equal
        assert_raises(AssertionError,
                      assert_allclose, spec_b, spec_c, atol=1e-08) 
开发者ID:miloharper,项目名称:neural-network-animation,代码行数:37,代码来源:test_mlab.py


注:本文中的matplotlib.mlab.psd方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。