From 3959fdcb8502caa4ee7f0b6ad73cdd16a2074cc0 2012-12-07 01:30:39 From: Miguel Valdez Date: 2012-12-07 01:30:39 Subject: [PATCH] Bugs fixed: Eliminacion de numpy.abs() en el calculo de las cross-correlaciones y mejoras en los graficos de CrossSpectra --- diff --git a/schainpy/model/graphics/mpldriver.py b/schainpy/model/graphics/mpldriver.py index f82bce6..0a023c9 100644 --- a/schainpy/model/graphics/mpldriver.py +++ b/schainpy/model/graphics/mpldriver.py @@ -11,89 +11,6 @@ from matplotlib.dates import DayLocator, HourLocator, MinuteLocator, SecondLocat from matplotlib.ticker import FuncFormatter from matplotlib.ticker import * -#def init(idfigure, wintitle, width, height, facecolor="w"): -# -# matplotlib.pyplot.ioff() -# fig = matplotlib.pyplot.matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor) -# fig.canvas.manager.set_window_title(wintitle) -# fig.canvas.manager.resize(width, height) -# matplotlib.pyplot.ion() -# -# return fig -# -#def setWinTitle(fig, title): -# -# fig.canvas.manager.set_window_title(title) -# -#def setTitle(idfigure, title): -# fig = matplotlib.pyplot.figure(idfigure) -# fig.suptitle(title) -# -#def makeAxes(idfigure, nrow, ncol, xpos, ypos, colspan, rowspan): -# fig = matplotlib.pyplot.figure(idfigure) -# ax = matplotlib.pyplot.subplot2grid((nrow, ncol), (xpos, ypos), colspan=colspan, rowspan=rowspan) -# return ax -# -#def setTextFromAxes(idfigure, ax, title): -# fig = matplotlib.pyplot.figure(idfigure) -# ax.annotate(title, xy=(.1, .99), -# xycoords='figure fraction', -# horizontalalignment='left', verticalalignment='top', -# fontsize=10) -# -#def pline(ax, x, y, xmin, xmax, ymin, ymax, xlabel, ylabel, title, firsttime): -# -# if firsttime: -# ax.plot(x, y) -# ax.set_xlim([xmin,xmax]) -# ax.set_ylim([ymin,ymax]) -# ax.set_xlabel(xlabel, size=8) -# ax.set_ylabel(ylabel, size=8) -# ax.set_title(title, size=10) -# matplotlib.pyplot.tight_layout() -# else: -# ax.lines[0].set_data(x,y) -# -#def draw(idfigure): -# -# fig = matplotlib.pyplot.figure(idfigure) -# fig.canvas.draw() -# -#def pcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel, ylabel, title, firsttime, mesh): -# -# if firsttime: -# divider = make_axes_locatable(ax) -# ax_cb = divider.new_horizontal(size="4%", pad=0.05) -# fig1 = ax.get_figure() -# fig1.add_axes(ax_cb) -# -# ax.set_xlim([xmin,xmax]) -# ax.set_ylim([ymin,ymax]) -# ax.set_xlabel(xlabel) -# ax.set_ylabel(ylabel) -# ax.set_title(title) -# print x -# imesh=ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax) -# matplotlib.pyplot.colorbar(imesh, cax=ax_cb) -# ax_cb.yaxis.tick_right() -# for tl in ax_cb.get_yticklabels(): -# tl.set_visible(True) -# ax_cb.yaxis.tick_right() -# matplotlib.pyplot.tight_layout() -# return imesh -# else: -## ax.set_xlim([xmin,xmax]) -## ax.set_ylim([ymin,ymax]) -# ax.set_xlabel(xlabel) -# ax.set_ylabel(ylabel) -# ax.set_title(title) -# -# z = z.T -## z = z[0:-1,0:-1] -# mesh.set_array(z.ravel()) -# -# return mesh - ########################################### #Actualizacion de las funciones del driver ########################################### @@ -101,7 +18,7 @@ from matplotlib.ticker import * def createFigure(idfigure, wintitle, width, height, facecolor="w"): matplotlib.pyplot.ioff() - fig = matplotlib.pyplot.matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor) + fig = matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor) fig.canvas.manager.set_window_title(wintitle) fig.canvas.manager.resize(width, height) matplotlib.pyplot.ion() @@ -212,7 +129,7 @@ def pline(iplot, x, y, xlabel='', ylabel='', title=''): def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel='', ylabel='', title='', ticksize = 9, - cblabel='', cbsize="5%", + colormap='jet',cblabel='', cbsize="5%", XAxisAsTime=False): divider = make_axes_locatable(ax) @@ -225,7 +142,7 @@ def createPcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, printLabels(ax, xlabel, ylabel, title) - imesh = ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax) + imesh = ax.pcolormesh(x,y,z.T, vmin=zmin, vmax=zmax, cmap=matplotlib.pyplot.get_cmap(colormap)) cb = matplotlib.pyplot.colorbar(imesh, cax=ax_cb) cb.set_label(cblabel) diff --git a/schainpy/model/jrodata.py b/schainpy/model/jrodata.py index 9ad5190..d845d8b 100644 --- a/schainpy/model/jrodata.py +++ b/schainpy/model/jrodata.py @@ -239,7 +239,7 @@ class JROData: _lambda = self.C/self.frequency - vmax = self.getFmax() * _lambda / 2. + vmax = self.getFmax() * _lambda return vmax @@ -440,14 +440,14 @@ class Spectra(JROData): def getFreqRange(self, extrapoints=0): - delfreq = 2 * self.getFmax() / self.nFFTPoints - freqrange = deltafreqs*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 + deltafreq = self.getFmax() / self.nFFTPoints + freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 return freqrange def getVelRange(self, extrapoints=0): - deltav = 2 * self.getVmax() / self.nFFTPoints + deltav = self.getVmax() / self.nFFTPoints velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2 return velrange diff --git a/schainpy/model/jroplot.py b/schainpy/model/jroplot.py index 903dfda..cfbebb5 100644 --- a/schainpy/model/jroplot.py +++ b/schainpy/model/jroplot.py @@ -79,10 +79,10 @@ class CrossSpectraPlot(Figure): raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) pairsIndexList.append(dataOut.pairsList.index(pair)) - if pairIndexList == []: + if pairsIndexList == []: return - x = dataOut.getVelRange(1) + x = dataOut.getFreqRange(1) y = dataOut.getHeiRange() z = 10.*numpy.log10(dataOut.data_spc[:,:,:]) avg = numpy.average(numpy.abs(z), axis=1) @@ -141,7 +141,7 @@ class CrossSpectraPlot(Figure): title = "Coherence %d%d" %(pair[0], pair[1]) axes0 = self.axesList[i*self.__nsubplots+2] axes0.pcolor(x, y, coherence, - xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-1, zmax=1, + xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, xlabel=xlabel, ylabel=ylabel, title=title, ticksize=9, cblabel='') @@ -150,7 +150,7 @@ class CrossSpectraPlot(Figure): axes0.pcolor(x, y, phase, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, xlabel=xlabel, ylabel=ylabel, title=title, - ticksize=9, cblabel='') + ticksize=9, cblabel='', colormap='RdBu') diff --git a/schainpy/model/jroprocessing.py b/schainpy/model/jroprocessing.py index d53e3b5..1e12f1f 100644 --- a/schainpy/model/jroprocessing.py +++ b/schainpy/model/jroprocessing.py @@ -606,7 +606,7 @@ class SpectraProc(ProcessingUnit): self.buffer self.dataOut.flagNoData """ - fft_volt = numpy.fft.fft(self.buffer,axis=1) + fft_volt = numpy.fft.fft(self.buffer,axis=1)/numpy.sqrt(self.dataOut.nFFTPoints) dc = fft_volt[:,0,:] #calculo de self-spectra @@ -624,7 +624,7 @@ class SpectraProc(ProcessingUnit): #calculo de cross-spectra cspc = numpy.zeros((self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') for pair in self.dataOut.pairsList: - cspc[pairIndex,:,:] = numpy.abs(fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])) + cspc[pairIndex,:,:] = fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:]) pairIndex += 1 blocksize += cspc.size