@@ -11,88 +11,88 from matplotlib.dates import DayLocator, HourLocator, MinuteLocator, SecondLocat | |||
|
11 | 11 | from matplotlib.ticker import FuncFormatter |
|
12 | 12 | from matplotlib.ticker import * |
|
13 | 13 | |
|
14 | def init(idfigure, wintitle, width, height, facecolor="w"): | |
|
15 | ||
|
16 | matplotlib.pyplot.ioff() | |
|
17 | fig = matplotlib.pyplot.matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor) | |
|
18 | fig.canvas.manager.set_window_title(wintitle) | |
|
19 | fig.canvas.manager.resize(width, height) | |
|
20 | matplotlib.pyplot.ion() | |
|
21 | ||
|
22 | return fig | |
|
23 | ||
|
24 | def setWinTitle(fig, title): | |
|
25 | ||
|
26 | fig.canvas.manager.set_window_title(title) | |
|
27 | ||
|
28 | def setTitle(idfigure, title): | |
|
29 | fig = matplotlib.pyplot.figure(idfigure) | |
|
30 | fig.suptitle(title) | |
|
31 | ||
|
32 | def makeAxes(idfigure, nrow, ncol, xpos, ypos, colspan, rowspan): | |
|
33 | fig = matplotlib.pyplot.figure(idfigure) | |
|
34 | ax = matplotlib.pyplot.subplot2grid((nrow, ncol), (xpos, ypos), colspan=colspan, rowspan=rowspan) | |
|
35 | return ax | |
|
36 | ||
|
37 | def setTextFromAxes(idfigure, ax, title): | |
|
38 | fig = matplotlib.pyplot.figure(idfigure) | |
|
39 | ax.annotate(title, xy=(.1, .99), | |
|
40 | xycoords='figure fraction', | |
|
41 | horizontalalignment='left', verticalalignment='top', | |
|
42 | fontsize=10) | |
|
43 | ||
|
44 | def pline(ax, x, y, xmin, xmax, ymin, ymax, xlabel, ylabel, title, firsttime): | |
|
45 | ||
|
46 | if firsttime: | |
|
47 | ax.plot(x, y) | |
|
48 | ax.set_xlim([xmin,xmax]) | |
|
49 | ax.set_ylim([ymin,ymax]) | |
|
50 | ax.set_xlabel(xlabel, size=8) | |
|
51 | ax.set_ylabel(ylabel, size=8) | |
|
52 | ax.set_title(title, size=10) | |
|
53 | matplotlib.pyplot.tight_layout() | |
|
54 | else: | |
|
55 | ax.lines[0].set_data(x,y) | |
|
56 | ||
|
57 | def draw(idfigure): | |
|
58 | ||
|
59 | fig = matplotlib.pyplot.figure(idfigure) | |
|
60 | fig.canvas.draw() | |
|
61 | ||
|
62 | def pcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel, ylabel, title, firsttime, mesh): | |
|
63 | ||
|
64 | if firsttime: | |
|
65 | divider = make_axes_locatable(ax) | |
|
66 | ax_cb = divider.new_horizontal(size="4%", pad=0.05) | |
|
67 | fig1 = ax.get_figure() | |
|
68 | fig1.add_axes(ax_cb) | |
|
69 | ||
|
70 | ax.set_xlim([xmin,xmax]) | |
|
71 | ax.set_ylim([ymin,ymax]) | |
|
72 | ax.set_xlabel(xlabel) | |
|
73 | ax.set_ylabel(ylabel) | |
|
74 | ax.set_title(title) | |
|
75 | print x | |
|
76 | imesh=ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax) | |
|
77 | matplotlib.pyplot.colorbar(imesh, cax=ax_cb) | |
|
78 | ax_cb.yaxis.tick_right() | |
|
79 | for tl in ax_cb.get_yticklabels(): | |
|
80 | tl.set_visible(True) | |
|
81 | ax_cb.yaxis.tick_right() | |
|
82 | matplotlib.pyplot.tight_layout() | |
|
83 | return imesh | |
|
84 | else: | |
|
14 | #def init(idfigure, wintitle, width, height, facecolor="w"): | |
|
15 | # | |
|
16 | # matplotlib.pyplot.ioff() | |
|
17 | # fig = matplotlib.pyplot.matplotlib.pyplot.figure(num=idfigure, facecolor=facecolor) | |
|
18 | # fig.canvas.manager.set_window_title(wintitle) | |
|
19 | # fig.canvas.manager.resize(width, height) | |
|
20 | # matplotlib.pyplot.ion() | |
|
21 | # | |
|
22 | # return fig | |
|
23 | # | |
|
24 | #def setWinTitle(fig, title): | |
|
25 | # | |
|
26 | # fig.canvas.manager.set_window_title(title) | |
|
27 | # | |
|
28 | #def setTitle(idfigure, title): | |
|
29 | # fig = matplotlib.pyplot.figure(idfigure) | |
|
30 | # fig.suptitle(title) | |
|
31 | # | |
|
32 | #def makeAxes(idfigure, nrow, ncol, xpos, ypos, colspan, rowspan): | |
|
33 | # fig = matplotlib.pyplot.figure(idfigure) | |
|
34 | # ax = matplotlib.pyplot.subplot2grid((nrow, ncol), (xpos, ypos), colspan=colspan, rowspan=rowspan) | |
|
35 | # return ax | |
|
36 | # | |
|
37 | #def setTextFromAxes(idfigure, ax, title): | |
|
38 | # fig = matplotlib.pyplot.figure(idfigure) | |
|
39 | # ax.annotate(title, xy=(.1, .99), | |
|
40 | # xycoords='figure fraction', | |
|
41 | # horizontalalignment='left', verticalalignment='top', | |
|
42 | # fontsize=10) | |
|
43 | # | |
|
44 | #def pline(ax, x, y, xmin, xmax, ymin, ymax, xlabel, ylabel, title, firsttime): | |
|
45 | # | |
|
46 | # if firsttime: | |
|
47 | # ax.plot(x, y) | |
|
85 | 48 | # ax.set_xlim([xmin,xmax]) |
|
86 | 49 | # ax.set_ylim([ymin,ymax]) |
|
87 | ax.set_xlabel(xlabel) | |
|
88 | ax.set_ylabel(ylabel) | |
|
89 | ax.set_title(title) | |
|
90 | ||
|
91 | z = z.T | |
|
92 | # z = z[0:-1,0:-1] | |
|
93 | mesh.set_array(z.ravel()) | |
|
94 | ||
|
95 | return mesh | |
|
50 | # ax.set_xlabel(xlabel, size=8) | |
|
51 | # ax.set_ylabel(ylabel, size=8) | |
|
52 | # ax.set_title(title, size=10) | |
|
53 | # matplotlib.pyplot.tight_layout() | |
|
54 | # else: | |
|
55 | # ax.lines[0].set_data(x,y) | |
|
56 | # | |
|
57 | #def draw(idfigure): | |
|
58 | # | |
|
59 | # fig = matplotlib.pyplot.figure(idfigure) | |
|
60 | # fig.canvas.draw() | |
|
61 | # | |
|
62 | #def pcolor(ax, x, y, z, xmin, xmax, ymin, ymax, zmin, zmax, xlabel, ylabel, title, firsttime, mesh): | |
|
63 | # | |
|
64 | # if firsttime: | |
|
65 | # divider = make_axes_locatable(ax) | |
|
66 | # ax_cb = divider.new_horizontal(size="4%", pad=0.05) | |
|
67 | # fig1 = ax.get_figure() | |
|
68 | # fig1.add_axes(ax_cb) | |
|
69 | # | |
|
70 | # ax.set_xlim([xmin,xmax]) | |
|
71 | # ax.set_ylim([ymin,ymax]) | |
|
72 | # ax.set_xlabel(xlabel) | |
|
73 | # ax.set_ylabel(ylabel) | |
|
74 | # ax.set_title(title) | |
|
75 | # print x | |
|
76 | # imesh=ax.pcolormesh(x,y,z.T,vmin=zmin,vmax=zmax) | |
|
77 | # matplotlib.pyplot.colorbar(imesh, cax=ax_cb) | |
|
78 | # ax_cb.yaxis.tick_right() | |
|
79 | # for tl in ax_cb.get_yticklabels(): | |
|
80 | # tl.set_visible(True) | |
|
81 | # ax_cb.yaxis.tick_right() | |
|
82 | # matplotlib.pyplot.tight_layout() | |
|
83 | # return imesh | |
|
84 | # else: | |
|
85 | ## ax.set_xlim([xmin,xmax]) | |
|
86 | ## ax.set_ylim([ymin,ymax]) | |
|
87 | # ax.set_xlabel(xlabel) | |
|
88 | # ax.set_ylabel(ylabel) | |
|
89 | # ax.set_title(title) | |
|
90 | # | |
|
91 | # z = z.T | |
|
92 | ## z = z[0:-1,0:-1] | |
|
93 | # mesh.set_array(z.ravel()) | |
|
94 | # | |
|
95 | # return mesh | |
|
96 | 96 | |
|
97 | 97 | ########################################### |
|
98 | 98 | #Actualizacion de las funciones del driver |
@@ -373,20 +373,6 class Spectra(JROData): | |||
|
373 | 373 | self.nFFTPoints = None |
|
374 | 374 | |
|
375 | 375 | self.wavelength = None |
|
376 | ||
|
377 | def getFreqRange(self, extrapoints=0): | |
|
378 | ||
|
379 | delfreq = 2 * self.getFmax() / self.nFFTPoints | |
|
380 | freqrange = deltafreqs*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 | |
|
381 | ||
|
382 | return freqrange | |
|
383 | ||
|
384 | def getVelRange(self, extrapoints=0): | |
|
385 | ||
|
386 | deltav = 2 * self.getVmax() / self.nFFTPoints | |
|
387 | velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2 | |
|
388 | ||
|
389 | return velrange | |
|
390 | 376 | |
|
391 | 377 | def getNoisebyHildebrand(self): |
|
392 | 378 | """ |
@@ -444,6 +430,32 class Spectra(JROData): | |||
|
444 | 430 | noise = self.getNoisebyWindow() |
|
445 | 431 | |
|
446 | 432 | return 10*numpy.log10(noise) |
|
433 | ||
|
434 | ||
|
435 | def getFreqRange(self, extrapoints=0): | |
|
436 | ||
|
437 | delfreq = 2 * self.getFmax() / self.nFFTPoints | |
|
438 | freqrange = deltafreqs*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 | |
|
439 | ||
|
440 | return freqrange | |
|
441 | ||
|
442 | def getVelRange(self, extrapoints=0): | |
|
443 | ||
|
444 | deltav = 2 * self.getVmax() / self.nFFTPoints | |
|
445 | velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2 | |
|
446 | ||
|
447 | return velrange | |
|
448 | ||
|
449 | def getNPairs(self): | |
|
450 | ||
|
451 | return len(self.pairsList) | |
|
452 | ||
|
453 | def getPairsIndexList(self): | |
|
454 | ||
|
455 | return range(self.nPairs) | |
|
456 | ||
|
457 | nPairs = property(getNPairs, "I'm the 'nPairs' property.") | |
|
458 | pairsIndexList = property(getPairsIndexList, "I'm the 'pairsIndexList' property.") | |
|
447 | 459 | |
|
448 | 460 | class SpectraHeis(JROData): |
|
449 | 461 |
@@ -2,6 +2,165 import numpy | |||
|
2 | 2 | import time, datetime |
|
3 | 3 | from graphics.figure import * |
|
4 | 4 | |
|
5 | class CrossSpectraPlot(Figure): | |
|
6 | ||
|
7 | __isConfig = None | |
|
8 | __nsubplots = None | |
|
9 | ||
|
10 | WIDTHPROF = None | |
|
11 | HEIGHTPROF = None | |
|
12 | PREFIX = 'spc' | |
|
13 | ||
|
14 | def __init__(self): | |
|
15 | ||
|
16 | self.__isConfig = False | |
|
17 | self.__nsubplots = 4 | |
|
18 | ||
|
19 | self.WIDTH = 300 | |
|
20 | self.HEIGHT = 400 | |
|
21 | self.WIDTHPROF = 0 | |
|
22 | self.HEIGHTPROF = 0 | |
|
23 | ||
|
24 | def getSubplots(self): | |
|
25 | ||
|
26 | ncol = 4 | |
|
27 | nrow = self.nplots | |
|
28 | ||
|
29 | return nrow, ncol | |
|
30 | ||
|
31 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
|
32 | ||
|
33 | self.__showprofile = showprofile | |
|
34 | self.nplots = nplots | |
|
35 | ||
|
36 | ncolspan = 1 | |
|
37 | colspan = 1 | |
|
38 | ||
|
39 | self.createFigure(idfigure = idfigure, | |
|
40 | wintitle = wintitle, | |
|
41 | widthplot = self.WIDTH + self.WIDTHPROF, | |
|
42 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
|
43 | ||
|
44 | nrow, ncol = self.getSubplots() | |
|
45 | ||
|
46 | counter = 0 | |
|
47 | for y in range(nrow): | |
|
48 | for x in range(ncol): | |
|
49 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
|
50 | ||
|
51 | counter += 1 | |
|
52 | ||
|
53 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
|
54 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
|
55 | save=False, figpath='./', figfile=None): | |
|
56 | ||
|
57 | """ | |
|
58 | ||
|
59 | Input: | |
|
60 | dataOut : | |
|
61 | idfigure : | |
|
62 | wintitle : | |
|
63 | channelList : | |
|
64 | showProfile : | |
|
65 | xmin : None, | |
|
66 | xmax : None, | |
|
67 | ymin : None, | |
|
68 | ymax : None, | |
|
69 | zmin : None, | |
|
70 | zmax : None | |
|
71 | """ | |
|
72 | ||
|
73 | if pairsList == None: | |
|
74 | pairsIndexList = dataOut.pairsIndexList | |
|
75 | else: | |
|
76 | pairsIndexList = [] | |
|
77 | for pair in pairsList: | |
|
78 | if pair not in dataOut.pairsList: | |
|
79 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
|
80 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
|
81 | ||
|
82 | x = dataOut.getVelRange(1) | |
|
83 | y = dataOut.getHeiRange() | |
|
84 | z = 10.*numpy.log10(dataOut.data_spc[:,:,:]) | |
|
85 | avg = numpy.average(numpy.abs(z), axis=1) | |
|
86 | ||
|
87 | noise = dataOut.getNoise() | |
|
88 | ||
|
89 | if not self.__isConfig: | |
|
90 | ||
|
91 | nplots = len(pairsIndexList) | |
|
92 | ||
|
93 | self.setup(idfigure=idfigure, | |
|
94 | nplots=nplots, | |
|
95 | wintitle=wintitle, | |
|
96 | showprofile=showprofile) | |
|
97 | ||
|
98 | if xmin == None: xmin = numpy.nanmin(x) | |
|
99 | if xmax == None: xmax = numpy.nanmax(x) | |
|
100 | if ymin == None: ymin = numpy.nanmin(y) | |
|
101 | if ymax == None: ymax = numpy.nanmax(y) | |
|
102 | if zmin == None: zmin = numpy.nanmin(avg)*0.9 | |
|
103 | if zmax == None: zmax = numpy.nanmax(avg)*0.9 | |
|
104 | ||
|
105 | self.__isConfig = True | |
|
106 | ||
|
107 | thisDatetime = datetime.datetime.fromtimestamp(dataOut.utctime) | |
|
108 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
|
109 | xlabel = "Velocity (m/s)" | |
|
110 | ylabel = "Range (Km)" | |
|
111 | ||
|
112 | self.setWinTitle(title) | |
|
113 | ||
|
114 | for i in range(self.nplots): | |
|
115 | pair = dataOut.pairsList[pairsIndexList[i]] | |
|
116 | ||
|
117 | title = "Channel %d: %4.2fdB" %(pair[0], noise[pair[0]]) | |
|
118 | z = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]) | |
|
119 | axes0 = self.axesList[i*self.__nsubplots] | |
|
120 | axes0.pcolor(x, y, z, | |
|
121 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
|
122 | xlabel=xlabel, ylabel=ylabel, title=title, | |
|
123 | ticksize=9, cblabel='') | |
|
124 | ||
|
125 | title = "Channel %d: %4.2fdB" %(pair[1], noise[pair[1]]) | |
|
126 | z = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]) | |
|
127 | axes0 = self.axesList[i*self.__nsubplots+1] | |
|
128 | axes0.pcolor(x, y, z, | |
|
129 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
|
130 | xlabel=xlabel, ylabel=ylabel, title=title, | |
|
131 | ticksize=9, cblabel='') | |
|
132 | ||
|
133 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
|
134 | coherence = numpy.abs(coherenceComplex) | |
|
135 | phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
|
136 | ||
|
137 | ||
|
138 | title = "Coherence %d%d" %(pair[0], pair[1]) | |
|
139 | axes0 = self.axesList[i*self.__nsubplots+2] | |
|
140 | axes0.pcolor(x, y, coherence, | |
|
141 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-1, zmax=1, | |
|
142 | xlabel=xlabel, ylabel=ylabel, title=title, | |
|
143 | ticksize=9, cblabel='') | |
|
144 | ||
|
145 | title = "Phase %d%d" %(pair[0], pair[1]) | |
|
146 | axes0 = self.axesList[i*self.__nsubplots+3] | |
|
147 | axes0.pcolor(x, y, phase, | |
|
148 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
|
149 | xlabel=xlabel, ylabel=ylabel, title=title, | |
|
150 | ticksize=9, cblabel='') | |
|
151 | ||
|
152 | ||
|
153 | ||
|
154 | self.draw() | |
|
155 | ||
|
156 | if save: | |
|
157 | date = thisDatetime.strftime("%Y%m%d") | |
|
158 | if figfile == None: | |
|
159 | figfile = self.getFilename(name = date) | |
|
160 | ||
|
161 | self.saveFigure(figpath, figfile) | |
|
162 | ||
|
163 | ||
|
5 | 164 | class RTIPlot(Figure): |
|
6 | 165 | |
|
7 | 166 | __isConfig = None |
@@ -118,7 +277,7 class RTIPlot(Figure): | |||
|
118 | 277 | for channel in channelList: |
|
119 | 278 | if channel not in dataOut.channelList: |
|
120 | 279 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
121 |
channelIndexList.append(dataOut.channelList.index( |
|
|
280 | channelIndexList.append(dataOut.channelList.index(channel)) | |
|
122 | 281 | |
|
123 | 282 | if timerange != None: |
|
124 | 283 | self.__timerange = timerange |
@@ -382,7 +541,7 class Scope(Figure): | |||
|
382 | 541 | for channel in channelList: |
|
383 | 542 | if channel not in dataOut.channelList: |
|
384 | 543 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
385 |
channelIndexList.append(dataOut.channelList.index( |
|
|
544 | channelIndexList.append(dataOut.channelList.index(channel)) | |
|
386 | 545 | |
|
387 | 546 | x = dataOut.heightList |
|
388 | 547 | y = dataOut.data[channelList,:] * numpy.conjugate(dataOut.data[channelList,:]) |
General Comments 0
You need to be logged in to leave comments.
Login now