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