##// END OF EJS Templates
22/08/2017
ebocanegra -
r1006:8363978b5396
parent child
Show More

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

@@ -1,109 +1,106
1 <<<<<<< HEAD
2 1 # Byte-compiled / optimized / DLL files
3 2 __pycache__/
4 3 *.py[cod]
5 4 *$py.class
6 5
7 6 # C extensions
8 7 *.so
9 8
10 9 # Distribution / packaging
11 10 .Python
12 11 env/
13 12 build/
14 13 develop-eggs/
15 14 dist/
16 15 downloads/
17 16 eggs/
18 17 .eggs/
19 18 lib/
20 19 lib64/
21 20 parts/
22 21 sdist/
23 22 var/
24 23 wheels/
25 24 *.egg-info/
26 25 .installed.cfg
27 26 *.egg
28 27
29 28 # PyInstaller
30 29 # Usually these files are written by a python script from a template
31 30 # before PyInstaller builds the exe, so as to inject date/other infos into it.
32 31 *.manifest
33 32 *.spec
34 33
35 34 # Installer logs
36 35 pip-log.txt
37 36 pip-delete-this-directory.txt
38 37
39 38 # Unit test / coverage reports
40 39 htmlcov/
41 40 .tox/
42 41 .coverage
43 42 .coverage.*
44 43 .cache
45 44 nosetests.xml
46 45 coverage.xml
47 46 *,cover
48 47 .hypothesis/
49 48
50 49 # Translations
51 50 *.mo
52 51 *.pot
53 52
54 53 # Django stuff:
55 54 *.log
56 55 local_settings.py
57 56
58 57 # Flask stuff:
59 58 instance/
60 59 .webassets-cache
61 60
62 61 # Scrapy stuff:
63 62 .scrapy
64 63
65 64 # Sphinx documentation
66 65 docs/_build/
67 66
68 67 # PyBuilder
69 68 target/
70 69
71 70 # Jupyter Notebook
72 71 .ipynb_checkpoints
73 72
74 73 # pyenv
75 74 .python-version
76 75
77 76 # celery beat schedule file
78 77 celerybeat-schedule
79 78
80 79 # SageMath parsed files
81 80 *.sage.py
82 81
83 82 # dotenv
84 83 .env
85 84
86 85 # virtualenv
87 86 .venv
88 87 venv/
89 88 ENV/
90 89
91 90 # Spyder project settings
92 91 .spyderproject
93 92 .spyproject
94 93
95 94 # Rope project settings
96 95 .ropeproject
97 96
98 97 # mkdocs documentation
99 98 /site
100 99
101 100 # eclipse
102 101 .project
103 102 .pydevproject
104 =======
105 build/
106 dist/
107 schainpy.egg-info/
108 103 .svn/
109 >>>>>>> 08c4507d6c3c48f6c52326d5dedfa1972fb26356
104 *.png
105 *.pyc
106 schainpy/scripts
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,19 +1,19
1 1 '''
2 2
3 3 $Author: murco $
4 4 $Id: JRODataIO.py 169 2012-11-19 21:57:03Z murco $
5 5 '''
6 6
7 7 from jroIO_voltage import *
8 8 from jroIO_spectra import *
9 9 from jroIO_heispectra import *
10 10 from jroIO_usrp import *
11 11
12 12 from jroIO_kamisr import *
13 13 from jroIO_param import *
14 14 from jroIO_hf import *
15 15
16 16 from jroIO_bltr import *
17 17 from jroIO_mira35c import *
18 #from io_bltr_block import *
18 from io_bltr_block import *
19 19
1 NO CONTENT: modified file, binary diff hidden
@@ -1,948 +1,950
1 1 '''
2 2 Created on Nov 9, 2016
3 3
4 4 @author: roj- LouVD
5 5 '''
6 6
7 7 import numpy
8 8 import os.path
9 9 import sys
10 10 import time
11 11 import datetime
12 12 from sys import path
13 13 from os.path import dirname
14 14 from mimify import HeaderFile
15 15 from numpy import size, asarray
16 16 from datetime import datetime
17 17 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
18 18 from schainpy.model.data.jrodata import Parameters
19 19 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader
20 20 from schainpy.model.graphics.jroplot_parameters import WindProfilerPlot
21 21 from schainpy.model.io.jroIO_base import *
22 22
23 23 import schainpy
24 24 #import madrigal
25 25 #import madrigal.cedar
26 26 #from madrigal.cedar import MadrigalCatalogRecord
27 27
28 28 import warnings
29 29 from time import gmtime
30 30 from math import floor
31
31 32 warnings.simplefilter("error")
32 33 from numpy.lib.nanfunctions import nansum
33 34 warnings.simplefilter('ignore', FutureWarning)
34 35
35 36
36 37 class testBLTRReader(ProcessingUnit):
37 38
38 39
39 def __init__(self):
40 def __init__(self, **kwargs):
40 41
41 42 path = None
42 43 startDate = None
43 44 endDate = None
44 45 startTime = None
45 46 endTime = None
46 47 startTime = None
47 48 endTime = None
48 49
49 50 isConfig = False
50 51 dataOut = None
51 52 walk = None
52 53 ext = 'swwma'
53 54 fileList = []
54 55 fileIndex = -1
55 56 timezone = None
56 57 filename = None
57 58
58 59 timearray = None
59 60 height = None
60 61 snr_ref = None
61 62 zon_ref = None
62 63 ver_ref = None
63 64 mer_ref = None
64 65 nmodes = None
65 66 nchannels = None
66 67 nranges = None
67 68 year = None
68 69 month = None
69 70 day = None
70 71 lat = None
71 72 lon = None
72 73 siteFile = None
73 74
74 ProcessingUnit.__init__(self)
75 ProcessingUnit.__init__(self , **kwargs)
75 76 self.dataOut = self.createObjByDefault()
76 77 self.imode = 0
77 78 self.counter_records = 0
78 79
79 80 self.isConfig = False
80 81 self.flagNoMoreFiles = 0
81 82
82 83 self.buffer = None
83 84
84 85
85 86 def createObjByDefault(self):
86 87
87 88 dataObj = Parameters()
88 89
89 90 return dataObj
90 91
91 92 def info(self):
92 93 '''
93 94 Experience information
94 95
95 96 '''
96 97 self.hoy = datetime.datetime.now()
97 98 place = 'Jicamarca Radio Observatory'
98 99 signalchainweb='http://jro-dev.igp.gob.pe:3000/projects/signal-chain/wiki/Manual_de_Desarrollador'
99 100 print '{} at {}'.format(self.hoy,place)
100 101 print 'Boundary Layer and Tropospheric Radar (BLTR) script, Wind velocities and SNR from *.sswma files'
101 102 print '{} \n'.format(signalchainweb)
102 103
103 def run(self, path, startDate, endDate, ext, startTime, endTime):
104 def run(self, path, startDate, endDate, ext, startTime, endTime, queue=None):
104 105
105 106 if not(self.isConfig):
106 107 self.setup(path, startDate, endDate, ext)
107 108 self.isConfig = True
108 109
109 110 self.getData()
110 111
111 112 def setup(self,
112 113 path=None,
113 114 startDate=None,
114 115 endDate=None,
115 116 ext=None,
116 117 startTime=datetime.time(0, 0, 0),
117 118 endTime=datetime.time(23, 59, 59),
118 119 timezone=0):
119 120
120 121 self.info()
121 122 self.path = path
122 123 if self.path == None:
123 124 raise ValueError, "The path is not valid"
124 125
125 126 if ext == None:
126 127 ext = self.ext
127 128
128 129 self.searchFiles(self.path, startDate, endDate, ext)
129 130
130 131 self.timezone = timezone
131 132 self.ext = ext
132 133 self.fileIndex = -1
133 134
134 135 if not(self.fileList):
135 136 raise Warning, "There is no files matching these date in the folder: %s. \n Check 'startDate' and 'endDate' "%(path)
136 137
137 138
138 139 if not(self.setNextFile()):
139 140
140 141 print 'not next file'
141 142 if (startDate!=None) and (endDate!=None):
142 143 print "No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
143 144 elif startDate != None:
144 145 print "No files in range: %s" %(datetime.datetime.combine(startDate,startTime).ctime())
145 146 else:
146 147 print "No files"
147 148
148 149 sys.exit(-1)
149 150
150 151 def searchFiles(self, path, startDate, endDate, ext=None):
151 152 '''
152 153 Searching for BLTR rawdata file in path
153 154 Creating a list of file to proces included in [startDate,endDate]
154 155
155 156 Input:
156 157 path - Path to find BLTR rawdata files
157 158 startDate - Select file from this date
158 159 enDate - Select file until this date
159 160 ext - Extension of the file to read
160 161
161 162 '''
162 163
163 164 fullpath = path
164 165 foldercounter = 0
165 166
166 167 print 'Searching file in %s ' % (fullpath)
167 168 fileList0 = glob.glob1(fullpath, "*%s" % ext)
168 169 fileList0.sort()
169 170
170 171 self.fileList = []
171 172 self.dateFileList = []
172 173
173 174 for thisFile in fileList0:
174 175 year = thisFile[-14:-10]
175 176 if not isNumber(year):
176 177 continue
177 178
178 179 month = thisFile[-10:-8]
179 180 if not isNumber(month):
180 181 continue
181 182
182 183 day = thisFile[-8:-6]
183 184 if not isNumber(day):
184 185 continue
185 186
186 187 year, month, day = int(year), int(month), int(day)
187 188 dateFile = datetime.date(year, month, day)
188 189
189 190 if not ((startDate <= dateFile) and (endDate > dateFile)):
190 191 continue
191 192
192 193 self.fileList.append(thisFile)
193 194 self.dateFileList.append(dateFile)
194 195
195 196 return 1
196 197
197 198
198 199 def setNextFile(self):
199 200
200 201 idFile = self.fileIndex
201 202
202 203 while (True):
203 204 idFile += 1
204 205 if idFile >= len(self.fileList):
205 206 print '\nNo more files in the folder'
206 207 print 'Total number of file(s) read : {}'.format(self.fileIndex + 1)
207 208 print 'Time of processing : {}'.format(datetime.datetime.now()- self.hoy)
208 209 self.flagNoMoreFiles = 1
209 210 return 0
210 211 if self.isConfig: print '------------------------[Next File]---------------------------'
211 212 filename = os.path.join(self.path, self.fileList[idFile])
212 213 self.Open(filename)
213 214
214 215 print '\n[Setting file] (%s) ...' % self.fileList[idFile]
215 216
216 217 break
217 218
218 219 self.flagIsNewFile =0
219 220
220 221 self.fileIndex = idFile
221 222 self.filename = filename
222 223 print 'File:',self.filename
223 224
224 225 return 1
225 226
226 227 def readDataBlock(self):
227 228
228 229
229 230 self.readHeader()
230 231 self.dataRecords(0)
231 232
232 233 print '[New Record] record: {} /{} // file {}/{}'.format(self.counter_records,self.nrecords,self.fileIndex+1,len(self.fileList))
233 234
234 235 self.setDataBuffer()
235 236
236 237 self.flagIsNewBlock = 1
237 238
238 239 if self.counter_records > self.nrecords:
239 240 self.flagIsNewFile = 1
240 241 return 0
241 242
242 243 return 1
243 244
244 245 def setDataBuffer(self):
245 246
246 247 '''
247 248 Storing data from one block
248 249
249 250 '''
250 251 self.t = datetime.datetime(self.year, self.month, self.day)
251 252 self.doy = time.localtime(time.mktime(self.t.timetuple())).tm_yday
252 253 self.buffer = numpy.squeeze(numpy.array([[self.one_snr],[self.one_zonal],[self.one_vertical],[self.one_meridional],
253 254 [self.time],[self.height],[self.fileIndex],
254 255 [self.year],[self.month],[self.day],[self.t],[self.doy]]))
255 256
256 257 self.dataOut.time1 = self.time1
257 258
258 259 def Open(self, filename):
259 260 '''
260 261 Opening BLTR rawdata file defined by filename
261 262
262 263 Inputs:
263 264
264 265 filename - Full path name of BLTR rawdata file
265 266
266 267 '''
267 268 [dir, name] = os.path.split(filename)
268 269 strFile = name.split('.')
269 270 self.siteFile = strFile[0] # 'peru2' ---> Piura - 'peru1' ---> Huancayo or Porcuya
270 271
271 272 self.filename = filename
272 273 if os.path.isfile(self.filename) == False:
273 274 print 'File do not exist. Check "filename"'
274 275 sys.exit(0)
275 276
276 277 self.h_file = numpy.dtype([
277 278 ('FMN', '<u4'),
278 279 ('nrec', '<u4'),
279 280 ('fr_offset', '<u4'),
280 281 ('id', '<u4'),
281 282 ('site', 'u1', (32,))
282 283 ])
283 284 self.pointer = open(self.filename, 'rb') # rb : Read Binary
284
285 print self.filename
285 286 self.header_file = numpy.fromfile(self.pointer, self.h_file, 1)
286
287 print self.header_file
287 288 self.nrecords = self.header_file['nrec'][0]
288 289
289 290 self.sizeOfFile = os.path.getsize(self.filename)
290 291
291 292 self.time = numpy.zeros([2, self.nrecords], dtype='u4')
292 293 self.counter_records = 0
293 294 self.count = 0
294 295 self.flag_initialArray = False
295 296
296 297 self.year = 0
297 298 self.month = 0
298 299 self.day = 0
299 300
300 301 def hasNotDataInBuffer(self):
301 302
302 303 if self.buffer == None:
303 304 return 1
304 305 return 0
305 306
306 307 def getData(self):
307 308 '''
308 309 Storing data from databuffer to dataOut object
309 310
310 311 '''
311 312 if self.flagNoMoreFiles==1:
312 313 self.dataOut.flagNoData = True
313 314 print 'No file left to process'
314 315 return 0
315 316
316 317 self.flagIsNewBlock = 0
317 318
318 319 if self.hasNotDataInBuffer():
319 320
320 321 if self.flagIsNewFile==0:
321 322
322 323 self.readNextBlock()
323 324 '''RETURN A BLOCK OF DATA'''
324 325 if self.flagNoMoreFiles==0:
325 326 self.dataOut.data_SNR = self.buffer[0]
326 327 self.dataOut.time = self.buffer[4]
327 328 self.dataOut.height = self.height
328 329
329 330 self.dataOut.height= self.height
330 331 self.dataOut.data_output = numpy.squeeze(numpy.array([[self.buffer[1]],
331 332 [self.buffer[3]],
332 333 [self.buffer[2]]]))
333 334
334 335 #
335 336
336 337 self.dataOut.day, self.dataOut.month, self.dataOut.year = self.buffer[9], self.buffer[8], self.buffer[7]
337 338
338 339 self.dataOut.utctimeInit = self.time1
339 340 self.dataOut.utctime = self.dataOut.utctimeInit
340 341 self.dataOut.counter_records = self.counter_records
341 342 self.dataOut.nrecords = self.nrecords
342 343
343 344 self.setHeader()
344 345
345 346 self.buffer = None
346 347 self.dataOut.flagNoData = False
347 348
348 349 def readNextBlock(self):
349 350
350 351 if not(self.setNewBlock()):
351 352 return 0
352 353
353 354 if not(self.readDataBlock()):
354 355 return 0
355 356
356 357 if self.flagIsNewFile:
357 358 self.setNextFile()
358 359
359 360 return 1
360 361
361 362 def setNewBlock(self):
362 363
363 364 if self.pointer==None:
364 365 return 0
365 366
366 367 if self.flagIsNewFile:
367 368 return 1
368 369
369 370 if self.counter_records < self.nrecords:
370 371 return 1
371 372
372 373 if not(self.setNextFile()):
373 374 return 0
374 375
375 376 return 1
376 377
377 378 def readHeader(self):
378 379 '''
379 380 RecordHeader of BLTR rawdata file
380 381 '''
381 382 if self.pointer.tell() == self.sizeOfFile:
382 383 print 'End of File'
383 384 return
384 385
385 386 self.h_rec1 = numpy.dtype([
386 387 ('rmn', '<u4'),
387 388 ('rcounter', '<u4'),
388 389 ('nr_offset', '<u4'),
389 390 ('tr_offset', '<u4'),
390 391 ('time', '<u4'),
391 392 ('time_msec', '<u4'),
392 393 ('tag', 'u1', (32,)),
393 394 ('comments', 'u1', (32,)),
394 395 ('lat', '<f4'),
395 396 ('lon', '<f4'),
396 397 ('gps_status', '<u4'),
397 398 ('freq', '<u4'),
398 399 ('freq0', '<u4'),
399 400 ('nchan', '<u4'),
400 401 ('delta_r', '<u4'),
401 402 ('nranges', '<u4'),
402 403 ('r0', '<u4'),
403 404 ('prf', '<u4'),
404 405 ('ncoh', '<u4'),
405 406 ('npoints', '<u4'),
406 407 ('polarization', '<i4'),
407 408 ('rx_filter', '<u4'),
408 409 ('nmodes', '<u4'),
409 410 ('dmode_index', '<u4'),
410 411 ('dmode_rngcorr', '<u4'),
411 412 ('nrxs', '<u4'),
412 413 ('acf_length', '<u4'),
413 414 ('acf_lags', '<u4'),
414 415 ('sea_to_atmos', '<f4'),
415 416 ('sea_notch', '<u4'),
416 417 ('lh_sea', '<u4'),
417 418 ('hh_sea', '<u4'),
418 419 ('nbins_sea', '<u4'),
419 420 ('min_snr', '<f4'),
420 421 ('min_cc', '<f4'),
421 422 ('max_time_diff', '<f4')
422 423 ])
423 424
424 425 self.header_rec1 = numpy.fromfile(self.pointer, self.h_rec1, 1)
425 426 self.lat = self.header_rec1['lat'][0]
426 427 self.lon = self.header_rec1['lon'][0]
427 428 self.nchannels = self.header_rec1['nchan'][0] / 2
428 429 self.kchan = self.header_rec1['nrxs'][0]
429 430 self.nranges = self.header_rec1['nranges'][0]
430 431 self.deltha = self.header_rec1['delta_r'][0]
431 432
432 433 self.correction = self.header_rec1['dmode_rngcorr'][0]
433 434 self.nmodes = self.header_rec1['nmodes'][0]
434 435 self.imode = self.header_rec1['dmode_index'][0]
435 436
436 437 self.h_rec2 = numpy.dtype([
437 438 ('antenna_coord', 'f4', (2, self.nchannels)),
438 439 ('rx_gains', 'u4', (self.nchannels,)),
439 440 ('rx_analysis', 'u4', (self.nchannels,))
440 441 ])
441 442
442 443 self.header_rec2 = numpy.fromfile(self.pointer, self.h_rec2, 1) # header rec2
443 444 self.antenna = self.header_rec2['antenna_coord']
444 445 self.rx_gains = self.header_rec2['rx_gains']
445 446
446 447 self.d_rec = numpy.dtype ([
447 448 ('range', '<u4'),
448 449 ('status', '<u4'),
449 450 ('zonal', '<f4'),
450 451 ('meridional', '<f4'),
451 452 ('vertical', '<f4'),
452 453 ('zonal_a', '<f4'),
453 454 ('meridional_a', '<f4'),
454 455 ('corrected_fading', '<f4'), # seconds
455 456 ('uncorrected_fading', '<f4'), # seconds
456 457 ('time_diff', '<f4'),
457 458 ('major_axis', '<f4'),
458 459 ('axial_ratio', '<f4'),
459 460 ('orientation', '<f4'),
460 461 ('sea_power', '<u4'),
461 462 ('sea_algorithm', '<u4'),
462 463 ('rx_saturation', 'u4', (self.nchannels,)),
463 464 ('chan_offset', 'u4', (2 * self.nchannels,)),
464 465 ('rx_amp', 'u4', (self.nchannels,)),
465 466 ('rx_snr', 'f4', (self.nchannels,)),
466 467 ('cross_snr', 'f4', (self.kchan,)),
467 468 ('sea_power_relative', 'f4', (self.kchan,))
468 469 ])
469 470
470 471 # Memory allocation
471 472 if not(self.flag_initialArray):
472 473 self.height = numpy.zeros([2, self.nranges], dtype='f4') + numpy.nan
473 474 self.p_zonal = numpy.zeros([self.nrecords, self.nranges, 2], dtype='f4') + numpy.nan
474 475 self.p_meridional = numpy.zeros([self.nrecords, self.nranges, 2], dtype='f4') + numpy.nan
475 476 self.p_vertical = numpy.zeros([self.nrecords, self.nranges, 2], dtype='f4') + numpy.nan
476 477 self.p_snr = numpy.zeros([self.nrecords, self.nranges, self.kchan, 2], dtype='f4') + numpy.nan
477 478 self.flag_initialArray = True
478 479
479 480 self.time[self.imode, self.count] = self.header_rec1['time'][0]
480 481 self.time1 = self.header_rec1['time'][0]
481 482 tseconds = self.header_rec1['time'][0]
482 483 local_t1 = time.localtime(tseconds)
483 484 self.year = local_t1.tm_year
484 485 self.month = local_t1.tm_mon
485 486 self.day = local_t1.tm_mday
486 487 self.t = datetime.datetime(self.year, self.month, self.day)
487 488
488 489
489 490 def setHeader(self):
490 491 '''
491 492 Saving metada on dataOut object
492 493
493 494 '''
494 495 self.dataOut.type = 'Parameters'
495 496 self.dataOut.useLocalTime = False
496 self.dataOut.outputInterval = 157
497 # self.dataOut.outputInterval = 157
498 self.dataOut.paramInterval = 157
497 499 self.dataOut.timezone = self.timezone
498 500 self.dataOut.site = self.siteFile
499 501 self.dataOut.nrecords = self.nrecords
500 502 self.dataOut.sizeOfFile = self.sizeOfFile
501 503 self.dataOut.lat = self.lat
502 504 self.dataOut.lon = self.lon
503 505 self.dataOut.nchannels = self.nchannels
504 506 self.dataOut.kchan = self.kchan
505 507 self.dataOut.nranges = self.nranges
506 508 self.dataOut.deltha = self.deltha
507 509 self.dataOut.correction = self.correction
508 510 self.dataOut.nmodes = self.nmodes
509 511 self.dataOut.imode = self.imode
510 512 self.dataOut.antenna = self.antenna
511 513 self.dataOut.rx_gains = self.rx_gains
512 514
513 515 def dataRecords(self, status_value):
514 516 '''
515 517 Reading and filtering data block record of BLTR rawdata file, filtering is according to status_value.
516 518
517 519 Input:
518 520 status_value - Array data is set to NAN for values that are not equal to status_value
519 521
520 522 '''
521 523 data_rec = numpy.fromfile(self.pointer, self.d_rec, self.nranges)
522 524 status = []
523 525 zonal = []
524 526 meridional = []
525 527 vertical = []
526 528 rx_snr = []
527 529
528 530 index = 0
529 531 for rec in data_rec:
530 532 status.append(rec['status'])
531 533 zonal.append(rec['zonal'])
532 534 meridional.append(rec['meridional'])
533 535 vertical.append(rec['vertical'])
534 536 self.height[self.imode, index] = (rec['range'] - self.correction) / 1000.
535 537 numpy.seterr(all='ignore')
536 538 index = index + 1
537 539 rx_snr.append(rec['rx_snr'])
538 540
539 541 status = numpy.array(status, dtype='int')
540 542 zonal = numpy.array(zonal, dtype='float')
541 543 meridional = numpy.array(meridional, dtype='float')
542 544 vertical = numpy.array(vertical, dtype='float')
543 545 rx_snr = numpy.array(rx_snr, dtype='float')
544 546
545 547
546 548
547 549 rx_snr = rx_snr.reshape((self.nranges, self.nchannels))
548 550
549 551 # FILTERING DATA
550 552 stvalue = status_value
551 553 zonal[numpy.where(zonal == -9999.)] = numpy.nan
552 554 zonal[numpy.where(status != stvalue)] = numpy.nan
553 555 self.p_zonal[self.count, :, self.imode] = zonal
554 556 self.one_zonal= self.p_zonal[self.count, :, :]
555 557
556 558 meridional[numpy.where(meridional == -9999.)] = numpy.nan
557 559 meridional[numpy.where(status != stvalue)] = numpy.nan
558 560 self.p_meridional[self.count, :, self.imode] = meridional
559 561 self.one_meridional = self.p_meridional[self.count, :, :]
560 562
561 563 vertical[numpy.where(vertical == -9999.)] = numpy.nan
562 564 vertical[numpy.where(status != stvalue)] = numpy.nan
563 565 self.p_vertical[self.count, :, self.imode] = vertical
564 566 self.one_vertical = self.p_vertical[self.count, :, :]
565 567
566 568 rx_snr[numpy.where(rx_snr == -9999.)] = numpy.nan
567 569 rx_snr[numpy.where(status != stvalue), :] = numpy.nan
568 570
569 571
570 572 for k in range(self.kchan):
571 573 self.p_snr[self.count, :, k, self.imode] = numpy.power(10, rx_snr[:, k] / 10)
572 574
573 575 self.one_snr = self.p_snr[self.count, :, :, :]
574 576 if self.nmodes == 2:
575 577 self.count = self.count + self.imode
576 578 else:
577 579 self.count = self.count + 1
578 580
579 581 self.imode +=1
580 582 self.counter_records = self.counter_records + 1
581 583
582 584 self.zon_ref = self.p_zonal
583 585 self.ver_ref = self.p_vertical
584 586 self.mer_ref = self.p_meridional
585 587 self.snr_ref = self.p_snr
586 588
587 589
588 590
589 591
590 592 def Close (self):
591 593 '''
592 594 Closing BLTR rawdata file
593 595 '''
594 596 if self.pointer.tell() == self.sizeOfFile:
595 597 self.pointer.close()
596 598 return
597 599
598 600
599 601
600 602 class testBLTRWriter(Operation):
601 603
602 604
603 605 def __init__(self):
604 606
605 607 Operation.__init__(self)
606 608 self.dataOut = Parameters()
607 609 self.path = None
608 610 self.dataOut = None
609 611 self.flagIsNewFile=1
610 612 self.ext = ".hdf5"
611 613
612 614 return
613 615
614 616 def run(self, dataOut, path , modetowrite,**kwargs):
615 617
616 618 if self.flagIsNewFile:
617 619 flagdata = self.setup(dataOut, path, modetowrite)
618 620
619 621 self.putData()
620 622 return
621 623
622 624 def setup(self, dataOut, path, modetowrite):
623 625 '''
624 626 Recovering data to write in new *.hdf5 file
625 627 Inputs:
626 628 modew -- mode to write (1 or 2)
627 629 path -- destination path
628 630
629 631 '''
630 632
631 633 self.im = modetowrite-1
632 634 if self.im!=0 and self.im!=1:
633 635 raise ValueError, 'Check "modetowrite" value. Must be egual to 1 or 2, "{}" is not valid. '.format(modetowrite)
634 636
635 637 self.dataOut = dataOut
636 638 self.nmodes = self.dataOut.nmodes
637 639 self.nchannels = self.dataOut.nchannels
638 640 self.lat = self.dataOut.lat
639 641 self.lon = self.dataOut.lon
640 642 self.hcm = 3
641 643 self.thisDate = self.dataOut.utctimeInit
642 644 self.year = self.dataOut.year
643 645 self.month = self.dataOut.month
644 646 self.day = self.dataOut.day
645 647 self.path = path
646 648
647 649 self.flagIsNewFile = 0
648 650
649 651 return 1
650 652
651 653 def setFile(self):
652 654 '''
653 655 - Determining the file name for each mode of operation
654 656 kinst - Kind of Instrument (mnemotic)
655 657 kindat - Kind of Data (mnemotic)
656 658
657 659 - Creating a cedarObject
658 660
659 661 '''
660 662 lat_piura = -5.17
661 663 lat_huancayo = -12.04
662 664 lat_porcuya = -5.8
663 665
664 666 if '%2.2f' % self.lat == '%2.2f' % lat_piura:
665 667 self.instMnemonic = 'pbr'
666 668
667 669 elif '%2.2f' % self.lat == '%2.2f' % lat_huancayo:
668 670 self.instMnemonic = 'hbr'
669 671
670 672 elif '%2.2f' % self.lat == '%2.2f' % lat_porcuya:
671 673 self.instMnemonic = 'obr'
672 674 else: raise Warning, "The site of file read doesn't match any site known. Only file from Huancayo, Piura and Porcuya can be processed.\n Check the file "
673 675
674 676 mode = ['_mode1','_mode2']
675 677
676 678 self.hdf5filename = '%s%4.4d%2.2d%2.2d%s%s' % (self.instMnemonic,
677 679 self.year,
678 680 self.month,
679 681 self.day,
680 682 mode[self.im],
681 683 self.ext)
682 684
683 685 self.fullname=os.path.join(self.path,self.hdf5filename)
684 686
685 687 if os.path.isfile(self.fullname) :
686 688 print "Destination path '%s' already exists. Previous file deleted. " %self.fullname
687 689 os.remove(self.fullname)
688 690
689 691 # Identify kinst and kindat
690 692 InstName = self.hdf5filename[0:3]
691 693 KinstList = [1000, 1001, 1002]
692 694 KinstId = {'pbr':0, 'hbr':1, 'obr':2} # pbr:piura, hbr:huancayo, obr:porcuya
693 695 KindatList = [1600, 1601] # mode 1, mode 2
694 696 self.type = KinstId[InstName]
695 697 self.kinst = KinstList[self.type]
696 698 self.kindat = KindatList[self.im]
697 699
698 700 try:
699 701 self.cedarObj = madrigal.cedar.MadrigalCedarFile(self.fullname, True)
700 702 except ValueError, message:
701 703 print '[Error]: Impossible to create a cedar object with "madrigal.cedar.MadrigalCedarFile" '
702 704 return
703 705
704 706 return 1
705 707
706 708 def writeBlock(self):
707 709 '''
708 710 - Selecting mode of operation:
709 711
710 712 bltr high resolution mode 1 - Low Atmosphere (0 - 3km) // bltr high resolution mode 2 - High Atmosphere (0 - 10km)
711 713 msnr - Average Signal Noise Ratio in dB
712 714 hcm - 3 km
713 715
714 716 - Filling the cedarObject by a block: each array data entry is assigned a code that defines the parameter to write to the file
715 717
716 718 GDLATR - Reference geod latitude (deg)
717 719 GDLONR - Reference geographic longitude (deg)
718 720 GDLAT2 - Geodetic latitude of second inst (deg)
719 721 GLON2 - Geographic longitude of second inst (deg)
720 722
721 723 GDALT - Geodetic altitude (height) (km)
722 724 SNL - Log10 (signal to noise ratio)
723 725 VN1P2 - Neutral wind in direction 1 (eastward) (m/s), ie zonal wind
724 726 VN2P2 - Neutral wind in direction 2 (northward) (m/s), ie meridional wind
725 727 EL2 - Ending elevation angle (deg), ie vertical wind
726 728
727 729 Other parameters: /madrigal3/metadata/parcodes.tab
728 730
729 731 '''
730 732
731 733 self.z_zon = self.dataOut.data_output[0,:,:]
732 734 self.z_mer =self.dataOut.data_output[1,:,:]
733 735 self.z_ver = self.dataOut.data_output[2,:,:]
734 736
735 737 if self.im == 0:
736 738 h_select = numpy.where(numpy.bitwise_and(self.dataOut.height[0, :] >= 0., self.dataOut.height[0, :] <= self.hcm, numpy.isfinite(self.dataOut.height[0, :])))
737 739 else:
738 740 h_select = numpy.where(numpy.bitwise_and(self.dataOut.height[0, :] >= 0., self.dataOut.height[0, :] < 20, numpy.isfinite(self.dataOut.height[0, :])))
739 741
740 742 ht = h_select[0]
741 743
742 744 self.o_height = self.dataOut.height[self.im, ht]
743 745 self.o_zon = self.z_zon[ht, self.im]
744 746 self.o_mer = self.z_mer[ht, self.im]
745 747 self.o_ver = self.z_ver[ht, self.im]
746 748 o_snr = self.dataOut.data_SNR[ :, :, self.im]
747 749
748 750 o_snr = o_snr[ht, :]
749 751
750 752 ndiv = numpy.nansum((numpy.isfinite(o_snr)), 1)
751 753 ndiv = ndiv.astype(float)
752 754
753 755 sel_div = numpy.where(ndiv == 0.)
754 756 ndiv[sel_div] = numpy.nan
755 757
756 758 if self.nchannels > 1:
757 759 msnr = numpy.nansum(o_snr, axis=1)
758 760 else:
759 761 msnr = o_snr
760 762
761 763 try:
762 764 self.msnr = 10 * numpy.log10(msnr / ndiv)
763 765 except ZeroDivisionError:
764 766 self.msnr = 10 * numpy.log10(msnr /1)
765 767 print 'Number of division (ndiv) egal to 1 by default. Check SNR'
766 768
767 769 time_t = time.gmtime(self.dataOut.time1)
768 770 year = time_t.tm_year
769 771 month = time_t.tm_mon
770 772 day = time_t.tm_mday
771 773 hour = time_t.tm_hour
772 774 minute = time_t.tm_min
773 775 second = time_t.tm_sec
774 776 timedate_0 = datetime.datetime(year, month, day, hour, minute, second)
775 777
776 778 # 1d parameters
777 779 GDLATR = self.lat
778 780 GDLONR = self.lon
779 781 GDLAT2 = self.lat
780 782 GLON2 = self.lon
781 783
782 784 # 2d parameters
783 785 GDALT = self.o_height
784 786
785 787 SNL = self.msnr
786 788 VN1P2 = self.o_zon
787 789 VN2P2 = self.o_mer
788 790 EL2 = self.o_ver
789 791 NROW = len(self.o_height)
790 792
791 793 startTime = timedate_0
792 794 endTime = startTime
793 795 self.dataRec = madrigal.cedar.MadrigalDataRecord(self.kinst,
794 796 self.kindat,
795 797 startTime.year,
796 798 startTime.month,
797 799 startTime.day,
798 800 startTime.hour,
799 801 startTime.minute,
800 802 startTime.second,
801 803 0,
802 804 endTime.year,
803 805 endTime.month,
804 806 endTime.day,
805 807 endTime.hour,
806 808 endTime.minute,
807 809 endTime.second,
808 810 0,
809 811 ('gdlatr', 'gdlonr', 'gdlat2', 'glon2'),
810 812 ('gdalt', 'snl', 'vn1p2', 'vn2p2', 'el2'),
811 813 NROW, ind2DList=['gdalt'])
812 814
813 815 # Setting 1d values
814 816 self.dataRec.set1D('gdlatr', GDLATR)
815 817 self.dataRec.set1D('gdlonr', GDLONR)
816 818 self.dataRec.set1D('gdlat2', GDLAT2)
817 819 self.dataRec.set1D('glon2', GLON2)
818 820
819 821 # Setting 2d values
820 822 for n in range(self.o_height.shape[0]):
821 823 self.dataRec.set2D('gdalt', n, GDALT[n])
822 824 self.dataRec.set2D('snl', n, SNL[n])
823 825 self.dataRec.set2D('vn1p2', n, VN1P2[n])
824 826 self.dataRec.set2D('vn2p2', n, VN2P2[n])
825 827 self.dataRec.set2D('el2', n, EL2[n])
826 828
827 829 # Appending new data record
828 830 '''
829 831 [MADRIGAL3]There are two ways to write to a MadrigalCedarFile. Either this method (write) is called after all the
830 832 records have been appended to the MadrigalCedarFile, or dump is called after a certain number of records are appended,
831 833 and then at the end dump is called a final time if there were any records not yet dumped, followed by addArray.
832 834 '''
833 835
834 836 self.cedarObj.append(self.dataRec)
835 837 print ' [Writing] records {} (mode {}).'.format(self.dataOut.counter_records,self.im+1)
836 838 self.cedarObj.dump()
837 839
838 840
839 841
840 842
841 843 def setHeader(self):
842 844 '''
843 845 - Creating self.catHeadObj
844 846 - Adding information catalog
845 847 - Writing file header
846 848
847 849 '''
848 850 self.catHeadObj = madrigal.cedar.CatalogHeaderCreator(self.fullname)
849 851 kindatDesc, comments, analyst, history, principleInvestigator = self._info_BLTR()
850 852
851 853 self.catHeadObj.createCatalog(principleInvestigator="Jarjar",
852 854 expPurpose='characterize the atmospheric dynamics in this region where frequently it happens the El Nino',
853 855 sciRemarks="http://madrigal3.haystack.mit.edu/static/CEDARMadrigalHdf5Format.pdf")
854 856
855 857 self.catHeadObj.createHeader(kindatDesc, analyst, comments, history)
856 858
857 859 self.catHeadObj.write()
858 860
859 861 print '[File created] path: %s' % (self.fullname)
860 862
861 863 def putData(self):
862 864
863 865 if self.dataOut.flagNoData:
864 866 return 0
865 867
866 868 if self.dataOut.counter_records == 1:
867 869 self.setFile()
868 870 print '[Writing] Setting new hdf5 file for the mode {}'.format(self.im+1)
869 871
870 872 if self.dataOut.counter_records <= self.dataOut.nrecords:
871 873 self.writeBlock()
872 874
873 875
874 876 if self.dataOut.counter_records == self.dataOut.nrecords:
875 877 self.cedarObj.addArray()
876 878
877 879 self.setHeader()
878 880 self.flagIsNewFile = 1
879 881
880 882 def _info_BLTR(self):
881 883
882 884 kindatDesc = '''--This header is for KINDAT = %d''' % self.kindat
883 885 history = None
884 886 analyst = '''Jarjar'''
885 887 principleInvestigator = '''
886 888 Jarjar
887 889 Radio Observatorio de Jicamarca
888 890 Instituto Geofisico del Peru
889 891
890 892 '''
891 893 if self.type == 1:
892 894 comments = '''
893 895
894 896 --These data are provided by two Boundary Layer and Tropospheric Radar (BLTR) deployed at two different locations at Peru(GMT-5), one of them at Piura(5.17 S, 80.64W) and another located at Huancayo (12.04 S, 75.32 W).
895 897
896 898 --The purpose of conducting these observations is to measure wind in the differents levels of height, this radar makes measurements the Zonal(U), Meridional(V) and Vertical(W) wind velocities component in northcoast from Peru. And the main purpose of these mensurations is to characterize the atmospheric dynamics in this region where frequently it happens the 'El Nino Phenomenon'
897 899
898 900 --In Kindat = 1600, contains information of wind velocities component since 0 Km to 3 Km.
899 901
900 902 --In Kindat = 1601, contains information of wind velocities component since 0 Km to 10 Km.
901 903
902 904 --The Huancayo-BLTR is a VHF Profiler Radar System is a 3 channel coherent receiver pulsed radar utilising state-of-the-art software and computing techniques to acquire, decode, and translate signals obtained from partial reflection echoes in the troposphere, lower stratosphere and mesosphere. It uses an array of three horizontal spaced and vertically directed receiving antennas. The data is recorded thirty seconds, averaged to one minute mean values of Height, Zonal, Meridional and Vertical wind.
903 905
904 906 --The Huancayo-BLTR was installed in January 2010. This instrument was designed and constructed by Genesis Soft Pty. Ltd. Is constituted by three groups of spaced antennas (distributed) forming an isosceles triangle.
905 907
906 908
907 909 Station _______ Geographic Coord ______ Geomagnetic Coord
908 910
909 911 _______________ Latitude _ Longitude __ Latitude _ Longitude
910 912
911 913 Huancayo (HUA) __12.04 S ___ 75.32 W _____ -12.05 ____ 352.85
912 914 Piura (PIU) _____ 5.17 S ___ 80.64 W ______ 5.18 ____ 350.93
913 915
914 916 WIND OBSERVATIONS
915 917
916 918 --To obtain wind the BLTR uses Spaced Antenna technique (e.g., Briggs 1984). The scatter and reflection it still provided by variations in the refractive index as in the Doppler method(Gage and Basley,1978; Balsley and Gage 1982; Larsen and Rottger 1982), but instead of using the Doppler shift to derive the velocity components, the cross-correlation between signals in an array of three horizontally spaced and vertically directed receiving antennas is used.
917 919
918 920 ......................................................................
919 921 For more information, consult the following references:
920 922 - Balsley, B. B., and K. S. Gage., On the use of radars for operational wind profiling, Bull. Amer. Meteor.Soc.,63, 1009-1018, 1982.
921 923
922 924 - Briggs, B. H., The analysis of spaced sensor data by correations techniques, Handbook for MAP, Vol. 13, SCOTEP Secretariat, University of Illinois, Urbana, 166-186, 1984.
923 925
924 926 - Gage, K. S., and B.B. Balsley., Doppler radar probing of the clear atmosphere, Bull. Amer. Meteor.Soc., 59, 1074-1093, 1978.
925 927
926 928 - Larsen, M. F., The Spaced Antenna Technique for Radar Wind Profiling, Journal of Atm. and Ocean. Technology. , Vol.6, 920-937, 1989.
927 929
928 930 - Larsen, M. F., A method for single radar voracity measurements?, Handbook for MAP,SCOSTEP Secretariat, University of the Illinois, Urban, in press, 1989.
929 931 ......................................................................
930 932
931 933 ACKNOWLEDGEMENTS:
932 934
933 935 --The Piura and Huancayo BLTR are part of the network of instruments operated by the Jicamarca Radio Observatory.
934 936
935 937 --The Jicamarca Radio Observatory is a facility of the Instituto Geofisico del Peru operated with support from the NSF Cooperative Agreement ATM-0432565 through Cornell University
936 938
937 939 ......................................................................
938 940
939 941 Further questions and comments should be addressed to:
940 942 Radio Observatorio de Jicamarca
941 943 Instituto Geofisico del Peru
942 944 Lima, Peru
943 945 Web URL: http://jro.igp.gob.pe
944 946 ......................................................................
945 947 '''
946 948
947 949 return kindatDesc, comments, analyst, history, principleInvestigator
948 950
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,16 +1,16
1 1 '''
2 2
3 3 $Author: murco $
4 4 $Id: Processor.py 1 2012-11-12 18:56:07Z murco $
5 5 '''
6 6
7 7 from jroproc_voltage import *
8 8 from jroproc_spectra import *
9 9 from jroproc_heispectra import *
10 10 from jroproc_amisr import *
11 11 from jroproc_correlation import *
12 12 from jroproc_parameters import *
13 13 from jroproc_spectra_lags import *
14 14 from jroproc_spectra_acf import *
15 #from jroproc_bltr import *
15 from jroproc_bltr import *
16 16
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,576 +1,576
1 1 '''
2 2 Created on Oct 24, 2016
3 3
4 4 @author: roj- LouVD
5 5 '''
6 6
7 7 import numpy
8 8 import copy
9 9 import datetime
10 10 import time
11 11 from time import gmtime
12 12
13 13 from jroproc_base import ProcessingUnit
14 14 from schainpy.model.data.jrodata import Parameters
15 15 from numpy import transpose
16 16
17 17 from matplotlib import cm
18 18 import matplotlib.pyplot as plt
19 19 from matplotlib.mlab import griddata
20 20
21 21
22 22
23 23
24 24 class BLTRProcess(ProcessingUnit):
25 25 isConfig = False
26 26 '''
27 27 Processing unit for BLTR rawdata
28 28
29 29 Inputs:
30 30 self.dataOut.nmodes - Number of operation modes
31 31 self.dataOut.nchannels - Number of channels
32 32 self.dataOut.nranges - Number of ranges
33 33
34 34 self.dataOut.data_SNR - SNR array
35 35 self.dataOut.data_output - Zonal, Vertical and Meridional velocity array
36 36 self.dataOut.height - Height array (km)
37 37 self.dataOut.time - Time array (seconds)
38 38
39 39 self.dataOut.fileIndex -Index of the file currently read
40 40 self.dataOut.lat - Latitude coordinate of BLTR location
41 41
42 42 self.dataOut.doy - Experiment doy (number of the day in the current year)
43 43 self.dataOut.month - Experiment month
44 44 self.dataOut.day - Experiment day
45 45 self.dataOut.year - Experiment year
46 46 '''
47 47
48 def __init__(self):
48 def __init__(self, **kwargs):
49 49 '''
50 50 Inputs: None
51 51
52 52 '''
53 ProcessingUnit.__init__(self)
53 ProcessingUnit.__init__(self, **kwargs)
54 54 self.dataOut = Parameters()
55 55
56 56 # Filters
57 57 snr_val = None
58 58 value = None
59 59 svalue2 = None
60 60 method = None
61 61 factor = None
62 62 filter = None
63 63 npoints = None
64 64 status_value = None
65 65 width = None
66 66 self.flagfirstmode = 0
67 67
68 68 def run (self):
69 69 if self.dataIn.type == "Parameters":
70 70 self.dataOut.copy(self.dataIn)
71 71
72 72
73 73 def TimeSelect(self):
74 74 '''
75 75 Selecting the time array according to the day of the experiment with a duration of 24 hours
76 76 '''
77 77
78 78 k1 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) - datetime.timedelta(hours=5)
79 79 k2 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) + datetime.timedelta(hours=25) - datetime.timedelta(hours=5)
80 80 limit_sec1 = time.mktime(k1.timetuple())
81 81 limit_sec2 = time.mktime(k2.timetuple())
82 82 valid_data = 0
83 83
84 84 doy = self.dataOut.doy
85 85 t1 = numpy.where(self.dataOut.time[0, :] >= limit_sec1)
86 86 t2 = numpy.where(self.dataOut.time[0, :] < limit_sec2)
87 87 time_select = []
88 88 for val_sec in t1[0]:
89 89 if val_sec in t2[0]:
90 90 time_select.append(val_sec)
91 91
92 92 time_select = numpy.array(time_select, dtype='int')
93 93 valid_data = valid_data + len(time_select)
94 94
95 95
96 96 if len(time_select) > 0:
97 97 self.f_timesec = self.dataOut.time[:, time_select]
98 98 snr = self.dataOut.data_SNR[time_select, :, :, :]
99 99 zon = self.dataOut.data_output[0][time_select, :, :]
100 100 mer = self.dataOut.data_output[1][time_select, :, :]
101 101 ver = self.dataOut.data_output[2][time_select, :, :]
102 102
103 103 if valid_data > 0:
104 104 self.timesec1 = self.f_timesec[0, :]
105 105 self.f_height = self.dataOut.height
106 106 self.f_zon = zon
107 107 self.f_mer = mer
108 108 self.f_ver = ver
109 109 self.f_snr = snr
110 110 self.f_timedate = []
111 111 self.f_time = []
112 112
113 113 for valuet in self.timesec1:
114 114 time_t = time.gmtime(valuet)
115 115 year = time_t.tm_year
116 116 month = time_t.tm_mon
117 117 day = time_t.tm_mday
118 118 hour = time_t.tm_hour
119 119 minute = time_t.tm_min
120 120 second = time_t.tm_sec
121 121 f_timedate_0 = datetime.datetime(year, month, day, hour, minute, second)
122 122 self.f_timedate.append(f_timedate_0)
123 123
124 124 return self.f_timedate, self.f_timesec, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr
125 125
126 126 else:
127 127 self.f_timesec = None
128 128 self.f_timedate = None
129 129 self.f_height = None
130 130 self.f_zon = None
131 131 self.f_mer = None
132 132 self.f_ver = None
133 133 self.f_snr = None
134 134 print 'Invalid time'
135 135
136 136 return self.f_timedate, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr
137 137
138 138 def SnrFilter(self, snr_val,modetofilter):
139 139 '''
140 140 Inputs: snr_val - Threshold value
141 141
142 142 '''
143 143 if modetofilter!=2 and modetofilter!=1 :
144 144 raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter)
145 145 m = modetofilter-1
146 146
147 147 print ' SNR filter [mode {}]: SNR <= {}: data_output = NA'.format(modetofilter,snr_val)
148 148 for k in range(self.dataOut.nchannels):
149 149 for r in range(self.dataOut.nranges):
150 150 if self.dataOut.data_SNR[r,k,m] <= snr_val:
151 151 self.dataOut.data_output[2][r,m] = numpy.nan
152 152 self.dataOut.data_output[1][r,m] = numpy.nan
153 153 self.dataOut.data_output[0][r,m] = numpy.nan
154 154
155 155
156 156
157 157 def OutliersFilter(self,modetofilter,svalue,svalue2,method,factor,filter,npoints):
158 158 '''
159 159 Inputs:
160 160 svalue - string to select array velocity
161 161 svalue2 - string to choose axis filtering
162 162 method - 0 for SMOOTH or 1 for MEDIAN
163 163 factor - number used to set threshold
164 164 filter - 1 for data filtering using the standard deviation criteria else 0
165 165 npoints - number of points for mask filter
166 166
167 167 '''
168 168 if modetofilter!=2 and modetofilter!=1 :
169 169 raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter)
170 170
171 171 m = modetofilter-1
172 172
173 173 print ' Outliers Filter [mode {}]: {} {} / threshold = {}'.format(modetofilter,svalue,svalue,factor)
174 174
175 175 npoints = 9
176 176 novalid = 0.1
177 177 if svalue == 'zonal':
178 178 value = self.dataOut.data_output[0]
179 179
180 180 elif svalue == 'meridional':
181 181 value = self.dataOut.data_output[1]
182 182
183 183 elif svalue == 'vertical':
184 184 value = self.dataOut.data_output[2]
185 185
186 186 else:
187 187 print 'value is not defined'
188 188 return
189 189
190 190 if svalue2 == 'inTime':
191 191 yaxis = self.dataOut.height
192 192 xaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]])
193 193
194 194 elif svalue2 == 'inHeight':
195 195 yaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]])
196 196 xaxis = self.dataOut.height
197 197
198 198 else:
199 199 print 'svalue2 is required, either inHeight or inTime'
200 200 return
201 201
202 202 output_array = value
203 203
204 204 value_temp = value[:,m]
205 205 error = numpy.zeros(len(self.dataOut.time[m,:]))
206 206 if svalue2 == 'inHeight':
207 207 value_temp = numpy.transpose(value_temp)
208 208 error = numpy.zeros(len(self.dataOut.height))
209 209
210 210 htemp = yaxis[m,:]
211 211 std = value_temp
212 212 for h in range(len(htemp)):
213 213 if filter: #standard deviation filtering
214 214 std[h] = numpy.std(value_temp[h],ddof = npoints)
215 215 value_temp[numpy.where(std[h] > 5),h] = numpy.nan
216 216 error[numpy.where(std[h] > 5)] = error[numpy.where(std[h] > 5)] + 1
217 217
218 218
219 219 nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0])
220 220 minvalid = novalid*len(xaxis[m,:])
221 221 if minvalid <= npoints:
222 222 minvalid = npoints
223 223
224 224 #only if valid values greater than the minimum required (10%)
225 225 if nvalues_valid > minvalid:
226 226
227 227 if method == 0:
228 228 #SMOOTH
229 229 w = value_temp[h] - self.Smooth(input=value_temp[h], width=npoints, edge_truncate=1)
230 230
231 231
232 232 if method == 1:
233 233 #MEDIAN
234 234 w = value_temp[h] - self.Median(input=value_temp[h], width = npoints)
235 235
236 236 dw = numpy.std(w[numpy.where(numpy.isfinite(w))],ddof = 1)
237 237
238 238 threshold = dw*factor
239 239 value_temp[numpy.where(w > threshold),h] = numpy.nan
240 240 value_temp[numpy.where(w < -1*threshold),h] = numpy.nan
241 241
242 242
243 243 #At the end
244 244 if svalue2 == 'inHeight':
245 245 value_temp = numpy.transpose(value_temp)
246 246 output_array[:,m] = value_temp
247 247
248 248 if svalue == 'zonal':
249 249 self.dataOut.data_output[0] = output_array
250 250
251 251 elif svalue == 'meridional':
252 252 self.dataOut.data_output[1] = output_array
253 253
254 254 elif svalue == 'vertical':
255 255 self.dataOut.data_output[2] = output_array
256 256
257 257 return self.dataOut.data_output
258 258
259 259
260 260 def Median(self,input,width):
261 261 '''
262 262 Inputs:
263 263 input - Velocity array
264 264 width - Number of points for mask filter
265 265
266 266 '''
267 267
268 268 if numpy.mod(width,2) == 1:
269 269 pc = int((width - 1) / 2)
270 270 cont = 0
271 271 output = []
272 272
273 273 for i in range(len(input)):
274 274 if i >= pc and i < len(input) - pc:
275 275 new2 = input[i-pc:i+pc+1]
276 276 temp = numpy.where(numpy.isfinite(new2))
277 277 new = new2[temp]
278 278 value = numpy.median(new)
279 279 output.append(value)
280 280
281 281 output = numpy.array(output)
282 282 output = numpy.hstack((input[0:pc],output))
283 283 output = numpy.hstack((output,input[-pc:len(input)]))
284 284
285 285 return output
286 286
287 287 def Smooth(self,input,width,edge_truncate = None):
288 288 '''
289 289 Inputs:
290 290 input - Velocity array
291 291 width - Number of points for mask filter
292 292 edge_truncate - 1 for truncate the convolution product else
293 293
294 294 '''
295 295
296 296 if numpy.mod(width,2) == 0:
297 297 real_width = width + 1
298 298 nzeros = width / 2
299 299 else:
300 300 real_width = width
301 301 nzeros = (width - 1) / 2
302 302
303 303 half_width = int(real_width)/2
304 304 length = len(input)
305 305
306 306 gate = numpy.ones(real_width,dtype='float')
307 307 norm_of_gate = numpy.sum(gate)
308 308
309 309 nan_process = 0
310 310 nan_id = numpy.where(numpy.isnan(input))
311 311 if len(nan_id[0]) > 0:
312 312 nan_process = 1
313 313 pb = numpy.zeros(len(input))
314 314 pb[nan_id] = 1.
315 315 input[nan_id] = 0.
316 316
317 317 if edge_truncate == True:
318 318 output = numpy.convolve(input/norm_of_gate,gate,mode='same')
319 319 elif edge_truncate == False or edge_truncate == None:
320 320 output = numpy.convolve(input/norm_of_gate,gate,mode='valid')
321 321 output = numpy.hstack((input[0:half_width],output))
322 322 output = numpy.hstack((output,input[len(input)-half_width:len(input)]))
323 323
324 324 if nan_process:
325 325 pb = numpy.convolve(pb/norm_of_gate,gate,mode='valid')
326 326 pb = numpy.hstack((numpy.zeros(half_width),pb))
327 327 pb = numpy.hstack((pb,numpy.zeros(half_width)))
328 328 output[numpy.where(pb > 0.9999)] = numpy.nan
329 329 input[nan_id] = numpy.nan
330 330 return output
331 331
332 332 def Average(self,aver=0,nhaver=1):
333 333 '''
334 334 Inputs:
335 335 aver - Indicates the time period over which is averaged or consensus data
336 336 nhaver - Indicates the decimation factor in heights
337 337
338 338 '''
339 339 nhpoints = 48
340 340
341 341 lat_piura = -5.17
342 342 lat_huancayo = -12.04
343 343 lat_porcuya = -5.8
344 344
345 345 if '%2.2f'%self.dataOut.lat == '%2.2f'%lat_piura:
346 346 hcm = 3.
347 347 if self.dataOut.year == 2003 :
348 348 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
349 349 nhpoints = 12
350 350
351 351 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_huancayo:
352 352 hcm = 3.
353 353 if self.dataOut.year == 2003 :
354 354 if self.dataOut.doy >= 25 and self.dataOut.doy < 64:
355 355 nhpoints = 12
356 356
357 357
358 358 elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_porcuya:
359 359 hcm = 5.#2
360 360
361 361 pdata = 0.2
362 362 taver = [1,2,3,4,6,8,12,24]
363 363 t0 = 0
364 364 tf = 24
365 365 ntime =(tf-t0)/taver[aver]
366 366 ti = numpy.arange(ntime)
367 367 tf = numpy.arange(ntime) + taver[aver]
368 368
369 369
370 370 old_height = self.dataOut.heightList
371 371
372 372 if nhaver > 1:
373 373 num_hei = len(self.dataOut.heightList)/nhaver/self.dataOut.nmodes
374 374 deltha = 0.05*nhaver
375 375 minhvalid = pdata*nhaver
376 376 for im in range(self.dataOut.nmodes):
377 377 new_height = numpy.arange(num_hei)*deltha + self.dataOut.height[im,0] + deltha/2.
378 378
379 379
380 380 data_fHeigths_List = []
381 381 data_fZonal_List = []
382 382 data_fMeridional_List = []
383 383 data_fVertical_List = []
384 384 startDTList = []
385 385
386 386
387 387 for i in range(ntime):
388 388 height = old_height
389 389
390 390 start = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(ti[i])) - datetime.timedelta(hours = 5)
391 391 stop = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(tf[i])) - datetime.timedelta(hours = 5)
392 392
393 393
394 394 limit_sec1 = time.mktime(start.timetuple())
395 395 limit_sec2 = time.mktime(stop.timetuple())
396 396
397 397 t1 = numpy.where(self.f_timesec >= limit_sec1)
398 398 t2 = numpy.where(self.f_timesec < limit_sec2)
399 399 time_select = []
400 400 for val_sec in t1[0]:
401 401 if val_sec in t2[0]:
402 402 time_select.append(val_sec)
403 403
404 404
405 405 time_select = numpy.array(time_select,dtype = 'int')
406 406 minvalid = numpy.ceil(pdata*nhpoints)
407 407
408 408 zon_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
409 409 mer_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
410 410 ver_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan
411 411
412 412 if nhaver > 1:
413 413 new_zon_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
414 414 new_mer_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
415 415 new_ver_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan
416 416
417 417 if len(time_select) > minvalid:
418 418 time_average = self.f_timesec[time_select]
419 419
420 420 for im in range(self.dataOut.nmodes):
421 421
422 422 for ih in range(self.dataOut.nranges):
423 423 if numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im])) >= minvalid:
424 424 zon_aver[ih,im] = numpy.nansum(self.f_zon[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im]))
425 425
426 426 if numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im])) >= minvalid:
427 427 mer_aver[ih,im] = numpy.nansum(self.f_mer[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im]))
428 428
429 429 if numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im])) >= minvalid:
430 430 ver_aver[ih,im] = numpy.nansum(self.f_ver[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im]))
431 431
432 432 if nhaver > 1:
433 433 for ih in range(num_hei):
434 434 hvalid = numpy.arange(nhaver) + nhaver*ih
435 435
436 436 if numpy.sum(numpy.isfinite(zon_aver[hvalid,im])) >= minvalid:
437 437 new_zon_aver[ih,im] = numpy.nansum(zon_aver[hvalid,im]) / numpy.sum(numpy.isfinite(zon_aver[hvalid,im]))
438 438
439 439 if numpy.sum(numpy.isfinite(mer_aver[hvalid,im])) >= minvalid:
440 440 new_mer_aver[ih,im] = numpy.nansum(mer_aver[hvalid,im]) / numpy.sum(numpy.isfinite(mer_aver[hvalid,im]))
441 441
442 442 if numpy.sum(numpy.isfinite(ver_aver[hvalid,im])) >= minvalid:
443 443 new_ver_aver[ih,im] = numpy.nansum(ver_aver[hvalid,im]) / numpy.sum(numpy.isfinite(ver_aver[hvalid,im]))
444 444 if nhaver > 1:
445 445 zon_aver = new_zon_aver
446 446 mer_aver = new_mer_aver
447 447 ver_aver = new_ver_aver
448 448 height = new_height
449 449
450 450
451 451 tstart = time_average[0]
452 452 tend = time_average[-1]
453 453 startTime = time.gmtime(tstart)
454 454
455 455 year = startTime.tm_year
456 456 month = startTime.tm_mon
457 457 day = startTime.tm_mday
458 458 hour = startTime.tm_hour
459 459 minute = startTime.tm_min
460 460 second = startTime.tm_sec
461 461
462 462 startDTList.append(datetime.datetime(year,month,day,hour,minute,second))
463 463
464 464
465 465 o_height = numpy.array([])
466 466 o_zon_aver = numpy.array([])
467 467 o_mer_aver = numpy.array([])
468 468 o_ver_aver = numpy.array([])
469 469 if self.dataOut.nmodes > 1:
470 470 for im in range(self.dataOut.nmodes):
471 471
472 472 if im == 0:
473 473 h_select = numpy.where(numpy.bitwise_and(height[0,:] >=0,height[0,:] <= hcm,numpy.isfinite(height[0,:])))
474 474 else:
475 475 h_select = numpy.where(numpy.bitwise_and(height[1,:] > hcm,height[1,:] < 20,numpy.isfinite(height[1,:])))
476 476
477 477
478 478 ht = h_select[0]
479 479
480 480 o_height = numpy.hstack((o_height,height[im,ht]))
481 481 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
482 482 o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im]))
483 483 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
484 484
485 485 data_fHeigths_List.append(o_height)
486 486 data_fZonal_List.append(o_zon_aver)
487 487 data_fMeridional_List.append(o_mer_aver)
488 488 data_fVertical_List.append(o_ver_aver)
489 489
490 490
491 491 else:
492 492 h_select = numpy.where(numpy.bitwise_and(height[0,:] <= hcm,numpy.isfinite(height[0,:])))
493 493 ht = h_select[0]
494 494 o_height = numpy.hstack((o_height,height[im,ht]))
495 495 o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im]))
496 496 o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im]))
497 497 o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im]))
498 498
499 499 data_fHeigths_List.append(o_height)
500 500 data_fZonal_List.append(o_zon_aver)
501 501 data_fMeridional_List.append(o_mer_aver)
502 502 data_fVertical_List.append(o_ver_aver)
503 503
504 504
505 505 return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List
506 506
507 507
508 508 def prePlot(self,modeselect=None):
509 509
510 510 '''
511 511 Inputs:
512 512
513 513 self.dataOut.data_output - Zonal, Meridional and Vertical velocity array
514 514 self.dataOut.height - height array
515 515 self.dataOut.time - Time array (seconds)
516 516 self.dataOut.data_SNR - SNR array
517 517
518 518 '''
519 519
520 520 m = modeselect -1
521 521
522 522 print ' [Plotting mode {}]'.format(modeselect)
523 523 if not (m ==1 or m==0):
524 524 raise IndexError("'Mode' must be egual to : 1 or 2")
525 525 #
526 526 if self.flagfirstmode==0:
527 527 #copy of the data
528 528 self.data_output_copy = self.dataOut.data_output.copy()
529 529 self.data_height_copy = self.dataOut.height.copy()
530 530 self.data_time_copy = self.dataOut.time.copy()
531 531 self.data_SNR_copy = self.dataOut.data_SNR.copy()
532 532 self.flagfirstmode = 1
533 533
534 534 else:
535 535 self.dataOut.data_output = self.data_output_copy
536 536 self.dataOut.height = self.data_height_copy
537 537 self.dataOut.time = self.data_time_copy
538 538 self.dataOut.data_SNR = self.data_SNR_copy
539 539 self.flagfirstmode = 0
540 540
541 541
542 542 #select data for mode m
543 543 #self.dataOut.data_output = self.dataOut.data_output[:,:,m]
544 544 self.dataOut.heightList = self.dataOut.height[0,:]
545 545
546 546 data_SNR = self.dataOut.data_SNR[:,:,m]
547 547 self.dataOut.data_SNR= transpose(data_SNR)
548 548
549 549 if m==1 and self.dataOut.counter_records%2==0:
550 550 print '*********'
551 551 print 'MODO 2'
552 552 #print 'Zonal', self.dataOut.data_output[0]
553 553 #print 'Meridional', self.dataOut.data_output[1]
554 554 #print 'Vertical', self.dataOut.data_output[2]
555 555
556 556 print '*********'
557 557
558 558 Vx=self.dataOut.data_output[0,:,m]
559 559 Vy=self.dataOut.data_output[1,:,m]
560 560
561 561 Vmag=numpy.sqrt(Vx**2+Vy**2)
562 562 Vang=numpy.arctan2(Vy,Vx)
563 563 #print 'Vmag', Vmag
564 564 #print 'Vang', Vang
565 565
566 566 self.dataOut.data_output[0,:,m]=Vmag
567 567 self.dataOut.data_output[1,:,m]=Vang
568 568
569 569 prin= self.dataOut.data_output[0,:,m][~numpy.isnan(self.dataOut.data_output[0,:,m])]
570 570 print ' '
571 571 print 'VmagAverage',numpy.mean(prin)
572 572 print ' '
573 573 self.dataOut.data_output = self.dataOut.data_output[:,:,m]
574 574
575 575
576 576 No newline at end of file
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
@@ -1,1 +1,1
1 <Project description="Segundo Test" id="191" name="test01"><ReadUnit datatype="VoltageReader" id="1911" inputId="0" name="VoltageReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="VoltageReader" /><Parameter format="str" id="191112" name="path" value="/home/erick/Documents/Data/Claire_Data/raw" /><Parameter format="date" id="191113" name="startDate" value="2017/07/26" /><Parameter format="date" id="191114" name="endDate" value="2017/10/28" /><Parameter format="time" id="191115" name="startTime" value="09:40: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="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="SpectraProc" id="1913" inputId="1912" name="SpectraProc"><Operation id="19131" name="run" priority="1" type="self"><Parameter format="int" id="191311" name="nFFTPoints" value="256" /><Parameter format="pairslist" id="191312" name="pairsList" value="(0,1),(0,2),(1,2)" /></Operation><Operation id="19132" name="removeDC" priority="2" type="self" /><Operation id="19133" name="IncohInt" priority="3" type="external"><Parameter format="float" id="191331" name="n" value="30" /></Operation><Operation id="19134" name="SpectraPlot" priority="4" type="external"><Parameter format="int" id="191341" name="id" value="11" /><Parameter format="str" id="191342" name="wintitle" value="SpectraPlot" /><Parameter format="str" id="191343" name="xaxis" value="velocity" /><Parameter format="int" id="191344" name="zmin" value="0" /><Parameter format="float" id="191345" name="ymin" value="1.5" /><Parameter format="int" id="191346" name="ymax" value="7" /><Parameter format="int" id="191347" name="zmax" value="40" /><Parameter format="int" id="191348" name="save" value="1" /></Operation><Operation id="19135" name="RTIPlot" priority="5" type="other"><Parameter format="int" id="191351" name="id" value="30" /><Parameter format="str" id="191352" name="wintitle" value="RTI" /><Parameter format="int" id="191353" name="zmin" value="0" /><Parameter format="int" id="191354" name="zmax" value="40" /><Parameter format="float" id="191355" name="ymin" value="1.5" /><Parameter format="int" id="191356" name="ymax" value="8" /><Parameter format="int" id="191357" name="showprofile" value="1" /><Parameter format="float" id="191358" name="xmin" value="0" /><Parameter format="float" id="191359" name="xmax" value="23.9" /><Parameter format="int" id="191360" name="save" value="1" /></Operation><Operation id="19136" name="CrossSpectraPlot" priority="6" type="other"><Parameter format="str" id="191361" name="phase_cmap" value="bwr" /><Parameter format="int" id="191362" name="id" value="2005" /><Parameter format="str" id="191363" name="wintitle" value="CrossSpectraPlot_ShortPulse" /><Parameter format="str" id="191364" name="xaxis" value="Velocity" /><Parameter format="float" id="191365" name="ymin" value="1.5" /><Parameter format="int" id="191366" name="ymax" value="7" /></Operation></ProcUnit><ProcUnit datatype="VoltageProc" id="1912" inputId="1911" name="VoltageProc"><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="selectHeights" priority="3" type="self"><Parameter format="float" id="191231" name="minHei" value="0" /><Parameter format="float" id="191232" name="maxHei" value="64" /></Operation></ProcUnit><ProcUnit datatype="Parameters" id="1914" inputId="1913" name="ParametersProc"><Operation id="19141" name="run" priority="1" type="self" /><Operation id="19142" name="SpectralMoments" priority="2" type="other" /><Operation id="19143" name="FullSpectralAnalysis" priority="3" type="other"><Parameter format="float" id="191431" name="E01" value="1.5" /><Parameter format="float" id="191432" name="E02" value="1.5" /><Parameter format="float" id="191433" name="E12" value="0" /><Parameter format="float" id="191434" name="N01" value="0.875" /><Parameter format="float" id="191435" name="N02" value="-0.875" /><Parameter format="float" id="191436" name="N12" value="-1.75" /></Operation><Operation id="19144" name="WindProfilerPlot" priority="4" type="other"><Parameter format="int" id="191441" name="id" value="4" /><Parameter format="str" id="191442" name="wintitle" value="Wind Profiler" /><Parameter format="bool" id="191443" name="save" value="1" /><Parameter format="float" id="191444" name="ymin" value="1.5" /><Parameter format="int" id="191445" name="ymax" value="7" /><Parameter format="float" id="191446" name="zmin" value="-0.00" /><Parameter format="float" id="191447" name="zmax" value="1.1" /></Operation></ProcUnit></Project> No newline at end of file
1 <Project description="read bltr data sswma file" id="191" name="test1"><ReadUnit datatype="testBLTRReader" id="1911" inputId="0" name="testBLTRReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="testBLTRReader" /><Parameter format="str" id="191112" name="path" value="/media/erick/6F60F7113095A154/BLTR" /><Parameter format="date" id="191113" name="startDate" value="2017/01/17" /><Parameter format="date" id="191114" name="endDate" value="2018/01/01" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="str" id="191118" name="ext" value="sswma" /></Operation></ReadUnit><ProcUnit datatype="BLTRProcess" id="1912" inputId="1911" name="BLTRProcess"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="SnrFilter" priority="2" type="self"><Parameter format="float" id="191221" name="snr_val" value="-20" /><Parameter format="int" id="191222" name="modetofilter" value="2" /></Operation><Operation id="19123" name="OutliersFilter" priority="3" type="self"><Parameter format="str" id="191231" name="svalue" value="meridional" /><Parameter format="str" id="191232" name="svalue2" value="inTime" /><Parameter format="float" id="191233" name="method" value="0" /><Parameter format="float" id="191234" name="factor" value="2" /><Parameter format="float" id="191235" name="filter" value="0" /><Parameter format="float" id="191236" name="npoints" value="9" /><Parameter format="int" id="191237" name="modetofilter" value="2" /></Operation><Operation id="19124" name="OutliersFilter" priority="4" type="self"><Parameter format="str" id="191241" name="svalue" value="zonal" /><Parameter format="str" id="191242" name="svalue2" value="inTime" /><Parameter format="float" id="191243" name="method" value="0" /><Parameter format="float" id="191244" name="factor" value="2" /><Parameter format="float" id="191245" name="filter" value="0" /><Parameter format="float" id="191246" name="npoints" value="9" /><Parameter format="int" id="191247" name="modetofilter" value="2" /></Operation><Operation id="19125" name="OutliersFilter" priority="5" type="self"><Parameter format="str" id="191251" name="svalue" value="vertical" /><Parameter format="str" id="191252" name="svalue2" value="inHeight" /><Parameter format="float" id="191253" name="method" value="0" /><Parameter format="float" id="191254" name="factor" value="2" /><Parameter format="float" id="191255" name="filter" value="0" /><Parameter format="float" id="191256" name="npoints" value="9" /><Parameter format="int" id="191257" name="modetofilter" value="2" /></Operation><Operation id="19126" name="prePlot" priority="6" type="self"><Parameter format="int" id="191261" name="modeselect" value="1" /></Operation><Operation id="19127" name="WindProfilerPlot" priority="7" type="other"><Parameter format="int" id="191271" name="id" value="1" /><Parameter format="str" id="191272" name="wintitle" value="" /><Parameter format="intlist" id="191273" name="channelList" value="0" /><Parameter format="int" id="191274" name="SNRmin" value="-10" /><Parameter format="int" id="191275" name="SNRmax" value="50" /><Parameter format="float" id="191276" name="SNRthresh" value="0" /><Parameter format="float" id="191277" name="xmin" value="0" /><Parameter format="float" id="191278" name="xmax" value="24" /><Parameter format="float" id="191279" name="ymax" value="3" /><Parameter format="float" id="191280" name="zmin" value="-20" /><Parameter format="float" id="191281" name="zmax" value="20" /><Parameter format="float" id="191282" name="zmin_ver" value="-200" /><Parameter format="float" id="191283" name="zmax_ver" value="200" /></Operation><Operation id="19128" name="prePlot" priority="8" type="self"><Parameter format="int" id="191281" name="modeselect" value="2" /></Operation><Operation id="19129" name="WindProfilerPlot" priority="9" type="other"><Parameter format="int" id="191291" name="id" value="2" /><Parameter format="str" id="191292" name="wintitle" value="" /><Parameter format="bool" id="191293" name="save" value="1" /><Parameter format="str" id="191294" name="figpath" value="/media/erick/6F60F7113095A154/BLTR/" /><Parameter format="int" id="191295" name="SNRmin" value="-20" /><Parameter format="int" id="191296" name="SNRmax" value="40" /><Parameter format="float" id="191297" name="SNRthresh" value="0" /><Parameter format="float" id="191298" name="xmin" value="0" /><Parameter format="float" id="191299" name="xmax" value="24" /><Parameter format="float" id="191300" name="ymin" value="0" /><Parameter format="float" id="191301" name="ymax" value="10" /><Parameter format="float" id="191302" name="zmin" value="-4" /><Parameter format="float" id="191303" name="zmax" value="4" /><Parameter format="float" id="191304" name="zmin_ver" value="-200" /><Parameter format="float" id="191305" name="zmax_ver" value="200" /></Operation></ProcUnit></Project> No newline at end of file
@@ -1,170 +1,171
1 1 '''
2 2 Created on Nov 09, 2016
3 3
4 4 @author: roj- LouVD
5 5 '''
6 6 import os, sys
7 7
8 8
9 9 path = os.path.split(os.getcwd())[0]
10 10 path = os.path.split(path)[0]
11 11
12 12 sys.path.insert(0, path)
13 13
14 14 from schainpy.controller import Project
15 15
16 16 filename = 'test1.xml'
17 17 # path = '/home/jespinoza/workspace/data/bltr/'
18 path = '/home/erick/Documents/Data/BLTR_Data/sswma/'
18 path = '/media/erick/6F60F7113095A154/BLTR/'
19 19 desc = "read bltr data sswma file"
20 figpath = '/home/erick/workspace'
20 figpath = '/media/erick/6F60F7113095A154/BLTR/'
21 21 pathhdf5 = '/tmp/'
22 22
23 23 controllerObj = Project()
24 24
25 25 controllerObj.setup(id = '191', name='test1', description=desc)
26 26 readUnitConfObj = controllerObj.addReadUnit(datatype='testBLTRReader',
27 27 path=path,
28 startDate='2015/01/17',
29 endDate='2017/01/01',
28 startDate='2017/01/17',
29 endDate='2018/01/01',
30 30 startTime='00:00:00',
31 31 endTime='23:59:59',
32 32 ext='sswma')
33 33
34 34 procUnitConfObj1 = controllerObj.addProcUnit(datatype='BLTRProcess',
35 35 inputId=readUnitConfObj.getId())
36 36
37 37 '''-------------------------------------------Processing--------------------------------------------'''
38 38
39 39 '''MODE 1: LOW ATMOSPHERE: 0- 3 km'''
40 40 # opObj10 = procUnitConfObj1.addOperation(name='SnrFilter')
41 41 # opObj10.addParameter(name='snr_val', value='-10', format='float')
42 42 # opObj10.addParameter(name='modetofilter', value='1', format='int')
43 43 #
44 44 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
45 45 # opObj10.addParameter(name='svalue', value='meridional', format='str')
46 46 # opObj10.addParameter(name='svalue2', value='inTime', format='str')
47 47 # opObj10.addParameter(name='method', value='0', format='float')
48 48 # opObj10.addParameter(name='factor', value='1', format='float')
49 49 # opObj10.addParameter(name='filter', value='0', format='float')
50 50 # opObj10.addParameter(name='npoints', value='5', format='float')
51 51 # opObj10.addParameter(name='modetofilter', value='1', format='int')
52 52 # #
53 53 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
54 54 # opObj10.addParameter(name='svalue', value='zonal', format='str')
55 55 # opObj10.addParameter(name='svalue2', value='inTime', format='str')
56 56 # opObj10.addParameter(name='method', value='0', format='float')
57 57 # opObj10.addParameter(name='factor', value='1', format='float')
58 58 # opObj10.addParameter(name='filter', value='0', format='float')
59 59 # opObj10.addParameter(name='npoints', value='5', format='float')
60 60 # opObj10.addParameter(name='modetofilter', value='1', format='int')
61 61 # #
62 62 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
63 63 # opObj10.addParameter(name='svalue', value='vertical', format='str')
64 64 # opObj10.addParameter(name='svalue2', value='inHeight', format='str')
65 65 # opObj10.addParameter(name='method', value='0', format='float')
66 66 # opObj10.addParameter(name='factor', value='2', format='float')
67 67 # opObj10.addParameter(name='filter', value='0', format='float')
68 68 # opObj10.addParameter(name='npoints', value='9', format='float')
69 69 # opObj10.addParameter(name='modetofilter', value='1', format='int')
70 70 #
71 71
72 72 ''' MODE 2: 0 - 10 km '''
73 73
74 74 opObj10 = procUnitConfObj1.addOperation(name='SnrFilter')
75 75 opObj10.addParameter(name='snr_val', value='-20', format='float')
76 76 opObj10.addParameter(name='modetofilter', value='2', format='int')
77 77
78 78 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
79 79 opObj10.addParameter(name='svalue', value='meridional', format='str')
80 80 opObj10.addParameter(name='svalue2', value='inTime', format='str')
81 81 opObj10.addParameter(name='method', value='0', format='float')
82 82 opObj10.addParameter(name='factor', value='2', format='float')
83 83 opObj10.addParameter(name='filter', value='0', format='float')
84 84 opObj10.addParameter(name='npoints', value='9', format='float')
85 85 opObj10.addParameter(name='modetofilter', value='2', format='int')
86 86 # #
87 87 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
88 88 opObj10.addParameter(name='svalue', value='zonal', format='str')
89 89 opObj10.addParameter(name='svalue2', value='inTime', format='str')
90 90 opObj10.addParameter(name='method', value='0', format='float')
91 91 opObj10.addParameter(name='factor', value='2', format='float')
92 92 opObj10.addParameter(name='filter', value='0', format='float')
93 93 opObj10.addParameter(name='npoints', value='9', format='float')
94 94 opObj10.addParameter(name='modetofilter', value='2', format='int')
95 95 # #
96 96 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
97 97 opObj10.addParameter(name='svalue', value='vertical', format='str')
98 98 opObj10.addParameter(name='svalue2', value='inHeight', format='str')
99 99 opObj10.addParameter(name='method', value='0', format='float')
100 100 opObj10.addParameter(name='factor', value='2', format='float')
101 101 opObj10.addParameter(name='filter', value='0', format='float')
102 102 opObj10.addParameter(name='npoints', value='9', format='float')
103 103 opObj10.addParameter(name='modetofilter', value='2', format='int')
104 104
105 105 # '''-----------------------------------------Writing-------------------------------------------'''
106 106 #
107 107 # # opObj10 = procUnitConfObj1.addOperation(name='testBLTRWriter',optype='other')
108 108 # # opObj10.addParameter(name='path', value = pathhdf5)
109 109 # # opObj10.addParameter(name='modetowrite', value = '2',format='int')
110 110 # #
111 111 # # opObj10 = procUnitConfObj1.addOperation(name='testBLTRWriter',optype='other')
112 112 # # opObj10.addParameter(name='path', value = pathhdf5)
113 113 # # opObj10.addParameter(name='modetowrite', value = '1',format='int')
114 114 #
115 115 # '''----------------------------------------Plotting--------------------------------------------'''
116 116 #
117 117 opObj10 = procUnitConfObj1.addOperation(name='prePlot')
118 118 opObj10.addParameter(name='modeselect',value='1',format='int')
119 119 # #
120 120 opObj10 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other')
121 121 opObj10.addParameter(name='id', value='1', format='int')
122 122 opObj10.addParameter(name='wintitle', value='', format='str')
123 123 opObj10.addParameter(name='channelList', value='0', format='intlist')
124 124 #opObj10.addParameter(name='save', value='1', format='bool')
125 125 #opObj10.addParameter(name='figpath', value=figpath, format='str')
126 126 opObj10.addParameter(name='SNRmin', value='-10', format='int')
127 127 opObj10.addParameter(name='SNRmax', value='50', format='int')
128 128 opObj10.addParameter(name='SNRthresh', value='0', format='float')
129 129 opObj10.addParameter(name='xmin', value='0', format='float')
130 130 opObj10.addParameter(name='xmax', value='24', format='float')
131 131 opObj10.addParameter(name='ymax', value='3', format='float')
132 132 opObj10.addParameter(name='zmin', value='-20', format='float')
133 133 opObj10.addParameter(name='zmax', value='20', format='float')
134 134 opObj10.addParameter(name='zmin_ver', value='-200', format='float')
135 135 opObj10.addParameter(name='zmax_ver', value='200', format='float')
136 136 #opObj10.addParameter(name='showprofile', value='1', format='bool')
137 137 #opObj10.addParameter(name='show', value='1', format='bool')
138 138
139 139 opObj10 = procUnitConfObj1.addOperation(name='prePlot')
140 140 opObj10.addParameter(name='modeselect',value='2',format='int')
141 141 #
142 142 opObj10 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other')
143 143 opObj10.addParameter(name='id', value='2', format='int')
144 144 opObj10.addParameter(name='wintitle', value='', format='str')
145 145 #opObj10.addParameter(name='channelList', value='0', format='intlist')
146 #opObj10.addParameter(name='save', value='1', format='bool')
147 #opObj10.addParameter(name='figpath', value=figpath, format='str')
146 opObj10.addParameter(name='save', value='1', format='bool')
147 opObj10.addParameter(name='figpath', value=figpath, format='str')
148 148 opObj10.addParameter(name='SNRmin', value='-20', format='int')
149 149 opObj10.addParameter(name='SNRmax', value='40', format='int')
150 150 opObj10.addParameter(name='SNRthresh', value='0', format='float')
151 151 opObj10.addParameter(name='xmin', value='0', format='float')
152 152 opObj10.addParameter(name='xmax', value='24', format='float')
153 #opObj10.addParameter(name='ymax', value='8', format='float')
153 opObj10.addParameter(name='ymin', value='0', format='float')
154 opObj10.addParameter(name='ymax', value='10', format='float')
154 155 opObj10.addParameter(name='zmin', value='-4', format='float')
155 156 opObj10.addParameter(name='zmax', value='4', format='float')
156 157 opObj10.addParameter(name='zmin_ver', value='-200', format='float')
157 158 opObj10.addParameter(name='zmax_ver', value='200', format='float')
158 159 #opObj10.addParameter(name='showprofile', value='1', format='bool')
159 160 #opObj10.addParameter(name='show', value='1', format='bool')
160 161
161 162 # # print "Escribiendo el archivo XML"
162 163 # controllerObj.writeXml(filename)
163 164 # # print "Leyendo el archivo XML"
164 165 # controllerObj.readXml(filename)
165 166
166 167 # controllerObj.createObjects()
167 168 # controllerObj.connectObjects()
168 169 # controllerObj.run()
169 170 controllerObj.start()
170 171
@@ -1,146 +1,150
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 desc = "ProcBLTR Test"
14 15 filename = "ProcBLTR.xml"
16 figpath = '/media/erick/6F60F7113095A154/BLTR'
15 17
16 18 controllerObj = Project()
17 19
18 20
19 21 controllerObj.setup(id='191', name='test01', description=desc)
20 22
21 23 readUnitConfObj = controllerObj.addReadUnit(datatype='BLTRReader',
22 path='/home/erick/Documents/Data/BLTR_Data/fdt/',
24 path='/media/erick/6F60F7113095A154/BLTR/',
23 25
24 26 endDate='2017/10/19',
25 27 startTime='13:00:00',
26 28 startDate='2016/11/8',
27 29 endTime='23:59:59',
28 30
29 31
30 32 online=0,
31 33 walk=0,
32 34 ReadMode='1')
33 35 # expLabel='')
34 36
35 37 # opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
36 38
37 39 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
38 40
39 41
40 42
41 43 opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
42 opObj11.addParameter(name='n', value='2', format='float')
44 opObj11.addParameter(name='n', value='3', format='float')
43 45
44 46 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
45 47
46 48 # opObj10 = procUnitConfObj1.addOperation(name='calcMag')
47 49
48 50 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
49 51 # opObj11.addParameter(name='id', value='21', format='int')
50 52 # opObj11.addParameter(name='wintitle', value='SpectraCutPlot', format='str')
51 53 # opObj11.addParameter(name='xaxis', value='frequency', format='str')
52 54 # opObj11.addParameter(name='colormap', value='winter', format='str')
53 55 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
54 56 # opObj11.addParameter(name='xmax', value='0.005', format='float')
55 57 # #opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
56 58 # #opObj10.addParameter(name='channelList', value='0,1', format='intlist')
57 59 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
58 60 # opObj11.addParameter(name='id', value='21', format='int')
59 61 # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
60 62 # #opObj11.addParameter(name='xaxis', value='Velocity', format='str')
61 63
62 64 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
63 65 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
64 66 # opObj11.addParameter(name='xmax', value='0.005', format='float')
65 67
66 68 # opObj11.addParameter(name='ymin', value='225', format='float')
67 69 # opObj11.addParameter(name='ymax', value='3000', format='float')
68 70 # opObj11.addParameter(name='zmin', value='-100', format='int')
69 71 # opObj11.addParameter(name='zmax', value='-65', format='int')
70 72
71 73 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
72 74 # opObj11.addParameter(name='id', value='10', format='int')
73 75 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
74 76 # opObj11.addParameter(name='ymin', value='0', format='float')
75 77 # opObj11.addParameter(name='ymax', value='4000', format='float')
76 78 # #opObj11.addParameter(name='zmin', value='-100', format='int')
77 79 # #opObj11.addParameter(name='zmax', value='-70', format='int')
78 80 # opObj11.addParameter(name='zmin', value='-90', format='int')
79 81 # opObj11.addParameter(name='zmax', value='-40', format='int')
80 82 # opObj11.addParameter(name='showprofile', value='1', format='int')
81 83 # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int')
82 84
83 85 opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
84 86 procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
85 87 opObj11.addParameter(name='id', value='2005', format='int')
86 88 opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
87 89 # opObj11.addParameter(name='exp_code', value='13', format='int')
88 90 opObj11.addParameter(name='xaxis', value='Velocity', format='str')
89 91 #opObj11.addParameter(name='xmin', value='-10', format='float')
90 92 #opObj11.addParameter(name='xmax', value='10', format='float')
91 93 #opObj11.addParameter(name='ymin', value='225', format='float')
92 94 #opObj11.addParameter(name='ymax', value='3000', format='float')
93 95 #opObj11.addParameter(name='phase_min', value='-4', format='int')
94 96 #opObj11.addParameter(name='phase_max', value='4', format='int')
95 97
96 98 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj1.getId())
97 99 # procUnitConfObj2.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
98 100
99 101 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
100 102 opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
101 103 opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
102 104 #
103 105 opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
104 106 opObj22.addParameter(name='id', value='4', format='int')
105 107 opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
106 108 opObj22.addParameter(name='save', value='1', format='bool')
107 109 # opObj22.addParameter(name='figpath', value = '/home/erick/Pictures', format='str')
108
110
109 111 opObj22.addParameter(name='zmin', value='-20', format='int')
110 112 opObj22.addParameter(name='zmax', value='20', format='int')
111 113 opObj22.addParameter(name='zmin_ver', value='-250', format='float')
112 114 opObj22.addParameter(name='zmax_ver', value='250', format='float')
113 115 opObj22.addParameter(name='SNRmin', value='-5', format='int')
114 116 opObj22.addParameter(name='SNRmax', value='30', format='int')
115 117 # opObj22.addParameter(name='SNRthresh', value='-3.5', format='float')
116 118 opObj22.addParameter(name='xmin', value=0, format='float')
117 119 opObj22.addParameter(name='xmax', value=24, format='float')
118 120 opObj22.addParameter(name='ymin', value='225', format='float')
119 121 #opObj22.addParameter(name='ymax', value='2000', format='float')
120
121
122 opObj22.addParameter(name='save', value='1', format='int')
123 opObj22.addParameter(name='figpath', value=figpath, format='str')
124
125
122 126 # opObj11.addParameter(name='pairlist', value='(1,0),(0,2),(1,2)', format='pairsList')
123 127 #opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
124 128 #opObj10.addParameter(name='minHei', value='225', format='float')
125 129 #opObj10.addParameter(name='maxHei', value='1000', format='float')
126
130
127 131 # opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other')
128 132 # opObj11.addParameter(name='id', value='102', format='int')
129 133 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
130 134 # opObj11.addParameter(name='ymin', value='225', format='float')
131 135 # opObj11.addParameter(name='ymax', value='4000', format='float')
132
136
133 137 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
134 138 # opObj11.addParameter(name='xmin', value='8.5', format='float')
135 139 # opObj11.addParameter(name='xmax', value='9.5', format='float')
136 140 # opObj11.addParameter(name='figpath', value=figpath, format='str')
137 141 # opObj11.addParameter(name='save', value=1, format='bool')
138 142 # opObj11.addParameter(name='pairsList', value='(1,0),(3,2)', format='pairsList')
139 143
140 144 # opObj12 = procUnitConfObj1.addOperation(name='PublishData', optype='other')
141 145 # opObj12.addParameter(name='zeromq', value=1, format='int')
142 146 # opObj12.addParameter(name='verbose', value=0, format='bool')
143 147 # opObj12.addParameter(name='server', value='erick2', format='str')
144 148 controllerObj.start()
145 149
146 150
1 NO CONTENT: modified file, binary diff hidden
General Comments 0
You need to be logged in to leave comments. Login now