##// END OF EJS Templates
update jroIO_digitalRF.py
avaldez -
r1263:6b55a7081d5a
parent child
Show More
@@ -17,6 +17,7 import datetime
17 17 import numpy
18 18 import timeit
19 19 from fractions import Fraction
20 from time import time
20 21
21 22 import schainpy.admin
22 23 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader
@@ -46,13 +47,14 class DigitalRFReader(ProcessingUnit):
46 47 self.__printInfo = True
47 48 self.__flagDiscontinuousBlock = False
48 49 self.__bufferIndex = 9999999
49 self.__ippKm = None
50 50 self.__codeType = 0
51 self.__ippKm = None
51 52 self.__nCode = None
52 53 self.__nBaud = None
53 54 self.__code = None
54 55 self.dtype = None
55 56 self.oldAverage = None
57 self.path = None
56 58
57 59 def close(self):
58 60 print('Average of writing to digital rf format is ', self.oldAverage * 1000)
@@ -248,6 +250,7 class DigitalRFReader(ProcessingUnit):
248 250 online
249 251 delay
250 252 '''
253 self.path = path
251 254 self.nCohInt = nCohInt
252 255 self.flagDecodeData = flagDecodeData
253 256 self.i = 0
@@ -298,7 +301,7 class DigitalRFReader(ProcessingUnit):
298 301
299 302 self.__frequency = self.fixed_metadata_dict.get('frequency', 1)
300 303
301 self.__timezone = self.fixed_metadata_dict.get('timezone', 300)
304 self.__timezone = self.fixed_metadata_dict.get('timezone', 18000)
302 305
303 306 try:
304 307 nSamples = self.fixed_metadata_dict['nSamples']
@@ -398,8 +401,7 class DigitalRFReader(ProcessingUnit):
398 401 startUTCSecond = numpy.floor(endUTCSecond)
399 402
400 403 # por que en el otro metodo lo primero q se hace es sumar samplestoread
401 self.__thisUnixSample = int(
402 startUTCSecond * self.__sample_rate) - self.__samples_to_read
404 self.__thisUnixSample = int(startUTCSecond * self.__sample_rate) - self.__samples_to_read
403 405
404 406 self.__data_buffer = numpy.zeros(
405 407 (self.__num_subchannels, self.__samples_to_read), dtype=numpy.complex)
@@ -434,7 +436,7 class DigitalRFReader(ProcessingUnit):
434 436 try:
435 437 self.digitalReadObj.reload(complete_update=True)
436 438 except:
437 self.digitalReadObj.reload()
439 self.digitalReadObj = digital_rf.DigitalRFReader(self.path)
438 440
439 441 start_index, end_index = self.digitalReadObj.get_bounds(
440 442 self.__channelNameList[self.__channelList[0]])
@@ -489,6 +491,7 class DigitalRFReader(ProcessingUnit):
489 491 indexChannel = 0
490 492
491 493 dataOk = False
494
492 495 for thisChannelName in self.__channelNameList: # TODO VARIOS CHANNELS?
493 496 for indexSubchannel in range(self.__num_subchannels):
494 497 try:
@@ -517,7 +520,6 class DigitalRFReader(ProcessingUnit):
517 520 break
518 521
519 522 self.__data_buffer[indexSubchannel, :] = result * volt_scale
520
521 523 indexChannel += 1
522 524
523 525 dataOk = True
@@ -554,14 +556,16 class DigitalRFReader(ProcessingUnit):
554 556 self.flagDiscontinuousBlock
555 557 self.flagIsNewBlock
556 558 '''
557
559 #print("getdata")
558 560 err_counter = 0
559 561 self.dataOut.flagNoData = True
560 562
561 563 if self.__isBufferEmpty():
564 #print("hi")
562 565 self.__flagDiscontinuousBlock = False
563 566
564 567 while True:
568 #print ("q ha pasado")
565 569 if self.__readNextBlock():
566 570 break
567 571 if self.__thisUnixSample > self.__endUTCSecond * self.__sample_rate:
@@ -584,10 +588,8 class DigitalRFReader(ProcessingUnit):
584 588 print('[Reading] waiting %d seconds to read a new block' % seconds)
585 589 time.sleep(seconds)
586 590
587 self.dataOut.data = self.__data_buffer[:,
588 self.__bufferIndex:self.__bufferIndex + self.__nSamples]
589 self.dataOut.utctime = (
590 self.__thisUnixSample + self.__bufferIndex) / self.__sample_rate
591 self.dataOut.data = self.__data_buffer[:, self.__bufferIndex:self.__bufferIndex + self.__nSamples]
592 self.dataOut.utctime = ( self.__thisUnixSample + self.__bufferIndex) / self.__sample_rate
591 593 self.dataOut.flagNoData = False
592 594 self.dataOut.flagDiscontinuousBlock = self.__flagDiscontinuousBlock
593 595 self.dataOut.profileIndex = self.profileIndex
@@ -598,7 +600,7 class DigitalRFReader(ProcessingUnit):
598 600 if self.profileIndex == self.dataOut.nProfiles:
599 601 self.profileIndex = 0
600 602
601 return
603 return True
602 604
603 605 def printInfo(self):
604 606 '''
@@ -779,7 +781,7 class DigitalRFWriter(Operation):
779 781 # self.writeMetadata()
780 782 ## if self.currentSample == self.__nProfiles: self.currentSample = 0
781 783
782 return dataOut
784 return dataOut# en la version 2.7 no aparece este return
783 785
784 786 def close(self):
785 787 print('[Writing] - Closing files ')
@@ -788,5 +790,3 class DigitalRFWriter(Operation):
788 790 self.digitalWriteObj.close()
789 791 except:
790 792 pass
791
792
General Comments 0
You need to be logged in to leave comments. Login now