@@ -7,6 +7,9 import numpy | |||
|
7 | 7 | import copy |
|
8 | 8 | import datetime |
|
9 | 9 | |
|
10 | SPEED_OF_LIGHT = 299792458 | |
|
11 | SPEED_OF_LIGHT = 3e8 | |
|
12 | ||
|
10 | 13 | BASIC_STRUCTURE = numpy.dtype([ |
|
11 | 14 | ('nSize','<u4'), |
|
12 | 15 | ('nVersion','<u2'), |
@@ -222,12 +225,12 class RadarControllerHeader(Header): | |||
|
222 | 225 | rangeTxA = None |
|
223 | 226 | rangeTxB = None |
|
224 | 227 | |
|
225 |
__ |
|
|
228 | __size = None | |
|
226 | 229 | |
|
227 | 230 | def __init__(self, expType=2, nTx=1, |
|
228 | 231 | ippKm=None, txA=0, txB=0, |
|
229 | 232 | nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None, |
|
230 |
numTaus=0, line6Function=0, line5Function=0, fClock= |
|
|
233 | numTaus=0, line6Function=0, line5Function=0, fClock=None, | |
|
231 | 234 | prePulseBefore=0, prePulseAfter=0, |
|
232 | 235 | codeType=0, nCode=0, nBaud=0, code=None, |
|
233 | 236 | flip1=0, flip2=0): |
@@ -265,6 +268,8 class RadarControllerHeader(Header): | |||
|
265 | 268 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 |
|
266 | 269 | # self.dynamic = numpy.array([],numpy.dtype('byte')) |
|
267 | 270 | |
|
271 | if self.fClock is None and self.deltaHeight is not None: | |
|
272 | self.fClock = 0.15/(deltaHeight*1e-6) #0.15Km / (height * 1u) | |
|
268 | 273 | |
|
269 | 274 | def read(self, fp): |
|
270 | 275 | |
@@ -272,7 +277,7 class RadarControllerHeader(Header): | |||
|
272 | 277 | startFp = fp.tell() |
|
273 | 278 | header = numpy.fromfile(fp,RADAR_STRUCTURE,1) |
|
274 | 279 | |
|
275 |
|
|
|
280 | size = int(header['nSize'][0]) | |
|
276 | 281 | self.expType = int(header['nExpType'][0]) |
|
277 | 282 | self.nTx = int(header['nNTx'][0]) |
|
278 | 283 | self.ipp = float(header['fIpp'][0]) |
@@ -290,7 +295,7 class RadarControllerHeader(Header): | |||
|
290 | 295 | self.rangeTxA = header['sRangeTxA'][0] |
|
291 | 296 | self.rangeTxB = header['sRangeTxB'][0] |
|
292 | 297 | # jump Dynamic Radar Controller Header |
|
293 |
# jumpFp = s |
|
|
298 | # jumpFp = size - 116 | |
|
294 | 299 | # self.dynamic = numpy.fromfile(fp,numpy.dtype('byte'),jumpFp) |
|
295 | 300 | #pointer backward to dynamic header and read |
|
296 | 301 | # backFp = fp.tell() - jumpFp |
@@ -319,13 +324,13 class RadarControllerHeader(Header): | |||
|
319 | 324 | self.code = 2.0*self.code - 1.0 |
|
320 | 325 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 |
|
321 | 326 | |
|
322 | if self.line5Function == RCfunction.FLIP: | |
|
323 | self.flip1 = numpy.fromfile(fp,'<u4',1) | |
|
324 | ||
|
325 | if self.line6Function == RCfunction.FLIP: | |
|
326 | self.flip2 = numpy.fromfile(fp,'<u4',1) | |
|
327 | # if self.line5Function == RCfunction.FLIP: | |
|
328 | # self.flip1 = numpy.fromfile(fp,'<u4',1) | |
|
329 | # | |
|
330 | # if self.line6Function == RCfunction.FLIP: | |
|
331 | # self.flip2 = numpy.fromfile(fp,'<u4',1) | |
|
327 | 332 | |
|
328 |
endFp = |
|
|
333 | endFp = size + startFp | |
|
329 | 334 | jumpFp = endFp - fp.tell() |
|
330 | 335 | if jumpFp > 0: |
|
331 | 336 | fp.seek(jumpFp) |
@@ -337,6 +342,7 class RadarControllerHeader(Header): | |||
|
337 | 342 | return 1 |
|
338 | 343 | |
|
339 | 344 | def write(self, fp): |
|
345 | ||
|
340 | 346 | headerTuple = (self.size, |
|
341 | 347 | self.expType, |
|
342 | 348 | self.nTx, |
@@ -358,9 +364,6 class RadarControllerHeader(Header): | |||
|
358 | 364 | header = numpy.array(headerTuple,RADAR_STRUCTURE) |
|
359 | 365 | header.tofile(fp) |
|
360 | 366 | |
|
361 | #dynamic = self.dynamic | |
|
362 | #dynamic.tofile(fp) | |
|
363 | ||
|
364 | 367 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) |
|
365 | 368 | samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE) |
|
366 | 369 | samplingWindow.tofile(fp) |
@@ -390,18 +393,18 class RadarControllerHeader(Header): | |||
|
390 | 393 | tempx = tempx.astype('u4') |
|
391 | 394 | tempx.tofile(fp) |
|
392 | 395 | |
|
393 | if self.line5Function == RCfunction.FLIP: | |
|
394 | self.flip1.tofile(fp) | |
|
395 | ||
|
396 | if self.line6Function == RCfunction.FLIP: | |
|
397 | self.flip2.tofile(fp) | |
|
396 | # if self.line5Function == RCfunction.FLIP: | |
|
397 | # self.flip1.tofile(fp) | |
|
398 | # | |
|
399 | # if self.line6Function == RCfunction.FLIP: | |
|
400 | # self.flip2.tofile(fp) | |
|
398 | 401 | |
|
399 | 402 | return 1 |
|
400 | 403 | |
|
401 | 404 | def get_ippSeconds(self): |
|
402 | 405 | ''' |
|
403 | 406 | ''' |
|
404 |
ippSeconds = 2.0 * 1000 * self.ipp / |
|
|
407 | ippSeconds = 2.0 * 1000 * self.ipp / SPEED_OF_LIGHT | |
|
405 | 408 | |
|
406 | 409 | return ippSeconds |
|
407 | 410 | |
@@ -409,11 +412,27 class RadarControllerHeader(Header): | |||
|
409 | 412 | ''' |
|
410 | 413 | ''' |
|
411 | 414 | |
|
412 |
self.ipp = ippSeconds * |
|
|
415 | self.ipp = ippSeconds * SPEED_OF_LIGHT / (2.0*1000) | |
|
416 | ||
|
417 | return | |
|
418 | ||
|
419 | def get_size(self): | |
|
420 | ||
|
421 | self.__size = 116 + 12*self.nWindows + 4*self.numTaus | |
|
422 | ||
|
423 | if self.codeType != 0: | |
|
424 | self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.) | |
|
425 | ||
|
426 | return self.__size | |
|
427 | ||
|
428 | def set_size(self, value): | |
|
429 | ||
|
430 | self.__size = value | |
|
413 | 431 | |
|
414 | 432 | return |
|
415 | 433 | |
|
416 | 434 | ippSeconds = property(get_ippSeconds, set_ippSeconds) |
|
435 | size = property(get_size, set_size) | |
|
417 | 436 | |
|
418 | 437 | class ProcessingHeader(Header): |
|
419 | 438 | |
@@ -581,6 +600,7 class nCodeType: | |||
|
581 | 600 | CODE_BINARY28=17 |
|
582 | 601 | |
|
583 | 602 | class PROCFLAG: |
|
603 | ||
|
584 | 604 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
585 | 605 | DECODE_DATA = numpy.uint32(0x00000002) |
|
586 | 606 | SPECTRA_CALC = numpy.uint32(0x00000004) |
@@ -616,3 +636,44 class PROCFLAG: | |||
|
616 | 636 | DATATYPE_MASK = numpy.uint32(0x00000FC0) |
|
617 | 637 | DATAARRANGE_MASK = numpy.uint32(0x00007000) |
|
618 | 638 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) |
|
639 | ||
|
640 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
|
641 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
|
642 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
|
643 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
|
644 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
|
645 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
|
646 | ||
|
647 | NUMPY_DTYPE_LIST = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
|
648 | ||
|
649 | PROCFLAG_DTYPE_LIST = [PROCFLAG.DATATYPE_CHAR, | |
|
650 | PROCFLAG.DATATYPE_SHORT, | |
|
651 | PROCFLAG.DATATYPE_LONG, | |
|
652 | PROCFLAG.DATATYPE_INT64, | |
|
653 | PROCFLAG.DATATYPE_FLOAT, | |
|
654 | PROCFLAG.DATATYPE_DOUBLE] | |
|
655 | ||
|
656 | DTYPE_WIDTH = [1, 2, 4, 8, 4, 8] | |
|
657 | ||
|
658 | def get_dtype_index(numpy_dtype): | |
|
659 | ||
|
660 | index = None | |
|
661 | ||
|
662 | for i in range(len(NUMPY_DTYPE_LIST)): | |
|
663 | if numpy_dtype == NUMPY_DTYPE_LIST[i]: | |
|
664 | index = i | |
|
665 | break | |
|
666 | ||
|
667 | return index | |
|
668 | ||
|
669 | def get_numpy_dtype(index): | |
|
670 | ||
|
671 | return NUMPY_DTYPE_LIST[index] | |
|
672 | ||
|
673 | def get_procflag_dtype(index): | |
|
674 | ||
|
675 | return PROCFLAG_DTYPE_LIST[index] | |
|
676 | ||
|
677 | def get_dtype_width(index): | |
|
678 | ||
|
679 | return DTYPE_WIDTH[index] No newline at end of file |
@@ -19,6 +19,7 except: | |||
|
19 | 19 | from time import sleep |
|
20 | 20 | |
|
21 | 21 | from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader |
|
22 | from schainpy.model.data.jroheaderIO import get_dtype_index, get_numpy_dtype, get_procflag_dtype, get_dtype_width | |
|
22 | 23 | |
|
23 | 24 | LOCALTIME = True |
|
24 | 25 | |
@@ -365,6 +366,13 class JRODataIO: | |||
|
365 | 366 | |
|
366 | 367 | raise ValueError, "Not implemented" |
|
367 | 368 | |
|
369 | def getDtypeWidth(self): | |
|
370 | ||
|
371 | dtype_index = get_dtype_index(self.dtype) | |
|
372 | dtype_width = get_dtype_width(dtype_index) | |
|
373 | ||
|
374 | return dtype_width | |
|
375 | ||
|
368 | 376 | class JRODataReader(JRODataIO): |
|
369 | 377 | |
|
370 | 378 | nReadBlocks = 0 |
@@ -872,12 +880,16 class JRODataReader(JRODataIO): | |||
|
872 | 880 | return 1 |
|
873 | 881 | |
|
874 | 882 | def readNextBlock(self): |
|
883 | ||
|
875 | 884 | if not(self.__setNewBlock()): |
|
876 | 885 | return 0 |
|
877 | 886 | |
|
878 | 887 | if not(self.readBlock()): |
|
879 | 888 | return 0 |
|
880 | 889 | |
|
890 | print "[Reading] Block No. %d/%d -> %s" %(self.basicHeaderObj.dataBlock+1, | |
|
891 | self.processingHeaderObj.dataBlocksPerFile, | |
|
892 | self.dataOut.datatime.ctime()) | |
|
881 | 893 | return 1 |
|
882 | 894 | |
|
883 | 895 | def __readFirstHeader(self): |
@@ -1128,7 +1140,8 class JRODataReader(JRODataIO): | |||
|
1128 | 1140 | |
|
1129 | 1141 | sys.exit(-1) |
|
1130 | 1142 | |
|
1131 |
|
|
|
1143 | self.getBasicHeader() | |
|
1144 | ||
|
1132 | 1145 | if last_set != None: |
|
1133 | 1146 | self.dataOut.last_block = last_set * self.processingHeaderObj.dataBlocksPerFile + self.basicHeaderObj.dataBlock |
|
1134 | 1147 | return |
@@ -1183,7 +1196,10 class JRODataReader(JRODataIO): | |||
|
1183 | 1196 | def printNumberOfBlock(self): |
|
1184 | 1197 | |
|
1185 | 1198 | if self.flagIsNewBlock: |
|
1186 |
print "[Reading] Block No. % |
|
|
1199 | print "[Reading] Block No. %d/%d -> %s" %(self.basicHeaderObj.dataBlock+1, | |
|
1200 | self.processingHeaderObj.dataBlocksPerFile, | |
|
1201 | self.dataOut.datatime.ctime()) | |
|
1202 | ||
|
1187 | 1203 | self.dataOut.blocknow = self.basicHeaderObj.dataBlock |
|
1188 | 1204 | |
|
1189 | 1205 | def printInfo(self): |
@@ -1248,6 +1264,36 class JRODataWriter(JRODataIO): | |||
|
1248 | 1264 | raise ValueError, "No implemented" |
|
1249 | 1265 | |
|
1250 | 1266 | |
|
1267 | def getProcessFlags(self): | |
|
1268 | ||
|
1269 | processFlags = 0 | |
|
1270 | ||
|
1271 | dtype_index = get_dtype_index(self.dtype) | |
|
1272 | procflag_dtype = get_procflag_dtype(dtype_index) | |
|
1273 | ||
|
1274 | processFlags += procflag_dtype | |
|
1275 | ||
|
1276 | if self.dataOut.flagDecodeData: | |
|
1277 | processFlags += PROCFLAG.DECODE_DATA | |
|
1278 | ||
|
1279 | if self.dataOut.flagDeflipData: | |
|
1280 | processFlags += PROCFLAG.DEFLIP_DATA | |
|
1281 | ||
|
1282 | if self.dataOut.code is not None: | |
|
1283 | processFlags += PROCFLAG.DEFINE_PROCESS_CODE | |
|
1284 | ||
|
1285 | if self.dataOut.nCohInt > 1: | |
|
1286 | processFlags += PROCFLAG.COHERENT_INTEGRATION | |
|
1287 | ||
|
1288 | if self.dataOut.type == "Spectra": | |
|
1289 | if self.dataOut.nIncohInt > 1: | |
|
1290 | processFlags += PROCFLAG.INCOHERENT_INTEGRATION | |
|
1291 | ||
|
1292 | if self.dataOut.data_dc is not None: | |
|
1293 | processFlags += PROCFLAG.SAVE_CHANNELS_DC | |
|
1294 | ||
|
1295 | return processFlags | |
|
1296 | ||
|
1251 | 1297 | def setBasicHeader(self): |
|
1252 | 1298 | |
|
1253 | 1299 | self.basicHeaderObj.size = self.basicHeaderSize #bytes |
@@ -1301,7 +1347,7 class JRODataWriter(JRODataIO): | |||
|
1301 | 1347 | self.radarControllerHeaderObj.write(self.fp) |
|
1302 | 1348 | self.processingHeaderObj.write(self.fp) |
|
1303 | 1349 | |
|
1304 | self.dtype = self.dataOut.dtype | |
|
1350 | ||
|
1305 | 1351 | |
|
1306 | 1352 | def __setNewBlock(self): |
|
1307 | 1353 | """ |
@@ -1340,6 +1386,8 class JRODataWriter(JRODataIO): | |||
|
1340 | 1386 | |
|
1341 | 1387 | self.writeBlock() |
|
1342 | 1388 | |
|
1389 | print "[Writing] Block No. %d/%d" %(self.blockIndex, self.processingHeaderObj.dataBlocksPerFile) | |
|
1390 | ||
|
1343 | 1391 | return 1 |
|
1344 | 1392 | |
|
1345 | 1393 | def setNextFile(self): |
@@ -1409,20 +1457,27 class JRODataWriter(JRODataIO): | |||
|
1409 | 1457 | |
|
1410 | 1458 | self.setFirstHeader() |
|
1411 | 1459 | |
|
1412 | print '[Writing] file: %s'%self.filename | |
|
1460 | print '[Writing] Opening file: %s'%self.filename | |
|
1413 | 1461 | |
|
1414 | 1462 | self.__writeFirstHeader() |
|
1415 | 1463 | |
|
1416 | 1464 | return 1 |
|
1417 | 1465 | |
|
1418 | def setup(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=0, ext=None): | |
|
1466 | def setup(self, dataOut, path, blocksPerFile, profilesPerBlock=64, set=0, ext=None, datatype=2): | |
|
1419 | 1467 | """ |
|
1420 | 1468 | Setea el tipo de formato en la cual sera guardada la data y escribe el First Header |
|
1421 | 1469 | |
|
1422 | 1470 | Inputs: |
|
1423 | path : el path destino en el cual se escribiran los files a crear | |
|
1424 | format : formato en el cual sera salvado un file | |
|
1425 |
set |
|
|
1471 | path : directory where data will be saved | |
|
1472 | profilesPerBlock : number of profiles per block | |
|
1473 | set : file set | |
|
1474 | datatype : An integer number that defines data type: | |
|
1475 | 0 : int8 (1 byte) | |
|
1476 | 1 : int16 (2 bytes) | |
|
1477 | 2 : int32 (4 bytes) | |
|
1478 | 3 : int64 (8 bytes) | |
|
1479 | 4 : float (4 bytes) | |
|
1480 | 5 : double (8 bytes) | |
|
1426 | 1481 | |
|
1427 | 1482 | Return: |
|
1428 | 1483 | 0 : Si no realizo un buen seteo |
@@ -1446,6 +1501,12 class JRODataWriter(JRODataIO): | |||
|
1446 | 1501 | |
|
1447 | 1502 | self.dataOut = dataOut |
|
1448 | 1503 | |
|
1504 | #By default | |
|
1505 | self.dtype = self.dataOut.dtype | |
|
1506 | ||
|
1507 | if datatype is not None: | |
|
1508 | self.dtype = get_numpy_dtype(datatype) | |
|
1509 | ||
|
1449 | 1510 | if not(self.setNextFile()): |
|
1450 | 1511 | print "[Writing] There isn't a next file" |
|
1451 | 1512 | return 0 |
@@ -274,6 +274,7 class SpectraReader(JRODataReader, ProcessingUnit): | |||
|
274 | 274 | |
|
275 | 275 | # self.processingHeaderObj.shif_fft = True |
|
276 | 276 | |
|
277 | #Dimensions : nChannels, nProfiles, nSamples | |
|
277 | 278 | spc = numpy.transpose( spc, (0,2,1) ) |
|
278 | 279 | self.data_spc = spc |
|
279 | 280 | |
@@ -298,6 +299,8 class SpectraReader(JRODataReader, ProcessingUnit): | |||
|
298 | 299 | |
|
299 | 300 | def getFirstHeader(self): |
|
300 | 301 | |
|
302 | self.getBasicHeader() | |
|
303 | ||
|
301 | 304 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() |
|
302 | 305 | |
|
303 | 306 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
@@ -599,89 +602,27 class SpectraWriter(JRODataWriter, Operation): | |||
|
599 | 602 | |
|
600 | 603 | return 1 |
|
601 | 604 | |
|
602 | ||
|
603 | def __getProcessFlags(self): | |
|
604 | ||
|
605 | processFlags = 0 | |
|
606 | ||
|
607 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
|
608 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
|
609 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
|
610 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
|
611 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
|
612 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
|
613 | ||
|
614 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
|
615 | ||
|
616 | ||
|
617 | ||
|
618 | datatypeValueList = [PROCFLAG.DATATYPE_CHAR, | |
|
619 | PROCFLAG.DATATYPE_SHORT, | |
|
620 | PROCFLAG.DATATYPE_LONG, | |
|
621 | PROCFLAG.DATATYPE_INT64, | |
|
622 | PROCFLAG.DATATYPE_FLOAT, | |
|
623 | PROCFLAG.DATATYPE_DOUBLE] | |
|
624 | ||
|
625 | ||
|
626 | for index in range(len(dtypeList)): | |
|
627 | if self.dataOut.dtype == dtypeList[index]: | |
|
628 | dtypeValue = datatypeValueList[index] | |
|
629 | break | |
|
630 | ||
|
631 | processFlags += dtypeValue | |
|
632 | ||
|
633 | if self.dataOut.flagDecodeData: | |
|
634 | processFlags += PROCFLAG.DECODE_DATA | |
|
635 | ||
|
636 | if self.dataOut.flagDeflipData: | |
|
637 | processFlags += PROCFLAG.DEFLIP_DATA | |
|
638 | ||
|
639 | if self.dataOut.code is not None: | |
|
640 | processFlags += PROCFLAG.DEFINE_PROCESS_CODE | |
|
641 | ||
|
642 | if self.dataOut.nIncohInt > 1: | |
|
643 | processFlags += PROCFLAG.INCOHERENT_INTEGRATION | |
|
644 | ||
|
645 | if self.dataOut.data_dc is not None: | |
|
646 | processFlags += PROCFLAG.SAVE_CHANNELS_DC | |
|
647 | ||
|
648 | return processFlags | |
|
649 | ||
|
650 | ||
|
651 | 605 | def __getBlockSize(self): |
|
652 | 606 | ''' |
|
653 | 607 | Este metodos determina el cantidad de bytes para un bloque de datos de tipo Spectra |
|
654 | 608 | ''' |
|
655 | 609 | |
|
656 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
|
657 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
|
658 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
|
659 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
|
660 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
|
661 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
|
662 | ||
|
663 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
|
664 | datatypeValueList = [1,2,4,8,4,8] | |
|
665 | for index in range(len(dtypeList)): | |
|
666 | if self.dataOut.dtype == dtypeList[index]: | |
|
667 | datatypeValue = datatypeValueList[index] | |
|
668 | break | |
|
669 | ||
|
610 | dtype_width = self.getDtypeWidth() | |
|
670 | 611 | |
|
671 | 612 | pts2write = self.dataOut.nHeights * self.dataOut.nFFTPoints |
|
672 | 613 | |
|
673 | 614 | pts2write_SelfSpectra = int(self.dataOut.nChannels * pts2write) |
|
674 |
blocksize = (pts2write_SelfSpectra*d |
|
|
615 | blocksize = (pts2write_SelfSpectra*dtype_width) | |
|
675 | 616 | |
|
676 | 617 | if self.dataOut.data_cspc is not None: |
|
677 | 618 | pts2write_CrossSpectra = int(self.dataOut.nPairs * pts2write) |
|
678 |
blocksize += (pts2write_CrossSpectra*d |
|
|
619 | blocksize += (pts2write_CrossSpectra*dtype_width*2) | |
|
679 | 620 | |
|
680 | 621 | if self.dataOut.data_dc is not None: |
|
681 | 622 | pts2write_DCchannels = int(self.dataOut.nChannels * self.dataOut.nHeights) |
|
682 |
blocksize += (pts2write_DCchannels*d |
|
|
623 | blocksize += (pts2write_DCchannels*dtype_width*2) | |
|
683 | 624 | |
|
684 | blocksize = blocksize #* datatypeValue * 2 #CORREGIR ESTO | |
|
625 | # blocksize = blocksize #* datatypeValue * 2 #CORREGIR ESTO | |
|
685 | 626 | |
|
686 | 627 | return blocksize |
|
687 | 628 | |
@@ -714,7 +655,7 class SpectraWriter(JRODataWriter, Operation): | |||
|
714 | 655 | self.processingHeaderObj.profilesPerBlock = self.dataOut.nFFTPoints |
|
715 | 656 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile |
|
716 | 657 | self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows |
|
717 |
self.processingHeaderObj.processFlags = self. |
|
|
658 | self.processingHeaderObj.processFlags = self.getProcessFlags() | |
|
718 | 659 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt# Se requiere para determinar el valor de timeInterval |
|
719 | 660 | self.processingHeaderObj.nIncohInt = self.dataOut.nIncohInt |
|
720 | 661 | self.processingHeaderObj.totalSpectra = self.dataOut.nPairs + self.dataOut.nChannels |
@@ -225,6 +225,8 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
225 | 225 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) |
|
226 | 226 | # return 0 |
|
227 | 227 | |
|
228 | #Dimensions : nChannels, nProfiles, nSamples | |
|
229 | ||
|
228 | 230 | junk = numpy.transpose(junk, (2,0,1)) |
|
229 | 231 | self.datablock = junk['real'] + junk['imag']*1j |
|
230 | 232 | |
@@ -240,6 +242,8 class VoltageReader(JRODataReader, ProcessingUnit): | |||
|
240 | 242 | |
|
241 | 243 | def getFirstHeader(self): |
|
242 | 244 | |
|
245 | self.getBasicHeader() | |
|
246 | ||
|
243 | 247 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() |
|
244 | 248 | |
|
245 | 249 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
@@ -419,7 +423,7 class VoltageWriter(JRODataWriter, Operation): | |||
|
419 | 423 | |
|
420 | 424 | self.flagIsNewFile = 1 |
|
421 | 425 | |
|
422 |
self. |
|
|
426 | self.blockIndex = 0 | |
|
423 | 427 | |
|
424 | 428 | self.flagIsNewBlock = 0 |
|
425 | 429 | |
@@ -536,71 +540,14 class VoltageWriter(JRODataWriter, Operation): | |||
|
536 | 540 | |
|
537 | 541 | return 1 |
|
538 | 542 | |
|
539 | def __getProcessFlags(self): | |
|
540 | ||
|
541 | processFlags = 0 | |
|
542 | ||
|
543 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
|
544 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
|
545 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
|
546 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
|
547 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
|
548 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
|
549 | ||
|
550 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
|
551 | ||
|
552 | ||
|
553 | ||
|
554 | datatypeValueList = [PROCFLAG.DATATYPE_CHAR, | |
|
555 | PROCFLAG.DATATYPE_SHORT, | |
|
556 | PROCFLAG.DATATYPE_LONG, | |
|
557 | PROCFLAG.DATATYPE_INT64, | |
|
558 | PROCFLAG.DATATYPE_FLOAT, | |
|
559 | PROCFLAG.DATATYPE_DOUBLE] | |
|
560 | ||
|
561 | ||
|
562 | for index in range(len(dtypeList)): | |
|
563 | if self.dataOut.dtype == dtypeList[index]: | |
|
564 | dtypeValue = datatypeValueList[index] | |
|
565 | break | |
|
566 | ||
|
567 | processFlags += dtypeValue | |
|
568 | ||
|
569 | if self.dataOut.flagDecodeData: | |
|
570 | processFlags += PROCFLAG.DECODE_DATA | |
|
571 | ||
|
572 | if self.dataOut.flagDeflipData: | |
|
573 | processFlags += PROCFLAG.DEFLIP_DATA | |
|
574 | ||
|
575 | if self.dataOut.code is not None: | |
|
576 | processFlags += PROCFLAG.DEFINE_PROCESS_CODE | |
|
577 | ||
|
578 | if self.dataOut.nCohInt > 1: | |
|
579 | processFlags += PROCFLAG.COHERENT_INTEGRATION | |
|
580 | ||
|
581 | return processFlags | |
|
582 | ||
|
583 | ||
|
584 | 543 | def __getBlockSize(self): |
|
585 | 544 | ''' |
|
586 | 545 | Este metodos determina el cantidad de bytes para un bloque de datos de tipo Voltage |
|
587 | 546 | ''' |
|
588 | 547 | |
|
589 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
|
590 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
|
591 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
|
592 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
|
593 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
|
594 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
|
595 | ||
|
596 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
|
597 | datatypeValueList = [1,2,4,8,4,8] | |
|
598 | for index in range(len(dtypeList)): | |
|
599 | if self.dataOut.dtype == dtypeList[index]: | |
|
600 | datatypeValue = datatypeValueList[index] | |
|
601 | break | |
|
548 | dtype_width = self.getDtypeWidth() | |
|
602 | 549 | |
|
603 |
blocksize = int(self.dataOut.nHeights * self.dataOut.nChannels * self.profilesPerBlock * d |
|
|
550 | blocksize = int(self.dataOut.nHeights * self.dataOut.nChannels * self.profilesPerBlock * dtype_width * 2) | |
|
604 | 551 | |
|
605 | 552 | return blocksize |
|
606 | 553 | |
@@ -630,7 +577,7 class VoltageWriter(JRODataWriter, Operation): | |||
|
630 | 577 | self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock |
|
631 | 578 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile |
|
632 | 579 | self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows |
|
633 |
self.processingHeaderObj.processFlags = self. |
|
|
580 | self.processingHeaderObj.processFlags = self.getProcessFlags() | |
|
634 | 581 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt |
|
635 | 582 | self.processingHeaderObj.nIncohInt = 1 # Cuando la data de origen es de tipo Voltage |
|
636 | 583 | self.processingHeaderObj.totalSpectra = 0 # Cuando la data de origen es de tipo Voltage |
General Comments 0
You need to be logged in to leave comments.
Login now