##// END OF EJS Templates
Last Commit foreva!
ebocanegra -
r1157:823d4012bd34
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,2161 +1,2393
1 1 import os
2 2 import datetime
3 3 import numpy
4 4 import inspect
5 5 from figure import Figure, isRealtime, isTimeInHourRange
6 6 from plotting_codes import *
7 7
8 class ParamLine(Figure):
9
10 isConfig = None
11
12 def __init__(self):
13
14 self.isConfig = False
15 self.WIDTH = 300
16 self.HEIGHT = 200
17 self.counter_imagwr = 0
18
19 def getSubplots(self):
20
21 nrow = self.nplots
22 ncol = 3
23 return nrow, ncol
24
25 def setup(self, id, nplots, wintitle, show):
26
27 self.nplots = nplots
28
29 self.createFigure(id=id,
30 wintitle=wintitle,
31 show=show)
32
33 nrow,ncol = self.getSubplots()
34 colspan = 3
35 rowspan = 1
36
37 for i in range(nplots):
38 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
39
40 def plot_iq(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
41 yreal = y[channelIndexList,:].real
42 yimag = y[channelIndexList,:].imag
43
44 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
45 xlabel = "Range (Km)"
46 ylabel = "Intensity - IQ"
47
48 if not self.isConfig:
49 nplots = len(channelIndexList)
50
51 self.setup(id=id,
52 nplots=nplots,
53 wintitle='',
54 show=show)
55
56 if xmin == None: xmin = numpy.nanmin(x)
57 if xmax == None: xmax = numpy.nanmax(x)
58 if ymin == None: ymin = min(numpy.nanmin(yreal),numpy.nanmin(yimag))
59 if ymax == None: ymax = max(numpy.nanmax(yreal),numpy.nanmax(yimag))
60
61 self.isConfig = True
62
63 self.setWinTitle(title)
64
65 for i in range(len(self.axesList)):
66 title = "Channel %d" %(i)
67 axes = self.axesList[i]
68
69 axes.pline(x, yreal[i,:],
70 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
71 xlabel=xlabel, ylabel=ylabel, title=title)
72
73 axes.addpline(x, yimag[i,:], idline=1, color="red", linestyle="solid", lw=2)
74
75 def plot_power(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
76 y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:])
77 yreal = y.real
78
79 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
80 xlabel = "Range (Km)"
81 ylabel = "Intensity"
82
83 if not self.isConfig:
84 nplots = len(channelIndexList)
85
86 self.setup(id=id,
87 nplots=nplots,
88 wintitle='',
89 show=show)
90
91 if xmin == None: xmin = numpy.nanmin(x)
92 if xmax == None: xmax = numpy.nanmax(x)
93 if ymin == None: ymin = numpy.nanmin(yreal)
94 if ymax == None: ymax = numpy.nanmax(yreal)
95
96 self.isConfig = True
97
98 self.setWinTitle(title)
99
100 for i in range(len(self.axesList)):
101 title = "Channel %d" %(i)
102 axes = self.axesList[i]
103 ychannel = yreal[i,:]
104 axes.pline(x, ychannel,
105 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
106 xlabel=xlabel, ylabel=ylabel, title=title)
107
108
109 def run(self, dataOut, id, wintitle="", channelList=None,
110 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
111 figpath='./', figfile=None, show=True, wr_period=1,
112 ftp=False, server=None, folder=None, username=None, password=None):
113
114 """
115
116 Input:
117 dataOut :
118 id :
119 wintitle :
120 channelList :
121 xmin : None,
122 xmax : None,
123 ymin : None,
124 ymax : None,
125 """
126
127 if channelList == None:
128 channelIndexList = dataOut.channelIndexList
129 else:
130 channelIndexList = []
131 for channel in channelList:
132 if channel not in dataOut.channelList:
133 raise ValueError, "Channel %d is not in dataOut.channelList"
134 channelIndexList.append(dataOut.channelList.index(channel))
135
136 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
137
138 y = dataOut.RR
139
140 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
141 xlabel = "Range (Km)"
142 ylabel = "Intensity"
143
144 if not self.isConfig:
145 nplots = len(channelIndexList)
146
147 self.setup(id=id,
148 nplots=nplots,
149 wintitle='',
150 show=show)
151
152 if xmin == None: xmin = numpy.nanmin(x)
153 if xmax == None: xmax = numpy.nanmax(x)
154 if ymin == None: ymin = numpy.nanmin(y)
155 if ymax == None: ymax = numpy.nanmax(y)
156
157 self.isConfig = True
158
159 self.setWinTitle(title)
160
161 for i in range(len(self.axesList)):
162 title = "Channel %d" %(i)
163 axes = self.axesList[i]
164 ychannel = y[i,:]
165 axes.pline(x, ychannel,
166 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
167 xlabel=xlabel, ylabel=ylabel, title=title)
168
169
170 self.draw()
171
172 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") + "_" + str(dataOut.profileIndex)
173 figfile = self.getFilename(name = str_datetime)
174
175 self.save(figpath=figpath,
176 figfile=figfile,
177 save=save,
178 ftp=ftp,
179 wr_period=wr_period,
180 thisDatetime=thisDatetime)
181
182
8 183
9 184 class SpcParamPlot(Figure):
10 185
11 186 isConfig = None
12 187 __nsubplots = None
13 188
14 189 WIDTHPROF = None
15 190 HEIGHTPROF = None
16 191 PREFIX = 'SpcParam'
17 192
18 193 def __init__(self, **kwargs):
19 194 Figure.__init__(self, **kwargs)
20 195 self.isConfig = False
21 196 self.__nsubplots = 1
22 197
23 198 self.WIDTH = 250
24 199 self.HEIGHT = 250
25 200 self.WIDTHPROF = 120
26 201 self.HEIGHTPROF = 0
27 202 self.counter_imagwr = 0
28 203
29 204 self.PLOT_CODE = SPEC_CODE
30 205
31 206 self.FTP_WEI = None
32 207 self.EXP_CODE = None
33 208 self.SUB_EXP_CODE = None
34 209 self.PLOT_POS = None
35 210
36 211 self.__xfilter_ena = False
37 212 self.__yfilter_ena = False
38 213
39 214 def getSubplots(self):
40 215
41 216 ncol = int(numpy.sqrt(self.nplots)+0.9)
42 217 nrow = int(self.nplots*1./ncol + 0.9)
43 218
44 219 return nrow, ncol
45 220
46 221 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
47 222
48 223 self.__showprofile = showprofile
49 224 self.nplots = nplots
50 225
51 226 ncolspan = 1
52 227 colspan = 1
53 228 if showprofile:
54 229 ncolspan = 3
55 230 colspan = 2
56 231 self.__nsubplots = 2
57 232
58 233 self.createFigure(id = id,
59 234 wintitle = wintitle,
60 235 widthplot = self.WIDTH + self.WIDTHPROF,
61 236 heightplot = self.HEIGHT + self.HEIGHTPROF,
62 237 show=show)
63 238
64 239 nrow, ncol = self.getSubplots()
65 240
66 241 counter = 0
67 242 for y in range(nrow):
68 243 for x in range(ncol):
69 244
70 245 if counter >= self.nplots:
71 246 break
72 247
73 248 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
74 249
75 250 if showprofile:
76 251 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
77 252
78 253 counter += 1
79 254
80 255 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
81 256 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
82 257 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
83 258 server=None, folder=None, username=None, password=None,
84 259 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
85 260 xaxis="frequency", colormap='jet', normFactor=None , Selector = 0):
86 261
87 262 """
88 263
89 264 Input:
90 265 dataOut :
91 266 id :
92 267 wintitle :
93 268 channelList :
94 269 showProfile :
95 270 xmin : None,
96 271 xmax : None,
97 272 ymin : None,
98 273 ymax : None,
99 274 zmin : None,
100 275 zmax : None
101 276 """
102 277 if realtime:
103 278 if not(isRealtime(utcdatatime = dataOut.utctime)):
104 279 print 'Skipping this plot function'
105 280 return
106 281
107 282 if channelList == None:
108 283 channelIndexList = dataOut.channelIndexList
109 284 else:
110 285 channelIndexList = []
111 286 for channel in channelList:
112 287 if channel not in dataOut.channelList:
113 288 raise ValueError, "Channel %d is not in dataOut.channelList" %channel
114 289 channelIndexList.append(dataOut.channelList.index(channel))
115 290
116 291 # if normFactor is None:
117 292 # factor = dataOut.normFactor
118 293 # else:
119 294 # factor = normFactor
120 295 if xaxis == "frequency":
121 296 x = dataOut.spcparam_range[0]
122 297 xlabel = "Frequency (kHz)"
123 298
124 299 elif xaxis == "time":
125 300 x = dataOut.spcparam_range[1]
126 301 xlabel = "Time (ms)"
127 302
128 303 else:
129 304 x = dataOut.spcparam_range[2]
130 305 xlabel = "Velocity (m/s)"
131 306 print "Vmax=",x[-1]
132 307
133 308 ylabel = "Range (km)"
134 309
135 310 y = dataOut.getHeiRange()
136 311
137 312 z = dataOut.SPCparam[Selector] /1966080.0#/ dataOut.normFactor#GauSelector] #dataOut.data_spc/factor
138 313 #print 'GausSPC', z[0,32,10:40]
139 314 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
140 315 zdB = 10*numpy.log10(z)
141 316
142 317 avg = numpy.average(z, axis=1)
143 318 avgdB = 10*numpy.log10(avg)
144 319
145 320 noise = dataOut.spc_noise
146 321 noisedB = 10*numpy.log10(noise)
147 322
148 323 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
149 324 title = wintitle + " Spectra"
150 325 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
151 326 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
152 327
153 328 if not self.isConfig:
154 329
155 330 nplots = len(channelIndexList)
156 331
157 332 self.setup(id=id,
158 333 nplots=nplots,
159 334 wintitle=wintitle,
160 335 showprofile=showprofile,
161 336 show=show)
162 337
163 338 if xmin == None: xmin = numpy.nanmin(x)
164 339 if xmax == None: xmax = numpy.nanmax(x)
165 340 if ymin == None: ymin = numpy.nanmin(y)
166 341 if ymax == None: ymax = numpy.nanmax(y)
167 342 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
168 343 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
169 344
170 345 self.FTP_WEI = ftp_wei
171 346 self.EXP_CODE = exp_code
172 347 self.SUB_EXP_CODE = sub_exp_code
173 348 self.PLOT_POS = plot_pos
174 349
175 350 self.isConfig = True
176 351
177 352 self.setWinTitle(title)
178 353
179 354 for i in range(self.nplots):
180 355 index = channelIndexList[i]
181 356 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
182 357 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime)
183 358 if len(dataOut.beam.codeList) != 0:
184 359 title = "Ch%d:%4.2fdB,%2.2f,%2.2f:%s" %(dataOut.channelList[index], noisedB[index], dataOut.beam.azimuthList[index], dataOut.beam.zenithList[index], str_datetime)
185 360
186 361 axes = self.axesList[i*self.__nsubplots]
187 362 axes.pcolor(x, y, zdB[index,:,:],
188 363 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
189 364 xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap,
190 365 ticksize=9, cblabel='')
191 366
192 367 if self.__showprofile:
193 368 axes = self.axesList[i*self.__nsubplots +1]
194 369 axes.pline(avgdB[index,:], y,
195 370 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
196 371 xlabel='dB', ylabel='', title='',
197 372 ytick_visible=False,
198 373 grid='x')
199 374
200 375 noiseline = numpy.repeat(noisedB[index], len(y))
201 376 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
202 377
203 378 self.draw()
204 379
205 380 if figfile == None:
206 381 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
207 382 name = str_datetime
208 383 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
209 384 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
210 385 figfile = self.getFilename(name)
211 386
212 387 self.save(figpath=figpath,
213 388 figfile=figfile,
214 389 save=save,
215 390 ftp=ftp,
216 391 wr_period=wr_period,
217 392 thisDatetime=thisDatetime)
218 393
219 394
220 395
221 396 class MomentsPlot(Figure):
222 397
223 398 isConfig = None
224 399 __nsubplots = None
225 400
226 401 WIDTHPROF = None
227 402 HEIGHTPROF = None
228 403 PREFIX = 'prm'
229 404
230 405 def __init__(self, **kwargs):
231 406 Figure.__init__(self, **kwargs)
232 407 self.isConfig = False
233 408 self.__nsubplots = 1
234 409
235 410 self.WIDTH = 280
236 411 self.HEIGHT = 250
237 412 self.WIDTHPROF = 120
238 413 self.HEIGHTPROF = 0
239 414 self.counter_imagwr = 0
240 415
241 416 self.PLOT_CODE = MOMENTS_CODE
242 417
243 418 self.FTP_WEI = None
244 419 self.EXP_CODE = None
245 420 self.SUB_EXP_CODE = None
246 421 self.PLOT_POS = None
247 422
248 423 def getSubplots(self):
249 424
250 425 ncol = int(numpy.sqrt(self.nplots)+0.9)
251 426 nrow = int(self.nplots*1./ncol + 0.9)
252 427
253 428 return nrow, ncol
254 429
255 430 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
256 431
257 432 self.__showprofile = showprofile
258 433 self.nplots = nplots
259 434
260 435 ncolspan = 1
261 436 colspan = 1
262 437 if showprofile:
263 438 ncolspan = 3
264 439 colspan = 2
265 440 self.__nsubplots = 2
266 441
267 442 self.createFigure(id = id,
268 443 wintitle = wintitle,
269 444 widthplot = self.WIDTH + self.WIDTHPROF,
270 445 heightplot = self.HEIGHT + self.HEIGHTPROF,
271 446 show=show)
272 447
273 448 nrow, ncol = self.getSubplots()
274 449
275 450 counter = 0
276 451 for y in range(nrow):
277 452 for x in range(ncol):
278 453
279 454 if counter >= self.nplots:
280 455 break
281 456
282 457 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
283 458
284 459 if showprofile:
285 460 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
286 461
287 462 counter += 1
288 463
289 464 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
290 465 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
291 466 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
292 467 server=None, folder=None, username=None, password=None,
293 468 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
294 469
295 470 """
296 471
297 472 Input:
298 473 dataOut :
299 474 id :
300 475 wintitle :
301 476 channelList :
302 477 showProfile :
303 478 xmin : None,
304 479 xmax : None,
305 480 ymin : None,
306 481 ymax : None,
307 482 zmin : None,
308 483 zmax : None
309 484 """
310 485
311 486 if dataOut.flagNoData:
312 487 return None
313 488
314 489 if realtime:
315 490 if not(isRealtime(utcdatatime = dataOut.utctime)):
316 491 print 'Skipping this plot function'
317 492 return
318 493
319 494 if channelList == None:
320 495 channelIndexList = dataOut.channelIndexList
321 496 else:
322 497 channelIndexList = []
323 498 for channel in channelList:
324 499 if channel not in dataOut.channelList:
325 500 raise ValueError, "Channel %d is not in dataOut.channelList"
326 501 channelIndexList.append(dataOut.channelList.index(channel))
327 502
328 503 factor = dataOut.normFactor
329 504 x = dataOut.abscissaList
330 505 y = dataOut.heightList
331 506
332 507 z = dataOut.data_pre[channelIndexList,:,:]/factor
333 508 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
334 509 avg = numpy.average(z, axis=1)
335 510 noise = dataOut.noise/factor
336 511
337 512 zdB = 10*numpy.log10(z)
338 513 avgdB = 10*numpy.log10(avg)
339 514 noisedB = 10*numpy.log10(noise)
340 515
341 516 #thisDatetime = dataOut.datatime
342 517 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
343 518 title = wintitle + " Parameters"
344 519 xlabel = "Velocity (m/s)"
345 520 ylabel = "Range (Km)"
346 521
347 522 update_figfile = False
348 523
349 524 if not self.isConfig:
350 525
351 526 nplots = len(channelIndexList)
352 527
353 528 self.setup(id=id,
354 529 nplots=nplots,
355 530 wintitle=wintitle,
356 531 showprofile=showprofile,
357 532 show=show)
358 533
359 534 if xmin == None: xmin = numpy.nanmin(x)
360 535 if xmax == None: xmax = numpy.nanmax(x)
361 536 if ymin == None: ymin = numpy.nanmin(y)
362 537 if ymax == None: ymax = numpy.nanmax(y)
363 538 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
364 539 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
365 540
366 541 self.FTP_WEI = ftp_wei
367 542 self.EXP_CODE = exp_code
368 543 self.SUB_EXP_CODE = sub_exp_code
369 544 self.PLOT_POS = plot_pos
370 545
371 546 self.isConfig = True
372 547 update_figfile = True
373 548
374 549 self.setWinTitle(title)
375 550
376 551 for i in range(self.nplots):
377 552 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
378 553 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime)
379 554 axes = self.axesList[i*self.__nsubplots]
380 555 axes.pcolor(x, y, zdB[i,:,:],
381 556 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
382 557 xlabel=xlabel, ylabel=ylabel, title=title,
383 558 ticksize=9, cblabel='')
384 559 #Mean Line
385 560 mean = dataOut.data_param[i, 1, :]
386 561 axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1)
387 562
388 563 if self.__showprofile:
389 564 axes = self.axesList[i*self.__nsubplots +1]
390 565 axes.pline(avgdB[i], y,
391 566 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
392 567 xlabel='dB', ylabel='', title='',
393 568 ytick_visible=False,
394 569 grid='x')
395 570
396 571 noiseline = numpy.repeat(noisedB[i], len(y))
397 572 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
398 573
399 574 self.draw()
400 575
401 576 self.save(figpath=figpath,
402 577 figfile=figfile,
403 578 save=save,
404 579 ftp=ftp,
405 580 wr_period=wr_period,
406 581 thisDatetime=thisDatetime)
407 582
408 583
409 584
410 585 class SkyMapPlot(Figure):
411 586
412 587 __isConfig = None
413 588 __nsubplots = None
414 589
415 590 WIDTHPROF = None
416 591 HEIGHTPROF = None
417 592 PREFIX = 'mmap'
418 593
419 594 def __init__(self, **kwargs):
420 595 Figure.__init__(self, **kwargs)
421 596 self.isConfig = False
422 597 self.__nsubplots = 1
423 598
424 599 # self.WIDTH = 280
425 600 # self.HEIGHT = 250
426 601 self.WIDTH = 600
427 602 self.HEIGHT = 600
428 603 self.WIDTHPROF = 120
429 604 self.HEIGHTPROF = 0
430 605 self.counter_imagwr = 0
431 606
432 607 self.PLOT_CODE = MSKYMAP_CODE
433 608
434 609 self.FTP_WEI = None
435 610 self.EXP_CODE = None
436 611 self.SUB_EXP_CODE = None
437 612 self.PLOT_POS = None
438 613
439 614 def getSubplots(self):
440 615
441 616 ncol = int(numpy.sqrt(self.nplots)+0.9)
442 617 nrow = int(self.nplots*1./ncol + 0.9)
443 618
444 619 return nrow, ncol
445 620
446 621 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
447 622
448 623 self.__showprofile = showprofile
449 624 self.nplots = nplots
450 625
451 626 ncolspan = 1
452 627 colspan = 1
453 628
454 629 self.createFigure(id = id,
455 630 wintitle = wintitle,
456 631 widthplot = self.WIDTH, #+ self.WIDTHPROF,
457 632 heightplot = self.HEIGHT,# + self.HEIGHTPROF,
458 633 show=show)
459 634
460 635 nrow, ncol = 1,1
461 636 counter = 0
462 637 x = 0
463 638 y = 0
464 639 self.addAxes(1, 1, 0, 0, 1, 1, True)
465 640
466 641 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
467 642 tmin=0, tmax=24, timerange=None,
468 643 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
469 644 server=None, folder=None, username=None, password=None,
470 645 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
471 646
472 647 """
473 648
474 649 Input:
475 650 dataOut :
476 651 id :
477 652 wintitle :
478 653 channelList :
479 654 showProfile :
480 655 xmin : None,
481 656 xmax : None,
482 657 ymin : None,
483 658 ymax : None,
484 659 zmin : None,
485 660 zmax : None
486 661 """
487 662
488 663 arrayParameters = dataOut.data_param
489 664 error = arrayParameters[:,-1]
490 665 indValid = numpy.where(error == 0)[0]
491 666 finalMeteor = arrayParameters[indValid,:]
492 667 finalAzimuth = finalMeteor[:,3]
493 668 finalZenith = finalMeteor[:,4]
494 669
495 670 x = finalAzimuth*numpy.pi/180
496 671 y = finalZenith
497 672 x1 = [dataOut.ltctime, dataOut.ltctime]
498 673
499 674 #thisDatetime = dataOut.datatime
500 675 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
501 676 title = wintitle + " Parameters"
502 677 xlabel = "Zonal Zenith Angle (deg) "
503 678 ylabel = "Meridional Zenith Angle (deg)"
504 679 update_figfile = False
505 680
506 681 if not self.isConfig:
507 682
508 683 nplots = 1
509 684
510 685 self.setup(id=id,
511 686 nplots=nplots,
512 687 wintitle=wintitle,
513 688 showprofile=showprofile,
514 689 show=show)
515 690
516 691 if self.xmin is None and self.xmax is None:
517 692 self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange)
518 693
519 694 if timerange != None:
520 695 self.timerange = timerange
521 696 else:
522 697 self.timerange = self.xmax - self.xmin
523 698
524 699 self.FTP_WEI = ftp_wei
525 700 self.EXP_CODE = exp_code
526 701 self.SUB_EXP_CODE = sub_exp_code
527 702 self.PLOT_POS = plot_pos
528 703 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
529 704 self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
530 705 self.isConfig = True
531 706 update_figfile = True
532 707
533 708 self.setWinTitle(title)
534 709
535 710 i = 0
536 711 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
537 712
538 713 axes = self.axesList[i*self.__nsubplots]
539 714 nevents = axes.x_buffer.shape[0] + x.shape[0]
540 715 title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents)
541 716 axes.polar(x, y,
542 717 title=title, xlabel=xlabel, ylabel=ylabel,
543 718 ticksize=9, cblabel='')
544 719
545 720 self.draw()
546 721
547 722 self.save(figpath=figpath,
548 723 figfile=figfile,
549 724 save=save,
550 725 ftp=ftp,
551 726 wr_period=wr_period,
552 727 thisDatetime=thisDatetime,
553 728 update_figfile=update_figfile)
554 729
555 730 if dataOut.ltctime >= self.xmax:
556 731 self.isConfigmagwr = wr_period
557 732 self.isConfig = False
558 733 update_figfile = True
559 734 axes.__firsttime = True
560 735 self.xmin += self.timerange
561 736 self.xmax += self.timerange
562 737
563 738
564 739
565 740
566 741 class WindProfilerPlot(Figure):
567 742
568 743 __isConfig = None
569 744 __nsubplots = None
570 745
571 746 WIDTHPROF = None
572 747 HEIGHTPROF = None
573 748 PREFIX = 'wind'
574 749
575 750 def __init__(self, **kwargs):
576 751 Figure.__init__(self, **kwargs)
577 752 self.timerange = None
578 753 self.isConfig = False
579 754 self.__nsubplots = 1
580 755
581 756 self.WIDTH = 800
582 757 self.HEIGHT = 300
583 758 self.WIDTHPROF = 120
584 759 self.HEIGHTPROF = 0
585 760 self.counter_imagwr = 0
586 761
587 762 self.PLOT_CODE = WIND_CODE
588 763
589 764 self.FTP_WEI = None
590 765 self.EXP_CODE = None
591 766 self.SUB_EXP_CODE = None
592 767 self.PLOT_POS = None
593 768 self.tmin = None
594 769 self.tmax = None
595 770
596 771 self.xmin = None
597 772 self.xmax = None
598 773
599 774 self.figfile = None
600 775
601 776 def getSubplots(self):
602 777
603 778 ncol = 1
604 779 nrow = self.nplots
605 780
606 781 return nrow, ncol
607 782
608 783 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
609 784
610 785 self.__showprofile = showprofile
611 786 self.nplots = nplots
612 787
613 788 ncolspan = 1
614 789 colspan = 1
615 790
616 791 self.createFigure(id = id,
617 792 wintitle = wintitle,
618 793 widthplot = self.WIDTH + self.WIDTHPROF,
619 794 heightplot = self.HEIGHT + self.HEIGHTPROF,
620 795 show=show)
621 796
622 797 nrow, ncol = self.getSubplots()
623 798
624 799 counter = 0
625 800 for y in range(nrow):
626 801 if counter >= self.nplots:
627 802 break
628 803
629 804 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
630 805 counter += 1
631 806
632 807 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False',
633 808 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
634 809 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
635 810 timerange=None, SNRthresh = None,
636 811 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
637 812 server=None, folder=None, username=None, password=None,
638 813 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
639 814 """
640 815
641 816 Input:
642 817 dataOut :
643 818 id :
644 819 wintitle :
645 820 channelList :
646 821 showProfile :
647 822 xmin : None,
648 823 xmax : None,
649 824 ymin : None,
650 825 ymax : None,
651 826 zmin : None,
652 827 zmax : None
653 828 """
654 829
655 830 # if timerange is not None:
656 831 # self.timerange = timerange
657 832 #
658 833 # tmin = None
659 834 # tmax = None
660 835
661 836 x = dataOut.getTimeRange1(dataOut.paramInterval)
662 837 y = dataOut.heightList
663 838 z = dataOut.data_output.copy()
664 839 nplots = z.shape[0] #Number of wind dimensions estimated
665 840 nplotsw = nplots
666 841
667 842
668 843 #If there is a SNR function defined
669 844 if dataOut.data_SNR is not None:
670 845 nplots += 1
671 846 SNR = dataOut.data_SNR[0]
672 847 SNRavg = SNR#numpy.average(SNR, axis=0)
673 848
674 849 SNRdB = 10*numpy.log10(SNR)
675 850 SNRavgdB = 10*numpy.log10(SNRavg)
676 851
677 852 if SNRthresh == None:
678 853 SNRthresh = -5.0
679 854 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
680 855
681 856 for i in range(nplotsw):
682 857 z[i,ind] = numpy.nan
683 858
684 859 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
685 860 #thisDatetime = datetime.datetime.now()
686 861 title = wintitle + "Wind"
687 862 xlabel = ""
688 863 ylabel = "Height (km)"
689 864 update_figfile = False
690 865
691 866 if not self.isConfig:
692 867
693 868 self.setup(id=id,
694 869 nplots=nplots,
695 870 wintitle=wintitle,
696 871 showprofile=showprofile,
697 872 show=show)
698 873
699 874 if timerange is not None:
700 875 self.timerange = timerange
701 876
702 877 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
703 878
704 879 if ymin == None: ymin = numpy.nanmin(y)
705 880 if ymax == None: ymax = numpy.nanmax(y)
706 881
707 882 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
708 883 #if numpy.isnan(zmax): zmax = 50
709 884 if zmin == None: zmin = -zmax
710 885
711 886 if nplotsw == 3:
712 887 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
713 888 if zmin_ver == None: zmin_ver = -zmax_ver
714 889
715 890 if dataOut.data_SNR is not None:
716 891 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
717 892 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
718 893
719 894
720 895 self.FTP_WEI = ftp_wei
721 896 self.EXP_CODE = exp_code
722 897 self.SUB_EXP_CODE = sub_exp_code
723 898 self.PLOT_POS = plot_pos
724 899
725 900 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
726 901 self.isConfig = True
727 902 self.figfile = figfile
728 903 update_figfile = True
729 904
730 905 self.setWinTitle(title)
731 906
732 907 if ((self.xmax - x[1]) < (x[1]-x[0])):
733 908 x[1] = self.xmax
734 909
735 910 strWind = ['Zonal', 'Meridional', 'Vertical']
736 911 strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
737 912 zmaxVector = [zmax, zmax, zmax_ver]
738 913 zminVector = [zmin, zmin, zmin_ver]
739 914 windFactor = [1,1,100]
740 915
741 916 for i in range(nplotsw):
742 917
743 918 title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
744 919 axes = self.axesList[i*self.__nsubplots]
745 920
746 921 z1 = z[i,:].reshape((1,-1))*windFactor[i]
747 922
748 923 print 'x', x
749 924 print datetime.datetime.utcfromtimestamp(x[0])
750 925 print datetime.datetime.utcfromtimestamp(x[1])
751 926
752 927 #z1=numpy.ma.masked_where(z1==0.,z1)
753 928
754 929 axes.pcolorbuffer(x, y, z1,
755 930 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
756 931 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
757 932 ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="seismic" )
758 933
759 934 if dataOut.data_SNR is not None:
760 935 i += 1
761 936 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
762 937 axes = self.axesList[i*self.__nsubplots]
763 938 SNRavgdB = SNRavgdB.reshape((1,-1))
764 939 axes.pcolorbuffer(x, y, SNRavgdB,
765 940 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
766 941 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
767 942 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
768 943
769 944 self.draw()
770 945
771 946 self.save(figpath=figpath,
772 947 figfile=figfile,
773 948 save=save,
774 949 ftp=ftp,
775 950 wr_period=wr_period,
776 951 thisDatetime=thisDatetime,
777 952 update_figfile=update_figfile)
778 953
779 954 if dataOut.ltctime + dataOut.paramInterval >= self.xmax:
780 955 self.counter_imagwr = wr_period
781 956 self.isConfig = False
782 957 update_figfile = True
783 958
784 959
785 960 class ParametersPlot(Figure):
786 961
787 962 __isConfig = None
788 963 __nsubplots = None
789 964
790 965 WIDTHPROF = None
791 966 HEIGHTPROF = None
792 967 PREFIX = 'param'
793 968
794 969 nplots = None
795 970 nchan = None
796 971
797 972 def __init__(self, **kwargs):
798 973 Figure.__init__(self, **kwargs)
799 974 self.timerange = None
800 975 self.isConfig = False
801 976 self.__nsubplots = 1
802 977
803 self.WIDTH = 800
804 self.HEIGHT = 250
978 self.WIDTH = 300
979 self.HEIGHT = 550
805 980 self.WIDTHPROF = 120
806 981 self.HEIGHTPROF = 0
807 982 self.counter_imagwr = 0
808 983
809 984 self.PLOT_CODE = RTI_CODE
810 985
811 986 self.FTP_WEI = None
812 987 self.EXP_CODE = None
813 988 self.SUB_EXP_CODE = None
814 989 self.PLOT_POS = None
815 990 self.tmin = None
816 991 self.tmax = None
817 992
818 993 self.xmin = None
819 994 self.xmax = None
820 995
821 996 self.figfile = None
822 997
823 998 def getSubplots(self):
824 999
825 1000 ncol = 1
826 1001 nrow = self.nplots
827 1002
828 1003 return nrow, ncol
829 1004
830 1005 def setup(self, id, nplots, wintitle, show=True):
831 1006
832 1007 self.nplots = nplots
833 1008
834 1009 ncolspan = 1
835 1010 colspan = 1
836 1011
837 1012 self.createFigure(id = id,
838 1013 wintitle = wintitle,
839 1014 widthplot = self.WIDTH + self.WIDTHPROF,
840 1015 heightplot = self.HEIGHT + self.HEIGHTPROF,
841 1016 show=show)
842 1017
843 1018 nrow, ncol = self.getSubplots()
844 1019
845 1020 counter = 0
846 1021 for y in range(nrow):
847 1022 for x in range(ncol):
848 1023
849 1024 if counter >= self.nplots:
850 1025 break
851 1026
852 1027 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
853 1028
854 1029 counter += 1
855 1030
856 1031 def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap="jet",
857 1032 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None,
858 1033 showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None,
859 1034 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
860 1035 server=None, folder=None, username=None, password=None,
861 1036 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, HEIGHT=None):
862 1037 """
863 1038
864 1039 Input:
865 1040 dataOut :
866 1041 id :
867 1042 wintitle :
868 1043 channelList :
869 1044 showProfile :
870 1045 xmin : None,
871 1046 xmax : None,
872 1047 ymin : None,
873 1048 ymax : None,
874 1049 zmin : None,
875 1050 zmax : None
876 1051 """
877 1052
878 1053 if HEIGHT is not None:
879 1054 self.HEIGHT = HEIGHT
880 1055
881 1056
882 1057 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
883 1058 return
884 1059
885 1060 if channelList == None:
886 1061 channelIndexList = range(dataOut.data_param.shape[0])
887 1062 else:
888 1063 channelIndexList = []
889 1064 for channel in channelList:
890 1065 if channel not in dataOut.channelList:
891 1066 raise ValueError, "Channel %d is not in dataOut.channelList"
892 1067 channelIndexList.append(dataOut.channelList.index(channel))
893 1068
894 1069 x = dataOut.getTimeRange1(dataOut.paramInterval)
895 1070 y = dataOut.getHeiRange()
896 1071
897 1072 if dataOut.data_param.ndim == 3:
898 1073 z = dataOut.data_param[channelIndexList,paramIndex,:]
899 1074 else:
900 1075 z = dataOut.data_param[channelIndexList,:]
901 1076
902 1077 if showSNR:
903 1078 #SNR data
904 1079 SNRarray = dataOut.data_SNR[channelIndexList,:]
905 1080 SNRdB = 10*numpy.log10(SNRarray)
906 1081 ind = numpy.where(SNRdB < SNRthresh)
907 1082 z[ind] = numpy.nan
908 1083
909 1084 thisDatetime = dataOut.datatime
910 1085 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
911 1086 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
912 1087 xlabel = ""
913 ylabel = "Range (Km)"
1088 ylabel = "Range (km)"
914 1089
915 1090 update_figfile = False
916 1091
917 1092 if not self.isConfig:
918 1093
919 1094 nchan = len(channelIndexList)
920 1095 self.nchan = nchan
921 1096 self.plotFact = 1
922 1097 nplots = nchan
923 1098
924 1099 if showSNR:
925 1100 nplots = nchan*2
926 1101 self.plotFact = 2
927 1102 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
928 1103 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
929 1104
930 1105 self.setup(id=id,
931 1106 nplots=nplots,
932 1107 wintitle=wintitle,
933 1108 show=show)
934 1109
935 1110 if timerange != None:
936 1111 self.timerange = timerange
937 1112
938 1113 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
939 1114
940 1115 if ymin == None: ymin = numpy.nanmin(y)
941 1116 if ymax == None: ymax = numpy.nanmax(y)
942 1117 if zmin == None: zmin = numpy.nanmin(z)
943 1118 if zmax == None: zmax = numpy.nanmax(z)
944 1119
945 1120 self.FTP_WEI = ftp_wei
946 1121 self.EXP_CODE = exp_code
947 1122 self.SUB_EXP_CODE = sub_exp_code
948 1123 self.PLOT_POS = plot_pos
949 1124
950 1125 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
951 1126 self.isConfig = True
952 1127 self.figfile = figfile
953 1128 update_figfile = True
954 1129
955 1130 self.setWinTitle(title)
956 1131
957 for i in range(self.nchan):
958 index = channelIndexList[i]
959 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
960 axes = self.axesList[i*self.plotFact]
961 z1 = z[i,:].reshape((1,-1))
962 axes.pcolorbuffer(x, y, z1,
963 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
964 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
965 ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
966
967 if showSNR:
968 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
969 axes = self.axesList[i*self.plotFact + 1]
970 SNRdB1 = SNRdB[i,:].reshape((1,-1))
971 axes.pcolorbuffer(x, y, SNRdB1,
972 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
973 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
974 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
1132 # for i in range(self.nchan):
1133 # index = channelIndexList[i]
1134 # title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1135 # axes = self.axesList[i*self.plotFact]
1136 # z1 = z[i,:].reshape((1,-1))
1137 # axes.pcolorbuffer(x, y, z1,
1138 # xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1139 # xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1140 # ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
1141 #
1142 # if showSNR:
1143 # title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1144 # axes = self.axesList[i*self.plotFact + 1]
1145 # SNRdB1 = SNRdB[i,:].reshape((1,-1))
1146 # axes.pcolorbuffer(x, y, SNRdB1,
1147 # xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1148 # xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1149 # ticksize=9, cblabel='', cbsize="1%",colormap='jet')
1150
1151 i=0
1152 index = channelIndexList[i]
1153 title = "Factor de reflectividad Z [dBZ]"
1154 axes = self.axesList[i*self.plotFact]
1155 z1 = z[i,:].reshape((1,-1))
1156 axes.pcolorbuffer(x, y, z1,
1157 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1158 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1159 ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
1160
1161 if showSNR:
1162 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1163 axes = self.axesList[i*self.plotFact + 1]
1164 SNRdB1 = SNRdB[i,:].reshape((1,-1))
1165 axes.pcolorbuffer(x, y, SNRdB1,
1166 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1167 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1168 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
1169
1170 i=1
1171 index = channelIndexList[i]
1172 title = "Velocidad vertical Doppler [m/s]"
1173 axes = self.axesList[i*self.plotFact]
1174 z1 = z[i,:].reshape((1,-1))
1175 axes.pcolorbuffer(x, y, z1,
1176 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=-10, zmax=10,
1177 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1178 ticksize=9, cblabel='', cbsize="1%",colormap='seismic_r')
1179
1180 if showSNR:
1181 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1182 axes = self.axesList[i*self.plotFact + 1]
1183 SNRdB1 = SNRdB[i,:].reshape((1,-1))
1184 axes.pcolorbuffer(x, y, SNRdB1,
1185 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1186 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1187 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
1188
1189 i=2
1190 index = channelIndexList[i]
1191 title = "Intensidad de lluvia [mm/h]"
1192 axes = self.axesList[i*self.plotFact]
1193 z1 = z[i,:].reshape((1,-1))
1194 axes.pcolorbuffer(x, y, z1,
1195 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=40,
1196 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1197 ticksize=9, cblabel='', cbsize="1%",colormap='ocean_r')
1198
1199 if showSNR:
1200 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1201 axes = self.axesList[i*self.plotFact + 1]
1202 SNRdB1 = SNRdB[i,:].reshape((1,-1))
1203 axes.pcolorbuffer(x, y, SNRdB1,
1204 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1205 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1206 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
975 1207
976 1208
977 1209 self.draw()
978 1210
979 1211 if dataOut.ltctime >= self.xmax:
980 1212 self.counter_imagwr = wr_period
981 1213 self.isConfig = False
982 1214 update_figfile = True
983 1215
984 1216 self.save(figpath=figpath,
985 1217 figfile=figfile,
986 1218 save=save,
987 1219 ftp=ftp,
988 1220 wr_period=wr_period,
989 1221 thisDatetime=thisDatetime,
990 1222 update_figfile=update_figfile)
991 1223
992 1224
993 1225
994 1226 class Parameters1Plot(Figure):
995 1227
996 1228 __isConfig = None
997 1229 __nsubplots = None
998 1230
999 1231 WIDTHPROF = None
1000 1232 HEIGHTPROF = None
1001 1233 PREFIX = 'prm'
1002 1234
1003 1235 def __init__(self, **kwargs):
1004 1236 Figure.__init__(self, **kwargs)
1005 1237 self.timerange = 2*60*60
1006 1238 self.isConfig = False
1007 1239 self.__nsubplots = 1
1008 1240
1009 1241 self.WIDTH = 800
1010 1242 self.HEIGHT = 180
1011 1243 self.WIDTHPROF = 120
1012 1244 self.HEIGHTPROF = 0
1013 1245 self.counter_imagwr = 0
1014 1246
1015 1247 self.PLOT_CODE = PARMS_CODE
1016 1248
1017 1249 self.FTP_WEI = None
1018 1250 self.EXP_CODE = None
1019 1251 self.SUB_EXP_CODE = None
1020 1252 self.PLOT_POS = None
1021 1253 self.tmin = None
1022 1254 self.tmax = None
1023 1255
1024 1256 self.xmin = None
1025 1257 self.xmax = None
1026 1258
1027 1259 self.figfile = None
1028 1260
1029 1261 def getSubplots(self):
1030 1262
1031 1263 ncol = 1
1032 1264 nrow = self.nplots
1033 1265
1034 1266 return nrow, ncol
1035 1267
1036 1268 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1037 1269
1038 1270 self.__showprofile = showprofile
1039 1271 self.nplots = nplots
1040 1272
1041 1273 ncolspan = 1
1042 1274 colspan = 1
1043 1275
1044 1276 self.createFigure(id = id,
1045 1277 wintitle = wintitle,
1046 1278 widthplot = self.WIDTH + self.WIDTHPROF,
1047 1279 heightplot = self.HEIGHT + self.HEIGHTPROF,
1048 1280 show=show)
1049 1281
1050 1282 nrow, ncol = self.getSubplots()
1051 1283
1052 1284 counter = 0
1053 1285 for y in range(nrow):
1054 1286 for x in range(ncol):
1055 1287
1056 1288 if counter >= self.nplots:
1057 1289 break
1058 1290
1059 1291 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1060 1292
1061 1293 if showprofile:
1062 1294 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1063 1295
1064 1296 counter += 1
1065 1297
1066 1298 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
1067 1299 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
1068 1300 parameterIndex = None, onlyPositive = False,
1069 1301 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
1070 1302 DOP = True,
1071 1303 zlabel = "", parameterName = "", parameterObject = "data_param",
1072 1304 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1073 1305 server=None, folder=None, username=None, password=None,
1074 1306 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1075 1307 #print inspect.getargspec(self.run).args
1076 1308 """
1077 1309
1078 1310 Input:
1079 1311 dataOut :
1080 1312 id :
1081 1313 wintitle :
1082 1314 channelList :
1083 1315 showProfile :
1084 1316 xmin : None,
1085 1317 xmax : None,
1086 1318 ymin : None,
1087 1319 ymax : None,
1088 1320 zmin : None,
1089 1321 zmax : None
1090 1322 """
1091 1323
1092 1324 data_param = getattr(dataOut, parameterObject)
1093 1325
1094 1326 if channelList == None:
1095 1327 channelIndexList = numpy.arange(data_param.shape[0])
1096 1328 else:
1097 1329 channelIndexList = numpy.array(channelList)
1098 1330
1099 1331 nchan = len(channelIndexList) #Number of channels being plotted
1100 1332
1101 1333 if nchan < 1:
1102 1334 return
1103 1335
1104 1336 nGraphsByChannel = 0
1105 1337
1106 1338 if SNR:
1107 1339 nGraphsByChannel += 1
1108 1340 if DOP:
1109 1341 nGraphsByChannel += 1
1110 1342
1111 1343 if nGraphsByChannel < 1:
1112 1344 return
1113 1345
1114 1346 nplots = nGraphsByChannel*nchan
1115 1347
1116 1348 if timerange is not None:
1117 1349 self.timerange = timerange
1118 1350
1119 1351 #tmin = None
1120 1352 #tmax = None
1121 1353 if parameterIndex == None:
1122 1354 parameterIndex = 1
1123 1355
1124 1356 x = dataOut.getTimeRange1(dataOut.paramInterval)
1125 1357 y = dataOut.heightList
1126 1358 z = data_param[channelIndexList,parameterIndex,:].copy()
1127 1359
1128 1360 zRange = dataOut.abscissaList
1129 1361 # nChannels = z.shape[0] #Number of wind dimensions estimated
1130 1362 # thisDatetime = dataOut.datatime
1131 1363
1132 1364 if dataOut.data_SNR is not None:
1133 1365 SNRarray = dataOut.data_SNR[channelIndexList,:]
1134 1366 SNRdB = 10*numpy.log10(SNRarray)
1135 1367 # SNRavgdB = 10*numpy.log10(SNRavg)
1136 1368 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
1137 1369 z[ind] = numpy.nan
1138 1370
1139 1371 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1140 1372 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
1141 1373 xlabel = ""
1142 1374 ylabel = "Range (Km)"
1143 1375
1144 1376 if (SNR and not onlySNR): nplots = 2*nplots
1145 1377
1146 1378 if onlyPositive:
1147 1379 colormap = "jet"
1148 1380 zmin = 0
1149 1381 else: colormap = "RdBu_r"
1150 1382
1151 1383 if not self.isConfig:
1152 1384
1153 1385 self.setup(id=id,
1154 1386 nplots=nplots,
1155 1387 wintitle=wintitle,
1156 1388 showprofile=showprofile,
1157 1389 show=show)
1158 1390
1159 1391 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1160 1392
1161 1393 if ymin == None: ymin = numpy.nanmin(y)
1162 1394 if ymax == None: ymax = numpy.nanmax(y)
1163 1395 if zmin == None: zmin = numpy.nanmin(zRange)
1164 1396 if zmax == None: zmax = numpy.nanmax(zRange)
1165 1397
1166 1398 if SNR:
1167 1399 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
1168 1400 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
1169 1401
1170 1402 self.FTP_WEI = ftp_wei
1171 1403 self.EXP_CODE = exp_code
1172 1404 self.SUB_EXP_CODE = sub_exp_code
1173 1405 self.PLOT_POS = plot_pos
1174 1406
1175 1407 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1176 1408 self.isConfig = True
1177 1409 self.figfile = figfile
1178 1410
1179 1411 self.setWinTitle(title)
1180 1412
1181 1413 if ((self.xmax - x[1]) < (x[1]-x[0])):
1182 1414 x[1] = self.xmax
1183 1415
1184 1416 for i in range(nchan):
1185 1417
1186 1418 if (SNR and not onlySNR): j = 2*i
1187 1419 else: j = i
1188 1420
1189 1421 j = nGraphsByChannel*i
1190 1422
1191 1423 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1192 1424 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
1193 1425
1194 1426 if not onlySNR:
1195 1427 axes = self.axesList[j*self.__nsubplots]
1196 1428 z1 = z[i,:].reshape((1,-1))
1197 1429 axes.pcolorbuffer(x, y, z1,
1198 1430 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1199 1431 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
1200 1432 ticksize=9, cblabel=zlabel, cbsize="1%")
1201 1433
1202 1434 if DOP:
1203 1435 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1204 1436
1205 1437 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1206 1438 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
1207 1439 axes = self.axesList[j]
1208 1440 z1 = z[i,:].reshape((1,-1))
1209 1441 axes.pcolorbuffer(x, y, z1,
1210 1442 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1211 1443 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
1212 1444 ticksize=9, cblabel=zlabel, cbsize="1%")
1213 1445
1214 1446 if SNR:
1215 1447 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1216 1448 axes = self.axesList[(j)*self.__nsubplots]
1217 1449 if not onlySNR:
1218 1450 axes = self.axesList[(j + 1)*self.__nsubplots]
1219 1451
1220 1452 axes = self.axesList[(j + nGraphsByChannel-1)]
1221 1453
1222 1454 z1 = SNRdB[i,:].reshape((1,-1))
1223 1455 axes.pcolorbuffer(x, y, z1,
1224 1456 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1225 1457 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
1226 1458 ticksize=9, cblabel=zlabel, cbsize="1%")
1227 1459
1228 1460
1229 1461
1230 1462 self.draw()
1231 1463
1232 1464 if x[1] >= self.axesList[0].xmax:
1233 1465 self.counter_imagwr = wr_period
1234 1466 self.isConfig = False
1235 1467 self.figfile = None
1236 1468
1237 1469 self.save(figpath=figpath,
1238 1470 figfile=figfile,
1239 1471 save=save,
1240 1472 ftp=ftp,
1241 1473 wr_period=wr_period,
1242 1474 thisDatetime=thisDatetime,
1243 1475 update_figfile=False)
1244 1476
1245 1477 class SpectralFittingPlot(Figure):
1246 1478
1247 1479 __isConfig = None
1248 1480 __nsubplots = None
1249 1481
1250 1482 WIDTHPROF = None
1251 1483 HEIGHTPROF = None
1252 1484 PREFIX = 'prm'
1253 1485
1254 1486
1255 1487 N = None
1256 1488 ippSeconds = None
1257 1489
1258 1490 def __init__(self, **kwargs):
1259 1491 Figure.__init__(self, **kwargs)
1260 1492 self.isConfig = False
1261 1493 self.__nsubplots = 1
1262 1494
1263 1495 self.PLOT_CODE = SPECFIT_CODE
1264 1496
1265 1497 self.WIDTH = 450
1266 1498 self.HEIGHT = 250
1267 1499 self.WIDTHPROF = 0
1268 1500 self.HEIGHTPROF = 0
1269 1501
1270 1502 def getSubplots(self):
1271 1503
1272 1504 ncol = int(numpy.sqrt(self.nplots)+0.9)
1273 1505 nrow = int(self.nplots*1./ncol + 0.9)
1274 1506
1275 1507 return nrow, ncol
1276 1508
1277 1509 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
1278 1510
1279 1511 showprofile = False
1280 1512 self.__showprofile = showprofile
1281 1513 self.nplots = nplots
1282 1514
1283 1515 ncolspan = 5
1284 1516 colspan = 4
1285 1517 if showprofile:
1286 1518 ncolspan = 5
1287 1519 colspan = 4
1288 1520 self.__nsubplots = 2
1289 1521
1290 1522 self.createFigure(id = id,
1291 1523 wintitle = wintitle,
1292 1524 widthplot = self.WIDTH + self.WIDTHPROF,
1293 1525 heightplot = self.HEIGHT + self.HEIGHTPROF,
1294 1526 show=show)
1295 1527
1296 1528 nrow, ncol = self.getSubplots()
1297 1529
1298 1530 counter = 0
1299 1531 for y in range(nrow):
1300 1532 for x in range(ncol):
1301 1533
1302 1534 if counter >= self.nplots:
1303 1535 break
1304 1536
1305 1537 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1306 1538
1307 1539 if showprofile:
1308 1540 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1309 1541
1310 1542 counter += 1
1311 1543
1312 1544 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
1313 1545 xmin=None, xmax=None, ymin=None, ymax=None,
1314 1546 save=False, figpath='./', figfile=None, show=True):
1315 1547
1316 1548 """
1317 1549
1318 1550 Input:
1319 1551 dataOut :
1320 1552 id :
1321 1553 wintitle :
1322 1554 channelList :
1323 1555 showProfile :
1324 1556 xmin : None,
1325 1557 xmax : None,
1326 1558 zmin : None,
1327 1559 zmax : None
1328 1560 """
1329 1561
1330 1562 if cutHeight==None:
1331 1563 h=270
1332 1564 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
1333 1565 cutHeight = dataOut.heightList[heightindex]
1334 1566
1335 1567 factor = dataOut.normFactor
1336 1568 x = dataOut.abscissaList[:-1]
1337 1569 #y = dataOut.getHeiRange()
1338 1570
1339 1571 z = dataOut.data_pre[:,:,heightindex]/factor
1340 1572 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1341 1573 avg = numpy.average(z, axis=1)
1342 1574 listChannels = z.shape[0]
1343 1575
1344 1576 #Reconstruct Function
1345 1577 if fit==True:
1346 1578 groupArray = dataOut.groupList
1347 1579 listChannels = groupArray.reshape((groupArray.size))
1348 1580 listChannels.sort()
1349 1581 spcFitLine = numpy.zeros(z.shape)
1350 1582 constants = dataOut.constants
1351 1583
1352 1584 nGroups = groupArray.shape[0]
1353 1585 nChannels = groupArray.shape[1]
1354 1586 nProfiles = z.shape[1]
1355 1587
1356 1588 for f in range(nGroups):
1357 1589 groupChann = groupArray[f,:]
1358 1590 p = dataOut.data_param[f,:,heightindex]
1359 1591 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
1360 1592 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
1361 1593 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
1362 1594 spcFitLine[groupChann,:] = fitLineAux
1363 1595 # spcFitLine = spcFitLine/factor
1364 1596
1365 1597 z = z[listChannels,:]
1366 1598 spcFitLine = spcFitLine[listChannels,:]
1367 1599 spcFitLinedB = 10*numpy.log10(spcFitLine)
1368 1600
1369 1601 zdB = 10*numpy.log10(z)
1370 1602 #thisDatetime = dataOut.datatime
1371 1603 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1372 1604 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1373 1605 xlabel = "Velocity (m/s)"
1374 1606 ylabel = "Spectrum"
1375 1607
1376 1608 if not self.isConfig:
1377 1609
1378 1610 nplots = listChannels.size
1379 1611
1380 1612 self.setup(id=id,
1381 1613 nplots=nplots,
1382 1614 wintitle=wintitle,
1383 1615 showprofile=showprofile,
1384 1616 show=show)
1385 1617
1386 1618 if xmin == None: xmin = numpy.nanmin(x)
1387 1619 if xmax == None: xmax = numpy.nanmax(x)
1388 1620 if ymin == None: ymin = numpy.nanmin(zdB)
1389 1621 if ymax == None: ymax = numpy.nanmax(zdB)+2
1390 1622
1391 1623 self.isConfig = True
1392 1624
1393 1625 self.setWinTitle(title)
1394 1626 for i in range(self.nplots):
1395 1627 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
1396 1628 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
1397 1629 axes = self.axesList[i*self.__nsubplots]
1398 1630 if fit == False:
1399 1631 axes.pline(x, zdB[i,:],
1400 1632 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1401 1633 xlabel=xlabel, ylabel=ylabel, title=title
1402 1634 )
1403 1635 if fit == True:
1404 1636 fitline=spcFitLinedB[i,:]
1405 1637 y=numpy.vstack([zdB[i,:],fitline] )
1406 1638 legendlabels=['Data','Fitting']
1407 1639 axes.pmultilineyaxis(x, y,
1408 1640 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1409 1641 xlabel=xlabel, ylabel=ylabel, title=title,
1410 1642 legendlabels=legendlabels, marker=None,
1411 1643 linestyle='solid', grid='both')
1412 1644
1413 1645 self.draw()
1414 1646
1415 1647 self.save(figpath=figpath,
1416 1648 figfile=figfile,
1417 1649 save=save,
1418 1650 ftp=ftp,
1419 1651 wr_period=wr_period,
1420 1652 thisDatetime=thisDatetime)
1421 1653
1422 1654
1423 1655 class EWDriftsPlot(Figure):
1424 1656
1425 1657 __isConfig = None
1426 1658 __nsubplots = None
1427 1659
1428 1660 WIDTHPROF = None
1429 1661 HEIGHTPROF = None
1430 1662 PREFIX = 'drift'
1431 1663
1432 1664 def __init__(self, **kwargs):
1433 1665 Figure.__init__(self, **kwargs)
1434 1666 self.timerange = 2*60*60
1435 1667 self.isConfig = False
1436 1668 self.__nsubplots = 1
1437 1669
1438 1670 self.WIDTH = 800
1439 1671 self.HEIGHT = 150
1440 1672 self.WIDTHPROF = 120
1441 1673 self.HEIGHTPROF = 0
1442 1674 self.counter_imagwr = 0
1443 1675
1444 1676 self.PLOT_CODE = EWDRIFT_CODE
1445 1677
1446 1678 self.FTP_WEI = None
1447 1679 self.EXP_CODE = None
1448 1680 self.SUB_EXP_CODE = None
1449 1681 self.PLOT_POS = None
1450 1682 self.tmin = None
1451 1683 self.tmax = None
1452 1684
1453 1685 self.xmin = None
1454 1686 self.xmax = None
1455 1687
1456 1688 self.figfile = None
1457 1689
1458 1690 def getSubplots(self):
1459 1691
1460 1692 ncol = 1
1461 1693 nrow = self.nplots
1462 1694
1463 1695 return nrow, ncol
1464 1696
1465 1697 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1466 1698
1467 1699 self.__showprofile = showprofile
1468 1700 self.nplots = nplots
1469 1701
1470 1702 ncolspan = 1
1471 1703 colspan = 1
1472 1704
1473 1705 self.createFigure(id = id,
1474 1706 wintitle = wintitle,
1475 1707 widthplot = self.WIDTH + self.WIDTHPROF,
1476 1708 heightplot = self.HEIGHT + self.HEIGHTPROF,
1477 1709 show=show)
1478 1710
1479 1711 nrow, ncol = self.getSubplots()
1480 1712
1481 1713 counter = 0
1482 1714 for y in range(nrow):
1483 1715 if counter >= self.nplots:
1484 1716 break
1485 1717
1486 1718 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1487 1719 counter += 1
1488 1720
1489 1721 def run(self, dataOut, id, wintitle="", channelList=None,
1490 1722 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1491 1723 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1492 1724 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1493 1725 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1494 1726 server=None, folder=None, username=None, password=None,
1495 1727 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1496 1728 """
1497 1729
1498 1730 Input:
1499 1731 dataOut :
1500 1732 id :
1501 1733 wintitle :
1502 1734 channelList :
1503 1735 showProfile :
1504 1736 xmin : None,
1505 1737 xmax : None,
1506 1738 ymin : None,
1507 1739 ymax : None,
1508 1740 zmin : None,
1509 1741 zmax : None
1510 1742 """
1511 1743
1512 1744 if timerange is not None:
1513 1745 self.timerange = timerange
1514 1746
1515 1747 tmin = None
1516 1748 tmax = None
1517 1749
1518 1750 x = dataOut.getTimeRange1(dataOut.outputInterval)
1519 1751 # y = dataOut.heightList
1520 1752 y = dataOut.heightList
1521 1753
1522 1754 z = dataOut.data_output
1523 1755 nplots = z.shape[0] #Number of wind dimensions estimated
1524 1756 nplotsw = nplots
1525 1757
1526 1758 #If there is a SNR function defined
1527 1759 if dataOut.data_SNR is not None:
1528 1760 nplots += 1
1529 1761 SNR = dataOut.data_SNR
1530 1762
1531 1763 if SNR_1:
1532 1764 SNR += 1
1533 1765
1534 1766 SNRavg = numpy.average(SNR, axis=0)
1535 1767
1536 1768 SNRdB = 10*numpy.log10(SNR)
1537 1769 SNRavgdB = 10*numpy.log10(SNRavg)
1538 1770
1539 1771 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1540 1772
1541 1773 for i in range(nplotsw):
1542 1774 z[i,ind] = numpy.nan
1543 1775
1544 1776
1545 1777 showprofile = False
1546 1778 # thisDatetime = dataOut.datatime
1547 1779 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1548 1780 title = wintitle + " EW Drifts"
1549 1781 xlabel = ""
1550 1782 ylabel = "Height (Km)"
1551 1783
1552 1784 if not self.isConfig:
1553 1785
1554 1786 self.setup(id=id,
1555 1787 nplots=nplots,
1556 1788 wintitle=wintitle,
1557 1789 showprofile=showprofile,
1558 1790 show=show)
1559 1791
1560 1792 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1561 1793
1562 1794 if ymin == None: ymin = numpy.nanmin(y)
1563 1795 if ymax == None: ymax = numpy.nanmax(y)
1564 1796
1565 1797 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1566 1798 if zminZonal == None: zminZonal = -zmaxZonal
1567 1799 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1568 1800 if zminVertical == None: zminVertical = -zmaxVertical
1569 1801
1570 1802 if dataOut.data_SNR is not None:
1571 1803 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1572 1804 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1573 1805
1574 1806 self.FTP_WEI = ftp_wei
1575 1807 self.EXP_CODE = exp_code
1576 1808 self.SUB_EXP_CODE = sub_exp_code
1577 1809 self.PLOT_POS = plot_pos
1578 1810
1579 1811 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1580 1812 self.isConfig = True
1581 1813
1582 1814
1583 1815 self.setWinTitle(title)
1584 1816
1585 1817 if ((self.xmax - x[1]) < (x[1]-x[0])):
1586 1818 x[1] = self.xmax
1587 1819
1588 1820 strWind = ['Zonal','Vertical']
1589 1821 strCb = 'Velocity (m/s)'
1590 1822 zmaxVector = [zmaxZonal, zmaxVertical]
1591 1823 zminVector = [zminZonal, zminVertical]
1592 1824
1593 1825 for i in range(nplotsw):
1594 1826
1595 1827 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1596 1828 axes = self.axesList[i*self.__nsubplots]
1597 1829
1598 1830 z1 = z[i,:].reshape((1,-1))
1599 1831
1600 1832 axes.pcolorbuffer(x, y, z1,
1601 1833 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1602 1834 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1603 1835 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1604 1836
1605 1837 if dataOut.data_SNR is not None:
1606 1838 i += 1
1607 1839 if SNR_1:
1608 1840 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1609 1841 else:
1610 1842 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1611 1843 axes = self.axesList[i*self.__nsubplots]
1612 1844 SNRavgdB = SNRavgdB.reshape((1,-1))
1613 1845
1614 1846 axes.pcolorbuffer(x, y, SNRavgdB,
1615 1847 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1616 1848 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1617 1849 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1618 1850
1619 1851 self.draw()
1620 1852
1621 1853 if x[1] >= self.axesList[0].xmax:
1622 1854 self.counter_imagwr = wr_period
1623 1855 self.isConfig = False
1624 1856 self.figfile = None
1625 1857
1626 1858
1627 1859
1628 1860
1629 1861 class PhasePlot(Figure):
1630 1862
1631 1863 __isConfig = None
1632 1864 __nsubplots = None
1633 1865
1634 1866 PREFIX = 'mphase'
1635 1867
1636 1868 def __init__(self, **kwargs):
1637 1869 Figure.__init__(self, **kwargs)
1638 1870 self.timerange = 24*60*60
1639 1871 self.isConfig = False
1640 1872 self.__nsubplots = 1
1641 1873 self.counter_imagwr = 0
1642 1874 self.WIDTH = 600
1643 1875 self.HEIGHT = 300
1644 1876 self.WIDTHPROF = 120
1645 1877 self.HEIGHTPROF = 0
1646 1878 self.xdata = None
1647 1879 self.ydata = None
1648 1880
1649 1881 self.PLOT_CODE = MPHASE_CODE
1650 1882
1651 1883 self.FTP_WEI = None
1652 1884 self.EXP_CODE = None
1653 1885 self.SUB_EXP_CODE = None
1654 1886 self.PLOT_POS = None
1655 1887
1656 1888
1657 1889 self.filename_phase = None
1658 1890
1659 1891 self.figfile = None
1660 1892
1661 1893 def getSubplots(self):
1662 1894
1663 1895 ncol = 1
1664 1896 nrow = 1
1665 1897
1666 1898 return nrow, ncol
1667 1899
1668 1900 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1669 1901
1670 1902 self.__showprofile = showprofile
1671 1903 self.nplots = nplots
1672 1904
1673 1905 ncolspan = 7
1674 1906 colspan = 6
1675 1907 self.__nsubplots = 2
1676 1908
1677 1909 self.createFigure(id = id,
1678 1910 wintitle = wintitle,
1679 1911 widthplot = self.WIDTH+self.WIDTHPROF,
1680 1912 heightplot = self.HEIGHT+self.HEIGHTPROF,
1681 1913 show=show)
1682 1914
1683 1915 nrow, ncol = self.getSubplots()
1684 1916
1685 1917 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1686 1918
1687 1919
1688 1920 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1689 1921 xmin=None, xmax=None, ymin=None, ymax=None,
1690 1922 timerange=None,
1691 1923 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1692 1924 server=None, folder=None, username=None, password=None,
1693 1925 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1694 1926
1695 1927
1696 1928 tmin = None
1697 1929 tmax = None
1698 1930 x = dataOut.getTimeRange1(dataOut.outputInterval)
1699 1931 y = dataOut.getHeiRange()
1700 1932
1701 1933
1702 1934 #thisDatetime = dataOut.datatime
1703 1935 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1704 1936 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1705 1937 xlabel = "Local Time"
1706 1938 ylabel = "Phase"
1707 1939
1708 1940
1709 1941 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1710 1942 phase_beacon = dataOut.data_output
1711 1943 update_figfile = False
1712 1944
1713 1945 if not self.isConfig:
1714 1946
1715 1947 self.nplots = phase_beacon.size
1716 1948
1717 1949 self.setup(id=id,
1718 1950 nplots=self.nplots,
1719 1951 wintitle=wintitle,
1720 1952 showprofile=showprofile,
1721 1953 show=show)
1722 1954
1723 1955 if timerange is not None:
1724 1956 self.timerange = timerange
1725 1957
1726 1958 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1727 1959
1728 1960 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1729 1961 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1730 1962
1731 1963 self.FTP_WEI = ftp_wei
1732 1964 self.EXP_CODE = exp_code
1733 1965 self.SUB_EXP_CODE = sub_exp_code
1734 1966 self.PLOT_POS = plot_pos
1735 1967
1736 1968 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1737 1969 self.isConfig = True
1738 1970 self.figfile = figfile
1739 1971 self.xdata = numpy.array([])
1740 1972 self.ydata = numpy.array([])
1741 1973
1742 1974 #open file beacon phase
1743 1975 path = '%s%03d' %(self.PREFIX, self.id)
1744 1976 beacon_file = os.path.join(path,'%s.txt'%self.name)
1745 1977 self.filename_phase = os.path.join(figpath,beacon_file)
1746 1978 update_figfile = True
1747 1979
1748 1980
1749 1981 #store data beacon phase
1750 1982 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1751 1983
1752 1984 self.setWinTitle(title)
1753 1985
1754 1986
1755 1987 title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1756 1988
1757 1989 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1758 1990
1759 1991 axes = self.axesList[0]
1760 1992
1761 1993 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1762 1994
1763 1995 if len(self.ydata)==0:
1764 1996 self.ydata = phase_beacon.reshape(-1,1)
1765 1997 else:
1766 1998 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1767 1999
1768 2000
1769 2001 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1770 2002 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1771 2003 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1772 2004 XAxisAsTime=True, grid='both'
1773 2005 )
1774 2006
1775 2007 self.draw()
1776 2008
1777 2009 self.save(figpath=figpath,
1778 2010 figfile=figfile,
1779 2011 save=save,
1780 2012 ftp=ftp,
1781 2013 wr_period=wr_period,
1782 2014 thisDatetime=thisDatetime,
1783 2015 update_figfile=update_figfile)
1784 2016
1785 2017 if dataOut.ltctime + dataOut.outputInterval >= self.xmax:
1786 2018 self.counter_imagwr = wr_period
1787 2019 self.isConfig = False
1788 2020 update_figfile = True
1789 2021
1790 2022
1791 2023
1792 2024 class NSMeteorDetection1Plot(Figure):
1793 2025
1794 2026 isConfig = None
1795 2027 __nsubplots = None
1796 2028
1797 2029 WIDTHPROF = None
1798 2030 HEIGHTPROF = None
1799 2031 PREFIX = 'nsm'
1800 2032
1801 2033 zminList = None
1802 2034 zmaxList = None
1803 2035 cmapList = None
1804 2036 titleList = None
1805 2037 nPairs = None
1806 2038 nChannels = None
1807 2039 nParam = None
1808 2040
1809 2041 def __init__(self, **kwargs):
1810 2042 Figure.__init__(self, **kwargs)
1811 2043 self.isConfig = False
1812 2044 self.__nsubplots = 1
1813 2045
1814 2046 self.WIDTH = 750
1815 2047 self.HEIGHT = 250
1816 2048 self.WIDTHPROF = 120
1817 2049 self.HEIGHTPROF = 0
1818 2050 self.counter_imagwr = 0
1819 2051
1820 2052 self.PLOT_CODE = SPEC_CODE
1821 2053
1822 2054 self.FTP_WEI = None
1823 2055 self.EXP_CODE = None
1824 2056 self.SUB_EXP_CODE = None
1825 2057 self.PLOT_POS = None
1826 2058
1827 2059 self.__xfilter_ena = False
1828 2060 self.__yfilter_ena = False
1829 2061
1830 2062 def getSubplots(self):
1831 2063
1832 2064 ncol = 3
1833 2065 nrow = int(numpy.ceil(self.nplots/3.0))
1834 2066
1835 2067 return nrow, ncol
1836 2068
1837 2069 def setup(self, id, nplots, wintitle, show=True):
1838 2070
1839 2071 self.nplots = nplots
1840 2072
1841 2073 ncolspan = 1
1842 2074 colspan = 1
1843 2075
1844 2076 self.createFigure(id = id,
1845 2077 wintitle = wintitle,
1846 2078 widthplot = self.WIDTH + self.WIDTHPROF,
1847 2079 heightplot = self.HEIGHT + self.HEIGHTPROF,
1848 2080 show=show)
1849 2081
1850 2082 nrow, ncol = self.getSubplots()
1851 2083
1852 2084 counter = 0
1853 2085 for y in range(nrow):
1854 2086 for x in range(ncol):
1855 2087
1856 2088 if counter >= self.nplots:
1857 2089 break
1858 2090
1859 2091 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1860 2092
1861 2093 counter += 1
1862 2094
1863 2095 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1864 2096 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1865 2097 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1866 2098 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1867 2099 server=None, folder=None, username=None, password=None,
1868 2100 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1869 2101 xaxis="frequency"):
1870 2102
1871 2103 """
1872 2104
1873 2105 Input:
1874 2106 dataOut :
1875 2107 id :
1876 2108 wintitle :
1877 2109 channelList :
1878 2110 showProfile :
1879 2111 xmin : None,
1880 2112 xmax : None,
1881 2113 ymin : None,
1882 2114 ymax : None,
1883 2115 zmin : None,
1884 2116 zmax : None
1885 2117 """
1886 2118 #SEPARAR EN DOS PLOTS
1887 2119 nParam = dataOut.data_param.shape[1] - 3
1888 2120
1889 2121 utctime = dataOut.data_param[0,0]
1890 2122 tmet = dataOut.data_param[:,1].astype(int)
1891 2123 hmet = dataOut.data_param[:,2].astype(int)
1892 2124
1893 2125 x = dataOut.abscissaList
1894 2126 y = dataOut.heightList
1895 2127
1896 2128 z = numpy.zeros((nParam, y.size, x.size - 1))
1897 2129 z[:,:] = numpy.nan
1898 2130 z[:,hmet,tmet] = dataOut.data_param[:,3:].T
1899 2131 z[0,:,:] = 10*numpy.log10(z[0,:,:])
1900 2132
1901 2133 xlabel = "Time (s)"
1902 2134 ylabel = "Range (km)"
1903 2135
1904 2136 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1905 2137
1906 2138 if not self.isConfig:
1907 2139
1908 2140 nplots = nParam
1909 2141
1910 2142 self.setup(id=id,
1911 2143 nplots=nplots,
1912 2144 wintitle=wintitle,
1913 2145 show=show)
1914 2146
1915 2147 if xmin is None: xmin = numpy.nanmin(x)
1916 2148 if xmax is None: xmax = numpy.nanmax(x)
1917 2149 if ymin is None: ymin = numpy.nanmin(y)
1918 2150 if ymax is None: ymax = numpy.nanmax(y)
1919 2151 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1920 2152 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1921 2153 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1922 2154 if vmin is None: vmin = -vmax
1923 2155 if wmin is None: wmin = 0
1924 2156 if wmax is None: wmax = 50
1925 2157
1926 2158 pairsList = dataOut.groupList
1927 2159 self.nPairs = len(dataOut.groupList)
1928 2160
1929 2161 zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs
1930 2162 zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs
1931 2163 titleList = ["SNR","Radial Velocity","Coherence"]
1932 2164 cmapList = ["jet","RdBu_r","jet"]
1933 2165
1934 2166 for i in range(self.nPairs):
1935 2167 strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1])
1936 2168 titleList = titleList + [strAux1]
1937 2169 cmapList = cmapList + ["RdBu_r"]
1938 2170
1939 2171 self.zminList = zminList
1940 2172 self.zmaxList = zmaxList
1941 2173 self.cmapList = cmapList
1942 2174 self.titleList = titleList
1943 2175
1944 2176 self.FTP_WEI = ftp_wei
1945 2177 self.EXP_CODE = exp_code
1946 2178 self.SUB_EXP_CODE = sub_exp_code
1947 2179 self.PLOT_POS = plot_pos
1948 2180
1949 2181 self.isConfig = True
1950 2182
1951 2183 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1952 2184
1953 2185 for i in range(nParam):
1954 2186 title = self.titleList[i] + ": " +str_datetime
1955 2187 axes = self.axesList[i]
1956 2188 axes.pcolor(x, y, z[i,:].T,
1957 2189 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
1958 2190 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
1959 2191 self.draw()
1960 2192
1961 2193 if figfile == None:
1962 2194 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1963 2195 name = str_datetime
1964 2196 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1965 2197 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1966 2198 figfile = self.getFilename(name)
1967 2199
1968 2200 self.save(figpath=figpath,
1969 2201 figfile=figfile,
1970 2202 save=save,
1971 2203 ftp=ftp,
1972 2204 wr_period=wr_period,
1973 2205 thisDatetime=thisDatetime)
1974 2206
1975 2207
1976 2208 class NSMeteorDetection2Plot(Figure):
1977 2209
1978 2210 isConfig = None
1979 2211 __nsubplots = None
1980 2212
1981 2213 WIDTHPROF = None
1982 2214 HEIGHTPROF = None
1983 2215 PREFIX = 'nsm'
1984 2216
1985 2217 zminList = None
1986 2218 zmaxList = None
1987 2219 cmapList = None
1988 2220 titleList = None
1989 2221 nPairs = None
1990 2222 nChannels = None
1991 2223 nParam = None
1992 2224
1993 2225 def __init__(self, **kwargs):
1994 2226 Figure.__init__(self, **kwargs)
1995 2227 self.isConfig = False
1996 2228 self.__nsubplots = 1
1997 2229
1998 2230 self.WIDTH = 750
1999 2231 self.HEIGHT = 250
2000 2232 self.WIDTHPROF = 120
2001 2233 self.HEIGHTPROF = 0
2002 2234 self.counter_imagwr = 0
2003 2235
2004 2236 self.PLOT_CODE = SPEC_CODE
2005 2237
2006 2238 self.FTP_WEI = None
2007 2239 self.EXP_CODE = None
2008 2240 self.SUB_EXP_CODE = None
2009 2241 self.PLOT_POS = None
2010 2242
2011 2243 self.__xfilter_ena = False
2012 2244 self.__yfilter_ena = False
2013 2245
2014 2246 def getSubplots(self):
2015 2247
2016 2248 ncol = 3
2017 2249 nrow = int(numpy.ceil(self.nplots/3.0))
2018 2250
2019 2251 return nrow, ncol
2020 2252
2021 2253 def setup(self, id, nplots, wintitle, show=True):
2022 2254
2023 2255 self.nplots = nplots
2024 2256
2025 2257 ncolspan = 1
2026 2258 colspan = 1
2027 2259
2028 2260 self.createFigure(id = id,
2029 2261 wintitle = wintitle,
2030 2262 widthplot = self.WIDTH + self.WIDTHPROF,
2031 2263 heightplot = self.HEIGHT + self.HEIGHTPROF,
2032 2264 show=show)
2033 2265
2034 2266 nrow, ncol = self.getSubplots()
2035 2267
2036 2268 counter = 0
2037 2269 for y in range(nrow):
2038 2270 for x in range(ncol):
2039 2271
2040 2272 if counter >= self.nplots:
2041 2273 break
2042 2274
2043 2275 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
2044 2276
2045 2277 counter += 1
2046 2278
2047 2279 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
2048 2280 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
2049 2281 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
2050 2282 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
2051 2283 server=None, folder=None, username=None, password=None,
2052 2284 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
2053 2285 xaxis="frequency"):
2054 2286
2055 2287 """
2056 2288
2057 2289 Input:
2058 2290 dataOut :
2059 2291 id :
2060 2292 wintitle :
2061 2293 channelList :
2062 2294 showProfile :
2063 2295 xmin : None,
2064 2296 xmax : None,
2065 2297 ymin : None,
2066 2298 ymax : None,
2067 2299 zmin : None,
2068 2300 zmax : None
2069 2301 """
2070 2302 #Rebuild matrix
2071 2303 utctime = dataOut.data_param[0,0]
2072 2304 cmet = dataOut.data_param[:,1].astype(int)
2073 2305 tmet = dataOut.data_param[:,2].astype(int)
2074 2306 hmet = dataOut.data_param[:,3].astype(int)
2075 2307
2076 2308 nParam = 3
2077 2309 nChan = len(dataOut.groupList)
2078 2310 x = dataOut.abscissaList
2079 2311 y = dataOut.heightList
2080 2312
2081 2313 z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan)
2082 2314 z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:]
2083 2315 z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale
2084 2316 z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1))
2085 2317
2086 2318 xlabel = "Time (s)"
2087 2319 ylabel = "Range (km)"
2088 2320
2089 2321 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
2090 2322
2091 2323 if not self.isConfig:
2092 2324
2093 2325 nplots = nParam*nChan
2094 2326
2095 2327 self.setup(id=id,
2096 2328 nplots=nplots,
2097 2329 wintitle=wintitle,
2098 2330 show=show)
2099 2331
2100 2332 if xmin is None: xmin = numpy.nanmin(x)
2101 2333 if xmax is None: xmax = numpy.nanmax(x)
2102 2334 if ymin is None: ymin = numpy.nanmin(y)
2103 2335 if ymax is None: ymax = numpy.nanmax(y)
2104 2336 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
2105 2337 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
2106 2338 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
2107 2339 if vmin is None: vmin = -vmax
2108 2340 if wmin is None: wmin = 0
2109 2341 if wmax is None: wmax = 50
2110 2342
2111 2343 self.nChannels = nChan
2112 2344
2113 2345 zminList = []
2114 2346 zmaxList = []
2115 2347 titleList = []
2116 2348 cmapList = []
2117 2349 for i in range(self.nChannels):
2118 2350 strAux1 = "SNR Channel "+ str(i)
2119 2351 strAux2 = "Radial Velocity Channel "+ str(i)
2120 2352 strAux3 = "Spectral Width Channel "+ str(i)
2121 2353
2122 2354 titleList = titleList + [strAux1,strAux2,strAux3]
2123 2355 cmapList = cmapList + ["jet","RdBu_r","jet"]
2124 2356 zminList = zminList + [SNRmin,vmin,wmin]
2125 2357 zmaxList = zmaxList + [SNRmax,vmax,wmax]
2126 2358
2127 2359 self.zminList = zminList
2128 2360 self.zmaxList = zmaxList
2129 2361 self.cmapList = cmapList
2130 2362 self.titleList = titleList
2131 2363
2132 2364 self.FTP_WEI = ftp_wei
2133 2365 self.EXP_CODE = exp_code
2134 2366 self.SUB_EXP_CODE = sub_exp_code
2135 2367 self.PLOT_POS = plot_pos
2136 2368
2137 2369 self.isConfig = True
2138 2370
2139 2371 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
2140 2372
2141 2373 for i in range(self.nplots):
2142 2374 title = self.titleList[i] + ": " +str_datetime
2143 2375 axes = self.axesList[i]
2144 2376 axes.pcolor(x, y, z[i,:].T,
2145 2377 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
2146 2378 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
2147 2379 self.draw()
2148 2380
2149 2381 if figfile == None:
2150 2382 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
2151 2383 name = str_datetime
2152 2384 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
2153 2385 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
2154 2386 figfile = self.getFilename(name)
2155 2387
2156 2388 self.save(figpath=figpath,
2157 2389 figfile=figfile,
2158 2390 save=save,
2159 2391 ftp=ftp,
2160 2392 wr_period=wr_period,
2161 2393 thisDatetime=thisDatetime)
@@ -1,1155 +1,795
1 1 import os, sys
2 2 import glob
3 3 import fnmatch
4 4 import datetime
5 5 import time
6 6 import re
7 7 import h5py
8 8 import numpy
9 9 import matplotlib.pyplot as plt
10 10
11 11 import pylab as plb
12 12 from scipy.optimize import curve_fit
13 13 from scipy import asarray as ar, exp
14 14 from scipy import stats
15 15
16 16 from numpy.ma.core import getdata
17 17
18 18 SPEED_OF_LIGHT = 299792458
19 19 SPEED_OF_LIGHT = 3e8
20 20
21 21 try:
22 22 from gevent import sleep
23 23 except:
24 24 from time import sleep
25 25
26 26 from schainpy.model.data.jrodata import Spectra
27 27 #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
28 28 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
29 29 #from schainpy.model.io.jroIO_bltr import BLTRReader
30 30 from numpy import imag, shape, NaN
31 31
32 32 from jroIO_base import JRODataReader
33 33
34 34
35 35 class Header(object):
36 36
37 37 def __init__(self):
38 38 raise NotImplementedError
39 39
40 40
41 41 def read(self):
42 42
43 43 raise NotImplementedError
44 44
45 45 def write(self):
46 46
47 47 raise NotImplementedError
48 48
49 49 def printInfo(self):
50 50
51 51 message = "#"*50 + "\n"
52 52 message += self.__class__.__name__.upper() + "\n"
53 53 message += "#"*50 + "\n"
54 54
55 55 keyList = self.__dict__.keys()
56 56 keyList.sort()
57 57
58 58 for key in keyList:
59 59 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
60 60
61 61 if "size" not in keyList:
62 62 attr = getattr(self, "size")
63 63
64 64 if attr:
65 65 message += "%s = %s" %("size", attr) + "\n"
66 66
67 67 #print message
68 68
69 69
70 70
71 71
72 72
73 73 FILE_STRUCTURE = numpy.dtype([ #HEADER 48bytes
74 74 ('FileMgcNumber','<u4'), #0x23020100
75 75 ('nFDTdataRecors','<u4'), #No Of FDT data records in this file (0 or more)
76 76 ('OffsetStartHeader','<u4'),
77 77 ('RadarUnitId','<u4'),
78 78 ('SiteName',numpy.str_,32), #Null terminated
79 79 ])
80 80
81 81 class FileHeaderBLTR(Header):
82 82
83 83 def __init__(self):
84 84
85 85 self.FileMgcNumber= 0 #0x23020100
86 86 self.nFDTdataRecors=0 #No Of FDT data records in this file (0 or more)
87 87 self.RadarUnitId= 0
88 88 self.OffsetStartHeader=0
89 89 self.SiteName= ""
90 90 self.size = 48
91 91
92 92 def FHread(self, fp):
93 93 #try:
94 94 startFp = open(fp,"rb")
95 95
96 96 header = numpy.fromfile(startFp, FILE_STRUCTURE,1)
97 97
98 98 print ' '
99 99 print 'puntero file header', startFp.tell()
100 100 print ' '
101 101
102 102
103 103 ''' numpy.fromfile(file, dtype, count, sep='')
104 104 file : file or str
105 105 Open file object or filename.
106 106
107 107 dtype : data-type
108 108 Data type of the returned array. For binary files, it is used to determine
109 109 the size and byte-order of the items in the file.
110 110
111 111 count : int
112 112 Number of items to read. -1 means all items (i.e., the complete file).
113 113
114 114 sep : str
115 115 Separator between items if file is a text file. Empty ("") separator means
116 116 the file should be treated as binary. Spaces (" ") in the separator match zero
117 117 or more whitespace characters. A separator consisting only of spaces must match
118 118 at least one whitespace.
119 119
120 120 '''
121 121
122 122
123 123
124 124 self.FileMgcNumber= hex(header['FileMgcNumber'][0])
125 125 self.nFDTdataRecors=int(header['nFDTdataRecors'][0]) #No Of FDT data records in this file (0 or more)
126 126 self.RadarUnitId= int(header['RadarUnitId'][0])
127 127 self.OffsetStartHeader= int(header['OffsetStartHeader'][0])
128 128 self.SiteName= str(header['SiteName'][0])
129 129
130 130 #print 'Numero de bloques', self.nFDTdataRecors
131 131
132 132
133 133 if self.size <48:
134 134 return 0
135 135
136 136 return 1
137 137
138 138
139 139 def write(self, fp):
140 140
141 141 headerTuple = (self.FileMgcNumber,
142 142 self.nFDTdataRecors,
143 143 self.RadarUnitId,
144 144 self.SiteName,
145 145 self.size)
146 146
147 147
148 148 header = numpy.array(headerTuple, FILE_STRUCTURE)
149 149 # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)
150 150 header.tofile(fp)
151 151 ''' ndarray.tofile(fid, sep, format) Write array to a file as text or binary (default).
152 152
153 153 fid : file or str
154 154 An open file object, or a string containing a filename.
155 155
156 156 sep : str
157 157 Separator between array items for text output. If "" (empty), a binary file is written,
158 158 equivalent to file.write(a.tobytes()).
159 159
160 160 format : str
161 161 Format string for text file output. Each entry in the array is formatted to text by
162 162 first converting it to the closest Python type, and then using "format" % item.
163 163
164 164 '''
165 165
166 166 return 1
167 167
168 168
169 169
170 170
171 171
172 172 RECORD_STRUCTURE = numpy.dtype([ #RECORD HEADER 180+20N bytes
173 173 ('RecMgcNumber','<u4'), #0x23030001
174 174 ('RecCounter','<u4'), #Record counter(0,1, ...)
175 175 ('Off2StartNxtRec','<u4'), #Offset to start of next record form start of this record
176 176 ('Off2StartData','<u4'), #Offset to start of data from start of this record
177 177 ('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds)
178 178 ('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999)
179 179 ('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated)
180 180 ('ExpComment',numpy.str_,32), #Experiment comment (null terminated)
181 181 ('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North)
182 182 ('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East)
183 183 ('RTCgpsStatus','<u4'), #RTC GPS engine status (0=SEEK, 1=LOCK, 2=NOT FITTED, 3=UNAVAILABLE)
184 184 ('TransmitFrec','<u4'), #Transmit frequency (Hz)
185 185 ('ReceiveFrec','<u4'), #Receive frequency
186 186 ('FirstOsciFrec','<u4'), #First local oscillator frequency (Hz)
187 187 ('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2")
188 188 ('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3)
189 189 ('nModesInUse','<u4'), #Number of modes in use (1 or 2)
190 190 ('DualModeIndex','<u4'), #Dual Mode index number for these data (0 or 1)
191 191 ('DualModeRange','<u4'), #Dual Mode range correction for these data (m)
192 192 ('nDigChannels','<u4'), #Number of digital channels acquired (2*N)
193 193 ('SampResolution','<u4'), #Sampling resolution (meters)
194 194 ('nHeights','<u4'), #Number of range gates sampled
195 195 ('StartRangeSamp','<u4'), #Start range of sampling (meters)
196 196 ('PRFhz','<u4'), #PRF (Hz)
197 197 ('nCohInt','<u4'), #Integrations
198 198 ('nProfiles','<u4'), #Number of data points transformed
199 199 ('nChannels','<u4'), #Number of receive beams stored in file (1 or N)
200 200 ('nIncohInt','<u4'), #Number of spectral averages
201 201 ('FFTwindowingInd','<u4'), #FFT windowing index (0 = no window)
202 202 ('BeamAngleAzim','<f4'), #Beam steer angle (azimuth) in degrees (clockwise from true North)
203 203 ('BeamAngleZen','<f4'), #Beam steer angle (zenith) in degrees (0=> vertical)
204 204 ('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
205 205 ('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
206 206 ('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
207 207 ('AntennaAngl1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
208 208 ('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
209 209 ('AntennaAngl2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
210 210 ('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values
211 211 ('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values
212 212 ('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values
213 213 ('RecAmpCalibr0','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
214 214 ('RecAmpCalibr1','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
215 215 ('RecAmpCalibr2','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
216 216 ('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values
217 217 ('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values
218 218 ('ReceiverGaindB2','<i4'), #Receiver gains in dB - N values
219 219 ])
220 220
221 221
222 222 class RecordHeaderBLTR(Header):
223 223
224 224 def __init__(self, RecMgcNumber=None, RecCounter= 0, Off2StartNxtRec= 811248,
225 225 nUtime= 0, nMilisec= 0, ExpTagName= None,
226 226 ExpComment=None, SiteLatDegrees=0, SiteLongDegrees= 0,
227 227 RTCgpsStatus= 0, TransmitFrec= 0, ReceiveFrec= 0,
228 228 FirstOsciFrec= 0, Polarisation= 0, ReceiverFiltSett= 0,
229 229 nModesInUse= 0, DualModeIndex= 0, DualModeRange= 0,
230 230 nDigChannels= 0, SampResolution= 0, nHeights= 0,
231 231 StartRangeSamp= 0, PRFhz= 0, nCohInt= 0,
232 232 nProfiles= 0, nChannels= 0, nIncohInt= 0,
233 233 FFTwindowingInd= 0, BeamAngleAzim= 0, BeamAngleZen= 0,
234 234 AntennaCoord0= 0, AntennaCoord1= 0, AntennaCoord2= 0,
235 235 RecPhaseCalibr0= 0, RecPhaseCalibr1= 0, RecPhaseCalibr2= 0,
236 236 RecAmpCalibr0= 0, RecAmpCalibr1= 0, RecAmpCalibr2= 0,
237 237 AntennaAngl0=0, AntennaAngl1=0, AntennaAngl2=0,
238 238 ReceiverGaindB0= 0, ReceiverGaindB1= 0, ReceiverGaindB2= 0, Off2StartData=0, OffsetStartHeader=0):
239 239
240 240 self.RecMgcNumber = RecMgcNumber #0x23030001
241 241 self.RecCounter = RecCounter
242 242 self.Off2StartNxtRec = Off2StartNxtRec
243 243 self.Off2StartData = Off2StartData
244 244 self.nUtime = nUtime
245 245 self.nMilisec = nMilisec
246 246 self.ExpTagName = ExpTagName
247 247 self.ExpComment = ExpComment
248 248 self.SiteLatDegrees = SiteLatDegrees
249 249 self.SiteLongDegrees = SiteLongDegrees
250 250 self.RTCgpsStatus = RTCgpsStatus
251 251 self.TransmitFrec = TransmitFrec
252 252 self.ReceiveFrec = ReceiveFrec
253 253 self.FirstOsciFrec = FirstOsciFrec
254 254 self.Polarisation = Polarisation
255 255 self.ReceiverFiltSett = ReceiverFiltSett
256 256 self.nModesInUse = nModesInUse
257 257 self.DualModeIndex = DualModeIndex
258 258 self.DualModeRange = DualModeRange
259 259 self.nDigChannels = nDigChannels
260 260 self.SampResolution = SampResolution
261 261 self.nHeights = nHeights
262 262 self.StartRangeSamp = StartRangeSamp
263 263 self.PRFhz = PRFhz
264 264 self.nCohInt = nCohInt
265 265 self.nProfiles = nProfiles
266 266 self.nChannels = nChannels
267 267 self.nIncohInt = nIncohInt
268 268 self.FFTwindowingInd = FFTwindowingInd
269 269 self.BeamAngleAzim = BeamAngleAzim
270 270 self.BeamAngleZen = BeamAngleZen
271 271 self.AntennaCoord0 = AntennaCoord0
272 272 self.AntennaAngl0 = AntennaAngl0
273 273 self.AntennaAngl1 = AntennaAngl1
274 274 self.AntennaAngl2 = AntennaAngl2
275 275 self.AntennaCoord1 = AntennaCoord1
276 276 self.AntennaCoord2 = AntennaCoord2
277 277 self.RecPhaseCalibr0 = RecPhaseCalibr0
278 278 self.RecPhaseCalibr1 = RecPhaseCalibr1
279 279 self.RecPhaseCalibr2 = RecPhaseCalibr2
280 280 self.RecAmpCalibr0 = RecAmpCalibr0
281 281 self.RecAmpCalibr1 = RecAmpCalibr1
282 282 self.RecAmpCalibr2 = RecAmpCalibr2
283 283 self.ReceiverGaindB0 = ReceiverGaindB0
284 284 self.ReceiverGaindB1 = ReceiverGaindB1
285 285 self.ReceiverGaindB2 = ReceiverGaindB2
286 286 self.OffsetStartHeader = 48
287 287
288 288
289 289
290 290 def RHread(self, fp):
291 291 #print fp
292 292 #startFp = open('/home/erick/Documents/Data/huancayo.20161019.22.fdt',"rb") #The method tell() returns the current position of the file read/write pointer within the file.
293 293 startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file.
294 294 #RecCounter=0
295 295 #Off2StartNxtRec=811248
296 296 OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
297 297 print ' '
298 298 print 'puntero Record Header', startFp.tell()
299 299 print ' '
300 300
301 301
302 302 startFp.seek(OffRHeader, os.SEEK_SET)
303 303
304 304 print ' '
305 305 print 'puntero Record Header con seek', startFp.tell()
306 306 print ' '
307 307
308 308 #print 'Posicion del bloque: ',OffRHeader
309 309
310 310 header = numpy.fromfile(startFp,RECORD_STRUCTURE,1)
311 311
312 312 print ' '
313 313 print 'puntero Record Header con seek', startFp.tell()
314 314 print ' '
315 315
316 316 print ' '
317 317 #
318 318 #print 'puntero Record Header despues de seek', header.tell()
319 319 print ' '
320 320
321 321 self.RecMgcNumber = hex(header['RecMgcNumber'][0]) #0x23030001
322 322 self.RecCounter = int(header['RecCounter'][0])
323 323 self.Off2StartNxtRec = int(header['Off2StartNxtRec'][0])
324 324 self.Off2StartData = int(header['Off2StartData'][0])
325 325 self.nUtime = header['nUtime'][0]
326 326 self.nMilisec = header['nMilisec'][0]
327 327 self.ExpTagName = str(header['ExpTagName'][0])
328 328 self.ExpComment = str(header['ExpComment'][0])
329 329 self.SiteLatDegrees = header['SiteLatDegrees'][0]
330 330 self.SiteLongDegrees = header['SiteLongDegrees'][0]
331 331 self.RTCgpsStatus = header['RTCgpsStatus'][0]
332 332 self.TransmitFrec = header['TransmitFrec'][0]
333 333 self.ReceiveFrec = header['ReceiveFrec'][0]
334 334 self.FirstOsciFrec = header['FirstOsciFrec'][0]
335 335 self.Polarisation = header['Polarisation'][0]
336 336 self.ReceiverFiltSett = header['ReceiverFiltSett'][0]
337 337 self.nModesInUse = header['nModesInUse'][0]
338 338 self.DualModeIndex = header['DualModeIndex'][0]
339 339 self.DualModeRange = header['DualModeRange'][0]
340 340 self.nDigChannels = header['nDigChannels'][0]
341 341 self.SampResolution = header['SampResolution'][0]
342 342 self.nHeights = header['nHeights'][0]
343 343 self.StartRangeSamp = header['StartRangeSamp'][0]
344 344 self.PRFhz = header['PRFhz'][0]
345 345 self.nCohInt = header['nCohInt'][0]
346 346 self.nProfiles = header['nProfiles'][0]
347 347 self.nChannels = header['nChannels'][0]
348 348 self.nIncohInt = header['nIncohInt'][0]
349 349 self.FFTwindowingInd = header['FFTwindowingInd'][0]
350 350 self.BeamAngleAzim = header['BeamAngleAzim'][0]
351 351 self.BeamAngleZen = header['BeamAngleZen'][0]
352 352 self.AntennaCoord0 = header['AntennaCoord0'][0]
353 353 self.AntennaAngl0 = header['AntennaAngl0'][0]
354 354 self.AntennaCoord1 = header['AntennaCoord1'][0]
355 355 self.AntennaAngl1 = header['AntennaAngl1'][0]
356 356 self.AntennaCoord2 = header['AntennaCoord2'][0]
357 357 self.AntennaAngl2 = header['AntennaAngl2'][0]
358 358 self.RecPhaseCalibr0 = header['RecPhaseCalibr0'][0]
359 359 self.RecPhaseCalibr1 = header['RecPhaseCalibr1'][0]
360 360 self.RecPhaseCalibr2 = header['RecPhaseCalibr2'][0]
361 361 self.RecAmpCalibr0 = header['RecAmpCalibr0'][0]
362 362 self.RecAmpCalibr1 = header['RecAmpCalibr1'][0]
363 363 self.RecAmpCalibr2 = header['RecAmpCalibr2'][0]
364 364 self.ReceiverGaindB0 = header['ReceiverGaindB0'][0]
365 365 self.ReceiverGaindB1 = header['ReceiverGaindB1'][0]
366 366 self.ReceiverGaindB2 = header['ReceiverGaindB2'][0]
367 367
368 368 self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
369 369
370 370 self.RHsize = 180+20*self.nChannels
371 371 self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
372 372 #print 'Datasize',self.Datasize
373 373 endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
374 374
375 375 print '=============================================='
376 376 print 'RecMgcNumber ',self.RecMgcNumber
377 377 print 'RecCounter ',self.RecCounter
378 378 print 'Off2StartNxtRec ',self.Off2StartNxtRec
379 379 print 'Off2StartData ',self.Off2StartData
380 380 print 'Range Resolution ',self.SampResolution
381 381 print 'First Height ',self.StartRangeSamp
382 382 print 'PRF (Hz) ',self.PRFhz
383 383 print 'Heights (K) ',self.nHeights
384 384 print 'Channels (N) ',self.nChannels
385 385 print 'Profiles (J) ',self.nProfiles
386 386 print 'iCoh ',self.nCohInt
387 387 print 'iInCoh ',self.nIncohInt
388 388 print 'BeamAngleAzim ',self.BeamAngleAzim
389 389 print 'BeamAngleZen ',self.BeamAngleZen
390 390
391 391 #print 'ModoEnUso ',self.DualModeIndex
392 392 #print 'UtcTime ',self.nUtime
393 393 #print 'MiliSec ',self.nMilisec
394 394 #print 'Exp TagName ',self.ExpTagName
395 395 #print 'Exp Comment ',self.ExpComment
396 396 #print 'FFT Window Index ',self.FFTwindowingInd
397 397 #print 'N Dig. Channels ',self.nDigChannels
398 398 print 'Size de bloque ',self.RHsize
399 399 print 'DataSize ',self.Datasize
400 400 print 'BeamAngleAzim ',self.BeamAngleAzim
401 401 #print 'AntennaCoord0 ',self.AntennaCoord0
402 402 #print 'AntennaAngl0 ',self.AntennaAngl0
403 403 #print 'AntennaCoord1 ',self.AntennaCoord1
404 404 #print 'AntennaAngl1 ',self.AntennaAngl1
405 405 #print 'AntennaCoord2 ',self.AntennaCoord2
406 406 #print 'AntennaAngl2 ',self.AntennaAngl2
407 407 print 'RecPhaseCalibr0 ',self.RecPhaseCalibr0
408 408 print 'RecPhaseCalibr1 ',self.RecPhaseCalibr1
409 409 print 'RecPhaseCalibr2 ',self.RecPhaseCalibr2
410 410 print 'RecAmpCalibr0 ',self.RecAmpCalibr0
411 411 print 'RecAmpCalibr1 ',self.RecAmpCalibr1
412 412 print 'RecAmpCalibr2 ',self.RecAmpCalibr2
413 413 print 'ReceiverGaindB0 ',self.ReceiverGaindB0
414 414 print 'ReceiverGaindB1 ',self.ReceiverGaindB1
415 415 print 'ReceiverGaindB2 ',self.ReceiverGaindB2
416 416 print '=============================================='
417 417
418 418 if OffRHeader > endFp:
419 419 sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp)
420 420 return 0
421 421
422 422 if OffRHeader < endFp:
423 423 sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp)
424 424 return 0
425 425
426 426 return 1
427 427
428 428
429 429 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODataReader):
430 430
431 431 path = None
432 432 startDate = None
433 433 endDate = None
434 434 startTime = None
435 435 endTime = None
436 436 walk = None
437 437 isConfig = False
438 438
439 439
440 440 fileList= None
441 441
442 442 #metadata
443 443 TimeZone= None
444 444 Interval= None
445 445 heightList= None
446 446
447 447 #data
448 448 data= None
449 449 utctime= None
450 450
451 451
452 452
453 453 def __init__(self, **kwargs):
454 454
455 455 #Eliminar de la base la herencia
456 456 ProcessingUnit.__init__(self, **kwargs)
457 457
458 458 #self.isConfig = False
459 459
460 460 #self.pts2read_SelfSpectra = 0
461 461 #self.pts2read_CrossSpectra = 0
462 462 #self.pts2read_DCchannels = 0
463 463 #self.datablock = None
464 464 self.utc = None
465 465 self.ext = ".fdt"
466 466 self.optchar = "P"
467 467 self.fpFile=None
468 468 self.fp = None
469 469 self.BlockCounter=0
470 470 self.dtype = None
471 471 self.fileSizeByHeader = None
472 472 self.filenameList = []
473 473 self.fileSelector = 0
474 474 self.Off2StartNxtRec=0
475 475 self.RecCounter=0
476 476 self.flagNoMoreFiles = 0
477 477 self.data_spc=None
478 478 self.data_cspc=None
479 479 self.data_output=None
480 480 self.path = None
481 481 self.OffsetStartHeader=0
482 482 self.Off2StartData=0
483 483 self.ipp = 0
484 484 self.nFDTdataRecors=0
485 485 self.blocksize = 0
486 486 self.dataOut = Spectra()
487 487 self.profileIndex = 1 #Always
488 488 self.dataOut.flagNoData=False
489 489 self.dataOut.nRdPairs = 0
490 490 self.dataOut.pairsList = []
491 491 self.dataOut.data_spc=None
492 492 self.dataOut.noise=[]
493 493 self.dataOut.velocityX=[]
494 494 self.dataOut.velocityY=[]
495 495 self.dataOut.velocityV=[]
496 496
497 497
498 498
499 499 def Files2Read(self, fp):
500 500 '''
501 501 Function that indicates the number of .fdt files that exist in the folder to be read.
502 502 It also creates an organized list with the names of the files to read.
503 503 '''
504 504 #self.__checkPath()
505 505
506 506 ListaData=os.listdir(fp) #Gets the list of files within the fp address
507 507 ListaData=sorted(ListaData) #Sort the list of files from least to largest by names
508 508 nFiles=0 #File Counter
509 509 FileList=[] #A list is created that will contain the .fdt files
510 510 for IndexFile in ListaData :
511 511 if '.fdt' in IndexFile:
512 512 FileList.append(IndexFile)
513 513 nFiles+=1
514 514
515 515 #print 'Files2Read'
516 516 #print 'Existen '+str(nFiles)+' archivos .fdt'
517 517
518 518 self.filenameList=FileList #List of files from least to largest by names
519 519
520 520
521 521 def run(self, **kwargs):
522 522 '''
523 523 This method will be the one that will initiate the data entry, will be called constantly.
524 524 You should first verify that your Setup () is set up and then continue to acquire
525 525 the data to be processed with getData ().
526 526 '''
527 527 if not self.isConfig:
528 528 self.setup(**kwargs)
529 529 self.isConfig = True
530 530
531 531 self.getData()
532 532 #print 'running'
533 533
534 534
535 535 def setup(self, path=None,
536 536 startDate=None,
537 537 endDate=None,
538 538 startTime=None,
539 539 endTime=None,
540 540 walk=True,
541 541 timezone='utc',
542 542 code = None,
543 543 online=False,
544 544 ReadMode=None,
545 545 **kwargs):
546 546
547 547 self.isConfig = True
548 548
549 549 self.path=path
550 550 self.startDate=startDate
551 551 self.endDate=endDate
552 552 self.startTime=startTime
553 553 self.endTime=endTime
554 554 self.walk=walk
555 555 self.ReadMode=int(ReadMode)
556 556
557 557 pass
558 558
559 559
560 560 def getData(self):
561 561 '''
562 562 Before starting this function, you should check that there is still an unread file,
563 563 If there are still blocks to read or if the data block is empty.
564 564
565 565 You should call the file "read".
566 566
567 567 '''
568 568
569 569 if self.flagNoMoreFiles:
570 570 self.dataOut.flagNoData = True
571 print 'NoData se vuelve true'
571 #print 'NoData se vuelve true'
572 572 return 0
573 573
574 574 self.fp=self.path
575 575 self.Files2Read(self.fp)
576 576 self.readFile(self.fp)
577 577 self.dataOut.data_spc = self.data_spc
578 578 self.dataOut.data_cspc =self.data_cspc
579 579 self.dataOut.data_output=self.data_output
580 580
581 print 'self.dataOut.data_output', shape(self.dataOut.data_output)
581 #print 'self.dataOut.data_output', shape(self.dataOut.data_output)
582 582
583 583 #self.removeDC()
584 584 return self.dataOut.data_spc
585 585
586 586
587 587 def readFile(self,fp):
588 588 '''
589 589 You must indicate if you are reading in Online or Offline mode and load the
590 590 The parameters for this file reading mode.
591 591
592 592 Then you must do 2 actions:
593 593
594 594 1. Get the BLTR FileHeader.
595 595 2. Start reading the first block.
596 596 '''
597 597
598 598 #The address of the folder is generated the name of the .fdt file that will be read
599 print "File: ",self.fileSelector+1
599 #print "File: ",self.fileSelector+1
600 600
601 601 if self.fileSelector < len(self.filenameList):
602 602
603 603 self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
604 604 #print self.fpFile
605 605 fheader = FileHeaderBLTR()
606 606 fheader.FHread(self.fpFile) #Bltr FileHeader Reading
607 607 self.nFDTdataRecors=fheader.nFDTdataRecors
608 608
609 609 self.readBlock() #Block reading
610 610 else:
611 print 'readFile FlagNoData becomes true'
611 #print 'readFile FlagNoData becomes true'
612 612 self.flagNoMoreFiles=True
613 613 self.dataOut.flagNoData = True
614 614 return 0
615 615
616 616 def getVelRange(self, extrapoints=0):
617 617 Lambda= SPEED_OF_LIGHT/50000000
618 618 PRF = self.dataOut.PRF#1./(self.dataOut.ippSeconds * self.dataOut.nCohInt)
619 619 Vmax=-Lambda/(4.*(1./PRF)*self.dataOut.nCohInt*2.)
620 620 deltafreq = PRF / (self.nProfiles)
621 621 deltavel = (Vmax*2) / (self.nProfiles)
622 622 freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2
623 623 velrange = deltavel*(numpy.arange(self.nProfiles)-self.nProfiles/2.)
624 624 return velrange
625 625
626 626 def readBlock(self):
627 627 '''
628 628 It should be checked if the block has data, if it is not passed to the next file.
629 629
630 630 Then the following is done:
631 631
632 632 1. Read the RecordHeader
633 633 2. Fill the buffer with the current block number.
634 634
635 635 '''
636 636
637 if self.BlockCounter < self.nFDTdataRecors-2:
638 print self.nFDTdataRecors, 'CONDICION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
637 if self.BlockCounter < self.nFDTdataRecors-1:
638 #print self.nFDTdataRecors, 'CONDICION'
639 639 if self.ReadMode==1:
640 640 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter+1)
641 641 elif self.ReadMode==0:
642 642 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter)
643 643
644 644 rheader.RHread(self.fpFile) #Bltr FileHeader Reading
645 645
646 646 self.OffsetStartHeader=rheader.OffsetStartHeader
647 647 self.RecCounter=rheader.RecCounter
648 648 self.Off2StartNxtRec=rheader.Off2StartNxtRec
649 649 self.Off2StartData=rheader.Off2StartData
650 650 self.nProfiles=rheader.nProfiles
651 651 self.nChannels=rheader.nChannels
652 652 self.nHeights=rheader.nHeights
653 653 self.frequency=rheader.TransmitFrec
654 654 self.DualModeIndex=rheader.DualModeIndex
655 655
656 656 self.pairsList =[(0,1),(0,2),(1,2)]
657 657 self.dataOut.pairsList = self.pairsList
658 658
659 659 self.nRdPairs=len(self.dataOut.pairsList)
660 660 self.dataOut.nRdPairs = self.nRdPairs
661 661
662 662 self.__firstHeigth=rheader.StartRangeSamp
663 663 self.__deltaHeigth=rheader.SampResolution
664 664 self.dataOut.heightList= self.__firstHeigth + numpy.array(range(self.nHeights))*self.__deltaHeigth
665 665 self.dataOut.channelList = range(self.nChannels)
666 666 self.dataOut.nProfiles=rheader.nProfiles
667 667 self.dataOut.nIncohInt=rheader.nIncohInt
668 668 self.dataOut.nCohInt=rheader.nCohInt
669 669 self.dataOut.ippSeconds= 1/float(rheader.PRFhz)
670 670 self.dataOut.PRF=rheader.PRFhz
671 671 self.dataOut.nFFTPoints=rheader.nProfiles
672 672 self.dataOut.utctime=rheader.nUtime
673 673 self.dataOut.timeZone=0
674 674 self.dataOut.normFactor= self.dataOut.nProfiles*self.dataOut.nIncohInt*self.dataOut.nCohInt
675 675 self.dataOut.outputInterval= self.dataOut.ippSeconds * self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles
676 676
677 677 self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN
678 print 'self.data_output', shape(self.data_output)
678 #print 'self.data_output', shape(self.data_output)
679 679 self.dataOut.velocityX=[]
680 680 self.dataOut.velocityY=[]
681 681 self.dataOut.velocityV=[]
682 682
683 683 '''Block Reading, the Block Data is received and Reshape is used to give it
684 684 shape.
685 685 '''
686 686
687 687 #Procedure to take the pointer to where the date block starts
688 688 startDATA = open(self.fpFile,"rb")
689 689 OffDATA= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec+self.Off2StartData
690 690 startDATA.seek(OffDATA, os.SEEK_SET)
691 691
692 692 def moving_average(x, N=2):
693 693 return numpy.convolve(x, numpy.ones((N,))/N)[(N-1):]
694 694
695 695 def gaus(xSamples,a,x0,sigma):
696 696 return a*exp(-(xSamples-x0)**2/(2*sigma**2))
697 697
698 698 def Find(x,value):
699 699 for index in range(len(x)):
700 700 if x[index]==value:
701 701 return index
702 702
703 703 def pol2cart(rho, phi):
704 704 x = rho * numpy.cos(phi)
705 705 y = rho * numpy.sin(phi)
706 706 return(x, y)
707 707
708 708
709 709
710 710
711 711 if self.DualModeIndex==self.ReadMode:
712 712
713 713 self.data_fft = numpy.fromfile( startDATA, [('complex','<c8')],self.nProfiles*self.nChannels*self.nHeights )
714 #
715 # if len(self.data_fft) is not 101376:
716 #
717 # self.data_fft = numpy.empty(101376)
714 718
715 719 self.data_fft=self.data_fft.astype(numpy.dtype('complex'))
716 720
721
722
723
724
717 725 self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles ))
718 726
719 727 self.data_block = numpy.transpose(self.data_block, (1,2,0))
720 728
721 729 copy = self.data_block.copy()
722 730 spc = copy * numpy.conjugate(copy)
723 731
724 732 self.data_spc = numpy.absolute(spc) # valor absoluto o magnitud
725 733
726 734 factor = self.dataOut.normFactor
727 735
728 736
729 737 z = self.data_spc.copy()#/factor
730 738 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
731 739 #zdB = 10*numpy.log10(z)
732 print ' '
733 print 'Z: '
734 print shape(z)
735 print ' '
736 print ' '
740
737 741
738 742 self.dataOut.data_spc=self.data_spc
739 743
740 744 self.noise = self.dataOut.getNoise(ymin_index=80, ymax_index=132)#/factor
741 745 #noisedB = 10*numpy.log10(self.noise)
742 746
743 747
744 748 ySamples=numpy.ones([3,self.nProfiles])
745 749 phase=numpy.ones([3,self.nProfiles])
746 750 CSPCSamples=numpy.ones([3,self.nProfiles],dtype=numpy.complex_)
747 751 coherence=numpy.ones([3,self.nProfiles])
748 752 PhaseSlope=numpy.ones(3)
749 753 PhaseInter=numpy.ones(3)
750 754
751 755 '''****** Getting CrossSpectra ******'''
752 756 cspc=self.data_block.copy()
753 757 self.data_cspc=self.data_block.copy()
754 758
755 759 xFrec=self.getVelRange(1)
756 760 VelRange=self.getVelRange(1)
757 761 self.dataOut.VelRange=VelRange
758 762 #print ' '
759 763 #print ' '
760 764 #print 'xFrec',xFrec
761 765 #print ' '
762 766 #print ' '
763 767 #Height=35
764 768
765 769 for i in range(self.nRdPairs):
766 770
767 771 chan_index0 = self.dataOut.pairsList[i][0]
768 772 chan_index1 = self.dataOut.pairsList[i][1]
769 773
770 774 self.data_cspc[i,:,:]=cspc[chan_index0,:,:] * numpy.conjugate(cspc[chan_index1,:,:])
771 775
772 776
773 777 '''Getting Eij and Nij'''
774 778 (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
775 779 (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
776 780 (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
777 781
778 782 E01=AntennaX0-AntennaX1
779 783 N01=AntennaY0-AntennaY1
780 784
781 785 E02=AntennaX0-AntennaX2
782 786 N02=AntennaY0-AntennaY2
783 787
784 788 E12=AntennaX1-AntennaX2
785 789 N12=AntennaY1-AntennaY2
786 790
787 791 self.ChanDist= numpy.array([[E01, N01],[E02,N02],[E12,N12]])
788 792
789 793 self.dataOut.ChanDist = self.ChanDist
790 794
791 795
792 # for Height in range(self.nHeights):
793 #
794 # for i in range(self.nRdPairs):
795 #
796 # '''****** Line of Data SPC ******'''
797 # zline=z[i,:,Height]
798 #
799 # '''****** DC is removed ******'''
800 # DC=Find(zline,numpy.amax(zline))
801 # zline[DC]=(zline[DC-1]+zline[DC+1])/2
802 #
803 #
804 # '''****** SPC is normalized ******'''
805 # FactNorm= zline.copy() / numpy.sum(zline.copy())
806 # FactNorm= FactNorm/numpy.sum(FactNorm)
807 #
808 # SmoothSPC=moving_average(FactNorm,N=3)
809 #
810 # xSamples = ar(range(len(SmoothSPC)))
811 # ySamples[i] = SmoothSPC-self.noise[i]
812 #
813 # for i in range(self.nRdPairs):
814 #
815 # '''****** Line of Data CSPC ******'''
816 # cspcLine=self.data_cspc[i,:,Height].copy()
817 #
818 #
819 #
820 # '''****** CSPC is normalized ******'''
821 # chan_index0 = self.dataOut.pairsList[i][0]
822 # chan_index1 = self.dataOut.pairsList[i][1]
823 # CSPCFactor= numpy.sum(ySamples[chan_index0]) * numpy.sum(ySamples[chan_index1])
824 #
825 #
826 # CSPCNorm= cspcLine.copy() / numpy.sqrt(CSPCFactor)
827 #
828 #
829 # CSPCSamples[i] = CSPCNorm-self.noise[i]
830 # coherence[i] = numpy.abs(CSPCSamples[i]) / numpy.sqrt(CSPCFactor)
831 #
832 # '''****** DC is removed ******'''
833 # DC=Find(coherence[i],numpy.amax(coherence[i]))
834 # coherence[i][DC]=(coherence[i][DC-1]+coherence[i][DC+1])/2
835 # coherence[i]= moving_average(coherence[i],N=2)
836 #
837 # phase[i] = moving_average( numpy.arctan2(CSPCSamples[i].imag, CSPCSamples[i].real),N=1)#*180/numpy.pi
838 #
839 #
840 # '''****** Getting fij width ******'''
841 #
842 # yMean=[]
843 # yMean2=[]
844 #
845 # for j in range(len(ySamples[1])):
846 # yMean=numpy.append(yMean,numpy.average([ySamples[0,j],ySamples[1,j],ySamples[2,j]]))
847 #
848 # '''******* Getting fitting Gaussian ******'''
849 # meanGauss=sum(xSamples*yMean) / len(xSamples)
850 # sigma=sum(yMean*(xSamples-meanGauss)**2) / len(xSamples)
851 # #print 'Height',Height,'SNR', meanGauss/sigma**2
852 #
853 # if (abs(meanGauss/sigma**2) > 0.0001) :
854 #
855 # try:
856 # popt,pcov = curve_fit(gaus,xSamples,yMean,p0=[1,meanGauss,sigma])
857 #
858 # if numpy.amax(popt)>numpy.amax(yMean)*0.3:
859 # FitGauss=gaus(xSamples,*popt)
860 #
861 # else:
862 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
863 # print 'Verificador: Dentro', Height
864 # except RuntimeError:
865 #
866 # try:
867 # for j in range(len(ySamples[1])):
868 # yMean2=numpy.append(yMean2,numpy.average([ySamples[1,j],ySamples[2,j]]))
869 # popt,pcov = curve_fit(gaus,xSamples,yMean2,p0=[1,meanGauss,sigma])
870 # FitGauss=gaus(xSamples,*popt)
871 # print 'Verificador: Exepcion1', Height
872 # except RuntimeError:
873 #
874 # try:
875 # popt,pcov = curve_fit(gaus,xSamples,ySamples[1],p0=[1,meanGauss,sigma])
876 # FitGauss=gaus(xSamples,*popt)
877 # print 'Verificador: Exepcion2', Height
878 # except RuntimeError:
879 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
880 # print 'Verificador: Exepcion3', Height
881 # else:
882 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
883 # #print 'Verificador: Fuera', Height
884 #
885 #
886 #
887 # Maximun=numpy.amax(yMean)
888 # eMinus1=Maximun*numpy.exp(-1)
889 #
890 # HWpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-eMinus1)))
891 # HalfWidth= xFrec[HWpos]
892 # GCpos=Find(FitGauss, numpy.amax(FitGauss))
893 # Vpos=Find(FactNorm, numpy.amax(FactNorm))
894 # #Vpos=numpy.sum(FactNorm)/len(FactNorm)
895 # #Vpos=Find(FactNorm, min(FactNorm, key=lambda value:abs(value- numpy.mean(FactNorm) )))
896 # #print 'GCpos',GCpos, numpy.amax(FitGauss), 'HWpos',HWpos
897 # '''****** Getting Fij ******'''
898 #
899 # GaussCenter=xFrec[GCpos]
900 # if (GaussCenter<0 and HalfWidth>0) or (GaussCenter>0 and HalfWidth<0):
901 # Fij=abs(GaussCenter)+abs(HalfWidth)+0.0000001
902 # else:
903 # Fij=abs(GaussCenter-HalfWidth)+0.0000001
904 #
905 # '''****** Getting Frecuency range of significant data ******'''
906 #
907 # Rangpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.10)))
908 #
909 # if Rangpos<GCpos:
910 # Range=numpy.array([Rangpos,2*GCpos-Rangpos])
911 # else:
912 # Range=numpy.array([2*GCpos-Rangpos,Rangpos])
913 #
914 # FrecRange=xFrec[Range[0]:Range[1]]
915 #
916 # #print 'FrecRange', FrecRange
917 # '''****** Getting SCPC Slope ******'''
918 #
919 # for i in range(self.nRdPairs):
920 #
921 # if len(FrecRange)>5 and len(FrecRange)<self.nProfiles*0.5:
922 # PhaseRange=moving_average(phase[i,Range[0]:Range[1]],N=3)
923 #
924 # slope, intercept, r_value, p_value, std_err = stats.linregress(FrecRange,PhaseRange)
925 # PhaseSlope[i]=slope
926 # PhaseInter[i]=intercept
927 # else:
928 # PhaseSlope[i]=0
929 # PhaseInter[i]=0
930 #
931 # # plt.figure(i+15)
932 # # plt.title('FASE ( CH%s*CH%s )' %(self.dataOut.pairsList[i][0],self.dataOut.pairsList[i][1]))
933 # # plt.xlabel('Frecuencia (KHz)')
934 # # plt.ylabel('Magnitud')
935 # # #plt.subplot(311+i)
936 # # plt.plot(FrecRange,PhaseRange,'b')
937 # # plt.plot(FrecRange,FrecRange*PhaseSlope[i]+PhaseInter[i],'r')
938 #
939 # #plt.axis([-0.6, 0.2, -3.2, 3.2])
940 #
941 #
942 # '''Getting constant C'''
943 # cC=(Fij*numpy.pi)**2
944 #
945 # # '''Getting Eij and Nij'''
946 # # (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
947 # # (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
948 # # (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
949 # #
950 # # E01=AntennaX0-AntennaX1
951 # # N01=AntennaY0-AntennaY1
952 # #
953 # # E02=AntennaX0-AntennaX2
954 # # N02=AntennaY0-AntennaY2
955 # #
956 # # E12=AntennaX1-AntennaX2
957 # # N12=AntennaY1-AntennaY2
958 #
959 # '''****** Getting constants F and G ******'''
960 # MijEijNij=numpy.array([[E02,N02], [E12,N12]])
961 # MijResult0=(-PhaseSlope[1]*cC) / (2*numpy.pi)
962 # MijResult1=(-PhaseSlope[2]*cC) / (2*numpy.pi)
963 # MijResults=numpy.array([MijResult0,MijResult1])
964 # (cF,cG) = numpy.linalg.solve(MijEijNij, MijResults)
965 #
966 # '''****** Getting constants A, B and H ******'''
967 # W01=numpy.amax(coherence[0])
968 # W02=numpy.amax(coherence[1])
969 # W12=numpy.amax(coherence[2])
970 #
971 # WijResult0=((cF*E01+cG*N01)**2)/cC - numpy.log(W01 / numpy.sqrt(numpy.pi/cC))
972 # WijResult1=((cF*E02+cG*N02)**2)/cC - numpy.log(W02 / numpy.sqrt(numpy.pi/cC))
973 # WijResult2=((cF*E12+cG*N12)**2)/cC - numpy.log(W12 / numpy.sqrt(numpy.pi/cC))
974 #
975 # WijResults=numpy.array([WijResult0, WijResult1, WijResult2])
976 #
977 # WijEijNij=numpy.array([ [E01**2, N01**2, 2*E01*N01] , [E02**2, N02**2, 2*E02*N02] , [E12**2, N12**2, 2*E12*N12] ])
978 # (cA,cB,cH) = numpy.linalg.solve(WijEijNij, WijResults)
979 #
980 # VxVy=numpy.array([[cA,cH],[cH,cB]])
981 #
982 # VxVyResults=numpy.array([-cF,-cG])
983 # (Vx,Vy) = numpy.linalg.solve(VxVy, VxVyResults)
984 # Vzon = Vy
985 # Vmer = Vx
986 # Vmag=numpy.sqrt(Vzon**2+Vmer**2)
987 # Vang=numpy.arctan2(Vmer,Vzon)
988 #
989 # if abs(Vy)<100 and abs(Vy)> 0.:
990 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, Vzon) #Vmag
991 # #print 'Vmag',Vmag
992 # else:
993 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, NaN)
994 #
995 # if abs(Vx)<100 and abs(Vx) > 0.:
996 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, Vmer) #Vang
997 # #print 'Vang',Vang
998 # else:
999 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, NaN)
1000 #
1001 # if abs(GaussCenter)<2:
1002 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, xFrec[Vpos])
1003 #
1004 # else:
1005 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, NaN)
1006 #
1007 #
1008 # # print '********************************************'
1009 # # print 'HalfWidth ', HalfWidth
1010 # # print 'Maximun ', Maximun
1011 # # print 'eMinus1 ', eMinus1
1012 # # print 'Rangpos ', Rangpos
1013 # # print 'GaussCenter ',GaussCenter
1014 # # print 'E01 ',E01
1015 # # print 'N01 ',N01
1016 # # print 'E02 ',E02
1017 # # print 'N02 ',N02
1018 # # print 'E12 ',E12
1019 # # print 'N12 ',N12
1020 # #print 'self.dataOut.velocityX ', self.dataOut.velocityX
1021 # # print 'Fij ', Fij
1022 # # print 'cC ', cC
1023 # # print 'cF ', cF
1024 # # print 'cG ', cG
1025 # # print 'cA ', cA
1026 # # print 'cB ', cB
1027 # # print 'cH ', cH
1028 # # print 'Vx ', Vx
1029 # # print 'Vy ', Vy
1030 # # print 'Vmag ', Vmag
1031 # # print 'Vang ', Vang*180/numpy.pi
1032 # # print 'PhaseSlope ',PhaseSlope[0]
1033 # # print 'PhaseSlope ',PhaseSlope[1]
1034 # # print 'PhaseSlope ',PhaseSlope[2]
1035 # # print '********************************************'
1036 # #print 'data_output',shape(self.dataOut.velocityX), shape(self.dataOut.velocityY)
1037 #
1038 # #print 'self.dataOut.velocityX', len(self.dataOut.velocityX)
1039 # #print 'self.dataOut.velocityY', len(self.dataOut.velocityY)
1040 # #print 'self.dataOut.velocityV', self.dataOut.velocityV
1041 #
1042 # self.data_output[0]=numpy.array(self.dataOut.velocityX)
1043 # self.data_output[1]=numpy.array(self.dataOut.velocityY)
1044 # self.data_output[2]=numpy.array(self.dataOut.velocityV)
1045 #
1046 # prin= self.data_output[0][~numpy.isnan(self.data_output[0])]
1047 # print ' '
1048 # print 'VmagAverage',numpy.mean(prin)
1049 # print ' '
1050 # # plt.figure(5)
1051 # # plt.subplot(211)
1052 # # plt.plot(self.dataOut.velocityX,'yo:')
1053 # # plt.subplot(212)
1054 # # plt.plot(self.dataOut.velocityY,'yo:')
1055 #
1056 # # plt.figure(1)
1057 # # # plt.subplot(121)
1058 # # # plt.plot(xFrec,ySamples[0],'k',label='Ch0')
1059 # # # plt.plot(xFrec,ySamples[1],'g',label='Ch1')
1060 # # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1061 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1062 # # # plt.legend()
1063 # # plt.title('DATOS A ALTURA DE 2850 METROS')
1064 # #
1065 # # plt.xlabel('Frecuencia (KHz)')
1066 # # plt.ylabel('Magnitud')
1067 # # # plt.subplot(122)
1068 # # # plt.title('Fit for Time Constant')
1069 # # #plt.plot(xFrec,zline)
1070 # # #plt.plot(xFrec,SmoothSPC,'g')
1071 # # plt.plot(xFrec,FactNorm)
1072 # # plt.axis([-4, 4, 0, 0.15])
1073 # # # plt.xlabel('SelfSpectra KHz')
1074 # #
1075 # # plt.figure(10)
1076 # # # plt.subplot(121)
1077 # # plt.plot(xFrec,ySamples[0],'b',label='Ch0')
1078 # # plt.plot(xFrec,ySamples[1],'y',label='Ch1')
1079 # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1080 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1081 # # plt.legend()
1082 # # plt.title('SELFSPECTRA EN CANALES')
1083 # #
1084 # # plt.xlabel('Frecuencia (KHz)')
1085 # # plt.ylabel('Magnitud')
1086 # # # plt.subplot(122)
1087 # # # plt.title('Fit for Time Constant')
1088 # # #plt.plot(xFrec,zline)
1089 # # #plt.plot(xFrec,SmoothSPC,'g')
1090 # # # plt.plot(xFrec,FactNorm)
1091 # # # plt.axis([-4, 4, 0, 0.15])
1092 # # # plt.xlabel('SelfSpectra KHz')
1093 # #
1094 # # plt.figure(9)
1095 # #
1096 # #
1097 # # plt.title('DATOS SUAVIZADOS')
1098 # # plt.xlabel('Frecuencia (KHz)')
1099 # # plt.ylabel('Magnitud')
1100 # # plt.plot(xFrec,SmoothSPC,'g')
1101 # #
1102 # # #plt.plot(xFrec,FactNorm)
1103 # # plt.axis([-4, 4, 0, 0.15])
1104 # # # plt.xlabel('SelfSpectra KHz')
1105 # # #
1106 # # plt.figure(2)
1107 # # # #plt.subplot(121)
1108 # # plt.plot(xFrec,yMean,'r',label='Mean SelfSpectra')
1109 # # plt.plot(xFrec,FitGauss,'yo:',label='Ajuste Gaussiano')
1110 # # # plt.plot(xFrec[Rangpos],FitGauss[Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.1)))],'bo')
1111 # # # #plt.plot(xFrec,phase)
1112 # # # plt.xlabel('Suavizado, promediado KHz')
1113 # # plt.title('SELFSPECTRA PROMEDIADO')
1114 # # # #plt.subplot(122)
1115 # # # #plt.plot(xSamples,zline)
1116 # # plt.xlabel('Frecuencia (KHz)')
1117 # # plt.ylabel('Magnitud')
1118 # # plt.legend()
1119 # # #
1120 # # # plt.figure(3)
1121 # # # plt.subplot(311)
1122 # # # #plt.plot(xFrec,phase[0])
1123 # # # plt.plot(xFrec,phase[0],'g')
1124 # # # plt.subplot(312)
1125 # # # plt.plot(xFrec,phase[1],'g')
1126 # # # plt.subplot(313)
1127 # # # plt.plot(xFrec,phase[2],'g')
1128 # # # #plt.plot(xFrec,phase[2])
1129 # # #
1130 # # # plt.figure(4)
1131 # # #
1132 # # # plt.plot(xSamples,coherence[0],'b')
1133 # # # plt.plot(xSamples,coherence[1],'r')
1134 # # # plt.plot(xSamples,coherence[2],'g')
1135 # # plt.show()
1136 # # #
1137 # # # plt.clf()
1138 # # # plt.cla()
1139 # # # plt.close()
1140 #
1141 # print ' '
1142
1143
1144
1145 self.BlockCounter+=2
1146
1147 else:
1148 self.fileSelector+=1
1149 self.BlockCounter=0
1150 print "Next File"
1151
1152
1153
1154
1155
@@ -1,1091 +1,1095
1 1 import numpy
2 2 import time
3 3 import os
4 4 import h5py
5 5 import re
6 6 import datetime
7 7
8 8 from schainpy.model.data.jrodata import *
9 9 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
10 10 # from jroIO_base import *
11 11 from schainpy.model.io.jroIO_base import *
12 12 import schainpy
13 13
14 14
15 15 class ParamReader(ProcessingUnit):
16 16 '''
17 17 Reads HDF5 format files
18 18
19 19 path
20 20
21 21 startDate
22 22
23 23 endDate
24 24
25 25 startTime
26 26
27 27 endTime
28 28 '''
29 29
30 30 ext = ".hdf5"
31 31
32 32 optchar = "D"
33 33
34 34 timezone = None
35 35
36 36 startTime = None
37 37
38 38 endTime = None
39 39
40 40 fileIndex = None
41 41
42 42 utcList = None #To select data in the utctime list
43 43
44 44 blockList = None #List to blocks to be read from the file
45 45
46 46 blocksPerFile = None #Number of blocks to be read
47 47
48 48 blockIndex = None
49 49
50 50 path = None
51 51
52 52 #List of Files
53 53
54 54 filenameList = None
55 55
56 56 datetimeList = None
57 57
58 58 #Hdf5 File
59 59
60 60 listMetaname = None
61 61
62 62 listMeta = None
63 63
64 64 listDataname = None
65 65
66 66 listData = None
67 67
68 68 listShapes = None
69 69
70 70 fp = None
71 71
72 72 #dataOut reconstruction
73 73
74 74 dataOut = None
75 75
76 76
77 77 def __init__(self, **kwargs):
78 78 ProcessingUnit.__init__(self, **kwargs)
79 79 self.dataOut = Parameters()
80 80 return
81 81
82 82 def setup(self, **kwargs):
83 83
84 84 path = kwargs['path']
85 85 startDate = kwargs['startDate']
86 86 endDate = kwargs['endDate']
87 87 startTime = kwargs['startTime']
88 88 endTime = kwargs['endTime']
89 89 walk = kwargs['walk']
90 90 if kwargs.has_key('ext'):
91 91 ext = kwargs['ext']
92 92 else:
93 93 ext = '.hdf5'
94 94 if kwargs.has_key('timezone'):
95 95 self.timezone = kwargs['timezone']
96 96 else:
97 97 self.timezone = 'lt'
98 98
99 99 print "[Reading] Searching files in offline mode ..."
100 100 pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate,
101 101 startTime=startTime, endTime=endTime,
102 102 ext=ext, walk=walk)
103 103
104 104 if not(filenameList):
105 105 print "There is no files into the folder: %s"%(path)
106 106 sys.exit(-1)
107 107
108 108 self.fileIndex = -1
109 109 self.startTime = startTime
110 110 self.endTime = endTime
111 111
112 112 self.__readMetadata()
113 113
114 114 self.__setNextFileOffline()
115 115
116 116 return
117 117
118 118 def __searchFilesOffLine(self,
119 119 path,
120 120 startDate=None,
121 121 endDate=None,
122 122 startTime=datetime.time(0,0,0),
123 123 endTime=datetime.time(23,59,59),
124 124 ext='.hdf5',
125 125 walk=True):
126 126
127 127 expLabel = ''
128 128 self.filenameList = []
129 129 self.datetimeList = []
130 130
131 131 pathList = []
132 132
133 133 JRODataObj = JRODataReader()
134 134 dateList, pathList = JRODataObj.findDatafiles(path, startDate, endDate, expLabel, ext, walk, include_path=True)
135 135
136 136 if dateList == []:
137 137 print "[Reading] No *%s files in %s from %s to %s)"%(ext, path,
138 138 datetime.datetime.combine(startDate,startTime).ctime(),
139 139 datetime.datetime.combine(endDate,endTime).ctime())
140 140
141 141 return None, None
142 142
143 143 if len(dateList) > 1:
144 144 print "[Reading] %d days were found in date range: %s - %s" %(len(dateList), startDate, endDate)
145 145 else:
146 146 print "[Reading] data was found for the date %s" %(dateList[0])
147 147
148 148 filenameList = []
149 149 datetimeList = []
150 150
151 151 #----------------------------------------------------------------------------------
152 152
153 153 for thisPath in pathList:
154 154 # thisPath = pathList[pathDict[file]]
155 155
156 156 fileList = glob.glob1(thisPath, "*%s" %ext)
157 157 fileList.sort()
158 158
159 159 for file in fileList:
160 160
161 161 filename = os.path.join(thisPath,file)
162 162
163 163 if not isFileInDateRange(filename, startDate, endDate):
164 164 continue
165 165
166 166 thisDatetime = self.__isFileInTimeRange(filename, startDate, endDate, startTime, endTime)
167 167
168 168 if not(thisDatetime):
169 169 continue
170 170
171 171 filenameList.append(filename)
172 172 datetimeList.append(thisDatetime)
173 173
174 174 if not(filenameList):
175 175 print "[Reading] Any file was found int time range %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
176 176 return None, None
177 177
178 178 print "[Reading] %d file(s) was(were) found in time range: %s - %s" %(len(filenameList), startTime, endTime)
179 179 print
180 180
181 181 # for i in range(len(filenameList)):
182 182 # print "[Reading] %s -> [%s]" %(filenameList[i], datetimeList[i].ctime())
183 183
184 184 self.filenameList = filenameList
185 185 self.datetimeList = datetimeList
186 186
187 187 return pathList, filenameList
188 188
189 189 def __isFileInTimeRange(self,filename, startDate, endDate, startTime, endTime):
190 190
191 191 """
192 192 Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
193 193
194 194 Inputs:
195 195 filename : nombre completo del archivo de datos en formato Jicamarca (.r)
196 196
197 197 startDate : fecha inicial del rango seleccionado en formato datetime.date
198 198
199 199 endDate : fecha final del rango seleccionado en formato datetime.date
200 200
201 201 startTime : tiempo inicial del rango seleccionado en formato datetime.time
202 202
203 203 endTime : tiempo final del rango seleccionado en formato datetime.time
204 204
205 205 Return:
206 206 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
207 207 fecha especificado, de lo contrario retorna False.
208 208
209 209 Excepciones:
210 210 Si el archivo no existe o no puede ser abierto
211 211 Si la cabecera no puede ser leida.
212 212
213 213 """
214 214
215 215 try:
216 216 fp = h5py.File(filename,'r')
217 217 grp1 = fp['Data']
218 218
219 219 except IOError:
220 220 traceback.print_exc()
221 221 raise IOError, "The file %s can't be opened" %(filename)
222 222 #chino rata
223 223 #In case has utctime attribute
224 224 grp2 = grp1['utctime']
225 225 # thisUtcTime = grp2.value[0] - 5*3600 #To convert to local time
226 226 thisUtcTime = grp2.value[0]
227 227
228 228 fp.close()
229 229
230 230 if self.timezone == 'lt':
231 231 thisUtcTime -= 5*3600
232 232
233 233 thisDatetime = datetime.datetime.fromtimestamp(thisUtcTime[0] + 5*3600)
234 234 # thisDatetime = datetime.datetime.fromtimestamp(thisUtcTime[0])
235 235 thisDate = thisDatetime.date()
236 236 thisTime = thisDatetime.time()
237 237
238 238 startUtcTime = (datetime.datetime.combine(thisDate,startTime)- datetime.datetime(1970, 1, 1)).total_seconds()
239 239 endUtcTime = (datetime.datetime.combine(thisDate,endTime)- datetime.datetime(1970, 1, 1)).total_seconds()
240 240
241 241 #General case
242 242 # o>>>>>>>>>>>>>><<<<<<<<<<<<<<o
243 243 #-----------o----------------------------o-----------
244 244 # startTime endTime
245 245
246 246 if endTime >= startTime:
247 247 thisUtcLog = numpy.logical_and(thisUtcTime > startUtcTime, thisUtcTime < endUtcTime)
248 248 if numpy.any(thisUtcLog): #If there is one block between the hours mentioned
249 249 return thisDatetime
250 250 return None
251 251
252 252 #If endTime < startTime then endTime belongs to the next day
253 253 #<<<<<<<<<<<o o>>>>>>>>>>>
254 254 #-----------o----------------------------o-----------
255 255 # endTime startTime
256 256
257 257 if (thisDate == startDate) and numpy.all(thisUtcTime < startUtcTime):
258 258 return None
259 259
260 260 if (thisDate == endDate) and numpy.all(thisUtcTime > endUtcTime):
261 261 return None
262 262
263 263 if numpy.all(thisUtcTime < startUtcTime) and numpy.all(thisUtcTime > endUtcTime):
264 264 return None
265 265
266 266 return thisDatetime
267 267
268 268 def __setNextFileOffline(self):
269 269
270 270 self.fileIndex += 1
271 271 idFile = self.fileIndex
272 272
273 273 if not(idFile < len(self.filenameList)):
274 274 print "No more Files"
275 275 return 0
276 276
277 277 filename = self.filenameList[idFile]
278 278
279 279 filePointer = h5py.File(filename,'r')
280 280
281 281 self.filename = filename
282 282
283 283 self.fp = filePointer
284 284
285 285 print "Setting the file: %s"%self.filename
286 286
287 287 # self.__readMetadata()
288 288 self.__setBlockList()
289 289 self.__readData()
290 290 # self.nRecords = self.fp['Data'].attrs['blocksPerFile']
291 291 # self.nRecords = self.fp['Data'].attrs['nRecords']
292 292 self.blockIndex = 0
293 293 return 1
294 294
295 295 def __setBlockList(self):
296 296 '''
297 297 Selects the data within the times defined
298 298
299 299 self.fp
300 300 self.startTime
301 301 self.endTime
302 302
303 303 self.blockList
304 304 self.blocksPerFile
305 305
306 306 '''
307 307 fp = self.fp
308 308 startTime = self.startTime
309 309 endTime = self.endTime
310 310
311 311 grp = fp['Data']
312 312 thisUtcTime = grp['utctime'].value.astype(numpy.float)[0]
313 313
314 314 #ERROOOOR
315 315 if self.timezone == 'lt':
316 316 thisUtcTime -= 5*3600
317 317
318 318 thisDatetime = datetime.datetime.fromtimestamp(thisUtcTime[0] + 5*3600)
319 319
320 320 thisDate = thisDatetime.date()
321 321 thisTime = thisDatetime.time()
322 322
323 323 startUtcTime = (datetime.datetime.combine(thisDate,startTime) - datetime.datetime(1970, 1, 1)).total_seconds()
324 324 endUtcTime = (datetime.datetime.combine(thisDate,endTime) - datetime.datetime(1970, 1, 1)).total_seconds()
325 325
326 326 ind = numpy.where(numpy.logical_and(thisUtcTime >= startUtcTime, thisUtcTime < endUtcTime))[0]
327 327
328 328 self.blockList = ind
329 329 self.blocksPerFile = len(ind)
330 330
331 331 return
332 332
333 333 def __readMetadata(self):
334 334 '''
335 335 Reads Metadata
336 336
337 337 self.pathMeta
338 338
339 339 self.listShapes
340 340 self.listMetaname
341 341 self.listMeta
342 342
343 343 '''
344 344
345 345 # grp = self.fp['Data']
346 346 # pathMeta = os.path.join(self.path, grp.attrs['metadata'])
347 347 #
348 348 # if pathMeta == self.pathMeta:
349 349 # return
350 350 # else:
351 351 # self.pathMeta = pathMeta
352 352 #
353 353 # filePointer = h5py.File(self.pathMeta,'r')
354 354 # groupPointer = filePointer['Metadata']
355 355
356 356 filename = self.filenameList[0]
357 357
358 358 fp = h5py.File(filename,'r')
359 359
360 360 gp = fp['Metadata']
361 361
362 362 listMetaname = []
363 363 listMetadata = []
364 364 for item in gp.items():
365 365 name = item[0]
366 366
367 367 if name=='array dimensions':
368 368 table = gp[name][:]
369 369 listShapes = {}
370 370 for shapes in table:
371 371 listShapes[shapes[0]] = numpy.array([shapes[1],shapes[2],shapes[3],shapes[4],shapes[5]])
372 372 else:
373 373 data = gp[name].value
374 374 listMetaname.append(name)
375 375 listMetadata.append(data)
376 376
377 377 # if name=='type':
378 378 # self.__initDataOut(data)
379 379
380 380 self.listShapes = listShapes
381 381 self.listMetaname = listMetaname
382 382 self.listMeta = listMetadata
383 383
384 384 fp.close()
385 385 return
386 386
387 387 def __readData(self):
388 388 grp = self.fp['Data']
389 389 listdataname = []
390 390 listdata = []
391 391
392 392 for item in grp.items():
393 393 name = item[0]
394 394 listdataname.append(name)
395 395
396 396 array = self.__setDataArray(grp[name],self.listShapes[name])
397 397 listdata.append(array)
398 398
399 399 self.listDataname = listdataname
400 400 self.listData = listdata
401 401 return
402 402
403 403 def __setDataArray(self, dataset, shapes):
404 404
405 405 nDims = shapes[0]
406 406
407 407 nDim2 = shapes[1] #Dimension 0
408 408
409 409 nDim1 = shapes[2] #Dimension 1, number of Points or Parameters
410 410
411 411 nDim0 = shapes[3] #Dimension 2, number of samples or ranges
412 412
413 413 mode = shapes[4] #Mode of storing
414 414
415 415 blockList = self.blockList
416 416
417 417 blocksPerFile = self.blocksPerFile
418 418
419 419 #Depending on what mode the data was stored
420 420 if mode == 0: #Divided in channels
421 421 arrayData = dataset.value.astype(numpy.float)[0][blockList]
422 422 if mode == 1: #Divided in parameter
423 423 strds = 'table'
424 424 nDatas = nDim1
425 425 newShapes = (blocksPerFile,nDim2,nDim0)
426 426 elif mode==2: #Concatenated in a table
427 427 strds = 'table0'
428 428 arrayData = dataset[strds].value
429 429 #Selecting part of the dataset
430 430 utctime = arrayData[:,0]
431 431 u, indices = numpy.unique(utctime, return_index=True)
432 432
433 433 if blockList.size != indices.size:
434 434 indMin = indices[blockList[0]]
435 435 if blockList[1] + 1 >= indices.size:
436 436 arrayData = arrayData[indMin:,:]
437 437 else:
438 438 indMax = indices[blockList[1] + 1]
439 439 arrayData = arrayData[indMin:indMax,:]
440 440 return arrayData
441 441
442 442 # One dimension
443 443 if nDims == 0:
444 444 arrayData = dataset.value.astype(numpy.float)[0][blockList]
445 445
446 446 # Two dimensions
447 447 elif nDims == 2:
448 448 arrayData = numpy.zeros((blocksPerFile,nDim1,nDim0))
449 449 newShapes = (blocksPerFile,nDim0)
450 450 nDatas = nDim1
451 451
452 452 for i in range(nDatas):
453 453 data = dataset[strds + str(i)].value
454 454 arrayData[:,i,:] = data[blockList,:]
455 455
456 456 # Three dimensions
457 457 else:
458 458 arrayData = numpy.zeros((blocksPerFile,nDim2,nDim1,nDim0))
459 459 for i in range(nDatas):
460 460
461 461 data = dataset[strds + str(i)].value
462 462
463 463 for b in range(blockList.size):
464 464 arrayData[b,:,i,:] = data[:,:,blockList[b]]
465 465
466 466 return arrayData
467 467
468 468 def __setDataOut(self):
469 469 listMeta = self.listMeta
470 470 listMetaname = self.listMetaname
471 471 listDataname = self.listDataname
472 472 listData = self.listData
473 473 listShapes = self.listShapes
474 474
475 475 blockIndex = self.blockIndex
476 476 # blockList = self.blockList
477 477
478 478 for i in range(len(listMeta)):
479 479 setattr(self.dataOut,listMetaname[i],listMeta[i])
480 480
481 481 for j in range(len(listData)):
482 482 nShapes = listShapes[listDataname[j]][0]
483 483 mode = listShapes[listDataname[j]][4]
484 484 if nShapes == 1:
485 485 setattr(self.dataOut,listDataname[j],listData[j][blockIndex])
486 486 elif nShapes > 1:
487 487 setattr(self.dataOut,listDataname[j],listData[j][blockIndex,:])
488 488 elif mode==0:
489 489 setattr(self.dataOut,listDataname[j],listData[j][blockIndex])
490 490 #Mode Meteors
491 491 elif mode ==2:
492 492 selectedData = self.__selectDataMode2(listData[j], blockIndex)
493 493 setattr(self.dataOut, listDataname[j], selectedData)
494 494 return
495 495
496 496 def __selectDataMode2(self, data, blockIndex):
497 497 utctime = data[:,0]
498 498 aux, indices = numpy.unique(utctime, return_inverse=True)
499 499 selInd = numpy.where(indices == blockIndex)[0]
500 500 selData = data[selInd,:]
501 501
502 502 return selData
503 503
504 504 def getData(self):
505 505
506 506 # if self.flagNoMoreFiles:
507 507 # self.dataOut.flagNoData = True
508 508 # print 'Process finished'
509 509 # return 0
510 510 #
511 511 if self.blockIndex==self.blocksPerFile:
512 512 if not( self.__setNextFileOffline() ):
513 513 self.dataOut.flagNoData = True
514 514 return 0
515 515
516 516 # if self.datablock == None: # setear esta condicion cuando no hayan datos por leers
517 517 # self.dataOut.flagNoData = True
518 518 # return 0
519 519 # self.__readData()
520 520 self.__setDataOut()
521 521 self.dataOut.flagNoData = False
522 522
523 523 self.blockIndex += 1
524 524
525 525 return
526 526
527 527 def run(self, **kwargs):
528 528
529 529 if not(self.isConfig):
530 530 self.setup(**kwargs)
531 531 # self.setObjProperties()
532 532 self.isConfig = True
533 533
534 534 self.getData()
535 535
536 536 return
537 537
538 538 class ParamWriter(Operation):
539 539 '''
540 540 HDF5 Writer, stores parameters data in HDF5 format files
541 541
542 542 path: path where the files will be stored
543 543
544 544 blocksPerFile: number of blocks that will be saved in per HDF5 format file
545 545
546 546 mode: selects the data stacking mode: '0' channels, '1' parameters, '3' table (for meteors)
547 547
548 548 metadataList: list of attributes that will be stored as metadata
549 549
550 550 dataList: list of attributes that will be stores as data
551 551
552 552 '''
553 553
554 554
555 555 ext = ".hdf5"
556 556
557 557 optchar = "D"
558 558
559 559 metaoptchar = "M"
560 560
561 561 metaFile = None
562 562
563 563 filename = None
564 564
565 565 path = None
566 566
567 567 setFile = None
568 568
569 569 fp = None
570 570
571 571 grp = None
572 572
573 573 ds = None
574 574
575 575 firsttime = True
576 576
577 577 #Configurations
578 578
579 579 blocksPerFile = None
580 580
581 581 blockIndex = None
582 582
583 583 dataOut = None
584 584
585 585 #Data Arrays
586 586
587 587 dataList = None
588 588
589 589 metadataList = None
590 590
591 591 # arrayDim = None
592 592
593 593 dsList = None #List of dictionaries with dataset properties
594 594
595 595 tableDim = None
596 596
597 597 # dtype = [('arrayName', 'S20'),('nChannels', 'i'), ('nPoints', 'i'), ('nSamples', 'i'),('mode', 'b')]
598 598
599 599 dtype = [('arrayName', 'S20'),('nDimensions', 'i'), ('dim2', 'i'), ('dim1', 'i'),('dim0', 'i'),('mode', 'b')]
600 600
601 601 currentDay = None
602 602
603 603 lastTime = None
604 604
605 605 def __init__(self, **kwargs):
606 606 Operation.__init__(self, **kwargs)
607 607 self.isConfig = False
608 608 return
609 609
610 610 def setup(self, dataOut, **kwargs):
611 611
612 612 self.path = kwargs['path']
613 613
614 614 if kwargs.has_key('blocksPerFile'):
615 615 self.blocksPerFile = kwargs['blocksPerFile']
616 616 else:
617 617 self.blocksPerFile = 10
618 618
619 619 self.metadataList = kwargs['metadataList']
620 620 self.dataList = kwargs['dataList']
621 621 self.dataOut = dataOut
622 622
623 623 if kwargs.has_key('mode'):
624 624 mode = kwargs['mode']
625 625
626 626 if type(mode) == int:
627 627 mode = numpy.zeros(len(self.dataList)) + mode
628 628 else:
629 629 mode = numpy.ones(len(self.dataList))
630 630
631 631 self.mode = mode
632 632
633 633 arrayDim = numpy.zeros((len(self.dataList),5))
634 634
635 635 #Table dimensions
636 636 dtype0 = self.dtype
637 637 tableList = []
638 638
639 639 #Dictionary and list of tables
640 640 dsList = []
641 641
642 642 for i in range(len(self.dataList)):
643 643 dsDict = {}
644 644 dataAux = getattr(self.dataOut, self.dataList[i])
645 645 dsDict['variable'] = self.dataList[i]
646 646 #--------------------- Conditionals ------------------------
647 647 #There is no data
648
649
648 650 if dataAux is None:
651
649 652 return 0
650 653
651 654 #Not array, just a number
652 655 #Mode 0
653 656 if type(dataAux)==float or type(dataAux)==int:
654 657 dsDict['mode'] = 0
655 658 dsDict['nDim'] = 0
656 659 arrayDim[i,0] = 0
657 660 dsList.append(dsDict)
658 661
659 662 #Mode 2: meteors
660 663 elif mode[i] == 2:
661 664 # dsDict['nDim'] = 0
662 665 dsDict['dsName'] = 'table0'
663 666 dsDict['mode'] = 2 # Mode meteors
664 667 dsDict['shape'] = dataAux.shape[-1]
665 668 dsDict['nDim'] = 0
666 669 dsDict['dsNumber'] = 1
667 670
668 671 arrayDim[i,3] = dataAux.shape[-1]
669 672 arrayDim[i,4] = mode[i] #Mode the data was stored
670 673
671 674 dsList.append(dsDict)
672 675
673 676 #Mode 1
674 677 else:
675 678 arrayDim0 = dataAux.shape #Data dimensions
676 679 arrayDim[i,0] = len(arrayDim0) #Number of array dimensions
677 680 arrayDim[i,4] = mode[i] #Mode the data was stored
678 681
679 682 strtable = 'table'
680 683 dsDict['mode'] = 1 # Mode parameters
681 684
682 685 # Three-dimension arrays
683 686 if len(arrayDim0) == 3:
684 687 arrayDim[i,1:-1] = numpy.array(arrayDim0)
685 688 nTables = int(arrayDim[i,2])
686 689 dsDict['dsNumber'] = nTables
687 690 dsDict['shape'] = arrayDim[i,2:4]
688 691 dsDict['nDim'] = 3
689 692
690 693 for j in range(nTables):
691 694 dsDict = dsDict.copy()
692 695 dsDict['dsName'] = strtable + str(j)
693 696 dsList.append(dsDict)
694 697
695 698 # Two-dimension arrays
696 699 elif len(arrayDim0) == 2:
697 700 arrayDim[i,2:-1] = numpy.array(arrayDim0)
698 701 nTables = int(arrayDim[i,2])
699 702 dsDict['dsNumber'] = nTables
700 703 dsDict['shape'] = arrayDim[i,3]
701 704 dsDict['nDim'] = 2
702 705
703 706 for j in range(nTables):
704 707 dsDict = dsDict.copy()
705 708 dsDict['dsName'] = strtable + str(j)
706 709 dsList.append(dsDict)
707 710
708 711 # One-dimension arrays
709 712 elif len(arrayDim0) == 1:
710 713 arrayDim[i,3] = arrayDim0[0]
711 714 dsDict['shape'] = arrayDim0[0]
712 715 dsDict['dsNumber'] = 1
713 716 dsDict['dsName'] = strtable + str(0)
714 717 dsDict['nDim'] = 1
715 718 dsList.append(dsDict)
716 719
717 720 table = numpy.array((self.dataList[i],) + tuple(arrayDim[i,:]),dtype = dtype0)
718 721 tableList.append(table)
719 722
720 723 # self.arrayDim = arrayDim
721 724 self.dsList = dsList
722 725 self.tableDim = numpy.array(tableList, dtype = dtype0)
723 726 self.blockIndex = 0
724 727
725 728 timeTuple = time.localtime(dataOut.utctime)
726 729 self.currentDay = timeTuple.tm_yday
727 730 return 1
728 731
729 732 def putMetadata(self):
730 733
731 734 fp = self.createMetadataFile()
732 735 self.writeMetadata(fp)
733 736 fp.close()
734 737 return
735 738
736 739 def createMetadataFile(self):
737 740 ext = self.ext
738 741 path = self.path
739 742 setFile = self.setFile
740 743
741 744 timeTuple = time.localtime(self.dataOut.utctime)
742 745
743 746 subfolder = ''
744 747 fullpath = os.path.join( path, subfolder )
745 748
746 749 if not( os.path.exists(fullpath) ):
747 750 os.mkdir(fullpath)
748 751 setFile = -1 #inicializo mi contador de seteo
749 752
750 753 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
751 754 fullpath = os.path.join( path, subfolder )
752 755
753 756 if not( os.path.exists(fullpath) ):
754 757 os.mkdir(fullpath)
755 758 setFile = -1 #inicializo mi contador de seteo
756 759
757 760 else:
758 761 filesList = os.listdir( fullpath )
759 762 filesList = sorted( filesList, key=str.lower )
760 763 if len( filesList ) > 0:
761 764 filesList = [k for k in filesList if 'M' in k]
762 765 filen = filesList[-1]
763 766 # el filename debera tener el siguiente formato
764 767 # 0 1234 567 89A BCDE (hex)
765 768 # x YYYY DDD SSS .ext
766 769 if isNumber( filen[8:11] ):
767 770 setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file
768 771 else:
769 772 setFile = -1
770 773 else:
771 774 setFile = -1 #inicializo mi contador de seteo
772 775
773 776 setFile += 1
774 777
775 778 file = '%s%4.4d%3.3d%3.3d%s' % (self.metaoptchar,
776 779 timeTuple.tm_year,
777 780 timeTuple.tm_yday,
778 781 setFile,
779 782 ext )
780 783
781 784 filename = os.path.join( path, subfolder, file )
782 785 self.metaFile = file
783 786 #Setting HDF5 File
784 787 fp = h5py.File(filename,'w')
785 788
786 789 return fp
787 790
788 791 def writeMetadata(self, fp):
789 792
790 793 grp = fp.create_group("Metadata")
791 794 grp.create_dataset('array dimensions', data = self.tableDim, dtype = self.dtype)
792 795
793 796 for i in range(len(self.metadataList)):
794 797 print '#####',self.metadataList[i], getattr(self.dataOut, self.metadataList[i])
795 798 grp.create_dataset(self.metadataList[i], data=getattr(self.dataOut, self.metadataList[i]))
796 799 return
797 800
798 801 def timeFlag(self):
799 802 currentTime = self.dataOut.utctime
800 803
801 804 if self.lastTime is None:
802 805 self.lastTime = currentTime
803 806
804 807 #Day
805 808 timeTuple = time.localtime(currentTime)
806 809 dataDay = timeTuple.tm_yday
807 810
808 811 #Time
809 812 timeDiff = currentTime - self.lastTime
810 813
811 814 #Si el dia es diferente o si la diferencia entre un dato y otro supera la hora
812 815 if dataDay != self.currentDay:
813 816 self.currentDay = dataDay
814 817 return True
815 818 elif timeDiff > 3*60*60:
816 819 self.lastTime = currentTime
817 820 return True
818 821 else:
819 822 self.lastTime = currentTime
820 823 return False
821 824
822 825 def setNextFile(self):
823
826
824 827 ext = self.ext
825 828 path = self.path
826 829 setFile = self.setFile
827 830 mode = self.mode
828 831
829 832 timeTuple = time.localtime(self.dataOut.utctime)
830 833 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
831 834
832 835 fullpath = os.path.join( path, subfolder )
833 836
834 837 if os.path.exists(fullpath):
835 838 filesList = os.listdir( fullpath )
836 839 filesList = [k for k in filesList if 'D' in k]
837 840 if len( filesList ) > 0:
838 841 filesList = sorted( filesList, key=str.lower )
839 842 filen = filesList[-1]
840 843 # el filename debera tener el siguiente formato
841 844 # 0 1234 567 89A BCDE (hex)
842 845 # x YYYY DDD SSS .ext
843 846 if isNumber( filen[8:11] ):
844 847 setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file
845 848 else:
846 849 setFile = -1
847 850 else:
848 851 setFile = -1 #inicializo mi contador de seteo
849 852 else:
850 853 os.makedirs(fullpath)
851 854 setFile = -1 #inicializo mi contador de seteo
852 855
853 856 setFile += 1
854 857
855 858 file = '%s%4.4d%3.3d%3.3d%s' % (self.optchar,
856 859 timeTuple.tm_year,
857 860 timeTuple.tm_yday,
858 861 setFile,
859 862 ext )
860 863
861 864 filename = os.path.join( path, subfolder, file )
862 865
863 866 #Setting HDF5 File
864 867 fp = h5py.File(filename,'w')
865 868 #write metadata
866 869 self.writeMetadata(fp)
867 870 #Write data
868 871 grp = fp.create_group("Data")
869 872 # grp.attrs['metadata'] = self.metaFile
870 873
871 874 # grp.attrs['blocksPerFile'] = 0
872 875 ds = []
873 876 data = []
874 877 dsList = self.dsList
875 878 i = 0
876 879 while i < len(dsList):
877 880 dsInfo = dsList[i]
878 881 #One-dimension data
879 882 if dsInfo['mode'] == 0:
880 883 # ds0 = grp.create_dataset(self.dataList[i], (1,1), maxshape=(1,self.blocksPerFile) , chunks = True, dtype='S20')
881 884 ds0 = grp.create_dataset(dsInfo['variable'], (1,1), maxshape=(1,self.blocksPerFile) , chunks = True, dtype=numpy.float64)
882 885 ds.append(ds0)
883 886 data.append([])
884 887 i += 1
885 888 continue
886 889 # nDimsForDs.append(nDims[i])
887 890
888 891 elif dsInfo['mode'] == 2:
889 892 grp0 = grp.create_group(dsInfo['variable'])
890 893 ds0 = grp0.create_dataset(dsInfo['dsName'], (1,dsInfo['shape']), data = numpy.zeros((1,dsInfo['shape'])) , maxshape=(None,dsInfo['shape']), chunks=True)
891 894 ds.append(ds0)
892 895 data.append([])
893 896 i += 1
894 897 continue
895 898
896 899 elif dsInfo['mode'] == 1:
897 900 grp0 = grp.create_group(dsInfo['variable'])
898 901
899 902 for j in range(dsInfo['dsNumber']):
900 903 dsInfo = dsList[i]
901 904 tableName = dsInfo['dsName']
902 905 shape = int(dsInfo['shape'])
903 906
904 907 if dsInfo['nDim'] == 3:
905 908 ds0 = grp0.create_dataset(tableName, (shape[0],shape[1],1) , data = numpy.zeros((shape[0],shape[1],1)), maxshape = (None,shape[1],None), chunks=True)
906 909 else:
907 910 ds0 = grp0.create_dataset(tableName, (1,shape), data = numpy.zeros((1,shape)) , maxshape=(None,shape), chunks=True)
908 911
909 912 ds.append(ds0)
910 913 data.append([])
911 914 i += 1
912 915 # nDimsForDs.append(nDims[i])
913 916
914 917 fp.flush()
915 918 fp.close()
916 919
917 920 # self.nDatas = nDatas
918 921 # self.nDims = nDims
919 922 # self.nDimsForDs = nDimsForDs
920 923 #Saving variables
921 924 print 'Writing the file: %s'%filename
922 925 self.filename = filename
923 926 # self.fp = fp
924 927 # self.grp = grp
925 928 # self.grp.attrs.modify('nRecords', 1)
926 929 self.ds = ds
927 930 self.data = data
928 931 # self.setFile = setFile
929 932 self.firsttime = True
930 933 self.blockIndex = 0
931 934 return
932 935
933 936 def putData(self):
934 937
935 938 if self.blockIndex == self.blocksPerFile or self.timeFlag():
936 939 self.setNextFile()
937 940
938 941 # if not self.firsttime:
939 942 self.readBlock()
940 943 self.setBlock() #Prepare data to be written
941 944 self.writeBlock() #Write data
942 945
943 946 return
944 947
945 948 def readBlock(self):
946 949
947 950 '''
948 951 data Array configured
949 952
950 953
951 954 self.data
952 955 '''
953 956 dsList = self.dsList
954 957 ds = self.ds
955 958 #Setting HDF5 File
956 959 fp = h5py.File(self.filename,'r+')
957 960 grp = fp["Data"]
958 961 ind = 0
959 962
960 963 # grp.attrs['blocksPerFile'] = 0
961 964 while ind < len(dsList):
962 965 dsInfo = dsList[ind]
963 966
964 967 if dsInfo['mode'] == 0:
965 968 ds0 = grp[dsInfo['variable']]
966 969 ds[ind] = ds0
967 970 ind += 1
968 971 else:
969 972
970 973 grp0 = grp[dsInfo['variable']]
971 974
972 975 for j in range(dsInfo['dsNumber']):
973 976 dsInfo = dsList[ind]
974 977 ds0 = grp0[dsInfo['dsName']]
975 978 ds[ind] = ds0
976 979 ind += 1
977 980
978 981 self.fp = fp
979 982 self.grp = grp
980 983 self.ds = ds
981 984
982 985 return
983 986
984 987 def setBlock(self):
985 988 '''
986 989 data Array configured
987 990
988 991
989 992 self.data
990 993 '''
991 994 #Creating Arrays
992 995 dsList = self.dsList
993 996 data = self.data
994 997 ind = 0
995 998
996 999 while ind < len(dsList):
997 1000 dsInfo = dsList[ind]
998 1001 dataAux = getattr(self.dataOut, dsInfo['variable'])
999 1002
1000 1003 mode = dsInfo['mode']
1001 1004 nDim = dsInfo['nDim']
1002 1005
1003 1006 if mode == 0 or mode == 2 or nDim == 1:
1004 1007 data[ind] = dataAux
1005 1008 ind += 1
1006 1009 # elif nDim == 1:
1007 1010 # data[ind] = numpy.reshape(dataAux,(numpy.size(dataAux),1))
1008 1011 # ind += 1
1009 1012 elif nDim == 2:
1010 1013 for j in range(dsInfo['dsNumber']):
1011 1014 data[ind] = dataAux[j,:]
1012 1015 ind += 1
1013 1016 elif nDim == 3:
1014 1017 for j in range(dsInfo['dsNumber']):
1015 1018 data[ind] = dataAux[:,j,:]
1016 1019 ind += 1
1017 1020
1018 1021 self.data = data
1019 1022 return
1020 1023
1021 1024 def writeBlock(self):
1022 1025 '''
1023 1026 Saves the block in the HDF5 file
1024 1027 '''
1025 1028 dsList = self.dsList
1026 1029
1027 1030 for i in range(len(self.ds)):
1028 1031 dsInfo = dsList[i]
1029 1032 nDim = dsInfo['nDim']
1030 1033 mode = dsInfo['mode']
1031 1034
1032 1035 # First time
1033 1036 if self.firsttime:
1034 1037 # self.ds[i].resize(self.data[i].shape)
1035 1038 # self.ds[i][self.blockIndex,:] = self.data[i]
1036 1039 if type(self.data[i]) == numpy.ndarray:
1037 1040
1038 1041 if nDim == 3:
1039 1042 self.data[i] = self.data[i].reshape((self.data[i].shape[0],self.data[i].shape[1],1))
1040 1043 self.ds[i].resize(self.data[i].shape)
1041 1044 if mode == 2:
1042 1045 self.ds[i].resize(self.data[i].shape)
1043 1046 self.ds[i][:] = self.data[i]
1044 1047 else:
1045 1048
1046 1049 # From second time
1047 1050 # Meteors!
1048 1051 if mode == 2:
1049 1052 dataShape = self.data[i].shape
1050 1053 dsShape = self.ds[i].shape
1051 1054 self.ds[i].resize((self.ds[i].shape[0] + dataShape[0],self.ds[i].shape[1]))
1052 1055 self.ds[i][dsShape[0]:,:] = self.data[i]
1053 1056 # No dimension
1054 1057 elif mode == 0:
1055 1058 self.ds[i].resize((self.ds[i].shape[0], self.ds[i].shape[1] + 1))
1056 1059 self.ds[i][0,-1] = self.data[i]
1057 1060 # One dimension
1058 1061 elif nDim == 1:
1059 1062 self.ds[i].resize((self.ds[i].shape[0] + 1, self.ds[i].shape[1]))
1060 1063 self.ds[i][-1,:] = self.data[i]
1061 1064 # Two dimension
1062 1065 elif nDim == 2:
1063 1066 self.ds[i].resize((self.ds[i].shape[0] + 1,self.ds[i].shape[1]))
1064 1067 self.ds[i][self.blockIndex,:] = self.data[i]
1065 1068 # Three dimensions
1066 1069 elif nDim == 3:
1067 1070 self.ds[i].resize((self.ds[i].shape[0],self.ds[i].shape[1],self.ds[i].shape[2]+1))
1068 1071 self.ds[i][:,:,-1] = self.data[i]
1069 1072
1070 1073 self.firsttime = False
1071 1074 self.blockIndex += 1
1072 1075
1073 1076 #Close to save changes
1074 1077 self.fp.flush()
1075 1078 self.fp.close()
1076 1079 return
1077 1080
1078 1081 def run(self, dataOut, **kwargs):
1079
1082
1080 1083 if not(self.isConfig):
1084
1081 1085 flagdata = self.setup(dataOut, **kwargs)
1082
1086
1083 1087 if not(flagdata):
1084 1088 return
1085 1089
1086 1090 self.isConfig = True
1087 1091 # self.putMetadata()
1088 1092 self.setNextFile()
1089 1093
1090 1094 self.putData()
1091 1095 return
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,1067 +1,1078
1 1 import numpy
2 2
3 3 from jroproc_base import ProcessingUnit, Operation
4 4 from schainpy.model.data.jrodata import Spectra
5 5 from schainpy.model.data.jrodata import hildebrand_sekhon
6 6
7 7 import matplotlib.pyplot as plt
8 8
9 9 class SpectraProc(ProcessingUnit):
10 10
11 11 def __init__(self, **kwargs):
12 12
13 13 ProcessingUnit.__init__(self, **kwargs)
14 14
15 15 self.buffer = None
16 16 self.firstdatatime = None
17 17 self.profIndex = 0
18 18 self.dataOut = Spectra()
19 19 self.id_min = None
20 20 self.id_max = None
21 21
22 22 def __updateSpecFromVoltage(self):
23 23
24 24 self.dataOut.timeZone = self.dataIn.timeZone
25 25 self.dataOut.dstFlag = self.dataIn.dstFlag
26 26 self.dataOut.errorCount = self.dataIn.errorCount
27 27 self.dataOut.useLocalTime = self.dataIn.useLocalTime
28 28
29 29 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
30 30 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()
31 31 self.dataOut.channelList = self.dataIn.channelList
32 32 self.dataOut.heightList = self.dataIn.heightList
33 33 self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')])
34 34
35 35 self.dataOut.nBaud = self.dataIn.nBaud
36 36 self.dataOut.nCode = self.dataIn.nCode
37 37 self.dataOut.code = self.dataIn.code
38 38 self.dataOut.nProfiles = self.dataOut.nFFTPoints
39 39
40 40 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
41 41 self.dataOut.utctime = self.firstdatatime
42 42 self.dataOut.flagDecodeData = self.dataIn.flagDecodeData #asumo q la data esta decodificada
43 43 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip
44 44 self.dataOut.flagShiftFFT = False
45 45
46 46 self.dataOut.nCohInt = self.dataIn.nCohInt
47 47 self.dataOut.nIncohInt = 1
48 48
49 49 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
50 50
51 51 self.dataOut.frequency = self.dataIn.frequency
52 52 self.dataOut.realtime = self.dataIn.realtime
53 53
54 54 self.dataOut.azimuth = self.dataIn.azimuth
55 55 self.dataOut.zenith = self.dataIn.zenith
56 56
57 57 self.dataOut.beam.codeList = self.dataIn.beam.codeList
58 58 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
59 59 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
60 60
61 61 def __getFft(self):
62 62 """
63 63 Convierte valores de Voltaje a Spectra
64 64
65 65 Affected:
66 66 self.dataOut.data_spc
67 67 self.dataOut.data_cspc
68 68 self.dataOut.data_dc
69 69 self.dataOut.heightList
70 70 self.profIndex
71 71 self.buffer
72 72 self.dataOut.flagNoData
73 73 """
74 74 fft_volt = numpy.fft.fft(self.buffer,n=self.dataOut.nFFTPoints,axis=1)
75 75
76 76 fft_volt = fft_volt.astype(numpy.dtype('complex'))
77 77 dc = fft_volt[:,0,:]
78 78
79 79 #calculo de self-spectra
80 80 fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,))
81 81 spc = fft_volt * numpy.conjugate(fft_volt)
82 82 spc = spc.real
83 83
84 84 blocksize = 0
85 85 blocksize += dc.size
86 86 blocksize += spc.size
87 87
88 88 cspc = None
89 89 pairIndex = 0
90 90 if self.dataOut.pairsList != None:
91 91 #calculo de cross-spectra
92 92 cspc = numpy.zeros((self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex')
93 93 for pair in self.dataOut.pairsList:
94 94 if pair[0] not in self.dataOut.channelList:
95 95 raise ValueError, "Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList))
96 96 if pair[1] not in self.dataOut.channelList:
97 97 raise ValueError, "Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList))
98 98
99 99 cspc[pairIndex,:,:] = fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])
100 100 pairIndex += 1
101 101 blocksize += cspc.size
102 102
103 103 self.dataOut.data_spc = spc
104 104 self.dataOut.data_cspc = cspc
105 105 self.dataOut.data_dc = dc
106 106 self.dataOut.blockSize = blocksize
107 107 self.dataOut.flagShiftFFT = True
108 108
109 109 def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], ippFactor=None):
110 110
111 111 self.dataOut.flagNoData = True
112 112
113 113 if self.dataIn.type == "Spectra":
114 114 self.dataOut.copy(self.dataIn)
115 115 # self.__selectPairs(pairsList)
116 116 return True
117 117
118 118 if self.dataIn.type == "Voltage":
119 119
120 120 if nFFTPoints == None:
121 121 raise ValueError, "This SpectraProc.run() need nFFTPoints input variable"
122 122
123 123 if nProfiles == None:
124 124 nProfiles = nFFTPoints
125 125
126 126 if ippFactor == None:
127 127 ippFactor = 1
128 128
129 129 self.dataOut.ippFactor = ippFactor
130 130
131 131 self.dataOut.nFFTPoints = nFFTPoints
132 132 self.dataOut.pairsList = pairsList
133 133
134 134 if self.buffer is None:
135 135 self.buffer = numpy.zeros( (self.dataIn.nChannels,
136 136 nProfiles,
137 137 self.dataIn.nHeights),
138 138 dtype='complex')
139 139
140 140 if self.dataIn.flagDataAsBlock:
141 141 #data dimension: [nChannels, nProfiles, nSamples]
142 142
143 143 nVoltProfiles = self.dataIn.data.shape[1]
144 144 # nVoltProfiles = self.dataIn.nProfiles
145 145
146 146 if nVoltProfiles == nProfiles:
147 147 self.buffer = self.dataIn.data.copy()
148 148 self.profIndex = nVoltProfiles
149 149
150 150 elif nVoltProfiles < nProfiles:
151 151
152 152 if self.profIndex == 0:
153 153 self.id_min = 0
154 154 self.id_max = nVoltProfiles
155 155
156 156 self.buffer[:,self.id_min:self.id_max,:] = self.dataIn.data
157 157 self.profIndex += nVoltProfiles
158 158 self.id_min += nVoltProfiles
159 159 self.id_max += nVoltProfiles
160 160 else:
161 161 raise ValueError, "The type object %s has %d profiles, it should just has %d profiles"%(self.dataIn.type,self.dataIn.data.shape[1],nProfiles)
162 162 self.dataOut.flagNoData = True
163 163 return 0
164 164 else:
165 165
166 166 self.buffer[:,self.profIndex,:] = self.dataIn.data.copy()
167 167 self.profIndex += 1
168 168
169 169 if self.firstdatatime == None:
170 170 self.firstdatatime = self.dataIn.utctime
171 171
172 172 if self.profIndex == nProfiles:
173 173 self.__updateSpecFromVoltage()
174 174 self.__getFft()
175 175
176 176 self.dataOut.flagNoData = False
177 177 self.firstdatatime = None
178 178 self.profIndex = 0
179 179
180 180 return True
181 181
182 182 raise ValueError, "The type of input object '%s' is not valid"%(self.dataIn.type)
183 183
184 184 def __selectPairs(self, pairsList):
185 185
186 186 if channelList == None:
187 187 return
188 188
189 189 pairsIndexListSelected = []
190 190
191 191 for thisPair in pairsList:
192 192
193 193 if thisPair not in self.dataOut.pairsList:
194 194 continue
195 195
196 196 pairIndex = self.dataOut.pairsList.index(thisPair)
197 197
198 198 pairsIndexListSelected.append(pairIndex)
199 199
200 200 if not pairsIndexListSelected:
201 201 self.dataOut.data_cspc = None
202 202 self.dataOut.pairsList = []
203 203 return
204 204
205 205 self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected]
206 206 self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected]
207 207
208 208 return
209 209
210 210 def __selectPairsByChannel(self, channelList=None):
211 211
212 212 if channelList == None:
213 213 return
214 214
215 215 pairsIndexListSelected = []
216 216 for pairIndex in self.dataOut.pairsIndexList:
217 217 #First pair
218 218 if self.dataOut.pairsList[pairIndex][0] not in channelList:
219 219 continue
220 220 #Second pair
221 221 if self.dataOut.pairsList[pairIndex][1] not in channelList:
222 222 continue
223 223
224 224 pairsIndexListSelected.append(pairIndex)
225 225
226 226 if not pairsIndexListSelected:
227 227 self.dataOut.data_cspc = None
228 228 self.dataOut.pairsList = []
229 229 return
230 230
231 231 self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected]
232 232 self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected]
233 233
234 234 return
235 235
236 236 def selectChannels(self, channelList):
237 237
238 238 channelIndexList = []
239 239
240 240 for channel in channelList:
241 241 if channel not in self.dataOut.channelList:
242 242 raise ValueError, "Error selecting channels, Channel %d is not valid.\nAvailable channels = %s" %(channel, str(self.dataOut.channelList))
243 243
244 244 index = self.dataOut.channelList.index(channel)
245 245 channelIndexList.append(index)
246 246
247 247 self.selectChannelsByIndex(channelIndexList)
248 248
249 249 def selectChannelsByIndex(self, channelIndexList):
250 250 """
251 251 Selecciona un bloque de datos en base a canales segun el channelIndexList
252 252
253 253 Input:
254 254 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
255 255
256 256 Affected:
257 257 self.dataOut.data_spc
258 258 self.dataOut.channelIndexList
259 259 self.dataOut.nChannels
260 260
261 261 Return:
262 262 None
263 263 """
264 264
265 265 for channelIndex in channelIndexList:
266 266 if channelIndex not in self.dataOut.channelIndexList:
267 267 raise ValueError, "Error selecting channels: The value %d in channelIndexList is not valid.\nAvailable channel indexes = " %(channelIndex, self.dataOut.channelIndexList)
268 268
269 269 # nChannels = len(channelIndexList)
270 270
271 271 data_spc = self.dataOut.data_spc[channelIndexList,:]
272 272 data_dc = self.dataOut.data_dc[channelIndexList,:]
273 273
274 274 self.dataOut.data_spc = data_spc
275 275 self.dataOut.data_dc = data_dc
276 276
277 277 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
278 278 # self.dataOut.nChannels = nChannels
279 279
280 280 self.__selectPairsByChannel(self.dataOut.channelList)
281 281
282 282 return 1
283 283
284 284
285 285 def selectFFTs(self, minFFT, maxFFT ):
286 286 """
287 287 Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango
288 288 minFFT<= FFT <= maxFFT
289 289 """
290 290
291 291 if (minFFT > maxFFT):
292 292 raise ValueError, "Error selecting heights: Height range (%d,%d) is not valid" % (minFFT, maxFFT)
293 293
294 294 if (minFFT < self.dataOut.getFreqRange()[0]):
295 295 minFFT = self.dataOut.getFreqRange()[0]
296 296
297 297 if (maxFFT > self.dataOut.getFreqRange()[-1]):
298 298 maxFFT = self.dataOut.getFreqRange()[-1]
299 299
300 300 minIndex = 0
301 301 maxIndex = 0
302 302 FFTs = self.dataOut.getFreqRange()
303 303
304 304 inda = numpy.where(FFTs >= minFFT)
305 305 indb = numpy.where(FFTs <= maxFFT)
306 306
307 307 try:
308 308 minIndex = inda[0][0]
309 309 except:
310 310 minIndex = 0
311 311
312 312 try:
313 313 maxIndex = indb[0][-1]
314 314 except:
315 315 maxIndex = len(FFTs)
316 316
317 317 self.selectFFTsByIndex(minIndex, maxIndex)
318 318
319 319 return 1
320 320
321 321
322 def setH0(self, h0, deltaHeight = None):
323
324 if not deltaHeight:
325 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
326
327 nHeights = self.dataOut.nHeights
328
329 newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight
330
331 self.dataOut.heightList = newHeiRange
332
322 333
323 334 def selectHeights(self, minHei, maxHei):
324 335 """
325 336 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
326 337 minHei <= height <= maxHei
327 338
328 339 Input:
329 340 minHei : valor minimo de altura a considerar
330 341 maxHei : valor maximo de altura a considerar
331 342
332 343 Affected:
333 344 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
334 345
335 346 Return:
336 347 1 si el metodo se ejecuto con exito caso contrario devuelve 0
337 348 """
338 349
339 350
340 351 if (minHei > maxHei):
341 352 raise ValueError, "Error selecting heights: Height range (%d,%d) is not valid" % (minHei, maxHei)
342 353
343 354 if (minHei < self.dataOut.heightList[0]):
344 355 minHei = self.dataOut.heightList[0]
345 356
346 357 if (maxHei > self.dataOut.heightList[-1]):
347 358 maxHei = self.dataOut.heightList[-1]
348 359
349 360 minIndex = 0
350 361 maxIndex = 0
351 362 heights = self.dataOut.heightList
352 363
353 364 inda = numpy.where(heights >= minHei)
354 365 indb = numpy.where(heights <= maxHei)
355 366
356 367 try:
357 368 minIndex = inda[0][0]
358 369 except:
359 370 minIndex = 0
360 371
361 372 try:
362 373 maxIndex = indb[0][-1]
363 374 except:
364 375 maxIndex = len(heights)
365 376
366 377 self.selectHeightsByIndex(minIndex, maxIndex)
367 378
368 379
369 380 return 1
370 381
371 382 def getBeaconSignal(self, tauindex = 0, channelindex = 0, hei_ref=None):
372 383 newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex])
373 384
374 385 if hei_ref != None:
375 386 newheis = numpy.where(self.dataOut.heightList>hei_ref)
376 387
377 388 minIndex = min(newheis[0])
378 389 maxIndex = max(newheis[0])
379 390 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
380 391 heightList = self.dataOut.heightList[minIndex:maxIndex+1]
381 392
382 393 # determina indices
383 394 nheis = int(self.dataOut.radarControllerHeaderObj.txB/(self.dataOut.heightList[1]-self.dataOut.heightList[0]))
384 395 avg_dB = 10*numpy.log10(numpy.sum(data_spc[channelindex,:,:],axis=0))
385 396 beacon_dB = numpy.sort(avg_dB)[-nheis:]
386 397 beacon_heiIndexList = []
387 398 for val in avg_dB.tolist():
388 399 if val >= beacon_dB[0]:
389 400 beacon_heiIndexList.append(avg_dB.tolist().index(val))
390 401
391 402 #data_spc = data_spc[:,:,beacon_heiIndexList]
392 403 data_cspc = None
393 404 if self.dataOut.data_cspc is not None:
394 405 data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1]
395 406 #data_cspc = data_cspc[:,:,beacon_heiIndexList]
396 407
397 408 data_dc = None
398 409 if self.dataOut.data_dc is not None:
399 410 data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1]
400 411 #data_dc = data_dc[:,beacon_heiIndexList]
401 412
402 413 self.dataOut.data_spc = data_spc
403 414 self.dataOut.data_cspc = data_cspc
404 415 self.dataOut.data_dc = data_dc
405 416 self.dataOut.heightList = heightList
406 417 self.dataOut.beacon_heiIndexList = beacon_heiIndexList
407 418
408 419 return 1
409 420
410 421 def selectFFTsByIndex(self, minIndex, maxIndex):
411 422 """
412 423
413 424 """
414 425
415 426 if (minIndex < 0) or (minIndex > maxIndex):
416 427 raise ValueError, "Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)
417 428
418 429 if (maxIndex >= self.dataOut.nProfiles):
419 430 maxIndex = self.dataOut.nProfiles-1
420 431
421 432 #Spectra
422 433 data_spc = self.dataOut.data_spc[:,minIndex:maxIndex+1,:]
423 434
424 435 data_cspc = None
425 436 if self.dataOut.data_cspc is not None:
426 437 data_cspc = self.dataOut.data_cspc[:,minIndex:maxIndex+1,:]
427 438
428 439 data_dc = None
429 440 if self.dataOut.data_dc is not None:
430 441 data_dc = self.dataOut.data_dc[minIndex:maxIndex+1,:]
431 442
432 443 self.dataOut.data_spc = data_spc
433 444 self.dataOut.data_cspc = data_cspc
434 445 self.dataOut.data_dc = data_dc
435 446
436 447 self.dataOut.ippSeconds = self.dataOut.ippSeconds*(self.dataOut.nFFTPoints / numpy.shape(data_cspc)[1])
437 448 self.dataOut.nFFTPoints = numpy.shape(data_cspc)[1]
438 449 self.dataOut.profilesPerBlock = numpy.shape(data_cspc)[1]
439 450
440 451 #self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex+1]
441 452
442 453 return 1
443 454
444 455
445 456
446 457 def selectHeightsByIndex(self, minIndex, maxIndex):
447 458 """
448 459 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
449 460 minIndex <= index <= maxIndex
450 461
451 462 Input:
452 463 minIndex : valor de indice minimo de altura a considerar
453 464 maxIndex : valor de indice maximo de altura a considerar
454 465
455 466 Affected:
456 467 self.dataOut.data_spc
457 468 self.dataOut.data_cspc
458 469 self.dataOut.data_dc
459 470 self.dataOut.heightList
460 471
461 472 Return:
462 473 1 si el metodo se ejecuto con exito caso contrario devuelve 0
463 474 """
464 475
465 476 if (minIndex < 0) or (minIndex > maxIndex):
466 477 raise ValueError, "Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)
467 478
468 479 if (maxIndex >= self.dataOut.nHeights):
469 480 maxIndex = self.dataOut.nHeights-1
470 481
471 482 #Spectra
472 483 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
473 484
474 485 data_cspc = None
475 486 if self.dataOut.data_cspc is not None:
476 487 data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1]
477 488
478 489 data_dc = None
479 490 if self.dataOut.data_dc is not None:
480 491 data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1]
481 492
482 493 self.dataOut.data_spc = data_spc
483 494 self.dataOut.data_cspc = data_cspc
484 495 self.dataOut.data_dc = data_dc
485 496
486 497 self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex+1]
487 498
488 499 return 1
489 500
490 501
491 502 def removeDC(self, mode = 2):
492 503 jspectra = self.dataOut.data_spc
493 504 jcspectra = self.dataOut.data_cspc
494 505
495 506
496 507 num_chan = jspectra.shape[0]
497 508 num_hei = jspectra.shape[2]
498 509
499 510 if jcspectra is not None:
500 511 jcspectraExist = True
501 512 num_pairs = jcspectra.shape[0]
502 513 else: jcspectraExist = False
503 514
504 515 freq_dc = jspectra.shape[1]/2
505 516 ind_vel = numpy.array([-2,-1,1,2]) + freq_dc
506 517
507 518 if ind_vel[0]<0:
508 519 ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof
509 520
510 521 if mode == 1:
511 522 jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION
512 523
513 524 if jcspectraExist:
514 525 jcspectra[:,freq_dc,:] = (jcspectra[:,ind_vel[1],:] + jcspectra[:,ind_vel[2],:])/2
515 526
516 527 if mode == 2:
517 528
518 529 vel = numpy.array([-2,-1,1,2])
519 530 xx = numpy.zeros([4,4])
520 531
521 532 for fil in range(4):
522 533 xx[fil,:] = vel[fil]**numpy.asarray(range(4))
523 534
524 535 xx_inv = numpy.linalg.inv(xx)
525 536 xx_aux = xx_inv[0,:]
526 537
527 538 for ich in range(num_chan):
528 539 yy = jspectra[ich,ind_vel,:]
529 540 jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy)
530 541
531 542 junkid = jspectra[ich,freq_dc,:]<=0
532 543 cjunkid = sum(junkid)
533 544
534 545 if cjunkid.any():
535 546 jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2
536 547
537 548 if jcspectraExist:
538 549 for ip in range(num_pairs):
539 550 yy = jcspectra[ip,ind_vel,:]
540 551 jcspectra[ip,freq_dc,:] = numpy.dot(xx_aux,yy)
541 552
542 553
543 554 self.dataOut.data_spc = jspectra
544 555 self.dataOut.data_cspc = jcspectra
545 556
546 557 return 1
547 558
548 559 def removeInterference2(self):
549 560
550 561 cspc = self.dataOut.data_cspc
551 562 spc = self.dataOut.data_spc
552 563 print numpy.shape(spc)
553 564 Heights = numpy.arange(cspc.shape[2])
554 565 realCspc = numpy.abs(cspc)
555 566
556 567 for i in range(cspc.shape[0]):
557 568 LinePower= numpy.sum(realCspc[i], axis=0)
558 569 Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)]
559 570 SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ]
560 571 #print numpy.shape(realCspc)
561 572 #print '',SelectedHeights, '', numpy.shape(realCspc[i,:,SelectedHeights])
562 573 InterferenceSum = numpy.sum( realCspc[i,:,SelectedHeights], axis=0 )
563 574 print SelectedHeights
564 575 InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)]
565 576 InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)]
566 577
567 578
568 579 InterferenceRange = numpy.where( ([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) )
569 580 #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax]))
570 581 if len(InterferenceRange)<int(cspc.shape[1]*0.3):
571 582 cspc[i,InterferenceRange,:] = numpy.NaN
572 583
573 584 print '########################################################################################'
574 585 print 'Len interference sum',len(InterferenceSum)
575 586 print 'InterferenceThresholdMin', InterferenceThresholdMin, 'InterferenceThresholdMax', InterferenceThresholdMax
576 587 print 'InterferenceRange',InterferenceRange
577 588 print '########################################################################################'
578 589
579 590 ''' Ploteo '''
580 591
581 592 #for i in range(3):
582 593 #print 'FASE', numpy.shape(phase), y[25]
583 594 #print numpy.shape(coherence)
584 595 #fig = plt.figure(10+ int(numpy.random.rand()*100))
585 596 #plt.plot( x[0:256],coherence[:,25] )
586 597 #cohAv = numpy.average(coherence[i],1)
587 598 #Pendiente = FrecRange * PhaseSlope[i]
588 599 #plt.plot( InterferenceSum)
589 600 #plt.plot( numpy.sort(InterferenceSum))
590 601 #plt.plot( LinePower )
591 602 #plt.plot( xFrec,phase[i])
592 603
593 604 #CSPCmean = numpy.mean(numpy.abs(CSPCSamples),0)
594 605 #plt.plot(xFrec, FitGauss01)
595 606 #plt.plot(xFrec, CSPCmean)
596 607 #plt.plot(xFrec, numpy.abs(CSPCSamples[0]))
597 608 #plt.plot(xFrec, FitGauss)
598 609 #plt.plot(xFrec, yMean)
599 610 #plt.plot(xFrec, numpy.abs(coherence[0]))
600 611
601 612 #plt.axis([-12, 12, 15, 50])
602 613 #plt.title("%s" %( '%s %s, Channel %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S") , i)))
603 614
604 615
605 616 #fig.savefig('/home/erick/Documents/Pics/nom{}.png'.format(int(numpy.random.rand()*100)))
606 617
607 618 #plt.show()
608 619 #self.indice=self.indice+1
609 620 #raise
610 621
611 622
612 623 self.dataOut.data_cspc = cspc
613 624
614 625 # for i in range(spc.shape[0]):
615 626 # LinePower= numpy.sum(spc[i], axis=0)
616 627 # Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)]
617 628 # SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ]
618 629 # #print numpy.shape(realCspc)
619 630 # #print '',SelectedHeights, '', numpy.shape(realCspc[i,:,SelectedHeights])
620 631 # InterferenceSum = numpy.sum( spc[i,:,SelectedHeights], axis=0 )
621 632 # InterferenceThreshold = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)]
622 633 # InterferenceRange = numpy.where( InterferenceSum > InterferenceThreshold )
623 634 # if len(InterferenceRange)<int(spc.shape[1]*0.03):
624 635 # spc[i,InterferenceRange,:] = numpy.NaN
625 636
626 637 #self.dataOut.data_spc = spc
627 638
628 639 def removeInterference(self, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None):
629 640
630 641 jspectra = self.dataOut.data_spc
631 642 jcspectra = self.dataOut.data_cspc
632 643 jnoise = self.dataOut.getNoise()
633 644 num_incoh = self.dataOut.nIncohInt
634 645
635 646 num_channel = jspectra.shape[0]
636 647 num_prof = jspectra.shape[1]
637 648 num_hei = jspectra.shape[2]
638 649
639 650 #hei_interf
640 651 if hei_interf is None:
641 652 count_hei = num_hei/2 #Como es entero no importa
642 653 hei_interf = numpy.asmatrix(range(count_hei)) + num_hei - count_hei
643 654 hei_interf = numpy.asarray(hei_interf)[0]
644 655 #nhei_interf
645 656 if (nhei_interf == None):
646 657 nhei_interf = 5
647 658 if (nhei_interf < 1):
648 659 nhei_interf = 1
649 660 if (nhei_interf > count_hei):
650 661 nhei_interf = count_hei
651 662 if (offhei_interf == None):
652 663 offhei_interf = 0
653 664
654 665 ind_hei = range(num_hei)
655 666 # mask_prof = numpy.asarray(range(num_prof - 2)) + 1
656 667 # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1
657 668 mask_prof = numpy.asarray(range(num_prof))
658 669 num_mask_prof = mask_prof.size
659 670 comp_mask_prof = [0, num_prof/2]
660 671
661 672
662 673 #noise_exist: Determina si la variable jnoise ha sido definida y contiene la informacion del ruido de cada canal
663 674 if (jnoise.size < num_channel or numpy.isnan(jnoise).any()):
664 675 jnoise = numpy.nan
665 676 noise_exist = jnoise[0] < numpy.Inf
666 677
667 678 #Subrutina de Remocion de la Interferencia
668 679 for ich in range(num_channel):
669 680 #Se ordena los espectros segun su potencia (menor a mayor)
670 681 power = jspectra[ich,mask_prof,:]
671 682 power = power[:,hei_interf]
672 683 power = power.sum(axis = 0)
673 684 psort = power.ravel().argsort()
674 685
675 686 #Se estima la interferencia promedio en los Espectros de Potencia empleando
676 687 junkspc_interf = jspectra[ich,:,hei_interf[psort[range(offhei_interf, nhei_interf + offhei_interf)]]]
677 688
678 689 if noise_exist:
679 690 # tmp_noise = jnoise[ich] / num_prof
680 691 tmp_noise = jnoise[ich]
681 692 junkspc_interf = junkspc_interf - tmp_noise
682 693 #junkspc_interf[:,comp_mask_prof] = 0
683 694
684 695 jspc_interf = junkspc_interf.sum(axis = 0) / nhei_interf
685 696 jspc_interf = jspc_interf.transpose()
686 697 #Calculando el espectro de interferencia promedio
687 698 noiseid = numpy.where(jspc_interf <= tmp_noise/ numpy.sqrt(num_incoh))
688 699 noiseid = noiseid[0]
689 700 cnoiseid = noiseid.size
690 701 interfid = numpy.where(jspc_interf > tmp_noise/ numpy.sqrt(num_incoh))
691 702 interfid = interfid[0]
692 703 cinterfid = interfid.size
693 704
694 705 if (cnoiseid > 0): jspc_interf[noiseid] = 0
695 706
696 707 #Expandiendo los perfiles a limpiar
697 708 if (cinterfid > 0):
698 709 new_interfid = (numpy.r_[interfid - 1, interfid, interfid + 1] + num_prof)%num_prof
699 710 new_interfid = numpy.asarray(new_interfid)
700 711 new_interfid = {x for x in new_interfid}
701 712 new_interfid = numpy.array(list(new_interfid))
702 713 new_cinterfid = new_interfid.size
703 714 else: new_cinterfid = 0
704 715
705 716 for ip in range(new_cinterfid):
706 717 ind = junkspc_interf[:,new_interfid[ip]].ravel().argsort()
707 718 jspc_interf[new_interfid[ip]] = junkspc_interf[ind[nhei_interf/2],new_interfid[ip]]
708 719
709 720
710 721 jspectra[ich,:,ind_hei] = jspectra[ich,:,ind_hei] - jspc_interf #Corregir indices
711 722
712 723 #Removiendo la interferencia del punto de mayor interferencia
713 724 ListAux = jspc_interf[mask_prof].tolist()
714 725 maxid = ListAux.index(max(ListAux))
715 726
716 727
717 728 if cinterfid > 0:
718 729 for ip in range(cinterfid*(interf == 2) - 1):
719 730 ind = (jspectra[ich,interfid[ip],:] < tmp_noise*(1 + 1/numpy.sqrt(num_incoh))).nonzero()
720 731 cind = len(ind)
721 732
722 733 if (cind > 0):
723 734 jspectra[ich,interfid[ip],ind] = tmp_noise*(1 + (numpy.random.uniform(cind) - 0.5)/numpy.sqrt(num_incoh))
724 735
725 736 ind = numpy.array([-2,-1,1,2])
726 737 xx = numpy.zeros([4,4])
727 738
728 739 for id1 in range(4):
729 740 xx[:,id1] = ind[id1]**numpy.asarray(range(4))
730 741
731 742 xx_inv = numpy.linalg.inv(xx)
732 743 xx = xx_inv[:,0]
733 744 ind = (ind + maxid + num_mask_prof)%num_mask_prof
734 745 yy = jspectra[ich,mask_prof[ind],:]
735 746 jspectra[ich,mask_prof[maxid],:] = numpy.dot(yy.transpose(),xx)
736 747
737 748
738 749 indAux = (jspectra[ich,:,:] < tmp_noise*(1-1/numpy.sqrt(num_incoh))).nonzero()
739 750 jspectra[ich,indAux[0],indAux[1]] = tmp_noise * (1 - 1/numpy.sqrt(num_incoh))
740 751
741 752 #Remocion de Interferencia en el Cross Spectra
742 753 if jcspectra is None: return jspectra, jcspectra
743 754 num_pairs = jcspectra.size/(num_prof*num_hei)
744 755 jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei)
745 756
746 757 for ip in range(num_pairs):
747 758
748 759 #-------------------------------------------
749 760
750 761 cspower = numpy.abs(jcspectra[ip,mask_prof,:])
751 762 cspower = cspower[:,hei_interf]
752 763 cspower = cspower.sum(axis = 0)
753 764
754 765 cspsort = cspower.ravel().argsort()
755 766 junkcspc_interf = jcspectra[ip,:,hei_interf[cspsort[range(offhei_interf, nhei_interf + offhei_interf)]]]
756 767 junkcspc_interf = junkcspc_interf.transpose()
757 768 jcspc_interf = junkcspc_interf.sum(axis = 1)/nhei_interf
758 769
759 770 ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort()
760 771
761 772 median_real = numpy.median(numpy.real(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:]))
762 773 median_imag = numpy.median(numpy.imag(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:]))
763 774 junkcspc_interf[comp_mask_prof,:] = numpy.complex(median_real, median_imag)
764 775
765 776 for iprof in range(num_prof):
766 777 ind = numpy.abs(junkcspc_interf[iprof,:]).ravel().argsort()
767 778 jcspc_interf[iprof] = junkcspc_interf[iprof, ind[nhei_interf/2]]
768 779
769 780 #Removiendo la Interferencia
770 781 jcspectra[ip,:,ind_hei] = jcspectra[ip,:,ind_hei] - jcspc_interf
771 782
772 783 ListAux = numpy.abs(jcspc_interf[mask_prof]).tolist()
773 784 maxid = ListAux.index(max(ListAux))
774 785
775 786 ind = numpy.array([-2,-1,1,2])
776 787 xx = numpy.zeros([4,4])
777 788
778 789 for id1 in range(4):
779 790 xx[:,id1] = ind[id1]**numpy.asarray(range(4))
780 791
781 792 xx_inv = numpy.linalg.inv(xx)
782 793 xx = xx_inv[:,0]
783 794
784 795 ind = (ind + maxid + num_mask_prof)%num_mask_prof
785 796 yy = jcspectra[ip,mask_prof[ind],:]
786 797 jcspectra[ip,mask_prof[maxid],:] = numpy.dot(yy.transpose(),xx)
787 798
788 799 #Guardar Resultados
789 800 self.dataOut.data_spc = jspectra
790 801 self.dataOut.data_cspc = jcspectra
791 802
792 803 return 1
793 804
794 805 def setRadarFrequency(self, frequency=None):
795 806
796 807 if frequency != None:
797 808 self.dataOut.frequency = frequency
798 809
799 810 return 1
800 811
801 812 def getNoise(self, minHei=None, maxHei=None, minVel=None, maxVel=None):
802 813 #validacion de rango
803 814 if minHei == None:
804 815 minHei = self.dataOut.heightList[0]
805 816
806 817 if maxHei == None:
807 818 maxHei = self.dataOut.heightList[-1]
808 819
809 820 if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei):
810 821 print 'minHei: %.2f is out of the heights range'%(minHei)
811 822 print 'minHei is setting to %.2f'%(self.dataOut.heightList[0])
812 823 minHei = self.dataOut.heightList[0]
813 824
814 825 if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei):
815 826 print 'maxHei: %.2f is out of the heights range'%(maxHei)
816 827 print 'maxHei is setting to %.2f'%(self.dataOut.heightList[-1])
817 828 maxHei = self.dataOut.heightList[-1]
818 829
819 830 # validacion de velocidades
820 831 velrange = self.dataOut.getVelRange(1)
821 832
822 833 if minVel == None:
823 834 minVel = velrange[0]
824 835
825 836 if maxVel == None:
826 837 maxVel = velrange[-1]
827 838
828 839 if (minVel < velrange[0]) or (minVel > maxVel):
829 840 print 'minVel: %.2f is out of the velocity range'%(minVel)
830 841 print 'minVel is setting to %.2f'%(velrange[0])
831 842 minVel = velrange[0]
832 843
833 844 if (maxVel > velrange[-1]) or (maxVel < minVel):
834 845 print 'maxVel: %.2f is out of the velocity range'%(maxVel)
835 846 print 'maxVel is setting to %.2f'%(velrange[-1])
836 847 maxVel = velrange[-1]
837 848
838 849 # seleccion de indices para rango
839 850 minIndex = 0
840 851 maxIndex = 0
841 852 heights = self.dataOut.heightList
842 853
843 854 inda = numpy.where(heights >= minHei)
844 855 indb = numpy.where(heights <= maxHei)
845 856
846 857 try:
847 858 minIndex = inda[0][0]
848 859 except:
849 860 minIndex = 0
850 861
851 862 try:
852 863 maxIndex = indb[0][-1]
853 864 except:
854 865 maxIndex = len(heights)
855 866
856 867 if (minIndex < 0) or (minIndex > maxIndex):
857 868 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
858 869
859 870 if (maxIndex >= self.dataOut.nHeights):
860 871 maxIndex = self.dataOut.nHeights-1
861 872
862 873 # seleccion de indices para velocidades
863 874 indminvel = numpy.where(velrange >= minVel)
864 875 indmaxvel = numpy.where(velrange <= maxVel)
865 876 try:
866 877 minIndexVel = indminvel[0][0]
867 878 except:
868 879 minIndexVel = 0
869 880
870 881 try:
871 882 maxIndexVel = indmaxvel[0][-1]
872 883 except:
873 884 maxIndexVel = len(velrange)
874 885
875 886 #seleccion del espectro
876 887 data_spc = self.dataOut.data_spc[:,minIndexVel:maxIndexVel+1,minIndex:maxIndex+1]
877 888 #estimacion de ruido
878 889 noise = numpy.zeros(self.dataOut.nChannels)
879 890
880 891 for channel in range(self.dataOut.nChannels):
881 892 daux = data_spc[channel,:,:]
882 893 noise[channel] = hildebrand_sekhon(daux, self.dataOut.nIncohInt)
883 894
884 895 self.dataOut.noise_estimation = noise.copy()
885 896
886 897 return 1
887 898
888 899 class IncohInt(Operation):
889 900
890 901
891 902 __profIndex = 0
892 903 __withOverapping = False
893 904
894 905 __byTime = False
895 906 __initime = None
896 907 __lastdatatime = None
897 908 __integrationtime = None
898 909
899 910 __buffer_spc = None
900 911 __buffer_cspc = None
901 912 __buffer_dc = None
902 913
903 914 __dataReady = False
904 915
905 916 __timeInterval = None
906 917
907 918 n = None
908 919
909 920
910 921
911 922 def __init__(self, **kwargs):
912 923
913 924 Operation.__init__(self, **kwargs)
914 925 # self.isConfig = False
915 926
916 927 def setup(self, n=None, timeInterval=None, overlapping=False):
917 928 """
918 929 Set the parameters of the integration class.
919 930
920 931 Inputs:
921 932
922 933 n : Number of coherent integrations
923 934 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
924 935 overlapping :
925 936
926 937 """
927 938
928 939 self.__initime = None
929 940 self.__lastdatatime = 0
930 941
931 942 self.__buffer_spc = 0
932 943 self.__buffer_cspc = 0
933 944 self.__buffer_dc = 0
934 945
935 946 self.__profIndex = 0
936 947 self.__dataReady = False
937 948 self.__byTime = False
938 949
939 950 if n is None and timeInterval is None:
940 951 raise ValueError, "n or timeInterval should be specified ..."
941 952
942 953 if n is not None:
943 954 self.n = int(n)
944 955 else:
945 956 self.__integrationtime = int(timeInterval) #if (type(timeInterval)!=integer) -> change this line
946 957 self.n = None
947 958 self.__byTime = True
948 959
949 960 def putData(self, data_spc, data_cspc, data_dc):
950 961
951 962 """
952 963 Add a profile to the __buffer_spc and increase in one the __profileIndex
953 964
954 965 """
955 966
956 967 self.__buffer_spc += data_spc
957 968
958 969 if data_cspc is None:
959 970 self.__buffer_cspc = None
960 971 else:
961 972 self.__buffer_cspc += data_cspc
962 973
963 974 if data_dc is None:
964 975 self.__buffer_dc = None
965 976 else:
966 977 self.__buffer_dc += data_dc
967 978
968 979 self.__profIndex += 1
969 980
970 981 return
971 982
972 983 def pushData(self):
973 984 """
974 985 Return the sum of the last profiles and the profiles used in the sum.
975 986
976 987 Affected:
977 988
978 989 self.__profileIndex
979 990
980 991 """
981 992
982 993 data_spc = self.__buffer_spc
983 994 data_cspc = self.__buffer_cspc
984 995 data_dc = self.__buffer_dc
985 996 n = self.__profIndex
986 997
987 998 self.__buffer_spc = 0
988 999 self.__buffer_cspc = 0
989 1000 self.__buffer_dc = 0
990 1001 self.__profIndex = 0
991 1002
992 1003 return data_spc, data_cspc, data_dc, n
993 1004
994 1005 def byProfiles(self, *args):
995 1006
996 1007 self.__dataReady = False
997 1008 avgdata_spc = None
998 1009 avgdata_cspc = None
999 1010 avgdata_dc = None
1000 1011
1001 1012 self.putData(*args)
1002 1013
1003 1014 if self.__profIndex == self.n:
1004 1015
1005 1016 avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData()
1006 1017 self.n = n
1007 1018 self.__dataReady = True
1008 1019
1009 1020 return avgdata_spc, avgdata_cspc, avgdata_dc
1010 1021
1011 1022 def byTime(self, datatime, *args):
1012 1023
1013 1024 self.__dataReady = False
1014 1025 avgdata_spc = None
1015 1026 avgdata_cspc = None
1016 1027 avgdata_dc = None
1017 1028
1018 1029 self.putData(*args)
1019 1030
1020 1031 if (datatime - self.__initime) >= self.__integrationtime:
1021 1032 avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData()
1022 1033 self.n = n
1023 1034 self.__dataReady = True
1024 1035
1025 1036 return avgdata_spc, avgdata_cspc, avgdata_dc
1026 1037
1027 1038 def integrate(self, datatime, *args):
1028 1039
1029 1040 if self.__profIndex == 0:
1030 1041 self.__initime = datatime
1031 1042
1032 1043 if self.__byTime:
1033 1044 avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime(datatime, *args)
1034 1045 else:
1035 1046 avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args)
1036 1047
1037 1048 if not self.__dataReady:
1038 1049 return None, None, None, None
1039 1050
1040 1051 return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc
1041 1052
1042 1053 def run(self, dataOut, n=None, timeInterval=None, overlapping=False):
1043 1054
1044 1055 if n==1:
1045 1056 return
1046 1057
1047 1058 dataOut.flagNoData = True
1048 1059
1049 1060 if not self.isConfig:
1050 1061 self.setup(n, timeInterval, overlapping)
1051 1062 self.isConfig = True
1052 1063
1053 1064 avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime,
1054 1065 dataOut.data_spc,
1055 1066 dataOut.data_cspc,
1056 1067 dataOut.data_dc)
1057 1068
1058 1069 if self.__dataReady:
1059 1070
1060 1071 dataOut.data_spc = avgdata_spc
1061 1072 dataOut.data_cspc = avgdata_cspc
1062 1073 dataOut.data_dc = avgdata_dc
1063 1074
1064 1075 dataOut.nIncohInt *= self.n
1065 1076 dataOut.utctime = avgdatatime
1066 1077 dataOut.flagNoData = False
1067 1078
@@ -1,1 +1,1
1 <Project description="Segundo Test" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/2018" /><Parameter format="date" id="191113" name="startDate" value="2018/01/26" /><Parameter format="date" id="191114" name="endDate" value="2018/01/26" /><Parameter format="time" id="191115" name="startTime" value="17:45:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:00" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="1" /></Operation><Operation id="19112" name="printInfo" priority="2" type="self" /><Operation id="19113" name="printNumberOfBlock" priority="3" type="self" /></ReadUnit><ProcUnit datatype="Parameters" id="1913" inputId="1912" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralFilters" priority="2" type="other"><Parameter format="float" id="191321" name="PositiveLimit" value="1.5" /><Parameter format="float" id="191322" name="NegativeLimit" value="12.5" /></Operation><Operation id="19133" name="PrecipitationProc" priority="3" type="other" /><Operation id="19134" name="ParametersPlot" priority="4" type="other"><Parameter format="int" id="191341" name="id" value="10" /><Parameter format="str" id="191342" name="wintitle" value="First_gg" /><Parameter format="str" id="191343" name="colormap" value="ocean_r" /><Parameter format="int" id="191344" name="zmin" value="00" /><Parameter format="int" id="191345" name="zmax" value="40" /><Parameter format="int" id="191346" name="ymin" value="0" /><Parameter format="int" id="191347" name="ymax" value="11" /><Parameter format="int" id="191348" name="xmin" value="17" /><Parameter format="int" id="191349" name="xmax" value="24" /><Parameter format="int" id="191350" name="save" value="1" /><Parameter format="str" id="191351" name="figpath" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/2018" /></Operation><Operation id="19135" name="SpcParamPlot" priority="5" type="other"><Parameter format="int" id="191351" name="id" value="21" /><Parameter format="str" id="191352" name="wintitle" value="Primer eco removido" /><Parameter format="str" id="191353" name="xaxis" value="velocity" /><Parameter format="int" id="191354" name="showprofile" value="1" /><Parameter format="int" id="191355" name="zmin" value="10" /><Parameter format="int" id="191356" name="zmax" value="40" /><Parameter format="int" id="191357" name="ymin" value="0" /><Parameter format="int" id="191358" name="ymax" value="10" /><Parameter format="int" id="191359" name="Selector" value="1" /></Operation></ProcUnit><ProcUnit datatype="SpectraProc" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="setRadarFrequency" priority="2" type="self"><Parameter format="float" id="191221" name="frequency" value="445.09e6" /></Operation></ProcUnit></Project> No newline at end of file
1 <Project description="Segundo Test" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra" /><Parameter format="date" id="191113" name="startDate" value="2018/02/23" /><Parameter format="date" id="191114" name="endDate" value="2018/02/23" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="03:59:50" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="1" /></Operation><Operation id="19112" name="printInfo" priority="2" type="self" /><Operation id="19113" name="printNumberOfBlock" priority="3" type="self" /></ReadUnit><ProcUnit datatype="Parameters" id="1913" inputId="1912" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralFilters" priority="2" type="other"><Parameter format="float" id="191321" name="PositiveLimit" value="1.5" /><Parameter format="float" id="191322" name="NegativeLimit" value="12.5" /></Operation><Operation id="19133" name="FullSpectralAnalysis" priority="3" type="other"><Parameter format="float" id="191331" name="SNRlimit" value="-16" /><Parameter format="float" id="191332" name="Xi01" value="1.500" /><Parameter format="float" id="191333" name="Xi02" value="1.500" /><Parameter format="float" id="191334" name="Xi12" value="0" /><Parameter format="float" id="191335" name="Eta01" value="0.875" /><Parameter format="float" id="191336" name="Eta02" value="-0.875" /><Parameter format="float" id="191337" name="Eta12" value="-1.750" /></Operation><Operation id="19134" name="WindProfilerPlot" priority="4" type="other"><Parameter format="int" id="191341" name="id" value="4" /><Parameter format="str" id="191342" name="wintitle" value="Wind Profiler" /><Parameter format="float" id="191343" name="xmin" value="0" /><Parameter format="float" id="191344" name="xmax" value="4" /><Parameter format="float" id="191345" name="ymin" value="0" /><Parameter format="int" id="191346" name="ymax" value="4" /><Parameter format="float" id="191347" name="zmin" value="-20" /><Parameter format="float" id="191348" name="zmax" value="20" /><Parameter format="float" id="191349" name="SNRmin" value="-20" /><Parameter format="float" id="191350" name="SNRmax" value="20" /><Parameter format="float" id="191351" name="zmin_ver" value="-200" /><Parameter format="float" id="191352" name="zmax_ver" value="200" /><Parameter format="float" id="191353" name="SNRthresh" value="-20" /><Parameter format="int" id="191354" name="save" value="1" /><Parameter format="str" id="191355" name="figpath" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/ImagenesTesis" /></Operation><Operation id="19135" name="ParamWriter" priority="5" type="other"><Parameter format="str" id="191351" name="path" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/ImagenesTesis" /><Parameter format="int" id="191352" name="blocksPerFile" value="500" /><Parameter format="list" id="191353" name="metadataList" value="heightList,timeZone,paramInterval" /><Parameter format="list" id="191354" name="dataList" value="data_output,utctime,utctimeInit" /></Operation></ProcUnit><ProcUnit datatype="SpectraProc" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="setRadarFrequency" priority="2" type="self"><Parameter format="float" id="191221" name="frequency" value="445.09e6" /></Operation><Operation id="19123" name="setH0" priority="3" type="self"><Parameter format="float" id="191231" name="h0" value="0.500" /></Operation></ProcUnit></Project> No newline at end of file
@@ -1,151 +1,152
1 1 #!/usr/bin/env python
2 2 import os, sys
3 3
4 4 # path = os.path.dirname(os.getcwd())
5 5 # path = os.path.join(path, 'source')
6 6 # sys.path.insert(0, '../')
7 7
8 8 from schainpy.controller import Project
9 9
10 10 xmin = '15.5'
11 11 xmax = '24'
12 12
13 13
14 14 desc = "ProcBLTR Test"
15 15 filename = "ProcBLTR.xml"
16 figpath = '/media/erick/6F60F7113095A154/BLTR'
16 figpath = '/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/2018'
17 17
18 18 controllerObj = Project()
19 19
20 20
21 21 controllerObj.setup(id='191', name='test01', description=desc)
22 22
23 23 readUnitConfObj = controllerObj.addReadUnit(datatype='BLTRSpectraReader',
24 24 #path='/media/erick/6F60F7113095A154/BLTR/',
25 #path='/data/BLTR',
25 26 path='/home/erick/Documents/Data/BLTR_Data/fdt/',
26 endDate='2017/10/19',
27 startTime='13:00:00',
28 startDate='2016/11/8',
27 endDate='2016/11/01',
28 startTime='0:00:00',
29 startDate='2016/11/01',
29 30 endTime='23:59:59',
30 31
31 32
32 33 online=0,
33 34 walk=0,
34 35 ReadMode='1')
35 36 # expLabel='')
36 37
37 38 # opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
38 39
39 40 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
40 41
41 42
42 43 opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
43 44 opObj11.addParameter(name='n', value='2', format='float')
44 45
45 46 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
46 47 #opObj10 = procUnitConfObj1.addOperation(name='removeInterference2')
47 48
48 49 # opObj10 = procUnitConfObj1.addOperation(name='calcMag')
49 50
50 51 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
51 52 # opObj11.addParameter(name='id', value='21', format='int')
52 53 # opObj11.addParameter(name='wintitle', value='SpectraCutPlot', format='str')
53 54 # opObj11.addParameter(name='xaxis', value='frequency', format='str')
54 55 # opObj11.addParameter(name='colormap', value='winter', format='str')
55 56 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
56 57 # opObj11.addParameter(name='xmax', value='0.005', format='float')
57 58 # #opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
58 59 # #opObj10.addParameter(name='channelList', value='0,1', format='intlist')
59 60 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
60 61 # opObj11.addParameter(name='id', value='21', format='int')
61 62 # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
62 63 # #opObj11.addParameter(name='xaxis', value='Velocity', format='str')
63 64
64 65 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
65 66 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
66 67 # opObj11.addParameter(name='xmax', value='0.005', format='float')
67 68
68 69 # opObj11.addParameter(name='ymin', value='225', format='float')
69 70 # opObj11.addParameter(name='ymax', value='3000', format='float')
70 71 # opObj11.addParameter(name='zmin', value='-100', format='int')
71 72 # opObj11.addParameter(name='zmax', value='-65', format='int')
72 73
73 74 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
74 75 # opObj11.addParameter(name='id', value='10', format='int')
75 76 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
76 77 # opObj11.addParameter(name='ymin', value='0', format='float')
77 78 # opObj11.addParameter(name='ymax', value='4000', format='float')
78 79 # #opObj11.addParameter(name='zmin', value='-100', format='int')
79 80 # #opObj11.addParameter(name='zmax', value='-70', format='int')
80 81 # opObj11.addParameter(name='zmin', value='-90', format='int')
81 82 # opObj11.addParameter(name='zmax', value='-40', format='int')
82 83 # opObj11.addParameter(name='showprofile', value='1', format='int')
83 84 # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int')
84 85
85 opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
86 procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
87 opObj11.addParameter(name='id', value='2005', format='int')
88 opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
89 # opObj11.addParameter(name='exp_code', value='13', format='int')
90 opObj11.addParameter(name='xaxis', value='Velocity', format='str')
86 # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
87 # procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
88 # opObj11.addParameter(name='id', value='2005', format='int')
89 # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
90 # # opObj11.addParameter(name='exp_code', value='13', format='int')
91 # opObj11.addParameter(name='xaxis', value='Velocity', format='str')
91 92 #opObj11.addParameter(name='xmin', value='-10', format='float')
92 93 #opObj11.addParameter(name='xmax', value='10', format='float')
93 94 #opObj11.addParameter(name='ymin', value='225', format='float')
94 95 #opObj11.addParameter(name='ymax', value='3000', format='float')
95 96 #opObj11.addParameter(name='phase_min', value='-4', format='int')
96 97 #opObj11.addParameter(name='phase_max', value='4', format='int')
97 98
98 99 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj1.getId())
99 100 # procUnitConfObj2.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
100 101
101 102 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
102 opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
103 #opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
103 104 opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
104 opObj22.addParameter(name='SNRlimit', value='7', format='float')
105 opObj22.addParameter(name='SNRlimit', value='2', format='float')
105 106
106 107 opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
107 108 opObj22.addParameter(name='id', value='4', format='int')
108 109 opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
109 opObj22.addParameter(name='save', value='1', format='bool')
110 #opObj22.addParameter(name='save', value='1', format='bool')
110 111 # opObj22.addParameter(name='figpath', value = '/home/erick/Pictures', format='str')
111 112
112 113 opObj22.addParameter(name='zmin', value='-20', format='int')
113 114 opObj22.addParameter(name='zmax', value='20', format='int')
114 115 opObj22.addParameter(name='zmin_ver', value='-300', format='float')
115 116 opObj22.addParameter(name='zmax_ver', value='300', format='float')
116 117 opObj22.addParameter(name='SNRmin', value='-5', format='int')
117 118 opObj22.addParameter(name='SNRmax', value='30', format='int')
118 119 # opObj22.addParameter(name='SNRthresh', value='-3.5', format='float')
119 120 opObj22.addParameter(name='xmin', value='0', format='float')
120 121 opObj22.addParameter(name='xmax', value='24', format='float')
121 122 opObj22.addParameter(name='ymin', value='225', format='float')
122 123 #opObj22.addParameter(name='ymax', value='2000', format='float')
123 124 opObj22.addParameter(name='save', value='1', format='int')
124 125 opObj22.addParameter(name='figpath', value=figpath, format='str')
125 126
126 127
127 128 # opObj11.addParameter(name='pairlist', value='(1,0),(0,2),(1,2)', format='pairsList')
128 129 #opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
129 130 #opObj10.addParameter(name='minHei', value='225', format='float')
130 131 #opObj10.addParameter(name='maxHei', value='1000', format='float')
131 132
132 133 # opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other')
133 134 # opObj11.addParameter(name='id', value='102', format='int')
134 135 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
135 136 # opObj11.addParameter(name='ymin', value='225', format='float')
136 137 # opObj11.addParameter(name='ymax', value='4000', format='float')
137 138
138 139 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
139 140 # opObj11.addParameter(name='xmin', value='8.5', format='float')
140 141 # opObj11.addParameter(name='xmax', value='9.5', format='float')
141 142 # opObj11.addParameter(name='figpath', value=figpath, format='str')
142 143 # opObj11.addParameter(name='save', value=1, format='bool')
143 144 # opObj11.addParameter(name='pairsList', value='(1,0),(3,2)', format='pairsList')
144 145
145 146 # opObj12 = procUnitConfObj1.addOperation(name='PublishData', optype='other')
146 147 # opObj12.addParameter(name='zeromq', value=1, format='int')
147 148 # opObj12.addParameter(name='verbose', value=0, format='bool')
148 149 # opObj12.addParameter(name='server', value='erick2', format='str')
149 150 controllerObj.start()
150 151
151 152
@@ -1,239 +1,239
1 1 import os, sys
2 2
3 3 from schainpy.controller import Project
4 4
5 5 if __name__ == '__main__':
6 6
7 7 desc = "Segundo Test"
8 8 filename = "schain.xml"
9 9
10 pathW='/media/erick/6F60F7113095A154/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra'
11 figpath = '/media/erick/6F60F7113095A154/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra'
10 pathW='/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra'
11 figpath = '/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra'
12 12
13 13 controllerObj = Project()
14 14
15 15 controllerObj.setup(id='191', name='test01', description=desc)
16 16
17 17 readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader',
18 path='/media/erick/6F60F7113095A154/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/',
18 path='/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA',
19 19 #path='/home/erick/Documents/Data/Claire_Data/raw',
20 startDate='2018/02/01',
21 endDate='2018/02/01',
22 startTime='12:00:00',
23 endTime='20:00:00',
20 startDate='2018/02/22',
21 endDate='2018/02/24',
22 startTime='00:00:00',
23 endTime='23:59:00',
24 24 online=0,
25 25 walk=1)
26 26
27 27 opObj00 = readUnitConfObj.addOperation(name='printInfo')
28 28 #
29 29 # procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc',
30 30 # inputId=readUnitConfObj.getId())
31 31 #
32 32 # opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
33 33 # opObj10.addParameter(name='minHei', value='0', format='float')
34 34 # opObj10.addParameter(name='maxHei', value='8', format='float')
35 35 #
36 36 # opObj10 = procUnitConfObj0.addOperation(name='filterByHeights')
37 37 # opObj10.addParameter(name='window', value='2', format='float')
38 38 #
39 39 # opObj10 = procUnitConfObj0.addOperation(name='Decoder', optype='external')
40 40 # opObj10.addParameter(name='code', value='1,-1', format='intlist')
41 41 # opObj10.addParameter(name='nCode', value='2', format='float')
42 42 # opObj10.addParameter(name='nBaud', value='1', format='float')
43 43 #
44 44 #
45 45 # opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
46 46 # opObj10.addParameter(name='n', value='1296', format='float')
47 47
48 48 opObj00 = readUnitConfObj.addOperation(name='printNumberOfBlock')
49 49
50 50 procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc',
51 51 inputId=readUnitConfObj.getId())
52 52
53 53
54 54 opObj10 = procUnitConfObj0.addOperation(name='setRadarFrequency')
55 55 opObj10.addParameter(name='frequency', value='445.09e6', format='float')
56 56
57 57 opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
58 58 opObj10.addParameter(name='n', value='2', format='float')
59 59
60 60 #opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
61 61 #opObj10.addParameter(name='minHei', value='1', format='float')
62 62 #opObj10.addParameter(name='maxHei', value='15', format='float')
63 63
64 64 #opObj10 = procUnitConfObj0.addOperation(name='selectFFTs')
65 65 #opObj10.addParameter(name='minHei', value='', format='float')
66 66 #opObj10.addParameter(name='maxHei', value='', format='float')
67 67
68 68 procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc',
69 69 inputId=procUnitConfObj0.getId())
70 70
71 71 # Creating a processing object with its parameters
72 72 # schainpy.model.proc.jroproc_spectra.SpectraProc.run()
73 73 # If you need to add more parameters can use the "addParameter method"
74 74 procUnitConfObj1.addParameter(name='nFFTPoints', value='256', format='int')
75 75
76 76
77 77 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
78 78 #opObj10 = procUnitConfObj1.addOperation(name='removeInterference')
79 79 opObj10 = procUnitConfObj1.addOperation(name='IncohInt', optype='external')
80 80 opObj10.addParameter(name='n', value='10', format='float')
81 81
82 82
83 83
84 84 #opObj10 = procUnitConfObj1.addOperation(name='selectFFTs')
85 85 #opObj10.addParameter(name='minFFT', value='-15', format='float')
86 86 #opObj10.addParameter(name='maxFFT', value='15', format='float')
87 87
88 88
89 89
90 90 opObj10 = procUnitConfObj1.addOperation(name='SpectraWriter', optype='other')
91 91 opObj10.addParameter(name='blocksPerFile', value='64', format = 'int')
92 92 opObj10.addParameter(name='path', value=pathW)
93 93 # Using internal methods
94 94 # schainpy.model.proc.jroproc_spectra.SpectraProc.selectChannels()
95 95 # opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
96 96 # opObj10.addParameter(name='channelList', value='0,1', format='intlist')
97 97
98 98 # Using internal methods
99 99 # schainpy.model.proc.jroproc_spectra.SpectraProc.selectHeights()
100 100 # opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
101 101 # opObj10.addParameter(name='minHei', value='90', format='float')
102 102 # opObj10.addParameter(name='maxHei', value='180', format='float')
103 103
104 104 # Using external methods (new modules)
105 105 # #schainpy.model.proc.jroproc_spectra.IncohInt.setup()
106 106 # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
107 107 # opObj12.addParameter(name='n', value='1', format='int')
108 108
109 109 # Using external methods (new modules)
110 110 # schainpy.model.graphics.jroplot_spectra.SpectraPlot.setup()
111 111 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
112 112 opObj11.addParameter(name='id', value='11', format='int')
113 113 opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
114 114 opObj11.addParameter(name='xaxis', value='velocity', format='str')
115 115 # opObj11.addParameter(name='xmin', value='-10', format='int')
116 116 # opObj11.addParameter(name='xmax', value='10', format='int')
117 117
118 118 # opObj11.addParameter(name='ymin', value='1', format='float')
119 119 # opObj11.addParameter(name='ymax', value='3', format='int')
120 120 #opObj11.addParameter(name='zmin', value='10', format='int')
121 121 #opObj11.addParameter(name='zmax', value='35', format='int')
122 122 # opObj11.addParameter(name='save', value='2', format='int')
123 123 # opObj11.addParameter(name='save', value='5', format='int')
124 124 # opObj11.addParameter(name='figpath', value=figpath, format='str')
125 125
126 126
127 127 opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
128 128 procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
129 129 opObj11.addParameter(name='id', value='2005', format='int')
130 130 #opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
131 131 #opObj11.addParameter(name='exp_code', value='13', format='int')
132 132 opObj11.addParameter(name='xaxis', value='Velocity', format='str')
133 133 #opObj11.addParameter(name='xmin', value='-6', format='float')
134 134 #opObj11.addParameter(name='xmax', value='6', format='float')
135 135 opObj11.addParameter(name='zmin', value='15', format='float')
136 136 opObj11.addParameter(name='zmax', value='50', format='float')
137 137 opObj11.addParameter(name='ymin', value='0', format='float')
138 138 opObj11.addParameter(name='ymax', value='7', format='float')
139 139 #opObj11.addParameter(name='phase_min', value='-4', format='int')
140 140 #opObj11.addParameter(name='phase_max', value='4', format='int')
141 141 #
142 142
143 143 # Using external methods (new modules)
144 144 # schainpy.model.graphics.jroplot_spectra.RTIPlot.setup()
145 145 opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
146 146 opObj11.addParameter(name='id', value='30', format='int')
147 147 opObj11.addParameter(name='wintitle', value='RTI', format='str')
148 148 opObj11.addParameter(name='zmin', value='15', format='int')
149 149 opObj11.addParameter(name='zmax', value='40', format='int')
150 150 opObj11.addParameter(name='ymin', value='1', format='int')
151 151 opObj11.addParameter(name='ymax', value='7', format='int')
152 152 opObj11.addParameter(name='showprofile', value='1', format='int')
153 153 # opObj11.addParameter(name='timerange', value=str(5*60*60*60), format='int')
154 154 #opObj11.addParameter(name='xmin', value='1', format='float')
155 155 #opObj11.addParameter(name='xmax', value='6', format='float')
156 156 opObj11.addParameter(name='save', value='1', format='int')
157 157 opObj11.addParameter(name='figpath', value=figpath, format='str')
158 158
159 159
160 160 # '''#########################################################################################'''
161 161 #
162 162 #
163 163 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
164 164 # opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
165 165 #
166 166 # '''
167 167 # # Discriminacion de ecos
168 168 # opObj11 = procUnitConfObj2.addOperation(name='GaussianFit', optype='other')
169 169 # opObj11.addParameter(name='SNRlimit', value='0', format='int')
170 170 # '''
171 171 #
172 172 # '''
173 173 # # Estimacion de Precipitacion
174 174 # opObj11 = procUnitConfObj2.addOperation(name='PrecipitationProc', optype='other')
175 175 # '''
176 176 #
177 177 # opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
178 178 #
179 179 # opObj22.addParameter(name='SNRlimit', value='-10', format='float')
180 180 # opObj22.addParameter(name='E01', value='1.500', format='float')
181 181 # opObj22.addParameter(name='E02', value='1.500', format='float')
182 182 # opObj22.addParameter(name='E12', value='0', format='float')
183 183 # opObj22.addParameter(name='N01', value='0.875', format='float')
184 184 # opObj22.addParameter(name='N02', value='-0.875', format='float')
185 185 # opObj22.addParameter(name='N12', value='-1.750', format='float')
186 186 #
187 187 #
188 188 # opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
189 189 # opObj22.addParameter(name='id', value='4', format='int')
190 190 # opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
191 191 # opObj22.addParameter(name='save', value='1', format='bool')
192 192 # opObj22.addParameter(name='xmin', value='0', format='float')
193 193 # opObj22.addParameter(name='xmax', value='6', format='float')
194 194 # opObj22.addParameter(name='ymin', value='1', format='float')
195 195 # opObj22.addParameter(name='ymax', value='3.5', format='float')
196 196 # opObj22.addParameter(name='zmin', value='-1', format='float')
197 197 # opObj22.addParameter(name='zmax', value='1', format='float')
198 198 # opObj22.addParameter(name='SNRmin', value='-15', format='float')
199 199 # opObj22.addParameter(name='SNRmax', value='20', format='float')
200 200 # opObj22.addParameter(name='zmin_ver', value='-200', format='float')
201 201 # opObj22.addParameter(name='zmax_ver', value='200', format='float')
202 202 # opObj22.addParameter(name='save', value='1', format='int')
203 203 # opObj22.addParameter(name='figpath', value=figpath, format='str')
204 204 #
205 205 #
206 206 #
207 207 # #opObj11.addParameter(name='zmin', value='75', format='int')
208 208 #
209 209 # #opObj12 = procUnitConfObj2.addOperation(name='ParametersPlot', optype='other')
210 210 # #opObj12.addParameter(name='id',value='4',format='int')
211 211 # #opObj12.addParameter(name='wintitle',value='First_gg',format='str')
212 212 # '''
213 213 # #Ploteo de Discriminacion de Gaussianas
214 214 #
215 215 # opObj11 = procUnitConfObj2.addOperation(name='FitGauPlot', optype='other')
216 216 # opObj11.addParameter(name='id', value='21', format='int')
217 217 # opObj11.addParameter(name='wintitle', value='Rainfall Gaussian', format='str')
218 218 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
219 219 # opObj11.addParameter(name='showprofile', value='1', format='int')
220 220 # opObj11.addParameter(name='zmin', value='75', format='int')
221 221 # opObj11.addParameter(name='zmax', value='100', format='int')
222 222 # opObj11.addParameter(name='GauSelector', value='1', format='int')
223 223 # #opObj11.addParameter(name='save', value='1', format='int')
224 224 # #opObj11.addParameter(name='figpath', value='/home/erick/Documents/Data/d2015106')
225 225 #
226 226 # opObj11 = procUnitConfObj2.addOperation(name='FitGauPlot', optype='other')
227 227 # opObj11.addParameter(name='id', value='22', format='int')
228 228 # opObj11.addParameter(name='wintitle', value='Wind Gaussian', format='str')
229 229 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
230 230 # opObj11.addParameter(name='showprofile', value='1', format='int')
231 231 # opObj11.addParameter(name='zmin', value='75', format='int')
232 232 # opObj11.addParameter(name='zmax', value='100', format='int')
233 233 # opObj11.addParameter(name='GauSelector', value='0', format='int')
234 234 # '''
235 235 #
236 236 #
237 237
238 238
239 239 controllerObj.start()
General Comments 0
You need to be logged in to leave comments. Login now