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