@@ -7,6 +7,9 import numpy | |||||
7 | import copy |
|
7 | import copy | |
8 | import datetime |
|
8 | import datetime | |
9 |
|
9 | |||
|
10 | SPEED_OF_LIGHT = 299792458 | |||
|
11 | SPEED_OF_LIGHT = 3e8 | |||
|
12 | ||||
10 | BASIC_STRUCTURE = numpy.dtype([ |
|
13 | BASIC_STRUCTURE = numpy.dtype([ | |
11 | ('nSize','<u4'), |
|
14 | ('nSize','<u4'), | |
12 | ('nVersion','<u2'), |
|
15 | ('nVersion','<u2'), | |
@@ -222,12 +225,12 class RadarControllerHeader(Header): | |||||
222 | rangeTxA = None |
|
225 | rangeTxA = None | |
223 | rangeTxB = None |
|
226 | rangeTxB = None | |
224 |
|
227 | |||
225 |
__ |
|
228 | __size = None | |
226 |
|
229 | |||
227 | def __init__(self, expType=2, nTx=1, |
|
230 | def __init__(self, expType=2, nTx=1, | |
228 | ippKm=None, txA=0, txB=0, |
|
231 | ippKm=None, txA=0, txB=0, | |
229 | nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None, |
|
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 | prePulseBefore=0, prePulseAfter=0, |
|
234 | prePulseBefore=0, prePulseAfter=0, | |
232 | codeType=0, nCode=0, nBaud=0, code=None, |
|
235 | codeType=0, nCode=0, nBaud=0, code=None, | |
233 | flip1=0, flip2=0): |
|
236 | flip1=0, flip2=0): | |
@@ -265,6 +268,8 class RadarControllerHeader(Header): | |||||
265 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 |
|
268 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 | |
266 | # self.dynamic = numpy.array([],numpy.dtype('byte')) |
|
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 | def read(self, fp): |
|
274 | def read(self, fp): | |
270 |
|
275 | |||
@@ -272,7 +277,7 class RadarControllerHeader(Header): | |||||
272 | startFp = fp.tell() |
|
277 | startFp = fp.tell() | |
273 | header = numpy.fromfile(fp,RADAR_STRUCTURE,1) |
|
278 | header = numpy.fromfile(fp,RADAR_STRUCTURE,1) | |
274 |
|
279 | |||
275 |
|
|
280 | size = int(header['nSize'][0]) | |
276 | self.expType = int(header['nExpType'][0]) |
|
281 | self.expType = int(header['nExpType'][0]) | |
277 | self.nTx = int(header['nNTx'][0]) |
|
282 | self.nTx = int(header['nNTx'][0]) | |
278 | self.ipp = float(header['fIpp'][0]) |
|
283 | self.ipp = float(header['fIpp'][0]) | |
@@ -290,7 +295,7 class RadarControllerHeader(Header): | |||||
290 | self.rangeTxA = header['sRangeTxA'][0] |
|
295 | self.rangeTxA = header['sRangeTxA'][0] | |
291 | self.rangeTxB = header['sRangeTxB'][0] |
|
296 | self.rangeTxB = header['sRangeTxB'][0] | |
292 | # jump Dynamic Radar Controller Header |
|
297 | # jump Dynamic Radar Controller Header | |
293 |
# jumpFp = s |
|
298 | # jumpFp = size - 116 | |
294 | # self.dynamic = numpy.fromfile(fp,numpy.dtype('byte'),jumpFp) |
|
299 | # self.dynamic = numpy.fromfile(fp,numpy.dtype('byte'),jumpFp) | |
295 | #pointer backward to dynamic header and read |
|
300 | #pointer backward to dynamic header and read | |
296 | # backFp = fp.tell() - jumpFp |
|
301 | # backFp = fp.tell() - jumpFp | |
@@ -319,13 +324,13 class RadarControllerHeader(Header): | |||||
319 | self.code = 2.0*self.code - 1.0 |
|
324 | self.code = 2.0*self.code - 1.0 | |
320 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 |
|
325 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 | |
321 |
|
326 | |||
322 | if self.line5Function == RCfunction.FLIP: |
|
327 | # if self.line5Function == RCfunction.FLIP: | |
323 | self.flip1 = numpy.fromfile(fp,'<u4',1) |
|
328 | # self.flip1 = numpy.fromfile(fp,'<u4',1) | |
324 |
|
329 | # | ||
325 | if self.line6Function == RCfunction.FLIP: |
|
330 | # if self.line6Function == RCfunction.FLIP: | |
326 | self.flip2 = numpy.fromfile(fp,'<u4',1) |
|
331 | # self.flip2 = numpy.fromfile(fp,'<u4',1) | |
327 |
|
332 | |||
328 |
endFp = |
|
333 | endFp = size + startFp | |
329 | jumpFp = endFp - fp.tell() |
|
334 | jumpFp = endFp - fp.tell() | |
330 | if jumpFp > 0: |
|
335 | if jumpFp > 0: | |
331 | fp.seek(jumpFp) |
|
336 | fp.seek(jumpFp) | |
@@ -337,6 +342,7 class RadarControllerHeader(Header): | |||||
337 | return 1 |
|
342 | return 1 | |
338 |
|
343 | |||
339 | def write(self, fp): |
|
344 | def write(self, fp): | |
|
345 | ||||
340 | headerTuple = (self.size, |
|
346 | headerTuple = (self.size, | |
341 | self.expType, |
|
347 | self.expType, | |
342 | self.nTx, |
|
348 | self.nTx, | |
@@ -358,9 +364,6 class RadarControllerHeader(Header): | |||||
358 | header = numpy.array(headerTuple,RADAR_STRUCTURE) |
|
364 | header = numpy.array(headerTuple,RADAR_STRUCTURE) | |
359 | header.tofile(fp) |
|
365 | header.tofile(fp) | |
360 |
|
366 | |||
361 | #dynamic = self.dynamic |
|
|||
362 | #dynamic.tofile(fp) |
|
|||
363 |
|
||||
364 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) |
|
367 | sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin) | |
365 | samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE) |
|
368 | samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE) | |
366 | samplingWindow.tofile(fp) |
|
369 | samplingWindow.tofile(fp) | |
@@ -390,18 +393,18 class RadarControllerHeader(Header): | |||||
390 | tempx = tempx.astype('u4') |
|
393 | tempx = tempx.astype('u4') | |
391 | tempx.tofile(fp) |
|
394 | tempx.tofile(fp) | |
392 |
|
395 | |||
393 | if self.line5Function == RCfunction.FLIP: |
|
396 | # if self.line5Function == RCfunction.FLIP: | |
394 | self.flip1.tofile(fp) |
|
397 | # self.flip1.tofile(fp) | |
395 |
|
398 | # | ||
396 | if self.line6Function == RCfunction.FLIP: |
|
399 | # if self.line6Function == RCfunction.FLIP: | |
397 | self.flip2.tofile(fp) |
|
400 | # self.flip2.tofile(fp) | |
398 |
|
401 | |||
399 | return 1 |
|
402 | return 1 | |
400 |
|
403 | |||
401 | def get_ippSeconds(self): |
|
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 | return ippSeconds |
|
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 | return |
|
432 | return | |
415 |
|
433 | |||
416 | ippSeconds = property(get_ippSeconds, set_ippSeconds) |
|
434 | ippSeconds = property(get_ippSeconds, set_ippSeconds) | |
|
435 | size = property(get_size, set_size) | |||
417 |
|
436 | |||
418 | class ProcessingHeader(Header): |
|
437 | class ProcessingHeader(Header): | |
419 |
|
438 | |||
@@ -581,6 +600,7 class nCodeType: | |||||
581 | CODE_BINARY28=17 |
|
600 | CODE_BINARY28=17 | |
582 |
|
601 | |||
583 | class PROCFLAG: |
|
602 | class PROCFLAG: | |
|
603 | ||||
584 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
604 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) | |
585 | DECODE_DATA = numpy.uint32(0x00000002) |
|
605 | DECODE_DATA = numpy.uint32(0x00000002) | |
586 | SPECTRA_CALC = numpy.uint32(0x00000004) |
|
606 | SPECTRA_CALC = numpy.uint32(0x00000004) | |
@@ -615,4 +635,45 class PROCFLAG: | |||||
615 | OPERATION_MASK = numpy.uint32(0x0000003F) |
|
635 | OPERATION_MASK = numpy.uint32(0x0000003F) | |
616 | DATATYPE_MASK = numpy.uint32(0x00000FC0) |
|
636 | DATATYPE_MASK = numpy.uint32(0x00000FC0) | |
617 | DATAARRANGE_MASK = numpy.uint32(0x00007000) |
|
637 | DATAARRANGE_MASK = numpy.uint32(0x00007000) | |
618 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) No newline at end of file |
|
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 | from time import sleep |
|
19 | from time import sleep | |
20 |
|
20 | |||
21 | from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader |
|
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 | LOCALTIME = True |
|
24 | LOCALTIME = True | |
24 |
|
25 | |||
@@ -365,6 +366,13 class JRODataIO: | |||||
365 |
|
366 | |||
366 | raise ValueError, "Not implemented" |
|
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 | class JRODataReader(JRODataIO): |
|
376 | class JRODataReader(JRODataIO): | |
369 |
|
377 | |||
370 | nReadBlocks = 0 |
|
378 | nReadBlocks = 0 | |
@@ -872,12 +880,16 class JRODataReader(JRODataIO): | |||||
872 | return 1 |
|
880 | return 1 | |
873 |
|
881 | |||
874 | def readNextBlock(self): |
|
882 | def readNextBlock(self): | |
|
883 | ||||
875 | if not(self.__setNewBlock()): |
|
884 | if not(self.__setNewBlock()): | |
876 | return 0 |
|
885 | return 0 | |
877 |
|
886 | |||
878 | if not(self.readBlock()): |
|
887 | if not(self.readBlock()): | |
879 | return 0 |
|
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 | return 1 |
|
893 | return 1 | |
882 |
|
894 | |||
883 | def __readFirstHeader(self): |
|
895 | def __readFirstHeader(self): | |
@@ -1128,7 +1140,8 class JRODataReader(JRODataIO): | |||||
1128 |
|
1140 | |||
1129 | sys.exit(-1) |
|
1141 | sys.exit(-1) | |
1130 |
|
1142 | |||
1131 |
|
|
1143 | self.getBasicHeader() | |
|
1144 | ||||
1132 | if last_set != None: |
|
1145 | if last_set != None: | |
1133 | self.dataOut.last_block = last_set * self.processingHeaderObj.dataBlocksPerFile + self.basicHeaderObj.dataBlock |
|
1146 | self.dataOut.last_block = last_set * self.processingHeaderObj.dataBlocksPerFile + self.basicHeaderObj.dataBlock | |
1134 | return |
|
1147 | return | |
@@ -1183,7 +1196,10 class JRODataReader(JRODataIO): | |||||
1183 | def printNumberOfBlock(self): |
|
1196 | def printNumberOfBlock(self): | |
1184 |
|
1197 | |||
1185 | if self.flagIsNewBlock: |
|
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 | self.dataOut.blocknow = self.basicHeaderObj.dataBlock |
|
1203 | self.dataOut.blocknow = self.basicHeaderObj.dataBlock | |
1188 |
|
1204 | |||
1189 | def printInfo(self): |
|
1205 | def printInfo(self): | |
@@ -1248,6 +1264,36 class JRODataWriter(JRODataIO): | |||||
1248 | raise ValueError, "No implemented" |
|
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 | def setBasicHeader(self): |
|
1297 | def setBasicHeader(self): | |
1252 |
|
1298 | |||
1253 | self.basicHeaderObj.size = self.basicHeaderSize #bytes |
|
1299 | self.basicHeaderObj.size = self.basicHeaderSize #bytes | |
@@ -1301,7 +1347,7 class JRODataWriter(JRODataIO): | |||||
1301 | self.radarControllerHeaderObj.write(self.fp) |
|
1347 | self.radarControllerHeaderObj.write(self.fp) | |
1302 | self.processingHeaderObj.write(self.fp) |
|
1348 | self.processingHeaderObj.write(self.fp) | |
1303 |
|
1349 | |||
1304 | self.dtype = self.dataOut.dtype |
|
1350 | ||
1305 |
|
1351 | |||
1306 | def __setNewBlock(self): |
|
1352 | def __setNewBlock(self): | |
1307 | """ |
|
1353 | """ | |
@@ -1339,7 +1385,9 class JRODataWriter(JRODataIO): | |||||
1339 | return 0 |
|
1385 | return 0 | |
1340 |
|
1386 | |||
1341 | self.writeBlock() |
|
1387 | self.writeBlock() | |
1342 |
|
1388 | |||
|
1389 | print "[Writing] Block No. %d/%d" %(self.blockIndex, self.processingHeaderObj.dataBlocksPerFile) | |||
|
1390 | ||||
1343 | return 1 |
|
1391 | return 1 | |
1344 |
|
1392 | |||
1345 | def setNextFile(self): |
|
1393 | def setNextFile(self): | |
@@ -1409,20 +1457,27 class JRODataWriter(JRODataIO): | |||||
1409 |
|
1457 | |||
1410 | self.setFirstHeader() |
|
1458 | self.setFirstHeader() | |
1411 |
|
1459 | |||
1412 | print '[Writing] file: %s'%self.filename |
|
1460 | print '[Writing] Opening file: %s'%self.filename | |
1413 |
|
1461 | |||
1414 | self.__writeFirstHeader() |
|
1462 | self.__writeFirstHeader() | |
1415 |
|
1463 | |||
1416 | return 1 |
|
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 | Setea el tipo de formato en la cual sera guardada la data y escribe el First Header |
|
1468 | Setea el tipo de formato en la cual sera guardada la data y escribe el First Header | |
1421 |
|
1469 | |||
1422 | Inputs: |
|
1470 | Inputs: | |
1423 | path : el path destino en el cual se escribiran los files a crear |
|
1471 | path : directory where data will be saved | |
1424 | format : formato en el cual sera salvado un file |
|
1472 | profilesPerBlock : number of profiles per block | |
1425 |
set |
|
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 | Return: |
|
1482 | Return: | |
1428 | 0 : Si no realizo un buen seteo |
|
1483 | 0 : Si no realizo un buen seteo | |
@@ -1446,6 +1501,12 class JRODataWriter(JRODataIO): | |||||
1446 |
|
1501 | |||
1447 | self.dataOut = dataOut |
|
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 | if not(self.setNextFile()): |
|
1510 | if not(self.setNextFile()): | |
1450 | print "[Writing] There isn't a next file" |
|
1511 | print "[Writing] There isn't a next file" | |
1451 | return 0 |
|
1512 | return 0 |
@@ -273,7 +273,8 class SpectraReader(JRODataReader, ProcessingUnit): | |||||
273 | cspc = numpy.roll( cspc, shift, axis=2 ) |
|
273 | cspc = numpy.roll( cspc, shift, axis=2 ) | |
274 |
|
274 | |||
275 | # self.processingHeaderObj.shif_fft = True |
|
275 | # self.processingHeaderObj.shif_fft = True | |
276 |
|
276 | |||
|
277 | #Dimensions : nChannels, nProfiles, nSamples | |||
277 | spc = numpy.transpose( spc, (0,2,1) ) |
|
278 | spc = numpy.transpose( spc, (0,2,1) ) | |
278 | self.data_spc = spc |
|
279 | self.data_spc = spc | |
279 |
|
280 | |||
@@ -298,6 +299,8 class SpectraReader(JRODataReader, ProcessingUnit): | |||||
298 |
|
299 | |||
299 | def getFirstHeader(self): |
|
300 | def getFirstHeader(self): | |
300 |
|
301 | |||
|
302 | self.getBasicHeader() | |||
|
303 | ||||
301 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() |
|
304 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() | |
302 |
|
305 | |||
303 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
|
306 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() | |
@@ -599,89 +602,27 class SpectraWriter(JRODataWriter, Operation): | |||||
599 |
|
602 | |||
600 | return 1 |
|
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 | def __getBlockSize(self): |
|
605 | def __getBlockSize(self): | |
652 | ''' |
|
606 | ''' | |
653 | Este metodos determina el cantidad de bytes para un bloque de datos de tipo Spectra |
|
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')]) |
|
610 | dtype_width = self.getDtypeWidth() | |
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 |
|
||||
670 |
|
611 | |||
671 | pts2write = self.dataOut.nHeights * self.dataOut.nFFTPoints |
|
612 | pts2write = self.dataOut.nHeights * self.dataOut.nFFTPoints | |
672 |
|
613 | |||
673 | pts2write_SelfSpectra = int(self.dataOut.nChannels * pts2write) |
|
614 | pts2write_SelfSpectra = int(self.dataOut.nChannels * pts2write) | |
674 |
blocksize = (pts2write_SelfSpectra*d |
|
615 | blocksize = (pts2write_SelfSpectra*dtype_width) | |
675 |
|
616 | |||
676 | if self.dataOut.data_cspc is not None: |
|
617 | if self.dataOut.data_cspc is not None: | |
677 | pts2write_CrossSpectra = int(self.dataOut.nPairs * pts2write) |
|
618 | pts2write_CrossSpectra = int(self.dataOut.nPairs * pts2write) | |
678 |
blocksize += (pts2write_CrossSpectra*d |
|
619 | blocksize += (pts2write_CrossSpectra*dtype_width*2) | |
679 |
|
620 | |||
680 | if self.dataOut.data_dc is not None: |
|
621 | if self.dataOut.data_dc is not None: | |
681 | pts2write_DCchannels = int(self.dataOut.nChannels * self.dataOut.nHeights) |
|
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 | return blocksize |
|
627 | return blocksize | |
687 |
|
628 | |||
@@ -714,7 +655,7 class SpectraWriter(JRODataWriter, Operation): | |||||
714 | self.processingHeaderObj.profilesPerBlock = self.dataOut.nFFTPoints |
|
655 | self.processingHeaderObj.profilesPerBlock = self.dataOut.nFFTPoints | |
715 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile |
|
656 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile | |
716 | self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows |
|
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 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt# Se requiere para determinar el valor de timeInterval |
|
659 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt# Se requiere para determinar el valor de timeInterval | |
719 | self.processingHeaderObj.nIncohInt = self.dataOut.nIncohInt |
|
660 | self.processingHeaderObj.nIncohInt = self.dataOut.nIncohInt | |
720 | self.processingHeaderObj.totalSpectra = self.dataOut.nPairs + self.dataOut.nChannels |
|
661 | self.processingHeaderObj.totalSpectra = self.dataOut.nPairs + self.dataOut.nChannels |
@@ -224,6 +224,8 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
224 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) |
|
224 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) | |
225 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) |
|
225 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) | |
226 | # return 0 |
|
226 | # return 0 | |
|
227 | ||||
|
228 | #Dimensions : nChannels, nProfiles, nSamples | |||
227 |
|
229 | |||
228 | junk = numpy.transpose(junk, (2,0,1)) |
|
230 | junk = numpy.transpose(junk, (2,0,1)) | |
229 | self.datablock = junk['real'] + junk['imag']*1j |
|
231 | self.datablock = junk['real'] + junk['imag']*1j | |
@@ -240,6 +242,8 class VoltageReader(JRODataReader, ProcessingUnit): | |||||
240 |
|
242 | |||
241 | def getFirstHeader(self): |
|
243 | def getFirstHeader(self): | |
242 |
|
244 | |||
|
245 | self.getBasicHeader() | |||
|
246 | ||||
243 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() |
|
247 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() | |
244 |
|
248 | |||
245 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
|
249 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() | |
@@ -419,7 +423,7 class VoltageWriter(JRODataWriter, Operation): | |||||
419 |
|
423 | |||
420 | self.flagIsNewFile = 1 |
|
424 | self.flagIsNewFile = 1 | |
421 |
|
425 | |||
422 |
self. |
|
426 | self.blockIndex = 0 | |
423 |
|
427 | |||
424 | self.flagIsNewBlock = 0 |
|
428 | self.flagIsNewBlock = 0 | |
425 |
|
429 | |||
@@ -536,71 +540,14 class VoltageWriter(JRODataWriter, Operation): | |||||
536 |
|
540 | |||
537 | return 1 |
|
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 | def __getBlockSize(self): |
|
543 | def __getBlockSize(self): | |
585 | ''' |
|
544 | ''' | |
586 | Este metodos determina el cantidad de bytes para un bloque de datos de tipo Voltage |
|
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')]) |
|
548 | dtype_width = self.getDtypeWidth() | |
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 |
|
|||
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 | return blocksize |
|
552 | return blocksize | |
606 |
|
553 | |||
@@ -630,7 +577,7 class VoltageWriter(JRODataWriter, Operation): | |||||
630 | self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock |
|
577 | self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock | |
631 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile |
|
578 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile | |
632 | self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows |
|
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 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt |
|
581 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt | |
635 | self.processingHeaderObj.nIncohInt = 1 # Cuando la data de origen es de tipo Voltage |
|
582 | self.processingHeaderObj.nIncohInt = 1 # Cuando la data de origen es de tipo Voltage | |
636 | self.processingHeaderObj.totalSpectra = 0 # Cuando la data de origen es de tipo Voltage |
|
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