@@ -0,0 +1,17 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class Correlation(Data): | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass No newline at end of file |
@@ -0,0 +1,18 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class Data: | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass | |
|
18 | No newline at end of file |
@@ -0,0 +1,18 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class Noise: | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass | |
|
18 | No newline at end of file |
@@ -0,0 +1,18 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class Spectra(Data): | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass | |
|
18 | No newline at end of file |
@@ -0,0 +1,18 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class Voltage(Data): | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass | |
|
18 | No newline at end of file |
|
1 | NO CONTENT: new file 100644 |
@@ -0,0 +1,17 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class CorrelationProcessor(): | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass No newline at end of file |
@@ -0,0 +1,17 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class SpectraProcessor(): | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass No newline at end of file |
@@ -0,0 +1,17 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class VoltageProcessor(): | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass No newline at end of file |
|
1 | NO CONTENT: new file 100644 |
@@ -0,0 +1,18 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class FtpServer(): | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass | |
|
18 | No newline at end of file |
@@ -0,0 +1,17 | |||
|
1 | ''' | |
|
2 | Created on Feb 7, 2012 | |
|
3 | ||
|
4 | @author: roj-idl71 | |
|
5 | ''' | |
|
6 | ||
|
7 | class FtpServerList(): | |
|
8 | ''' | |
|
9 | classdocs | |
|
10 | ''' | |
|
11 | ||
|
12 | ||
|
13 | def __init__(self): | |
|
14 | ''' | |
|
15 | Constructor | |
|
16 | ''' | |
|
17 | pass No newline at end of file |
|
1 | NO CONTENT: new file 100644 |
|
1 | NO CONTENT: modified file |
|
1 | NO CONTENT: modified file |
@@ -1,237 +1,245 | |||
|
1 | 1 | import numpy |
|
2 | 2 | |
|
3 | 3 | class PROCFLAG: |
|
4 | 4 | COHERENT_INTEGRATION = numpy.uint32(0x00000001) |
|
5 | 5 | DECODE_DATA = numpy.uint32(0x00000002) |
|
6 | 6 | SPECTRA_CALC = numpy.uint32(0x00000004) |
|
7 | 7 | INCOHERENT_INTEGRATION = numpy.uint32(0x00000008) |
|
8 | 8 | POST_COHERENT_INTEGRATION = numpy.uint32(0x00000010) |
|
9 | 9 | SHIFT_FFT_DATA = numpy.uint32(0x00000020) |
|
10 | 10 | |
|
11 | 11 | DATATYPE_CHAR = numpy.uint32(0x00000040) |
|
12 | 12 | DATATYPE_SHORT = numpy.uint32(0x00000080) |
|
13 | 13 | DATATYPE_LONG = numpy.uint32(0x00000100) |
|
14 | 14 | DATATYPE_INT64 = numpy.uint32(0x00000200) |
|
15 | 15 | DATATYPE_FLOAT = numpy.uint32(0x00000400) |
|
16 | 16 | DATATYPE_DOUBLE = numpy.uint32(0x00000800) |
|
17 | 17 | |
|
18 | 18 | DATAARRANGE_CONTIGUOUS_CH = numpy.uint32(0x00001000) |
|
19 | 19 | DATAARRANGE_CONTIGUOUS_H = numpy.uint32(0x00002000) |
|
20 | 20 | DATAARRANGE_CONTIGUOUS_P = numpy.uint32(0x00004000) |
|
21 | 21 | |
|
22 | 22 | SAVE_CHANNELS_DC = numpy.uint32(0x00008000) |
|
23 | 23 | DEFLIP_DATA = numpy.uint32(0x00010000) |
|
24 | 24 | DEFINE_PROCESS_CODE = numpy.uint32(0x00020000) |
|
25 | 25 | |
|
26 | 26 | ACQ_SYS_NATALIA = numpy.uint32(0x00040000) |
|
27 | 27 | ACQ_SYS_ECHOTEK = numpy.uint32(0x00080000) |
|
28 | 28 | ACQ_SYS_ADRXD = numpy.uint32(0x000C0000) |
|
29 | 29 | ACQ_SYS_JULIA = numpy.uint32(0x00100000) |
|
30 | 30 | ACQ_SYS_XXXXXX = numpy.uint32(0x00140000) |
|
31 | 31 | |
|
32 | 32 | EXP_NAME_ESP = numpy.uint32(0x00200000) |
|
33 | 33 | CHANNEL_NAMES_ESP = numpy.uint32(0x00400000) |
|
34 | 34 | |
|
35 | 35 | OPERATION_MASK = numpy.uint32(0x0000003F) |
|
36 | 36 | DATATYPE_MASK = numpy.uint32(0x00000FC0) |
|
37 | 37 | DATAARRANGE_MASK = numpy.uint32(0x00007000) |
|
38 | 38 | ACQ_SYS_MASK = numpy.uint32(0x001C0000) |
|
39 | 39 | |
|
40 | 40 | class BasicHeader: |
|
41 | 41 | |
|
42 | 42 | size = 0 |
|
43 | 43 | version = 0 |
|
44 | 44 | dataBlock = 0 |
|
45 | 45 | utc = 0 |
|
46 | 46 | miliSecond = 0 |
|
47 | 47 | timeZone = 0 |
|
48 | 48 | dstFlag = 0 |
|
49 | 49 | errorCount = 0 |
|
50 | 50 | struct = numpy.dtype([ |
|
51 | 51 | ('nSize','<u4'), |
|
52 | 52 | ('nVersion','<u2'), |
|
53 | 53 | ('nDataBlockId','<u4'), |
|
54 | 54 | ('nUtime','<u4'), |
|
55 | 55 | ('nMilsec','<u2'), |
|
56 | 56 | ('nTimezone','<i2'), |
|
57 | 57 | ('nDstflag','<i2'), |
|
58 | 58 | ('nErrorCount','<u4') |
|
59 | 59 | ]) |
|
60 | 60 | |
|
61 | 61 | def __init__(self): |
|
62 | 62 | pass |
|
63 | 63 | |
|
64 | 64 | def read(self, fp): |
|
65 | 65 | |
|
66 | 66 | header = numpy.fromfile(fp, self.struct,1) |
|
67 | 67 | self.size = header['nSize'][0] |
|
68 | 68 | self.version = header['nVersion'][0] |
|
69 | 69 | self.dataBlock = header['nDataBlockId'][0] |
|
70 | 70 | self.utc = header['nUtime'][0] |
|
71 | 71 | self.miliSecond = header['nMilsec'][0] |
|
72 | 72 | self.timeZone = header['nTimezone'][0] |
|
73 | 73 | self.dstFlag = header['nDstflag'][0] |
|
74 | 74 | self.errorCount = header['nErrorCount'][0] |
|
75 | 75 | |
|
76 | 76 | return 1 |
|
77 | 77 | |
|
78 | def copy(self): | |
|
79 | ||
|
80 | obj = BasicHeader() | |
|
81 | obj.size = self.size | |
|
82 | ||
|
83 | ||
|
84 | return obj | |
|
85 | ||
|
78 | 86 | class SystemHeader: |
|
79 | 87 | size = 0 |
|
80 | 88 | numSamples = 0 |
|
81 | 89 | numProfiles = 0 |
|
82 | 90 | numChannels = 0 |
|
83 | 91 | adcResolution = 0 |
|
84 | 92 | pciDioBusWidth = 0 |
|
85 | 93 | struct = numpy.dtype([ |
|
86 | 94 | ('nSize','<u4'), |
|
87 | 95 | ('nNumSamples','<u4'), |
|
88 | 96 | ('nNumProfiles','<u4'), |
|
89 | 97 | ('nNumChannels','<u4'), |
|
90 | 98 | ('nADCResolution','<u4'), |
|
91 | 99 | ('nPCDIOBusWidth','<u4'), |
|
92 | 100 | ]) |
|
93 | 101 | |
|
94 | 102 | def __init__(self): |
|
95 | 103 | pass |
|
96 | 104 | |
|
97 | 105 | def read(self, fp): |
|
98 | 106 | header = numpy.fromfile(fp,self.struct,1) |
|
99 | 107 | self.size = header['nSize'][0] |
|
100 | 108 | self.numSamples = header['nNumSamples'][0] |
|
101 | 109 | self.numProfiles = header['nNumProfiles'][0] |
|
102 | 110 | self.numChannels = header['nNumChannels'][0] |
|
103 | 111 | self.adcResolution = header['nADCResolution'][0] |
|
104 | 112 | self.pciDioBusWidth = header['nPCDIOBusWidth'][0] |
|
105 | 113 | |
|
106 | 114 | |
|
107 | 115 | return 1 |
|
108 | 116 | |
|
109 | 117 | class RadarControllerHeader: |
|
110 | 118 | size = 0 |
|
111 | 119 | expType = 0 |
|
112 | 120 | nTx = 0 |
|
113 | 121 | ipp = 0 |
|
114 | 122 | txA = 0 |
|
115 | 123 | txB = 0 |
|
116 | 124 | numWindows = 0 |
|
117 | 125 | numTaus = 0 |
|
118 | 126 | codeType = 0 |
|
119 | 127 | line6Function = 0 |
|
120 | 128 | line5Fuction = 0 |
|
121 | 129 | fClock = 0 |
|
122 | 130 | prePulseBefore = 0 |
|
123 | 131 | prePulserAfter = 0 |
|
124 | 132 | rangeIpp = 0 |
|
125 | 133 | rangeTxA = 0 |
|
126 | 134 | rangeTxB = 0 |
|
127 | 135 | struct = numpy.dtype([ |
|
128 | 136 | ('nSize','<u4'), |
|
129 | 137 | ('nExpType','<u4'), |
|
130 | 138 | ('nNTx','<u4'), |
|
131 | 139 | ('fIpp','<f4'), |
|
132 | 140 | ('fTxA','<f4'), |
|
133 | 141 | ('fTxB','<f4'), |
|
134 | 142 | ('nNumWindows','<u4'), |
|
135 | 143 | ('nNumTaus','<u4'), |
|
136 | 144 | ('nCodeType','<u4'), |
|
137 | 145 | ('nLine6Function','<u4'), |
|
138 | 146 | ('nLine5Function','<u4'), |
|
139 | 147 | ('fClock','<f4'), |
|
140 | 148 | ('nPrePulseBefore','<u4'), |
|
141 | 149 | ('nPrePulseAfter','<u4'), |
|
142 | 150 | ('sRangeIPP','<a20'), |
|
143 | 151 | ('sRangeTxA','<a20'), |
|
144 | 152 | ('sRangeTxB','<a20'), |
|
145 | 153 | ]) |
|
146 | 154 | |
|
147 | 155 | |
|
148 | 156 | def __init__(self): |
|
149 | 157 | pass |
|
150 | 158 | |
|
151 | 159 | def read(self, fp): |
|
152 | 160 | header = numpy.fromfile(fp,self.struct,1) |
|
153 | 161 | self.size = header['nSize'][0] |
|
154 | 162 | self.expType = header['nExpType'][0] |
|
155 | 163 | self.nTx = header['nNTx'][0] |
|
156 | 164 | self.ipp = header['fIpp'][0] |
|
157 | 165 | self.txA = header['fTxA'][0] |
|
158 | 166 | self.txB = header['fTxB'][0] |
|
159 | 167 | self.numWindows = header['nNumWindows'][0] |
|
160 | 168 | self.numTaus = header['nNumTaus'][0] |
|
161 | 169 | self.codeType = header['nCodeType'][0] |
|
162 | 170 | self.line6Function = header['nLine6Function'][0] |
|
163 | 171 | self.line5Fuction = header['nLine5Function'][0] |
|
164 | 172 | self.fClock = header['fClock'][0] |
|
165 | 173 | self.prePulseBefore = header['nPrePulseBefore'][0] |
|
166 | 174 | self.prePulserAfter = header['nPrePulseAfter'][0] |
|
167 | 175 | self.rangeIpp = header['sRangeIPP'][0] |
|
168 | 176 | self.rangeTxA = header['sRangeTxA'][0] |
|
169 | 177 | self.rangeTxB = header['sRangeTxB'][0] |
|
170 | 178 | # jump Dynamic Radar Controller Header |
|
171 | 179 | jumpHeader = self.size - 116 |
|
172 | 180 | fp.seek(fp.tell() + jumpHeader) |
|
173 | 181 | |
|
174 | 182 | return 1 |
|
175 | 183 | |
|
176 | 184 | class ProcessingHeader: |
|
177 | 185 | size = 0 |
|
178 | 186 | dataType = 0 |
|
179 | 187 | blockSize = 0 |
|
180 | 188 | profilesPerBlock = 0 |
|
181 | 189 | dataBlocksPerFile = 0 |
|
182 | 190 | numWindows = 0 |
|
183 | 191 | processFlags = 0 |
|
184 | 192 | coherentInt = 0 |
|
185 | 193 | incoherentInt = 0 |
|
186 | 194 | totalSpectra = 0 |
|
187 | 195 | struct = numpy.dtype([ |
|
188 | 196 | ('nSize','<u4'), |
|
189 | 197 | ('nDataType','<u4'), |
|
190 | 198 | ('nSizeOfDataBlock','<u4'), |
|
191 | 199 | ('nProfilesperBlock','<u4'), |
|
192 | 200 | ('nDataBlocksperFile','<u4'), |
|
193 | 201 | ('nNumWindows','<u4'), |
|
194 | 202 | ('nProcessFlags','<u4'), |
|
195 | 203 | ('nCoherentIntegrations','<u4'), |
|
196 | 204 | ('nIncoherentIntegrations','<u4'), |
|
197 | 205 | ('nTotalSpectra','<u4') |
|
198 | 206 | ]) |
|
199 | 207 | samplingWindow = 0 |
|
200 | 208 | structSamplingWindow = numpy.dtype([('h0','<f4'),('dh','<f4'),('nsa','<u4')]) |
|
201 | 209 | numHeights = 0 |
|
202 | 210 | firstHeight = 0 |
|
203 | 211 | deltaHeight = 0 |
|
204 | 212 | samplesWin = 0 |
|
205 | 213 | spectraComb = 0 |
|
206 | 214 | numCode = 0 |
|
207 | 215 | codes = 0 |
|
208 | 216 | numBaud = 0 |
|
209 | 217 | |
|
210 | 218 | def __init__(self): |
|
211 | 219 | pass |
|
212 | 220 | |
|
213 | 221 | def read(self, fp): |
|
214 | 222 | header = numpy.fromfile(fp,self.struct,1) |
|
215 | 223 | self.size = header['nSize'][0] |
|
216 | 224 | self.dataType = header['nDataType'][0] |
|
217 | 225 | self.blockSize = header['nSizeOfDataBlock'][0] |
|
218 | 226 | self.profilesPerBlock = header['nProfilesperBlock'][0] |
|
219 | 227 | self.dataBlocksPerFile = header['nDataBlocksperFile'][0] |
|
220 | 228 | self.numWindows = header['nNumWindows'][0] |
|
221 | 229 | self.processFlags = header['nProcessFlags'] |
|
222 | 230 | self.coherentInt = header['nCoherentIntegrations'][0] |
|
223 | 231 | self.incoherentInt = header['nIncoherentIntegrations'][0] |
|
224 | 232 | self.totalSpectra = header['nTotalSpectra'][0] |
|
225 | 233 | self.samplingWindow = numpy.fromfile(fp,self.structSamplingWindow,self.numWindows) |
|
226 | 234 | self.numHeights = numpy.sum(self.samplingWindow['nsa']) |
|
227 | 235 | self.firstHeight = self.samplingWindow['h0'] |
|
228 | 236 | self.deltaHeight = self.samplingWindow['dh'] |
|
229 | 237 | self.samplesWin = self.samplingWindow['nsa'] |
|
230 | 238 | self.spectraComb = numpy.fromfile(fp,'u1',2*self.totalSpectra) |
|
231 | 239 | if self.processFlags & PROCFLAG.DEFINE_PROCESS_CODE == PROCFLAG.DEFINE_PROCESS_CODE: |
|
232 | 240 | self.numCode = numpy.fromfile(fp,'<u4',1) |
|
233 | 241 | self.numBaud = numpy.fromfile(fp,'<u4',1) |
|
234 | 242 | self.codes = numpy.fromfile(fp,'<f4',self.numCode*self.numBaud).reshape(self.numBaud,self.numCode) |
|
235 | 243 | |
|
236 | 244 | |
|
237 | 245 | return 1 No newline at end of file |
|
1 | NO CONTENT: modified file |
@@ -1,385 +1,414 | |||
|
1 | 1 | ''' |
|
2 | 2 | Created on 23/01/2012 |
|
3 | 3 | |
|
4 | 4 | @author: danielangelsuarezmunoz |
|
5 | 5 | ''' |
|
6 | 6 | |
|
7 | ||
|
8 | import os, sys | |
|
7 | 9 | import numpy |
|
8 | import os.path | |
|
9 | 10 | import glob |
|
10 | 11 | import fnmatch |
|
11 | 12 | import time |
|
12 | 13 | import datetime |
|
13 | 14 | |
|
14 | 15 | from Header import * |
|
15 | 16 | from Data import DataReader |
|
16 | 17 | from Data import DataWriter |
|
17 | 18 | |
|
19 | path = os.path.split(os.getcwd())[0] | |
|
20 | sys.path.append(os.path.join(path,"Model")) | |
|
21 | ||
|
22 | from Voltage import Voltage | |
|
23 | ||
|
18 | 24 | class VoltageReader(DataReader): |
|
19 | 25 | |
|
20 | 26 | __idFile = 0 |
|
21 | 27 | |
|
22 | 28 | __fp = 0 |
|
23 | 29 | |
|
24 | 30 | __startDateTime = 0 |
|
25 | 31 | |
|
26 | 32 | __endDateTime = 0 |
|
27 | 33 | |
|
28 | 34 | __dataType = 0 |
|
29 | 35 | |
|
30 | 36 | __sizeOfFileByHeader = 0 |
|
31 | 37 | |
|
32 | 38 | __pathList = [] |
|
33 | 39 | |
|
34 | 40 | filenameList = [] |
|
35 | 41 | |
|
36 | 42 | __lastUTTime = 0 |
|
37 | 43 | |
|
38 | 44 | __maxTimeStep = 5 |
|
39 | 45 | |
|
40 | 46 | flagResetProcessing = 0 |
|
41 | 47 | |
|
42 | 48 | __flagIsNewFile = 0 |
|
43 | 49 | |
|
44 | 50 | noMoreFiles = 0 |
|
45 | 51 | |
|
46 | 52 | online = 0 |
|
47 | 53 | |
|
48 | 54 | filename = '' |
|
49 | 55 | |
|
50 | 56 | fileSize = 0 |
|
51 | 57 | |
|
52 | 58 | firstHeaderSize = 0 |
|
53 | 59 | |
|
54 | 60 | basicHeaderSize = 24 |
|
55 | 61 | |
|
56 |
|
|
|
62 | m_BasicHeader = BasicHeader() | |
|
63 | ||
|
64 | m_SystemHeader = SystemHeader() | |
|
57 | 65 | |
|
58 | systemHeaderObj = SystemHeader() | |
|
66 | m_RadarControllerHeader = RadarControllerHeader() | |
|
59 | 67 | |
|
60 | radarControllerHeaderObj = RadarControllerHeader() | |
|
68 | m_ProcessingHeader = ProcessingHeader() | |
|
61 | 69 | |
|
62 | processingHeaderObj = ProcessingHeader() | |
|
70 | m_Voltage = None | |
|
63 | 71 | |
|
64 | 72 | __buffer = 0 |
|
65 | 73 | |
|
66 | 74 | __buffer_id = 9999 |
|
67 | #m_Voltage= Voltage() | |
|
68 | 75 | |
|
76 | def __init__(self, m_Voltage): | |
|
69 | 77 | |
|
70 | def __init__(self): | |
|
71 | pass | |
|
78 | self.m_Voltage = m_Voltage | |
|
72 | 79 | |
|
73 | 80 | def __rdSystemHeader(self,fp=None): |
|
74 | 81 | if fp == None: |
|
75 | 82 | fp = self.__fp |
|
76 | 83 | |
|
77 |
self. |
|
|
84 | self.m_SystemHeader.read(fp) | |
|
78 | 85 | |
|
79 | 86 | def __rdRadarControllerHeader(self,fp=None): |
|
80 | 87 | if fp == None: |
|
81 | 88 | fp = self.__fp |
|
82 | 89 | |
|
83 |
self. |
|
|
90 | self.m_RadarControllerHeader.read(fp) | |
|
84 | 91 | |
|
85 | 92 | def __rdProcessingHeader(self,fp=None): |
|
86 | 93 | if fp == None: |
|
87 | 94 | fp = self.__fp |
|
88 | 95 | |
|
89 |
self. |
|
|
96 | self.m_ProcessingHeader.read(fp) | |
|
90 | 97 | |
|
91 | 98 | def __searchFiles(self,path, startDateTime, endDateTime, set=None, expLabel = "", ext = "*.r"): |
|
92 | 99 | |
|
93 | 100 | startUtSeconds = time.mktime(startDateTime.timetuple()) |
|
94 | 101 | endUtSeconds = time.mktime(endDateTime.timetuple()) |
|
95 | 102 | |
|
96 | 103 | startYear = startDateTime.timetuple().tm_year |
|
97 | 104 | endYear = endDateTime.timetuple().tm_year |
|
98 | 105 | |
|
99 | 106 | startDoy = startDateTime.timetuple().tm_yday |
|
100 | 107 | endDoy = endDateTime.timetuple().tm_yday |
|
101 | 108 | |
|
102 | 109 | rangeOfYears = range(startYear,endYear+1) |
|
103 | 110 | |
|
104 | 111 | listOfListDoys = [] |
|
105 | 112 | if startYear == endYear: |
|
106 | 113 | doyList = range(startDoy,endDoy+1) |
|
107 | 114 | else: |
|
108 | 115 | for year in rangeOfYears: |
|
109 | 116 | if (year == startYear): |
|
110 | 117 | listOfListDoys.append(range(startDoy,365+1)) |
|
111 | 118 | elif (year == endYear): |
|
112 | 119 | listOfListDoys.append(range(1,endDoy+1)) |
|
113 | 120 | else: |
|
114 | 121 | listOfListDoys.append(range(1,365+1)) |
|
115 | 122 | doyList = [] |
|
116 | 123 | for list in listOfListDoys: |
|
117 | 124 | doyList = doyList + list |
|
118 | 125 | |
|
119 | 126 | folders = [] |
|
120 | 127 | for thisPath in os.listdir(path): |
|
121 | 128 | if os.path.isdir(os.path.join(path,thisPath)): |
|
122 | 129 | #folders.append(os.path.join(path,thisPath)) |
|
123 | 130 | folders.append(thisPath) |
|
124 | 131 | |
|
125 | 132 | pathList = [] |
|
126 | 133 | dicOfPath = {} |
|
127 | 134 | for year in rangeOfYears: |
|
128 | 135 | for doy in doyList: |
|
129 | 136 | tmp = fnmatch.filter(folders, 'D' + '%4.4d%3.3d' % (year,doy)) |
|
130 | 137 | if len(tmp) == 0: |
|
131 | 138 | continue |
|
132 | 139 | if expLabel == '': |
|
133 | 140 | pathList.append(os.path.join(path,tmp[0])) |
|
134 | 141 | dicOfPath.setdefault(os.path.join(path,tmp[0])) |
|
135 | 142 | dicOfPath[os.path.join(path,tmp[0])] = [] |
|
136 | 143 | else: |
|
137 | 144 | pathList.append(os.path.join(path,os.path.join(tmp[0],expLabel))) |
|
138 | 145 | dicOfPath.setdefault(os.path.join(path,os.path.join(tmp[0],expLabel))) |
|
139 | 146 | dicOfPath[os.path.join(path,os.path.join(tmp[0],expLabel))] = [] |
|
140 | 147 | |
|
141 | 148 | |
|
142 | 149 | filenameList = [] |
|
143 | 150 | for thisPath in pathList: |
|
144 | 151 | fileList = glob.glob1(thisPath, ext) |
|
145 | 152 | #dicOfPath[thisPath].append(fileList) |
|
146 | 153 | fileList.sort() |
|
147 | 154 | for file in fileList: |
|
148 | 155 | filename = os.path.join(thisPath,file) |
|
149 | 156 | if self.isThisFileinRange(filename, startUtSeconds, endUtSeconds): |
|
150 | 157 | filenameList.append(filename) |
|
151 | 158 | |
|
152 | 159 | self.filenameList = filenameList |
|
153 | 160 | |
|
154 | 161 | return pathList, filenameList |
|
155 | 162 | |
|
156 | 163 | def isThisFileinRange(self, filename, startUTSeconds=None, endUTSeconds=None): |
|
157 | 164 | |
|
158 | 165 | try: |
|
159 | 166 | fp = open(filename,'rb') |
|
160 | 167 | except: |
|
161 | 168 | raise IOError, "The file %s can't be opened" %(filename) |
|
162 | 169 | |
|
163 | 170 | if startUTSeconds==None: |
|
164 | 171 | startUTSeconds = self.startUTCSeconds |
|
165 | 172 | |
|
166 | 173 | if endUTSeconds==None: |
|
167 | 174 | endUTSeconds = self.endUTCSeconds |
|
168 | 175 | |
|
169 |
|
|
|
176 | m_BasicHeader = BasicHeader() | |
|
170 | 177 | |
|
171 |
if not( |
|
|
178 | if not(m_BasicHeader.read(fp)): | |
|
172 | 179 | return 0 |
|
173 | 180 | |
|
174 | 181 | fp.close() |
|
175 | 182 | |
|
176 |
if not ((startUTSeconds <= |
|
|
183 | if not ((startUTSeconds <= m_BasicHeader.utc) and (endUTSeconds >= m_BasicHeader.utc)): | |
|
177 | 184 | return 0 |
|
178 | 185 | |
|
179 | 186 | return 1 |
|
180 | 187 | |
|
181 | 188 | def __readBasicHeader(self, fp=None): |
|
182 | 189 | |
|
183 | 190 | if fp == None: |
|
184 | 191 | fp = self.__fp |
|
185 | 192 | |
|
186 |
self. |
|
|
193 | self.m_BasicHeader.read(fp) | |
|
187 | 194 | |
|
188 | 195 | def __readFirstHeader(self): |
|
189 | 196 | |
|
190 | 197 | self.__readBasicHeader() |
|
191 | 198 | self.__rdSystemHeader() |
|
192 | 199 | self.__rdRadarControllerHeader() |
|
193 | 200 | self.__rdProcessingHeader() |
|
194 |
self.firstHeaderSize = self. |
|
|
201 | self.firstHeaderSize = self.m_BasicHeader.size | |
|
195 | 202 | |
|
196 |
data_type=int(numpy.log2((self. |
|
|
203 | data_type=int(numpy.log2((self.m_ProcessingHeader.processFlags & PROCFLAG.DATATYPE_MASK))-numpy.log2(PROCFLAG.DATATYPE_CHAR)) | |
|
197 | 204 | if data_type == 0: |
|
198 | 205 | tmp=numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
199 | 206 | elif data_type == 1: |
|
200 | 207 | tmp=numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
201 | 208 | elif data_type == 2: |
|
202 | 209 | tmp=numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
203 | 210 | elif data_type == 3: |
|
204 | 211 | tmp=numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
205 | 212 | elif data_type == 4: |
|
206 | 213 | tmp=numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
207 | 214 | elif data_type == 5: |
|
208 | 215 | tmp=numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
209 | 216 | else: |
|
210 | 217 | print 'no define data type' |
|
211 | 218 | tmp = 0 |
|
212 | 219 | |
|
213 | 220 | self.__dataType = tmp |
|
214 |
self.__sizeOfFileByHeader = self. |
|
|
221 | self.__sizeOfFileByHeader = self.m_ProcessingHeader.dataBlocksPerFile * self.m_ProcessingHeader.blockSize + self.firstHeaderSize + self.basicHeaderSize*(self.m_ProcessingHeader.dataBlocksPerFile - 1) | |
|
215 | 222 | |
|
216 | 223 | def __setNextFileOnline(self): |
|
217 | 224 | return 0 |
|
218 | 225 | |
|
219 | 226 | def __setNextFileOffline(self): |
|
220 | 227 | |
|
221 | 228 | idFile = self.__idFile |
|
222 | 229 | while(True): |
|
223 | 230 | |
|
224 | 231 | idFile += 1 |
|
225 | 232 | |
|
226 | 233 | if not(idFile < len(self.filenameList)): |
|
227 | 234 | self.noMoreFiles = 1 |
|
228 | 235 | return 0 |
|
229 | 236 | |
|
230 | 237 | filename = self.filenameList[idFile] |
|
231 | 238 | fileSize = os.path.getsize(filename) |
|
232 | 239 | fp = open(filename,'rb') |
|
233 | 240 | |
|
234 | 241 | currentSize = fileSize - fp.tell() |
|
235 |
neededSize = self. |
|
|
242 | neededSize = self.m_ProcessingHeader.blockSize + self.firstHeaderSize | |
|
236 | 243 | |
|
237 | 244 | if (currentSize < neededSize): |
|
238 | 245 | continue |
|
239 | 246 | |
|
240 | 247 | break |
|
241 | 248 | |
|
242 | 249 | self.__flagIsNewFile = 1 |
|
243 | 250 | self.__idFile = idFile |
|
244 | 251 | self.filename = filename |
|
245 | 252 | self.fileSize = fileSize |
|
246 | 253 | self.__fp = fp |
|
247 | 254 | |
|
248 | 255 | print 'Setting the file: %s'%self.filename |
|
249 | 256 | |
|
250 | 257 | return 1 |
|
251 | 258 | |
|
252 | 259 | def __setNextFile(self): |
|
253 | 260 | |
|
254 | 261 | if self.online: |
|
255 | 262 | return self.__setNextFileOnline() |
|
256 | 263 | else: |
|
257 | 264 | return self.__setNextFileOffline() |
|
258 | 265 | |
|
259 | 266 | def __setNewBlock(self): |
|
260 | 267 | |
|
261 | 268 | if self.__flagIsNewFile: |
|
262 | 269 | return 1 |
|
263 | 270 | |
|
264 | 271 | currentSize = self.fileSize - self.__fp.tell() |
|
265 |
neededSize = self. |
|
|
272 | neededSize = self.m_ProcessingHeader.blockSize + self.basicHeaderSize | |
|
266 | 273 | |
|
267 | 274 | # Bloque Completo |
|
268 | 275 | if (currentSize >= neededSize): |
|
269 | 276 | self.__readBasicHeader() |
|
270 | 277 | return 1 |
|
271 | 278 | |
|
272 | 279 | if not(self.__setNextFile()): |
|
273 | 280 | return 0 |
|
274 | 281 | |
|
275 | 282 | self.__readFirstHeader() |
|
276 | 283 | |
|
277 |
deltaTime = self. |
|
|
284 | deltaTime = self.m_BasicHeader.utc - self.__lastUTTime # check this | |
|
278 | 285 | |
|
279 | 286 | self.flagResetProcessing = 0 |
|
280 | 287 | if deltaTime > self.__maxTimeStep: |
|
281 | 288 | self.flagResetProcessing = 1 |
|
282 | 289 | |
|
283 | 290 | return 1 |
|
284 | 291 | |
|
285 | 292 | def __readBlock(self): |
|
286 | 293 | """Lee el bloque de datos desde la posicion actual del puntero del archivo y |
|
287 | 294 | actualiza todos los parametros relacionados al bloque de datos (data, time, |
|
288 | 295 | etc). La data leida es almacenada en el buffer y el contador de datos leidos es |
|
289 | 296 | seteado a 0 |
|
290 | 297 | """ |
|
291 | 298 | |
|
292 |
pts2read = self. |
|
|
299 | pts2read = self.m_ProcessingHeader.profilesPerBlock*self.m_ProcessingHeader.numHeights*self.m_SystemHeader.numChannels | |
|
293 | 300 | |
|
294 | 301 | data = numpy.fromfile(self.__fp,self.__dataType,pts2read) |
|
295 | 302 | |
|
296 |
data = data.reshape((self. |
|
|
303 | data = data.reshape((self.m_ProcessingHeader.profilesPerBlock, self.m_ProcessingHeader.numHeights, self.m_SystemHeader.numChannels)) | |
|
297 | 304 | |
|
298 | 305 | self.__flagIsNewFile = 0 |
|
299 | 306 | |
|
300 | 307 | self.__buffer = data |
|
301 | 308 | |
|
302 | 309 | self.__buffer_id = 0 |
|
303 | 310 | |
|
304 | 311 | def readNextBlock(self): |
|
305 | 312 | |
|
306 | 313 | if not(self.__setNewBlock()): |
|
307 | 314 | return 0 |
|
308 | 315 | |
|
309 | 316 | self.__readBlock() |
|
310 | 317 | |
|
311 |
self.__lastUTTime = self. |
|
|
318 | self.__lastUTTime = self.m_BasicHeader.utc | |
|
312 | 319 | |
|
313 | 320 | return 1 |
|
314 | 321 | |
|
315 | 322 | def __hasNotDataInBuffer(self): |
|
316 |
if self.__buffer_id >= self. |
|
|
323 | if self.__buffer_id >= self.m_ProcessingHeader.profilesPerBlock: | |
|
317 | 324 | return 1 |
|
318 | 325 | |
|
319 | 326 | return 0 |
|
320 | 327 | |
|
321 | 328 | def getData(self): |
|
322 | 329 | """Obtiene un unidad de datos del buffer de lectura y es copiada a la clase "Data" |
|
323 | 330 | con todos los parametros asociados a este. cuando no hay datos en el buffer de |
|
324 | 331 | lectura es necesario hacer una nueva lectura de los bloques de datos |
|
325 | 332 | "__readBlock" |
|
326 | 333 | """ |
|
327 | 334 | self.flagResetProcessing = 0 |
|
328 | 335 | |
|
329 | 336 | if self.__hasNotDataInBuffer(): |
|
330 | 337 | self.readNextBlock() |
|
331 | 338 | |
|
332 | 339 | if self.noMoreFiles == 1: |
|
333 | 340 | print 'read finished' |
|
334 | 341 | return None |
|
335 | 342 | |
|
336 | 343 | data = self.__buffer[self.__buffer_id,:,:] |
|
337 | #time = timeblock + n*ipp | |
|
338 | #print self.__buffer_id | |
|
344 | time = 111 | |
|
345 | ||
|
346 | self.m_Voltage.data = data | |
|
347 | self.m_Voltage.timeProfile = time | |
|
348 | self.m_Voltage.m_BasicHeader = self.m_BasicHeader.copy() | |
|
349 | self.m_Voltage.m_ProcessingHeader = self.m_ProcessingHeader.copy() | |
|
350 | self.m_Voltage.m_RadarControllerHeader = self.m_RadarControllerHeader.copy() | |
|
351 | self.m_Voltage.m_SystemHeader = self.m_systemHeader.copy() | |
|
339 | 352 | |
|
340 | 353 | self.__buffer_id += 1 |
|
341 | 354 | |
|
342 | 355 | #call setData - to Data Object |
|
343 | 356 | |
|
344 | 357 | return data |
|
345 | 358 | |
|
346 | 359 | |
|
347 | 360 | def setup(self, path, startDateTime, endDateTime, set=None, expLabel = "", ext = ".r", online = 0): |
|
348 | 361 | |
|
349 | 362 | if online == 0: |
|
350 | 363 | pathList, filenameList = self.__searchFiles(path, startDateTime, endDateTime, set, expLabel, ext) |
|
351 | 364 | |
|
352 | 365 | if len(filenameList) == 0: |
|
353 | 366 | print 'Do not exist files in range: %s - %s'%(startDateTime.ctime(), endDateTime.ctime()) |
|
354 | 367 | return 0 |
|
355 | 368 | |
|
356 | 369 | # for thisFile in filenameList: |
|
357 | 370 | # print thisFile |
|
358 | 371 | |
|
359 | 372 | self.__idFile = -1 |
|
360 | 373 | |
|
361 | 374 | if not(self.__setNextFile()): |
|
362 | 375 | print "No more files" |
|
363 | 376 | return 0 |
|
364 | 377 | |
|
365 | 378 | self.__readFirstHeader() |
|
366 | 379 | |
|
367 | 380 | self.startUTCSeconds = time.mktime(startDateTime.timetuple()) |
|
368 | 381 | self.endUTCSeconds = time.mktime(endDateTime.timetuple()) |
|
369 | 382 | |
|
370 | 383 | self.startYear = startDateTime.timetuple().tm_year |
|
371 | 384 | self.endYear = endDateTime.timetuple().tm_year |
|
372 | 385 | |
|
373 | 386 | self.startDoy = startDateTime.timetuple().tm_yday |
|
374 | 387 | self.endDoy = endDateTime.timetuple().tm_yday |
|
375 | 388 | #call fillHeaderValues() - to Data Object |
|
376 | 389 | |
|
377 | 390 | self.__pathList = pathList |
|
378 | 391 | self.filenameList = filenameList |
|
379 | 392 | self.online = online |
|
380 | 393 | |
|
381 | 394 | class VoltageWriter(DataWriter): |
|
382 | 395 | |
|
383 | def __init__(self): | |
|
384 | pass | |
|
396 | m_BasicHeader= BasicHeader() | |
|
397 | ||
|
398 | ||
|
399 | m_SystemHeader = SystemHeader() | |
|
400 | ||
|
401 | ||
|
402 | m_RadarControllerHeader = RadarControllerHeader() | |
|
403 | ||
|
404 | ||
|
405 | m_ProcessingHeader = ProcessingHeader() | |
|
406 | ||
|
407 | m_Voltage = None | |
|
408 | ||
|
409 | def __init__(self, m_Voltage): | |
|
410 | ||
|
411 | self.m_Voltage = m_Voltage | |
|
412 | ||
|
413 | ||
|
385 | 414 | No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now