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