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


Python pylab.specgram函数代码示例

本文整理汇总了Python中pylab.specgram函数的典型用法代码示例。如果您正苦于以下问题:Python specgram函数的具体用法?Python specgram怎么用?Python specgram使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: graph_spectrogram

def graph_spectrogram(wav_file):
    sound_info, frame_rate = get_wav_info(wav_file)
    pylab.figure(num=None, figsize=(19, 12))
    pylab.subplot(111)
    pylab.title('spectrogram of %r' % wav_file)
    pylab.specgram(sound_info, Fs=frame_rate)
    pylab.savefig('spectrogram - %s' % os.path.splitext(wav_file)[0])
开发者ID:cgoldberg,项目名称:audiotools,代码行数:7,代码来源:spectrogram_matplotlib.py

示例2: spectrogram

def spectrogram(Y, Fs):

    s = Y.shape

    if len(Y.shape) > 1:
        ch = s[1]
    else:
        ch = 1

    # Ym = numpy.sum( Y , 1 ) / float(ch)

    for j in numpy.arange(ch):
        pyplot.subplot(210 + j + 1)
        pylab.specgram(Y[:, j], NFFT=Fs, Fs=Fs, cmap="gnuplot2")

        mean_x = numpy.array([0, s[0] * (1 / Fs)])
        mean_x = numpy.array([mean, mean])

        pyplot.axis([0, s[0] * (1 / Fs), 0, Fs / 2.0])

        pyplot.title("Channel %d" % j)
        pyplot.xlabel("Time [sec]")
        pyplot.ylabel("Freq. [Hz]")
        pyplot.grid(True)

        pyplot.title("Channel: %d" % int(j + 1))

    pyplot.show()
开发者ID:simon-r,项目名称:dr14_t.meter,代码行数:28,代码来源:spectrogram.py

示例3: makeimg

def makeimg(wav):
	global callpath
	global imgpath

	fs, frames = wavfile.read(os.path.join(callpath, wav))
	
	pylab.ion()

	# generate specgram
	pylab.figure(1)
	
	# generate specgram
	pylab.specgram(
		frames,
		NFFT=256, 
		Fs=22050, 
		detrend=pylab.detrend_none,
		window=numpy.hamming(256),
		noverlap=192,
		cmap=pylab.get_cmap('Greys'))
	
	x_width = len(frames)/fs
	
	pylab.ylim([0,11025])
	pylab.xlim([0,round(x_width,3)-0.006])
	
	img_path = os.path.join(imgpath, wav.replace(".wav",".png"))

	pylab.savefig(img_path)
	
	return img_path
开发者ID:tomauer,项目名称:nfc_tweet,代码行数:31,代码来源:nfc_images.py

示例4: graph_spectrogram

def graph_spectrogram(wav_file):
    sound_info, frame_rate = get_wav_info(wav_file)
    pylab.figure(num=None, figsize=(19, 12))
    pylab.subplot(111)
    pylab.title('spectrogram of %r' % wav_file)
    pylab.specgram(sound_info, Fs=frame_rate)
    pylab.savefig('D:\spectrogram.png')
开发者ID:whmrtm,项目名称:Python_Scientific_Computing,代码行数:7,代码来源:test_audio.py

示例5: spectrogram

def spectrogram(t, x, Fs, NFFT=256):
    ax1 = pylab.subplot(211)
    pylab.plot(t, x)

    pylab.subplot(212, sharex=ax1)
    pylab.specgram(x, NFFT=NFFT, Fs=Fs, noverlap=NFFT/2,
                   cmap=pylab.cm.gist_heat)
开发者ID:RagnarDanneskjold,项目名称:amodem,代码行数:7,代码来源:show.py

示例6: graph_spectrogram

def graph_spectrogram(wav_file):
    sound_info, frame_rate = get_wav_info(wav_file)
    pylab.figure(num=None, figsize=(19, 12))
    pylab.axes(frameon = False)
    pylab.specgram(sound_info, Fs=frame_rate)
    pylab.savefig('pngs/%s.png' % os.path.splitext(wav_file)[0], bbox_inches = 'tight')
    sleep(60)
开发者ID:BlitzKraft,项目名称:Misc,代码行数:7,代码来源:music2img.py

示例7: frequency_plot

def frequency_plot(channel_one):
    pylab.specgram(channel_one, Fs=44100)
    pylab.xlabel("Time (s)  (equivalent to distance)")
    pylab.ylabel("Frequency")
    ax=pylab.gca()
    ax.xaxis.set_major_formatter(FormatStrFormatter('%0.4f'))
    ax.yaxis.set_major_formatter(FormatStrFormatter('%0.0f'))
    pylab.subplots_adjust(left=0.15, right=0.95, top=0.95, bottom=0.1)
开发者ID:groverlab,项目名称:anechoic-python,代码行数:8,代码来源:graphics.py

示例8: spektrogramy

def spektrogramy():
	sred_r,sred_s=np.average(o1_bez,axis=0),np.average(o1_sty,axis=0)
	py.subplot(121)
	py.specgram(sred_r, Fs=fs, scale_by_freq=True)
	py.title('ref')
	py.subplot(122)
	py.specgram(sred_s, Fs=fs, scale_by_freq=True)
	py.title('stym')
	py.show()
开发者ID:dokato,项目名称:ssveppj,代码行数:9,代码来源:analiza.py

示例9: graph_spectrogram

def graph_spectrogram(wav_file):
    sound_info, frame_rate = get_wav_info(wav_file)
    pylab.figure(num=None, figsize=(8, 6))
    pylab.subplot(111)
    pylab.title('spectrogram of %r' % wav_file)
    pylab.ylabel('Frequency')
    pylab.xlabel('Time')
    pylab.specgram(sound_info, Fs=frame_rate)
    pylab.savefig('spectrogram.png')
开发者ID:AlanRodrigo,项目名称:audioprocessing,代码行数:9,代码来源:spectrogram-generator.py

示例10: plot_spectrogram

def plot_spectrogram(input_data, windowfn=None, units='kHz', channel_number=0, filename=None, coloraxis=None, noverlap=0,NFFT=None, **kwargs):
    import pylab as pl
    
    if windowfn == None: windowfn=pl.window_hanning

    # look in the config file section Plots for NFFT = 1234
    # Dave - how about a method to allow this in one line
    # e.g. pyfusion.config.numgetdef('Plots','NFFT', 2048)
    # usage:  
    # if (NFFT==None): NFFT = pyfusion.config.numgetdef('Plots','NFFT', 2048)
    # 
    # also nice to have pyfusion.config.re-read()
    if NFFT == None:
        try:
            NFFT=(int(pyfusion.config.get('Plots','NFFT')))
        except:
            NFFT = 2048

    print(NFFT)        
    if units.lower() == 'khz': ffact = 1000.
    else: ffact =1.        
    xextent=(min(input_data.timebase),max(input_data.timebase))

    pl.specgram(input_data.signal.get_channel(channel_number), NFFT=NFFT, noverlap=noverlap, Fs=input_data.timebase.sample_freq/ffact, window=windowfn, xextent=xextent, **kwargs)
    #accept multi or single channel data (I think?)
        
    if coloraxis != None: pl.clim(coloraxis)
    else:
        try:
            pl.clim(eval(pyfusion.config.get('Plots','coloraxis')))
        except:
            pass

    # look in the config file section Plots for a string like 
    # FT_Axis = [0,0.08,0,500e3]   don't quote
    try:
        #pl.axis(eval(pyfusion.config.get('Plots','FT_Axis')))
        # this is clumsier now we need to consider freq units.
        axt = eval(pyfusion.config.get('Plots','FT_Axis'))
        pl.axis([axt[0], axt[1], axt[2]/ffact, axt[3]/ffact])
    except:
        pass
    # but override X if we have zoomed in bdb
    if 'reduce_time' in input_data.history:
        pl.xlim(np.min(input_data.timebase),max(input_data.timebase))
        
    try:
        pl.title("%d, %s"%(input_data.meta['shot'], input_data.channels[channel_number].name))
    except:
        pl.title("%d, %s"%(input_data.meta['shot'], input_data.channels.name))
        
    if filename != None:
        pl.savefig(filename)
    else:
        pl.show()
开发者ID:dpretty,项目名称:pyfusion,代码行数:55,代码来源:plots.py

示例11: spectrogram

 def spectrogram(self, inputSignal=None, tempo=120):
     if inputSignal is None:
         inputSignal = self.data
     NFFT = int(8.0 * self.samplingRate / float(tempo))
     noverlap = NFFT >> 2
     if (len(inputSignal.shape) == 2):
         Pxx, freqs, bins, im = pylab.specgram(inputSignal[:, 0], NFFT=NFFT, Fs=self.samplingRate, noverlap=noverlap)
         return [Pxx, freqs, bins]
     else:
         Pxx, freqs, bins, im = pylab.specgram(inputSignal, NFFT=NFFT, Fs=self.samplingRate, noverlap=noverlap)
         return [Pxx, freqs, bins]
开发者ID:nlintz,项目名称:SigsysFinal,代码行数:11,代码来源:Analysis.py

示例12: plot

    def plot(self, noverlap=0, cmap=cm.binary, window_length=20):
        """
        Function to give Praat-style waveform + spectrogram + textgrid plot
        time is given in sec units
        """
        # plot waveform
        subplot(3, 1, 1)
        plot(self.time, self.data, color='black', linewidth=0.2)

        # plot spectrogram
        subplot(3, 1, 2)
        nfft = int(float((window_length * self.rate)) / 1000)
        specgram(self.data, NFFT=nfft, noverlap=noverlap, cmap=cmap)
开发者ID:teonbrooks,项目名称:Pyphon,代码行数:13,代码来源:pyphon.py

示例13: plotPartialSpectrogram

 def plotPartialSpectrogram(self, timeStart, timeEnd, inputSignal=None, tempo=120):
     if inputSignal is None:
         inputSignal = self.data
     startIndex = timeStart * self.samplingRate
     stopIndex = timeEnd * self.samplingRate
     NFFT = int(8.0 * self.samplingRate / float(tempo))
     noverlap = NFFT >> 2
     if (len(inputSignal.shape) == 2):
         Pxx, freqs, bins, im = pylab.specgram(inputSignal[startIndex:stopIndex, 0], NFFT=NFFT, Fs=self.samplingRate, noverlap=noverlap)
         pylab.show()
     else:
         Pxx, freqs, bins, im = pylab.specgram(inputSignal[startIndex:stopIndex], NFFT=NFFT, Fs=self.samplingRate, noverlap=noverlap)
         pylab.show()
开发者ID:nlintz,项目名称:SigsysFinal,代码行数:13,代码来源:Analysis.py

示例14: call_spec

def call_spec():
    global y,NFFT,Fsamp,Fcentre,foverlap,detrend,_window, _type, fmod, chan_name, diag_name, hold
    print len(y), NFFT,foverlap, _type, fmod
    ax = pl.subplot(111)
    z=_window(y)
    if _type=='F': 
        shot=callback.get_shot()
        print("shot={s}".format(s=shot))
        data = device.acq.getdata(shot, diag_name)    
        if chan_name=='':
            try:
                ch=data.channels
                print("Choosing from", [chn.name for chn in ch])
                name=ch[channel_number].name
            except:
                print "Failed to open channel database - try mirnov_1_8"
                name='mirnov_1_8'
                name='mirnov_linear_2'
        else:        
            name=chan_name

#        data = pyfusion.load_channel(shot,name)
#        data = pyfusion.acq.getdata(shot_number, diag_name)    
        if type(data)==type(None): return(False)
        
        if _window==local_none: windowfn=pl.window_none
#        else: windowfn=pl.window_hanning
        elif _window==local_hanning: windowfn=pl.window_hanning
        else: windowfn=_window(arange(NFFT))
        clim=(-70,0)   # eventually make this adjustable
        if hold==0:  pl.clf()
# colorbar commented out because it keeps adding itself
        data.plot_spectrogram(NFFT=NFFT, windowfn=windowfn, noverlap=foverlap*NFFT, 
                              channel_number=channel_number)
#                         colorbar=True, clim=clim)
#        colorbar() # used to come up on a separate page, fixed, but a little clunky - leave for now

        return(True)
    elif _type == 'T':
# some matplotlib versions don't know about Fc
        pl.specgram(z*y, NFFT=NFFT, Fs=Fsamp, detrend=detrend,
#                 window = _window
                 noverlap=foverlap*NFFT, cmap=cmap)
    elif _type == 'L':
        pl.plot(20*log10(abs(fft.fft(y*z))))
    elif _type == 'W':
        pl.plot(z)
    elif _type =='C':
        pl.plot(hold=0)
    else: raise ' unknown plot type "' + _type +'"'
开发者ID:bdb112,项目名称:pyfusion,代码行数:50,代码来源:wid_specgram.py

示例15: graph_spectrogram

def graph_spectrogram(wav_file):
    sound_info, frame_rate = get_wav_info(wav_file)
    pylab.figure(num=None, figsize=(8, 6))
    pylab.subplot(111)
    pylab.title('spectrogram of %r' % wav_file)
    pylab.specgram(sound_info, Fs=frame_rate,
                   NFFT=4096, noverlap=4000,
                   )
    pylab.grid(True)
    pylab.axis((0.1, 1.85, 600, 2600))
    pylab.yticks([ 740.0,  830.6,  932.6, 1108.7, 1244.5,
                  1480.0, 1661.2, 1864.66, 2217.46, 2489.0])
    file_name, file_ext = os.path.splitext(wav_file)
    pylab.savefig('%s.%s' % (file_name, 'png'))
开发者ID:moreati,项目名称:google-tone,代码行数:14,代码来源:spectrogram.py


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