##// END OF EJS Templates
Se comenta el retorno para evitar la interrupción del programa debido al uso del...
Alexander Valdez -
r725:55bd4dcd7f84
parent child
Show More
@@ -1,734 +1,735
1 1 '''
2 2
3 3 $Author: murco $
4 4 $Id: JROHeaderIO.py 151 2012-10-31 19:00:51Z murco $
5 5 '''
6 6 import numpy
7 7 import copy
8 8 import datetime
9 9
10 10 SPEED_OF_LIGHT = 299792458
11 11 SPEED_OF_LIGHT = 3e8
12 12
13 13 BASIC_STRUCTURE = numpy.dtype([
14 14 ('nSize','<u4'),
15 15 ('nVersion','<u2'),
16 16 ('nDataBlockId','<u4'),
17 17 ('nUtime','<u4'),
18 18 ('nMilsec','<u2'),
19 19 ('nTimezone','<i2'),
20 20 ('nDstflag','<i2'),
21 21 ('nErrorCount','<u4')
22 22 ])
23 23
24 24 SYSTEM_STRUCTURE = numpy.dtype([
25 25 ('nSize','<u4'),
26 26 ('nNumSamples','<u4'),
27 27 ('nNumProfiles','<u4'),
28 28 ('nNumChannels','<u4'),
29 29 ('nADCResolution','<u4'),
30 30 ('nPCDIOBusWidth','<u4'),
31 31 ])
32 32
33 33 RADAR_STRUCTURE = numpy.dtype([
34 34 ('nSize','<u4'),
35 35 ('nExpType','<u4'),
36 36 ('nNTx','<u4'),
37 37 ('fIpp','<f4'),
38 38 ('fTxA','<f4'),
39 39 ('fTxB','<f4'),
40 40 ('nNumWindows','<u4'),
41 41 ('nNumTaus','<u4'),
42 42 ('nCodeType','<u4'),
43 43 ('nLine6Function','<u4'),
44 44 ('nLine5Function','<u4'),
45 45 ('fClock','<f4'),
46 46 ('nPrePulseBefore','<u4'),
47 47 ('nPrePulseAfter','<u4'),
48 48 ('sRangeIPP','<a20'),
49 49 ('sRangeTxA','<a20'),
50 50 ('sRangeTxB','<a20'),
51 51 ])
52 52
53 53 SAMPLING_STRUCTURE = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')])
54 54
55 55
56 56 PROCESSING_STRUCTURE = numpy.dtype([
57 57 ('nSize','<u4'),
58 58 ('nDataType','<u4'),
59 59 ('nSizeOfDataBlock','<u4'),
60 60 ('nProfilesperBlock','<u4'),
61 61 ('nDataBlocksperFile','<u4'),
62 62 ('nNumWindows','<u4'),
63 63 ('nProcessFlags','<u4'),
64 64 ('nCoherentIntegrations','<u4'),
65 65 ('nIncoherentIntegrations','<u4'),
66 66 ('nTotalSpectra','<u4')
67 67 ])
68 68
69 69 class Header(object):
70 70
71 71 def __init__(self):
72 72 raise NotImplementedError
73 73
74 74 def copy(self):
75 75 return copy.deepcopy(self)
76 76
77 77 def read(self):
78 78
79 79 raise NotImplementedError
80 80
81 81 def write(self):
82 82
83 83 raise NotImplementedError
84 84
85 85 def printInfo(self):
86 86
87 87 message = "#"*50 + "\n"
88 88 message += self.__class__.__name__.upper() + "\n"
89 89 message += "#"*50 + "\n"
90 90
91 91 for key in self.__dict__.keys():
92 92 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
93 93
94 94 print message
95 95
96 96 class BasicHeader(Header):
97 97
98 98 size = None
99 99 version = None
100 100 dataBlock = None
101 101 utc = None
102 102 ltc = None
103 103 miliSecond = None
104 104 timeZone = None
105 105 dstFlag = None
106 106 errorCount = None
107 107 datatime = None
108 108
109 109 __LOCALTIME = None
110 110
111 111 def __init__(self, useLocalTime=True):
112 112
113 113 self.size = 24
114 114 self.version = 0
115 115 self.dataBlock = 0
116 116 self.utc = 0
117 117 self.miliSecond = 0
118 118 self.timeZone = 0
119 119 self.dstFlag = 0
120 120 self.errorCount = 0
121 121
122 122 self.useLocalTime = useLocalTime
123 123
124 124 def read(self, fp):
125 125
126 126 try:
127 127 header = numpy.fromfile(fp, BASIC_STRUCTURE,1)
128 128
129 129 except Exception, e:
130 130 print "BasicHeader: "
131 131 print e
132 132 return 0
133 133
134 134 self.size = int(header['nSize'][0])
135 135 self.version = int(header['nVersion'][0])
136 136 self.dataBlock = int(header['nDataBlockId'][0])
137 137 self.utc = int(header['nUtime'][0])
138 138 self.miliSecond = int(header['nMilsec'][0])
139 139 self.timeZone = int(header['nTimezone'][0])
140 140 self.dstFlag = int(header['nDstflag'][0])
141 141 self.errorCount = int(header['nErrorCount'][0])
142 142
143 143 return 1
144 144
145 145 def write(self, fp):
146 146
147 147 headerTuple = (self.size,self.version,self.dataBlock,self.utc,self.miliSecond,self.timeZone,self.dstFlag,self.errorCount)
148 148 header = numpy.array(headerTuple, BASIC_STRUCTURE)
149 149 header.tofile(fp)
150 150
151 151 return 1
152 152
153 153 def get_ltc(self):
154 154
155 155 return self.utc - self.timeZone*60
156 156
157 157 def set_ltc(self, value):
158 158
159 159 self.utc = value + self.timeZone*60
160 160
161 161 def get_datatime(self):
162 162
163 163 return datetime.datetime.utcfromtimestamp(self.ltc)
164 164
165 165 ltc = property(get_ltc, set_ltc)
166 166 datatime = property(get_datatime)
167 167
168 168 class SystemHeader(Header):
169 169
170 170 size = None
171 171 nSamples = None
172 172 nProfiles = None
173 173 nChannels = None
174 174 adcResolution = None
175 175 pciDioBusWidth = None
176 176
177 177 def __init__(self, nSamples=0, nProfiles=0, nChannels=0, adcResolution=14, pciDioBusWith=0):
178 178
179 179 self.size = 24
180 180 self.nSamples = nSamples
181 181 self.nProfiles = nProfiles
182 182 self.nChannels = nChannels
183 183 self.adcResolution = adcResolution
184 184 self.pciDioBusWidth = pciDioBusWith
185 185
186 186 def read(self, fp):
187 187
188 188 startFp = fp.tell()
189 189
190 190 try:
191 191 header = numpy.fromfile(fp,SYSTEM_STRUCTURE,1)
192 192 except Exception, e:
193 193 print "SystemHeader: " + e
194 194 return 0
195 195
196 196 self.size = header['nSize'][0]
197 197 self.nSamples = header['nNumSamples'][0]
198 198 self.nProfiles = header['nNumProfiles'][0]
199 199 self.nChannels = header['nNumChannels'][0]
200 200 self.adcResolution = header['nADCResolution'][0]
201 201 self.pciDioBusWidth = header['nPCDIOBusWidth'][0]
202 202
203 203 endFp = self.size + startFp
204 204
205 205 if fp.tell() != endFp:
206 206 print "System Header is not consistent"
207 207 return 0
208 208
209 209 return 1
210 210
211 211 def write(self, fp):
212 212
213 213 headerTuple = (self.size,self.nSamples,self.nProfiles,self.nChannels,self.adcResolution,self.pciDioBusWidth)
214 214 header = numpy.array(headerTuple,SYSTEM_STRUCTURE)
215 215 header.tofile(fp)
216 216
217 217 return 1
218 218
219 219 class RadarControllerHeader(Header):
220 220
221 221 size = None
222 222 expType = None
223 223 nTx = None
224 224 ipp = None
225 225 txA = None
226 226 txB = None
227 227 nWindows = None
228 228 numTaus = None
229 229 codeType = None
230 230 line6Function = None
231 231 line5Function = None
232 232 fClock = None
233 233 prePulseBefore = None
234 234 prePulserAfter = None
235 235 rangeIpp = None
236 236 rangeTxA = None
237 237 rangeTxB = None
238 238
239 239 __size = None
240 240
241 241 def __init__(self, expType=2, nTx=1,
242 242 ippKm=None, txA=0, txB=0,
243 243 nWindows=None, nHeights=None, firstHeight=None, deltaHeight=None,
244 244 numTaus=0, line6Function=0, line5Function=0, fClock=None,
245 245 prePulseBefore=0, prePulseAfter=0,
246 246 codeType=0, nCode=0, nBaud=0, code=None,
247 247 flip1=0, flip2=0):
248 248
249 249 self.size = 116
250 250 self.expType = expType
251 251 self.nTx = nTx
252 252 self.ipp = ippKm
253 253 self.txA = txA
254 254 self.txB = txB
255 255 self.rangeIpp = ippKm
256 256 self.rangeTxA = txA
257 257 self.rangeTxB = txB
258 258
259 259 self.nWindows = nWindows
260 260 self.numTaus = numTaus
261 261 self.codeType = codeType
262 262 self.line6Function = line6Function
263 263 self.line5Function = line5Function
264 264 self.fClock = fClock
265 265 self.prePulseBefore = prePulseBefore
266 266 self.prePulserAfter = prePulseAfter
267 267
268 268 self.nHeights = nHeights
269 269 self.firstHeight = firstHeight
270 270 self.deltaHeight = deltaHeight
271 271 self.samplesWin = nHeights
272 272
273 273 self.nCode = nCode
274 274 self.nBaud = nBaud
275 275 self.code = code
276 276 self.flip1 = flip1
277 277 self.flip2 = flip2
278 278
279 279 self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4
280 280 # self.dynamic = numpy.array([],numpy.dtype('byte'))
281 281
282 282 if self.fClock is None and self.deltaHeight is not None:
283 283 self.fClock = 0.15/(deltaHeight*1e-6) #0.15Km / (height * 1u)
284 284
285 285 def read(self, fp):
286 286
287 287
288 288 startFp = fp.tell()
289 289 try:
290 290 header = numpy.fromfile(fp,RADAR_STRUCTURE,1)
291 291 except Exception, e:
292 292 print "RadarControllerHeader: " + e
293 293 return 0
294 294
295 295 size = int(header['nSize'][0])
296 296 self.expType = int(header['nExpType'][0])
297 297 self.nTx = int(header['nNTx'][0])
298 298 self.ipp = float(header['fIpp'][0])
299 299 self.txA = float(header['fTxA'][0])
300 300 self.txB = float(header['fTxB'][0])
301 301 self.nWindows = int(header['nNumWindows'][0])
302 302 self.numTaus = int(header['nNumTaus'][0])
303 303 self.codeType = int(header['nCodeType'][0])
304 304 self.line6Function = int(header['nLine6Function'][0])
305 305 self.line5Function = int(header['nLine5Function'][0])
306 306 self.fClock = float(header['fClock'][0])
307 307 self.prePulseBefore = int(header['nPrePulseBefore'][0])
308 308 self.prePulserAfter = int(header['nPrePulseAfter'][0])
309 309 self.rangeIpp = header['sRangeIPP'][0]
310 310 self.rangeTxA = header['sRangeTxA'][0]
311 311 self.rangeTxB = header['sRangeTxB'][0]
312 312
313 313 samplingWindow = numpy.fromfile(fp,SAMPLING_STRUCTURE,self.nWindows)
314 314
315 315 self.nHeights = int(numpy.sum(samplingWindow['nsa']))
316 316 self.firstHeight = samplingWindow['h0']
317 317 self.deltaHeight = samplingWindow['dh']
318 318 self.samplesWin = samplingWindow['nsa']
319 319
320 320 self.Taus = numpy.fromfile(fp,'<f4',self.numTaus)
321 321
322 322 self.code_size = 0
323 323 if self.codeType != 0:
324 324 self.nCode = int(numpy.fromfile(fp,'<u4',1))
325 325 self.nBaud = int(numpy.fromfile(fp,'<u4',1))
326 326
327 327 code = numpy.empty([self.nCode,self.nBaud],dtype='i1')
328 328 for ic in range(self.nCode):
329 329 temp = numpy.fromfile(fp,'u4',int(numpy.ceil(self.nBaud/32.)))
330 330 for ib in range(self.nBaud-1,-1,-1):
331 331 code[ic,ib] = temp[ib/32]%2
332 332 temp[ib/32] = temp[ib/32]/2
333 333
334 334 self.code = 2.0*code - 1.0
335 335 self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4
336 336
337 337 # if self.line5Function == RCfunction.FLIP:
338 338 # self.flip1 = numpy.fromfile(fp,'<u4',1)
339 339 #
340 340 # if self.line6Function == RCfunction.FLIP:
341 341 # self.flip2 = numpy.fromfile(fp,'<u4',1)
342 342
343 343 endFp = size + startFp
344 344
345 345 if fp.tell() != endFp:
346 print "Radar Controller Header is not consistent"
347 return 0
346 # fp.seek(endFp)
347 print "Radar Controller Header is not consistent read[%d] != header[%d]" %(fp.tell()-startFp,endFp)
348 # return 0
348 349
349 350 return 1
350 351
351 352 def write(self, fp):
352 353
353 354 headerTuple = (self.size,
354 355 self.expType,
355 356 self.nTx,
356 357 self.ipp,
357 358 self.txA,
358 359 self.txB,
359 360 self.nWindows,
360 361 self.numTaus,
361 362 self.codeType,
362 363 self.line6Function,
363 364 self.line5Function,
364 365 self.fClock,
365 366 self.prePulseBefore,
366 367 self.prePulserAfter,
367 368 self.rangeIpp,
368 369 self.rangeTxA,
369 370 self.rangeTxB)
370 371
371 372 header = numpy.array(headerTuple,RADAR_STRUCTURE)
372 373 header.tofile(fp)
373 374
374 375 sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin)
375 376 samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE)
376 377 samplingWindow.tofile(fp)
377 378
378 379 if self.numTaus > 0:
379 380 self.Taus.tofile(fp)
380 381
381 382 if self.codeType !=0:
382 383 nCode = numpy.array(self.nCode, '<u4')
383 384 nCode.tofile(fp)
384 385 nBaud = numpy.array(self.nBaud, '<u4')
385 386 nBaud.tofile(fp)
386 387 code1 = (self.code + 1.0)/2.
387 388
388 389 for ic in range(self.nCode):
389 390 tempx = numpy.zeros(numpy.ceil(self.nBaud/32.))
390 391 start = 0
391 392 end = 32
392 393 for i in range(len(tempx)):
393 394 code_selected = code1[ic,start:end]
394 395 for j in range(len(code_selected)-1,-1,-1):
395 396 if code_selected[j] == 1:
396 397 tempx[i] = tempx[i] + 2**(len(code_selected)-1-j)
397 398 start = start + 32
398 399 end = end + 32
399 400
400 401 tempx = tempx.astype('u4')
401 402 tempx.tofile(fp)
402 403
403 404 # if self.line5Function == RCfunction.FLIP:
404 405 # self.flip1.tofile(fp)
405 406 #
406 407 # if self.line6Function == RCfunction.FLIP:
407 408 # self.flip2.tofile(fp)
408 409
409 410 return 1
410 411
411 412 def get_ippSeconds(self):
412 413 '''
413 414 '''
414 415 ippSeconds = 2.0 * 1000 * self.ipp / SPEED_OF_LIGHT
415 416
416 417 return ippSeconds
417 418
418 419 def set_ippSeconds(self, ippSeconds):
419 420 '''
420 421 '''
421 422
422 423 self.ipp = ippSeconds * SPEED_OF_LIGHT / (2.0*1000)
423 424
424 425 return
425 426
426 427 def get_size(self):
427 428
428 429 self.__size = 116 + 12*self.nWindows + 4*self.numTaus
429 430
430 431 if self.codeType != 0:
431 432 self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.)
432 433
433 434 return self.__size
434 435
435 436 def set_size(self, value):
436 437
437 438 self.__size = value
438 439
439 440 return
440 441
441 442 ippSeconds = property(get_ippSeconds, set_ippSeconds)
442 443 size = property(get_size, set_size)
443 444
444 445 class ProcessingHeader(Header):
445 446
446 447 # size = None
447 448 dtype = None
448 449 blockSize = None
449 450 profilesPerBlock = None
450 451 dataBlocksPerFile = None
451 452 nWindows = None
452 453 processFlags = None
453 454 nCohInt = None
454 455 nIncohInt = None
455 456 totalSpectra = None
456 457
457 458 flag_dc = None
458 459 flag_cspc = None
459 460
460 461 def __init__(self):
461 462
462 463 # self.size = 0
463 464 self.dtype = 0
464 465 self.blockSize = 0
465 466 self.profilesPerBlock = 0
466 467 self.dataBlocksPerFile = 0
467 468 self.nWindows = 0
468 469 self.processFlags = 0
469 470 self.nCohInt = 0
470 471 self.nIncohInt = 0
471 472 self.totalSpectra = 0
472 473
473 474 self.nHeights = 0
474 475 self.firstHeight = 0
475 476 self.deltaHeight = 0
476 477 self.samplesWin = 0
477 478 self.spectraComb = 0
478 479 self.nCode = None
479 480 self.code = None
480 481 self.nBaud = None
481 482
482 483 self.shif_fft = False
483 484 self.flag_dc = False
484 485 self.flag_cspc = False
485 486 self.flag_decode = False
486 487 self.flag_deflip = False
487 488
488 489 def read(self, fp):
489 490
490 491 startFp = fp.tell()
491 492
492 493 try:
493 494 header = numpy.fromfile(fp,PROCESSING_STRUCTURE,1)
494 495 except Exception, e:
495 496 print "ProcessingHeader: " + e
496 497 return 0
497 498
498 499 size = int(header['nSize'][0])
499 500 self.dtype = int(header['nDataType'][0])
500 501 self.blockSize = int(header['nSizeOfDataBlock'][0])
501 502 self.profilesPerBlock = int(header['nProfilesperBlock'][0])
502 503 self.dataBlocksPerFile = int(header['nDataBlocksperFile'][0])
503 504 self.nWindows = int(header['nNumWindows'][0])
504 505 self.processFlags = header['nProcessFlags']
505 506 self.nCohInt = int(header['nCoherentIntegrations'][0])
506 507 self.nIncohInt = int(header['nIncoherentIntegrations'][0])
507 508 self.totalSpectra = int(header['nTotalSpectra'][0])
508 509
509 510 samplingWindow = numpy.fromfile(fp,SAMPLING_STRUCTURE,self.nWindows)
510 511
511 512 self.nHeights = int(numpy.sum(samplingWindow['nsa']))
512 513 self.firstHeight = float(samplingWindow['h0'][0])
513 514 self.deltaHeight = float(samplingWindow['dh'][0])
514 515 self.samplesWin = samplingWindow['nsa'][0]
515 516
516 517 self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra)
517 518
518 519 if ((self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE) == PROCFLAG.DEFINE_PROCESS_CODE):
519 520 self.nCode = int(numpy.fromfile(fp,'<u4',1))
520 521 self.nBaud = int(numpy.fromfile(fp,'<u4',1))
521 522 self.code = numpy.fromfile(fp,'<f4',self.nCode*self.nBaud).reshape(self.nCode,self.nBaud)
522 523
523 524 if ((self.processFlags & PROCFLAG.EXP_NAME_ESP) == PROCFLAG.EXP_NAME_ESP):
524 525 exp_name_len = int(numpy.fromfile(fp,'<u4',1))
525 526 exp_name = numpy.fromfile(fp,'u1',exp_name_len+1)
526 527
527 528 if ((self.processFlags & PROCFLAG.SHIFT_FFT_DATA) == PROCFLAG.SHIFT_FFT_DATA):
528 529 self.shif_fft = True
529 530 else:
530 531 self.shif_fft = False
531 532
532 533 if ((self.processFlags & PROCFLAG.SAVE_CHANNELS_DC) == PROCFLAG.SAVE_CHANNELS_DC):
533 534 self.flag_dc = True
534 535 else:
535 536 self.flag_dc = False
536 537
537 538 if ((self.processFlags & PROCFLAG.DECODE_DATA) == PROCFLAG.DECODE_DATA):
538 539 self.flag_decode = True
539 540 else:
540 541 self.flag_decode = False
541 542
542 543 if ((self.processFlags & PROCFLAG.DEFLIP_DATA) == PROCFLAG.DEFLIP_DATA):
543 544 self.flag_deflip = True
544 545 else:
545 546 self.flag_deflip = False
546 547
547 548 nChannels = 0
548 549 nPairs = 0
549 550 pairList = []
550 551
551 552 for i in range( 0, self.totalSpectra*2, 2 ):
552 553 if self.spectraComb[i] == self.spectraComb[i+1]:
553 554 nChannels = nChannels + 1 #par de canales iguales
554 555 else:
555 556 nPairs = nPairs + 1 #par de canales diferentes
556 557 pairList.append( (self.spectraComb[i], self.spectraComb[i+1]) )
557 558
558 559 self.flag_cspc = False
559 560 if nPairs > 0:
560 561 self.flag_cspc = True
561 562
562 563 endFp = size + startFp
563 564
564 565 if fp.tell() != endFp:
565 566 print "Processing Header is not consistent"
566 567 return 0
567 568
568 569 return 1
569 570
570 571 def write(self, fp):
571 572 #Clear DEFINE_PROCESS_CODE
572 573 self.processFlags = self.processFlags & (~PROCFLAG.DEFINE_PROCESS_CODE)
573 574
574 575 headerTuple = (self.size,
575 576 self.dtype,
576 577 self.blockSize,
577 578 self.profilesPerBlock,
578 579 self.dataBlocksPerFile,
579 580 self.nWindows,
580 581 self.processFlags,
581 582 self.nCohInt,
582 583 self.nIncohInt,
583 584 self.totalSpectra)
584 585
585 586 header = numpy.array(headerTuple,PROCESSING_STRUCTURE)
586 587 header.tofile(fp)
587 588
588 589 if self.nWindows != 0:
589 590 sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin)
590 591 samplingWindow = numpy.array(sampleWindowTuple,SAMPLING_STRUCTURE)
591 592 samplingWindow.tofile(fp)
592 593
593 594 if self.totalSpectra != 0:
594 595 # spectraComb = numpy.array([],numpy.dtype('u1'))
595 596 spectraComb = self.spectraComb
596 597 spectraComb.tofile(fp)
597 598
598 599 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
599 600 nCode = numpy.array([self.nCode], numpy.dtype('u4')) #Probar con un dato que almacene codigo, hasta el momento no se hizo la prueba
600 601 nCode.tofile(fp)
601 602
602 603 nBaud = numpy.array([self.nBaud], numpy.dtype('u4'))
603 604 nBaud.tofile(fp)
604 605
605 606 code = self.code.reshape(self.nCode*self.nBaud)
606 607 code = code.astype(numpy.dtype('<f4'))
607 608 code.tofile(fp)
608 609
609 610 return 1
610 611
611 612 def get_size(self):
612 613
613 614 self.__size = 40 + 12*self.nWindows + 2*self.totalSpectra
614 615
615 616 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
616 617 # self.__size += 4 + 4 + 4*self.nCode*numpy.ceil(self.nBaud/32.)
617 618 self.__size += 4 + 4 + 4 * self.nCode * self.nBaud
618 619
619 620 return self.__size
620 621
621 622 def set_size(self, value):
622 623
623 624 self.__size = value
624 625
625 626 return
626 627
627 628 size = property(get_size, set_size)
628 629
629 630 class RCfunction:
630 631 NONE=0
631 632 FLIP=1
632 633 CODE=2
633 634 SAMPLING=3
634 635 LIN6DIV256=4
635 636 SYNCHRO=5
636 637
637 638 class nCodeType:
638 639 NONE=0
639 640 USERDEFINE=1
640 641 BARKER2=2
641 642 BARKER3=3
642 643 BARKER4=4
643 644 BARKER5=5
644 645 BARKER7=6
645 646 BARKER11=7
646 647 BARKER13=8
647 648 AC128=9
648 649 COMPLEMENTARYCODE2=10
649 650 COMPLEMENTARYCODE4=11
650 651 COMPLEMENTARYCODE8=12
651 652 COMPLEMENTARYCODE16=13
652 653 COMPLEMENTARYCODE32=14
653 654 COMPLEMENTARYCODE64=15
654 655 COMPLEMENTARYCODE128=16
655 656 CODE_BINARY28=17
656 657
657 658 class PROCFLAG:
658 659
659 660 COHERENT_INTEGRATION = numpy.uint32(0x00000001)
660 661 DECODE_DATA = numpy.uint32(0x00000002)
661 662 SPECTRA_CALC = numpy.uint32(0x00000004)
662 663 INCOHERENT_INTEGRATION = numpy.uint32(0x00000008)
663 664 POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010)
664 665 SHIFT_FFT_DATA = numpy.uint32(0x00000020)
665 666
666 667 DATATYPE_CHAR = numpy.uint32(0x00000040)
667 668 DATATYPE_SHORT = numpy.uint32(0x00000080)
668 669 DATATYPE_LONG = numpy.uint32(0x00000100)
669 670 DATATYPE_INT64 = numpy.uint32(0x00000200)
670 671 DATATYPE_FLOAT = numpy.uint32(0x00000400)
671 672 DATATYPE_DOUBLE = numpy.uint32(0x00000800)
672 673
673 674 DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000)
674 675 DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000)
675 676 DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000)
676 677
677 678 SAVE_CHANNELS_DC = numpy.uint32(0x00008000)
678 679 DEFLIP_DATA = numpy.uint32(0x00010000)
679 680 DEFINE_PROCESS_CODE = numpy.uint32(0x00020000)
680 681
681 682 ACQ_SYS_NATALIA = numpy.uint32(0x00040000)
682 683 ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000)
683 684 ACQ_SYS_ADRXD = numpy.uint32(0x000C0000)
684 685 ACQ_SYS_JULIA = numpy.uint32(0x00100000)
685 686 ACQ_SYS_XXXXXX = numpy.uint32(0x00140000)
686 687
687 688 EXP_NAME_ESP = numpy.uint32(0x00200000)
688 689 CHANNEL_NAMES_ESP = numpy.uint32(0x00400000)
689 690
690 691 OPERATION_MASK = numpy.uint32(0x0000003F)
691 692 DATATYPE_MASK = numpy.uint32(0x00000FC0)
692 693 DATAARRANGE_MASK = numpy.uint32(0x00007000)
693 694 ACQ_SYS_MASK = numpy.uint32(0x001C0000)
694 695
695 696 dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')])
696 697 dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')])
697 698 dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')])
698 699 dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')])
699 700 dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')])
700 701 dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')])
701 702
702 703 NUMPY_DTYPE_LIST = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5]
703 704
704 705 PROCFLAG_DTYPE_LIST = [PROCFLAG.DATATYPE_CHAR,
705 706 PROCFLAG.DATATYPE_SHORT,
706 707 PROCFLAG.DATATYPE_LONG,
707 708 PROCFLAG.DATATYPE_INT64,
708 709 PROCFLAG.DATATYPE_FLOAT,
709 710 PROCFLAG.DATATYPE_DOUBLE]
710 711
711 712 DTYPE_WIDTH = [1, 2, 4, 8, 4, 8]
712 713
713 714 def get_dtype_index(numpy_dtype):
714 715
715 716 index = None
716 717
717 718 for i in range(len(NUMPY_DTYPE_LIST)):
718 719 if numpy_dtype == NUMPY_DTYPE_LIST[i]:
719 720 index = i
720 721 break
721 722
722 723 return index
723 724
724 725 def get_numpy_dtype(index):
725 726
726 727 return NUMPY_DTYPE_LIST[index]
727 728
728 729 def get_procflag_dtype(index):
729 730
730 731 return PROCFLAG_DTYPE_LIST[index]
731 732
732 733 def get_dtype_width(index):
733 734
734 735 return DTYPE_WIDTH[index] No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now