Python matplotlib.mlab.specgram() Examples
The following are 30
code examples of matplotlib.mlab.specgram().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
matplotlib.mlab
, or try the search function
.
Example #1
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_specgram_complex(self): freqs = self.freqs_specgram spec, fsp, t = 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='complex') specm = np.mean(np.abs(spec), axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0] self.check_freqs(specm, freqs, fsp, self.fstims)
Example #2
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_specgram_psd(self): freqs = self.freqs_specgram spec, fsp, t = 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') specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0] # since we are using a single freq, all time slices # should be about the same if np.abs(spec.max()) != 0: assert_allclose(np.diff(spec, axis=1).max()/np.abs(spec.max()), 0, atol=1e-02) self.check_freqs(specm, freqs, fsp, self.fstims)
Example #3
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_specgram_default(self): freqs = self.freqs_specgram spec, fsp, t = 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') specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0] # since we are using a single freq, all time slices # should be about the same if np.abs(spec.max()) != 0: assert_allclose(np.diff(spec, axis=1).max()/np.abs(spec.max()), 0, atol=1e-02) self.check_freqs(specm, freqs, fsp, self.fstims)
Example #4
Source File: test_mlab.py From ImageFusion with MIT License | 6 votes |
def test_specgram_phase(self): freqs = self.freqs_specgram spec, fsp, t = 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='phase') specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert_equal(spec.shape[0], freqs.shape[0]) assert_equal(spec.shape[1], self.t_specgram.shape[0])
Example #5
Source File: analyzer.py From shazam-demo with MIT License | 6 votes |
def fingerprint(channel_samples, Fs=DEFAULT_FS, wsize=DEFAULT_WINDOW_SIZE, wratio=DEFAULT_OVERLAP_RATIO, fan_value=DEFAULT_FAN_VALUE, amp_min=DEFAULT_AMP_MIN): arr2D = mlab.specgram( channel_samples, NFFT=wsize, Fs=Fs, window=mlab.window_hanning, noverlap=int(wsize * wratio))[0] arr2D = 10 * np.log10(replaceZeroes(arr2D)) arr2D[arr2D == -np.inf] = 0 local_maxima = get_2D_peaks(arr2D, amp_min=amp_min) return generate_hashes(local_maxima, fan_value=fan_value)
Example #6
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
def test_specgram_angle_phase_equivalent(self): 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, mode='angle') specp, freqspecp, tp = 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='phase') assert_array_equal(freqspeca, freqspecp) assert_array_equal(ta, tp) assert_allclose(np.unwrap(speca, axis=0), specp, atol=1e-06)
Example #7
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
def test_specgram_complex_phase_equivalent(self): freqs = self.freqs_specgram 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='complex') specp, freqspecp, tp = 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='phase') assert_array_equal(freqspecc, freqspecp) assert_array_equal(tc, tp) assert_allclose(np.unwrap(np.angle(specc), axis=0), specp, atol=1e-06)
Example #8
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_specgram_auto(self): freqs = self.freqs_specgram spec, fsp, t = 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) specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0] # since we are using a single freq, all time slices # should be about the same if np.abs(spec.max()) != 0: assert_allclose(np.diff(spec, axis=1).max()/np.abs(spec.max()), 0, atol=1e-02) self.check_freqs(specm, freqs, fsp, self.fstims)
Example #9
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_specgram_magnitude(self): freqs = self.freqs_specgram spec, fsp, t = 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='magnitude') specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0] # since we are using a single freq, all time slices # should be about the same if np.abs(spec.max()) != 0: assert_allclose(np.diff(spec, axis=1).max()/np.abs(spec.max()), 0, atol=1e-02) self.check_freqs(specm, freqs, fsp, self.fstims)
Example #10
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_specgram_phase(self): freqs = self.freqs_specgram spec, fsp, t = 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='phase') specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0]
Example #11
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
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)
Example #12
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
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)
Example #13
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_specgram_complex_mag_equivalent(self): freqs = self.freqs_specgram 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='complex') specm, freqspecm, tm = 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='magnitude') assert_array_equal(freqspecc, freqspecm) assert_array_equal(tc, tm) assert_allclose(np.abs(specc), specm, atol=1e-06)
Example #14
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_specgram_complex_phase_equivalent(self): freqs = self.freqs_specgram 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='complex') specp, freqspecp, tp = 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='phase') assert_array_equal(freqspecc, freqspecp) assert_array_equal(tc, tp) assert_allclose(np.unwrap(np.angle(specc), axis=0), specp, atol=1e-06)
Example #15
Source File: test_mlab.py From twitter-stock-recommendation with MIT License | 6 votes |
def test_specgram_angle_phase_equivalent(self): 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, mode='angle') specp, freqspecp, tp = 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='phase') assert_array_equal(freqspeca, freqspecp) assert_array_equal(ta, tp) assert_allclose(np.unwrap(speca, axis=0), specp, atol=1e-06)
Example #16
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
def test_specgram_complex_mag_equivalent(self): freqs = self.freqs_specgram 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='complex') specm, freqspecm, tm = 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='magnitude') assert_array_equal(freqspecc, freqspecm) assert_array_equal(tc, tm) assert_allclose(np.abs(specc), specm, atol=1e-06)
Example #17
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
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)
Example #18
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
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)
Example #19
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
def test_specgram_phase(self): freqs = self.freqs_specgram spec, fsp, t = 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='phase') specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0]
Example #20
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
def test_specgram_magnitude(self): freqs = self.freqs_specgram spec, fsp, t = 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='magnitude') specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0] # since we are using a single freq, all time slices # should be about the same if np.abs(spec.max()) != 0: assert_allclose(np.diff(spec, axis=1).max()/np.abs(spec.max()), 0, atol=1e-02) self.check_freqs(specm, freqs, fsp, self.fstims)
Example #21
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
def test_specgram_complex(self): freqs = self.freqs_specgram spec, fsp, t = 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='complex') specm = np.mean(np.abs(spec), axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0] self.check_freqs(specm, freqs, fsp, self.fstims)
Example #22
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
def test_specgram_psd(self): freqs = self.freqs_specgram spec, fsp, t = 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') specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0] # since we are using a single freq, all time slices # should be about the same if np.abs(spec.max()) != 0: assert_allclose(np.diff(spec, axis=1).max()/np.abs(spec.max()), 0, atol=1e-02) self.check_freqs(specm, freqs, fsp, self.fstims)
Example #23
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
def test_specgram_default(self): freqs = self.freqs_specgram spec, fsp, t = 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') specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0] # since we are using a single freq, all time slices # should be about the same if np.abs(spec.max()) != 0: assert_allclose(np.diff(spec, axis=1).max()/np.abs(spec.max()), 0, atol=1e-02) self.check_freqs(specm, freqs, fsp, self.fstims)
Example #24
Source File: test_mlab.py From coffeegrindsize with MIT License | 6 votes |
def test_specgram_auto(self): freqs = self.freqs_specgram spec, fsp, t = 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) specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert spec.shape[0] == freqs.shape[0] assert spec.shape[1] == self.t_specgram.shape[0] # since we are using a single freq, all time slices # should be about the same if np.abs(spec.max()) != 0: assert_allclose(np.diff(spec, axis=1).max()/np.abs(spec.max()), 0, atol=1e-02) self.check_freqs(specm, freqs, fsp, self.fstims)
Example #25
Source File: test_mlab.py From ImageFusion with MIT License | 6 votes |
def test_specgram_angle_phase_equivalent(self): 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, mode='angle') specp, freqspecp, tp = 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='phase') assert_array_equal(freqspeca, freqspecp) assert_array_equal(ta, tp) assert_allclose(np.unwrap(speca, axis=0), specp, atol=1e-06)
Example #26
Source File: test_mlab.py From ImageFusion with MIT License | 6 votes |
def test_specgram_complex_angle_equivalent(self): freqs = self.freqs_specgram 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='complex') 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, mode='angle') assert_array_equal(freqspecc, freqspeca) assert_array_equal(tc, ta) assert_allclose(np.angle(specc), speca, atol=1e-06)
Example #27
Source File: test_mlab.py From ImageFusion with MIT License | 6 votes |
def test_specgram_complex_mag_equivalent(self): freqs = self.freqs_specgram 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='complex') specm, freqspecm, tm = 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='magnitude') assert_array_equal(freqspecc, freqspecm) assert_array_equal(tc, tm) assert_allclose(np.abs(specc), specm, atol=1e-06)
Example #28
Source File: test_mlab.py From ImageFusion with MIT License | 6 votes |
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)
Example #29
Source File: test_mlab.py From ImageFusion with MIT License | 6 votes |
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)
Example #30
Source File: test_mlab.py From ImageFusion with MIT License | 6 votes |
def test_specgram_magnitude(self): freqs = self.freqs_specgram spec, fsp, t = 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='magnitude') specm = np.mean(spec, axis=1) assert_allclose(fsp, freqs, atol=1e-06) assert_allclose(t, self.t_specgram, atol=1e-06) assert_equal(spec.shape[0], freqs.shape[0]) assert_equal(spec.shape[1], self.t_specgram.shape[0]) # since we are using a single freq, all time slices # should be about the same if np.abs(spec.max()) != 0: assert_allclose(np.diff(spec, axis=1).max()/np.abs(spec.max()), 0, atol=1e-02) self.check_freqs(specm, freqs, fsp, self.fstims)