##// END OF EJS Templates
casi merge con online_data_hour
José Chávez -
r1036:754fcef10e66 merge
parent child
Show More
@@ -542,7 +542,7 class JRODataIO:
542 542
543 543 class JRODataReader(JRODataIO):
544 544
545
545 firstTime = True
546 546 online = 0
547 547
548 548 realtime = 0
@@ -579,7 +579,7 class JRODataReader(JRODataIO):
579 579
580 580 selBlocktime = None
581 581
582
582 onlineWithDate = False
583 583 def __init__(self):
584 584
585 585 """
@@ -616,7 +616,6 class JRODataReader(JRODataIO):
616 616 cursor=None,
617 617 skip=None,
618 618 walk=True):
619
620 619 self.filenameList = []
621 620 self.datetimeList = []
622 621
@@ -683,10 +682,9 class JRODataReader(JRODataIO):
683 682
684 683 self.filenameList = filenameList
685 684 self.datetimeList = datetimeList
686
687 685 return pathList, filenameList
688 686
689 def __searchFilesOnLine(self, path, expLabel = "", ext = None, walk=True, set=None):
687 def __searchFilesOnLine(self, path, expLabel="", ext=None, walk=True, set=None, startDate=None, startTime=None):
690 688
691 689 """
692 690 Busca el ultimo archivo de la ultima carpeta (determinada o no por startDateTime) y
@@ -699,7 +697,7 class JRODataReader(JRODataIO):
699 697
700 698 ext : extension de los files
701 699
702 walk : Si es habilitado no realiza busquedas dentro de los ubdirectorios (doypath)
700 walk : Si es habilitado no realiza busquedas dentro de los subdirectorios (doypath)
703 701
704 702 Return:
705 703 directory : eL directorio donde esta el file encontrado
@@ -710,6 +708,8 class JRODataReader(JRODataIO):
710 708
711 709
712 710 """
711 pathList = None
712 filenameList = None
713 713 if not os.path.isdir(path):
714 714 return None, None, None, None, None, None
715 715
@@ -810,6 +810,7 class JRODataReader(JRODataIO):
810 810 Excepciones:
811 811 Si un determinado file no puede ser abierto
812 812 """
813
813 814 nFiles = 0
814 815 fileOk_flag = False
815 816 firstTime_flag = True
@@ -882,13 +883,34 class JRODataReader(JRODataIO):
882 883 def setNextFile(self):
883 884 if self.fp != None:
884 885 self.fp.close()
885
886 886 if self.online:
887 887 newFile = self.__setNextFileOnline()
888 888 else:
889 889 newFile = self.__setNextFileOffline()
890
891 890 if not(newFile):
891 if self.onlineWithDate is True:
892 self.onlineWithDate=False
893 self.online = True
894 self.firstTime = False
895 self.setup(
896 path=self.path,
897 startDate=self.startDate,
898 endDate=self.endDate,
899 startTime=self.startTime ,
900 endTime=self.endTime,
901 set=self.set,
902 expLabel=self.expLabel,
903 ext=self.ext,
904 online=self.online,
905 delay=self.delay,
906 walk=self.walk,
907 getblock=self.getblock,
908 nTxs=self.nTxs,
909 realtime=self.realtime,
910 blocksize=self.blocksize,
911 blocktime=self.blocktime
912 )
913 return 1
892 914 print '[Reading] No more files to read'
893 915 return 0
894 916
@@ -1046,12 +1068,9 class JRODataReader(JRODataIO):
1046 1068 if not(self.__setNewBlock()):
1047 1069 print 'returning'
1048 1070 return 0
1049
1050 1071 if not(self.readBlock()):
1051 1072 return 0
1052
1053 1073 self.getBasicHeader()
1054
1055 1074 if not isTimeInRange(self.dataOut.datatime.time(), self.startTime, self.endTime):
1056 1075
1057 1076 print "[Reading] Block No. %d/%d -> %s [Skipping]" %(self.nReadBlocks,
@@ -1328,6 +1347,7 class JRODataReader(JRODataIO):
1328 1347 walk=walk, cursor=cursor,
1329 1348 skip=skip, queue=queue)
1330 1349
1350 <<<<<<< HEAD
1331 1351 if not(pathList):
1332 1352 # print "[Reading] No *%s files in %s (%s - %s)"%(ext, path,
1333 1353 # datetime.datetime.combine(startDate,startTime).ctime(),
@@ -1340,6 +1360,129 class JRODataReader(JRODataIO):
1340 1360 self.filenameList = []
1341 1361 return
1342 1362
1363 =======
1364 if path == None:
1365 raise ValueError, "[Reading] The path is not valid"
1366
1367
1368 if ext == None:
1369 ext = self.ext
1370
1371 self.path = path
1372 self.startDate = startDate
1373 self.endDate = endDate
1374 self.startTime = startTime
1375 self.endTime = endTime
1376 self.set = set
1377 self.expLabel = expLabel
1378 self.ext = ext
1379 self.online = online
1380 self.delay = delay
1381 self.walk = walk
1382 self.getblock = getblock
1383 self.nTxs = nTxs
1384 self.realtime = realtime
1385 self.blocksize = blocksize
1386 self.blocktime = blocktime
1387
1388
1389 if self.firstTime is True:
1390 pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate,
1391 startTime=startTime, endTime=endTime,
1392 set=set, expLabel=expLabel, ext=ext,
1393 walk=walk)
1394 filenameList = filenameList[:-1]
1395
1396 if pathList is not None and filenameList is not None and online:
1397 self.onlineWithDate = True
1398 online = False
1399 self.fileIndex = -1
1400 self.pathList = pathList
1401 self.filenameList = filenameList
1402 file_name = os.path.basename(filenameList[-1])
1403 basename, ext = os.path.splitext(file_name)
1404 last_set = int(basename[-3:])
1405
1406 if online:
1407 print "[Reading] Searching files in online mode..."
1408
1409 for nTries in range(self.nTries):
1410 fullpath, foldercounter, file, year, doy, set = self.__searchFilesOnLine(path=path,
1411 expLabel=expLabel,
1412 ext=ext,
1413 walk=walk,
1414 startDate=startDate,
1415 startTime=startTime,
1416 set=set)
1417
1418 if fullpath:
1419 break
1420 print '[Reading] Waiting %0.2f sec for an valid file in %s: try %02d ...' % (self.delay, path, nTries+1)
1421 sleep( self.delay )
1422
1423 if not(fullpath):
1424 print "[Reading] There 'isn't any valid file in %s" % path
1425 return
1426
1427 self.year = year
1428 self.doy = doy
1429 self.set = set - 1
1430 self.path = path
1431 self.foldercounter = foldercounter
1432 last_set = None
1433
1434 else:
1435 print "[Reading] Searching files in offline mode ..."
1436 pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate,
1437 startTime=startTime, endTime=endTime,
1438 set=set, expLabel=expLabel, ext=ext,
1439 walk=walk)
1440
1441 if not(pathList):
1442 # print "[Reading] No *%s files in %s (%s - %s)"%(ext, path,
1443 # datetime.datetime.combine(startDate,startTime).ctime(),
1444 # datetime.datetime.combine(endDate,endTime).ctime())
1445
1446 # sys.exit(-1)
1447
1448 self.fileIndex = -1
1449 self.pathList = []
1450 self.filenameList = []
1451 return
1452
1453 self.fileIndex = -1
1454 self.pathList = pathList
1455 self.filenameList = filenameList
1456 file_name = os.path.basename(filenameList[-1])
1457 basename, ext = os.path.splitext(file_name)
1458 last_set = int(basename[-3:])
1459
1460
1461 self.online = online
1462 self.realtime = realtime
1463 self.delay = delay
1464 ext = ext.lower()
1465 self.ext = ext
1466 self.getByBlock = getblock
1467 self.nTxs = nTxs
1468 self.startTime = startTime
1469 self.endTime = endTime
1470
1471
1472 #Added-----------------
1473 self.selBlocksize = blocksize
1474 self.selBlocktime = blocktime
1475
1476
1477 if not(self.setNextFile()):
1478 if (startDate!=None) and (endDate!=None):
1479 print "[Reading] No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
1480 elif startDate != None:
1481 print "[Reading] No files in range: %s" %(datetime.datetime.combine(startDate,startTime).ctime())
1482 else:
1483 print "[Reading] No files"
1484
1485 >>>>>>> online_data_hour
1343 1486 self.fileIndex = -1
1344 1487 self.pathList = pathList
1345 1488 self.filenameList = filenameList
@@ -1365,6 +1508,7 class JRODataReader(JRODataIO):
1365 1508 self.verbose = verbose
1366 1509 self.warnings = warnings
1367 1510
1511 <<<<<<< HEAD
1368 1512 if not(self.setNextFile()):
1369 1513 if (startDate!=None) and (endDate!=None):
1370 1514 print "[Reading] No files in range: %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
@@ -1383,6 +1527,13 class JRODataReader(JRODataIO):
1383 1527 if last_set != None:
1384 1528 self.dataOut.last_block = last_set * self.processingHeaderObj.dataBlocksPerFile + self.basicHeaderObj.dataBlock
1385 1529 return
1530 =======
1531 # self.getBasicHeader()
1532
1533 if last_set != None:
1534 self.dataOut.last_block = last_set * self.processingHeaderObj.dataBlocksPerFile + self.basicHeaderObj.dataBlock
1535 return
1536 >>>>>>> online_data_hour
1386 1537
1387 1538 def getBasicHeader(self):
1388 1539
@@ -1476,6 +1627,7 class JRODataReader(JRODataIO):
1476 1627 verbose=True, **kwargs):
1477 1628
1478 1629 if not(self.isConfig):
1630 <<<<<<< HEAD
1479 1631 # self.dataOut = dataOut
1480 1632 self.setup( path=path,
1481 1633 startDate=startDate,
@@ -1499,6 +1651,11 class JRODataReader(JRODataIO):
1499 1651 warnings=warnings,
1500 1652 server=server,
1501 1653 verbose=verbose)
1654 =======
1655
1656 # self.dataOut = dataOut
1657 self.setup(**kwargs)
1658 >>>>>>> online_data_hour
1502 1659 self.isConfig = True
1503 1660 if server is None:
1504 1661 self.getData()
@@ -1621,9 +1778,15 class JRODataWriter(JRODataIO):
1621 1778 Return:
1622 1779 None
1623 1780 """
1781 <<<<<<< HEAD
1782
1783 # CALCULAR PARAMETROS
1784
1785 =======
1624 1786
1625 1787 # CALCULAR PARAMETROS
1626 1788
1789 >>>>>>> online_data_hour
1627 1790 sizeLongHeader = self.systemHeaderObj.size + self.radarControllerHeaderObj.size + self.processingHeaderObj.size
1628 1791 self.basicHeaderObj.size = self.basicHeaderSize + sizeLongHeader
1629 1792
@@ -180,10 +180,17 class VoltageReader(JRODataReader, ProcessingUnit):
180 180
181 181 def getBlockDimension(self):
182 182 """
183 <<<<<<< HEAD
183 184 Obtiene la cantidad de puntos a leer por cada bloque de datos
184 185
185 186 Affected:
186 187 self.blocksize
188 =======
189 Obtiene la cantidad de puntos a leer por cada bloque de datos
190
191 Affected:
192 self.blocksize
193 >>>>>>> online_data_hour
187 194
188 195 Return:
189 196 None
@@ -195,6 +202,28 class VoltageReader(JRODataReader, ProcessingUnit):
195 202
196 203 def readBlock(self):
197 204 """
205 <<<<<<< HEAD
206 readBlock lee el bloque de datos desde la posicion actual del puntero del archivo
207 (self.fp) y actualiza todos los parametros relacionados al bloque de datos
208 (metadata + data). La data leida es almacenada en el buffer y el contador del buffer
209 es seteado a 0
210
211 Inputs:
212 None
213
214 Return:
215 None
216
217 Affected:
218 self.profileIndex
219 self.datablock
220 self.flagIsNewFile
221 self.flagIsNewBlock
222 self.nTotalBlocks
223
224 Exceptions:
225 Si un bloque leido no es un bloque valido
226 =======
198 227 readBlock lee el bloque de datos desde la posicion actual del puntero del archivo
199 228 (self.fp) y actualiza todos los parametros relacionados al bloque de datos
200 229 (metadata + data). La data leida es almacenada en el buffer y el contador del buffer
@@ -215,6 +244,7 class VoltageReader(JRODataReader, ProcessingUnit):
215 244
216 245 Exceptions:
217 246 Si un bloque leido no es un bloque valido
247 >>>>>>> online_data_hour
218 248 """
219 249
220 250 # if self.server is not None:
@@ -408,6 +438,41 class VoltageReader(JRODataReader, ProcessingUnit):
408 438
409 439 def getData(self):
410 440 """
441 <<<<<<< HEAD
442 getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut
443 del tipo "Voltage" con todos los parametros asociados a este (metadata). cuando no hay datos
444 en el buffer de lectura es necesario hacer una nueva lectura de los bloques de datos usando
445 "readNextBlock"
446
447 Ademas incrementa el contador del buffer "self.profileIndex" en 1.
448
449 Return:
450
451 Si el flag self.getByBlock ha sido seteado el bloque completo es copiado a self.dataOut y el self.profileIndex
452 es igual al total de perfiles leidos desde el archivo.
453
454 Si self.getByBlock == False:
455
456 self.dataOut.data = buffer[:, thisProfile, :]
457
458 shape = [nChannels, nHeis]
459
460 Si self.getByBlock == True:
461
462 self.dataOut.data = buffer[:, :, :]
463
464 shape = [nChannels, nProfiles, nHeis]
465
466 Variables afectadas:
467 self.dataOut
468 self.profileIndex
469
470 Affected:
471 self.dataOut
472 self.profileIndex
473 self.flagDiscontinuousBlock
474 self.flagIsNewBlock
475 =======
411 476 getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut
412 477 del tipo "Voltage" con todos los parametros asociados a este (metadata). cuando no hay datos
413 478 en el buffer de lectura es necesario hacer una nueva lectura de los bloques de datos usando
@@ -441,6 +506,7 class VoltageReader(JRODataReader, ProcessingUnit):
441 506 self.profileIndex
442 507 self.flagDiscontinuousBlock
443 508 self.flagIsNewBlock
509 >>>>>>> online_data_hour
444 510 """
445 511 if self.flagNoMoreFiles:
446 512 self.dataOut.flagNoData = True
@@ -462,16 +528,36 class VoltageReader(JRODataReader, ProcessingUnit):
462 528 if not self.getByBlock:
463 529
464 530 """
531 <<<<<<< HEAD
465 532 Return profile by profile
466 533
467 534 If nTxs > 1 then one profile is divided by nTxs and number of total
468 535 blocks is increased by nTxs (nProfiles *= nTxs)
536 =======
537 Return profile by profile
538
539 If nTxs > 1 then one profile is divided by nTxs and number of total
540 blocks is increased by nTxs (nProfiles *= nTxs)
541 >>>>>>> online_data_hour
469 542 """
470 543 self.dataOut.flagDataAsBlock = False
471 544 self.dataOut.data = self.datablock[:,self.profileIndex,:]
472 545 self.dataOut.profileIndex = self.profileIndex
473 546
474 547 self.profileIndex += 1
548 <<<<<<< HEAD
549
550 # elif self.selBlocksize==None or self.selBlocksize==self.dataOut.nProfiles:
551 # """
552 # Return all block
553 # """
554 # self.dataOut.flagDataAsBlock = True
555 # self.dataOut.data = self.datablock
556 # self.dataOut.profileIndex = self.dataOut.nProfiles - 1
557 #
558 # self.profileIndex = self.dataOut.nProfiles
559
560 =======
475 561
476 562 # elif self.selBlocksize==None or self.selBlocksize==self.dataOut.nProfiles:
477 563 # """
@@ -483,6 +569,7 class VoltageReader(JRODataReader, ProcessingUnit):
483 569 #
484 570 # self.profileIndex = self.dataOut.nProfiles
485 571
572 >>>>>>> online_data_hour
486 573 else:
487 574 """
488 575 Return a block
@@ -166,12 +166,21 class Remote(Thread):
166 166 return 0
167 167
168 168 self.mutex.acquire()
169 <<<<<<< HEAD
169 170 # init = time.time()
170 171 #
171 172 # while(self.bussy):
172 173 # sleep(0.1)
173 174 # if time.time() - init > 2*self.period:
174 175 # return 0
176 =======
177 # init = time.time()
178 #
179 # while(self.bussy):
180 # sleep(0.1)
181 # if time.time() - init > 2*self.period:
182 # return 0
183 >>>>>>> online_data_hour
175 184
176 185 self.fileList = fileList
177 186 self.mutex.release()
@@ -196,7 +205,11 class Remote(Thread):
196 205 if self.stopFlag:
197 206 break
198 207
208 <<<<<<< HEAD
199 209 # self.bussy = True
210 =======
211 # self.bussy = True
212 >>>>>>> online_data_hour
200 213 self.mutex.acquire()
201 214
202 215 print "[Remote Server] Opening %s" %self.__server
@@ -619,6 +632,7 class SendToServer(ProcessingUnit):
619 632 filenameList = glob.glob1(thisFolder, '*%s' %self.ext)
620 633
621 634 if len(filenameList) < 1:
635
622 636 continue
623 637
624 638 for thisFile in filenameList:
@@ -55,17 +55,26 opObj00.addParameter(name='channelList', value='0,1,2,3,4', format='intlist')
55 55 opObj01 = procUnitConfObj0.addOperation(name='setRadarFrequency')
56 56 opObj01.addParameter(name='frequency', value='30.e6', format='float')
57 57
58 opObj01 = procUnitConfObj0.addOperation(name='interpolateHeights')
59 opObj01.addParameter(name='topLim', value='73', format='int')
60 opObj01.addParameter(name='botLim', value='71', format='int')
58 # opObj01 = procUnitConfObj0.addOperation(name='interpolateHeights')
59 # opObj01.addParameter(name='topLim', value='73', format='int')
60 # opObj01.addParameter(name='botLim', value='71', format='int')
61 61
62 62 opObj02 = procUnitConfObj0.addOperation(name='Decoder', optype='other')
63 63
64 64 opObj03 = procUnitConfObj0.addOperation(name='CohInt', optype='other')
65 65 opObj03.addParameter(name='n', value='2', format='int')
66 66
67 procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId())
68 opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
69 opObj11.addParameter(name='id', value='237', format='int')
70 opObj11.addParameter(name='xmin', value='9.0', format='float')
71 opObj11.addParameter(name='xmax', value='16.0', format='float')
72 opObj11.addParameter(name='zmin', value='15.0', format='float')
73 opObj11.addParameter(name='zmax', value='50.0', format='float')
74
67 75 #--------------------------- Parameters Processing Unit ------------------------------------
68 76
77 <<<<<<< HEAD
69 78 procUnitConfObj1 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj0.getId())
70 79 #
71 80 opObj10 = procUnitConfObj1.addOperation(name='SMDetection', optype='other')
@@ -83,3 +92,23 opObj12.addParameter(name='mode',value='2',format='int')
83 92 #--------------------------------------------------------------------------------------------------
84 93
85 94 controllerObj.start()
95 =======
96 # procUnitConfObj1 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj0.getId())
97 # #
98 # opObj10 = procUnitConfObj1.addOperation(name='SMDetection', optype='other')
99 # opObj10.addParameter(name='azimuth', value='45', format='float')
100 # opObj10.addParameter(name='hmin', value='60', format='float')
101 # opObj10.addParameter(name='hmax', value='120', format='float')
102
103 # opObj12 = procUnitConfObj1.addOperation(name='ParamWriter', optype='other')
104 # opObj12.addParameter(name='path', value=pathfile)
105 # opObj12.addParameter(name='blocksPerFile', value='1000', format='int')
106 # opObj12.addParameter(name='metadataList',value='type,heightList,paramInterval,timeZone',format='list')
107 # opObj12.addParameter(name='dataList',value='data_param,utctime',format='list')
108 # opObj12.addParameter(name='mode',value='2',format='int')
109
110 #--------------------------------------------------------------------------------------------------
111 controllerObj.createObjects()
112 controllerObj.connectObjects()
113 controllerObj.run()
114 >>>>>>> online_data_hour
General Comments 0
You need to be logged in to leave comments. Login now