Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -106,15 +106,13 @@ def audio_to_spec(filename): · 105 unmodified lines | |||
| 106 | assert len(data[0]) == len(freq) | 106 | assert len(data[0]) == len(freq) |
| 107 | return data,time,freq | 107 | return data,time,freq |
| 108 | 108 | ||
| 109 | def plot_spec(filenames, outplot='',extension='', fileout=None, start=0, end=None, noaxis=None,log=1): | 109 | def plot_spec(filename, outplot='',extension='', fileout=None, start=0, end=None, noaxis=None,log=1): |
| 110 | import Gnuplot | 110 | import Gnuplot |
| 111 | g = gnuplot_create(outplot,extension) | 111 | g = gnuplot_create(outplot,extension) |
| 112 | todraw = len(filenames) | 112 | data,time,freq = audio_to_spec(filename) |
| 113 | xorig = 0. | 113 | xorig = 0. |
| 114 | xsize = 1./todraw | 114 | xsize = 1.#/todraw |
| 115 | data,time,freq = audio_to_spec(filenames.pop(0)) | 115 | if not noaxis: |
| 116 | |||
| 117 | if not noaxis and todraw==1: | ||
| 118 | g.xlabel('Time (s)') | 116 | g.xlabel('Time (s)') |
| 119 | g.ylabel('Frequency (Hz)') | 117 | g.ylabel('Frequency (Hz)') |
| 120 | g.gnuplot('set pm3d map') | 118 | g.gnuplot('set pm3d map') |
| @@ -126,7 +124,7 @@ def plot_spec(filenames, outplot='',extension='', fileout=None, start=0, end=Non · 5 unmodified lines | |||
| 126 | g.gnuplot('set yrange [10.1:%f]' % (freq[-1]/1.)) | 124 | g.gnuplot('set yrange [10.1:%f]' % (freq[-1]/1.)) |
| 127 | g.gnuplot('set log y') | 125 | g.gnuplot('set log y') |
| 128 | g.splot(Gnuplot.GridData(data,time,freq, binary=1)) | 126 | g.splot(Gnuplot.GridData(data,time,freq, binary=1)) |
| 129 | xorig += 1./todraw | 127 | #xorig += 1./todraw |
| 130 | 128 | ||
| 131 | def downsample_audio(time,data,maxpoints=10000): | 129 | def downsample_audio(time,data,maxpoints=10000): |
| 132 | """ resample audio data to last only maxpoints """ | 130 | """ resample audio data to last only maxpoints """ |
| @@ -173,5 +171,5 @@ def gnuplot_create(outplot='',extension='',debug=0,persist=1): · 40 unmodified lines | |||
| 173 | else: exit("ERR: unknown plot extension") | 171 | else: exit("ERR: unknown plot extension") |
| 174 | g('set terminal %s' % extension) | 172 | g('set terminal %s' % extension) |
| 175 | if outplot != "stdout": | 173 | if outplot != "stdout": |
| 176 | g('set output \'roc-%s%s\'' % (outplot,ext)) | 174 | g('set output \'%s%s\'' % (outplot,ext)) |
| 177 | return g | 175 | return g |