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