##// END OF EJS Templates
Victor Sarmiento -
r34:6ea360bced78
parent child
Show More
@@ -1,409 +1,410
1 1 '''
2 2 Created on 23/01/2012
3 3
4 4 @author $Author$
5 5 @version $Id$
6 6 '''
7 7
8 8 import numpy
9 9
10 10 class BasicHeader:
11 11
12 12 def __init__(self):
13 13 self.size = 0
14 14 self.version = 0
15 15 self.dataBlock = 0
16 16 self.utc = 0
17 17 self.miliSecond = 0
18 18 self.timeZone = 0
19 19 self.dstFlag = 0
20 20 self.errorCount = 0
21 21 self.struct = numpy.dtype([
22 22 ('nSize','<u4'),
23 23 ('nVersion','<u2'),
24 24 ('nDataBlockId','<u4'),
25 25 ('nUtime','<u4'),
26 26 ('nMilsec','<u2'),
27 27 ('nTimezone','<i2'),
28 28 ('nDstflag','<i2'),
29 29 ('nErrorCount','<u4')
30 30 ])
31 31 pass
32 32
33 33 def read(self, fp):
34 34
35 35 header = numpy.fromfile(fp, self.struct,1)
36 36 self.size = header['nSize'][0]
37 37 self.version = header['nVersion'][0]
38 38 self.dataBlock = header['nDataBlockId'][0]
39 39 self.utc = header['nUtime'][0]
40 40 self.miliSecond = header['nMilsec'][0]
41 41 self.timeZone = header['nTimezone'][0]
42 42 self.dstFlag = header['nDstflag'][0]
43 43 self.errorCount = header['nErrorCount'][0]
44 44
45 45 return 1
46 46
47 47 def copy(self):
48 48
49 49 obj = BasicHeader()
50 50 obj.size = self.size
51 51 obj.version = self.version
52 52 obj.dataBlock = self.dataBlock
53 53 obj.utc = self.utc
54 54 obj.miliSecond = self.miliSecond
55 55 obj.timeZone = self.timeZone
56 56 obj.dstFlag = self.dstFlag
57 57 obj.errorCount = self.errorCount
58 58
59 59 return obj
60 60
61 61 def write(self, fp):
62 62 headerTuple = (self.size,self.version,self.dataBlock,self.utc,self.miliSecond,self.timeZone,self.dstFlag,self.errorCount)
63 63 header = numpy.array(headerTuple,self.struct)
64 64 header.tofile(fp)
65 65
66 66 return 1
67 67
68 68 class SystemHeader:
69 69
70 70 def __init__(self):
71 71 self.size = 0
72 72 self.numSamples = 0
73 73 self.numProfiles = 0
74 74 self.numChannels = 0
75 75 self.adcResolution = 0
76 76 self.pciDioBusWidth = 0
77 77 self.struct = numpy.dtype([
78 78 ('nSize','<u4'),
79 79 ('nNumSamples','<u4'),
80 80 ('nNumProfiles','<u4'),
81 81 ('nNumChannels','<u4'),
82 82 ('nADCResolution','<u4'),
83 83 ('nPCDIOBusWidth','<u4'),
84 84 ])
85 85
86 86
87 87 def read(self, fp):
88 88 header = numpy.fromfile(fp,self.struct,1)
89 89 self.size = header['nSize'][0]
90 90 self.numSamples = header['nNumSamples'][0]
91 91 self.numProfiles = header['nNumProfiles'][0]
92 92 self.numChannels = header['nNumChannels'][0]
93 93 self.adcResolution = header['nADCResolution'][0]
94 94 self.pciDioBusWidth = header['nPCDIOBusWidth'][0]
95 95
96 96
97 97 return 1
98 98
99 99 def copy(self):
100 100
101 101 obj = SystemHeader()
102 102 obj.size = self.size
103 103 obj.numSamples = self.numSamples
104 104 obj.numProfiles = self.numProfiles
105 105 obj.numChannels = self.numChannels
106 106 obj.adcResolution = self.adcResolution
107 self.pciDioBusWidth = self.pciDioBusWidth
107 obj.pciDioBusWidth = self.pciDioBusWidth
108 108
109 109
110 110 return obj
111 111
112 112 def write(self, fp):
113 113 headerTuple = (self.size,self.numSamples,self.numProfiles,self.numChannels,self.adcResolution,self.pciDioBusWidth)
114 114 header = numpy.array(headerTuple,self.struct)
115 115 header.tofile(fp)
116 116
117 117 return 1
118 118
119 119 class RadarControllerHeader:
120 120
121 121
122 122 def __init__(self):
123 123 self.size = 0
124 124 self.expType = 0
125 125 self.nTx = 0
126 126 self.ipp = 0
127 127 self.txA = 0
128 128 self.txB = 0
129 129 self.numWindows = 0
130 130 self.numTaus = 0
131 131 self.codeType = 0
132 132 self.line6Function = 0
133 133 self.line5Function = 0
134 134 self.fClock = 0
135 135 self.prePulseBefore = 0
136 136 self.prePulserAfter = 0
137 137 self.rangeIpp = 0
138 138 self.rangeTxA = 0
139 139 self.rangeTxB = 0
140 140 self.struct = numpy.dtype([
141 141 ('nSize','<u4'),
142 142 ('nExpType','<u4'),
143 143 ('nNTx','<u4'),
144 144 ('fIpp','<f4'),
145 145 ('fTxA','<f4'),
146 146 ('fTxB','<f4'),
147 147 ('nNumWindows','<u4'),
148 148 ('nNumTaus','<u4'),
149 149 ('nCodeType','<u4'),
150 150 ('nLine6Function','<u4'),
151 151 ('nLine5Function','<u4'),
152 152 ('fClock','<f4'),
153 153 ('nPrePulseBefore','<u4'),
154 154 ('nPrePulseAfter','<u4'),
155 155 ('sRangeIPP','<a20'),
156 156 ('sRangeTxA','<a20'),
157 157 ('sRangeTxB','<a20'),
158 158 ])
159 159 self.dynamic = numpy.array([],numpy.dtype('byte'))
160 160
161 161
162 162 def read(self, fp):
163 163 header = numpy.fromfile(fp,self.struct,1)
164 164 self.size = header['nSize'][0]
165 165 self.expType = header['nExpType'][0]
166 166 self.nTx = header['nNTx'][0]
167 167 self.ipp = header['fIpp'][0]
168 168 self.txA = header['fTxA'][0]
169 169 self.txB = header['fTxB'][0]
170 170 self.numWindows = header['nNumWindows'][0]
171 171 self.numTaus = header['nNumTaus'][0]
172 172 self.codeType = header['nCodeType'][0]
173 173 self.line6Function = header['nLine6Function'][0]
174 174 self.line5Function = header['nLine5Function'][0]
175 175 self.fClock = header['fClock'][0]
176 176 self.prePulseBefore = header['nPrePulseBefore'][0]
177 177 self.prePulserAfter = header['nPrePulseAfter'][0]
178 178 self.rangeIpp = header['sRangeIPP'][0]
179 179 self.rangeTxA = header['sRangeTxA'][0]
180 180 self.rangeTxB = header['sRangeTxB'][0]
181 181 # jump Dynamic Radar Controller Header
182 182 jumpHeader = self.size - 116
183 183 self.dynamic = numpy.fromfile(fp,numpy.dtype('byte'),jumpHeader)
184 184
185 185 return 1
186 186
187 187 def copy(self):
188 188
189 189 obj = RadarControllerHeader()
190 190 obj.size = self.size
191 191 obj.expType = self.expType
192 192 obj.nTx = self.nTx
193 193 obj.ipp = self.ipp
194 194 obj.txA = self.txA
195 195 obj.txB = self.txB
196 196 obj.numWindows = self.numWindows
197 197 obj.numTaus = self.numTaus
198 198 obj.codeType = self.codeType
199 199 obj.line6Function = self.line6Function
200 200 obj.line5Function = self.line5Function
201 201 obj.fClock = self.fClock
202 202 obj.prePulseBefore = self.prePulseBefore
203 203 obj.prePulserAfter = self.prePulserAfter
204 204 obj.rangeIpp = self.rangeIpp
205 205 obj.rangeTxA = self.rangeTxA
206 206 obj.rangeTxB = self.rangeTxB
207 207 obj.dynamic = self.dynamic
208 208
209 209 return obj
210 210
211 211 def write(self, fp):
212 212 headerTuple = (self.size,
213 213 self.expType,
214 214 self.nTx,
215 215 self.ipp,
216 216 self.txA,
217 217 self.txB,
218 218 self.numWindows,
219 219 self.numTaus,
220 220 self.codeType,
221 221 self.line6Function,
222 222 self.line5Function,
223 223 self.fClock,
224 224 self.prePulseBefore,
225 225 self.prePulserAfter,
226 226 self.rangeIpp,
227 227 self.rangeTxA,
228 228 self.rangeTxB)
229 229
230 230 header = numpy.array(headerTuple,self.struct)
231 231 header.tofile(fp)
232 232
233 233 dynamic = self.dynamic
234 234 dynamic.tofile(fp)
235 235
236 236 return 1
237 237
238 238
239 239
240 240 class ProcessingHeader:
241 241
242 242 def __init__(self):
243 243 self.size = 0
244 244 self.dataType = 0
245 245 self.blockSize = 0
246 246 self.profilesPerBlock = 0
247 247 self.dataBlocksPerFile = 0
248 248 self.numWindows = 0
249 249 self.processFlags = 0
250 250 self.coherentInt = 0
251 251 self.incoherentInt = 0
252 252 self.totalSpectra = 0
253 253 self.struct = numpy.dtype([
254 254 ('nSize','<u4'),
255 255 ('nDataType','<u4'),
256 256 ('nSizeOfDataBlock','<u4'),
257 257 ('nProfilesperBlock','<u4'),
258 258 ('nDataBlocksperFile','<u4'),
259 259 ('nNumWindows','<u4'),
260 260 ('nProcessFlags','<u4'),
261 261 ('nCoherentIntegrations','<u4'),
262 262 ('nIncoherentIntegrations','<u4'),
263 263 ('nTotalSpectra','<u4')
264 264 ])
265 265 self.samplingWindow = 0
266 266 self.structSamplingWindow = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')])
267 267 self.numHeights = 0
268 268 self.firstHeight = 0
269 269 self.deltaHeight = 0
270 270 self.samplesWin = 0
271 271 self.spectraComb = 0
272 272 self.numCode = 0
273 273 self.codes = 0
274 274 self.numBaud = 0
275 self.shif_fft = False
275 276
276 277 def read(self, fp):
277 278 header = numpy.fromfile(fp,self.struct,1)
278 279 self.size = header['nSize'][0]
279 280 self.dataType = header['nDataType'][0]
280 281 self.blockSize = header['nSizeOfDataBlock'][0]
281 282 self.profilesPerBlock = header['nProfilesperBlock'][0]
282 283 self.dataBlocksPerFile = header['nDataBlocksperFile'][0]
283 284 self.numWindows = header['nNumWindows'][0]
284 285 self.processFlags = header['nProcessFlags']
285 286 self.coherentInt = header['nCoherentIntegrations'][0]
286 287 self.incoherentInt = header['nIncoherentIntegrations'][0]
287 288 self.totalSpectra = header['nTotalSpectra'][0]
288 289 self.samplingWindow = numpy.fromfile(fp,self.structSamplingWindow,self.numWindows)
289 290 self.numHeights = numpy.sum(self.samplingWindow['nsa'])
290 291 self.firstHeight = self.samplingWindow['h0']
291 292 self.deltaHeight = self.samplingWindow['dh']
292 293 self.samplesWin = self.samplingWindow['nsa']
293 294 self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra)
294 295
295 296 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
296 297 self.numCode = numpy.fromfile(fp,'<u4',1)
297 298 self.numBaud = numpy.fromfile(fp,'<u4',1)
298 299 self.codes = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode)
299 300
300 301 if self.processFlags & PROCFLAG.SHIFT_FFT_DATA == PROCFLAG.SHIFT_FFT_DATA:
301 302 self.shif_fft = True
302 303 else:
303 304 self.shif_fft = False
304 305
305 306
306 307 return 1
307 308
308 309 def copy(self):
309 310
310 311 obj = ProcessingHeader()
311 312 obj.size = self.size
312 313 obj.dataType = self.dataType
313 314 obj.blockSize = self.blockSize
314 315 obj.profilesPerBlock = self.profilesPerBlock
315 316 obj.dataBlocksPerFile = self.dataBlocksPerFile
316 317 obj.numWindows = self.numWindows
317 318 obj.processFlags = self.processFlags
318 319 obj.coherentInt = self.coherentInt
319 320 obj.incoherentInt = self.incoherentInt
320 321 obj.totalSpectra = self.totalSpectra
321 322 obj.samplingWindow = self.samplingWindow
322 323 obj.numHeights = self.numHeights
323 324 obj.firstHeight = self.firstHeight
324 325 obj.deltaHeight = self.deltaHeight
325 326 obj.samplesWin = self.samplesWin
326 327 obj.spectraComb = self.spectraComb
327 328 obj.numCode = self.numCode
328 329 obj.numBaud = self.numBaud
329 330 obj.codes = self.codes
330 331
331 332 obj.shif_fft = self.shif_fft
332 333 return obj
333 334
334 335 def write(self, fp):
335 336 headerTuple = (self.size,
336 337 self.dataType,
337 338 self.blockSize,
338 339 self.profilesPerBlock,
339 340 self.dataBlocksPerFile,
340 341 self.numWindows,
341 342 self.processFlags,
342 343 self.coherentInt,
343 344 self.incoherentInt,
344 345 self.totalSpectra)
345 346
346 347 header = numpy.array(headerTuple,self.struct)
347 348 header.tofile(fp)
348 349
349 350 if self.numWindows != 0:
350 351 sampleWindowTuple = (self.firstHeight,self.deltaHeight,self.samplesWin)
351 352 samplingWindow = numpy.array(sampleWindowTuple,self.structSamplingWindow)
352 353 samplingWindow.tofile(fp)
353 354
354 355
355 356 if self.totalSpectra != 0:
356 357 spectraComb = numpy.array([],numpy.dtype('u1'))
357 358 spectraComb = self.spectraComb
358 359 spectraComb.tofile(fp)
359 360
360 361
361 362 if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE:
362 363 numCode = self.numCode
363 364 numCode.tofile(fp)
364 365
365 366 numBaud = self.numBaud
366 367 numBaud.tofile(fp)
367 368
368 369 codes = self.codes.reshape(numCode*numBaud)
369 370 codes.tofile(fp)
370 371
371 372 return 1
372 373
373 374
374 375 class PROCFLAG:
375 376 COHERENT_INTEGRATION = numpy.uint32(0x00000001)
376 377 DECODE_DATA = numpy.uint32(0x00000002)
377 378 SPECTRA_CALC = numpy.uint32(0x00000004)
378 379 INCOHERENT_INTEGRATION = numpy.uint32(0x00000008)
379 380 POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010)
380 381 SHIFT_FFT_DATA = numpy.uint32(0x00000020)
381 382
382 383 DATATYPE_CHAR = numpy.uint32(0x00000040)
383 384 DATATYPE_SHORT = numpy.uint32(0x00000080)
384 385 DATATYPE_LONG = numpy.uint32(0x00000100)
385 386 DATATYPE_INT64 = numpy.uint32(0x00000200)
386 387 DATATYPE_FLOAT = numpy.uint32(0x00000400)
387 388 DATATYPE_DOUBLE = numpy.uint32(0x00000800)
388 389
389 390 DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000)
390 391 DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000)
391 392 DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000)
392 393
393 394 SAVE_CHANNELS_DC = numpy.uint32(0x00008000)
394 395 DEFLIP_DATA = numpy.uint32(0x00010000)
395 396 DEFINE_PROCESS_CODE = numpy.uint32(0x00020000)
396 397
397 398 ACQ_SYS_NATALIA = numpy.uint32(0x00040000)
398 399 ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000)
399 400 ACQ_SYS_ADRXD = numpy.uint32(0x000C0000)
400 401 ACQ_SYS_JULIA = numpy.uint32(0x00100000)
401 402 ACQ_SYS_XXXXXX = numpy.uint32(0x00140000)
402 403
403 404 EXP_NAME_ESP = numpy.uint32(0x00200000)
404 405 CHANNEL_NAMES_ESP = numpy.uint32(0x00400000)
405 406
406 407 OPERATION_MASK = numpy.uint32(0x0000003F)
407 408 DATATYPE_MASK = numpy.uint32(0x00000FC0)
408 409 DATAARRANGE_MASK = numpy.uint32(0x00007000)
409 410 ACQ_SYS_MASK = numpy.uint32(0x001C0000) No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now