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