##// END OF EJS Templates
algo
José Chávez -
r998:3cfafdf000de
parent child
Show More
@@ -1,730 +1,729
1 1
2 2 '''
3 3 Created on Jul 3, 2014
4 4
5 5 @author: roj-idl71
6 6 '''
7 7 # SUBCHANNELS EN VEZ DE CHANNELS
8 8 # BENCHMARKS -> PROBLEMAS CON ARCHIVOS GRANDES -> INCONSTANTE EN EL TIEMPO
9 9 # ACTUALIZACION DE VERSION
10 10 # HEADERS
11 11 # MODULO DE ESCRITURA
12 12 # METADATA
13 13
14 14 import os
15 15 import datetime
16 16 import numpy
17 17 import timeit
18 18 from profilehooks import coverage, profile
19 19 from fractions import Fraction
20 20
21 21 try:
22 22 from gevent import sleep
23 23 except:
24 24 from time import sleep
25 25
26 26 from schainpy.model.data.jroheaderIO import RadarControllerHeader, SystemHeader
27 27 from schainpy.model.data.jrodata import Voltage
28 28 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
29 29 from time import time
30 30
31 31 import cPickle
32 32 try:
33 33 import digital_rf
34 34 except:
35 35 print 'You should install "digital_rf" module if you want to read Digital RF data'
36 36
37 37 class DigitalRFReader(ProcessingUnit):
38 38 '''
39 39 classdocs
40 40 '''
41 41
42 42 def __init__(self, **kwargs):
43 43 '''
44 44 Constructor
45 45 '''
46 46
47 47 ProcessingUnit.__init__(self, **kwargs)
48 48
49 49 self.dataOut = Voltage()
50 50 self.__printInfo = True
51 51 self.__flagDiscontinuousBlock = False
52 52 self.__bufferIndex = 9999999
53 53 self.__ippKm = None
54 54 self.__codeType = 0
55 55 self.__nCode = None
56 56 self.__nBaud = None
57 57 self.__code = None
58 58
59 59 def close(self):
60 60 print 'Average of writing to digital rf format is ', self.oldAverage * 1000
61 61 return
62 62
63 63 def __getCurrentSecond(self):
64 64
65 65 return self.__thisUnixSample/self.__sample_rate
66 66
67 67 thisSecond = property(__getCurrentSecond, "I'm the 'thisSecond' property.")
68 68
69 69 def __setFileHeader(self):
70 70 '''
71 71 In this method will be initialized every parameter of dataOut object (header, no data)
72 72 '''
73 73 ippSeconds = 1.0*self.__nSamples/self.__sample_rate
74 74
75 75 nProfiles = 1.0/ippSeconds # Number of profiles in one second
76 76
77 77 self.dataOut.radarControllerHeaderObj = RadarControllerHeader(self.__radarControllerHeader)
78 78
79 79 self.dataOut.systemHeaderObj = SystemHeader(self.__systemHeader)
80 80
81 81 self.dataOut.type = "Voltage"
82 82
83 83 self.dataOut.data = None
84 84
85 85 self.dataOut.dtype = self.dtype
86 86
87 87 # self.dataOut.nChannels = 0
88 88
89 89 # self.dataOut.nHeights = 0
90 90
91 91 self.dataOut.nProfiles = nProfiles
92 92
93 93 self.dataOut.heightList = self.__firstHeigth + numpy.arange(self.__nSamples, dtype = numpy.float)*self.__deltaHeigth
94 94
95 95 self.dataOut.channelList = range(self.__num_subchannels)
96 96
97 97 self.dataOut.blocksize = self.dataOut.getNChannels() * self.dataOut.getNHeights()
98 98
99 99 # self.dataOut.channelIndexList = None
100 100
101 101 self.dataOut.flagNoData = True
102 102
103 103 self.dataOut.flagDataAsBlock = False
104 104 # Set to TRUE if the data is discontinuous
105 105 self.dataOut.flagDiscontinuousBlock = False
106 106
107 107 self.dataOut.utctime = None
108 108
109 109 self.dataOut.timeZone = self.__timezone/60 # timezone like jroheader, difference in minutes between UTC and localtime
110 110
111 111 self.dataOut.dstFlag = 0
112 112
113 113 self.dataOut.errorCount = 0
114 114
115 115 self.dataOut.nCohInt = self.fixed_metadata_dict['nCohInt']
116 116
117 117 self.dataOut.flagDecodeData = self.fixed_metadata_dict['flagDecodeData'] # asumo que la data esta decodificada
118 118
119 119 self.dataOut.flagDeflipData = self.fixed_metadata_dict['flagDeflipData'] # asumo que la data esta sin flip
120 120
121 121 self.dataOut.flagShiftFFT = self.fixed_metadata_dict['flagShiftFFT']
122 122
123 123 self.dataOut.useLocalTime = self.fixed_metadata_dict['useLocalTime']
124 124
125 125 self.dataOut.ippSeconds = ippSeconds
126 126
127 127 # Time interval between profiles
128 128 # self.dataOut.timeInterval = self.dataOut.ippSeconds * self.dataOut.nCohInt
129 129
130 130 self.dataOut.frequency = self.__frequency
131 131
132 132 self.dataOut.realtime = self.__online
133 133
134 134 def findDatafiles(self, path, startDate=None, endDate=None):
135 135
136 136 if not os.path.isdir(path):
137 137 return []
138 138
139 139 try:
140 140 digitalReadObj = digital_rf.DigitalRFReader(path, load_all_metadata=True)
141 141 except:
142 142 digitalReadObj = digital_rf.DigitalRFReader(path)
143 143
144 144 channelNameList = digitalReadObj.get_channels()
145 145
146 146 if not channelNameList:
147 147 return []
148 148
149 149 metadata_dict = digitalReadObj.get_rf_file_metadata(channelNameList[0])
150 150
151 151 sample_rate = metadata_dict['sample_rate'][0]
152 152
153 153 this_metadata_file = digitalReadObj.get_metadata(channelNameList[0])
154 154
155 155 try:
156 156 timezone = this_metadata_file['timezone'].value
157 157 except:
158 158 timezone = 0
159 159
160 160 startUTCSecond, endUTCSecond = digitalReadObj.get_bounds(channelNameList[0])/sample_rate - timezone
161 161
162 162 startDatetime = datetime.datetime.utcfromtimestamp(startUTCSecond)
163 163 endDatatime = datetime.datetime.utcfromtimestamp(endUTCSecond)
164 164
165 165 if not startDate:
166 166 startDate = startDatetime.date()
167 167
168 168 if not endDate:
169 169 endDate = endDatatime.date()
170 170
171 171 dateList = []
172 172
173 173 thisDatetime = startDatetime
174 174
175 175 while(thisDatetime<=endDatatime):
176 176
177 177 thisDate = thisDatetime.date()
178 178
179 179 if thisDate < startDate:
180 180 continue
181 181
182 182 if thisDate > endDate:
183 183 break
184 184
185 185 dateList.append(thisDate)
186 186 thisDatetime += datetime.timedelta(1)
187 187
188 188 return dateList
189 189
190 190 def setup(self, path = None,
191 191 startDate = None,
192 192 endDate = None,
193 193 startTime = datetime.time(0,0,0),
194 194 endTime = datetime.time(23,59,59),
195 195 channelList = None,
196 196 nSamples = None,
197 197 online = False,
198 198 delay = 60,
199 199 buffer_size = 1024,
200 200 ippKm=None,
201 201 **kwargs):
202 202 '''
203 203 In this method we should set all initial parameters.
204 204
205 205 Inputs:
206 206 path
207 207 startDate
208 208 endDate
209 209 startTime
210 210 endTime
211 211 set
212 212 expLabel
213 213 ext
214 214 online
215 215 delay
216 216 '''
217
217 self.i = 0
218 218 if not os.path.isdir(path):
219 219 raise ValueError, "[Reading] Directory %s does not exist" %path
220 220
221 221 try:
222 222 self.digitalReadObj = digital_rf.DigitalRFReader(path, load_all_metadata=True)
223 223 except:
224 224 self.digitalReadObj = digital_rf.DigitalRFReader(path)
225 225
226 226 channelNameList = self.digitalReadObj.get_channels()
227 227
228 228 if not channelNameList:
229 229 raise ValueError, "[Reading] Directory %s does not have any files" %path
230 230
231 231 if not channelList:
232 232 channelList = range(len(channelNameList))
233 233
234 234
235 235 ########## Reading metadata ######################
236 236
237 237 top_properties = self.digitalReadObj.get_properties(channelNameList[channelList[0]])
238 238
239 239
240 240
241 241
242 242
243 243
244 244 self.__num_subchannels = top_properties['num_subchannels']
245 245 self.__sample_rate = 1.0 * top_properties['sample_rate_numerator'] / top_properties['sample_rate_denominator']
246 246
247 247 # self.__samples_per_file = top_properties['samples_per_file'][0]
248 248 self.__deltaHeigth = 1e6*0.15/self.__sample_rate ## why 0.15?
249 249
250 250 this_metadata_file = self.digitalReadObj.get_digital_metadata(channelNameList[channelList[0]])
251 print this_metadata_file
252 251 metadata_bounds = this_metadata_file.get_bounds()
253 252 self.fixed_metadata_dict = this_metadata_file.read(metadata_bounds[0])[metadata_bounds[0]] ## GET FIRST HEADER
254 253 self.__processingHeader = self.fixed_metadata_dict['processingHeader']
255 254 self.__radarControllerHeader = self.fixed_metadata_dict['radarControllerHeader']
256 255 self.__systemHeader = self.fixed_metadata_dict['systemHeader']
257 256 self.dtype = cPickle.loads(self.fixed_metadata_dict['dtype'])
258 257
259 258 self.__frequency = None
260 259
261 260 try:
262 261 self.__frequency = self.fixed_metadata_dict['frequency']
263 262 except:
264 263 self.__frequency = None
265 264
266 265 try:
267 266 self.__timezone = self.fixed_metadata_dict['timezone'] * 60
268 267 except:
269 268 self.__timezone = 0
270 269
271 270
272 271 try:
273 272 nSamples = self.fixed_metadata_dict['nSamples']
274 273 except:
275 274 nSamples = None
276 275
277 276 self.__firstHeigth = 0
278 277
279 278 try:
280 279 codeType = self.__radarControllerHeader['codeType']
281 280 except:
282 281 codeType = 0
283 282
284 283 nCode = 1
285 284 nBaud = 1
286 285 code = numpy.ones((nCode, nBaud), dtype=numpy.int)
287 286
288 287 if codeType:
289 288 nCode = self.__radarControllerHeader['nCode']
290 289 nBaud = self.__radarControllerHeader['nBaud']
291 290 code = self.__radarControllerHeader['code']
292 291
293 292 if not ippKm:
294 293 try:
295 294 # seconds to km
296 295 ippKm = self.__radarControllerHeader['ipp']
297 296 except:
298 297 ippKm = None
299 298 ####################################################
300 299 startUTCSecond = None
301 300 endUTCSecond = None
302 301
303 302 if startDate:
304 303 startDatetime = datetime.datetime.combine(startDate, startTime)
305 304 startUTCSecond = (startDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone
306 305
307 306 if endDate:
308 307 endDatetime = datetime.datetime.combine(endDate, endTime)
309 308 endUTCSecond = (endDatetime-datetime.datetime(1970,1,1)).total_seconds() + self.__timezone
310 309
311 310 start_index, end_index = self.digitalReadObj.get_bounds(channelNameList[channelList[0]])
312 311
313 312 if not startUTCSecond:
314 313 startUTCSecond = start_index/self.__sample_rate
315 314
316 315 if start_index > startUTCSecond*self.__sample_rate:
317 316 startUTCSecond = start_index/self.__sample_rate
318 317
319 318 if not endUTCSecond:
320 319 endUTCSecond = end_index/self.__sample_rate
321 320
322 321 if end_index < endUTCSecond*self.__sample_rate:
323 322 endUTCSecond = end_index/self.__sample_rate
324 print ippKm
325 323 if not nSamples:
326 324 if not ippKm:
327 325 raise ValueError, "[Reading] nSamples or ippKm should be defined"
328 326 nSamples = int(ippKm / (1e6*0.15/self.__sample_rate))
329 print nSamples
330 327 channelBoundList = []
331 328 channelNameListFiltered = []
332 329
333 330 for thisIndexChannel in channelList:
334 331 thisChannelName = channelNameList[thisIndexChannel]
335 332 start_index, end_index = self.digitalReadObj.get_bounds(thisChannelName)
336 333 channelBoundList.append((start_index, end_index))
337 334 channelNameListFiltered.append(thisChannelName)
338 335
339 336 self.profileIndex = 0
340 337 self.i= 0
341 338 self.__delay = delay
342 339 self.__ippKm = ippKm
343 340 self.__codeType = codeType
344 341 self.__nCode = nCode
345 342 self.__nBaud = nBaud
346 343 self.__code = code
347 344
348 345 self.__datapath = path
349 346 self.__online = online
350 347 self.__channelList = channelList
351 348 self.__channelNameList = channelNameListFiltered
352 349 self.__channelBoundList = channelBoundList
353 350 self.__nSamples = nSamples
354 351 self.__samples_to_read = long(nSamples) # FIJO: AHORA 40
355 352 self.__nChannels = len(self.__channelList)
356 353
357 354 self.__startUTCSecond = startUTCSecond
358 355 self.__endUTCSecond = endUTCSecond
359 356
360 357 self.__timeInterval = 1.0 * self.__samples_to_read/self.__sample_rate # Time interval
361 358
362 359 if online:
363 360 # self.__thisUnixSample = int(endUTCSecond*self.__sample_rate - 4*self.__samples_to_read)
364 361 startUTCSecond = numpy.floor(endUTCSecond)
365 362
366 363 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
367 364
368 365 self.__data_buffer = numpy.zeros((self.__num_subchannels, self.__samples_to_read), dtype = numpy.complex)
369 366
370 367 self.__setFileHeader()
371 368 self.isConfig = True
372 369
373 370 print "[Reading] Digital RF Data was found from %s to %s " %(
374 371 datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone),
375 372 datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone)
376 373 )
377 374
378 375 print "[Reading] Starting process from %s to %s" %(datetime.datetime.utcfromtimestamp(startUTCSecond - self.__timezone),
379 376 datetime.datetime.utcfromtimestamp(endUTCSecond - self.__timezone)
380 377 )
381 378 self.oldAverage = None
382 379 self.count = 0
383 380 self.executionTime = 0
384 381 def __reload(self):
385 382 # print
386 383 # print "%s not in range [%s, %s]" %(
387 384 # datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone),
388 385 # datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone),
389 386 # datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone)
390 387 # )
391 388 print "[Reading] reloading metadata ..."
392 389
393 390 try:
394 391 self.digitalReadObj.reload(complete_update=True)
395 392 except:
396 393 self.digitalReadObj.reload()
397 394
398 395 start_index, end_index = self.digitalReadObj.get_bounds(self.__channelNameList[self.__channelList[0]])
399 396
400 397 if start_index > self.__startUTCSecond*self.__sample_rate:
401 398 self.__startUTCSecond = 1.0*start_index/self.__sample_rate
402 399
403 400 if end_index > self.__endUTCSecond*self.__sample_rate:
404 401 self.__endUTCSecond = 1.0*end_index/self.__sample_rate
405 402 print
406 403 print "[Reading] New timerange found [%s, %s] " %(
407 404 datetime.datetime.utcfromtimestamp(self.__startUTCSecond - self.__timezone),
408 405 datetime.datetime.utcfromtimestamp(self.__endUTCSecond - self.__timezone)
409 406 )
410 407
411 408 return True
412 409
413 410 return False
414 411
415 412 def timeit(self, toExecute):
416 413 t0 = time()
417 414 toExecute()
418 415 self.executionTime = time() - t0
419 416 if self.oldAverage is None: self.oldAverage = self.executionTime
420 417 self.oldAverage = (self.executionTime + self.count*self.oldAverage) / (self.count + 1.0)
421 418 self.count = self.count + 1.0
422 419 return
423 420
424 421 def __readNextBlock(self, seconds=30, volt_scale = 1):
425 422 '''
426 423 '''
427 424
428 425 # Set the next data
429 426 self.__flagDiscontinuousBlock = False
430 427 self.__thisUnixSample += self.__samples_to_read
431 428
432 429 if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate:
433 430 print "[Reading] There are no more data into selected time-range"
434 431 if self.__online:
435 432 self.__reload()
436 433 else:
437 434 return False
438 435
439 436 if self.__thisUnixSample + 2*self.__samples_to_read > self.__endUTCSecond*self.__sample_rate:
440 437 return False
441 438 self.__thisUnixSample -= self.__samples_to_read
442 439
443 440 indexChannel = 0
444 441
445 442 dataOk = False
446 443 for thisChannelName in self.__channelNameList: ##TODO VARIOS CHANNELS?
447 444 for indexSubchannel in range(self.__num_subchannels):
448 445 try:
449 446 t0 = time()
450 447 result = self.digitalReadObj.read_vector_c81d(self.__thisUnixSample,
451 448 self.__samples_to_read,
452 449 thisChannelName, sub_channel=indexSubchannel)
453 450 self.executionTime = time() - t0
454 451 if self.oldAverage is None: self.oldAverage = self.executionTime
455 452 self.oldAverage = (self.executionTime + self.count*self.oldAverage) / (self.count + 1.0)
456 453 self.count = self.count + 1.0
457 454
458 455 except IOError, e:
459 456 #read next profile
460 457 self.__flagDiscontinuousBlock = True
461 458 print "[Reading] %s" %datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone), e
462 459 break
463 460
464 461 if result.shape[0] != self.__samples_to_read:
465 462 self.__flagDiscontinuousBlock = True
466 463 print "[Reading] %s: Too few samples were found, just %d/%d samples" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone),
467 464 result.shape[0],
468 465 self.__samples_to_read)
469 466 break
470 467
471 468 self.__data_buffer[indexSubchannel,:] = result*volt_scale
472 469
473 470 indexChannel += 1
474 471
475 472 dataOk = True
476 473
477 474 self.__utctime = self.__thisUnixSample/self.__sample_rate
478 475
479 476 if not dataOk:
480 477 return False
481 478
482 479 print "[Reading] %s: %d samples <> %f sec" %(datetime.datetime.utcfromtimestamp(self.thisSecond - self.__timezone),
483 480 self.__samples_to_read,
484 481 self.__timeInterval)
485 482
486 483 self.__bufferIndex = 0
487 484
488 485 return True
489 486
490 487 def __isBufferEmpty(self):
491 488 return self.__bufferIndex > self.__samples_to_read - self.__nSamples #40960 - 40
492 489
493 490 def getData(self, seconds=30, nTries=5):
494 491
495 492 '''
496 493 This method gets the data from files and put the data into the dataOut object
497 494
498 495 In addition, increase el the buffer counter in one.
499 496
500 497 Return:
501 498 data : retorna un perfil de voltages (alturas * canales) copiados desde el
502 499 buffer. Si no hay mas archivos a leer retorna None.
503 500
504 501 Affected:
505 502 self.dataOut
506 503 self.profileIndex
507 504 self.flagDiscontinuousBlock
508 505 self.flagIsNewBlock
509 506 '''
510 507
511 508 err_counter = 0
512 509 self.dataOut.flagNoData = True
513 510
514 511 if self.__isBufferEmpty():
515 512 self.__flagDiscontinuousBlock = False
516 513
517 514 while True:
518 515 if self.__readNextBlock():
519 516 break
520 517 if self.__thisUnixSample > self.__endUTCSecond*self.__sample_rate:
521 518 return False
522 519
523 520 if self.__flagDiscontinuousBlock:
524 521 print '[Reading] discontinuous block found ... continue with the next block'
525 522 continue
526 523
527 524 if not self.__online:
528 525 return False
529 526
530 527 err_counter += 1
531 528 if err_counter > nTries:
532 529 return False
533 530
534 531 print '[Reading] waiting %d seconds to read a new block' %seconds
535 532 sleep(seconds)
536 533
537 534 self.dataOut.data = self.__data_buffer[:,self.__bufferIndex:self.__bufferIndex+self.__nSamples]
538 535 self.dataOut.utctime = (self.__thisUnixSample + self.__bufferIndex)/self.__sample_rate
539 536 self.dataOut.flagNoData = False
540 537 self.dataOut.flagDiscontinuousBlock = self.__flagDiscontinuousBlock
541 538 self.dataOut.profileIndex = self.profileIndex
542 539
543 540 self.__bufferIndex += self.__nSamples
544 541 self.profileIndex += 1
545 542
546 543 if self.profileIndex == self.dataOut.nProfiles:
547 544 self.profileIndex = 0
548 545
549 546 return True
550 547
551 548 def printInfo(self):
552 549 '''
553 550 '''
554 551 if self.__printInfo == False:
555 552 return
556 553
557 554 # self.systemHeaderObj.printInfo()
558 555 # self.radarControllerHeaderObj.printInfo()
559 556
560 557 self.__printInfo = False
561 558
562 559 def printNumberOfBlock(self):
563 560 '''
564 561 '''
565 562 return
566 563 # print self.profileIndex
567 564
568 ##@profile
565
569 566 def run(self, **kwargs):
570 567 '''
571 568 This method will be called many times so here you should put all your code
572 569 '''
573 570
574 571 if not self.isConfig:
575 572 self.setup(**kwargs)
576 self.i = self.i+1
573 #self.i = self.i+1
577 574 self.getData(seconds=self.__delay)
578 575
579 576 return
580 577
581 578 class DigitalRFWriter(Operation):
582 579 '''
583 580 classdocs
584 581 '''
585 582
586 583 def __init__(self, **kwargs):
587 584 '''
588 585 Constructor
589 586 '''
590 587 Operation.__init__(self, **kwargs)
591 588 self.metadata_dict = {}
592 589 self.dataOut = None
593 590
594 591 def setHeader(self):
595 592
596 593 self.metadata_dict['frequency'] = self.dataOut.frequency
597 594 self.metadata_dict['timezone'] = self.dataOut.timeZone
598 595 self.metadata_dict['dtype'] = cPickle.dumps(self.dataOut.dtype)
599 596 self.metadata_dict['nProfiles'] = self.dataOut.nProfiles
600 597 self.metadata_dict['heightList'] = self.dataOut.heightList
601 598 self.metadata_dict['channelList'] = self.dataOut.channelList
602 599 self.metadata_dict['flagDecodeData'] = self.dataOut.flagDecodeData
603 600 self.metadata_dict['flagDeflipData'] = self.dataOut.flagDeflipData
604 601 self.metadata_dict['flagShiftFFT'] = self.dataOut.flagShiftFFT
605 602 self.metadata_dict['flagDataAsBlock'] = self.dataOut.flagDataAsBlock
606 603 self.metadata_dict['useLocalTime'] = self.dataOut.useLocalTime
607 604 self.metadata_dict['nCohInt'] = self.dataOut.nCohInt
608 605
609 606 return
610 607
611 608 def setup(self, dataOut, path, frequency, fileCadence, dirCadence, metadataCadence, set=0, metadataFile='metadata', ext='.h5'):
612 609 '''
613 610 In this method we should set all initial parameters.
614 611 Input:
615 612 dataOut: Input data will also be outputa data
616 613 '''
617 614 self.setHeader()
618 615 self.__ippSeconds = dataOut.ippSeconds
619 616 self.__deltaH = dataOut.getDeltaH()
620 617 self.__sample_rate = 1e6*0.15/self.__deltaH
621 618 self.__dtype = dataOut.dtype
622 619 if len(dataOut.dtype) == 2:
623 620 self.__dtype = dataOut.dtype[0]
624 621 self.__nSamples = dataOut.systemHeaderObj.nSamples
625 622 self.__nProfiles = dataOut.nProfiles
626 623 self.__blocks_per_file = dataOut.processingHeaderObj.dataBlocksPerFile
627 self.arr_data = arr_data = numpy.ones((self.__nSamples, 2), dtype=[('r', self.__dtype), ('i', self.__dtype)])
624
625 self.arr_data = arr_data = numpy.ones((self.__nSamples, len(self.dataOut.channelList)), dtype=[('r', self.__dtype), ('i', self.__dtype)])
628 626
629 627 file_cadence_millisecs = long(1.0 * self.__blocks_per_file * self.__nProfiles * self.__nSamples / self.__sample_rate) * 1000
630 628 sub_cadence_secs = file_cadence_millisecs / 500
631 629
632 630 sample_rate_fraction = Fraction(self.__sample_rate).limit_denominator()
633 631 sample_rate_numerator = long(sample_rate_fraction.numerator)
634 632 sample_rate_denominator = long(sample_rate_fraction.denominator)
635 633 start_global_index = dataOut.utctime * self.__sample_rate
636 634
637 635 uuid = 'prueba'
638 636 compression_level = 1
639 637 checksum = False
640 638 is_complex = True
641 639 num_subchannels = len(dataOut.channelList)
642 640 is_continuous = True
643 641 marching_periods = False
644 642
645 643 self.digitalWriteObj = digital_rf.DigitalRFWriter(path, self.__dtype, dirCadence,
646 644 fileCadence, start_global_index,
647 645 sample_rate_numerator, sample_rate_denominator, uuid, compression_level, checksum,
648 646 is_complex, num_subchannels, is_continuous, marching_periods)
649 647
650 648 metadata_dir = os.path.join(path, 'metadata')
651 649 os.system('mkdir %s' % (metadata_dir))
652 650
653 651 self.digitalMetadataWriteObj = digital_rf.DigitalMetadataWriter(metadata_dir, dirCadence, 1, ##236, file_cadence_millisecs / 1000
654 652 sample_rate_numerator, sample_rate_denominator,
655 653 metadataFile)
656 654
657 655
658 656 self.isConfig = True
659 657 self.currentSample = 0
660 658 self.oldAverage = 0
661 659 self.count = 0
662 660 return
663 661
664 662 def writeMetadata(self):
665 663 print '[Writing] - Writing metadata'
666 664 start_idx = self.__sample_rate * self.dataOut.utctime
667 665
668 666 self.metadata_dict['processingHeader'] = self.dataOut.processingHeaderObj.getAsDict()
669 667 self.metadata_dict['radarControllerHeader'] = self.dataOut.radarControllerHeaderObj.getAsDict()
670 668 self.metadata_dict['systemHeader'] = self.dataOut.systemHeaderObj.getAsDict()
671 669 self.digitalMetadataWriteObj.write(start_idx, self.metadata_dict)
672 670 return
673 671
674 672
675 673 def timeit(self, toExecute):
676 674 t0 = time()
677 675 toExecute()
678 676 self.executionTime = time() - t0
679 677 if self.oldAverage is None: self.oldAverage = self.executionTime
680 678 self.oldAverage = (self.executionTime + self.count*self.oldAverage) / (self.count + 1.0)
681 679 self.count = self.count + 1.0
682 680 return
683 681
684 682
685 683 def writeData(self):
686 684 for i in range(self.dataOut.systemHeaderObj.nSamples):
687 685 for channel in self.dataOut.channelList:
688 686 self.arr_data[i][channel]['r'] = self.dataOut.data[channel][i].real
689 687 self.arr_data[i][channel]['i'] = self.dataOut.data[channel][i].imag
690 688
691 689 def f(): return self.digitalWriteObj.rf_write(self.arr_data)
692 690 self.timeit(f)
693 691
694 692 return
695 693
696 def run(self, dataOut, frequency=49.92e6, path=None, fileCadence=1000, dirCadence=100, metadataCadence=1, **kwargs):
694 def run(self, dataOut, frequency=49.92e6, path=None, fileCadence=100, dirCadence=25, metadataCadence=1, **kwargs):
697 695 '''
698 696 This method will be called many times so here you should put all your code
699 697 Inputs:
700 698 dataOut: object with the data
701 699 '''
702 700 # print dataOut.__dict__
703 701 self.dataOut = dataOut
704 702 if not self.isConfig:
705 703 self.setup(dataOut, path, frequency, fileCadence, dirCadence, metadataCadence, **kwargs)
704 self.writeMetadata()
706 705
707 706 self.writeData()
708 707
709 self.currentSample += 1
710 if self.dataOut.flagDataAsBlock or self.currentSample == 1:
711 self.writeMetadata()
712 if self.currentSample == self.__nProfiles: self.currentSample = 0
708 ## self.currentSample += 1
709 ## if self.dataOut.flagDataAsBlock or self.currentSample == 1:
710 ## self.writeMetadata()
711 ## if self.currentSample == self.__nProfiles: self.currentSample = 0
713 712
714 713 def close(self):
715 714 print '[Writing] - Closing files '
716 715 print 'Average of writing to digital rf format is ', self.oldAverage * 1000
717 716 try:
718 717 self.digitalWriteObj.close()
719 718 except:
720 719 pass
721 720
722 721 # raise
723 722 if __name__ == '__main__':
724 723
725 724 readObj = DigitalRFReader()
726 725
727 726 while True:
728 727 readObj.run(path='/home/jchavez/jicamarca/mocked_data/')
729 728 # readObj.printInfo()
730 729 # readObj.printNumberOfBlock()
@@ -1,739 +1,739
1 1 '''
2 2 Created on Jul 2, 2014
3 3
4 4 @author: roj-idl71
5 5 '''
6 6
7 7 import numpy
8 8
9 9 from jroIO_base import LOCALTIME, JRODataReader, JRODataWriter
10 10 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
11 11 from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader
12 12 from schainpy.model.data.jrodata import Voltage
13 13 import zmq
14 14 import tempfile
15 15 from StringIO import StringIO
16 16 # from _sha import blocksize
17 17
18 18 class VoltageReader(JRODataReader, ProcessingUnit):
19 19 """
20 20 Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura
21 21 de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones:
22 22 perfiles*alturas*canales) son almacenados en la variable "buffer".
23 23
24 24 perfiles * alturas * canales
25 25
26 26 Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader,
27 27 RadarControllerHeader y Voltage. Los tres primeros se usan para almacenar informacion de la
28 28 cabecera de datos (metadata), y el cuarto (Voltage) para obtener y almacenar un perfil de
29 29 datos desde el "buffer" cada vez que se ejecute el metodo "getData".
30 30
31 31 Example:
32 32
33 33 dpath = "/home/myuser/data"
34 34
35 35 startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0)
36 36
37 37 endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0)
38 38
39 39 readerObj = VoltageReader()
40 40
41 41 readerObj.setup(dpath, startTime, endTime)
42 42
43 43 while(True):
44 44
45 45 #to get one profile
46 46 profile = readerObj.getData()
47 47
48 48 #print the profile
49 49 print profile
50 50
51 51 #If you want to see all datablock
52 52 print readerObj.datablock
53 53
54 54 if readerObj.flagNoMoreFiles:
55 55 break
56 56
57 57 """
58 58
59 59 ext = ".r"
60 60
61 61 optchar = "D"
62 62 dataOut = None
63 63
64 64 def __init__(self, **kwargs):
65 65 """
66 66 Inicializador de la clase VoltageReader para la lectura de datos de voltage.
67 67
68 68 Input:
69 69 dataOut : Objeto de la clase Voltage. Este objeto sera utilizado para
70 70 almacenar un perfil de datos cada vez que se haga un requerimiento
71 71 (getData). El perfil sera obtenido a partir del buffer de datos,
72 72 si el buffer esta vacio se hara un nuevo proceso de lectura de un
73 73 bloque de datos.
74 74 Si este parametro no es pasado se creara uno internamente.
75 75
76 76 Variables afectadas:
77 77 self.dataOut
78 78
79 79 Return:
80 80 None
81 81 """
82
82
83 83 ProcessingUnit.__init__(self, **kwargs)
84
84 self.i = 0
85 85 self.isConfig = False
86 86
87 87 self.datablock = None
88 88
89 89 self.utc = 0
90 90
91 91 self.ext = ".r"
92 92
93 93 self.optchar = "D"
94 94
95 95 self.basicHeaderObj = BasicHeader(LOCALTIME)
96 96
97 97 self.systemHeaderObj = SystemHeader()
98 98
99 99 self.radarControllerHeaderObj = RadarControllerHeader()
100 100
101 101 self.processingHeaderObj = ProcessingHeader()
102 102
103 103 self.online = 0
104 104
105 105 self.fp = None
106 106
107 107 self.idFile = None
108 108
109 109 self.dtype = None
110 110
111 111 self.fileSizeByHeader = None
112 112
113 113 self.filenameList = []
114 114
115 115 self.filename = None
116 116
117 117 self.fileSize = None
118 118
119 119 self.firstHeaderSize = 0
120 120
121 121 self.basicHeaderSize = 24
122 122
123 123 self.pathList = []
124 124
125 125 self.filenameList = []
126 126
127 127 self.lastUTTime = 0
128 128
129 129 self.maxTimeStep = 30
130 130
131 131 self.flagNoMoreFiles = 0
132 132
133 133 self.set = 0
134 134
135 135 self.path = None
136 136
137 137 self.profileIndex = 2**32-1
138 138
139 139 self.delay = 3 #seconds
140 140
141 141 self.nTries = 3 #quantity tries
142 142
143 143 self.nFiles = 3 #number of files for searching
144 144
145 145 self.nReadBlocks = 0
146 146
147 147 self.flagIsNewFile = 1
148 148
149 149 self.__isFirstTimeOnline = 1
150 150
151 151 # self.ippSeconds = 0
152 152
153 153 self.flagDiscontinuousBlock = 0
154 154
155 155 self.flagIsNewBlock = 0
156 156
157 157 self.nTotalBlocks = 0
158 158
159 159 self.blocksize = 0
160 160
161 161 self.dataOut = self.createObjByDefault()
162 162
163 163 self.nTxs = 1
164 164
165 165 self.txIndex = 0
166 166
167 167 def createObjByDefault(self):
168 168
169 169 dataObj = Voltage()
170 170
171 171 return dataObj
172 172
173 173 def __hasNotDataInBuffer(self):
174 174
175 175 if self.profileIndex >= self.processingHeaderObj.profilesPerBlock*self.nTxs:
176 176 return 1
177 177
178 178 return 0
179 179
180 180
181 181 def getBlockDimension(self):
182 182 """
183 183 Obtiene la cantidad de puntos a leer por cada bloque de datos
184 184
185 185 Affected:
186 186 self.blocksize
187 187
188 188 Return:
189 189 None
190 190 """
191 191 pts2read = self.processingHeaderObj.profilesPerBlock * self.processingHeaderObj.nHeights * self.systemHeaderObj.nChannels
192 192 self.blocksize = pts2read
193 193
194 194
195 195
196 196 def readBlock(self):
197 197 """
198 198 readBlock lee el bloque de datos desde la posicion actual del puntero del archivo
199 199 (self.fp) y actualiza todos los parametros relacionados al bloque de datos
200 200 (metadata + data). La data leida es almacenada en el buffer y el contador del buffer
201 201 es seteado a 0
202 202
203 203 Inputs:
204 204 None
205 205
206 206 Return:
207 207 None
208 208
209 209 Affected:
210 210 self.profileIndex
211 211 self.datablock
212 212 self.flagIsNewFile
213 213 self.flagIsNewBlock
214 214 self.nTotalBlocks
215 215
216 216 Exceptions:
217 217 Si un bloque leido no es un bloque valido
218 218 """
219 219
220 220 # if self.server is not None:
221 221 # self.zBlock = self.receiver.recv()
222 222 # self.zHeader = self.zBlock[:24]
223 223 # self.zDataBlock = self.zBlock[24:]
224 224 # junk = numpy.fromstring(self.zDataBlock, numpy.dtype([('real','<i4'),('imag','<i4')]))
225 225 # self.processingHeaderObj.profilesPerBlock = 240
226 226 # self.processingHeaderObj.nHeights = 248
227 227 # self.systemHeaderObj.nChannels
228 228 # else:
229 229 current_pointer_location = self.fp.tell()
230 230 junk = numpy.fromfile( self.fp, self.dtype, self.blocksize )
231 231
232 232 try:
233 233 junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) )
234 234 except:
235 235 #print "The read block (%3d) has not enough data" %self.nReadBlocks
236 236
237 237 if self.waitDataBlock(pointer_location=current_pointer_location):
238 238 junk = numpy.fromfile( self.fp, self.dtype, self.blocksize )
239 239 junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) )
240 240 # return 0
241 241
242 242 #Dimensions : nChannels, nProfiles, nSamples
243 243
244 244 junk = numpy.transpose(junk, (2,0,1))
245 245 self.datablock = junk['real'] + junk['imag']*1j
246 246
247 247 self.profileIndex = 0
248 248
249 249 self.flagIsNewFile = 0
250 250 self.flagIsNewBlock = 1
251 251
252 252 self.nTotalBlocks += 1
253 253 self.nReadBlocks += 1
254 254
255 255 return 1
256 256
257 257 def getFirstHeader(self):
258 258
259 259 self.getBasicHeader()
260 260
261 261 self.dataOut.systemHeaderObj = self.systemHeaderObj.copy()
262 262
263 263 self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy()
264 264
265 265 self.dataOut.processingHeaderObj = self.processingHeaderObj.copy()
266 266
267 267 if self.nTxs > 1:
268 268 self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs
269 269
270 270 #Time interval and code are propierties of dataOut. Its value depends of radarControllerHeaderObj.
271 271
272 272 # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt
273 273 #
274 274 # if self.radarControllerHeaderObj.code is not None:
275 275 #
276 276 # self.dataOut.nCode = self.radarControllerHeaderObj.nCode
277 277 #
278 278 # self.dataOut.nBaud = self.radarControllerHeaderObj.nBaud
279 279 #
280 280 # self.dataOut.code = self.radarControllerHeaderObj.code
281 281
282 282 self.dataOut.dtype = self.dtype
283 283
284 284 self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock
285 285
286 286 self.dataOut.heightList = numpy.arange(self.processingHeaderObj.nHeights) *self.processingHeaderObj.deltaHeight + self.processingHeaderObj.firstHeight
287 287
288 288 self.dataOut.channelList = range(self.systemHeaderObj.nChannels)
289 289
290 290 self.dataOut.nCohInt = self.processingHeaderObj.nCohInt
291 291
292 292 self.dataOut.flagDecodeData = self.processingHeaderObj.flag_decode #asumo q la data no esta decodificada
293 293
294 294 self.dataOut.flagDeflipData = self.processingHeaderObj.flag_deflip #asumo q la data no esta sin flip
295 295
296 296 self.dataOut.flagShiftFFT = self.processingHeaderObj.shif_fft
297 297
298 298 def reshapeData(self):
299 299
300 300 if self.nTxs < 0:
301 301 return
302 302
303 303 if self.nTxs == 1:
304 304 return
305 305
306 306 if self.nTxs < 1 and self.processingHeaderObj.profilesPerBlock % (1./self.nTxs) != 0:
307 307 raise ValueError, "1./nTxs (=%f), should be a multiple of nProfiles (=%d)" %(1./self.nTxs, self.processingHeaderObj.profilesPerBlock)
308 308
309 309 if self.nTxs > 1 and self.processingHeaderObj.nHeights % self.nTxs != 0:
310 310 raise ValueError, "nTxs (=%d), should be a multiple of nHeights (=%d)" %(self.nTxs, self.processingHeaderObj.nHeights)
311 311
312 312 self.datablock = self.datablock.reshape((self.systemHeaderObj.nChannels, self.processingHeaderObj.profilesPerBlock*self.nTxs, self.processingHeaderObj.nHeights/self.nTxs))
313 313
314 314 self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs
315 315 self.dataOut.heightList = numpy.arange(self.processingHeaderObj.nHeights/self.nTxs) *self.processingHeaderObj.deltaHeight + self.processingHeaderObj.firstHeight
316 316 self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs
317 317
318 318 return
319 319
320 320 def readFirstHeaderFromServer(self):
321 321
322 322 self.getFirstHeader()
323 323
324 324 self.firstHeaderSize = self.basicHeaderObj.size
325 325
326 326 datatype = int(numpy.log2((self.processingHeaderObj.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR))
327 327 if datatype == 0:
328 328 datatype_str = numpy.dtype([('real','<i1'),('imag','<i1')])
329 329 elif datatype == 1:
330 330 datatype_str = numpy.dtype([('real','<i2'),('imag','<i2')])
331 331 elif datatype == 2:
332 332 datatype_str = numpy.dtype([('real','<i4'),('imag','<i4')])
333 333 elif datatype == 3:
334 334 datatype_str = numpy.dtype([('real','<i8'),('imag','<i8')])
335 335 elif datatype == 4:
336 336 datatype_str = numpy.dtype([('real','<f4'),('imag','<f4')])
337 337 elif datatype == 5:
338 338 datatype_str = numpy.dtype([('real','<f8'),('imag','<f8')])
339 339 else:
340 340 raise ValueError, 'Data type was not defined'
341 341
342 342 self.dtype = datatype_str
343 343 #self.ippSeconds = 2 * 1000 * self.radarControllerHeaderObj.ipp / self.c
344 344 self.fileSizeByHeader = self.processingHeaderObj.dataBlocksPerFile * self.processingHeaderObj.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.processingHeaderObj.dataBlocksPerFile - 1)
345 345 # self.dataOut.channelList = numpy.arange(self.systemHeaderObj.numChannels)
346 346 # self.dataOut.channelIndexList = numpy.arange(self.systemHeaderObj.numChannels)
347 347 self.getBlockDimension()
348 348
349 349
350 350 def getFromServer(self):
351 351 self.flagDiscontinuousBlock = 0
352 352 self.profileIndex = 0
353 353 self.flagIsNewBlock = 1
354 354 self.dataOut.flagNoData = False
355 355 self.nTotalBlocks += 1
356 356 self.nReadBlocks += 1
357 357 self.blockPointer = 0
358 358
359 359 block = self.receiver.recv()
360 360
361 361 self.basicHeaderObj.read(block[self.blockPointer:])
362 362 self.blockPointer += self.basicHeaderObj.length
363 363 self.systemHeaderObj.read(block[self.blockPointer:])
364 364 self.blockPointer += self.systemHeaderObj.length
365 365 self.radarControllerHeaderObj.read(block[self.blockPointer:])
366 366 self.blockPointer += self.radarControllerHeaderObj.length
367 367 self.processingHeaderObj.read(block[self.blockPointer:])
368 368 self.blockPointer += self.processingHeaderObj.length
369 369 self.readFirstHeaderFromServer()
370 370
371 371 timestamp = self.basicHeaderObj.get_datatime()
372 372 print '[Reading] - Block {} - {}'.format(self.nTotalBlocks, timestamp)
373 373 current_pointer_location = self.blockPointer
374 374 junk = numpy.fromstring( block[self.blockPointer:], self.dtype, self.blocksize )
375 375
376 376 try:
377 377 junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) )
378 378 except:
379 379 #print "The read block (%3d) has not enough data" %self.nReadBlocks
380 380 if self.waitDataBlock(pointer_location=current_pointer_location):
381 381 junk = numpy.fromstring( block[self.blockPointer:], self.dtype, self.blocksize )
382 382 junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) )
383 383 # return 0
384 384
385 385 #Dimensions : nChannels, nProfiles, nSamples
386 386
387 387 junk = numpy.transpose(junk, (2,0,1))
388 388 self.datablock = junk['real'] + junk['imag'] * 1j
389 389 self.profileIndex = 0
390 390 if self.selBlocksize == None: self.selBlocksize = self.dataOut.nProfiles
391 391 if self.selBlocktime != None:
392 392 if self.dataOut.nCohInt is not None:
393 393 nCohInt = self.dataOut.nCohInt
394 394 else:
395 395 nCohInt = 1
396 396 self.selBlocksize = int(self.dataOut.nProfiles*round(self.selBlocktime/(nCohInt*self.dataOut.ippSeconds*self.dataOut.nProfiles)))
397 397 self.dataOut.data = self.datablock[:,self.profileIndex:self.profileIndex+self.selBlocksize,:]
398 398 datasize = self.dataOut.data.shape[1]
399 399 if datasize < self.selBlocksize:
400 400 buffer = numpy.zeros((self.dataOut.data.shape[0], self.selBlocksize, self.dataOut.data.shape[2]), dtype = 'complex')
401 401 buffer[:,:datasize,:] = self.dataOut.data
402 402 self.dataOut.data = buffer
403 403 self.profileIndex = blockIndex
404 404
405 405 self.dataOut.flagDataAsBlock = True
406 406 self.flagIsNewBlock = 1
407 407 self.dataOut.realtime = self.online
408 408
409 409 return self.dataOut.data
410 410
411 411 def getData(self):
412 412 """
413 413 getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut
414 414 del tipo "Voltage" con todos los parametros asociados a este (metadata). cuando no hay datos
415 415 en el buffer de lectura es necesario hacer una nueva lectura de los bloques de datos usando
416 416 "readNextBlock"
417 417
418 418 Ademas incrementa el contador del buffer "self.profileIndex" en 1.
419 419
420 420 Return:
421 421
422 422 Si el flag self.getByBlock ha sido seteado el bloque completo es copiado a self.dataOut y el self.profileIndex
423 423 es igual al total de perfiles leidos desde el archivo.
424 424
425 425 Si self.getByBlock == False:
426 426
427 427 self.dataOut.data = buffer[:, thisProfile, :]
428 428
429 429 shape = [nChannels, nHeis]
430 430
431 431 Si self.getByBlock == True:
432 432
433 433 self.dataOut.data = buffer[:, :, :]
434 434
435 435 shape = [nChannels, nProfiles, nHeis]
436 436
437 437 Variables afectadas:
438 438 self.dataOut
439 439 self.profileIndex
440 440
441 441 Affected:
442 442 self.dataOut
443 443 self.profileIndex
444 444 self.flagDiscontinuousBlock
445 445 self.flagIsNewBlock
446 446 """
447 447 if self.flagNoMoreFiles:
448 448 self.dataOut.flagNoData = True
449 449 print 'Process finished'
450 450 return 0
451 451 self.flagDiscontinuousBlock = 0
452 452 self.flagIsNewBlock = 0
453 453 if self.__hasNotDataInBuffer():
454 454 if not( self.readNextBlock() ):
455 455 return 0
456 456
457 457 self.getFirstHeader()
458 458
459 459 self.reshapeData()
460 460 if self.datablock is None:
461 461 self.dataOut.flagNoData = True
462 462 return 0
463 463
464 464 if not self.getByBlock:
465 465
466 466 """
467 467 Return profile by profile
468 468
469 469 If nTxs > 1 then one profile is divided by nTxs and number of total
470 470 blocks is increased by nTxs (nProfiles *= nTxs)
471 471 """
472 472 self.dataOut.flagDataAsBlock = False
473 473 self.dataOut.data = self.datablock[:,self.profileIndex,:]
474 474 self.dataOut.profileIndex = self.profileIndex
475 475
476 476 self.profileIndex += 1
477 477
478 478 # elif self.selBlocksize==None or self.selBlocksize==self.dataOut.nProfiles:
479 479 # """
480 480 # Return all block
481 481 # """
482 482 # self.dataOut.flagDataAsBlock = True
483 483 # self.dataOut.data = self.datablock
484 484 # self.dataOut.profileIndex = self.dataOut.nProfiles - 1
485 485 #
486 486 # self.profileIndex = self.dataOut.nProfiles
487 487
488 488 else:
489 489 """
490 490 Return a block
491 491 """
492 492 if self.selBlocksize == None: self.selBlocksize = self.dataOut.nProfiles
493 493 if self.selBlocktime != None:
494 494 if self.dataOut.nCohInt is not None:
495 495 nCohInt = self.dataOut.nCohInt
496 496 else:
497 497 nCohInt = 1
498 498 self.selBlocksize = int(self.dataOut.nProfiles*round(self.selBlocktime/(nCohInt*self.dataOut.ippSeconds*self.dataOut.nProfiles)))
499 499
500 500 self.dataOut.data = self.datablock[:,self.profileIndex:self.profileIndex+self.selBlocksize,:]
501 501 self.profileIndex += self.selBlocksize
502 502 datasize = self.dataOut.data.shape[1]
503 503
504 504 if datasize < self.selBlocksize:
505 505 buffer = numpy.zeros((self.dataOut.data.shape[0],self.selBlocksize,self.dataOut.data.shape[2]), dtype = 'complex')
506 506 buffer[:,:datasize,:] = self.dataOut.data
507 507
508 508 while datasize < self.selBlocksize: #Not enough profiles to fill the block
509 509 if not( self.readNextBlock() ):
510 510 return 0
511 511 self.getFirstHeader()
512 512 self.reshapeData()
513 513 if self.datablock is None:
514 514 self.dataOut.flagNoData = True
515 515 return 0
516 516 #stack data
517 517 blockIndex = self.selBlocksize - datasize
518 518 datablock1 = self.datablock[:,:blockIndex,:]
519 519
520 520 buffer[:,datasize:datasize+datablock1.shape[1],:] = datablock1
521 521 datasize += datablock1.shape[1]
522 522
523 523 self.dataOut.data = buffer
524 524 self.profileIndex = blockIndex
525 525
526 526 self.dataOut.flagDataAsBlock = True
527 527 self.dataOut.nProfiles = self.dataOut.data.shape[1]
528 528
529 529 self.dataOut.flagNoData = False
530 530
531 531 self.getBasicHeader()
532 532
533 533 self.dataOut.realtime = self.online
534 534
535 535 return self.dataOut.data
536 536
537 537 class VoltageWriter(JRODataWriter, Operation):
538 538 """
539 539 Esta clase permite escribir datos de voltajes a archivos procesados (.r). La escritura
540 540 de los datos siempre se realiza por bloques.
541 541 """
542 542
543 543 ext = ".r"
544 544
545 545 optchar = "D"
546 546
547 547 shapeBuffer = None
548 548
549 549
550 550 def __init__(self, **kwargs):
551 551 """
552 552 Inicializador de la clase VoltageWriter para la escritura de datos de espectros.
553 553
554 554 Affected:
555 555 self.dataOut
556 556
557 557 Return: None
558 558 """
559 559 Operation.__init__(self, **kwargs)
560 560
561 561 self.nTotalBlocks = 0
562 562
563 563 self.profileIndex = 0
564 564
565 565 self.isConfig = False
566 566
567 567 self.fp = None
568 568
569 569 self.flagIsNewFile = 1
570 570
571 571 self.blockIndex = 0
572 572
573 573 self.flagIsNewBlock = 0
574 574
575 575 self.setFile = None
576 576
577 577 self.dtype = None
578 578
579 579 self.path = None
580 580
581 581 self.filename = None
582 582
583 583 self.basicHeaderObj = BasicHeader(LOCALTIME)
584 584
585 585 self.systemHeaderObj = SystemHeader()
586 586
587 587 self.radarControllerHeaderObj = RadarControllerHeader()
588 588
589 589 self.processingHeaderObj = ProcessingHeader()
590 590
591 591 def hasAllDataInBuffer(self):
592 592 if self.profileIndex >= self.processingHeaderObj.profilesPerBlock:
593 593 return 1
594 594 return 0
595 595
596 596
597 597 def setBlockDimension(self):
598 598 """
599 599 Obtiene las formas dimensionales del los subbloques de datos que componen un bloque
600 600
601 601 Affected:
602 602 self.shape_spc_Buffer
603 603 self.shape_cspc_Buffer
604 604 self.shape_dc_Buffer
605 605
606 606 Return: None
607 607 """
608 608 self.shapeBuffer = (self.processingHeaderObj.profilesPerBlock,
609 609 self.processingHeaderObj.nHeights,
610 610 self.systemHeaderObj.nChannels)
611 611
612 612 self.datablock = numpy.zeros((self.systemHeaderObj.nChannels,
613 613 self.processingHeaderObj.profilesPerBlock,
614 614 self.processingHeaderObj.nHeights),
615 615 dtype=numpy.dtype('complex64'))
616 616
617 617 def writeBlock(self):
618 618 """
619 619 Escribe el buffer en el file designado
620 620
621 621 Affected:
622 622 self.profileIndex
623 623 self.flagIsNewFile
624 624 self.flagIsNewBlock
625 625 self.nTotalBlocks
626 626 self.blockIndex
627 627
628 628 Return: None
629 629 """
630 630 data = numpy.zeros( self.shapeBuffer, self.dtype )
631 631
632 632 junk = numpy.transpose(self.datablock, (1,2,0))
633 633
634 634 data['real'] = junk.real
635 635 data['imag'] = junk.imag
636 636
637 637 data = data.reshape( (-1) )
638 638
639 639 data.tofile( self.fp )
640 640
641 641 self.datablock.fill(0)
642 642
643 643 self.profileIndex = 0
644 644 self.flagIsNewFile = 0
645 645 self.flagIsNewBlock = 1
646 646
647 647 self.blockIndex += 1
648 648 self.nTotalBlocks += 1
649 649
650 650 # print "[Writing] Block = %04d" %self.blockIndex
651 651
652 652 def putData(self):
653 653 """
654 654 Setea un bloque de datos y luego los escribe en un file
655 655
656 656 Affected:
657 657 self.flagIsNewBlock
658 658 self.profileIndex
659 659
660 660 Return:
661 661 0 : Si no hay data o no hay mas files que puedan escribirse
662 662 1 : Si se escribio la data de un bloque en un file
663 663 """
664 664 if self.dataOut.flagNoData:
665 665 return 0
666 666
667 667 self.flagIsNewBlock = 0
668 668
669 669 if self.dataOut.flagDiscontinuousBlock:
670 670 self.datablock.fill(0)
671 671 self.profileIndex = 0
672 672 self.setNextFile()
673 673
674 674 if self.profileIndex == 0:
675 675 self.setBasicHeader()
676 676
677 677 self.datablock[:,self.profileIndex,:] = self.dataOut.data
678 678
679 679 self.profileIndex += 1
680 680
681 681 if self.hasAllDataInBuffer():
682 682 #if self.flagIsNewFile:
683 683 self.writeNextBlock()
684 684 # self.setFirstHeader()
685 685
686 686 return 1
687 687
688 688 def __getBlockSize(self):
689 689 '''
690 690 Este metodos determina el cantidad de bytes para un bloque de datos de tipo Voltage
691 691 '''
692 692
693 693 dtype_width = self.getDtypeWidth()
694 694
695 695 blocksize = int(self.dataOut.nHeights * self.dataOut.nChannels * self.profilesPerBlock * dtype_width * 2)
696 696
697 697 return blocksize
698 698
699 699 def setFirstHeader(self):
700 700
701 701 """
702 702 Obtiene una copia del First Header
703 703
704 704 Affected:
705 705 self.systemHeaderObj
706 706 self.radarControllerHeaderObj
707 707 self.dtype
708 708
709 709 Return:
710 710 None
711 711 """
712 712
713 713 self.systemHeaderObj = self.dataOut.systemHeaderObj.copy()
714 714 self.systemHeaderObj.nChannels = self.dataOut.nChannels
715 715 self.radarControllerHeaderObj = self.dataOut.radarControllerHeaderObj.copy()
716 716
717 717 self.processingHeaderObj.dtype = 0 # Voltage
718 718 self.processingHeaderObj.blockSize = self.__getBlockSize()
719 719 self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock
720 720 self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile
721 721 self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows
722 722 self.processingHeaderObj.nCohInt = self.dataOut.nCohInt
723 723 self.processingHeaderObj.nIncohInt = 1 # Cuando la data de origen es de tipo Voltage
724 724 self.processingHeaderObj.totalSpectra = 0 # Cuando la data de origen es de tipo Voltage
725 725
726 726 if self.dataOut.code is not None:
727 727 self.processingHeaderObj.code = self.dataOut.code
728 728 self.processingHeaderObj.nCode = self.dataOut.nCode
729 729 self.processingHeaderObj.nBaud = self.dataOut.nBaud
730 730
731 731 if self.processingHeaderObj.nWindows != 0:
732 732 self.processingHeaderObj.firstHeight = self.dataOut.heightList[0]
733 733 self.processingHeaderObj.deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
734 734 self.processingHeaderObj.nHeights = self.dataOut.nHeights
735 735 self.processingHeaderObj.samplesWin = self.dataOut.nHeights
736 736
737 737 self.processingHeaderObj.processFlags = self.getProcessFlags()
738 738
739 739 self.setBasicHeader()
@@ -1,97 +1,97
1 1
2 2 import os, sys
3 3
4 4 path = os.path.split(os.getcwd())[0]
5 5 path = os.path.split(path)[0]
6 6
7 7 sys.path.insert(0, path)
8 8
9 9 from schainpy.controller import Project
10 10
11 11 controllerObj = Project()
12 12 controllerObj.setup(id = '002', name='script02', description="JASMET Meteor Detection")
13 13
14 14 #-------------------------------------- Setup -----------------------------------------
15 15 #Verificar estas variables
16 16
17 17 #Path para los archivos
18 18 # path = '/mnt/jars/2016_08/NOCHE'
19 19 # path = '/media/joscanoa/DATA_JASMET/JASMET/2016_08/DIA'
20 20 # path = '/media/joscanoa/DATA_JASMET/JASMET/2016_08/NOCHE'
21 path = '/media/joscanoa/DATA_JASMET/JASMET/2016_08/DIA'
21 path = '/media/nanosat/NewVolumen/JASMET/2016_08/DIA'
22 22
23 23 #Path para los graficos
24 24 pathfig = os.path.join(os.environ['HOME'],'Pictures/JASMET30/201608/graphics')
25 25
26 26 #Path para los archivos HDF5 de meteoros
27 27 pathfile = os.path.join(os.environ['HOME'],'Pictures/JASMET30/201608/meteor')
28 28
29 29 #Fechas para busqueda de archivos
30 30 startDate = '2016/08/29'
31 31 endDate = '2016/09/11'
32 32 #Horas para busqueda de archivos
33 33 startTime = '00:00:00'
34 34 endTime = '23:59:59'
35 35
36 36
37 37 #------------------------------ Voltage Reading Unit ----------------------------------
38 38
39 39 readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader',
40 40 path=path,
41 41 startDate=startDate,
42 42 endDate=endDate,
43 43 startTime=startTime,
44 44 endTime=endTime,
45 45 online=0,
46 46 delay=30,
47 47 walk=1,
48 48 getblock=1,
49 49 blocktime=100)
50 50
51 51 opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
52 52
53 53 #-------------------------- Voltage Processing Unit ------------------------------------
54 54
55 55 procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId())
56 56
57 57 opObj00 = procUnitConfObj0.addOperation(name='selectChannels')
58 58 opObj00.addParameter(name='channelList', value='0,1,2,3,4', format='intlist')
59 59
60 60 opObj01 = procUnitConfObj0.addOperation(name='setRadarFrequency')
61 61 opObj01.addParameter(name='frequency', value='30.e6', format='float')
62 62
63 63 opObj01 = procUnitConfObj0.addOperation(name='interpolateHeights')
64 64 opObj01.addParameter(name='topLim', value='73', format='int')
65 65 opObj01.addParameter(name='botLim', value='71', format='int')
66 66
67 67 opObj02 = procUnitConfObj0.addOperation(name='Decoder', optype='other')
68 68
69 69 opObj03 = procUnitConfObj0.addOperation(name='CohInt', optype='other')
70 70 opObj03.addParameter(name='n', value='2', format='int')
71 71
72 72 #--------------------------- Parameters Processing Unit ------------------------------------
73 73
74 74 procUnitConfObj1 = controllerObj.addProcUnit(datatype='ParametersProc', inputId=procUnitConfObj0.getId())
75 75 #
76 76 opObj10 = procUnitConfObj1.addOperation(name='SMDetection', optype='other')
77 77 opObj10.addParameter(name='azimuth', value='45', format='float')
78 78 opObj10.addParameter(name='hmin', value='60', format='float')
79 79 opObj10.addParameter(name='hmax', value='120', format='float')
80 80
81 81 opObj12 = procUnitConfObj1.addOperation(name='ParamWriter', optype='other')
82 82 opObj12.addParameter(name='path', value=pathfile)
83 83 opObj12.addParameter(name='blocksPerFile', value='1000', format='int')
84 84 opObj12.addParameter(name='metadataList',value='type,heightList,paramInterval,timeZone',format='list')
85 85 opObj12.addParameter(name='dataList',value='data_param,utctime',format='list')
86 86 opObj12.addParameter(name='mode',value='2',format='int')
87 87
88 88 #--------------------------------------------------------------------------------------------------
89 89
90 90 print "Escribiendo el archivo XML"
91 91 controllerObj.writeXml("JASMET02.xml")
92 92 print "Leyendo el archivo XML"
93 93 controllerObj.readXml("JASMET02.xml")
94 94
95 95 controllerObj.createObjects()
96 96 controllerObj.connectObjects()
97 97 controllerObj.run() No newline at end of file
@@ -1,1 +1,1
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="/media/jchavez/DATA/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
1 <Project description="Testing USRP data reader" id="191" name="test01"><ReadUnit datatype="Voltage" id="1911" inputId="0" name="VoltageReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="Voltage" /><Parameter format="str" id="191112" name="path" value="/home/nanosat/data/John" /><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="blockTime" value="100" /><Parameter format="int" id="191119" name="walk" value="0" /><Parameter format="int" id="191120" name="online" value="0" /></Operation></ReadUnit><ProcUnit datatype="VoltageProc" id="1912" inputId="1911" name="VoltageProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="Decoder" priority="2" type="external"><Parameter format="intlist" id="191221" name="code" value="1,-1,-1,1,-1" /><Parameter format="int" id="191222" name="nCode" value="5" /><Parameter format="int" id="191223" name="nBaud" value="1" /></Operation></ProcUnit></Project> No newline at end of file
@@ -1,117 +1,117
1 1 #!/usr/bin/env python
2 2 '''
3 3 Created on Jul 7, 2014
4 4
5 5 @author: roj-idl71
6 6 '''
7 7 import os, sys
8 8
9 9 from schainpy.controller import Project
10 10
11 11 def main():
12 12
13 13 desc = "Testing USRP data reader"
14 14 filename = "schain.xml"
15 15 figpath = "./"
16 16 remotefolder = "/home/wmaster/graficos"
17 17
18 18 #this controller object save all user configuration and then execute each module
19 19 #with their parameters.
20 20 controllerObj = Project()
21 21
22 22 controllerObj.setup(id = '191', name='test01', description=desc)
23 23
24 24 #Creating a reader object with its parameters
25 25 #schainpy.model.io.jroIO_usrp.USRPReader.setup()
26 26 readUnitConfObj = controllerObj.addReadUnit(datatype='DigitalRF',
27 path='/media/jchavez/DATA/mocked_data',
27 path='/home/nanosat/data/',
28 28 startDate='2000/07/03',
29 29 endDate='2017/07/03',
30 30 startTime='00:00:00',
31 31 endTime='23:59:59',
32 32 online=0)
33 33
34 procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage',
35 inputId=readUnitConfObj.getId())
34 # procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage',
35 # inputId=readUnitConfObj.getId())
36 36
37 37 # opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
38 38 # opObj10.addParameter(name='minHei', value='0', format='float')
39 39 # opObj10.addParameter(name='maxHei', value='8', format='float')
40 40
41 41 # opObj10 = procUnitConfObj0.addOperation(name='setH0')
42 42 # opObj10.addParameter(name='h0', value='5.4', format='float')
43 43
44 44 # opObj10 = procUnitConfObj0.addOperation(name='Decoder', optype='external')
45 45 # opObj10.addParameter(name='code', value='1,-1', format='intlist')
46 46 # opObj10.addParameter(name='nCode', value='2', format='float')
47 47 # opObj10.addParameter(name='nBaud', value='1', format='float')
48 48
49 49 # opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
50 50 # opObj10.addParameter(name='n', value='128', format='float')
51 51
52 52 # opObj11 = procUnitConfObj0.addOperation(name='Scope', optype='external')
53 53 # opObj11.addParameter(name='id', value='121', format='int')
54 54 # opObj11.addParameter(name='wintitle', value='Scope', format='str')
55 55
56 56 # procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra',
57 57 # inputId=procUnitConfObj0.getId())
58 58
59 59 # #Creating a processing object with its parameters
60 60 # #schainpy.model.proc.jroproc_spectra.SpectraProc.run()
61 61 # #If you need to add more parameters can use the "addParameter method"
62 62 # procUnitConfObj1.addParameter(name='nFFTPoints', value='8', format='int')
63 63 # procUnitConfObj1.addParameter(name='pairsList', value='(0,1)', format='pairslist')
64 64
65 65 # opObj10 = procUnitConfObj1.addOperation(name='IncohInt', optype='external')
66 66 # opObj10.addParameter(name='n', value='2', format='float')
67 67 #
68 68 #Using internal methods
69 69 #schainpy.model.proc.jroproc_spectra.SpectraProc.selectChannels()
70 70 # opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
71 71 # opObj10.addParameter(name='channelList', value='0,1', format='intlist')
72 72
73 73 #Using internal methods
74 74 #schainpy.model.proc.jroproc_spectra.SpectraProc.selectHeights()
75 75 # opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
76 76 # opObj10.addParameter(name='minHei', value='90', format='float')
77 77 # opObj10.addParameter(name='maxHei', value='180', format='float')
78 78
79 79 #Using external methods (new modules)
80 80 # #schainpy.model.proc.jroproc_spectra.IncohInt.setup()
81 81 # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
82 82 # opObj12.addParameter(name='n', value='1', format='int')
83 83
84 84 #Using external methods (new modules)
85 85 #schainpy.model.graphics.jroplot_spectra.SpectraPlot.setup()
86 86 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
87 87 # opObj11.addParameter(name='id', value='11', format='int')
88 88 # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
89 89 # opObj11.addParameter(name='zmin', value='0', format='int')
90 90 # opObj11.addParameter(name='zmax', value='90', format='int')
91 91 # opObj11.addParameter(name='save', value='1', format='int')
92 92 # opObj11.addParameter(name='xmin', value='-20', format='float')
93 93 # opObj11.addParameter(name='xmax', value='20', format='float')
94 94
95 95 #Using external methods (new modules)
96 96 #schainpy.model.graphics.jroplot_spectra.RTIPlot.setup()
97 97 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
98 98 # opObj11.addParameter(name='id', value='30', format='int')
99 99 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
100 100 # # opObj11.addParameter(name='zmin', value='0', format='int')
101 101 # # opObj11.addParameter(name='zmax', value='90', format='int')
102 102 # opObj11.addParameter(name='showprofile', value='1', format='int')
103 103 # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int')
104 104 # opObj11.addParameter(name='xmin', value='19.5', format='float')
105 105 # opObj11.addParameter(name='xmax', value='20', format='float')
106 106
107 107 # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
108 108 # opObj11.addParameter(name='id', value='3', format='int')
109 109 # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str')
110 110 # opObj11.addParameter(name='zmin', value='30', format='int')
111 111 # opObj11.addParameter(name='zmax', value='120', format='int')
112 112 # opObj11.addParameter(name='pairsList', value='(0,1)', format='pairslist')
113 113
114 114 controllerObj.start()
115 115
116 116 if __name__ == '__main__':
117 117 main()
@@ -1,98 +1,98
1 1 import os, sys
2 2
3 3 from schainpy.controller import Project
4 4
5 5 if __name__ == '__main__':
6 6
7 7 desc = "Segundo Test"
8 8 filename = "schain.xml"
9 9
10 10 controllerObj = Project()
11 11
12 12 controllerObj.setup(id = '191', name='test01', description=desc)
13 13
14 14 readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader',
15 path='/home/jchavez/jicamarca/jro_data/rawdata/',
15 path='/home/nanosat/data/John',
16 16 startDate='2010/10/28',
17 17 endDate='2017/10/28',
18 18 startTime='00:00:00',
19 19 endTime='23:59:59',
20 20 online=0,
21 21 walk=0)
22 22
23 23 opObj00 = readUnitConfObj.addOperation(name='printNumberOfBlock')
24 24
25 25 procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc',
26 26 inputId=readUnitConfObj.getId())
27 27
28 28 # opObj11 = procUnitConfObj0.addOperation(name='Scope', optype='external')
29 29 # opObj11.addParameter(name='id', value='121', format='int')
30 30 # opObj11.addParameter(name='wintitle', value='Scope', format='str')
31 31
32 32 opObj10 = procUnitConfObj0.addOperation(name='DigitalRFWriter', optype='other')
33 opObj10.addParameter(name='path', value='/media/jchavez/DATA/mocked_data/voltage', format='str')
33 opObj10.addParameter(name='path', value='/home/nanosat/data/digitalrf', format='str')
34 34 # opObj10.addParameter(name='minHei', value='0', format='float')
35 35 # opObj10.addParameter(name='maxHei', value='8', format='float')
36 36
37 37 # opObj10 = procUnitConfObj0.addOperation(name='filterByHeights')
38 38 # opObj10.addParameter(name='window', value='2', format='float')
39 39
40 40 # opObj10 = procUnitConfObj0.addOperation(name='Decoder', optype='external')
41 41 # opObj10.addParameter(name='code', value='1,-1', format='intlist')
42 42 # opObj10.addParameter(name='nCode', value='2', format='float')
43 43 # opObj10.addParameter(name='nBaud', value='1', format='float')
44 44
45 45
46 46 # opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
47 47 # opObj10.addParameter(name='n', value='1296', format='float')
48 48
49 49 # procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc',
50 50 # inputId=procUnitConfObj0.getId())
51 51
52 52 #Creating a processing object with its parameters
53 53 #schainpy.model.proc.jroproc_spectra.SpectraProc.run()
54 54 #If you need to add more parameters can use the "addParameter method"
55 55 # procUnitConfObj1.addParameter(name='nFFTPoints', value='128', format='int')
56 56
57 57 # opObj10 = procUnitConfObj1.addOperation(name='IncohInt', optype='external')
58 58 # opObj10.addParameter(name='n', value='2', format='float')
59 59
60 60 #Using internal methods
61 61 #schainpy.model.proc.jroproc_spectra.SpectraProc.selectChannels()
62 62 # opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
63 63 # opObj10.addParameter(name='channelList', value='0,1', format='intlist')
64 64
65 65 #Using internal methods
66 66 #schainpy.model.proc.jroproc_spectra.SpectraProc.selectHeights()
67 67 # opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
68 68 # opObj10.addParameter(name='minHei', value='90', format='float')
69 69 # opObj10.addParameter(name='maxHei', value='180', format='float')
70 70
71 71 #Using external methods (new modules)
72 72 # #schainpy.model.proc.jroproc_spectra.IncohInt.setup()
73 73 # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
74 74 # opObj12.addParameter(name='n', value='1', format='int')
75 75
76 76 #Using external methods (new modules)
77 77 #schainpy.model.graphics.jroplot_spectra.SpectraPlot.setup()
78 78 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
79 79 # opObj11.addParameter(name='id', value='11', format='int')
80 80 # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
81 81 # opObj11.addParameter(name='zmin', value='-60', format='int')
82 82 # opObj11.addParameter(name='zmax', value='10', format='int')
83 83 # opObj11.addParameter(name='save', value='1', format='int')
84 84
85 85 # #Using external methods (new modules)
86 86 # #schainpy.model.graphics.jroplot_spectra.RTIPlot.setup()
87 87 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
88 88 # opObj11.addParameter(name='id', value='30', format='int')
89 89 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
90 90 # opObj11.addParameter(name='zmin', value='-60', format='int')
91 91 # opObj11.addParameter(name='zmax', value='-10', format='int')
92 92 # opObj11.addParameter(name='showprofile', value='1', format='int')
93 93 # # opObj11.addParameter(name='timerange', value=str(5*60*60*60), format='int')
94 94 # opObj11.addParameter(name='xmin', value='14', format='float')
95 95 # opObj11.addParameter(name='xmax', value='23.9', format='float')
96 96 # opObj11.addParameter(name='save', value='1', format='int')
97 97
98 98 controllerObj.start()
General Comments 0
You need to be logged in to leave comments. Login now