##// END OF EJS Templates
minor changes: ...
Miguel Valdez -
r585:4a01f48d236b
parent child
Show More
@@ -1,93 +1,93
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Form implementation generated from reading ui file '/home/roj-idl71/SignalChain/initwindowv2.ui'
4 4 #
5 5 # Created: Wed Mar 6 15:32:39 2013
6 6 # by: PyQt4 UI code generator 4.8.6
7 7 #
8 8 # WARNING! All changes made in this file will be lost!
9 9
10 10 from PyQt4 import QtCore, QtGui
11 11
12 12 try:
13 13 _fromUtf8 = QtCore.QString.fromUtf8
14 14 except AttributeError:
15 15 _fromUtf8 = lambda s: s
16 16
17 17 import os
18 18 from schainpy.gui.figures import tools
19 19
20 20 FIGURES_PATH = tools.get_path()
21 21
22 22 class Ui_InitWindow(object):
23 23 def setupUi(self, Dialog):
24 24 Dialog.setObjectName(_fromUtf8("Dialog"))
25 25 Dialog.resize(652, 496)
26 26 Dialog.setWindowTitle(QtGui.QApplication.translate("Dialog", "Dialog", None, QtGui.QApplication.UnicodeUTF8))
27 27 self.gridLayout = QtGui.QGridLayout(Dialog)
28 28 self.gridLayout.setObjectName(_fromUtf8("gridLayout"))
29 29 self.verticalLayout_3 = QtGui.QVBoxLayout()
30 30 self.verticalLayout_3.setObjectName(_fromUtf8("verticalLayout_3"))
31 31 self.verticalLayout_4 = QtGui.QVBoxLayout()
32 32 self.verticalLayout_4.setObjectName(_fromUtf8("verticalLayout_4"))
33 33 self.label_3 = QtGui.QLabel(Dialog)
34 34 font = QtGui.QFont()
35 35 font.setFamily(_fromUtf8("Cambria"))
36 36 font.setPointSize(22)
37 37 font.setBold(False)
38 38 font.setWeight(50)
39 39 self.label_3.setFont(font)
40 self.label_3.setText(QtGui.QApplication.translate("Dialog", "Signal Chain - Ver. 1.0", None, QtGui.QApplication.UnicodeUTF8))
40 self.label_3.setText(QtGui.QApplication.translate("Dialog", "Signal Chain GUI - Ver. 2.0", None, QtGui.QApplication.UnicodeUTF8))
41 41 self.label_3.setObjectName(_fromUtf8("label_3"))
42 42 self.verticalLayout_4.addWidget(self.label_3)
43 43 self.line_2 = QtGui.QFrame(Dialog)
44 44 self.line_2.setFrameShape(QtGui.QFrame.HLine)
45 45 self.line_2.setFrameShadow(QtGui.QFrame.Sunken)
46 46 self.line_2.setObjectName(_fromUtf8("line_2"))
47 47 self.verticalLayout_4.addWidget(self.line_2)
48 48 self.label_4 = QtGui.QLabel(Dialog)
49 49 self.label_4.setText(_fromUtf8(""))
50 50 self.label_4.setPixmap(QtGui.QPixmap(_fromUtf8( os.path.join(FIGURES_PATH,"w.jpg") )))
51 51 self.label_4.setScaledContents(True)
52 52 self.label_4.setObjectName(_fromUtf8("label_4"))
53 53 self.verticalLayout_4.addWidget(self.label_4)
54 54 self.verticalLayout_3.addLayout(self.verticalLayout_4)
55 55 self.horizontalLayout_3 = QtGui.QHBoxLayout()
56 56 self.horizontalLayout_3.setObjectName(_fromUtf8("horizontalLayout_3"))
57 57 self.horizontalLayout_4 = QtGui.QHBoxLayout()
58 58 self.horizontalLayout_4.setObjectName(_fromUtf8("horizontalLayout_4"))
59 59 spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
60 60 self.horizontalLayout_4.addItem(spacerItem)
61 61 self.ExitBtn = QtGui.QPushButton(Dialog)
62 62 self.ExitBtn.setText(QtGui.QApplication.translate("Dialog", "Exit", None, QtGui.QApplication.UnicodeUTF8))
63 63 self.ExitBtn.setObjectName(_fromUtf8("ExitBtn"))
64 64 self.horizontalLayout_4.addWidget(self.ExitBtn)
65 65 self.ContinueBtn = QtGui.QPushButton(Dialog)
66 66 self.ContinueBtn.setText(QtGui.QApplication.translate("Dialog", "Continue", None, QtGui.QApplication.UnicodeUTF8))
67 67 self.ContinueBtn.setObjectName(_fromUtf8("ContinueBtn"))
68 68 self.horizontalLayout_4.addWidget(self.ContinueBtn)
69 69 spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
70 70 self.horizontalLayout_4.addItem(spacerItem1)
71 71 self.horizontalLayout_3.addLayout(self.horizontalLayout_4)
72 72 self.verticalLayout_3.addLayout(self.horizontalLayout_3)
73 73 self.gridLayout.addLayout(self.verticalLayout_3, 0, 0, 1, 1)
74 74
75 75 self.retranslateUi(Dialog)
76 76 QtCore.QMetaObject.connectSlotsByName(Dialog)
77 77
78 78 def retranslateUi(self, Dialog):
79 79 pass
80 80
81 81
82 82 if __name__ == "__main__":
83 83 import sys
84 84 app = QtGui.QApplication(sys.argv)
85 85 Dialog = QtGui.QDialog()
86 86 ui = Ui_InitWindow()
87 87 ui.setupUi(Dialog)
88 88 Dialog.show()
89 89 sys.exit(app.exec_())
90 90
91 91
92 92
93 93
@@ -1,653 +1,653
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
14 14 class VoltageReader(JRODataReader, ProcessingUnit):
15 15 """
16 16 Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura
17 17 de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones:
18 18 perfiles*alturas*canales) son almacenados en la variable "buffer".
19 19
20 20 perfiles * alturas * canales
21 21
22 22 Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader,
23 23 RadarControllerHeader y Voltage. Los tres primeros se usan para almacenar informacion de la
24 24 cabecera de datos (metadata), y el cuarto (Voltage) para obtener y almacenar un perfil de
25 25 datos desde el "buffer" cada vez que se ejecute el metodo "getData".
26 26
27 27 Example:
28 28
29 29 dpath = "/home/myuser/data"
30 30
31 31 startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0)
32 32
33 33 endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0)
34 34
35 35 readerObj = VoltageReader()
36 36
37 37 readerObj.setup(dpath, startTime, endTime)
38 38
39 39 while(True):
40 40
41 41 #to get one profile
42 42 profile = readerObj.getData()
43 43
44 44 #print the profile
45 45 print profile
46 46
47 47 #If you want to see all datablock
48 48 print readerObj.datablock
49 49
50 50 if readerObj.flagNoMoreFiles:
51 51 break
52 52
53 53 """
54 54
55 55 ext = ".r"
56 56
57 57 optchar = "D"
58 58 dataOut = None
59 59
60 60
61 61 def __init__(self):
62 62 """
63 63 Inicializador de la clase VoltageReader para la lectura de datos de voltage.
64 64
65 65 Input:
66 66 dataOut : Objeto de la clase Voltage. Este objeto sera utilizado para
67 67 almacenar un perfil de datos cada vez que se haga un requerimiento
68 68 (getData). El perfil sera obtenido a partir del buffer de datos,
69 69 si el buffer esta vacio se hara un nuevo proceso de lectura de un
70 70 bloque de datos.
71 71 Si este parametro no es pasado se creara uno internamente.
72 72
73 73 Variables afectadas:
74 74 self.dataOut
75 75
76 76 Return:
77 77 None
78 78 """
79 79
80 80 ProcessingUnit.__init__(self)
81 81
82 82 self.isConfig = False
83 83
84 84 self.datablock = None
85 85
86 86 self.utc = 0
87 87
88 88 self.ext = ".r"
89 89
90 90 self.optchar = "D"
91 91
92 92 self.basicHeaderObj = BasicHeader(LOCALTIME)
93 93
94 94 self.systemHeaderObj = SystemHeader()
95 95
96 96 self.radarControllerHeaderObj = RadarControllerHeader()
97 97
98 98 self.processingHeaderObj = ProcessingHeader()
99 99
100 100 self.online = 0
101 101
102 102 self.fp = None
103 103
104 104 self.idFile = None
105 105
106 106 self.dtype = None
107 107
108 108 self.fileSizeByHeader = None
109 109
110 110 self.filenameList = []
111 111
112 112 self.filename = None
113 113
114 114 self.fileSize = None
115 115
116 116 self.firstHeaderSize = 0
117 117
118 118 self.basicHeaderSize = 24
119 119
120 120 self.pathList = []
121 121
122 122 self.filenameList = []
123 123
124 124 self.lastUTTime = 0
125 125
126 126 self.maxTimeStep = 30
127 127
128 128 self.flagNoMoreFiles = 0
129 129
130 130 self.set = 0
131 131
132 132 self.path = None
133 133
134 134 self.profileIndex = 2**32-1
135 135
136 136 self.delay = 3 #seconds
137 137
138 138 self.nTries = 3 #quantity tries
139 139
140 140 self.nFiles = 3 #number of files for searching
141 141
142 142 self.nReadBlocks = 0
143 143
144 144 self.flagIsNewFile = 1
145 145
146 146 self.__isFirstTimeOnline = 1
147 147
148 148 # self.ippSeconds = 0
149 149
150 150 self.flagDiscontinuousBlock = 0
151 151
152 152 self.flagIsNewBlock = 0
153 153
154 154 self.nTotalBlocks = 0
155 155
156 156 self.blocksize = 0
157 157
158 158 self.dataOut = self.createObjByDefault()
159 159
160 160 self.nTxs = 1
161 161
162 162 self.txIndex = 0
163 163
164 164 def createObjByDefault(self):
165 165
166 166 dataObj = Voltage()
167 167
168 168 return dataObj
169 169
170 170 def __hasNotDataInBuffer(self):
171 171
172 172 if self.profileIndex >= self.processingHeaderObj.profilesPerBlock:
173 173 return 1
174 174
175 175 return 0
176 176
177 177
178 178 def getBlockDimension(self):
179 179 """
180 180 Obtiene la cantidad de puntos a leer por cada bloque de datos
181 181
182 182 Affected:
183 183 self.blocksize
184 184
185 185 Return:
186 186 None
187 187 """
188 188 pts2read = self.processingHeaderObj.profilesPerBlock * self.processingHeaderObj.nHeights * self.systemHeaderObj.nChannels
189 189 self.blocksize = pts2read
190 190
191 191
192 192 def readBlock(self):
193 193 """
194 194 readBlock lee el bloque de datos desde la posicion actual del puntero del archivo
195 195 (self.fp) y actualiza todos los parametros relacionados al bloque de datos
196 196 (metadata + data). La data leida es almacenada en el buffer y el contador del buffer
197 197 es seteado a 0
198 198
199 199 Inputs:
200 200 None
201 201
202 202 Return:
203 203 None
204 204
205 205 Affected:
206 206 self.profileIndex
207 207 self.datablock
208 208 self.flagIsNewFile
209 209 self.flagIsNewBlock
210 210 self.nTotalBlocks
211 211
212 212 Exceptions:
213 213 Si un bloque leido no es un bloque valido
214 214 """
215 215 current_pointer_location = self.fp.tell()
216 216 junk = numpy.fromfile( self.fp, self.dtype, self.blocksize )
217 217
218 218 try:
219 219 junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) )
220 220 except:
221 221 #print "The read block (%3d) has not enough data" %self.nReadBlocks
222 222
223 223 if self.waitDataBlock(pointer_location=current_pointer_location):
224 224 junk = numpy.fromfile( self.fp, self.dtype, self.blocksize )
225 225 junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) )
226 226 # return 0
227 227
228 228 junk = numpy.transpose(junk, (2,0,1))
229 229 self.datablock = junk['real'] + junk['imag']*1j
230 230
231 231 self.profileIndex = 0
232 232
233 233 self.flagIsNewFile = 0
234 234 self.flagIsNewBlock = 1
235 235
236 236 self.nTotalBlocks += 1
237 237 self.nReadBlocks += 1
238 238
239 239 return 1
240 240
241 241 def getFirstHeader(self):
242 242
243 243 self.dataOut.systemHeaderObj = self.systemHeaderObj.copy()
244 244
245 245 self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy()
246 246
247 247 if self.nTxs > 1:
248 248 self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs
249 249
250 250 # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt
251 251 #
252 252 # if self.radarControllerHeaderObj.code != None:
253 253 #
254 254 # self.dataOut.nCode = self.radarControllerHeaderObj.nCode
255 255 #
256 256 # self.dataOut.nBaud = self.radarControllerHeaderObj.nBaud
257 257 #
258 258 # self.dataOut.code = self.radarControllerHeaderObj.code
259 259
260 260 self.dataOut.dtype = self.dtype
261 261
262 262 self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs
263 263
264 264 if self.processingHeaderObj.nHeights % self.nTxs != 0:
265 265 raise ValueError, "nTxs (%d) should be a multiple of nHeights (%d)" %(self.nTxs, self.processingHeaderObj.nHeights)
266 266
267 267 xf = self.processingHeaderObj.firstHeight + int(self.processingHeaderObj.nHeights/self.nTxs)*self.processingHeaderObj.deltaHeight
268 268
269 269 self.dataOut.heightList = numpy.arange(self.processingHeaderObj.firstHeight, xf, self.processingHeaderObj.deltaHeight)
270 270
271 271 self.dataOut.channelList = range(self.systemHeaderObj.nChannels)
272 272
273 273 self.dataOut.nCohInt = self.processingHeaderObj.nCohInt
274 274
275 275 self.dataOut.flagShiftFFT = False
276 276
277 277 self.dataOut.flagDecodeData = False #asumo q la data no esta decodificada
278 278
279 279 self.dataOut.flagDeflipData = False #asumo q la data no esta sin flip
280 280
281 281 self.dataOut.flagShiftFFT = False
282 282
283 283 def getData(self):
284 284 """
285 285 getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut
286 286 del tipo "Voltage" con todos los parametros asociados a este (metadata). cuando no hay datos
287 287 en el buffer de lectura es necesario hacer una nueva lectura de los bloques de datos usando
288 288 "readNextBlock"
289 289
290 290 Ademas incrementa el contador del buffer "self.profileIndex" en 1.
291 291
292 292 Return:
293 293
294 294 Si el flag self.getByBlock ha sido seteado el bloque completo es copiado a self.dataOut y el self.profileIndex
295 295 es igual al total de perfiles leidos desde el archivo.
296 296
297 297 Si self.getByBlock == False:
298 298
299 299 self.dataOut.data = buffer[:, thisProfile, :]
300 300
301 301 shape = [nChannels, nHeis]
302 302
303 303 Si self.getByBlock == True:
304 304
305 305 self.dataOut.data = buffer[:, :, :]
306 306
307 307 shape = [nChannels, nProfiles, nHeis]
308 308
309 309 Variables afectadas:
310 310 self.dataOut
311 311 self.profileIndex
312 312
313 313 Affected:
314 314 self.dataOut
315 315 self.profileIndex
316 316 self.flagDiscontinuousBlock
317 317 self.flagIsNewBlock
318 318 """
319 319
320 320 if self.flagNoMoreFiles:
321 321 self.dataOut.flagNoData = True
322 322 print 'Process finished'
323 323 return 0
324 324
325 325 self.flagDiscontinuousBlock = 0
326 326 self.flagIsNewBlock = 0
327 327
328 328 if self.__hasNotDataInBuffer():
329 329
330 330 if not( self.readNextBlock() ):
331 331 return 0
332 332
333 333 self.getFirstHeader()
334 334
335 335 if self.datablock == None:
336 336 self.dataOut.flagNoData = True
337 337 return 0
338 338
339 339 if not self.getByBlock:
340 340
341 341 """
342 342 Return profile by profile
343 343
344 344 If nTxs > 1 then one profile is divided by nTxs and number of total
345 345 blocks is increased by nTxs (nProfiles *= nTxs)
346 346 """
347 347 if self.nTxs == 1:
348 348 self.dataOut.flagDataAsBlock = False
349 349 self.dataOut.data = self.datablock[:,self.profileIndex,:]
350 350 self.dataOut.profileIndex = self.profileIndex
351 351
352 352 self.profileIndex += 1
353 353
354 354 else:
355 355 self.dataOut.flagDataAsBlock = False
356 356
357 357 iniHei_ForThisTx = (self.txIndex)*int(self.processingHeaderObj.nHeights/self.nTxs)
358 358 endHei_ForThisTx = (self.txIndex+1)*int(self.processingHeaderObj.nHeights/self.nTxs)
359 359
360 360 # print iniHei_ForThisTx, endHei_ForThisTx
361 361
362 362 self.dataOut.data = self.datablock[:, self.profileIndex, iniHei_ForThisTx:endHei_ForThisTx]
363 363 self.dataOut.profileIndex = self.profileIndex*self.nTxs + self.txIndex
364 364
365 365 self.txIndex += 1
366 366
367 367 if self.txIndex == self.nTxs:
368 368 self.txIndex = 0
369 369 self.profileIndex += 1
370 370
371 371 else:
372 372 """
373 373 Return all block
374 374 """
375 375 self.dataOut.flagDataAsBlock = True
376 376 self.dataOut.data = self.datablock
377 377 self.dataOut.profileIndex = self.processingHeaderObj.profilesPerBlock - 1
378 378
379 379 self.profileIndex = self.processingHeaderObj.profilesPerBlock - 1
380 380
381 381 self.dataOut.flagNoData = False
382 382
383 383 self.getBasicHeader()
384 384
385 385 self.dataOut.realtime = self.online
386 386
387 387 return self.dataOut.data
388 388
389 389 class VoltageWriter(JRODataWriter, Operation):
390 390 """
391 391 Esta clase permite escribir datos de voltajes a archivos procesados (.r). La escritura
392 392 de los datos siempre se realiza por bloques.
393 393 """
394 394
395 395 ext = ".r"
396 396
397 397 optchar = "D"
398 398
399 399 shapeBuffer = None
400 400
401 401
402 402 def __init__(self):
403 403 """
404 404 Inicializador de la clase VoltageWriter para la escritura de datos de espectros.
405 405
406 406 Affected:
407 407 self.dataOut
408 408
409 409 Return: None
410 410 """
411 411 Operation.__init__(self)
412 412
413 413 self.nTotalBlocks = 0
414 414
415 415 self.profileIndex = 0
416 416
417 417 self.isConfig = False
418 418
419 419 self.fp = None
420 420
421 421 self.flagIsNewFile = 1
422 422
423 423 self.nTotalBlocks = 0
424 424
425 425 self.flagIsNewBlock = 0
426 426
427 427 self.setFile = None
428 428
429 429 self.dtype = None
430 430
431 431 self.path = None
432 432
433 433 self.filename = None
434 434
435 435 self.basicHeaderObj = BasicHeader(LOCALTIME)
436 436
437 437 self.systemHeaderObj = SystemHeader()
438 438
439 439 self.radarControllerHeaderObj = RadarControllerHeader()
440 440
441 441 self.processingHeaderObj = ProcessingHeader()
442 442
443 443 def hasAllDataInBuffer(self):
444 444 if self.profileIndex >= self.processingHeaderObj.profilesPerBlock:
445 445 return 1
446 446 return 0
447 447
448 448
449 449 def setBlockDimension(self):
450 450 """
451 451 Obtiene las formas dimensionales del los subbloques de datos que componen un bloque
452 452
453 453 Affected:
454 454 self.shape_spc_Buffer
455 455 self.shape_cspc_Buffer
456 456 self.shape_dc_Buffer
457 457
458 458 Return: None
459 459 """
460 460 self.shapeBuffer = (self.processingHeaderObj.profilesPerBlock,
461 461 self.processingHeaderObj.nHeights,
462 462 self.systemHeaderObj.nChannels)
463 463
464 464 self.datablock = numpy.zeros((self.systemHeaderObj.nChannels,
465 465 self.processingHeaderObj.profilesPerBlock,
466 466 self.processingHeaderObj.nHeights),
467 467 dtype=numpy.dtype('complex64'))
468 468
469 469 def writeBlock(self):
470 470 """
471 471 Escribe el buffer en el file designado
472 472
473 473 Affected:
474 474 self.profileIndex
475 475 self.flagIsNewFile
476 476 self.flagIsNewBlock
477 477 self.nTotalBlocks
478 478 self.blockIndex
479 479
480 480 Return: None
481 481 """
482 482 data = numpy.zeros( self.shapeBuffer, self.dtype )
483 483
484 484 junk = numpy.transpose(self.datablock, (1,2,0))
485 485
486 486 data['real'] = junk.real
487 487 data['imag'] = junk.imag
488 488
489 489 data = data.reshape( (-1) )
490 490
491 491 data.tofile( self.fp )
492 492
493 493 self.datablock.fill(0)
494 494
495 495 self.profileIndex = 0
496 496 self.flagIsNewFile = 0
497 497 self.flagIsNewBlock = 1
498 498
499 499 self.blockIndex += 1
500 500 self.nTotalBlocks += 1
501 501
502 print "[Writing] Block = ", self.blockIndex
502 # print "[Writing] Block = %04d" %self.blockIndex
503 503
504 504 def putData(self):
505 505 """
506 506 Setea un bloque de datos y luego los escribe en un file
507 507
508 508 Affected:
509 509 self.flagIsNewBlock
510 510 self.profileIndex
511 511
512 512 Return:
513 513 0 : Si no hay data o no hay mas files que puedan escribirse
514 514 1 : Si se escribio la data de un bloque en un file
515 515 """
516 516 if self.dataOut.flagNoData:
517 517 return 0
518 518
519 519 self.flagIsNewBlock = 0
520 520
521 521 if self.dataOut.flagDiscontinuousBlock:
522 522 self.datablock.fill(0)
523 523 self.profileIndex = 0
524 524 self.setNextFile()
525 525
526 526 if self.profileIndex == 0:
527 527 self.setBasicHeader()
528 528
529 529 self.datablock[:,self.profileIndex,:] = self.dataOut.data
530 530
531 531 self.profileIndex += 1
532 532
533 533 if self.hasAllDataInBuffer():
534 534 #if self.flagIsNewFile:
535 535 self.writeNextBlock()
536 536 # self.setFirstHeader()
537 537
538 538 return 1
539 539
540 540 def __getProcessFlags(self):
541 541
542 542 processFlags = 0
543 543
544 544 dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')])
545 545 dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')])
546 546 dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')])
547 547 dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')])
548 548 dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')])
549 549 dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')])
550 550
551 551 dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5]
552 552
553 553
554 554
555 555 datatypeValueList = [PROCFLAG.DATATYPE_CHAR,
556 556 PROCFLAG.DATATYPE_SHORT,
557 557 PROCFLAG.DATATYPE_LONG,
558 558 PROCFLAG.DATATYPE_INT64,
559 559 PROCFLAG.DATATYPE_FLOAT,
560 560 PROCFLAG.DATATYPE_DOUBLE]
561 561
562 562
563 563 for index in range(len(dtypeList)):
564 564 if self.dataOut.dtype == dtypeList[index]:
565 565 dtypeValue = datatypeValueList[index]
566 566 break
567 567
568 568 processFlags += dtypeValue
569 569
570 570 if self.dataOut.flagDecodeData:
571 571 processFlags += PROCFLAG.DECODE_DATA
572 572
573 573 if self.dataOut.flagDeflipData:
574 574 processFlags += PROCFLAG.DEFLIP_DATA
575 575
576 576 if self.dataOut.code != None:
577 577 processFlags += PROCFLAG.DEFINE_PROCESS_CODE
578 578
579 579 if self.dataOut.nCohInt > 1:
580 580 processFlags += PROCFLAG.COHERENT_INTEGRATION
581 581
582 582 return processFlags
583 583
584 584
585 585 def __getBlockSize(self):
586 586 '''
587 587 Este metodos determina el cantidad de bytes para un bloque de datos de tipo Voltage
588 588 '''
589 589
590 590 dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')])
591 591 dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')])
592 592 dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')])
593 593 dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')])
594 594 dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')])
595 595 dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')])
596 596
597 597 dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5]
598 598 datatypeValueList = [1,2,4,8,4,8]
599 599 for index in range(len(dtypeList)):
600 600 if self.dataOut.dtype == dtypeList[index]:
601 601 datatypeValue = datatypeValueList[index]
602 602 break
603 603
604 604 blocksize = int(self.dataOut.nHeights * self.dataOut.nChannels * self.profilesPerBlock * datatypeValue * 2)
605 605
606 606 return blocksize
607 607
608 608 def setFirstHeader(self):
609 609
610 610 """
611 611 Obtiene una copia del First Header
612 612
613 613 Affected:
614 614 self.systemHeaderObj
615 615 self.radarControllerHeaderObj
616 616 self.dtype
617 617
618 618 Return:
619 619 None
620 620 """
621 621
622 622 self.systemHeaderObj = self.dataOut.systemHeaderObj.copy()
623 623 self.systemHeaderObj.nChannels = self.dataOut.nChannels
624 624 self.radarControllerHeaderObj = self.dataOut.radarControllerHeaderObj.copy()
625 625
626 626 self.setBasicHeader()
627 627
628 628 processingHeaderSize = 40 # bytes
629 629 self.processingHeaderObj.dtype = 0 # Voltage
630 630 self.processingHeaderObj.blockSize = self.__getBlockSize()
631 631 self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock
632 632 self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile
633 633 self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows
634 634 self.processingHeaderObj.processFlags = self.__getProcessFlags()
635 635 self.processingHeaderObj.nCohInt = self.dataOut.nCohInt
636 636 self.processingHeaderObj.nIncohInt = 1 # Cuando la data de origen es de tipo Voltage
637 637 self.processingHeaderObj.totalSpectra = 0 # Cuando la data de origen es de tipo Voltage
638 638
639 639 # if self.dataOut.code != None:
640 640 # self.processingHeaderObj.code = self.dataOut.code
641 641 # self.processingHeaderObj.nCode = self.dataOut.nCode
642 642 # self.processingHeaderObj.nBaud = self.dataOut.nBaud
643 643 # codesize = int(8 + 4 * self.dataOut.nCode * self.dataOut.nBaud)
644 644 # processingHeaderSize += codesize
645 645
646 646 if self.processingHeaderObj.nWindows != 0:
647 647 self.processingHeaderObj.firstHeight = self.dataOut.heightList[0]
648 648 self.processingHeaderObj.deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
649 649 self.processingHeaderObj.nHeights = self.dataOut.nHeights
650 650 self.processingHeaderObj.samplesWin = self.dataOut.nHeights
651 651 processingHeaderSize += 12
652 652
653 653 self.processingHeaderObj.size = processingHeaderSize No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now