@@ -1,1012 +1,1041 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import time, datetime |
|
2 | import time, datetime | |
3 | from graphics.figure import * |
|
3 | from graphics.figure import * | |
4 |
|
4 | |||
5 | class CrossSpectraPlot(Figure): |
|
5 | class CrossSpectraPlot(Figure): | |
6 |
|
6 | |||
7 | __isConfig = None |
|
7 | __isConfig = None | |
8 | __nsubplots = None |
|
8 | __nsubplots = None | |
9 |
|
9 | |||
10 | WIDTH = None |
|
10 | WIDTH = None | |
11 | HEIGHT = None |
|
11 | HEIGHT = None | |
12 | WIDTHPROF = None |
|
12 | WIDTHPROF = None | |
13 | HEIGHTPROF = None |
|
13 | HEIGHTPROF = None | |
14 | PREFIX = 'cspc' |
|
14 | PREFIX = 'cspc' | |
15 |
|
15 | |||
16 | def __init__(self): |
|
16 | def __init__(self): | |
17 |
|
17 | |||
18 | self.__isConfig = False |
|
18 | self.__isConfig = False | |
19 | self.__nsubplots = 4 |
|
19 | self.__nsubplots = 4 | |
20 |
|
20 | |||
21 | self.WIDTH = 250 |
|
21 | self.WIDTH = 250 | |
22 | self.HEIGHT = 250 |
|
22 | self.HEIGHT = 250 | |
23 | self.WIDTHPROF = 0 |
|
23 | self.WIDTHPROF = 0 | |
24 | self.HEIGHTPROF = 0 |
|
24 | self.HEIGHTPROF = 0 | |
25 |
|
25 | |||
26 | def getSubplots(self): |
|
26 | def getSubplots(self): | |
27 |
|
27 | |||
28 | ncol = 4 |
|
28 | ncol = 4 | |
29 | nrow = self.nplots |
|
29 | nrow = self.nplots | |
30 |
|
30 | |||
31 | return nrow, ncol |
|
31 | return nrow, ncol | |
32 |
|
32 | |||
33 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
33 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
34 |
|
34 | |||
35 | self.__showprofile = showprofile |
|
35 | self.__showprofile = showprofile | |
36 | self.nplots = nplots |
|
36 | self.nplots = nplots | |
37 |
|
37 | |||
38 | ncolspan = 1 |
|
38 | ncolspan = 1 | |
39 | colspan = 1 |
|
39 | colspan = 1 | |
40 |
|
40 | |||
41 | self.createFigure(idfigure = idfigure, |
|
41 | self.createFigure(idfigure = idfigure, | |
42 | wintitle = wintitle, |
|
42 | wintitle = wintitle, | |
43 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
43 | widthplot = self.WIDTH + self.WIDTHPROF, | |
44 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
44 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
45 |
|
45 | |||
46 | nrow, ncol = self.getSubplots() |
|
46 | nrow, ncol = self.getSubplots() | |
47 |
|
47 | |||
48 | counter = 0 |
|
48 | counter = 0 | |
49 | for y in range(nrow): |
|
49 | for y in range(nrow): | |
50 | for x in range(ncol): |
|
50 | for x in range(ncol): | |
51 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
51 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
52 |
|
52 | |||
53 | counter += 1 |
|
53 | counter += 1 | |
54 |
|
54 | |||
55 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
55 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
56 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
56 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
57 | save=False, figpath='./', figfile=None, |
|
57 | save=False, figpath='./', figfile=None, | |
58 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r'): |
|
58 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r'): | |
59 |
|
59 | |||
60 | """ |
|
60 | """ | |
61 |
|
61 | |||
62 | Input: |
|
62 | Input: | |
63 | dataOut : |
|
63 | dataOut : | |
64 | idfigure : |
|
64 | idfigure : | |
65 | wintitle : |
|
65 | wintitle : | |
66 | channelList : |
|
66 | channelList : | |
67 | showProfile : |
|
67 | showProfile : | |
68 | xmin : None, |
|
68 | xmin : None, | |
69 | xmax : None, |
|
69 | xmax : None, | |
70 | ymin : None, |
|
70 | ymin : None, | |
71 | ymax : None, |
|
71 | ymax : None, | |
72 | zmin : None, |
|
72 | zmin : None, | |
73 | zmax : None |
|
73 | zmax : None | |
74 | """ |
|
74 | """ | |
75 |
|
75 | |||
76 | if pairsList == None: |
|
76 | if pairsList == None: | |
77 | pairsIndexList = dataOut.pairsIndexList |
|
77 | pairsIndexList = dataOut.pairsIndexList | |
78 | else: |
|
78 | else: | |
79 | pairsIndexList = [] |
|
79 | pairsIndexList = [] | |
80 | for pair in pairsList: |
|
80 | for pair in pairsList: | |
81 | if pair not in dataOut.pairsList: |
|
81 | if pair not in dataOut.pairsList: | |
82 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
82 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
83 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
83 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
84 |
|
84 | |||
85 | if pairsIndexList == []: |
|
85 | if pairsIndexList == []: | |
86 | return |
|
86 | return | |
87 |
|
87 | |||
88 | if len(pairsIndexList) > 4: |
|
88 | if len(pairsIndexList) > 4: | |
89 | pairsIndexList = pairsIndexList[0:4] |
|
89 | pairsIndexList = pairsIndexList[0:4] | |
90 | factor = dataOut.normFactor |
|
90 | factor = dataOut.normFactor | |
91 | x = dataOut.getVelRange(1) |
|
91 | x = dataOut.getVelRange(1) | |
92 | y = dataOut.getHeiRange() |
|
92 | y = dataOut.getHeiRange() | |
93 | z = dataOut.data_spc[:,:,:]/factor |
|
93 | z = dataOut.data_spc[:,:,:]/factor | |
94 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
94 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
95 |
avg = |
|
95 | avg = numpy.average(z, axis=1) | |
96 | noise = dataOut.getNoise()/factor |
|
96 | noise = dataOut.getNoise()/factor | |
97 |
|
97 | |||
98 | zdB = 10*numpy.log10(z) |
|
98 | zdB = 10*numpy.log10(z) | |
99 | avgdB = 10*numpy.log10(avg) |
|
99 | avgdB = 10*numpy.log10(avg) | |
100 | noisedB = 10*numpy.log10(noise) |
|
100 | noisedB = 10*numpy.log10(noise) | |
101 |
|
101 | |||
102 |
|
102 | |||
103 | thisDatetime = dataOut.datatime |
|
103 | thisDatetime = dataOut.datatime | |
104 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
104 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
105 | xlabel = "Velocity (m/s)" |
|
105 | xlabel = "Velocity (m/s)" | |
106 | ylabel = "Range (Km)" |
|
106 | ylabel = "Range (Km)" | |
107 |
|
107 | |||
108 | if not self.__isConfig: |
|
108 | if not self.__isConfig: | |
109 |
|
109 | |||
110 | nplots = len(pairsIndexList) |
|
110 | nplots = len(pairsIndexList) | |
111 |
|
111 | |||
112 | self.setup(idfigure=idfigure, |
|
112 | self.setup(idfigure=idfigure, | |
113 | nplots=nplots, |
|
113 | nplots=nplots, | |
114 | wintitle=wintitle, |
|
114 | wintitle=wintitle, | |
115 | showprofile=showprofile) |
|
115 | showprofile=showprofile) | |
116 |
|
116 | |||
117 | if xmin == None: xmin = numpy.nanmin(x) |
|
117 | if xmin == None: xmin = numpy.nanmin(x) | |
118 | if xmax == None: xmax = numpy.nanmax(x) |
|
118 | if xmax == None: xmax = numpy.nanmax(x) | |
119 | if ymin == None: ymin = numpy.nanmin(y) |
|
119 | if ymin == None: ymin = numpy.nanmin(y) | |
120 | if ymax == None: ymax = numpy.nanmax(y) |
|
120 | if ymax == None: ymax = numpy.nanmax(y) | |
121 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
121 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
122 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
122 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
123 |
|
123 | |||
124 | self.__isConfig = True |
|
124 | self.__isConfig = True | |
125 |
|
125 | |||
126 | self.setWinTitle(title) |
|
126 | self.setWinTitle(title) | |
127 |
|
127 | |||
128 | for i in range(self.nplots): |
|
128 | for i in range(self.nplots): | |
129 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
129 | pair = dataOut.pairsList[pairsIndexList[i]] | |
130 |
|
130 | |||
131 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) |
|
131 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) | |
132 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) |
|
132 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) | |
133 | axes0 = self.axesList[i*self.__nsubplots] |
|
133 | axes0 = self.axesList[i*self.__nsubplots] | |
134 | axes0.pcolor(x, y, zdB, |
|
134 | axes0.pcolor(x, y, zdB, | |
135 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
135 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
136 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
136 | xlabel=xlabel, ylabel=ylabel, title=title, | |
137 | ticksize=9, colormap=power_cmap, cblabel='') |
|
137 | ticksize=9, colormap=power_cmap, cblabel='') | |
138 |
|
138 | |||
139 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) |
|
139 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) | |
140 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) |
|
140 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) | |
141 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
141 | axes0 = self.axesList[i*self.__nsubplots+1] | |
142 | axes0.pcolor(x, y, zdB, |
|
142 | axes0.pcolor(x, y, zdB, | |
143 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
143 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
144 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
144 | xlabel=xlabel, ylabel=ylabel, title=title, | |
145 | ticksize=9, colormap=power_cmap, cblabel='') |
|
145 | ticksize=9, colormap=power_cmap, cblabel='') | |
146 |
|
146 | |||
147 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
147 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
148 | coherence = numpy.abs(coherenceComplex) |
|
148 | coherence = numpy.abs(coherenceComplex) | |
149 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
149 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
150 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi |
|
150 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi | |
151 |
|
151 | |||
152 | title = "Coherence %d%d" %(pair[0], pair[1]) |
|
152 | title = "Coherence %d%d" %(pair[0], pair[1]) | |
153 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
153 | axes0 = self.axesList[i*self.__nsubplots+2] | |
154 | axes0.pcolor(x, y, coherence, |
|
154 | axes0.pcolor(x, y, coherence, | |
155 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
155 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
156 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
156 | xlabel=xlabel, ylabel=ylabel, title=title, | |
157 | ticksize=9, colormap=coherence_cmap, cblabel='') |
|
157 | ticksize=9, colormap=coherence_cmap, cblabel='') | |
158 |
|
158 | |||
159 | title = "Phase %d%d" %(pair[0], pair[1]) |
|
159 | title = "Phase %d%d" %(pair[0], pair[1]) | |
160 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
160 | axes0 = self.axesList[i*self.__nsubplots+3] | |
161 | axes0.pcolor(x, y, phase, |
|
161 | axes0.pcolor(x, y, phase, | |
162 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
162 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
163 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
163 | xlabel=xlabel, ylabel=ylabel, title=title, | |
164 | ticksize=9, colormap=phase_cmap, cblabel='') |
|
164 | ticksize=9, colormap=phase_cmap, cblabel='') | |
165 |
|
165 | |||
166 |
|
166 | |||
167 |
|
167 | |||
168 | self.draw() |
|
168 | self.draw() | |
169 |
|
169 | |||
170 | if save: |
|
170 | if save: | |
171 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
171 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
172 | if figfile == None: |
|
172 | if figfile == None: | |
173 | figfile = self.getFilename(name = date) |
|
173 | figfile = self.getFilename(name = date) | |
174 |
|
174 | |||
175 | self.saveFigure(figpath, figfile) |
|
175 | self.saveFigure(figpath, figfile) | |
176 |
|
176 | |||
177 |
|
177 | |||
178 | class RTIPlot(Figure): |
|
178 | class RTIPlot(Figure): | |
179 |
|
179 | |||
180 | __isConfig = None |
|
180 | __isConfig = None | |
181 | __nsubplots = None |
|
181 | __nsubplots = None | |
182 | __missing = 1E30 |
|
182 | __missing = 1E30 | |
183 | WIDTHPROF = None |
|
183 | WIDTHPROF = None | |
184 | HEIGHTPROF = None |
|
184 | HEIGHTPROF = None | |
185 | PREFIX = 'rti' |
|
185 | PREFIX = 'rti' | |
186 |
|
186 | |||
187 | def __init__(self): |
|
187 | def __init__(self): | |
188 |
|
188 | |||
189 | self.timerange = 2*60*60 |
|
189 | self.timerange = 2*60*60 | |
190 | self.__isConfig = False |
|
190 | self.__isConfig = False | |
191 | self.__nsubplots = 1 |
|
191 | self.__nsubplots = 1 | |
192 |
|
192 | |||
193 | self.WIDTH = 800 |
|
193 | self.WIDTH = 800 | |
194 | self.HEIGHT = 200 |
|
194 | self.HEIGHT = 200 | |
195 | self.WIDTHPROF = 120 |
|
195 | self.WIDTHPROF = 120 | |
196 | self.HEIGHTPROF = 0 |
|
196 | self.HEIGHTPROF = 0 | |
197 | self.x_buffer = None |
|
197 | self.x_buffer = None | |
198 | self.avgdB_buffer = None |
|
198 | self.avgdB_buffer = None | |
199 |
|
199 | |||
200 | def getSubplots(self): |
|
200 | def getSubplots(self): | |
201 |
|
201 | |||
202 | ncol = 1 |
|
202 | ncol = 1 | |
203 | nrow = self.nplots |
|
203 | nrow = self.nplots | |
204 |
|
204 | |||
205 | return nrow, ncol |
|
205 | return nrow, ncol | |
206 |
|
206 | |||
207 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
207 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
208 |
|
208 | |||
209 | self.__showprofile = showprofile |
|
209 | self.__showprofile = showprofile | |
210 | self.nplots = nplots |
|
210 | self.nplots = nplots | |
211 |
|
211 | |||
212 | ncolspan = 1 |
|
212 | ncolspan = 1 | |
213 | colspan = 1 |
|
213 | colspan = 1 | |
214 | if showprofile: |
|
214 | if showprofile: | |
215 | ncolspan = 7 |
|
215 | ncolspan = 7 | |
216 | colspan = 6 |
|
216 | colspan = 6 | |
217 | self.__nsubplots = 2 |
|
217 | self.__nsubplots = 2 | |
218 |
|
218 | |||
219 | self.createFigure(idfigure = idfigure, |
|
219 | self.createFigure(idfigure = idfigure, | |
220 | wintitle = wintitle, |
|
220 | wintitle = wintitle, | |
221 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
221 | widthplot = self.WIDTH + self.WIDTHPROF, | |
222 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
222 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
223 |
|
223 | |||
224 | nrow, ncol = self.getSubplots() |
|
224 | nrow, ncol = self.getSubplots() | |
225 |
|
225 | |||
226 | counter = 0 |
|
226 | counter = 0 | |
227 | for y in range(nrow): |
|
227 | for y in range(nrow): | |
228 | for x in range(ncol): |
|
228 | for x in range(ncol): | |
229 |
|
229 | |||
230 | if counter >= self.nplots: |
|
230 | if counter >= self.nplots: | |
231 | break |
|
231 | break | |
232 |
|
232 | |||
233 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
233 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
234 |
|
234 | |||
235 | if showprofile: |
|
235 | if showprofile: | |
236 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
236 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
237 |
|
237 | |||
238 | counter += 1 |
|
238 | counter += 1 | |
239 |
|
239 | |||
240 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
240 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
241 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
241 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
242 | timerange=None, |
|
242 | timerange=None, | |
243 | save=False, figpath='./', figfile=None): |
|
243 | save=False, figpath='./', figfile=None): | |
244 |
|
244 | |||
245 | """ |
|
245 | """ | |
246 |
|
246 | |||
247 | Input: |
|
247 | Input: | |
248 | dataOut : |
|
248 | dataOut : | |
249 | idfigure : |
|
249 | idfigure : | |
250 | wintitle : |
|
250 | wintitle : | |
251 | channelList : |
|
251 | channelList : | |
252 | showProfile : |
|
252 | showProfile : | |
253 | xmin : None, |
|
253 | xmin : None, | |
254 | xmax : None, |
|
254 | xmax : None, | |
255 | ymin : None, |
|
255 | ymin : None, | |
256 | ymax : None, |
|
256 | ymax : None, | |
257 | zmin : None, |
|
257 | zmin : None, | |
258 | zmax : None |
|
258 | zmax : None | |
259 | """ |
|
259 | """ | |
260 |
|
260 | |||
261 | if channelList == None: |
|
261 | if channelList == None: | |
262 | channelIndexList = dataOut.channelIndexList |
|
262 | channelIndexList = dataOut.channelIndexList | |
263 | else: |
|
263 | else: | |
264 | channelIndexList = [] |
|
264 | channelIndexList = [] | |
265 | for channel in channelList: |
|
265 | for channel in channelList: | |
266 | if channel not in dataOut.channelList: |
|
266 | if channel not in dataOut.channelList: | |
267 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
267 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
268 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
268 | channelIndexList.append(dataOut.channelList.index(channel)) | |
269 |
|
269 | |||
270 | if timerange != None: |
|
270 | if timerange != None: | |
271 | self.timerange = timerange |
|
271 | self.timerange = timerange | |
272 |
|
272 | |||
273 | tmin = None |
|
273 | tmin = None | |
274 | tmax = None |
|
274 | tmax = None | |
275 | factor = dataOut.normFactor |
|
275 | factor = dataOut.normFactor | |
276 | x = dataOut.getTimeRange() |
|
276 | x = dataOut.getTimeRange() | |
277 | y = dataOut.getHeiRange() |
|
277 | y = dataOut.getHeiRange() | |
278 |
|
278 | |||
279 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
279 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
280 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
280 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
281 | avg = numpy.average(z, axis=1) |
|
281 | avg = numpy.average(z, axis=1) | |
282 |
|
282 | |||
283 | avgdB = 10.*numpy.log10(avg) |
|
283 | avgdB = 10.*numpy.log10(avg) | |
284 |
|
284 | |||
285 |
|
285 | |||
286 | thisDatetime = dataOut.datatime |
|
286 | thisDatetime = dataOut.datatime | |
287 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
287 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
288 | xlabel = "Velocity (m/s)" |
|
288 | xlabel = "Velocity (m/s)" | |
289 | ylabel = "Range (Km)" |
|
289 | ylabel = "Range (Km)" | |
290 |
|
290 | |||
291 | if not self.__isConfig: |
|
291 | if not self.__isConfig: | |
292 |
|
292 | |||
293 | nplots = len(channelIndexList) |
|
293 | nplots = len(channelIndexList) | |
294 |
|
294 | |||
295 | self.setup(idfigure=idfigure, |
|
295 | self.setup(idfigure=idfigure, | |
296 | nplots=nplots, |
|
296 | nplots=nplots, | |
297 | wintitle=wintitle, |
|
297 | wintitle=wintitle, | |
298 | showprofile=showprofile) |
|
298 | showprofile=showprofile) | |
299 |
|
299 | |||
300 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
300 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
301 | if ymin == None: ymin = numpy.nanmin(y) |
|
301 | if ymin == None: ymin = numpy.nanmin(y) | |
302 | if ymax == None: ymax = numpy.nanmax(y) |
|
302 | if ymax == None: ymax = numpy.nanmax(y) | |
303 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
303 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
304 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
304 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
305 |
|
305 | |||
306 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
306 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
307 | self.x_buffer = numpy.array([]) |
|
307 | self.x_buffer = numpy.array([]) | |
308 | self.avgdB_buffer = numpy.array([]) |
|
308 | self.avgdB_buffer = numpy.array([]) | |
309 | self.__isConfig = True |
|
309 | self.__isConfig = True | |
310 |
|
310 | |||
311 |
|
311 | |||
312 | self.setWinTitle(title) |
|
312 | self.setWinTitle(title) | |
313 |
|
313 | |||
314 | if len(self.avgdB_buffer)==0: |
|
314 | if len(self.avgdB_buffer)==0: | |
315 | self.avgdB_buffer = avgdB |
|
315 | self.avgdB_buffer = avgdB | |
316 | newxdim = 1 |
|
316 | newxdim = 1 | |
317 | newydim = -1 |
|
317 | newydim = -1 | |
318 | else: |
|
318 | else: | |
319 | if x[0]>self.x_buffer[-1]: |
|
319 | if x[0]>self.x_buffer[-1]: | |
320 | gap = avgdB.copy() |
|
320 | gap = avgdB.copy() | |
321 | gap[:] = self.__missing |
|
321 | gap[:] = self.__missing | |
322 | self.avgdB_buffer = numpy.hstack((self.avgdB_buffer, gap)) |
|
322 | self.avgdB_buffer = numpy.hstack((self.avgdB_buffer, gap)) | |
323 |
|
323 | |||
324 | self.avgdB_buffer = numpy.hstack((self.avgdB_buffer, avgdB)) |
|
324 | self.avgdB_buffer = numpy.hstack((self.avgdB_buffer, avgdB)) | |
325 | newxdim = -1 |
|
325 | newxdim = -1 | |
326 | newydim = len(y) |
|
326 | newydim = len(y) | |
327 |
|
327 | |||
328 | self.x_buffer = numpy.hstack((self.x_buffer, x)) |
|
328 | self.x_buffer = numpy.hstack((self.x_buffer, x)) | |
329 |
|
329 | |||
330 | self.avgdB_buffer = numpy.ma.masked_inside(self.avgdB_buffer,0.99*self.__missing,1.01*self.__missing) |
|
330 | self.avgdB_buffer = numpy.ma.masked_inside(self.avgdB_buffer,0.99*self.__missing,1.01*self.__missing) | |
331 |
|
331 | |||
332 | for i in range(self.nplots): |
|
332 | for i in range(self.nplots): | |
333 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
333 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
334 | axes = self.axesList[i*self.__nsubplots] |
|
334 | axes = self.axesList[i*self.__nsubplots] | |
335 | zdB = self.avgdB_buffer[i].reshape(newxdim,newydim) |
|
335 | zdB = self.avgdB_buffer[i].reshape(newxdim,newydim) | |
336 | axes.pcolor(self.x_buffer, y, zdB, |
|
336 | axes.pcolor(self.x_buffer, y, zdB, | |
337 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
337 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
338 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
338 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
339 | ticksize=9, cblabel='', cbsize="1%") |
|
339 | ticksize=9, cblabel='', cbsize="1%") | |
340 |
|
340 | |||
341 | if self.__showprofile: |
|
341 | if self.__showprofile: | |
342 | axes = self.axesList[i*self.__nsubplots +1] |
|
342 | axes = self.axesList[i*self.__nsubplots +1] | |
343 | axes.pline(avgdB[i], y, |
|
343 | axes.pline(avgdB[i], y, | |
344 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
344 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
345 | xlabel='dB', ylabel='', title='', |
|
345 | xlabel='dB', ylabel='', title='', | |
346 | ytick_visible=False, |
|
346 | ytick_visible=False, | |
347 | grid='x') |
|
347 | grid='x') | |
348 |
|
348 | |||
349 | self.draw() |
|
349 | self.draw() | |
350 |
|
350 | |||
351 | if save: |
|
351 | if save: | |
352 |
|
352 | |||
353 | if figfile == None: |
|
353 | if figfile == None: | |
354 | figfile = self.getFilename(name = self.name) |
|
354 | figfile = self.getFilename(name = self.name) | |
355 |
|
355 | |||
356 | self.saveFigure(figpath, figfile) |
|
356 | self.saveFigure(figpath, figfile) | |
357 |
|
357 | |||
358 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
358 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
359 | self.__isConfig = False |
|
359 | self.__isConfig = False | |
360 |
|
360 | |||
361 | class SpectraPlot(Figure): |
|
361 | class SpectraPlot(Figure): | |
362 |
|
362 | |||
363 | __isConfig = None |
|
363 | __isConfig = None | |
364 | __nsubplots = None |
|
364 | __nsubplots = None | |
365 |
|
365 | |||
366 | WIDTHPROF = None |
|
366 | WIDTHPROF = None | |
367 | HEIGHTPROF = None |
|
367 | HEIGHTPROF = None | |
368 | PREFIX = 'spc' |
|
368 | PREFIX = 'spc' | |
369 |
|
369 | |||
370 | def __init__(self): |
|
370 | def __init__(self): | |
371 |
|
371 | |||
372 | self.__isConfig = False |
|
372 | self.__isConfig = False | |
373 | self.__nsubplots = 1 |
|
373 | self.__nsubplots = 1 | |
374 |
|
374 | |||
375 | self.WIDTH = 230 |
|
375 | self.WIDTH = 230 | |
376 | self.HEIGHT = 250 |
|
376 | self.HEIGHT = 250 | |
377 | self.WIDTHPROF = 120 |
|
377 | self.WIDTHPROF = 120 | |
378 | self.HEIGHTPROF = 0 |
|
378 | self.HEIGHTPROF = 0 | |
379 |
|
379 | |||
380 | def getSubplots(self): |
|
380 | def getSubplots(self): | |
381 |
|
381 | |||
382 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
382 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
383 | nrow = int(self.nplots*1./ncol + 0.9) |
|
383 | nrow = int(self.nplots*1./ncol + 0.9) | |
384 |
|
384 | |||
385 | return nrow, ncol |
|
385 | return nrow, ncol | |
386 |
|
386 | |||
387 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
387 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
388 |
|
388 | |||
389 | self.__showprofile = showprofile |
|
389 | self.__showprofile = showprofile | |
390 | self.nplots = nplots |
|
390 | self.nplots = nplots | |
391 |
|
391 | |||
392 | ncolspan = 1 |
|
392 | ncolspan = 1 | |
393 | colspan = 1 |
|
393 | colspan = 1 | |
394 | if showprofile: |
|
394 | if showprofile: | |
395 | ncolspan = 3 |
|
395 | ncolspan = 3 | |
396 | colspan = 2 |
|
396 | colspan = 2 | |
397 | self.__nsubplots = 2 |
|
397 | self.__nsubplots = 2 | |
398 |
|
398 | |||
399 | self.createFigure(idfigure = idfigure, |
|
399 | self.createFigure(idfigure = idfigure, | |
400 | wintitle = wintitle, |
|
400 | wintitle = wintitle, | |
401 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
401 | widthplot = self.WIDTH + self.WIDTHPROF, | |
402 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
402 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
403 |
|
403 | |||
404 | nrow, ncol = self.getSubplots() |
|
404 | nrow, ncol = self.getSubplots() | |
405 |
|
405 | |||
406 | counter = 0 |
|
406 | counter = 0 | |
407 | for y in range(nrow): |
|
407 | for y in range(nrow): | |
408 | for x in range(ncol): |
|
408 | for x in range(ncol): | |
409 |
|
409 | |||
410 | if counter >= self.nplots: |
|
410 | if counter >= self.nplots: | |
411 | break |
|
411 | break | |
412 |
|
412 | |||
413 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
413 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
414 |
|
414 | |||
415 | if showprofile: |
|
415 | if showprofile: | |
416 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
416 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
417 |
|
417 | |||
418 | counter += 1 |
|
418 | counter += 1 | |
419 |
|
419 | |||
420 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
420 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
421 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
421 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
422 | save=False, figpath='./', figfile=None): |
|
422 | save=False, figpath='./', figfile=None): | |
423 |
|
423 | |||
424 | """ |
|
424 | """ | |
425 |
|
425 | |||
426 | Input: |
|
426 | Input: | |
427 | dataOut : |
|
427 | dataOut : | |
428 | idfigure : |
|
428 | idfigure : | |
429 | wintitle : |
|
429 | wintitle : | |
430 | channelList : |
|
430 | channelList : | |
431 | showProfile : |
|
431 | showProfile : | |
432 | xmin : None, |
|
432 | xmin : None, | |
433 | xmax : None, |
|
433 | xmax : None, | |
434 | ymin : None, |
|
434 | ymin : None, | |
435 | ymax : None, |
|
435 | ymax : None, | |
436 | zmin : None, |
|
436 | zmin : None, | |
437 | zmax : None |
|
437 | zmax : None | |
438 | """ |
|
438 | """ | |
439 |
|
439 | |||
440 | if channelList == None: |
|
440 | if channelList == None: | |
441 | channelIndexList = dataOut.channelIndexList |
|
441 | channelIndexList = dataOut.channelIndexList | |
442 | else: |
|
442 | else: | |
443 | channelIndexList = [] |
|
443 | channelIndexList = [] | |
444 | for channel in channelList: |
|
444 | for channel in channelList: | |
445 | if channel not in dataOut.channelList: |
|
445 | if channel not in dataOut.channelList: | |
446 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
446 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
447 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
447 | channelIndexList.append(dataOut.channelList.index(channel)) | |
448 | factor = dataOut.normFactor |
|
448 | factor = dataOut.normFactor | |
449 | x = dataOut.getVelRange(1) |
|
449 | x = dataOut.getVelRange(1) | |
450 | y = dataOut.getHeiRange() |
|
450 | y = dataOut.getHeiRange() | |
451 |
|
451 | |||
452 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
452 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
453 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
453 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
454 | avg = numpy.average(z, axis=1) |
|
454 | avg = numpy.average(z, axis=1) | |
455 | noise = dataOut.getNoise()/factor |
|
455 | noise = dataOut.getNoise()/factor | |
456 |
|
456 | |||
457 | zdB = 10*numpy.log10(z) |
|
457 | zdB = 10*numpy.log10(z) | |
458 | avgdB = 10*numpy.log10(avg) |
|
458 | avgdB = 10*numpy.log10(avg) | |
459 | noisedB = 10*numpy.log10(noise) |
|
459 | noisedB = 10*numpy.log10(noise) | |
460 |
|
460 | |||
461 | thisDatetime = dataOut.datatime |
|
461 | thisDatetime = dataOut.datatime | |
462 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
462 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
463 | xlabel = "Velocity (m/s)" |
|
463 | xlabel = "Velocity (m/s)" | |
464 | ylabel = "Range (Km)" |
|
464 | ylabel = "Range (Km)" | |
465 |
|
465 | |||
466 | if not self.__isConfig: |
|
466 | if not self.__isConfig: | |
467 |
|
467 | |||
468 | nplots = len(channelIndexList) |
|
468 | nplots = len(channelIndexList) | |
469 |
|
469 | |||
470 | self.setup(idfigure=idfigure, |
|
470 | self.setup(idfigure=idfigure, | |
471 | nplots=nplots, |
|
471 | nplots=nplots, | |
472 | wintitle=wintitle, |
|
472 | wintitle=wintitle, | |
473 | showprofile=showprofile) |
|
473 | showprofile=showprofile) | |
474 |
|
474 | |||
475 | if xmin == None: xmin = numpy.nanmin(x) |
|
475 | if xmin == None: xmin = numpy.nanmin(x) | |
476 | if xmax == None: xmax = numpy.nanmax(x) |
|
476 | if xmax == None: xmax = numpy.nanmax(x) | |
477 | if ymin == None: ymin = numpy.nanmin(y) |
|
477 | if ymin == None: ymin = numpy.nanmin(y) | |
478 | if ymax == None: ymax = numpy.nanmax(y) |
|
478 | if ymax == None: ymax = numpy.nanmax(y) | |
479 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
479 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
480 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
480 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
481 |
|
481 | |||
482 | self.__isConfig = True |
|
482 | self.__isConfig = True | |
483 |
|
483 | |||
484 | self.setWinTitle(title) |
|
484 | self.setWinTitle(title) | |
485 |
|
485 | |||
486 | for i in range(self.nplots): |
|
486 | for i in range(self.nplots): | |
487 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i]) |
|
487 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i]) | |
488 | axes = self.axesList[i*self.__nsubplots] |
|
488 | axes = self.axesList[i*self.__nsubplots] | |
489 | axes.pcolor(x, y, zdB[i,:,:], |
|
489 | axes.pcolor(x, y, zdB[i,:,:], | |
490 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
490 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
491 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
491 | xlabel=xlabel, ylabel=ylabel, title=title, | |
492 | ticksize=9, cblabel='') |
|
492 | ticksize=9, cblabel='') | |
493 |
|
493 | |||
494 | if self.__showprofile: |
|
494 | if self.__showprofile: | |
495 | axes = self.axesList[i*self.__nsubplots +1] |
|
495 | axes = self.axesList[i*self.__nsubplots +1] | |
496 | axes.pline(avgdB[i], y, |
|
496 | axes.pline(avgdB[i], y, | |
497 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
497 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
498 | xlabel='dB', ylabel='', title='', |
|
498 | xlabel='dB', ylabel='', title='', | |
499 | ytick_visible=False, |
|
499 | ytick_visible=False, | |
500 | grid='x') |
|
500 | grid='x') | |
501 |
|
501 | |||
502 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
502 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
503 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
503 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
504 |
|
504 | |||
505 | self.draw() |
|
505 | self.draw() | |
506 |
|
506 | |||
507 | if save: |
|
507 | if save: | |
508 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
508 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
509 | if figfile == None: |
|
509 | if figfile == None: | |
510 | figfile = self.getFilename(name = date) |
|
510 | figfile = self.getFilename(name = date) | |
511 |
|
511 | |||
512 | self.saveFigure(figpath, figfile) |
|
512 | self.saveFigure(figpath, figfile) | |
513 |
|
513 | |||
514 | class Scope(Figure): |
|
514 | class Scope(Figure): | |
515 |
|
515 | |||
516 | __isConfig = None |
|
516 | __isConfig = None | |
517 |
|
517 | |||
518 | def __init__(self): |
|
518 | def __init__(self): | |
519 |
|
519 | |||
520 | self.__isConfig = False |
|
520 | self.__isConfig = False | |
521 | self.WIDTH = 600 |
|
521 | self.WIDTH = 600 | |
522 | self.HEIGHT = 200 |
|
522 | self.HEIGHT = 200 | |
523 |
|
523 | |||
524 | def getSubplots(self): |
|
524 | def getSubplots(self): | |
525 |
|
525 | |||
526 | nrow = self.nplots |
|
526 | nrow = self.nplots | |
527 | ncol = 3 |
|
527 | ncol = 3 | |
528 | return nrow, ncol |
|
528 | return nrow, ncol | |
529 |
|
529 | |||
530 | def setup(self, idfigure, nplots, wintitle): |
|
530 | def setup(self, idfigure, nplots, wintitle): | |
531 |
|
531 | |||
532 | self.nplots = nplots |
|
532 | self.nplots = nplots | |
533 |
|
533 | |||
534 | self.createFigure(idfigure, wintitle) |
|
534 | self.createFigure(idfigure, wintitle) | |
535 |
|
535 | |||
536 | nrow,ncol = self.getSubplots() |
|
536 | nrow,ncol = self.getSubplots() | |
537 | colspan = 3 |
|
537 | colspan = 3 | |
538 | rowspan = 1 |
|
538 | rowspan = 1 | |
539 |
|
539 | |||
540 | for i in range(nplots): |
|
540 | for i in range(nplots): | |
541 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
541 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
542 |
|
542 | |||
543 |
|
543 | |||
544 |
|
544 | |||
545 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
545 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
546 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
546 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, | |
547 | figpath='./', figfile=None): |
|
547 | figpath='./', figfile=None): | |
548 |
|
548 | |||
549 | """ |
|
549 | """ | |
550 |
|
550 | |||
551 | Input: |
|
551 | Input: | |
552 | dataOut : |
|
552 | dataOut : | |
553 | idfigure : |
|
553 | idfigure : | |
554 | wintitle : |
|
554 | wintitle : | |
555 | channelList : |
|
555 | channelList : | |
556 | xmin : None, |
|
556 | xmin : None, | |
557 | xmax : None, |
|
557 | xmax : None, | |
558 | ymin : None, |
|
558 | ymin : None, | |
559 | ymax : None, |
|
559 | ymax : None, | |
560 | """ |
|
560 | """ | |
561 |
|
561 | |||
562 | if channelList == None: |
|
562 | if channelList == None: | |
563 | channelIndexList = dataOut.channelIndexList |
|
563 | channelIndexList = dataOut.channelIndexList | |
564 | else: |
|
564 | else: | |
565 | channelIndexList = [] |
|
565 | channelIndexList = [] | |
566 | for channel in channelList: |
|
566 | for channel in channelList: | |
567 | if channel not in dataOut.channelList: |
|
567 | if channel not in dataOut.channelList: | |
568 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
568 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
569 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
569 | channelIndexList.append(dataOut.channelList.index(channel)) | |
570 |
|
570 | |||
571 | x = dataOut.heightList |
|
571 | x = dataOut.heightList | |
572 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
572 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
573 | y = y.real |
|
573 | y = y.real | |
574 |
|
574 | |||
575 | thisDatetime = dataOut.datatime |
|
575 | thisDatetime = dataOut.datatime | |
576 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
576 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
577 | xlabel = "Range (Km)" |
|
577 | xlabel = "Range (Km)" | |
578 | ylabel = "Intensity" |
|
578 | ylabel = "Intensity" | |
579 |
|
579 | |||
580 | if not self.__isConfig: |
|
580 | if not self.__isConfig: | |
581 | nplots = len(channelIndexList) |
|
581 | nplots = len(channelIndexList) | |
582 |
|
582 | |||
583 | self.setup(idfigure=idfigure, |
|
583 | self.setup(idfigure=idfigure, | |
584 | nplots=nplots, |
|
584 | nplots=nplots, | |
585 | wintitle=wintitle) |
|
585 | wintitle=wintitle) | |
586 |
|
586 | |||
587 | if xmin == None: xmin = numpy.nanmin(x) |
|
587 | if xmin == None: xmin = numpy.nanmin(x) | |
588 | if xmax == None: xmax = numpy.nanmax(x) |
|
588 | if xmax == None: xmax = numpy.nanmax(x) | |
589 | if ymin == None: ymin = numpy.nanmin(y) |
|
589 | if ymin == None: ymin = numpy.nanmin(y) | |
590 | if ymax == None: ymax = numpy.nanmax(y) |
|
590 | if ymax == None: ymax = numpy.nanmax(y) | |
591 |
|
591 | |||
592 | self.__isConfig = True |
|
592 | self.__isConfig = True | |
593 |
|
593 | |||
594 | self.setWinTitle(title) |
|
594 | self.setWinTitle(title) | |
595 |
|
595 | |||
596 | for i in range(len(self.axesList)): |
|
596 | for i in range(len(self.axesList)): | |
597 | title = "Channel %d" %(i) |
|
597 | title = "Channel %d" %(i) | |
598 | axes = self.axesList[i] |
|
598 | axes = self.axesList[i] | |
599 | ychannel = y[i,:] |
|
599 | ychannel = y[i,:] | |
600 | axes.pline(x, ychannel, |
|
600 | axes.pline(x, ychannel, | |
601 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
601 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
602 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
602 | xlabel=xlabel, ylabel=ylabel, title=title) | |
603 |
|
603 | |||
604 | self.draw() |
|
604 | self.draw() | |
605 |
|
605 | |||
606 | if save: |
|
606 | if save: | |
607 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
607 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
608 | if figfile == None: |
|
608 | if figfile == None: | |
609 | figfile = self.getFilename(name = date) |
|
609 | figfile = self.getFilename(name = date) | |
610 |
|
610 | |||
611 | self.saveFigure(figpath, figfile) |
|
611 | self.saveFigure(figpath, figfile) | |
612 |
|
612 | |||
613 | class ProfilePlot(Figure): |
|
613 | class ProfilePlot(Figure): | |
614 | __isConfig = None |
|
614 | __isConfig = None | |
615 | __nsubplots = None |
|
615 | __nsubplots = None | |
616 |
|
616 | |||
617 | WIDTHPROF = None |
|
617 | WIDTHPROF = None | |
618 | HEIGHTPROF = None |
|
618 | HEIGHTPROF = None | |
619 | PREFIX = 'spcprofile' |
|
619 | PREFIX = 'spcprofile' | |
620 |
|
620 | |||
621 | def __init__(self): |
|
621 | def __init__(self): | |
622 | self.__isConfig = False |
|
622 | self.__isConfig = False | |
623 | self.__nsubplots = 1 |
|
623 | self.__nsubplots = 1 | |
624 |
|
624 | |||
625 | self.WIDTH = 300 |
|
625 | self.WIDTH = 300 | |
626 | self.HEIGHT = 500 |
|
626 | self.HEIGHT = 500 | |
627 |
|
627 | |||
628 | def getSubplots(self): |
|
628 | def getSubplots(self): | |
629 | ncol = 1 |
|
629 | ncol = 1 | |
630 | nrow = 1 |
|
630 | nrow = 1 | |
631 |
|
631 | |||
632 | return nrow, ncol |
|
632 | return nrow, ncol | |
633 |
|
633 | |||
634 | def setup(self, idfigure, nplots, wintitle): |
|
634 | def setup(self, idfigure, nplots, wintitle): | |
635 |
|
635 | |||
636 | self.nplots = nplots |
|
636 | self.nplots = nplots | |
637 |
|
637 | |||
638 | ncolspan = 1 |
|
638 | ncolspan = 1 | |
639 | colspan = 1 |
|
639 | colspan = 1 | |
640 |
|
640 | |||
641 | self.createFigure(idfigure = idfigure, |
|
641 | self.createFigure(idfigure = idfigure, | |
642 | wintitle = wintitle, |
|
642 | wintitle = wintitle, | |
643 | widthplot = self.WIDTH, |
|
643 | widthplot = self.WIDTH, | |
644 | heightplot = self.HEIGHT) |
|
644 | heightplot = self.HEIGHT) | |
645 |
|
645 | |||
646 | nrow, ncol = self.getSubplots() |
|
646 | nrow, ncol = self.getSubplots() | |
647 |
|
647 | |||
648 | counter = 0 |
|
648 | counter = 0 | |
649 | for y in range(nrow): |
|
649 | for y in range(nrow): | |
650 | for x in range(ncol): |
|
650 | for x in range(ncol): | |
651 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
651 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
652 |
|
652 | |||
653 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
653 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
654 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
654 | xmin=None, xmax=None, ymin=None, ymax=None, | |
655 | save=False, figpath='./', figfile=None): |
|
655 | save=False, figpath='./', figfile=None): | |
656 |
|
656 | |||
657 | if channelList == None: |
|
657 | if channelList == None: | |
658 | channelIndexList = dataOut.channelIndexList |
|
658 | channelIndexList = dataOut.channelIndexList | |
659 | channelList = dataOut.channelList |
|
659 | channelList = dataOut.channelList | |
660 | else: |
|
660 | else: | |
661 | channelIndexList = [] |
|
661 | channelIndexList = [] | |
662 | for channel in channelList: |
|
662 | for channel in channelList: | |
663 | if channel not in dataOut.channelList: |
|
663 | if channel not in dataOut.channelList: | |
664 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
664 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
665 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
665 | channelIndexList.append(dataOut.channelList.index(channel)) | |
666 |
|
666 | |||
667 | factor = dataOut.normFactor |
|
667 | factor = dataOut.normFactor | |
668 | y = dataOut.getHeiRange() |
|
668 | y = dataOut.getHeiRange() | |
669 | x = dataOut.data_spc[channelIndexList,:,:]/factor |
|
669 | x = dataOut.data_spc[channelIndexList,:,:]/factor | |
670 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
670 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
671 | avg = numpy.average(x, axis=1) |
|
671 | avg = numpy.average(x, axis=1) | |
672 |
|
672 | |||
673 | avgdB = 10*numpy.log10(avg) |
|
673 | avgdB = 10*numpy.log10(avg) | |
674 |
|
674 | |||
675 | thisDatetime = dataOut.datatime |
|
675 | thisDatetime = dataOut.datatime | |
676 | title = "Power Profile" |
|
676 | title = "Power Profile" | |
677 | xlabel = "dB" |
|
677 | xlabel = "dB" | |
678 | ylabel = "Range (Km)" |
|
678 | ylabel = "Range (Km)" | |
679 |
|
679 | |||
680 | if not self.__isConfig: |
|
680 | if not self.__isConfig: | |
681 |
|
681 | |||
682 | nplots = 1 |
|
682 | nplots = 1 | |
683 |
|
683 | |||
684 | self.setup(idfigure=idfigure, |
|
684 | self.setup(idfigure=idfigure, | |
685 | nplots=nplots, |
|
685 | nplots=nplots, | |
686 | wintitle=wintitle) |
|
686 | wintitle=wintitle) | |
687 |
|
687 | |||
688 | if ymin == None: ymin = numpy.nanmin(y) |
|
688 | if ymin == None: ymin = numpy.nanmin(y) | |
689 | if ymax == None: ymax = numpy.nanmax(y) |
|
689 | if ymax == None: ymax = numpy.nanmax(y) | |
690 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 |
|
690 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 | |
691 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 |
|
691 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 | |
692 |
|
692 | |||
693 | self.__isConfig = True |
|
693 | self.__isConfig = True | |
694 |
|
694 | |||
695 | self.setWinTitle(title) |
|
695 | self.setWinTitle(title) | |
696 |
|
696 | |||
697 |
|
697 | |||
698 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
698 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
699 | axes = self.axesList[0] |
|
699 | axes = self.axesList[0] | |
700 |
|
700 | |||
701 | legendlabels = ["channel %d"%x for x in channelList] |
|
701 | legendlabels = ["channel %d"%x for x in channelList] | |
702 | axes.pmultiline(avgdB, y, |
|
702 | axes.pmultiline(avgdB, y, | |
703 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
703 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
704 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
704 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
705 | ytick_visible=True, nxticks=5, |
|
705 | ytick_visible=True, nxticks=5, | |
706 | grid='x') |
|
706 | grid='x') | |
707 |
|
707 | |||
708 | self.draw() |
|
708 | self.draw() | |
709 |
|
709 | |||
710 | if save: |
|
710 | if save: | |
711 | date = thisDatetime.strftime("%Y%m%d") |
|
711 | date = thisDatetime.strftime("%Y%m%d") | |
712 | if figfile == None: |
|
712 | if figfile == None: | |
713 | figfile = self.getFilename(name = date) |
|
713 | figfile = self.getFilename(name = date) | |
714 |
|
714 | |||
715 | self.saveFigure(figpath, figfile) |
|
715 | self.saveFigure(figpath, figfile) | |
716 |
|
716 | |||
717 | class CoherenceMap(Figure): |
|
717 | class CoherenceMap(Figure): | |
718 | __isConfig = None |
|
718 | __isConfig = None | |
719 | __nsubplots = None |
|
719 | __nsubplots = None | |
720 |
|
720 | |||
721 | WIDTHPROF = None |
|
721 | WIDTHPROF = None | |
722 | HEIGHTPROF = None |
|
722 | HEIGHTPROF = None | |
723 | PREFIX = 'cmap' |
|
723 | PREFIX = 'cmap' | |
|
724 | __missing = 1E30 | |||
724 |
|
725 | |||
725 | def __init__(self): |
|
726 | def __init__(self): | |
726 | self.timerange = 2*60*60 |
|
727 | self.timerange = 2*60*60 | |
727 | self.__isConfig = False |
|
728 | self.__isConfig = False | |
728 | self.__nsubplots = 1 |
|
729 | self.__nsubplots = 1 | |
729 |
|
730 | |||
730 | self.WIDTH = 800 |
|
731 | self.WIDTH = 800 | |
731 | self.HEIGHT = 200 |
|
732 | self.HEIGHT = 200 | |
732 | self.WIDTHPROF = 120 |
|
733 | self.WIDTHPROF = 120 | |
733 | self.HEIGHTPROF = 0 |
|
734 | self.HEIGHTPROF = 0 | |
|
735 | self.x_buffer = None | |||
|
736 | self.coherence_buffer = None | |||
|
737 | self.phase_buffer = None | |||
734 |
|
738 | |||
735 | def getSubplots(self): |
|
739 | def getSubplots(self): | |
736 | ncol = 1 |
|
740 | ncol = 1 | |
737 | nrow = self.nplots*2 |
|
741 | nrow = self.nplots*2 | |
738 |
|
742 | |||
739 | return nrow, ncol |
|
743 | return nrow, ncol | |
740 |
|
744 | |||
741 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
745 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
742 | self.__showprofile = showprofile |
|
746 | self.__showprofile = showprofile | |
743 | self.nplots = nplots |
|
747 | self.nplots = nplots | |
744 |
|
748 | |||
745 | ncolspan = 1 |
|
749 | ncolspan = 1 | |
746 | colspan = 1 |
|
750 | colspan = 1 | |
747 | if showprofile: |
|
751 | if showprofile: | |
748 | ncolspan = 7 |
|
752 | ncolspan = 7 | |
749 | colspan = 6 |
|
753 | colspan = 6 | |
750 | self.__nsubplots = 2 |
|
754 | self.__nsubplots = 2 | |
751 |
|
755 | |||
752 | self.createFigure(idfigure = idfigure, |
|
756 | self.createFigure(idfigure = idfigure, | |
753 | wintitle = wintitle, |
|
757 | wintitle = wintitle, | |
754 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
758 | widthplot = self.WIDTH + self.WIDTHPROF, | |
755 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
759 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
756 |
|
760 | |||
757 | nrow, ncol = self.getSubplots() |
|
761 | nrow, ncol = self.getSubplots() | |
758 |
|
762 | |||
759 | for y in range(nrow): |
|
763 | for y in range(nrow): | |
760 | for x in range(ncol): |
|
764 | for x in range(ncol): | |
761 |
|
765 | |||
762 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
766 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
763 |
|
767 | |||
764 | if showprofile: |
|
768 | if showprofile: | |
765 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
769 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
766 |
|
770 | |||
767 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
771 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
768 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
772 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
769 | timerange=None, |
|
773 | timerange=None, | |
770 | save=False, figpath='./', figfile=None, |
|
774 | save=False, figpath='./', figfile=None, | |
771 | coherence_cmap='jet', phase_cmap='RdBu_r'): |
|
775 | coherence_cmap='jet', phase_cmap='RdBu_r'): | |
772 |
|
776 | |||
773 | if pairsList == None: |
|
777 | if pairsList == None: | |
774 | pairsIndexList = dataOut.pairsIndexList |
|
778 | pairsIndexList = dataOut.pairsIndexList | |
775 | else: |
|
779 | else: | |
776 | pairsIndexList = [] |
|
780 | pairsIndexList = [] | |
777 | for pair in pairsList: |
|
781 | for pair in pairsList: | |
778 | if pair not in dataOut.pairsList: |
|
782 | if pair not in dataOut.pairsList: | |
779 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
783 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
780 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
784 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
781 |
|
785 | |||
782 | if timerange != None: |
|
786 | if timerange != None: | |
783 | self.timerange = timerange |
|
787 | self.timerange = timerange | |
784 |
|
788 | |||
785 | if pairsIndexList == []: |
|
789 | if pairsIndexList == []: | |
786 | return |
|
790 | return | |
787 |
|
791 | |||
788 | if len(pairsIndexList) > 4: |
|
792 | if len(pairsIndexList) > 4: | |
789 | pairsIndexList = pairsIndexList[0:4] |
|
793 | pairsIndexList = pairsIndexList[0:4] | |
790 |
|
794 | |||
791 | tmin = None |
|
795 | tmin = None | |
792 | tmax = None |
|
796 | tmax = None | |
793 | x = dataOut.getTimeRange() |
|
797 | x = dataOut.getTimeRange() | |
794 | y = dataOut.getHeiRange() |
|
798 | y = dataOut.getHeiRange() | |
795 |
|
799 | |||
796 | thisDatetime = dataOut.datatime |
|
800 | thisDatetime = dataOut.datatime | |
797 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
801 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
798 | xlabel = "" |
|
802 | xlabel = "" | |
799 | ylabel = "Range (Km)" |
|
803 | ylabel = "Range (Km)" | |
800 |
|
804 | |||
801 | if not self.__isConfig: |
|
805 | if not self.__isConfig: | |
802 | nplots = len(pairsIndexList) |
|
806 | nplots = len(pairsIndexList) | |
803 | self.setup(idfigure=idfigure, |
|
807 | self.setup(idfigure=idfigure, | |
804 | nplots=nplots, |
|
808 | nplots=nplots, | |
805 | wintitle=wintitle, |
|
809 | wintitle=wintitle, | |
806 | showprofile=showprofile) |
|
810 | showprofile=showprofile) | |
807 |
|
811 | |||
808 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
812 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
809 | if ymin == None: ymin = numpy.nanmin(y) |
|
813 | if ymin == None: ymin = numpy.nanmin(y) | |
810 | if ymax == None: ymax = numpy.nanmax(y) |
|
814 | if ymax == None: ymax = numpy.nanmax(y) | |
811 |
|
815 | |||
812 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
816 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
813 |
|
817 | self.x_buffer = numpy.array([]) | ||
|
818 | self.coherence_buffer = numpy.array([]) | |||
|
819 | self.phase_buffer = numpy.array([]) | |||
814 | self.__isConfig = True |
|
820 | self.__isConfig = True | |
815 |
|
821 | |||
816 | self.setWinTitle(title) |
|
822 | self.setWinTitle(title) | |
817 |
|
823 | |||
818 | for i in range(self.nplots): |
|
|||
819 |
|
824 | |||
820 |
|
|
825 | pairArray = numpy.array(dataOut.pairsList) | |
821 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
826 | pairArray = pairArray[pairsIndexList] | |
822 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) |
|
827 | pair0ids = pairArray[:,0] | |
|
828 | pair1ids = pairArray[:,1] | |||
|
829 | ||||
|
830 | coherenceComplex = dataOut.data_cspc[pairsIndexList,:,:]/numpy.sqrt(dataOut.data_spc[pair0ids,:,:]*dataOut.data_spc[pair1ids,:,:]) | |||
|
831 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=1) | |||
823 |
|
|
832 | coherence = numpy.abs(avgcoherenceComplex) | |
824 | # coherence = numpy.abs(coherenceComplex) |
|
|||
825 | # avg = numpy.average(coherence, axis=0) |
|
|||
826 |
|
|
833 | ||
827 | z = coherence.reshape((1,-1)) |
|
834 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
828 |
|
835 | |||
829 | counter = 0 |
|
836 | if len(self.coherence_buffer)==0: | |
|
837 | self.coherence_buffer = coherence | |||
|
838 | self.phase_buffer = phase | |||
|
839 | newxdim = 1 | |||
|
840 | newydim = -1 | |||
|
841 | else: | |||
|
842 | if x[0]>self.x_buffer[-1]: | |||
|
843 | gap = coherence.copy() | |||
|
844 | gap[:] = self.__missing | |||
|
845 | self.coherence_buffer = numpy.hstack((self.coherence_buffer, gap)) | |||
|
846 | self.phase_buffer = numpy.hstack((self.phase_buffer, gap)) | |||
|
847 | ||||
|
848 | self.coherence_buffer = numpy.hstack((self.coherence_buffer, coherence)) | |||
|
849 | self.phase_buffer = numpy.hstack((self.phase_buffer, phase)) | |||
|
850 | newxdim = -1 | |||
|
851 | newydim = len(y) | |||
|
852 | ||||
|
853 | self.x_buffer = numpy.hstack((self.x_buffer, x)) | |||
830 |
|
|
854 | ||
831 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
855 | self.coherence_buffer = numpy.ma.masked_inside(self.coherence_buffer,0.99*self.__missing,1.01*self.__missing) | |
|
856 | self.phase_buffer = numpy.ma.masked_inside(self.phase_buffer,0.99*self.__missing,1.01*self.__missing) | |||
|
857 | ||||
|
858 | ||||
|
859 | for i in range(self.nplots): | |||
|
860 | counter = 0 | |||
|
861 | z = self.coherence_buffer[i,:].reshape((newxdim,newydim)) | |||
|
862 | title = "Coherence %d%d: %s" %(pair0ids[i], pair1ids[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |||
832 | axes = self.axesList[i*self.__nsubplots*2] |
|
863 | axes = self.axesList[i*self.__nsubplots*2] | |
833 | axes.pcolor(x, y, z, |
|
864 | axes.pcolor(self.x_buffer, y, z, | |
834 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
865 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
835 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
866 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
836 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") |
|
867 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") | |
837 |
|
868 | |||
838 | if self.__showprofile: |
|
869 | if self.__showprofile: | |
839 | counter += 1 |
|
870 | counter += 1 | |
840 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
871 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
841 | axes.pline(coherence, y, |
|
872 | axes.pline(coherence[i,:], y, | |
842 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, |
|
873 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, | |
843 | xlabel='', ylabel='', title='', ticksize=7, |
|
874 | xlabel='', ylabel='', title='', ticksize=7, | |
844 | ytick_visible=False, nxticks=5, |
|
875 | ytick_visible=False, nxticks=5, | |
845 | grid='x') |
|
876 | grid='x') | |
846 |
|
877 | |||
847 | counter += 1 |
|
878 | counter += 1 | |
848 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
|||
849 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
|||
850 | # avg = numpy.average(phase, axis=0) |
|
|||
851 | z = phase.reshape((1,-1)) |
|
|||
852 |
|
879 | |||
853 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
880 | z = self.phase_buffer[i,:].reshape((newxdim,newydim)) | |
|
881 | ||||
|
882 | title = "Phase %d%d: %s" %(pair0ids[i], pair1ids[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |||
854 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
883 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
855 | axes.pcolor(x, y, z, |
|
884 | axes.pcolor(self.x_buffer, y, z, | |
856 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
885 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
857 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
886 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
858 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") |
|
887 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") | |
859 |
|
888 | |||
860 | if self.__showprofile: |
|
889 | if self.__showprofile: | |
861 | counter += 1 |
|
890 | counter += 1 | |
862 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
891 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
863 | axes.pline(phase, y, |
|
892 | axes.pline(phase[i,:], y, | |
864 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, |
|
893 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, | |
865 | xlabel='', ylabel='', title='', ticksize=7, |
|
894 | xlabel='', ylabel='', title='', ticksize=7, | |
866 | ytick_visible=False, nxticks=4, |
|
895 | ytick_visible=False, nxticks=4, | |
867 | grid='x') |
|
896 | grid='x') | |
868 |
|
897 | |||
869 | self.draw() |
|
898 | self.draw() | |
870 |
|
899 | |||
871 | if save: |
|
900 | if save: | |
872 |
|
901 | |||
873 | if figfile == None: |
|
902 | if figfile == None: | |
874 | figfile = self.getFilename(name = self.name) |
|
903 | figfile = self.getFilename(name = self.name) | |
875 |
|
904 | |||
876 | self.saveFigure(figpath, figfile) |
|
905 | self.saveFigure(figpath, figfile) | |
877 |
|
906 | |||
878 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
907 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
879 | self.__isConfig = False |
|
908 | self.__isConfig = False | |
880 |
|
909 | |||
881 | class RTIfromNoise(Figure): |
|
910 | class RTIfromNoise(Figure): | |
882 |
|
911 | |||
883 | __isConfig = None |
|
912 | __isConfig = None | |
884 | __nsubplots = None |
|
913 | __nsubplots = None | |
885 |
|
914 | |||
886 | PREFIX = 'rtinoise' |
|
915 | PREFIX = 'rtinoise' | |
887 |
|
916 | |||
888 | def __init__(self): |
|
917 | def __init__(self): | |
889 |
|
918 | |||
890 | self.timerange = 24*60*60 |
|
919 | self.timerange = 24*60*60 | |
891 | self.__isConfig = False |
|
920 | self.__isConfig = False | |
892 | self.__nsubplots = 1 |
|
921 | self.__nsubplots = 1 | |
893 |
|
922 | |||
894 | self.WIDTH = 820 |
|
923 | self.WIDTH = 820 | |
895 | self.HEIGHT = 200 |
|
924 | self.HEIGHT = 200 | |
896 | self.WIDTHPROF = 120 |
|
925 | self.WIDTHPROF = 120 | |
897 | self.HEIGHTPROF = 0 |
|
926 | self.HEIGHTPROF = 0 | |
898 | self.xdata = None |
|
927 | self.xdata = None | |
899 | self.ydata = None |
|
928 | self.ydata = None | |
900 |
|
929 | |||
901 | def getSubplots(self): |
|
930 | def getSubplots(self): | |
902 |
|
931 | |||
903 | ncol = 1 |
|
932 | ncol = 1 | |
904 | nrow = 1 |
|
933 | nrow = 1 | |
905 |
|
934 | |||
906 | return nrow, ncol |
|
935 | return nrow, ncol | |
907 |
|
936 | |||
908 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
937 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
909 |
|
938 | |||
910 | self.__showprofile = showprofile |
|
939 | self.__showprofile = showprofile | |
911 | self.nplots = nplots |
|
940 | self.nplots = nplots | |
912 |
|
941 | |||
913 | ncolspan = 7 |
|
942 | ncolspan = 7 | |
914 | colspan = 6 |
|
943 | colspan = 6 | |
915 | self.__nsubplots = 2 |
|
944 | self.__nsubplots = 2 | |
916 |
|
945 | |||
917 | self.createFigure(idfigure = idfigure, |
|
946 | self.createFigure(idfigure = idfigure, | |
918 | wintitle = wintitle, |
|
947 | wintitle = wintitle, | |
919 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
948 | widthplot = self.WIDTH+self.WIDTHPROF, | |
920 | heightplot = self.HEIGHT+self.HEIGHTPROF) |
|
949 | heightplot = self.HEIGHT+self.HEIGHTPROF) | |
921 |
|
950 | |||
922 | nrow, ncol = self.getSubplots() |
|
951 | nrow, ncol = self.getSubplots() | |
923 |
|
952 | |||
924 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
953 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
925 |
|
954 | |||
926 |
|
955 | |||
927 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
956 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
928 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
957 | xmin=None, xmax=None, ymin=None, ymax=None, | |
929 | timerange=None, |
|
958 | timerange=None, | |
930 | save=False, figpath='./', figfile=None): |
|
959 | save=False, figpath='./', figfile=None): | |
931 |
|
960 | |||
932 | if channelList == None: |
|
961 | if channelList == None: | |
933 | channelIndexList = dataOut.channelIndexList |
|
962 | channelIndexList = dataOut.channelIndexList | |
934 | channelList = dataOut.channelList |
|
963 | channelList = dataOut.channelList | |
935 | else: |
|
964 | else: | |
936 | channelIndexList = [] |
|
965 | channelIndexList = [] | |
937 | for channel in channelList: |
|
966 | for channel in channelList: | |
938 | if channel not in dataOut.channelList: |
|
967 | if channel not in dataOut.channelList: | |
939 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
968 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
940 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
969 | channelIndexList.append(dataOut.channelList.index(channel)) | |
941 |
|
970 | |||
942 | if timerange != None: |
|
971 | if timerange != None: | |
943 | self.timerange = timerange |
|
972 | self.timerange = timerange | |
944 |
|
973 | |||
945 | tmin = None |
|
974 | tmin = None | |
946 | tmax = None |
|
975 | tmax = None | |
947 | x = dataOut.getTimeRange() |
|
976 | x = dataOut.getTimeRange() | |
948 | y = dataOut.getHeiRange() |
|
977 | y = dataOut.getHeiRange() | |
949 | factor = dataOut.normFactor |
|
978 | factor = dataOut.normFactor | |
950 | noise = dataOut.getNoise()/factor |
|
979 | noise = dataOut.getNoise()/factor | |
951 | noisedB = 10*numpy.log10(noise) |
|
980 | noisedB = 10*numpy.log10(noise) | |
952 |
|
981 | |||
953 | thisDatetime = dataOut.datatime |
|
982 | thisDatetime = dataOut.datatime | |
954 | title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
983 | title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
955 | xlabel = "" |
|
984 | xlabel = "" | |
956 | ylabel = "Range (Km)" |
|
985 | ylabel = "Range (Km)" | |
957 |
|
986 | |||
958 | if not self.__isConfig: |
|
987 | if not self.__isConfig: | |
959 |
|
988 | |||
960 | nplots = 1 |
|
989 | nplots = 1 | |
961 |
|
990 | |||
962 | self.setup(idfigure=idfigure, |
|
991 | self.setup(idfigure=idfigure, | |
963 | nplots=nplots, |
|
992 | nplots=nplots, | |
964 | wintitle=wintitle, |
|
993 | wintitle=wintitle, | |
965 | showprofile=showprofile) |
|
994 | showprofile=showprofile) | |
966 |
|
995 | |||
967 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
996 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
968 | if ymin == None: ymin = numpy.nanmin(noisedB) |
|
997 | if ymin == None: ymin = numpy.nanmin(noisedB) | |
969 | if ymax == None: ymax = numpy.nanmax(noisedB) |
|
998 | if ymax == None: ymax = numpy.nanmax(noisedB) | |
970 |
|
999 | |||
971 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1000 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
972 | self.__isConfig = True |
|
1001 | self.__isConfig = True | |
973 |
|
1002 | |||
974 | self.xdata = numpy.array([]) |
|
1003 | self.xdata = numpy.array([]) | |
975 | self.ydata = numpy.array([]) |
|
1004 | self.ydata = numpy.array([]) | |
976 |
|
1005 | |||
977 | self.setWinTitle(title) |
|
1006 | self.setWinTitle(title) | |
978 |
|
1007 | |||
979 |
|
1008 | |||
980 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1009 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
981 |
|
1010 | |||
982 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] |
|
1011 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] | |
983 | axes = self.axesList[0] |
|
1012 | axes = self.axesList[0] | |
984 |
|
1013 | |||
985 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1014 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
986 |
|
1015 | |||
987 | if len(self.ydata)==0: |
|
1016 | if len(self.ydata)==0: | |
988 | self.ydata = noisedB[channelIndexList].reshape(-1,1) |
|
1017 | self.ydata = noisedB[channelIndexList].reshape(-1,1) | |
989 | else: |
|
1018 | else: | |
990 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) |
|
1019 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) | |
991 |
|
1020 | |||
992 |
|
1021 | |||
993 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1022 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
994 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
1023 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | |
995 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1024 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
996 | XAxisAsTime=True |
|
1025 | XAxisAsTime=True | |
997 | ) |
|
1026 | ) | |
998 |
|
1027 | |||
999 | self.draw() |
|
1028 | self.draw() | |
1000 |
|
1029 | |||
1001 | if save: |
|
1030 | if save: | |
1002 |
|
1031 | |||
1003 | if figfile == None: |
|
1032 | if figfile == None: | |
1004 | figfile = self.getFilename(name = self.name) |
|
1033 | figfile = self.getFilename(name = self.name) | |
1005 |
|
1034 | |||
1006 | self.saveFigure(figpath, figfile) |
|
1035 | self.saveFigure(figpath, figfile) | |
1007 |
|
1036 | |||
1008 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1037 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
1009 | self.__isConfig = False |
|
1038 | self.__isConfig = False | |
1010 | del self.xdata |
|
1039 | del self.xdata | |
1011 | del self.ydata |
|
1040 | del self.ydata | |
1012 | No newline at end of file |
|
1041 |
General Comments 0
You need to be logged in to leave comments.
Login now