From 338ee2ca09fea0fc62ddba6d46ef2dee6184a5dd 2012-12-13 22:05:18 From: Miguel Valdez Date: 2012-12-13 22:05:18 Subject: [PATCH] Se modifico la forma de calcular la phase de la coherencia --- diff --git a/schainpy/model/graphics/mpldriver.py b/schainpy/model/graphics/mpldriver.py index 11d1834..bb0eeb6 100644 --- a/schainpy/model/graphics/mpldriver.py +++ b/schainpy/model/graphics/mpldriver.py @@ -2,17 +2,16 @@ import numpy import datetime import sys import matplotlib -if sys.platform == 'linux': - matplotlib.use("GTKAgg") -if sys.platform == 'darwin': + +if 'linux' in sys.platform: + matplotlib.use("TKAgg") + +if 'darwin' in sys.platform: matplotlib.use("TKAgg") + import matplotlib.pyplot -import matplotlib.dates -#import scitools.numpyutils -from mpl_toolkits.axes_grid1 import make_axes_locatable -from matplotlib.dates import DayLocator, HourLocator, MinuteLocator, SecondLocator, DateFormatter -from matplotlib.ticker import FuncFormatter +from mpl_toolkits.axes_grid1 import make_axes_locatable from matplotlib.ticker import * ########################################### diff --git a/schainpy/model/jrodataIO.py b/schainpy/model/jrodataIO.py index 34f7c64..8b360a5 100644 --- a/schainpy/model/jrodataIO.py +++ b/schainpy/model/jrodataIO.py @@ -360,10 +360,10 @@ class JRODataReader(JRODataIO, ProcessingUnit): thisDate += datetime.timedelta(1) if pathList == []: - print "Any folder found into date range %s-%s" %(startDate, endDate) + print "Any folder was found for the date range: %s-%s" %(startDate, endDate) return None, None - print "%d folder(s) found [%s, ...]" %(len(pathList), pathList[0]) + print "%d folder(s) was(were) found for the date range: %s-%s" %(len(pathList), startDate, endDate) filenameList = [] for thisPath in pathList: @@ -379,8 +379,10 @@ class JRODataReader(JRODataIO, ProcessingUnit): filenameList.append(filename) if not(filenameList): - print "Any file found into time range %s-%s" %(startTime, endTime) + print "Any file was found for the time range %s - %s" %(startTime, endTime) return None, None + + print "%d file(s) was(were) found for the time range: %s - %s" %(len(filenameList), startTime, endTime) self.filenameList = filenameList @@ -2077,10 +2079,19 @@ class SpectraReader(JRODataReader): self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft - self.dataOut.flagDecodeData = True #asumo q la data no esta decodificada + self.dataOut.flagDecodeData = False #asumo q la data no esta decodificada self.dataOut.flagDeflipData = True #asumo q la data no esta sin flip - + + if self.processingHeaderObj.code != None: + + self.dataOut.nCode = self.processingHeaderObj.nCode + + self.dataOut.nBaud = self.processingHeaderObj.nBaud + + self.dataOut.code = self.processingHeaderObj.code + + self.dataOut.flagDecodeData = True return self.dataOut.data_spc diff --git a/schainpy/model/jroplot.py b/schainpy/model/jroplot.py index e7c04fb..d4c4d6c 100644 --- a/schainpy/model/jroplot.py +++ b/schainpy/model/jroplot.py @@ -54,7 +54,8 @@ class CrossSpectraPlot(Figure): def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, - save=False, figpath='./', figfile=None): + save=False, figpath='./', figfile=None, + power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r'): """ @@ -90,8 +91,8 @@ class CrossSpectraPlot(Figure): x = dataOut.getVelRange(1) y = dataOut.getHeiRange() z = dataOut.data_spc[:,:,:]/factor - z = numpy.where(numpy.isfinite(z), z, numpy.NAN) - avg = numpy.average(numpy.abs(z), axis=1) +# z = numpy.where(numpy.isfinite(z), z, numpy.NAN) + avg = numpy.abs(numpy.average(z, axis=1)) noise = dataOut.getNoise()/factor zdB = 10*numpy.log10(z) @@ -133,7 +134,7 @@ class CrossSpectraPlot(Figure): axes0.pcolor(x, y, zdB, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, xlabel=xlabel, ylabel=ylabel, title=title, - ticksize=9, cblabel='') + ticksize=9, colormap=power_cmap, cblabel='') title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) @@ -141,26 +142,26 @@ class CrossSpectraPlot(Figure): axes0.pcolor(x, y, zdB, xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, xlabel=xlabel, ylabel=ylabel, title=title, - ticksize=9, cblabel='') + ticksize=9, colormap=power_cmap, cblabel='') coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) coherence = numpy.abs(coherenceComplex) - phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi - +# phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi + phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi 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=0, zmax=1, xlabel=xlabel, ylabel=ylabel, title=title, - ticksize=9, cblabel='') + ticksize=9, colormap=coherence_cmap, cblabel='') title = "Phase %d%d" %(pair[0], pair[1]) axes0 = self.axesList[i*self.__nsubplots+3] 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='', colormap='RdBu_r') + ticksize=9, colormap=phase_cmap, cblabel='') @@ -719,7 +720,7 @@ class CoherenceMap(Figure): WIDTHPROF = None HEIGHTPROF = None - PREFIX = 'coherencemap' + PREFIX = 'cmap' def __init__(self): self.timerange = 2*60*60 @@ -766,7 +767,8 @@ class CoherenceMap(Figure): def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None, - save=False, figpath='./', figfile=None): + save=False, figpath='./', figfile=None, + coherence_cmap='jet', phase_cmap='RdBu_r'): if pairsList == None: pairsIndexList = dataOut.pairsIndexList @@ -817,9 +819,12 @@ class CoherenceMap(Figure): pair = dataOut.pairsList[pairsIndexList[i]] coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) - coherence = numpy.abs(coherenceComplex) - avg = numpy.average(coherence, axis=0) - z = avg.reshape((1,-1)) + avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) + coherence = numpy.abs(avgcoherenceComplex) +# coherence = numpy.abs(coherenceComplex) +# avg = numpy.average(coherence, axis=0) + + z = coherence.reshape((1,-1)) counter = 0 @@ -828,33 +833,34 @@ class CoherenceMap(Figure): axes.pcolor(x, y, z, xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, - ticksize=9, cblabel='', cbsize="1%") + ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") if self.__showprofile: counter += 1 axes = self.axesList[i*self.__nsubplots*2 + counter] - axes.pline(avg, y, + axes.pline(coherence, y, xmin=0, xmax=1, ymin=ymin, ymax=ymax, xlabel='', ylabel='', title='', ticksize=7, ytick_visible=False, nxticks=5, grid='x') counter += 1 - phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi - avg = numpy.average(phase, axis=0) - z = avg.reshape((1,-1)) +# phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi + phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi +# avg = numpy.average(phase, axis=0) + z = phase.reshape((1,-1)) title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) axes = self.axesList[i*self.__nsubplots*2 + counter] axes.pcolor(x, y, z, xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, - ticksize=9, cblabel='', colormap='RdBu', cbsize="1%") + ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") if self.__showprofile: counter += 1 axes = self.axesList[i*self.__nsubplots*2 + counter] - axes.pline(avg, y, + axes.pline(phase, y, xmin=-180, xmax=180, ymin=ymin, ymax=ymax, xlabel='', ylabel='', title='', ticksize=7, ytick_visible=False, nxticks=4,