@@ -85,8 +85,23 class Header(object): | |||
|
85 | 85 | raise NotImplementedError |
|
86 | 86 | |
|
87 | 87 | def getAllowedArgs(self): |
|
88 |
|
|
|
88 | args = inspect.getargspec(self.__init__).args | |
|
89 | try: | |
|
90 | args.remove('self') | |
|
91 | except: | |
|
92 | pass | |
|
93 | return args | |
|
94 | ||
|
95 | def getAsDict(self): | |
|
96 | args = self.getAllowedArgs() | |
|
97 | asDict = {} | |
|
98 | for x in args: | |
|
99 | asDict[x] = self[x] | |
|
100 | return asDict | |
|
89 | 101 | |
|
102 | def __getitem__(self, name): | |
|
103 | return getattr(self, name) | |
|
104 | ||
|
90 | 105 | def printInfo(self): |
|
91 | 106 | |
|
92 | 107 | message = "#"*50 + "\n" |
@@ -196,14 +211,14 class SystemHeader(Header): | |||
|
196 | 211 | pciDioBusWidth = None |
|
197 | 212 | structure = SYSTEM_STRUCTURE |
|
198 | 213 | |
|
199 | def __init__(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWith=0): | |
|
214 | def __init__(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWidth=0): | |
|
200 | 215 | |
|
201 | 216 | self.size = 24 |
|
202 | 217 | self.nSamples = nSamples |
|
203 | 218 | self.nProfiles = nProfiles |
|
204 | 219 | self.nChannels = nChannels |
|
205 | 220 | self.adcResolution = adcResolution |
|
206 | self.pciDioBusWidth = pciDioBusWith | |
|
221 | self.pciDioBusWidth = pciDioBusWidth | |
|
207 | 222 | |
|
208 | 223 | def read(self, fp): |
|
209 | 224 | self.length = 0 |
@@ -266,7 +281,7 class RadarControllerHeader(Header): | |||
|
266 | 281 | line5Function = None |
|
267 | 282 | fClock = None |
|
268 | 283 | prePulseBefore = None |
|
269 |
prePulse |
|
|
284 | prePulseAfter = None | |
|
270 | 285 | rangeIpp = None |
|
271 | 286 | rangeTxA = None |
|
272 | 287 | rangeTxB = None |
@@ -274,7 +289,7 class RadarControllerHeader(Header): | |||
|
274 | 289 | __size = None |
|
275 | 290 | |
|
276 | 291 | def __init__(self, expType=2, nTx=1, |
|
277 |
ipp |
|
|
292 | ipp=None, txA=0, txB=0, | |
|
278 | 293 | nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None, |
|
279 | 294 | numTaus=0, line6Function=0, line5Function=0, fClock=None, |
|
280 | 295 | prePulseBefore=0, prePulseAfter=0, |
@@ -284,10 +299,10 class RadarControllerHeader(Header): | |||
|
284 | 299 | # self.size = 116 |
|
285 | 300 | self.expType = expType |
|
286 | 301 | self.nTx = nTx |
|
287 |
self.ipp = ipp |
|
|
302 | self.ipp = ipp | |
|
288 | 303 | self.txA = txA |
|
289 | 304 | self.txB = txB |
|
290 |
self.rangeIpp = ipp |
|
|
305 | self.rangeIpp = ipp | |
|
291 | 306 | self.rangeTxA = txA |
|
292 | 307 | self.rangeTxB = txB |
|
293 | 308 | |
@@ -298,7 +313,7 class RadarControllerHeader(Header): | |||
|
298 | 313 | self.line5Function = line5Function |
|
299 | 314 | self.fClock = fClock |
|
300 | 315 | self.prePulseBefore = prePulseBefore |
|
301 |
self.prePulse |
|
|
316 | self.prePulseAfter = prePulseAfter | |
|
302 | 317 | |
|
303 | 318 | self.nHeights = nHeights |
|
304 | 319 | self.firstHeight = firstHeight |
@@ -348,7 +363,7 class RadarControllerHeader(Header): | |||
|
348 | 363 | self.line5Function = int(header['nLine5Function'][0]) |
|
349 | 364 | self.fClock = float(header['fClock'][0]) |
|
350 | 365 | self.prePulseBefore = int(header['nPrePulseBefore'][0]) |
|
351 |
self.prePulse |
|
|
366 | self.prePulseAfter = int(header['nPrePulseAfter'][0]) | |
|
352 | 367 | self.rangeIpp = header['sRangeIPP'][0] |
|
353 | 368 | self.rangeTxA = header['sRangeTxA'][0] |
|
354 | 369 | self.rangeTxB = header['sRangeTxB'][0] |
@@ -456,7 +471,7 class RadarControllerHeader(Header): | |||
|
456 | 471 | self.line5Function, |
|
457 | 472 | self.fClock, |
|
458 | 473 | self.prePulseBefore, |
|
459 |
self.prePulse |
|
|
474 | self.prePulseAfter, | |
|
460 | 475 | self.rangeIpp, |
|
461 | 476 | self.rangeTxA, |
|
462 | 477 | self.rangeTxB) |
@@ -7,7 +7,7 Created on Jul 3, 2014 | |||
|
7 | 7 | import os |
|
8 | 8 | import datetime |
|
9 | 9 | import numpy |
|
10 | from profilehooks import coverage | |
|
10 | from profilehooks import coverage, profile | |
|
11 | 11 | from fractions import Fraction |
|
12 | 12 | |
|
13 | 13 | try: |
@@ -18,7 +18,8 except: | |||
|
18 | 18 | from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader |
|
19 | 19 | from schainpy.model.data.jrodata import Voltage |
|
20 | 20 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
21 | ||
|
21 | from time import time | |
|
22 | import cPickle | |
|
22 | 23 | try: |
|
23 | 24 | import digital_rf |
|
24 | 25 | except: |
@@ -40,7 +41,6 class DigitalRFReader(ProcessingUnit): | |||
|
40 | 41 | self.__printInfo = True |
|
41 | 42 | self.__flagDiscontinuousBlock = False |
|
42 | 43 | self.__bufferIndex = 9999999 |
|
43 | ||
|
44 | 44 | self.__ippKm = None |
|
45 | 45 | self.__codeType = 0 |
|
46 | 46 | self.__nCode = None |
@@ -59,33 +59,21 class DigitalRFReader(ProcessingUnit): | |||
|
59 | 59 | ''' |
|
60 | 60 | ippSeconds = 1.0*self.__nSamples/self.__sample_rate |
|
61 | 61 | |
|
62 | nProfiles = 1.0/ippSeconds #Number of profiles in one second | |
|
62 | nProfiles = 1.0/ippSeconds # Number of profiles in one second | |
|
63 | 63 | |
|
64 |
self.dataOut.radarControllerHeaderObj = RadarControllerHeader( |
|
|
65 | txA=0, | |
|
66 | txB=0, | |
|
67 | nWindows=1, | |
|
68 | nHeights=self.__nSamples, | |
|
69 | firstHeight=self.__firstHeigth, | |
|
70 | deltaHeight=self.__deltaHeigth, | |
|
71 | codeType=self.__codeType, | |
|
72 | nCode=self.__nCode, nBaud=self.__nBaud, | |
|
73 | code = self.__code) | |
|
64 | self.dataOut.radarControllerHeaderObj = RadarControllerHeader(self.__radarControllerHeader) | |
|
74 | 65 | |
|
75 |
self.dataOut.systemHeaderObj = SystemHeader( |
|
|
76 | nProfiles=nProfiles, | |
|
77 | nChannels=len(self.__channelList), | |
|
78 | adcResolution=14) | |
|
66 | self.dataOut.systemHeaderObj = SystemHeader(self.__systemHeader) | |
|
79 | 67 | |
|
80 | 68 | self.dataOut.type = "Voltage" |
|
81 | 69 | |
|
82 | 70 | self.dataOut.data = None |
|
83 | 71 | |
|
84 |
self.dataOut.dtype = |
|
|
72 | self.dataOut.dtype = self.dtype | |
|
85 | 73 | |
|
86 |
|
|
|
74 | # self.dataOut.nChannels = 0 | |
|
87 | 75 | |
|
88 |
|
|
|
76 | # self.dataOut.nHeights = 0 | |
|
89 | 77 | |
|
90 | 78 | self.dataOut.nProfiles = nProfiles |
|
91 | 79 | |
@@ -95,16 +83,16 class DigitalRFReader(ProcessingUnit): | |||
|
95 | 83 | |
|
96 | 84 | self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights() |
|
97 | 85 | |
|
98 |
|
|
|
86 | # self.dataOut.channelIndexList = None | |
|
99 | 87 | |
|
100 | 88 | self.dataOut.flagNoData = True |
|
101 | ||
|
102 | #Set to TRUE if the data is discontinuous | |
|
89 | self.dataOut.flagDataAsBlock = False | |
|
90 | # Set to TRUE if the data is discontinuous | |
|
103 | 91 | self.dataOut.flagDiscontinuousBlock = False |
|
104 | 92 | |
|
105 | 93 | self.dataOut.utctime = None |
|
106 | 94 | |
|
107 | self.dataOut.timeZone = self.__timezone/60 #timezone like jroheader, difference in minutes between UTC and localtime | |
|
95 | self.dataOut.timeZone = self.__timezone/60 # timezone like jroheader, difference in minutes between UTC and localtime | |
|
108 | 96 | |
|
109 | 97 | self.dataOut.dstFlag = 0 |
|
110 | 98 | |
@@ -112,16 +100,16 class DigitalRFReader(ProcessingUnit): | |||
|
112 | 100 | |
|
113 | 101 | self.dataOut.nCohInt = 1 |
|
114 | 102 | |
|
115 | self.dataOut.flagDecodeData = False #asumo que la data esta decodificada | |
|
103 | self.dataOut.flagDecodeData = False # asumo que la data esta decodificada | |
|
116 | 104 | |
|
117 | self.dataOut.flagDeflipData = False #asumo que la data esta sin flip | |
|
105 | self.dataOut.flagDeflipData = False # asumo que la data esta sin flip | |
|
118 | 106 | |
|
119 | 107 | self.dataOut.flagShiftFFT = False |
|
120 | 108 | |
|
121 | 109 | self.dataOut.ippSeconds = ippSeconds |
|
122 | 110 | |
|
123 | #Time interval between profiles | |
|
124 | #self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt | |
|
111 | # Time interval between profiles | |
|
112 | # self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt | |
|
125 | 113 | |
|
126 | 114 | self.dataOut.frequency = self.__frequency |
|
127 | 115 | |
@@ -227,19 +215,25 class DigitalRFReader(ProcessingUnit): | |||
|
227 | 215 | if not channelList: |
|
228 | 216 | channelList = range(len(channelNameList)) |
|
229 | 217 | |
|
218 | ||
|
230 | 219 | ########## Reading metadata ###################### |
|
231 | 220 | |
|
232 |
|
|
|
221 | top_properties = self.digitalReadObj.get_properties(channelNameList[channelList[0]]) | |
|
233 | 222 | |
|
234 |
self.__sample_rate = |
|
|
235 |
|
|
|
223 | self.__sample_rate = 1.0 * top_properties['sample_rate_numerator'] / top_properties['sample_rate_denominator'] | |
|
224 | # self.__samples_per_file = top_properties['samples_per_file'][0] | |
|
236 | 225 | self.__deltaHeigth = 1e6*0.15/self.__sample_rate ## why 0.15? |
|
237 | 226 | |
|
238 | 227 | this_metadata_file = self.digitalReadObj.get_digital_metadata(channelNameList[channelList[0]]) |
|
239 | 228 | metadata_bounds = this_metadata_file.get_bounds() |
|
240 | self.fixed_metadata_dict = this_metadata_file.read(metadata_bounds[0])[metadata_bounds[0]] ##GET FIRST HEADER | |
|
229 | self.fixed_metadata_dict = this_metadata_file.read(metadata_bounds[0])[metadata_bounds[0]] ## GET FIRST HEADER | |
|
230 | self.__processingHeader = self.fixed_metadata_dict['processingHeader'] | |
|
231 | self.__radarControllerHeader = self.fixed_metadata_dict['radarControllerHeader'] | |
|
232 | self.__systemHeader = self.fixed_metadata_dict['systemHeader'] | |
|
233 | self.dtype = cPickle.loads(self.fixed_metadata_dict['dtype']) | |
|
241 | 234 | |
|
242 | 235 | self.__frequency = None |
|
236 | ||
|
243 | 237 | try: |
|
244 | 238 | self.__frequency = self.fixed_metadata_dict['frequency'] |
|
245 | 239 | except: |
@@ -250,10 +244,16 class DigitalRFReader(ProcessingUnit): | |||
|
250 | 244 | except: |
|
251 | 245 | self.__timezone = 0 |
|
252 | 246 | |
|
247 | ||
|
248 | try: | |
|
249 | nSamples = self.__systemHeader['nSamples'] | |
|
250 | except: | |
|
251 | nSamples = None | |
|
252 | ||
|
253 | 253 | self.__firstHeigth = 0 |
|
254 | 254 | |
|
255 | 255 | try: |
|
256 |
codeType = self. |
|
|
256 | codeType = self.__radarControllerHeader['codeType'] | |
|
257 | 257 | except: |
|
258 | 258 | codeType = 0 |
|
259 | 259 | |
@@ -262,14 +262,14 class DigitalRFReader(ProcessingUnit): | |||
|
262 | 262 | code = numpy.ones((nCode, nBaud), dtype=numpy.int) |
|
263 | 263 | |
|
264 | 264 | if codeType: |
|
265 |
nCode = self. |
|
|
266 |
nBaud = self. |
|
|
267 |
code = self. |
|
|
268 | ||
|
265 | nCode = self.__radarControllerHeader['nCode'] | |
|
266 | nBaud = self.__radarControllerHeader['nBaud'] | |
|
267 | code = self.__radarControllerHeader['code'] | |
|
268 | ||
|
269 | 269 | if not ippKm: |
|
270 | 270 | try: |
|
271 | #seconds to km | |
|
272 |
ippKm = 1e6*0.15*self. |
|
|
271 | # seconds to km | |
|
272 | ippKm = 1e6*0.15*self.__radarControllerHeader['ipp'] | |
|
273 | 273 | except: |
|
274 | 274 | ippKm = None |
|
275 | 275 | #################################################### |
@@ -313,7 +313,7 class DigitalRFReader(ProcessingUnit): | |||
|
313 | 313 | channelNameListFiltered.append(thisChannelName) |
|
314 | 314 | |
|
315 | 315 | self.profileIndex = 0 |
|
316 | ||
|
316 | self.i= 0 | |
|
317 | 317 | self.__delay = delay |
|
318 | 318 | self.__ippKm = ippKm |
|
319 | 319 | self.__codeType = codeType |
@@ -327,19 +327,19 class DigitalRFReader(ProcessingUnit): | |||
|
327 | 327 | self.__channelNameList = channelNameListFiltered |
|
328 | 328 | self.__channelBoundList = channelBoundList |
|
329 | 329 | self.__nSamples = nSamples |
|
330 |
self.__samples_to_read = long( |
|
|
330 | self.__samples_to_read = long(nSamples) # FIJO: AHORA 40 | |
|
331 | 331 | self.__nChannels = len(self.__channelList) |
|
332 | 332 | |
|
333 | 333 | self.__startUTCSecond = startUTCSecond |
|
334 | 334 | self.__endUTCSecond = endUTCSecond |
|
335 | 335 | |
|
336 | self.__timeInterval = 1.0 * self.__samples_to_read/self.__sample_rate #Time interval | |
|
336 | self.__timeInterval = 1.0 * self.__samples_to_read/self.__sample_rate # Time interval | |
|
337 | 337 | |
|
338 | 338 | if online: |
|
339 |
|
|
|
339 | # self.__thisUnixSample = int(endUTCSecond*self.__sample_rate - 4*self.__samples_to_read) | |
|
340 | 340 | startUTCSecond = numpy.floor(endUTCSecond) |
|
341 | 341 | |
|
342 | self.__thisUnixSample = long(startUTCSecond*self.__sample_rate) - self.__samples_to_read ##por que en el otro metodo lo primero q se hace es sumar samplestoread | |
|
342 | self.__thisUnixSample = long(startUTCSecond*self.__sample_rate) - self.__samples_to_read ## por que en el otro metodo lo primero q se hace es sumar samplestoread | |
|
343 | 343 | |
|
344 | 344 | self.__data_buffer = numpy.zeros((self.__nChannels, self.__samples_to_read), dtype = numpy.complex) |
|
345 | 345 | |
@@ -390,7 +390,7 class DigitalRFReader(ProcessingUnit): | |||
|
390 | 390 | ''' |
|
391 | 391 | ''' |
|
392 | 392 | |
|
393 | #Set the next data | |
|
393 | # Set the next data | |
|
394 | 394 | self.__flagDiscontinuousBlock = False |
|
395 | 395 | self.__thisUnixSample += self.__samples_to_read |
|
396 | 396 | |
@@ -408,9 +408,7 class DigitalRFReader(ProcessingUnit): | |||
|
408 | 408 | indexChannel = 0 |
|
409 | 409 | |
|
410 | 410 | dataOk = False |
|
411 | ||
|
412 | 411 | for thisChannelName in self.__channelNameList: ##TODO VARIOS CHANNELS? |
|
413 | ||
|
414 | 412 | try: |
|
415 | 413 | result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample, |
|
416 | 414 | self.__samples_to_read, |
@@ -433,7 +431,7 class DigitalRFReader(ProcessingUnit): | |||
|
433 | 431 | indexChannel += 1 |
|
434 | 432 | |
|
435 | 433 | dataOk = True |
|
436 | ||
|
434 | ||
|
437 | 435 | self.__utctime = self.__thisUnixSample/self.__sample_rate |
|
438 | 436 | |
|
439 | 437 | if not dataOk: |
@@ -472,7 +470,6 class DigitalRFReader(ProcessingUnit): | |||
|
472 | 470 | self.dataOut.flagNoData = True |
|
473 | 471 | |
|
474 | 472 | if self.__isBufferEmpty(): |
|
475 | ||
|
476 | 473 | self.__flagDiscontinuousBlock = False |
|
477 | 474 | |
|
478 | 475 | while True: |
@@ -515,8 +512,8 class DigitalRFReader(ProcessingUnit): | |||
|
515 | 512 | if self.__printInfo == False: |
|
516 | 513 | return |
|
517 | 514 | |
|
518 |
|
|
|
519 |
|
|
|
515 | # self.systemHeaderObj.printInfo() | |
|
516 | # self.radarControllerHeaderObj.printInfo() | |
|
520 | 517 | |
|
521 | 518 | self.__printInfo = False |
|
522 | 519 | |
@@ -524,16 +521,18 class DigitalRFReader(ProcessingUnit): | |||
|
524 | 521 | ''' |
|
525 | 522 | ''' |
|
526 | 523 | return |
|
527 | #print self.profileIndex | |
|
524 | # print self.profileIndex | |
|
528 | 525 | |
|
526 | ##@profile | |
|
529 | 527 | def run(self, **kwargs): |
|
530 | 528 | ''' |
|
531 | 529 | This method will be called many times so here you should put all your code |
|
532 | 530 | ''' |
|
533 | ||
|
531 | ||
|
534 | 532 | if not self.isConfig: |
|
535 | 533 | self.setup(**kwargs) |
|
536 | ||
|
534 | print self.dataOut.dtype | |
|
535 | self.i = self.i+1 | |
|
537 | 536 | self.getData(seconds=self.__delay) |
|
538 | 537 | |
|
539 | 538 | return |
@@ -548,17 +547,19 class DigitalRFWriter(Operation): | |||
|
548 | 547 | Constructor |
|
549 | 548 | ''' |
|
550 | 549 | Operation.__init__(self, **kwargs) |
|
550 | self.metadata_dict = {} | |
|
551 | 551 | self.dataOut = None |
|
552 | 552 | |
|
553 | def setup(self, dataOut, path, set=0, metadataFile='metadata', ext='.h5'): | |
|
553 | def setup(self, dataOut, path, frequency, set=0, metadataFile='metadata', ext='.h5'): | |
|
554 | 554 | ''' |
|
555 | 555 | In this method we should set all initial parameters. |
|
556 | ||
|
557 | 556 | Input: |
|
558 |
dataOut |
|
|
559 | ||
|
557 | dataOut: Input data will also be outputa data | |
|
560 | 558 | ''' |
|
561 | ||
|
559 | self.metadata_dict['frequency'] = frequency | |
|
560 | self.metadata_dict['timezone'] = -5 * 60 * 60 | |
|
561 | self.metadata_dict['dtype'] = cPickle.dumps(dataOut.dtype) | |
|
562 | ||
|
562 | 563 | self.__ippSeconds = dataOut.ippSeconds |
|
563 | 564 | self.__deltaH = dataOut.getDeltaH() |
|
564 | 565 | self.__sample_rate = 1e6*0.15/self.__deltaH |
@@ -570,11 +571,11 class DigitalRFWriter(Operation): | |||
|
570 | 571 | self.__blocks_per_file = dataOut.processingHeaderObj.dataBlocksPerFile |
|
571 | 572 | self.arr_data = arr_data = numpy.ones((self.__nSamples, 1), dtype=[('r', self.__dtype), ('i', self.__dtype)]) |
|
572 | 573 | |
|
573 |
file_cadence_millisecs = long(1.0 * self.__blocks_per_file * self.__nProfiles * self.__nSamples / self.__sample_rate * 1000 |
|
|
574 | sub_cadence_secs = file_cadence_millisecs | |
|
574 | file_cadence_millisecs = long(1.0 * self.__blocks_per_file * self.__nProfiles * self.__nSamples / self.__sample_rate) * 1000 | |
|
575 | sub_cadence_secs = file_cadence_millisecs / 500 | |
|
575 | 576 | |
|
576 |
|
|
|
577 |
|
|
|
577 | print file_cadence_millisecs | |
|
578 | print sub_cadence_secs | |
|
578 | 579 | |
|
579 | 580 | sample_rate_fraction = Fraction(self.__sample_rate).limit_denominator() |
|
580 | 581 | sample_rate_numerator = long(sample_rate_fraction.numerator) |
@@ -589,15 +590,15 class DigitalRFWriter(Operation): | |||
|
589 | 590 | is_continuous = True |
|
590 | 591 | marching_periods = False |
|
591 | 592 | |
|
592 |
self.digitalWriteObj = digital_rf.DigitalRFWriter(path, self.__dtype, |
|
|
593 |
|
|
|
593 | self.digitalWriteObj = digital_rf.DigitalRFWriter(path, self.__dtype, 100, | |
|
594 | 1000, start_global_index, | |
|
594 | 595 | sample_rate_numerator, sample_rate_denominator, uuid, compression_level, checksum, |
|
595 | 596 | is_complex, num_subchannels, is_continuous, marching_periods) |
|
596 | 597 | |
|
597 | 598 | metadata_dir = os.path.join(path, 'metadata') |
|
598 | 599 | os.system('mkdir %s' % (metadata_dir)) |
|
599 | 600 | |
|
600 |
self.digitalMetadataWriteObj = digital_rf.DigitalMetadataWriter(metadata_dir, |
|
|
601 | self.digitalMetadataWriteObj = digital_rf.DigitalMetadataWriter(metadata_dir, 100, 1, ##236, file_cadence_millisecs / 1000 | |
|
601 | 602 | sample_rate_numerator, sample_rate_denominator, |
|
602 | 603 | metadataFile) |
|
603 | 604 | |
@@ -605,49 +606,56 class DigitalRFWriter(Operation): | |||
|
605 | 606 | self.isConfig = True |
|
606 | 607 | self.currentSample = 0 |
|
607 | 608 | return |
|
609 | ||
|
610 | def writeMetadata(self): | |
|
611 | print '[Writing] - Writing metadata' | |
|
612 | start_idx = self.__sample_rate * self.dataOut.utctime | |
|
613 | ||
|
614 | self.metadata_dict['processingHeader'] = self.dataOut.processingHeaderObj.getAsDict() | |
|
615 | self.metadata_dict['radarControllerHeader'] = self.dataOut.radarControllerHeaderObj.getAsDict() | |
|
616 | self.metadata_dict['systemHeader'] = self.dataOut.systemHeaderObj.getAsDict() | |
|
617 | self.digitalMetadataWriteObj.write(start_idx, self.metadata_dict) | |
|
618 | return | |
|
608 | 619 | |
|
609 | @coverage | |
|
610 | def run(self, dataOut, path=None, **kwargs): | |
|
620 | ||
|
621 | def writeData(self): | |
|
622 | for i in range(self.dataOut.systemHeaderObj.nSamples): | |
|
623 | self.arr_data[i]['r'] = self.dataOut.data[0][i].real | |
|
624 | self.arr_data[i]['i'] = self.dataOut.data[0][i].imag | |
|
625 | self.digitalWriteObj.rf_write(self.arr_data) | |
|
626 | return | |
|
627 | ||
|
628 | def run(self, dataOut, frequency=49.92e6, path=None, **kwargs): | |
|
611 | 629 | ''' |
|
612 | 630 | This method will be called many times so here you should put all your code |
|
613 | ||
|
614 | 631 | Inputs: |
|
615 | ||
|
616 | dataOut : object with the data | |
|
617 | ||
|
632 | dataOut: object with the data | |
|
618 | 633 | ''' |
|
619 | #print dataOut.__dict__ | |
|
634 | # print dataOut.__dict__ | |
|
620 | 635 | self.dataOut = dataOut |
|
621 | ||
|
622 | 636 | if not self.isConfig: |
|
623 | self.setup(dataOut, path, **kwargs) | |
|
624 | ||
|
625 | samples = len(self.dataOut.data[0]) | |
|
637 | self.setup(dataOut, path, frequency, **kwargs) | |
|
626 | 638 | |
|
627 | for i in range(samples): | |
|
628 | self.arr_data[i]['r'] = dataOut.data[0][i].real | |
|
629 | self.arr_data[i]['i'] = dataOut.data[0][i].imag | |
|
630 | self.digitalWriteObj.rf_write(self.arr_data) | |
|
631 | start_idx = self.__sample_rate * dataOut.utctime | |
|
632 | metadata_dict = {} | |
|
633 | metadata_dict['frequency'] = 49.92e6 | |
|
634 | metadata_dict['blablabla'] = 49.92e6 | |
|
639 | self.writeData() | |
|
640 | ||
|
635 | 641 | self.currentSample += 1 |
|
636 | if self.dataOut.flagDataAsBlock: | |
|
637 | self.digitalMetadataWriteObj.write(start_idx, metadata_dict) | |
|
638 | elif self.currentSample == 1: | |
|
639 | print '[Writing] - Writing metadata' | |
|
640 | self.digitalMetadataWriteObj.write(start_idx, metadata_dict) | |
|
642 | if self.dataOut.flagDataAsBlock or self.currentSample == 1: | |
|
643 | self.writeMetadata() | |
|
641 | 644 | if self.currentSample == self.__nProfiles: self.currentSample = 0 |
|
645 | ||
|
642 | 646 | def close(self): |
|
643 | 647 | print '[Writing] - Closing files ' |
|
644 | self.digitalWriteObj.close() | |
|
645 | #raise | |
|
648 | try: | |
|
649 | self.digitalWriteObj.close() | |
|
650 | except: | |
|
651 | pass | |
|
652 | ||
|
653 | # raise | |
|
646 | 654 | if __name__ == '__main__': |
|
647 | 655 | |
|
648 | 656 | readObj = DigitalRFReader() |
|
649 | 657 | |
|
650 | 658 | while True: |
|
651 | 659 | readObj.run(path='/home/jchavez/jicamarca/mocked_data/') |
|
652 |
|
|
|
653 | #readObj.printNumberOfBlock() | |
|
660 | # readObj.printInfo() | |
|
661 | # readObj.printNumberOfBlock() |
@@ -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/jchavez/jicamarca/jro_data/rawdata" /><Parameter format="date" id="191113" name="startDate" value="2010/10/28" /><Parameter format="date" id="191114" name="endDate" value="2017/10/28" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="0" /></Operation><Operation id="19112" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="VoltageProc" id="1912" inputId="1911" name="VoltageProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="DigitalRFWriter" priority="2" type="other"><Parameter format="str" id="191221" name="path" value="/home/jchavez/jicamarca/mocked_data/voltage" /></Operation></ProcUnit></Project> No newline at end of file | |
|
1 | <Project description="Testing USRP data reader" id="191" name="test01"><ReadUnit datatype="DigitalRF" id="1911" inputId="0" name="DigitalRFReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="DigitalRF" /><Parameter format="str" id="191112" name="path" value="/home/jchavez/jicamarca/mocked_data" /><Parameter format="date" id="191113" name="startDate" value="2000/07/03" /><Parameter format="date" id="191114" name="endDate" value="2017/07/03" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="int" id="191118" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="Voltage" id="1912" inputId="1911" name="VoltageProc"><Operation id="19121" name="run" priority="1" type="self" /></ProcUnit></Project> No newline at end of file |
@@ -29,8 +29,7 def main(): | |||
|
29 | 29 | endDate='2017/07/03', |
|
30 | 30 | startTime='00:00:00', |
|
31 | 31 | endTime='23:59:59', |
|
32 |
online=0 |
|
|
33 | ippKm = 60) | |
|
32 | online=0) | |
|
34 | 33 | |
|
35 | 34 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', |
|
36 | 35 | inputId=readUnitConfObj.getId()) |
@@ -47,12 +46,12 def main(): | |||
|
47 | 46 | # opObj10.addParameter(name='nCode', value='2', format='float') |
|
48 | 47 | # opObj10.addParameter(name='nBaud', value='1', format='float') |
|
49 | 48 | |
|
50 | opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external') | |
|
51 | opObj10.addParameter(name='n', value='1', format='float') | |
|
49 | # opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external') | |
|
50 | # opObj10.addParameter(name='n', value='1', format='float') | |
|
52 | 51 | |
|
53 | opObj11 = procUnitConfObj0.addOperation(name='Scope', optype='external') | |
|
54 | opObj11.addParameter(name='id', value='121', format='int') | |
|
55 | opObj11.addParameter(name='wintitle', value='Scope', format='str') | |
|
52 | # opObj11 = procUnitConfObj0.addOperation(name='Scope', optype='external') | |
|
53 | # opObj11.addParameter(name='id', value='121', format='int') | |
|
54 | # opObj11.addParameter(name='wintitle', value='Scope', format='str') | |
|
56 | 55 | |
|
57 | 56 | # procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', |
|
58 | 57 | # inputId=procUnitConfObj0.getId()) |
General Comments 0
You need to be logged in to leave comments.
Login now