@@ -1,1115 +1,1115 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author: murco $ |
|
3 | $Author: murco $ | |
4 | $Id: JROData.py 173 2012-11-20 15:06:21Z murco $ |
|
4 | $Id: JROData.py 173 2012-11-20 15:06:21Z murco $ | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import copy |
|
7 | import copy | |
8 | import numpy |
|
8 | import numpy | |
9 | import datetime |
|
9 | import datetime | |
10 |
|
10 | |||
11 | from jroheaderIO import SystemHeader, RadarControllerHeader |
|
11 | from jroheaderIO import SystemHeader, RadarControllerHeader | |
12 |
|
12 | |||
13 | def getNumpyDtype(dataTypeCode): |
|
13 | def getNumpyDtype(dataTypeCode): | |
14 |
|
14 | |||
15 | if dataTypeCode == 0: |
|
15 | if dataTypeCode == 0: | |
16 | numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
16 | numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
17 | elif dataTypeCode == 1: |
|
17 | elif dataTypeCode == 1: | |
18 | numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
18 | numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
19 | elif dataTypeCode == 2: |
|
19 | elif dataTypeCode == 2: | |
20 | numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
20 | numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
21 | elif dataTypeCode == 3: |
|
21 | elif dataTypeCode == 3: | |
22 | numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
22 | numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
23 | elif dataTypeCode == 4: |
|
23 | elif dataTypeCode == 4: | |
24 | numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
24 | numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
25 | elif dataTypeCode == 5: |
|
25 | elif dataTypeCode == 5: | |
26 | numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
26 | numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
27 | else: |
|
27 | else: | |
28 | raise ValueError, 'dataTypeCode was not defined' |
|
28 | raise ValueError, 'dataTypeCode was not defined' | |
29 |
|
29 | |||
30 | return numpyDtype |
|
30 | return numpyDtype | |
31 |
|
31 | |||
32 | def getDataTypeCode(numpyDtype): |
|
32 | def getDataTypeCode(numpyDtype): | |
33 |
|
33 | |||
34 | if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]): |
|
34 | if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]): | |
35 | datatype = 0 |
|
35 | datatype = 0 | |
36 | elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]): |
|
36 | elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]): | |
37 | datatype = 1 |
|
37 | datatype = 1 | |
38 | elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]): |
|
38 | elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]): | |
39 | datatype = 2 |
|
39 | datatype = 2 | |
40 | elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]): |
|
40 | elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]): | |
41 | datatype = 3 |
|
41 | datatype = 3 | |
42 | elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]): |
|
42 | elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]): | |
43 | datatype = 4 |
|
43 | datatype = 4 | |
44 | elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]): |
|
44 | elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]): | |
45 | datatype = 5 |
|
45 | datatype = 5 | |
46 | else: |
|
46 | else: | |
47 | datatype = None |
|
47 | datatype = None | |
48 |
|
48 | |||
49 | return datatype |
|
49 | return datatype | |
50 |
|
50 | |||
51 | def hildebrand_sekhon(data, navg): |
|
51 | def hildebrand_sekhon(data, navg): | |
52 | """ |
|
52 | """ | |
53 | This method is for the objective determination of the noise level in Doppler spectra. This |
|
53 | This method is for the objective determination of the noise level in Doppler spectra. This | |
54 | implementation technique is based on the fact that the standard deviation of the spectral |
|
54 | implementation technique is based on the fact that the standard deviation of the spectral | |
55 | densities is equal to the mean spectral density for white Gaussian noise |
|
55 | densities is equal to the mean spectral density for white Gaussian noise | |
56 |
|
56 | |||
57 | Inputs: |
|
57 | Inputs: | |
58 | Data : heights |
|
58 | Data : heights | |
59 | navg : numbers of averages |
|
59 | navg : numbers of averages | |
60 |
|
60 | |||
61 | Return: |
|
61 | Return: | |
62 | -1 : any error |
|
62 | -1 : any error | |
63 | anoise : noise's level |
|
63 | anoise : noise's level | |
64 | """ |
|
64 | """ | |
65 |
|
65 | |||
66 | sortdata = numpy.sort(data,axis=None) |
|
66 | sortdata = numpy.sort(data,axis=None) | |
67 | lenOfData = len(sortdata) |
|
67 | lenOfData = len(sortdata) | |
68 | nums_min = lenOfData/10 |
|
68 | nums_min = lenOfData/10 | |
69 |
|
69 | |||
70 | if (lenOfData/10) > 2: |
|
70 | if (lenOfData/10) > 2: | |
71 | nums_min = lenOfData/10 |
|
71 | nums_min = lenOfData/10 | |
72 | else: |
|
72 | else: | |
73 | nums_min = 2 |
|
73 | nums_min = 2 | |
74 |
|
74 | |||
75 | sump = 0. |
|
75 | sump = 0. | |
76 |
|
76 | |||
77 | sumq = 0. |
|
77 | sumq = 0. | |
78 |
|
78 | |||
79 | j = 0 |
|
79 | j = 0 | |
80 |
|
80 | |||
81 | cont = 1 |
|
81 | cont = 1 | |
82 |
|
82 | |||
83 | while((cont==1)and(j<lenOfData)): |
|
83 | while((cont==1)and(j<lenOfData)): | |
84 |
|
84 | |||
85 | sump += sortdata[j] |
|
85 | sump += sortdata[j] | |
86 |
|
86 | |||
87 | sumq += sortdata[j]**2 |
|
87 | sumq += sortdata[j]**2 | |
88 |
|
88 | |||
89 | j += 1 |
|
|||
90 |
|
||||
91 | if j > nums_min: |
|
89 | if j > nums_min: | |
92 | rtest = float(j)/(j-1) + 1.0/navg |
|
90 | rtest = float(j)/(j-1) + 1.0/navg | |
93 | if ((sumq*j) > (rtest*sump**2)): |
|
91 | if ((sumq*j) > (rtest*sump**2)): | |
94 | j = j - 1 |
|
92 | j = j - 1 | |
95 | sump = sump - sortdata[j] |
|
93 | sump = sump - sortdata[j] | |
96 | sumq = sumq - sortdata[j]**2 |
|
94 | sumq = sumq - sortdata[j]**2 | |
97 | cont = 0 |
|
95 | cont = 0 | |
98 |
|
96 | |||
|
97 | j += 1 | |||
|
98 | ||||
99 | lnoise = sump /j |
|
99 | lnoise = sump /j | |
100 | stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1)) |
|
100 | stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1)) | |
101 | return lnoise |
|
101 | return lnoise | |
102 |
|
102 | |||
103 | class Beam: |
|
103 | class Beam: | |
104 | def __init__(self): |
|
104 | def __init__(self): | |
105 | self.codeList = [] |
|
105 | self.codeList = [] | |
106 | self.azimuthList = [] |
|
106 | self.azimuthList = [] | |
107 | self.zenithList = [] |
|
107 | self.zenithList = [] | |
108 |
|
108 | |||
109 | class GenericData(object): |
|
109 | class GenericData(object): | |
110 |
|
110 | |||
111 | flagNoData = True |
|
111 | flagNoData = True | |
112 |
|
112 | |||
113 | def __init__(self): |
|
113 | def __init__(self): | |
114 |
|
114 | |||
115 | raise ValueError, "This class has not been implemented" |
|
115 | raise ValueError, "This class has not been implemented" | |
116 |
|
116 | |||
117 | def copy(self, inputObj=None): |
|
117 | def copy(self, inputObj=None): | |
118 |
|
118 | |||
119 | if inputObj == None: |
|
119 | if inputObj == None: | |
120 | return copy.deepcopy(self) |
|
120 | return copy.deepcopy(self) | |
121 |
|
121 | |||
122 | for key in inputObj.__dict__.keys(): |
|
122 | for key in inputObj.__dict__.keys(): | |
123 | self.__dict__[key] = inputObj.__dict__[key] |
|
123 | self.__dict__[key] = inputObj.__dict__[key] | |
124 |
|
124 | |||
125 | def deepcopy(self): |
|
125 | def deepcopy(self): | |
126 |
|
126 | |||
127 | return copy.deepcopy(self) |
|
127 | return copy.deepcopy(self) | |
128 |
|
128 | |||
129 | def isEmpty(self): |
|
129 | def isEmpty(self): | |
130 |
|
130 | |||
131 | return self.flagNoData |
|
131 | return self.flagNoData | |
132 |
|
132 | |||
133 | class JROData(GenericData): |
|
133 | class JROData(GenericData): | |
134 |
|
134 | |||
135 | # m_BasicHeader = BasicHeader() |
|
135 | # m_BasicHeader = BasicHeader() | |
136 | # m_ProcessingHeader = ProcessingHeader() |
|
136 | # m_ProcessingHeader = ProcessingHeader() | |
137 |
|
137 | |||
138 | systemHeaderObj = SystemHeader() |
|
138 | systemHeaderObj = SystemHeader() | |
139 |
|
139 | |||
140 | radarControllerHeaderObj = RadarControllerHeader() |
|
140 | radarControllerHeaderObj = RadarControllerHeader() | |
141 |
|
141 | |||
142 | # data = None |
|
142 | # data = None | |
143 |
|
143 | |||
144 | type = None |
|
144 | type = None | |
145 |
|
145 | |||
146 | datatype = None #dtype but in string |
|
146 | datatype = None #dtype but in string | |
147 |
|
147 | |||
148 | # dtype = None |
|
148 | # dtype = None | |
149 |
|
149 | |||
150 | # nChannels = None |
|
150 | # nChannels = None | |
151 |
|
151 | |||
152 | # nHeights = None |
|
152 | # nHeights = None | |
153 |
|
153 | |||
154 | nProfiles = None |
|
154 | nProfiles = None | |
155 |
|
155 | |||
156 | heightList = None |
|
156 | heightList = None | |
157 |
|
157 | |||
158 | channelList = None |
|
158 | channelList = None | |
159 |
|
159 | |||
160 | flagDiscontinuousBlock = False |
|
160 | flagDiscontinuousBlock = False | |
161 |
|
161 | |||
162 | useLocalTime = False |
|
162 | useLocalTime = False | |
163 |
|
163 | |||
164 | utctime = None |
|
164 | utctime = None | |
165 |
|
165 | |||
166 | timeZone = None |
|
166 | timeZone = None | |
167 |
|
167 | |||
168 | dstFlag = None |
|
168 | dstFlag = None | |
169 |
|
169 | |||
170 | errorCount = None |
|
170 | errorCount = None | |
171 |
|
171 | |||
172 | blocksize = None |
|
172 | blocksize = None | |
173 |
|
173 | |||
174 | # nCode = None |
|
174 | # nCode = None | |
175 | # |
|
175 | # | |
176 | # nBaud = None |
|
176 | # nBaud = None | |
177 | # |
|
177 | # | |
178 | # code = None |
|
178 | # code = None | |
179 |
|
179 | |||
180 | flagDecodeData = False #asumo q la data no esta decodificada |
|
180 | flagDecodeData = False #asumo q la data no esta decodificada | |
181 |
|
181 | |||
182 | flagDeflipData = False #asumo q la data no esta sin flip |
|
182 | flagDeflipData = False #asumo q la data no esta sin flip | |
183 |
|
183 | |||
184 | flagShiftFFT = False |
|
184 | flagShiftFFT = False | |
185 |
|
185 | |||
186 | # ippSeconds = None |
|
186 | # ippSeconds = None | |
187 |
|
187 | |||
188 | # timeInterval = None |
|
188 | # timeInterval = None | |
189 |
|
189 | |||
190 | nCohInt = None |
|
190 | nCohInt = None | |
191 |
|
191 | |||
192 | # noise = None |
|
192 | # noise = None | |
193 |
|
193 | |||
194 | windowOfFilter = 1 |
|
194 | windowOfFilter = 1 | |
195 |
|
195 | |||
196 | #Speed of ligth |
|
196 | #Speed of ligth | |
197 | C = 3e8 |
|
197 | C = 3e8 | |
198 |
|
198 | |||
199 | frequency = 49.92e6 |
|
199 | frequency = 49.92e6 | |
200 |
|
200 | |||
201 | realtime = False |
|
201 | realtime = False | |
202 |
|
202 | |||
203 | beacon_heiIndexList = None |
|
203 | beacon_heiIndexList = None | |
204 |
|
204 | |||
205 | last_block = None |
|
205 | last_block = None | |
206 |
|
206 | |||
207 | blocknow = None |
|
207 | blocknow = None | |
208 |
|
208 | |||
209 | azimuth = None |
|
209 | azimuth = None | |
210 |
|
210 | |||
211 | zenith = None |
|
211 | zenith = None | |
212 |
|
212 | |||
213 | beam = Beam() |
|
213 | beam = Beam() | |
214 |
|
214 | |||
215 | profileIndex = None |
|
215 | profileIndex = None | |
216 |
|
216 | |||
217 | def __init__(self): |
|
217 | def __init__(self): | |
218 |
|
218 | |||
219 | raise ValueError, "This class has not been implemented" |
|
219 | raise ValueError, "This class has not been implemented" | |
220 |
|
220 | |||
221 | def getNoise(self): |
|
221 | def getNoise(self): | |
222 |
|
222 | |||
223 | raise ValueError, "Not implemented" |
|
223 | raise ValueError, "Not implemented" | |
224 |
|
224 | |||
225 | def getNChannels(self): |
|
225 | def getNChannels(self): | |
226 |
|
226 | |||
227 | return len(self.channelList) |
|
227 | return len(self.channelList) | |
228 |
|
228 | |||
229 | def getChannelIndexList(self): |
|
229 | def getChannelIndexList(self): | |
230 |
|
230 | |||
231 | return range(self.nChannels) |
|
231 | return range(self.nChannels) | |
232 |
|
232 | |||
233 | def getNHeights(self): |
|
233 | def getNHeights(self): | |
234 |
|
234 | |||
235 | return len(self.heightList) |
|
235 | return len(self.heightList) | |
236 |
|
236 | |||
237 | def getHeiRange(self, extrapoints=0): |
|
237 | def getHeiRange(self, extrapoints=0): | |
238 |
|
238 | |||
239 | heis = self.heightList |
|
239 | heis = self.heightList | |
240 | # deltah = self.heightList[1] - self.heightList[0] |
|
240 | # deltah = self.heightList[1] - self.heightList[0] | |
241 | # |
|
241 | # | |
242 | # heis.append(self.heightList[-1]) |
|
242 | # heis.append(self.heightList[-1]) | |
243 |
|
243 | |||
244 | return heis |
|
244 | return heis | |
245 |
|
245 | |||
246 | def getltctime(self): |
|
246 | def getltctime(self): | |
247 |
|
247 | |||
248 | if self.useLocalTime: |
|
248 | if self.useLocalTime: | |
249 | return self.utctime - self.timeZone*60 |
|
249 | return self.utctime - self.timeZone*60 | |
250 |
|
250 | |||
251 | return self.utctime |
|
251 | return self.utctime | |
252 |
|
252 | |||
253 | def getDatatime(self): |
|
253 | def getDatatime(self): | |
254 |
|
254 | |||
255 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
255 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) | |
256 | return datatimeValue |
|
256 | return datatimeValue | |
257 |
|
257 | |||
258 | def getTimeRange(self): |
|
258 | def getTimeRange(self): | |
259 |
|
259 | |||
260 | datatime = [] |
|
260 | datatime = [] | |
261 |
|
261 | |||
262 | datatime.append(self.ltctime) |
|
262 | datatime.append(self.ltctime) | |
263 | datatime.append(self.ltctime + self.timeInterval+60) |
|
263 | datatime.append(self.ltctime + self.timeInterval+60) | |
264 |
|
264 | |||
265 | datatime = numpy.array(datatime) |
|
265 | datatime = numpy.array(datatime) | |
266 |
|
266 | |||
267 | return datatime |
|
267 | return datatime | |
268 |
|
268 | |||
269 | def getFmax(self): |
|
269 | def getFmax(self): | |
270 |
|
270 | |||
271 | PRF = 1./(self.ippSeconds * self.nCohInt) |
|
271 | PRF = 1./(self.ippSeconds * self.nCohInt) | |
272 |
|
272 | |||
273 | fmax = PRF/2. |
|
273 | fmax = PRF/2. | |
274 |
|
274 | |||
275 | return fmax |
|
275 | return fmax | |
276 |
|
276 | |||
277 | def getVmax(self): |
|
277 | def getVmax(self): | |
278 |
|
278 | |||
279 | _lambda = self.C/self.frequency |
|
279 | _lambda = self.C/self.frequency | |
280 |
|
280 | |||
281 | vmax = self.getFmax() * _lambda |
|
281 | vmax = self.getFmax() * _lambda | |
282 |
|
282 | |||
283 | return vmax |
|
283 | return vmax | |
284 |
|
284 | |||
285 | def get_ippSeconds(self): |
|
285 | def get_ippSeconds(self): | |
286 | ''' |
|
286 | ''' | |
287 | ''' |
|
287 | ''' | |
288 | return self.radarControllerHeaderObj.ippSeconds |
|
288 | return self.radarControllerHeaderObj.ippSeconds | |
289 |
|
289 | |||
290 | def set_ippSeconds(self, ippSeconds): |
|
290 | def set_ippSeconds(self, ippSeconds): | |
291 | ''' |
|
291 | ''' | |
292 | ''' |
|
292 | ''' | |
293 |
|
293 | |||
294 | self.radarControllerHeaderObj.ippSeconds = ippSeconds |
|
294 | self.radarControllerHeaderObj.ippSeconds = ippSeconds | |
295 |
|
295 | |||
296 | return |
|
296 | return | |
297 |
|
297 | |||
298 | def get_dtype(self): |
|
298 | def get_dtype(self): | |
299 | ''' |
|
299 | ''' | |
300 | ''' |
|
300 | ''' | |
301 | return getNumpyDtype(self.datatype) |
|
301 | return getNumpyDtype(self.datatype) | |
302 |
|
302 | |||
303 | def set_dtype(self, numpyDtype): |
|
303 | def set_dtype(self, numpyDtype): | |
304 | ''' |
|
304 | ''' | |
305 | ''' |
|
305 | ''' | |
306 |
|
306 | |||
307 | self.datatype = getDataTypeCode(numpyDtype) |
|
307 | self.datatype = getDataTypeCode(numpyDtype) | |
308 |
|
308 | |||
309 | def get_code(self): |
|
309 | def get_code(self): | |
310 | ''' |
|
310 | ''' | |
311 | ''' |
|
311 | ''' | |
312 | return self.radarControllerHeaderObj.code |
|
312 | return self.radarControllerHeaderObj.code | |
313 |
|
313 | |||
314 | def set_code(self, code): |
|
314 | def set_code(self, code): | |
315 | ''' |
|
315 | ''' | |
316 | ''' |
|
316 | ''' | |
317 | self.radarControllerHeaderObj.code = code |
|
317 | self.radarControllerHeaderObj.code = code | |
318 |
|
318 | |||
319 | return |
|
319 | return | |
320 |
|
320 | |||
321 | def get_ncode(self): |
|
321 | def get_ncode(self): | |
322 | ''' |
|
322 | ''' | |
323 | ''' |
|
323 | ''' | |
324 | return self.radarControllerHeaderObj.nCode |
|
324 | return self.radarControllerHeaderObj.nCode | |
325 |
|
325 | |||
326 | def set_ncode(self, nCode): |
|
326 | def set_ncode(self, nCode): | |
327 | ''' |
|
327 | ''' | |
328 | ''' |
|
328 | ''' | |
329 | self.radarControllerHeaderObj.nCode = nCode |
|
329 | self.radarControllerHeaderObj.nCode = nCode | |
330 |
|
330 | |||
331 | return |
|
331 | return | |
332 |
|
332 | |||
333 | def get_nbaud(self): |
|
333 | def get_nbaud(self): | |
334 | ''' |
|
334 | ''' | |
335 | ''' |
|
335 | ''' | |
336 | return self.radarControllerHeaderObj.nBaud |
|
336 | return self.radarControllerHeaderObj.nBaud | |
337 |
|
337 | |||
338 | def set_nbaud(self, nBaud): |
|
338 | def set_nbaud(self, nBaud): | |
339 | ''' |
|
339 | ''' | |
340 | ''' |
|
340 | ''' | |
341 | self.radarControllerHeaderObj.nBaud = nBaud |
|
341 | self.radarControllerHeaderObj.nBaud = nBaud | |
342 |
|
342 | |||
343 | return |
|
343 | return | |
344 | # def getTimeInterval(self): |
|
344 | # def getTimeInterval(self): | |
345 | # |
|
345 | # | |
346 | # raise IOError, "This method should be implemented inside each Class" |
|
346 | # raise IOError, "This method should be implemented inside each Class" | |
347 |
|
347 | |||
348 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
348 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
349 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
349 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
350 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
350 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
351 | #noise = property(getNoise, "I'm the 'nHeights' property.") |
|
351 | #noise = property(getNoise, "I'm the 'nHeights' property.") | |
352 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
352 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
353 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
353 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
354 | ippSeconds = property(get_ippSeconds, set_ippSeconds) |
|
354 | ippSeconds = property(get_ippSeconds, set_ippSeconds) | |
355 | dtype = property(get_dtype, set_dtype) |
|
355 | dtype = property(get_dtype, set_dtype) | |
356 | # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
356 | # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
357 | code = property(get_code, set_code) |
|
357 | code = property(get_code, set_code) | |
358 | nCode = property(get_ncode, set_ncode) |
|
358 | nCode = property(get_ncode, set_ncode) | |
359 | nBaud = property(get_nbaud, set_nbaud) |
|
359 | nBaud = property(get_nbaud, set_nbaud) | |
360 |
|
360 | |||
361 | class Voltage(JROData): |
|
361 | class Voltage(JROData): | |
362 |
|
362 | |||
363 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
363 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
364 | data = None |
|
364 | data = None | |
365 |
|
365 | |||
366 | def __init__(self): |
|
366 | def __init__(self): | |
367 | ''' |
|
367 | ''' | |
368 | Constructor |
|
368 | Constructor | |
369 | ''' |
|
369 | ''' | |
370 |
|
370 | |||
371 | self.useLocalTime = True |
|
371 | self.useLocalTime = True | |
372 |
|
372 | |||
373 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
373 | self.radarControllerHeaderObj = RadarControllerHeader() | |
374 |
|
374 | |||
375 | self.systemHeaderObj = SystemHeader() |
|
375 | self.systemHeaderObj = SystemHeader() | |
376 |
|
376 | |||
377 | self.type = "Voltage" |
|
377 | self.type = "Voltage" | |
378 |
|
378 | |||
379 | self.data = None |
|
379 | self.data = None | |
380 |
|
380 | |||
381 | # self.dtype = None |
|
381 | # self.dtype = None | |
382 |
|
382 | |||
383 | # self.nChannels = 0 |
|
383 | # self.nChannels = 0 | |
384 |
|
384 | |||
385 | # self.nHeights = 0 |
|
385 | # self.nHeights = 0 | |
386 |
|
386 | |||
387 | self.nProfiles = None |
|
387 | self.nProfiles = None | |
388 |
|
388 | |||
389 | self.heightList = None |
|
389 | self.heightList = None | |
390 |
|
390 | |||
391 | self.channelList = None |
|
391 | self.channelList = None | |
392 |
|
392 | |||
393 | # self.channelIndexList = None |
|
393 | # self.channelIndexList = None | |
394 |
|
394 | |||
395 | self.flagNoData = True |
|
395 | self.flagNoData = True | |
396 |
|
396 | |||
397 | self.flagDiscontinuousBlock = False |
|
397 | self.flagDiscontinuousBlock = False | |
398 |
|
398 | |||
399 | self.utctime = None |
|
399 | self.utctime = None | |
400 |
|
400 | |||
401 | self.timeZone = None |
|
401 | self.timeZone = None | |
402 |
|
402 | |||
403 | self.dstFlag = None |
|
403 | self.dstFlag = None | |
404 |
|
404 | |||
405 | self.errorCount = None |
|
405 | self.errorCount = None | |
406 |
|
406 | |||
407 | self.nCohInt = None |
|
407 | self.nCohInt = None | |
408 |
|
408 | |||
409 | self.blocksize = None |
|
409 | self.blocksize = None | |
410 |
|
410 | |||
411 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
411 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
412 |
|
412 | |||
413 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
413 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
414 |
|
414 | |||
415 | self.flagShiftFFT = False |
|
415 | self.flagShiftFFT = False | |
416 |
|
416 | |||
417 | self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil |
|
417 | self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil | |
418 |
|
418 | |||
419 | self.profileIndex = 0 |
|
419 | self.profileIndex = 0 | |
420 |
|
420 | |||
421 | def getNoisebyHildebrand(self, channel = None): |
|
421 | def getNoisebyHildebrand(self, channel = None): | |
422 | """ |
|
422 | """ | |
423 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
423 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
424 |
|
424 | |||
425 | Return: |
|
425 | Return: | |
426 | noiselevel |
|
426 | noiselevel | |
427 | """ |
|
427 | """ | |
428 |
|
428 | |||
429 | if channel != None: |
|
429 | if channel != None: | |
430 | data = self.data[channel] |
|
430 | data = self.data[channel] | |
431 | nChannels = 1 |
|
431 | nChannels = 1 | |
432 | else: |
|
432 | else: | |
433 | data = self.data |
|
433 | data = self.data | |
434 | nChannels = self.nChannels |
|
434 | nChannels = self.nChannels | |
435 |
|
435 | |||
436 | noise = numpy.zeros(nChannels) |
|
436 | noise = numpy.zeros(nChannels) | |
437 | power = data * numpy.conjugate(data) |
|
437 | power = data * numpy.conjugate(data) | |
438 |
|
438 | |||
439 | for thisChannel in range(nChannels): |
|
439 | for thisChannel in range(nChannels): | |
440 | if nChannels == 1: |
|
440 | if nChannels == 1: | |
441 | daux = power[:].real |
|
441 | daux = power[:].real | |
442 | else: |
|
442 | else: | |
443 | daux = power[thisChannel,:].real |
|
443 | daux = power[thisChannel,:].real | |
444 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) |
|
444 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) | |
445 |
|
445 | |||
446 | return noise |
|
446 | return noise | |
447 |
|
447 | |||
448 | def getNoise(self, type = 1, channel = None): |
|
448 | def getNoise(self, type = 1, channel = None): | |
449 |
|
449 | |||
450 | if type == 1: |
|
450 | if type == 1: | |
451 | noise = self.getNoisebyHildebrand(channel) |
|
451 | noise = self.getNoisebyHildebrand(channel) | |
452 |
|
452 | |||
453 | return 10*numpy.log10(noise) |
|
453 | return 10*numpy.log10(noise) | |
454 |
|
454 | |||
455 | def getPower(self, channel = None): |
|
455 | def getPower(self, channel = None): | |
456 |
|
456 | |||
457 | if channel != None: |
|
457 | if channel != None: | |
458 | data = self.data[channel] |
|
458 | data = self.data[channel] | |
459 | else: |
|
459 | else: | |
460 | data = self.data |
|
460 | data = self.data | |
461 |
|
461 | |||
462 | power = data * numpy.conjugate(data) |
|
462 | power = data * numpy.conjugate(data) | |
463 |
|
463 | |||
464 | return 10*numpy.log10(power.real) |
|
464 | return 10*numpy.log10(power.real) | |
465 |
|
465 | |||
466 | def getTimeInterval(self): |
|
466 | def getTimeInterval(self): | |
467 |
|
467 | |||
468 | timeInterval = self.ippSeconds * self.nCohInt |
|
468 | timeInterval = self.ippSeconds * self.nCohInt | |
469 |
|
469 | |||
470 | return timeInterval |
|
470 | return timeInterval | |
471 |
|
471 | |||
472 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
472 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
473 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
473 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
474 |
|
474 | |||
475 | class Spectra(JROData): |
|
475 | class Spectra(JROData): | |
476 |
|
476 | |||
477 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) |
|
477 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) | |
478 | data_spc = None |
|
478 | data_spc = None | |
479 |
|
479 | |||
480 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) |
|
480 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) | |
481 | data_cspc = None |
|
481 | data_cspc = None | |
482 |
|
482 | |||
483 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
483 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
484 | data_dc = None |
|
484 | data_dc = None | |
485 |
|
485 | |||
486 | nFFTPoints = None |
|
486 | nFFTPoints = None | |
487 |
|
487 | |||
488 | # nPairs = None |
|
488 | # nPairs = None | |
489 |
|
489 | |||
490 | pairsList = None |
|
490 | pairsList = None | |
491 |
|
491 | |||
492 | nIncohInt = None |
|
492 | nIncohInt = None | |
493 |
|
493 | |||
494 | wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia |
|
494 | wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia | |
495 |
|
495 | |||
496 | nCohInt = None #se requiere para determinar el valor de timeInterval |
|
496 | nCohInt = None #se requiere para determinar el valor de timeInterval | |
497 |
|
497 | |||
498 | ippFactor = None |
|
498 | ippFactor = None | |
499 |
|
499 | |||
500 | profileIndex = 0 |
|
500 | profileIndex = 0 | |
501 |
|
501 | |||
502 | def __init__(self): |
|
502 | def __init__(self): | |
503 | ''' |
|
503 | ''' | |
504 | Constructor |
|
504 | Constructor | |
505 | ''' |
|
505 | ''' | |
506 |
|
506 | |||
507 | self.useLocalTime = True |
|
507 | self.useLocalTime = True | |
508 |
|
508 | |||
509 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
509 | self.radarControllerHeaderObj = RadarControllerHeader() | |
510 |
|
510 | |||
511 | self.systemHeaderObj = SystemHeader() |
|
511 | self.systemHeaderObj = SystemHeader() | |
512 |
|
512 | |||
513 | self.type = "Spectra" |
|
513 | self.type = "Spectra" | |
514 |
|
514 | |||
515 | # self.data = None |
|
515 | # self.data = None | |
516 |
|
516 | |||
517 | # self.dtype = None |
|
517 | # self.dtype = None | |
518 |
|
518 | |||
519 | # self.nChannels = 0 |
|
519 | # self.nChannels = 0 | |
520 |
|
520 | |||
521 | # self.nHeights = 0 |
|
521 | # self.nHeights = 0 | |
522 |
|
522 | |||
523 | self.nProfiles = None |
|
523 | self.nProfiles = None | |
524 |
|
524 | |||
525 | self.heightList = None |
|
525 | self.heightList = None | |
526 |
|
526 | |||
527 | self.channelList = None |
|
527 | self.channelList = None | |
528 |
|
528 | |||
529 | # self.channelIndexList = None |
|
529 | # self.channelIndexList = None | |
530 |
|
530 | |||
531 | self.pairsList = None |
|
531 | self.pairsList = None | |
532 |
|
532 | |||
533 | self.flagNoData = True |
|
533 | self.flagNoData = True | |
534 |
|
534 | |||
535 | self.flagDiscontinuousBlock = False |
|
535 | self.flagDiscontinuousBlock = False | |
536 |
|
536 | |||
537 | self.utctime = None |
|
537 | self.utctime = None | |
538 |
|
538 | |||
539 | self.nCohInt = None |
|
539 | self.nCohInt = None | |
540 |
|
540 | |||
541 | self.nIncohInt = None |
|
541 | self.nIncohInt = None | |
542 |
|
542 | |||
543 | self.blocksize = None |
|
543 | self.blocksize = None | |
544 |
|
544 | |||
545 | self.nFFTPoints = None |
|
545 | self.nFFTPoints = None | |
546 |
|
546 | |||
547 | self.wavelength = None |
|
547 | self.wavelength = None | |
548 |
|
548 | |||
549 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
549 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
550 |
|
550 | |||
551 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
551 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
552 |
|
552 | |||
553 | self.flagShiftFFT = False |
|
553 | self.flagShiftFFT = False | |
554 |
|
554 | |||
555 | self.ippFactor = 1 |
|
555 | self.ippFactor = 1 | |
556 |
|
556 | |||
557 | #self.noise = None |
|
557 | #self.noise = None | |
558 |
|
558 | |||
559 | self.beacon_heiIndexList = [] |
|
559 | self.beacon_heiIndexList = [] | |
560 |
|
560 | |||
561 | self.noise_estimation = None |
|
561 | self.noise_estimation = None | |
562 |
|
562 | |||
563 |
|
563 | |||
564 | def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): |
|
564 | def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): | |
565 | """ |
|
565 | """ | |
566 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
566 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
567 |
|
567 | |||
568 | Return: |
|
568 | Return: | |
569 | noiselevel |
|
569 | noiselevel | |
570 | """ |
|
570 | """ | |
571 |
|
571 | |||
572 | noise = numpy.zeros(self.nChannels) |
|
572 | noise = numpy.zeros(self.nChannels) | |
573 |
|
573 | |||
574 | for channel in range(self.nChannels): |
|
574 | for channel in range(self.nChannels): | |
575 | daux = self.data_spc[channel,xmin_index:xmax_index,ymin_index:ymax_index] |
|
575 | daux = self.data_spc[channel,xmin_index:xmax_index,ymin_index:ymax_index] | |
576 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) |
|
576 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) | |
577 |
|
577 | |||
578 | return noise |
|
578 | return noise | |
579 |
|
579 | |||
580 | def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): |
|
580 | def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): | |
581 |
|
581 | |||
582 | if self.noise_estimation != None: |
|
582 | if self.noise_estimation != None: | |
583 | return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py |
|
583 | return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py | |
584 | else: |
|
584 | else: | |
585 | noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index) |
|
585 | noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index) | |
586 | return noise |
|
586 | return noise | |
587 |
|
587 | |||
588 |
|
588 | |||
589 | def getFreqRange(self, extrapoints=0): |
|
589 | def getFreqRange(self, extrapoints=0): | |
590 |
|
590 | |||
591 | deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor) |
|
591 | deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor) | |
592 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 |
|
592 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 | |
593 |
|
593 | |||
594 | return freqrange |
|
594 | return freqrange | |
595 |
|
595 | |||
596 | def getVelRange(self, extrapoints=0): |
|
596 | def getVelRange(self, extrapoints=0): | |
597 |
|
597 | |||
598 | deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor) |
|
598 | deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor) | |
599 | velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2 |
|
599 | velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2 | |
600 |
|
600 | |||
601 | return velrange |
|
601 | return velrange | |
602 |
|
602 | |||
603 | def getNPairs(self): |
|
603 | def getNPairs(self): | |
604 |
|
604 | |||
605 | return len(self.pairsList) |
|
605 | return len(self.pairsList) | |
606 |
|
606 | |||
607 | def getPairsIndexList(self): |
|
607 | def getPairsIndexList(self): | |
608 |
|
608 | |||
609 | return range(self.nPairs) |
|
609 | return range(self.nPairs) | |
610 |
|
610 | |||
611 | def getNormFactor(self): |
|
611 | def getNormFactor(self): | |
612 | pwcode = 1 |
|
612 | pwcode = 1 | |
613 | if self.flagDecodeData: |
|
613 | if self.flagDecodeData: | |
614 | pwcode = numpy.sum(self.code[0]**2) |
|
614 | pwcode = numpy.sum(self.code[0]**2) | |
615 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
615 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
616 | normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
616 | normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
617 |
|
617 | |||
618 | return normFactor |
|
618 | return normFactor | |
619 |
|
619 | |||
620 | def getFlagCspc(self): |
|
620 | def getFlagCspc(self): | |
621 |
|
621 | |||
622 | if self.data_cspc == None: |
|
622 | if self.data_cspc == None: | |
623 | return True |
|
623 | return True | |
624 |
|
624 | |||
625 | return False |
|
625 | return False | |
626 |
|
626 | |||
627 | def getFlagDc(self): |
|
627 | def getFlagDc(self): | |
628 |
|
628 | |||
629 | if self.data_dc == None: |
|
629 | if self.data_dc == None: | |
630 | return True |
|
630 | return True | |
631 |
|
631 | |||
632 | return False |
|
632 | return False | |
633 |
|
633 | |||
634 | def getTimeInterval(self): |
|
634 | def getTimeInterval(self): | |
635 |
|
635 | |||
636 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles |
|
636 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles | |
637 |
|
637 | |||
638 | return timeInterval |
|
638 | return timeInterval | |
639 |
|
639 | |||
640 | nPairs = property(getNPairs, "I'm the 'nPairs' property.") |
|
640 | nPairs = property(getNPairs, "I'm the 'nPairs' property.") | |
641 | pairsIndexList = property(getPairsIndexList, "I'm the 'pairsIndexList' property.") |
|
641 | pairsIndexList = property(getPairsIndexList, "I'm the 'pairsIndexList' property.") | |
642 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") |
|
642 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") | |
643 | flag_cspc = property(getFlagCspc) |
|
643 | flag_cspc = property(getFlagCspc) | |
644 | flag_dc = property(getFlagDc) |
|
644 | flag_dc = property(getFlagDc) | |
645 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
645 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
646 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
646 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
647 |
|
647 | |||
648 | class SpectraHeis(Spectra): |
|
648 | class SpectraHeis(Spectra): | |
649 |
|
649 | |||
650 | data_spc = None |
|
650 | data_spc = None | |
651 |
|
651 | |||
652 | data_cspc = None |
|
652 | data_cspc = None | |
653 |
|
653 | |||
654 | data_dc = None |
|
654 | data_dc = None | |
655 |
|
655 | |||
656 | nFFTPoints = None |
|
656 | nFFTPoints = None | |
657 |
|
657 | |||
658 | # nPairs = None |
|
658 | # nPairs = None | |
659 |
|
659 | |||
660 | pairsList = None |
|
660 | pairsList = None | |
661 |
|
661 | |||
662 | nCohInt = None |
|
662 | nCohInt = None | |
663 |
|
663 | |||
664 | nIncohInt = None |
|
664 | nIncohInt = None | |
665 |
|
665 | |||
666 | def __init__(self): |
|
666 | def __init__(self): | |
667 |
|
667 | |||
668 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
668 | self.radarControllerHeaderObj = RadarControllerHeader() | |
669 |
|
669 | |||
670 | self.systemHeaderObj = SystemHeader() |
|
670 | self.systemHeaderObj = SystemHeader() | |
671 |
|
671 | |||
672 | self.type = "SpectraHeis" |
|
672 | self.type = "SpectraHeis" | |
673 |
|
673 | |||
674 | # self.dtype = None |
|
674 | # self.dtype = None | |
675 |
|
675 | |||
676 | # self.nChannels = 0 |
|
676 | # self.nChannels = 0 | |
677 |
|
677 | |||
678 | # self.nHeights = 0 |
|
678 | # self.nHeights = 0 | |
679 |
|
679 | |||
680 | self.nProfiles = None |
|
680 | self.nProfiles = None | |
681 |
|
681 | |||
682 | self.heightList = None |
|
682 | self.heightList = None | |
683 |
|
683 | |||
684 | self.channelList = None |
|
684 | self.channelList = None | |
685 |
|
685 | |||
686 | # self.channelIndexList = None |
|
686 | # self.channelIndexList = None | |
687 |
|
687 | |||
688 | self.flagNoData = True |
|
688 | self.flagNoData = True | |
689 |
|
689 | |||
690 | self.flagDiscontinuousBlock = False |
|
690 | self.flagDiscontinuousBlock = False | |
691 |
|
691 | |||
692 | # self.nPairs = 0 |
|
692 | # self.nPairs = 0 | |
693 |
|
693 | |||
694 | self.utctime = None |
|
694 | self.utctime = None | |
695 |
|
695 | |||
696 | self.blocksize = None |
|
696 | self.blocksize = None | |
697 |
|
697 | |||
698 | self.profileIndex = 0 |
|
698 | self.profileIndex = 0 | |
699 |
|
699 | |||
700 | self.nCohInt = 1 |
|
700 | self.nCohInt = 1 | |
701 |
|
701 | |||
702 | self.nIncohInt = 1 |
|
702 | self.nIncohInt = 1 | |
703 |
|
703 | |||
704 | def getNormFactor(self): |
|
704 | def getNormFactor(self): | |
705 | pwcode = 1 |
|
705 | pwcode = 1 | |
706 | if self.flagDecodeData: |
|
706 | if self.flagDecodeData: | |
707 | pwcode = numpy.sum(self.code[0]**2) |
|
707 | pwcode = numpy.sum(self.code[0]**2) | |
708 |
|
708 | |||
709 | normFactor = self.nIncohInt*self.nCohInt*pwcode |
|
709 | normFactor = self.nIncohInt*self.nCohInt*pwcode | |
710 |
|
710 | |||
711 | return normFactor |
|
711 | return normFactor | |
712 |
|
712 | |||
713 | def getTimeInterval(self): |
|
713 | def getTimeInterval(self): | |
714 |
|
714 | |||
715 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
715 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
716 |
|
716 | |||
717 | return timeInterval |
|
717 | return timeInterval | |
718 |
|
718 | |||
719 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") |
|
719 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") | |
720 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
720 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
721 |
|
721 | |||
722 | class Fits(JROData): |
|
722 | class Fits(JROData): | |
723 |
|
723 | |||
724 | heightList = None |
|
724 | heightList = None | |
725 |
|
725 | |||
726 | channelList = None |
|
726 | channelList = None | |
727 |
|
727 | |||
728 | flagNoData = True |
|
728 | flagNoData = True | |
729 |
|
729 | |||
730 | flagDiscontinuousBlock = False |
|
730 | flagDiscontinuousBlock = False | |
731 |
|
731 | |||
732 | useLocalTime = False |
|
732 | useLocalTime = False | |
733 |
|
733 | |||
734 | utctime = None |
|
734 | utctime = None | |
735 |
|
735 | |||
736 | timeZone = None |
|
736 | timeZone = None | |
737 |
|
737 | |||
738 | # ippSeconds = None |
|
738 | # ippSeconds = None | |
739 |
|
739 | |||
740 | # timeInterval = None |
|
740 | # timeInterval = None | |
741 |
|
741 | |||
742 | nCohInt = None |
|
742 | nCohInt = None | |
743 |
|
743 | |||
744 | nIncohInt = None |
|
744 | nIncohInt = None | |
745 |
|
745 | |||
746 | noise = None |
|
746 | noise = None | |
747 |
|
747 | |||
748 | windowOfFilter = 1 |
|
748 | windowOfFilter = 1 | |
749 |
|
749 | |||
750 | #Speed of ligth |
|
750 | #Speed of ligth | |
751 | C = 3e8 |
|
751 | C = 3e8 | |
752 |
|
752 | |||
753 | frequency = 49.92e6 |
|
753 | frequency = 49.92e6 | |
754 |
|
754 | |||
755 | realtime = False |
|
755 | realtime = False | |
756 |
|
756 | |||
757 |
|
757 | |||
758 | def __init__(self): |
|
758 | def __init__(self): | |
759 |
|
759 | |||
760 | self.type = "Fits" |
|
760 | self.type = "Fits" | |
761 |
|
761 | |||
762 | self.nProfiles = None |
|
762 | self.nProfiles = None | |
763 |
|
763 | |||
764 | self.heightList = None |
|
764 | self.heightList = None | |
765 |
|
765 | |||
766 | self.channelList = None |
|
766 | self.channelList = None | |
767 |
|
767 | |||
768 | # self.channelIndexList = None |
|
768 | # self.channelIndexList = None | |
769 |
|
769 | |||
770 | self.flagNoData = True |
|
770 | self.flagNoData = True | |
771 |
|
771 | |||
772 | self.utctime = None |
|
772 | self.utctime = None | |
773 |
|
773 | |||
774 | self.nCohInt = 1 |
|
774 | self.nCohInt = 1 | |
775 |
|
775 | |||
776 | self.nIncohInt = 1 |
|
776 | self.nIncohInt = 1 | |
777 |
|
777 | |||
778 | self.useLocalTime = True |
|
778 | self.useLocalTime = True | |
779 |
|
779 | |||
780 | self.profileIndex = 0 |
|
780 | self.profileIndex = 0 | |
781 |
|
781 | |||
782 | # self.utctime = None |
|
782 | # self.utctime = None | |
783 | # self.timeZone = None |
|
783 | # self.timeZone = None | |
784 | # self.ltctime = None |
|
784 | # self.ltctime = None | |
785 | # self.timeInterval = None |
|
785 | # self.timeInterval = None | |
786 | # self.header = None |
|
786 | # self.header = None | |
787 | # self.data_header = None |
|
787 | # self.data_header = None | |
788 | # self.data = None |
|
788 | # self.data = None | |
789 | # self.datatime = None |
|
789 | # self.datatime = None | |
790 | # self.flagNoData = False |
|
790 | # self.flagNoData = False | |
791 | # self.expName = '' |
|
791 | # self.expName = '' | |
792 | # self.nChannels = None |
|
792 | # self.nChannels = None | |
793 | # self.nSamples = None |
|
793 | # self.nSamples = None | |
794 | # self.dataBlocksPerFile = None |
|
794 | # self.dataBlocksPerFile = None | |
795 | # self.comments = '' |
|
795 | # self.comments = '' | |
796 | # |
|
796 | # | |
797 |
|
797 | |||
798 |
|
798 | |||
799 | def getltctime(self): |
|
799 | def getltctime(self): | |
800 |
|
800 | |||
801 | if self.useLocalTime: |
|
801 | if self.useLocalTime: | |
802 | return self.utctime - self.timeZone*60 |
|
802 | return self.utctime - self.timeZone*60 | |
803 |
|
803 | |||
804 | return self.utctime |
|
804 | return self.utctime | |
805 |
|
805 | |||
806 | def getDatatime(self): |
|
806 | def getDatatime(self): | |
807 |
|
807 | |||
808 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
808 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) | |
809 | return datatime |
|
809 | return datatime | |
810 |
|
810 | |||
811 | def getTimeRange(self): |
|
811 | def getTimeRange(self): | |
812 |
|
812 | |||
813 | datatime = [] |
|
813 | datatime = [] | |
814 |
|
814 | |||
815 | datatime.append(self.ltctime) |
|
815 | datatime.append(self.ltctime) | |
816 | datatime.append(self.ltctime + self.timeInterval) |
|
816 | datatime.append(self.ltctime + self.timeInterval) | |
817 |
|
817 | |||
818 | datatime = numpy.array(datatime) |
|
818 | datatime = numpy.array(datatime) | |
819 |
|
819 | |||
820 | return datatime |
|
820 | return datatime | |
821 |
|
821 | |||
822 | def getHeiRange(self): |
|
822 | def getHeiRange(self): | |
823 |
|
823 | |||
824 | heis = self.heightList |
|
824 | heis = self.heightList | |
825 |
|
825 | |||
826 | return heis |
|
826 | return heis | |
827 |
|
827 | |||
828 | def isEmpty(self): |
|
828 | def isEmpty(self): | |
829 |
|
829 | |||
830 | return self.flagNoData |
|
830 | return self.flagNoData | |
831 |
|
831 | |||
832 | def getNHeights(self): |
|
832 | def getNHeights(self): | |
833 |
|
833 | |||
834 | return len(self.heightList) |
|
834 | return len(self.heightList) | |
835 |
|
835 | |||
836 | def getNChannels(self): |
|
836 | def getNChannels(self): | |
837 |
|
837 | |||
838 | return len(self.channelList) |
|
838 | return len(self.channelList) | |
839 |
|
839 | |||
840 | def getChannelIndexList(self): |
|
840 | def getChannelIndexList(self): | |
841 |
|
841 | |||
842 | return range(self.nChannels) |
|
842 | return range(self.nChannels) | |
843 |
|
843 | |||
844 | def getNoise(self, type = 1): |
|
844 | def getNoise(self, type = 1): | |
845 |
|
845 | |||
846 | #noise = numpy.zeros(self.nChannels) |
|
846 | #noise = numpy.zeros(self.nChannels) | |
847 |
|
847 | |||
848 | if type == 1: |
|
848 | if type == 1: | |
849 | noise = self.getNoisebyHildebrand() |
|
849 | noise = self.getNoisebyHildebrand() | |
850 |
|
850 | |||
851 | if type == 2: |
|
851 | if type == 2: | |
852 | noise = self.getNoisebySort() |
|
852 | noise = self.getNoisebySort() | |
853 |
|
853 | |||
854 | if type == 3: |
|
854 | if type == 3: | |
855 | noise = self.getNoisebyWindow() |
|
855 | noise = self.getNoisebyWindow() | |
856 |
|
856 | |||
857 | return noise |
|
857 | return noise | |
858 |
|
858 | |||
859 | def getTimeInterval(self): |
|
859 | def getTimeInterval(self): | |
860 |
|
860 | |||
861 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
861 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
862 |
|
862 | |||
863 | return timeInterval |
|
863 | return timeInterval | |
864 |
|
864 | |||
865 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
865 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
866 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
866 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
867 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
867 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
868 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
868 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
869 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
869 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
870 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
870 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
871 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
871 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
872 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
872 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
873 |
|
873 | |||
874 | class Correlation(JROData): |
|
874 | class Correlation(JROData): | |
875 |
|
875 | |||
876 | noise = None |
|
876 | noise = None | |
877 |
|
877 | |||
878 | SNR = None |
|
878 | SNR = None | |
879 |
|
879 | |||
880 | pairsAutoCorr = None #Pairs of Autocorrelation |
|
880 | pairsAutoCorr = None #Pairs of Autocorrelation | |
881 |
|
881 | |||
882 | #-------------------------------------------------- |
|
882 | #-------------------------------------------------- | |
883 |
|
883 | |||
884 | data_corr = None |
|
884 | data_corr = None | |
885 |
|
885 | |||
886 | data_volt = None |
|
886 | data_volt = None | |
887 |
|
887 | |||
888 | lagT = None # each element value is a profileIndex |
|
888 | lagT = None # each element value is a profileIndex | |
889 |
|
889 | |||
890 | lagR = None # each element value is in km |
|
890 | lagR = None # each element value is in km | |
891 |
|
891 | |||
892 | pairsList = None |
|
892 | pairsList = None | |
893 |
|
893 | |||
894 | calculateVelocity = None |
|
894 | calculateVelocity = None | |
895 |
|
895 | |||
896 | nPoints = None |
|
896 | nPoints = None | |
897 |
|
897 | |||
898 | nAvg = None |
|
898 | nAvg = None | |
899 |
|
899 | |||
900 | bufferSize = None |
|
900 | bufferSize = None | |
901 |
|
901 | |||
902 | def __init__(self): |
|
902 | def __init__(self): | |
903 | ''' |
|
903 | ''' | |
904 | Constructor |
|
904 | Constructor | |
905 | ''' |
|
905 | ''' | |
906 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
906 | self.radarControllerHeaderObj = RadarControllerHeader() | |
907 |
|
907 | |||
908 | self.systemHeaderObj = SystemHeader() |
|
908 | self.systemHeaderObj = SystemHeader() | |
909 |
|
909 | |||
910 | self.type = "Correlation" |
|
910 | self.type = "Correlation" | |
911 |
|
911 | |||
912 | self.data = None |
|
912 | self.data = None | |
913 |
|
913 | |||
914 | self.dtype = None |
|
914 | self.dtype = None | |
915 |
|
915 | |||
916 | self.nProfiles = None |
|
916 | self.nProfiles = None | |
917 |
|
917 | |||
918 | self.heightList = None |
|
918 | self.heightList = None | |
919 |
|
919 | |||
920 | self.channelList = None |
|
920 | self.channelList = None | |
921 |
|
921 | |||
922 | self.flagNoData = True |
|
922 | self.flagNoData = True | |
923 |
|
923 | |||
924 | self.flagDiscontinuousBlock = False |
|
924 | self.flagDiscontinuousBlock = False | |
925 |
|
925 | |||
926 | self.utctime = None |
|
926 | self.utctime = None | |
927 |
|
927 | |||
928 | self.timeZone = None |
|
928 | self.timeZone = None | |
929 |
|
929 | |||
930 | self.dstFlag = None |
|
930 | self.dstFlag = None | |
931 |
|
931 | |||
932 | self.errorCount = None |
|
932 | self.errorCount = None | |
933 |
|
933 | |||
934 | self.blocksize = None |
|
934 | self.blocksize = None | |
935 |
|
935 | |||
936 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
936 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
937 |
|
937 | |||
938 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
938 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
939 |
|
939 | |||
940 | self.pairsList = None |
|
940 | self.pairsList = None | |
941 |
|
941 | |||
942 | self.nPoints = None |
|
942 | self.nPoints = None | |
943 |
|
943 | |||
944 | def getLagTRange(self, extrapoints=0): |
|
944 | def getLagTRange(self, extrapoints=0): | |
945 |
|
945 | |||
946 | lagTRange = self.lagT |
|
946 | lagTRange = self.lagT | |
947 | diff = lagTRange[1] - lagTRange[0] |
|
947 | diff = lagTRange[1] - lagTRange[0] | |
948 | extra = numpy.arange(1,extrapoints + 1)*diff + lagTRange[-1] |
|
948 | extra = numpy.arange(1,extrapoints + 1)*diff + lagTRange[-1] | |
949 | lagTRange = numpy.hstack((lagTRange, extra)) |
|
949 | lagTRange = numpy.hstack((lagTRange, extra)) | |
950 |
|
950 | |||
951 | return lagTRange |
|
951 | return lagTRange | |
952 |
|
952 | |||
953 | def getLagRRange(self, extrapoints=0): |
|
953 | def getLagRRange(self, extrapoints=0): | |
954 |
|
954 | |||
955 | return self.lagR |
|
955 | return self.lagR | |
956 |
|
956 | |||
957 | def getPairsList(self): |
|
957 | def getPairsList(self): | |
958 |
|
958 | |||
959 | return self.pairsList |
|
959 | return self.pairsList | |
960 |
|
960 | |||
961 | def getCalculateVelocity(self): |
|
961 | def getCalculateVelocity(self): | |
962 |
|
962 | |||
963 | return self.calculateVelocity |
|
963 | return self.calculateVelocity | |
964 |
|
964 | |||
965 | def getNPoints(self): |
|
965 | def getNPoints(self): | |
966 |
|
966 | |||
967 | return self.nPoints |
|
967 | return self.nPoints | |
968 |
|
968 | |||
969 | def getNAvg(self): |
|
969 | def getNAvg(self): | |
970 |
|
970 | |||
971 | return self.nAvg |
|
971 | return self.nAvg | |
972 |
|
972 | |||
973 | def getBufferSize(self): |
|
973 | def getBufferSize(self): | |
974 |
|
974 | |||
975 | return self.bufferSize |
|
975 | return self.bufferSize | |
976 |
|
976 | |||
977 | def getPairsAutoCorr(self): |
|
977 | def getPairsAutoCorr(self): | |
978 | pairsList = self.pairsList |
|
978 | pairsList = self.pairsList | |
979 | pairsAutoCorr = numpy.zeros(self.nChannels, dtype = 'int')*numpy.nan |
|
979 | pairsAutoCorr = numpy.zeros(self.nChannels, dtype = 'int')*numpy.nan | |
980 |
|
980 | |||
981 | for l in range(len(pairsList)): |
|
981 | for l in range(len(pairsList)): | |
982 | firstChannel = pairsList[l][0] |
|
982 | firstChannel = pairsList[l][0] | |
983 | secondChannel = pairsList[l][1] |
|
983 | secondChannel = pairsList[l][1] | |
984 |
|
984 | |||
985 | #Obteniendo pares de Autocorrelacion |
|
985 | #Obteniendo pares de Autocorrelacion | |
986 | if firstChannel == secondChannel: |
|
986 | if firstChannel == secondChannel: | |
987 | pairsAutoCorr[firstChannel] = int(l) |
|
987 | pairsAutoCorr[firstChannel] = int(l) | |
988 |
|
988 | |||
989 | pairsAutoCorr = pairsAutoCorr.astype(int) |
|
989 | pairsAutoCorr = pairsAutoCorr.astype(int) | |
990 |
|
990 | |||
991 | return pairsAutoCorr |
|
991 | return pairsAutoCorr | |
992 |
|
992 | |||
993 | def getNoise(self, mode = 2): |
|
993 | def getNoise(self, mode = 2): | |
994 |
|
994 | |||
995 | indR = numpy.where(self.lagR == 0)[0][0] |
|
995 | indR = numpy.where(self.lagR == 0)[0][0] | |
996 | indT = numpy.where(self.lagT == 0)[0][0] |
|
996 | indT = numpy.where(self.lagT == 0)[0][0] | |
997 |
|
997 | |||
998 | jspectra0 = self.data_corr[:,:,indR,:] |
|
998 | jspectra0 = self.data_corr[:,:,indR,:] | |
999 | jspectra = copy.copy(jspectra0) |
|
999 | jspectra = copy.copy(jspectra0) | |
1000 |
|
1000 | |||
1001 | num_chan = jspectra.shape[0] |
|
1001 | num_chan = jspectra.shape[0] | |
1002 | num_hei = jspectra.shape[2] |
|
1002 | num_hei = jspectra.shape[2] | |
1003 |
|
1003 | |||
1004 | freq_dc = jspectra.shape[1]/2 |
|
1004 | freq_dc = jspectra.shape[1]/2 | |
1005 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc |
|
1005 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc | |
1006 |
|
1006 | |||
1007 | if ind_vel[0]<0: |
|
1007 | if ind_vel[0]<0: | |
1008 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof |
|
1008 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof | |
1009 |
|
1009 | |||
1010 | if mode == 1: |
|
1010 | if mode == 1: | |
1011 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION |
|
1011 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION | |
1012 |
|
1012 | |||
1013 | if mode == 2: |
|
1013 | if mode == 2: | |
1014 |
|
1014 | |||
1015 | vel = numpy.array([-2,-1,1,2]) |
|
1015 | vel = numpy.array([-2,-1,1,2]) | |
1016 | xx = numpy.zeros([4,4]) |
|
1016 | xx = numpy.zeros([4,4]) | |
1017 |
|
1017 | |||
1018 | for fil in range(4): |
|
1018 | for fil in range(4): | |
1019 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) |
|
1019 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) | |
1020 |
|
1020 | |||
1021 | xx_inv = numpy.linalg.inv(xx) |
|
1021 | xx_inv = numpy.linalg.inv(xx) | |
1022 | xx_aux = xx_inv[0,:] |
|
1022 | xx_aux = xx_inv[0,:] | |
1023 |
|
1023 | |||
1024 | for ich in range(num_chan): |
|
1024 | for ich in range(num_chan): | |
1025 | yy = jspectra[ich,ind_vel,:] |
|
1025 | yy = jspectra[ich,ind_vel,:] | |
1026 | jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy) |
|
1026 | jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy) | |
1027 |
|
1027 | |||
1028 | junkid = jspectra[ich,freq_dc,:]<=0 |
|
1028 | junkid = jspectra[ich,freq_dc,:]<=0 | |
1029 | cjunkid = sum(junkid) |
|
1029 | cjunkid = sum(junkid) | |
1030 |
|
1030 | |||
1031 | if cjunkid.any(): |
|
1031 | if cjunkid.any(): | |
1032 | jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2 |
|
1032 | jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2 | |
1033 |
|
1033 | |||
1034 | noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:] |
|
1034 | noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:] | |
1035 |
|
1035 | |||
1036 | return noise |
|
1036 | return noise | |
1037 |
|
1037 | |||
1038 | def getTimeInterval(self): |
|
1038 | def getTimeInterval(self): | |
1039 |
|
1039 | |||
1040 | timeInterval = self.ippSeconds * self.nCohInt * self.nPoints |
|
1040 | timeInterval = self.ippSeconds * self.nCohInt * self.nPoints | |
1041 |
|
1041 | |||
1042 | return timeInterval |
|
1042 | return timeInterval | |
1043 |
|
1043 | |||
1044 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
1044 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
1045 | # pairsList = property(getPairsList, "I'm the 'pairsList' property.") |
|
1045 | # pairsList = property(getPairsList, "I'm the 'pairsList' property.") | |
1046 | # nPoints = property(getNPoints, "I'm the 'nPoints' property.") |
|
1046 | # nPoints = property(getNPoints, "I'm the 'nPoints' property.") | |
1047 | calculateVelocity = property(getCalculateVelocity, "I'm the 'calculateVelocity' property.") |
|
1047 | calculateVelocity = property(getCalculateVelocity, "I'm the 'calculateVelocity' property.") | |
1048 | nAvg = property(getNAvg, "I'm the 'nAvg' property.") |
|
1048 | nAvg = property(getNAvg, "I'm the 'nAvg' property.") | |
1049 | bufferSize = property(getBufferSize, "I'm the 'bufferSize' property.") |
|
1049 | bufferSize = property(getBufferSize, "I'm the 'bufferSize' property.") | |
1050 |
|
1050 | |||
1051 |
|
1051 | |||
1052 | class Parameters(JROData): |
|
1052 | class Parameters(JROData): | |
1053 |
|
1053 | |||
1054 | #Information from previous data |
|
1054 | #Information from previous data | |
1055 |
|
1055 | |||
1056 | inputUnit = None #Type of data to be processed |
|
1056 | inputUnit = None #Type of data to be processed | |
1057 |
|
1057 | |||
1058 | operation = None #Type of operation to parametrize |
|
1058 | operation = None #Type of operation to parametrize | |
1059 |
|
1059 | |||
1060 | normFactor = None #Normalization Factor |
|
1060 | normFactor = None #Normalization Factor | |
1061 |
|
1061 | |||
1062 | groupList = None #List of Pairs, Groups, etc |
|
1062 | groupList = None #List of Pairs, Groups, etc | |
1063 |
|
1063 | |||
1064 | #Parameters |
|
1064 | #Parameters | |
1065 |
|
1065 | |||
1066 | data_param = None #Parameters obtained |
|
1066 | data_param = None #Parameters obtained | |
1067 |
|
1067 | |||
1068 | data_pre = None #Data Pre Parametrization |
|
1068 | data_pre = None #Data Pre Parametrization | |
1069 |
|
1069 | |||
1070 | data_SNR = None #Signal to Noise Ratio |
|
1070 | data_SNR = None #Signal to Noise Ratio | |
1071 |
|
1071 | |||
1072 | heightRange = None #Heights |
|
1072 | heightRange = None #Heights | |
1073 |
|
1073 | |||
1074 | abscissaRange = None #Abscissa, can be velocities, lags or time |
|
1074 | abscissaRange = None #Abscissa, can be velocities, lags or time | |
1075 |
|
1075 | |||
1076 | noise = None #Noise Potency |
|
1076 | noise = None #Noise Potency | |
1077 |
|
1077 | |||
1078 | # initUtcTime = None #Initial UTC time |
|
1078 | # initUtcTime = None #Initial UTC time | |
1079 |
|
1079 | |||
1080 | paramInterval = None #Time interval to calculate Parameters in seconds |
|
1080 | paramInterval = None #Time interval to calculate Parameters in seconds | |
1081 |
|
1081 | |||
1082 | #Fitting |
|
1082 | #Fitting | |
1083 |
|
1083 | |||
1084 | data_error = None #Error of the estimation |
|
1084 | data_error = None #Error of the estimation | |
1085 |
|
1085 | |||
1086 | constants = None |
|
1086 | constants = None | |
1087 |
|
1087 | |||
1088 | library = None |
|
1088 | library = None | |
1089 |
|
1089 | |||
1090 | #Output signal |
|
1090 | #Output signal | |
1091 |
|
1091 | |||
1092 | outputInterval = None #Time interval to calculate output signal in seconds |
|
1092 | outputInterval = None #Time interval to calculate output signal in seconds | |
1093 |
|
1093 | |||
1094 | data_output = None #Out signal |
|
1094 | data_output = None #Out signal | |
1095 |
|
1095 | |||
1096 | def __init__(self): |
|
1096 | def __init__(self): | |
1097 | ''' |
|
1097 | ''' | |
1098 | Constructor |
|
1098 | Constructor | |
1099 | ''' |
|
1099 | ''' | |
1100 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
1100 | self.radarControllerHeaderObj = RadarControllerHeader() | |
1101 |
|
1101 | |||
1102 | self.systemHeaderObj = SystemHeader() |
|
1102 | self.systemHeaderObj = SystemHeader() | |
1103 |
|
1103 | |||
1104 | self.type = "Parameters" |
|
1104 | self.type = "Parameters" | |
1105 |
|
1105 | |||
1106 | def getTimeRange1(self): |
|
1106 | def getTimeRange1(self): | |
1107 |
|
1107 | |||
1108 | datatime = [] |
|
1108 | datatime = [] | |
1109 |
|
1109 | |||
1110 | datatime.append(self.ltctime) |
|
1110 | datatime.append(self.ltctime) | |
1111 | datatime.append(self.ltctime + self.outputInterval - 1) |
|
1111 | datatime.append(self.ltctime + self.outputInterval - 1) | |
1112 |
|
1112 | |||
1113 | datatime = numpy.array(datatime) |
|
1113 | datatime = numpy.array(datatime) | |
1114 |
|
1114 | |||
1115 | return datatime |
|
1115 | return datatime |
@@ -1,653 +1,652 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jul 2, 2014 |
|
2 | Created on Jul 2, 2014 | |
3 |
|
3 | |||
4 | @author: roj-idl71 |
|
4 | @author: roj-idl71 | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import numpy |
|
7 | import numpy | |
8 |
|
8 | |||
9 | from jroIO_base import LOCALTIME, JRODataReader, JRODataWriter |
|
9 | from jroIO_base import LOCALTIME, JRODataReader, JRODataWriter | |
10 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation |
|
10 | from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation | |
11 | from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader |
|
11 | from schainpy.model.data.jroheaderIO import PROCFLAG, BasicHeader, SystemHeader, RadarControllerHeader, ProcessingHeader | |
12 | from schainpy.model.data.jrodata import Voltage |
|
12 | from schainpy.model.data.jrodata import Voltage | |
13 |
|
13 | |||
14 | class VoltageReader(JRODataReader, ProcessingUnit): |
|
14 | class VoltageReader(JRODataReader, ProcessingUnit): | |
15 | """ |
|
15 | """ | |
16 | Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura |
|
16 | Esta clase permite leer datos de voltage desde archivos en formato rawdata (.r). La lectura | |
17 | de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones: |
|
17 | de los datos siempre se realiza por bloques. Los datos leidos (array de 3 dimensiones: | |
18 | perfiles*alturas*canales) son almacenados en la variable "buffer". |
|
18 | perfiles*alturas*canales) son almacenados en la variable "buffer". | |
19 |
|
19 | |||
20 | perfiles * alturas * canales |
|
20 | perfiles * alturas * canales | |
21 |
|
21 | |||
22 | Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader, |
|
22 | Esta clase contiene instancias (objetos) de las clases BasicHeader, SystemHeader, | |
23 | RadarControllerHeader y Voltage. Los tres primeros se usan para almacenar informacion de la |
|
23 | RadarControllerHeader y Voltage. Los tres primeros se usan para almacenar informacion de la | |
24 | cabecera de datos (metadata), y el cuarto (Voltage) para obtener y almacenar un perfil de |
|
24 | cabecera de datos (metadata), y el cuarto (Voltage) para obtener y almacenar un perfil de | |
25 | datos desde el "buffer" cada vez que se ejecute el metodo "getData". |
|
25 | datos desde el "buffer" cada vez que se ejecute el metodo "getData". | |
26 |
|
26 | |||
27 | Example: |
|
27 | Example: | |
28 |
|
28 | |||
29 | dpath = "/home/myuser/data" |
|
29 | dpath = "/home/myuser/data" | |
30 |
|
30 | |||
31 | startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0) |
|
31 | startTime = datetime.datetime(2010,1,20,0,0,0,0,0,0) | |
32 |
|
32 | |||
33 | endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0) |
|
33 | endTime = datetime.datetime(2010,1,21,23,59,59,0,0,0) | |
34 |
|
34 | |||
35 | readerObj = VoltageReader() |
|
35 | readerObj = VoltageReader() | |
36 |
|
36 | |||
37 | readerObj.setup(dpath, startTime, endTime) |
|
37 | readerObj.setup(dpath, startTime, endTime) | |
38 |
|
38 | |||
39 | while(True): |
|
39 | while(True): | |
40 |
|
40 | |||
41 | #to get one profile |
|
41 | #to get one profile | |
42 | profile = readerObj.getData() |
|
42 | profile = readerObj.getData() | |
43 |
|
43 | |||
44 | #print the profile |
|
44 | #print the profile | |
45 | print profile |
|
45 | print profile | |
46 |
|
46 | |||
47 | #If you want to see all datablock |
|
47 | #If you want to see all datablock | |
48 | print readerObj.datablock |
|
48 | print readerObj.datablock | |
49 |
|
49 | |||
50 | if readerObj.flagNoMoreFiles: |
|
50 | if readerObj.flagNoMoreFiles: | |
51 | break |
|
51 | break | |
52 |
|
52 | |||
53 | """ |
|
53 | """ | |
54 |
|
54 | |||
55 | ext = ".r" |
|
55 | ext = ".r" | |
56 |
|
56 | |||
57 | optchar = "D" |
|
57 | optchar = "D" | |
58 | dataOut = None |
|
58 | dataOut = None | |
59 |
|
59 | |||
60 |
|
60 | |||
61 | def __init__(self): |
|
61 | def __init__(self): | |
62 | """ |
|
62 | """ | |
63 | Inicializador de la clase VoltageReader para la lectura de datos de voltage. |
|
63 | Inicializador de la clase VoltageReader para la lectura de datos de voltage. | |
64 |
|
64 | |||
65 | Input: |
|
65 | Input: | |
66 | dataOut : Objeto de la clase Voltage. Este objeto sera utilizado para |
|
66 | dataOut : Objeto de la clase Voltage. Este objeto sera utilizado para | |
67 | almacenar un perfil de datos cada vez que se haga un requerimiento |
|
67 | almacenar un perfil de datos cada vez que se haga un requerimiento | |
68 | (getData). El perfil sera obtenido a partir del buffer de datos, |
|
68 | (getData). El perfil sera obtenido a partir del buffer de datos, | |
69 | si el buffer esta vacio se hara un nuevo proceso de lectura de un |
|
69 | si el buffer esta vacio se hara un nuevo proceso de lectura de un | |
70 | bloque de datos. |
|
70 | bloque de datos. | |
71 | Si este parametro no es pasado se creara uno internamente. |
|
71 | Si este parametro no es pasado se creara uno internamente. | |
72 |
|
72 | |||
73 | Variables afectadas: |
|
73 | Variables afectadas: | |
74 | self.dataOut |
|
74 | self.dataOut | |
75 |
|
75 | |||
76 | Return: |
|
76 | Return: | |
77 | None |
|
77 | None | |
78 | """ |
|
78 | """ | |
79 |
|
79 | |||
80 | ProcessingUnit.__init__(self) |
|
80 | ProcessingUnit.__init__(self) | |
81 |
|
81 | |||
82 | self.isConfig = False |
|
82 | self.isConfig = False | |
83 |
|
83 | |||
84 | self.datablock = None |
|
84 | self.datablock = None | |
85 |
|
85 | |||
86 | self.utc = 0 |
|
86 | self.utc = 0 | |
87 |
|
87 | |||
88 | self.ext = ".r" |
|
88 | self.ext = ".r" | |
89 |
|
89 | |||
90 | self.optchar = "D" |
|
90 | self.optchar = "D" | |
91 |
|
91 | |||
92 | self.basicHeaderObj = BasicHeader(LOCALTIME) |
|
92 | self.basicHeaderObj = BasicHeader(LOCALTIME) | |
93 |
|
93 | |||
94 | self.systemHeaderObj = SystemHeader() |
|
94 | self.systemHeaderObj = SystemHeader() | |
95 |
|
95 | |||
96 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
96 | self.radarControllerHeaderObj = RadarControllerHeader() | |
97 |
|
97 | |||
98 | self.processingHeaderObj = ProcessingHeader() |
|
98 | self.processingHeaderObj = ProcessingHeader() | |
99 |
|
99 | |||
100 | self.online = 0 |
|
100 | self.online = 0 | |
101 |
|
101 | |||
102 | self.fp = None |
|
102 | self.fp = None | |
103 |
|
103 | |||
104 | self.idFile = None |
|
104 | self.idFile = None | |
105 |
|
105 | |||
106 | self.dtype = None |
|
106 | self.dtype = None | |
107 |
|
107 | |||
108 | self.fileSizeByHeader = None |
|
108 | self.fileSizeByHeader = None | |
109 |
|
109 | |||
110 | self.filenameList = [] |
|
110 | self.filenameList = [] | |
111 |
|
111 | |||
112 | self.filename = None |
|
112 | self.filename = None | |
113 |
|
113 | |||
114 | self.fileSize = None |
|
114 | self.fileSize = None | |
115 |
|
115 | |||
116 | self.firstHeaderSize = 0 |
|
116 | self.firstHeaderSize = 0 | |
117 |
|
117 | |||
118 | self.basicHeaderSize = 24 |
|
118 | self.basicHeaderSize = 24 | |
119 |
|
119 | |||
120 | self.pathList = [] |
|
120 | self.pathList = [] | |
121 |
|
121 | |||
122 | self.filenameList = [] |
|
122 | self.filenameList = [] | |
123 |
|
123 | |||
124 | self.lastUTTime = 0 |
|
124 | self.lastUTTime = 0 | |
125 |
|
125 | |||
126 | self.maxTimeStep = 30 |
|
126 | self.maxTimeStep = 30 | |
127 |
|
127 | |||
128 | self.flagNoMoreFiles = 0 |
|
128 | self.flagNoMoreFiles = 0 | |
129 |
|
129 | |||
130 | self.set = 0 |
|
130 | self.set = 0 | |
131 |
|
131 | |||
132 | self.path = None |
|
132 | self.path = None | |
133 |
|
133 | |||
134 | self.profileIndex = 2**32-1 |
|
134 | self.profileIndex = 2**32-1 | |
135 |
|
135 | |||
136 | self.delay = 3 #seconds |
|
136 | self.delay = 3 #seconds | |
137 |
|
137 | |||
138 | self.nTries = 3 #quantity tries |
|
138 | self.nTries = 3 #quantity tries | |
139 |
|
139 | |||
140 | self.nFiles = 3 #number of files for searching |
|
140 | self.nFiles = 3 #number of files for searching | |
141 |
|
141 | |||
142 | self.nReadBlocks = 0 |
|
142 | self.nReadBlocks = 0 | |
143 |
|
143 | |||
144 | self.flagIsNewFile = 1 |
|
144 | self.flagIsNewFile = 1 | |
145 |
|
145 | |||
146 | self.__isFirstTimeOnline = 1 |
|
146 | self.__isFirstTimeOnline = 1 | |
147 |
|
147 | |||
148 | # self.ippSeconds = 0 |
|
148 | # self.ippSeconds = 0 | |
149 |
|
149 | |||
150 | self.flagDiscontinuousBlock = 0 |
|
150 | self.flagDiscontinuousBlock = 0 | |
151 |
|
151 | |||
152 | self.flagIsNewBlock = 0 |
|
152 | self.flagIsNewBlock = 0 | |
153 |
|
153 | |||
154 | self.nTotalBlocks = 0 |
|
154 | self.nTotalBlocks = 0 | |
155 |
|
155 | |||
156 | self.blocksize = 0 |
|
156 | self.blocksize = 0 | |
157 |
|
157 | |||
158 | self.dataOut = self.createObjByDefault() |
|
158 | self.dataOut = self.createObjByDefault() | |
159 |
|
159 | |||
160 | self.nTxs = 1 |
|
160 | self.nTxs = 1 | |
161 |
|
161 | |||
162 | self.txIndex = 0 |
|
162 | self.txIndex = 0 | |
163 |
|
163 | |||
164 | def createObjByDefault(self): |
|
164 | def createObjByDefault(self): | |
165 |
|
165 | |||
166 | dataObj = Voltage() |
|
166 | dataObj = Voltage() | |
167 |
|
167 | |||
168 | return dataObj |
|
168 | return dataObj | |
169 |
|
169 | |||
170 | def __hasNotDataInBuffer(self): |
|
170 | def __hasNotDataInBuffer(self): | |
171 |
|
171 | |||
172 | if self.profileIndex >= self.processingHeaderObj.profilesPerBlock: |
|
172 | if self.profileIndex >= self.processingHeaderObj.profilesPerBlock: | |
173 | return 1 |
|
173 | return 1 | |
174 |
|
174 | |||
175 | return 0 |
|
175 | return 0 | |
176 |
|
176 | |||
177 |
|
177 | |||
178 | def getBlockDimension(self): |
|
178 | def getBlockDimension(self): | |
179 | """ |
|
179 | """ | |
180 | Obtiene la cantidad de puntos a leer por cada bloque de datos |
|
180 | Obtiene la cantidad de puntos a leer por cada bloque de datos | |
181 |
|
181 | |||
182 | Affected: |
|
182 | Affected: | |
183 | self.blocksize |
|
183 | self.blocksize | |
184 |
|
184 | |||
185 | Return: |
|
185 | Return: | |
186 | None |
|
186 | None | |
187 | """ |
|
187 | """ | |
188 | pts2read = self.processingHeaderObj.profilesPerBlock * self.processingHeaderObj.nHeights * self.systemHeaderObj.nChannels |
|
188 | pts2read = self.processingHeaderObj.profilesPerBlock * self.processingHeaderObj.nHeights * self.systemHeaderObj.nChannels | |
189 | self.blocksize = pts2read |
|
189 | self.blocksize = pts2read | |
190 |
|
190 | |||
191 |
|
191 | |||
192 | def readBlock(self): |
|
192 | def readBlock(self): | |
193 | """ |
|
193 | """ | |
194 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo |
|
194 | readBlock lee el bloque de datos desde la posicion actual del puntero del archivo | |
195 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos |
|
195 | (self.fp) y actualiza todos los parametros relacionados al bloque de datos | |
196 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer |
|
196 | (metadata + data). La data leida es almacenada en el buffer y el contador del buffer | |
197 | es seteado a 0 |
|
197 | es seteado a 0 | |
198 |
|
198 | |||
199 | Inputs: |
|
199 | Inputs: | |
200 | None |
|
200 | None | |
201 |
|
201 | |||
202 | Return: |
|
202 | Return: | |
203 | None |
|
203 | None | |
204 |
|
204 | |||
205 | Affected: |
|
205 | Affected: | |
206 | self.profileIndex |
|
206 | self.profileIndex | |
207 | self.datablock |
|
207 | self.datablock | |
208 | self.flagIsNewFile |
|
208 | self.flagIsNewFile | |
209 | self.flagIsNewBlock |
|
209 | self.flagIsNewBlock | |
210 | self.nTotalBlocks |
|
210 | self.nTotalBlocks | |
211 |
|
211 | |||
212 | Exceptions: |
|
212 | Exceptions: | |
213 | Si un bloque leido no es un bloque valido |
|
213 | Si un bloque leido no es un bloque valido | |
214 | """ |
|
214 | """ | |
215 | current_pointer_location = self.fp.tell() |
|
215 | current_pointer_location = self.fp.tell() | |
216 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) |
|
216 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) | |
217 |
|
217 | |||
218 | try: |
|
218 | try: | |
219 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) |
|
219 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) | |
220 | except: |
|
220 | except: | |
221 | #print "The read block (%3d) has not enough data" %self.nReadBlocks |
|
221 | #print "The read block (%3d) has not enough data" %self.nReadBlocks | |
222 |
|
222 | |||
223 | if self.waitDataBlock(pointer_location=current_pointer_location): |
|
223 | if self.waitDataBlock(pointer_location=current_pointer_location): | |
224 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) |
|
224 | junk = numpy.fromfile( self.fp, self.dtype, self.blocksize ) | |
225 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) |
|
225 | junk = junk.reshape( (self.processingHeaderObj.profilesPerBlock, self.processingHeaderObj.nHeights, self.systemHeaderObj.nChannels) ) | |
226 | # return 0 |
|
226 | # return 0 | |
227 |
|
227 | |||
228 | junk = numpy.transpose(junk, (2,0,1)) |
|
228 | junk = numpy.transpose(junk, (2,0,1)) | |
229 | self.datablock = junk['real'] + junk['imag']*1j |
|
229 | self.datablock = junk['real'] + junk['imag']*1j | |
230 |
|
230 | |||
231 | self.profileIndex = 0 |
|
231 | self.profileIndex = 0 | |
232 |
|
232 | |||
233 | self.flagIsNewFile = 0 |
|
233 | self.flagIsNewFile = 0 | |
234 | self.flagIsNewBlock = 1 |
|
234 | self.flagIsNewBlock = 1 | |
235 |
|
235 | |||
236 | self.nTotalBlocks += 1 |
|
236 | self.nTotalBlocks += 1 | |
237 | self.nReadBlocks += 1 |
|
237 | self.nReadBlocks += 1 | |
238 |
|
238 | |||
239 | return 1 |
|
239 | return 1 | |
240 |
|
240 | |||
241 | def getFirstHeader(self): |
|
241 | def getFirstHeader(self): | |
242 |
|
242 | |||
243 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() |
|
243 | self.dataOut.systemHeaderObj = self.systemHeaderObj.copy() | |
244 |
|
244 | |||
245 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() |
|
245 | self.dataOut.radarControllerHeaderObj = self.radarControllerHeaderObj.copy() | |
246 |
|
246 | |||
247 | if self.nTxs > 1: |
|
247 | if self.nTxs > 1: | |
248 | self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs |
|
248 | self.dataOut.radarControllerHeaderObj.ippSeconds = self.radarControllerHeaderObj.ippSeconds/self.nTxs | |
249 |
|
249 | |||
250 | # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt |
|
250 | # self.dataOut.timeInterval = self.radarControllerHeaderObj.ippSeconds * self.processingHeaderObj.nCohInt | |
251 | # |
|
251 | # | |
252 | # if self.radarControllerHeaderObj.code != None: |
|
252 | # if self.radarControllerHeaderObj.code != None: | |
253 | # |
|
253 | # | |
254 | # self.dataOut.nCode = self.radarControllerHeaderObj.nCode |
|
254 | # self.dataOut.nCode = self.radarControllerHeaderObj.nCode | |
255 | # |
|
255 | # | |
256 | # self.dataOut.nBaud = self.radarControllerHeaderObj.nBaud |
|
256 | # self.dataOut.nBaud = self.radarControllerHeaderObj.nBaud | |
257 | # |
|
257 | # | |
258 | # self.dataOut.code = self.radarControllerHeaderObj.code |
|
258 | # self.dataOut.code = self.radarControllerHeaderObj.code | |
259 |
|
259 | |||
260 | self.dataOut.dtype = self.dtype |
|
260 | self.dataOut.dtype = self.dtype | |
261 |
|
261 | |||
262 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs |
|
262 | self.dataOut.nProfiles = self.processingHeaderObj.profilesPerBlock*self.nTxs | |
263 |
|
263 | |||
264 | if self.processingHeaderObj.nHeights % self.nTxs != 0: |
|
264 | if self.processingHeaderObj.nHeights % self.nTxs != 0: | |
265 | raise ValueError, "nTxs (%d) should be a multiple of nHeights (%d)" %(self.nTxs, self.processingHeaderObj.nHeights) |
|
265 | raise ValueError, "nTxs (%d) should be a multiple of nHeights (%d)" %(self.nTxs, self.processingHeaderObj.nHeights) | |
266 |
|
266 | |||
267 | xf = self.processingHeaderObj.firstHeight + int(self.processingHeaderObj.nHeights/self.nTxs)*self.processingHeaderObj.deltaHeight |
|
267 | xf = self.processingHeaderObj.firstHeight + int(self.processingHeaderObj.nHeights/self.nTxs)*self.processingHeaderObj.deltaHeight | |
268 |
|
268 | |||
269 | self.dataOut.heightList = numpy.arange(self.processingHeaderObj.firstHeight, xf, self.processingHeaderObj.deltaHeight) |
|
269 | self.dataOut.heightList = numpy.arange(self.processingHeaderObj.firstHeight, xf, self.processingHeaderObj.deltaHeight) | |
270 |
|
270 | |||
271 | self.dataOut.channelList = range(self.systemHeaderObj.nChannels) |
|
271 | self.dataOut.channelList = range(self.systemHeaderObj.nChannels) | |
272 |
|
272 | |||
273 | self.dataOut.nCohInt = self.processingHeaderObj.nCohInt |
|
273 | self.dataOut.nCohInt = self.processingHeaderObj.nCohInt | |
274 |
|
274 | |||
275 | self.dataOut.flagShiftFFT = False |
|
275 | self.dataOut.flagShiftFFT = False | |
276 |
|
276 | |||
277 | self.dataOut.flagDecodeData = False #asumo q la data no esta decodificada |
|
277 | self.dataOut.flagDecodeData = False #asumo q la data no esta decodificada | |
278 |
|
278 | |||
279 | self.dataOut.flagDeflipData = False #asumo q la data no esta sin flip |
|
279 | self.dataOut.flagDeflipData = False #asumo q la data no esta sin flip | |
280 |
|
280 | |||
281 | self.dataOut.flagShiftFFT = False |
|
281 | self.dataOut.flagShiftFFT = False | |
282 |
|
282 | |||
283 | def getData(self): |
|
283 | def getData(self): | |
284 | """ |
|
284 | """ | |
285 | getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut |
|
285 | getData obtiene una unidad de datos del buffer de lectura, un perfil, y la copia al objeto self.dataOut | |
286 | del tipo "Voltage" con todos los parametros asociados a este (metadata). cuando no hay datos |
|
286 | del tipo "Voltage" con todos los parametros asociados a este (metadata). cuando no hay datos | |
287 | en el buffer de lectura es necesario hacer una nueva lectura de los bloques de datos usando |
|
287 | en el buffer de lectura es necesario hacer una nueva lectura de los bloques de datos usando | |
288 | "readNextBlock" |
|
288 | "readNextBlock" | |
289 |
|
289 | |||
290 | Ademas incrementa el contador del buffer "self.profileIndex" en 1. |
|
290 | Ademas incrementa el contador del buffer "self.profileIndex" en 1. | |
291 |
|
291 | |||
292 | Return: |
|
292 | Return: | |
293 |
|
293 | |||
294 | Si el flag self.getByBlock ha sido seteado el bloque completo es copiado a self.dataOut y el self.profileIndex |
|
294 | Si el flag self.getByBlock ha sido seteado el bloque completo es copiado a self.dataOut y el self.profileIndex | |
295 | es igual al total de perfiles leidos desde el archivo. |
|
295 | es igual al total de perfiles leidos desde el archivo. | |
296 |
|
296 | |||
297 | Si self.getByBlock == False: |
|
297 | Si self.getByBlock == False: | |
298 |
|
298 | |||
299 | self.dataOut.data = buffer[:, thisProfile, :] |
|
299 | self.dataOut.data = buffer[:, thisProfile, :] | |
300 |
|
300 | |||
301 | shape = [nChannels, nHeis] |
|
301 | shape = [nChannels, nHeis] | |
302 |
|
302 | |||
303 | Si self.getByBlock == True: |
|
303 | Si self.getByBlock == True: | |
304 |
|
304 | |||
305 | self.dataOut.data = buffer[:, :, :] |
|
305 | self.dataOut.data = buffer[:, :, :] | |
306 |
|
306 | |||
307 | shape = [nChannels, nProfiles, nHeis] |
|
307 | shape = [nChannels, nProfiles, nHeis] | |
308 |
|
308 | |||
309 | Variables afectadas: |
|
309 | Variables afectadas: | |
310 | self.dataOut |
|
310 | self.dataOut | |
311 | self.profileIndex |
|
311 | self.profileIndex | |
312 |
|
312 | |||
313 | Affected: |
|
313 | Affected: | |
314 | self.dataOut |
|
314 | self.dataOut | |
315 | self.profileIndex |
|
315 | self.profileIndex | |
316 | self.flagDiscontinuousBlock |
|
316 | self.flagDiscontinuousBlock | |
317 | self.flagIsNewBlock |
|
317 | self.flagIsNewBlock | |
318 | """ |
|
318 | """ | |
319 |
|
319 | |||
320 | if self.flagNoMoreFiles: |
|
320 | if self.flagNoMoreFiles: | |
321 | self.dataOut.flagNoData = True |
|
321 | self.dataOut.flagNoData = True | |
322 | print 'Process finished' |
|
322 | print 'Process finished' | |
323 | return 0 |
|
323 | return 0 | |
324 |
|
324 | |||
325 | self.flagDiscontinuousBlock = 0 |
|
325 | self.flagDiscontinuousBlock = 0 | |
326 | self.flagIsNewBlock = 0 |
|
326 | self.flagIsNewBlock = 0 | |
327 |
|
327 | |||
328 | if self.__hasNotDataInBuffer(): |
|
328 | if self.__hasNotDataInBuffer(): | |
329 |
|
329 | |||
330 | if not( self.readNextBlock() ): |
|
330 | if not( self.readNextBlock() ): | |
331 | return 0 |
|
331 | return 0 | |
332 |
|
332 | |||
333 | self.getFirstHeader() |
|
333 | self.getFirstHeader() | |
334 |
|
334 | |||
335 | if self.datablock == None: |
|
335 | if self.datablock == None: | |
336 | self.dataOut.flagNoData = True |
|
336 | self.dataOut.flagNoData = True | |
337 | return 0 |
|
337 | return 0 | |
338 |
|
338 | |||
339 | if not self.getByBlock: |
|
339 | if not self.getByBlock: | |
340 |
|
340 | |||
341 | """ |
|
341 | """ | |
342 | Return profile by profile |
|
342 | Return profile by profile | |
343 |
|
343 | |||
344 | If nTxs > 1 then one profile is divided by nTxs and number of total |
|
344 | If nTxs > 1 then one profile is divided by nTxs and number of total | |
345 | blocks is increased by nTxs (nProfiles *= nTxs) |
|
345 | blocks is increased by nTxs (nProfiles *= nTxs) | |
346 | """ |
|
346 | """ | |
|
347 | self.dataOut.flagDataAsBlock = False | |||
|
348 | ||||
347 | if self.nTxs == 1: |
|
349 | if self.nTxs == 1: | |
348 | self.dataOut.flagDataAsBlock = False |
|
|||
349 | self.dataOut.data = self.datablock[:,self.profileIndex,:] |
|
350 | self.dataOut.data = self.datablock[:,self.profileIndex,:] | |
350 | self.dataOut.profileIndex = self.profileIndex |
|
351 | self.dataOut.profileIndex = self.profileIndex | |
351 |
|
352 | |||
352 | self.profileIndex += 1 |
|
353 | self.profileIndex += 1 | |
353 |
|
354 | |||
354 | else: |
|
355 | else: | |
355 | self.dataOut.flagDataAsBlock = False |
|
|||
356 |
|
||||
357 | iniHei_ForThisTx = (self.txIndex)*int(self.processingHeaderObj.nHeights/self.nTxs) |
|
356 | iniHei_ForThisTx = (self.txIndex)*int(self.processingHeaderObj.nHeights/self.nTxs) | |
358 | endHei_ForThisTx = (self.txIndex+1)*int(self.processingHeaderObj.nHeights/self.nTxs) |
|
357 | endHei_ForThisTx = (self.txIndex+1)*int(self.processingHeaderObj.nHeights/self.nTxs) | |
359 |
|
358 | |||
360 | # print iniHei_ForThisTx, endHei_ForThisTx |
|
359 | # print iniHei_ForThisTx, endHei_ForThisTx | |
361 |
|
360 | |||
362 | self.dataOut.data = self.datablock[:, self.profileIndex, iniHei_ForThisTx:endHei_ForThisTx] |
|
361 | self.dataOut.data = self.datablock[:, self.profileIndex, iniHei_ForThisTx:endHei_ForThisTx] | |
363 | self.dataOut.profileIndex = self.profileIndex*self.nTxs + self.txIndex |
|
362 | self.dataOut.profileIndex = self.profileIndex*self.nTxs + self.txIndex | |
364 |
|
363 | |||
365 | self.txIndex += 1 |
|
364 | self.txIndex += 1 | |
366 |
|
365 | |||
367 | if self.txIndex == self.nTxs: |
|
366 | if self.txIndex == self.nTxs: | |
368 | self.txIndex = 0 |
|
367 | self.txIndex = 0 | |
369 | self.profileIndex += 1 |
|
368 | self.profileIndex += 1 | |
370 |
|
369 | |||
371 | else: |
|
370 | else: | |
372 | """ |
|
371 | """ | |
373 | Return all block |
|
372 | Return all block | |
374 | """ |
|
373 | """ | |
375 | self.dataOut.flagDataAsBlock = True |
|
374 | self.dataOut.flagDataAsBlock = True | |
376 | self.dataOut.data = self.datablock |
|
375 | self.dataOut.data = self.datablock | |
377 |
self.dataOut.profileIndex = self.processingHeaderObj.profilesPerBlock |
|
376 | self.dataOut.profileIndex = self.processingHeaderObj.profilesPerBlock | |
378 |
|
377 | |||
379 |
self.profileIndex = self.processingHeaderObj.profilesPerBlock |
|
378 | self.profileIndex = self.processingHeaderObj.profilesPerBlock | |
380 |
|
379 | |||
381 | self.dataOut.flagNoData = False |
|
380 | self.dataOut.flagNoData = False | |
382 |
|
381 | |||
383 | self.getBasicHeader() |
|
382 | self.getBasicHeader() | |
384 |
|
383 | |||
385 | self.dataOut.realtime = self.online |
|
384 | self.dataOut.realtime = self.online | |
386 |
|
385 | |||
387 | return self.dataOut.data |
|
386 | return self.dataOut.data | |
388 |
|
387 | |||
389 | class VoltageWriter(JRODataWriter, Operation): |
|
388 | class VoltageWriter(JRODataWriter, Operation): | |
390 | """ |
|
389 | """ | |
391 | Esta clase permite escribir datos de voltajes a archivos procesados (.r). La escritura |
|
390 | Esta clase permite escribir datos de voltajes a archivos procesados (.r). La escritura | |
392 | de los datos siempre se realiza por bloques. |
|
391 | de los datos siempre se realiza por bloques. | |
393 | """ |
|
392 | """ | |
394 |
|
393 | |||
395 | ext = ".r" |
|
394 | ext = ".r" | |
396 |
|
395 | |||
397 | optchar = "D" |
|
396 | optchar = "D" | |
398 |
|
397 | |||
399 | shapeBuffer = None |
|
398 | shapeBuffer = None | |
400 |
|
399 | |||
401 |
|
400 | |||
402 | def __init__(self): |
|
401 | def __init__(self): | |
403 | """ |
|
402 | """ | |
404 | Inicializador de la clase VoltageWriter para la escritura de datos de espectros. |
|
403 | Inicializador de la clase VoltageWriter para la escritura de datos de espectros. | |
405 |
|
404 | |||
406 | Affected: |
|
405 | Affected: | |
407 | self.dataOut |
|
406 | self.dataOut | |
408 |
|
407 | |||
409 | Return: None |
|
408 | Return: None | |
410 | """ |
|
409 | """ | |
411 | Operation.__init__(self) |
|
410 | Operation.__init__(self) | |
412 |
|
411 | |||
413 | self.nTotalBlocks = 0 |
|
412 | self.nTotalBlocks = 0 | |
414 |
|
413 | |||
415 | self.profileIndex = 0 |
|
414 | self.profileIndex = 0 | |
416 |
|
415 | |||
417 | self.isConfig = False |
|
416 | self.isConfig = False | |
418 |
|
417 | |||
419 | self.fp = None |
|
418 | self.fp = None | |
420 |
|
419 | |||
421 | self.flagIsNewFile = 1 |
|
420 | self.flagIsNewFile = 1 | |
422 |
|
421 | |||
423 | self.nTotalBlocks = 0 |
|
422 | self.nTotalBlocks = 0 | |
424 |
|
423 | |||
425 | self.flagIsNewBlock = 0 |
|
424 | self.flagIsNewBlock = 0 | |
426 |
|
425 | |||
427 | self.setFile = None |
|
426 | self.setFile = None | |
428 |
|
427 | |||
429 | self.dtype = None |
|
428 | self.dtype = None | |
430 |
|
429 | |||
431 | self.path = None |
|
430 | self.path = None | |
432 |
|
431 | |||
433 | self.filename = None |
|
432 | self.filename = None | |
434 |
|
433 | |||
435 | self.basicHeaderObj = BasicHeader(LOCALTIME) |
|
434 | self.basicHeaderObj = BasicHeader(LOCALTIME) | |
436 |
|
435 | |||
437 | self.systemHeaderObj = SystemHeader() |
|
436 | self.systemHeaderObj = SystemHeader() | |
438 |
|
437 | |||
439 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
438 | self.radarControllerHeaderObj = RadarControllerHeader() | |
440 |
|
439 | |||
441 | self.processingHeaderObj = ProcessingHeader() |
|
440 | self.processingHeaderObj = ProcessingHeader() | |
442 |
|
441 | |||
443 | def hasAllDataInBuffer(self): |
|
442 | def hasAllDataInBuffer(self): | |
444 | if self.profileIndex >= self.processingHeaderObj.profilesPerBlock: |
|
443 | if self.profileIndex >= self.processingHeaderObj.profilesPerBlock: | |
445 | return 1 |
|
444 | return 1 | |
446 | return 0 |
|
445 | return 0 | |
447 |
|
446 | |||
448 |
|
447 | |||
449 | def setBlockDimension(self): |
|
448 | def setBlockDimension(self): | |
450 | """ |
|
449 | """ | |
451 | Obtiene las formas dimensionales del los subbloques de datos que componen un bloque |
|
450 | Obtiene las formas dimensionales del los subbloques de datos que componen un bloque | |
452 |
|
451 | |||
453 | Affected: |
|
452 | Affected: | |
454 | self.shape_spc_Buffer |
|
453 | self.shape_spc_Buffer | |
455 | self.shape_cspc_Buffer |
|
454 | self.shape_cspc_Buffer | |
456 | self.shape_dc_Buffer |
|
455 | self.shape_dc_Buffer | |
457 |
|
456 | |||
458 | Return: None |
|
457 | Return: None | |
459 | """ |
|
458 | """ | |
460 | self.shapeBuffer = (self.processingHeaderObj.profilesPerBlock, |
|
459 | self.shapeBuffer = (self.processingHeaderObj.profilesPerBlock, | |
461 | self.processingHeaderObj.nHeights, |
|
460 | self.processingHeaderObj.nHeights, | |
462 | self.systemHeaderObj.nChannels) |
|
461 | self.systemHeaderObj.nChannels) | |
463 |
|
462 | |||
464 | self.datablock = numpy.zeros((self.systemHeaderObj.nChannels, |
|
463 | self.datablock = numpy.zeros((self.systemHeaderObj.nChannels, | |
465 | self.processingHeaderObj.profilesPerBlock, |
|
464 | self.processingHeaderObj.profilesPerBlock, | |
466 | self.processingHeaderObj.nHeights), |
|
465 | self.processingHeaderObj.nHeights), | |
467 | dtype=numpy.dtype('complex64')) |
|
466 | dtype=numpy.dtype('complex64')) | |
468 |
|
467 | |||
469 | def writeBlock(self): |
|
468 | def writeBlock(self): | |
470 | """ |
|
469 | """ | |
471 | Escribe el buffer en el file designado |
|
470 | Escribe el buffer en el file designado | |
472 |
|
471 | |||
473 | Affected: |
|
472 | Affected: | |
474 | self.profileIndex |
|
473 | self.profileIndex | |
475 | self.flagIsNewFile |
|
474 | self.flagIsNewFile | |
476 | self.flagIsNewBlock |
|
475 | self.flagIsNewBlock | |
477 | self.nTotalBlocks |
|
476 | self.nTotalBlocks | |
478 | self.blockIndex |
|
477 | self.blockIndex | |
479 |
|
478 | |||
480 | Return: None |
|
479 | Return: None | |
481 | """ |
|
480 | """ | |
482 | data = numpy.zeros( self.shapeBuffer, self.dtype ) |
|
481 | data = numpy.zeros( self.shapeBuffer, self.dtype ) | |
483 |
|
482 | |||
484 | junk = numpy.transpose(self.datablock, (1,2,0)) |
|
483 | junk = numpy.transpose(self.datablock, (1,2,0)) | |
485 |
|
484 | |||
486 | data['real'] = junk.real |
|
485 | data['real'] = junk.real | |
487 | data['imag'] = junk.imag |
|
486 | data['imag'] = junk.imag | |
488 |
|
487 | |||
489 | data = data.reshape( (-1) ) |
|
488 | data = data.reshape( (-1) ) | |
490 |
|
489 | |||
491 | data.tofile( self.fp ) |
|
490 | data.tofile( self.fp ) | |
492 |
|
491 | |||
493 | self.datablock.fill(0) |
|
492 | self.datablock.fill(0) | |
494 |
|
493 | |||
495 | self.profileIndex = 0 |
|
494 | self.profileIndex = 0 | |
496 | self.flagIsNewFile = 0 |
|
495 | self.flagIsNewFile = 0 | |
497 | self.flagIsNewBlock = 1 |
|
496 | self.flagIsNewBlock = 1 | |
498 |
|
497 | |||
499 | self.blockIndex += 1 |
|
498 | self.blockIndex += 1 | |
500 | self.nTotalBlocks += 1 |
|
499 | self.nTotalBlocks += 1 | |
501 |
|
500 | |||
502 | # print "[Writing] Block = %04d" %self.blockIndex |
|
501 | # print "[Writing] Block = %04d" %self.blockIndex | |
503 |
|
502 | |||
504 | def putData(self): |
|
503 | def putData(self): | |
505 | """ |
|
504 | """ | |
506 | Setea un bloque de datos y luego los escribe en un file |
|
505 | Setea un bloque de datos y luego los escribe en un file | |
507 |
|
506 | |||
508 | Affected: |
|
507 | Affected: | |
509 | self.flagIsNewBlock |
|
508 | self.flagIsNewBlock | |
510 | self.profileIndex |
|
509 | self.profileIndex | |
511 |
|
510 | |||
512 | Return: |
|
511 | Return: | |
513 | 0 : Si no hay data o no hay mas files que puedan escribirse |
|
512 | 0 : Si no hay data o no hay mas files que puedan escribirse | |
514 | 1 : Si se escribio la data de un bloque en un file |
|
513 | 1 : Si se escribio la data de un bloque en un file | |
515 | """ |
|
514 | """ | |
516 | if self.dataOut.flagNoData: |
|
515 | if self.dataOut.flagNoData: | |
517 | return 0 |
|
516 | return 0 | |
518 |
|
517 | |||
519 | self.flagIsNewBlock = 0 |
|
518 | self.flagIsNewBlock = 0 | |
520 |
|
519 | |||
521 | if self.dataOut.flagDiscontinuousBlock: |
|
520 | if self.dataOut.flagDiscontinuousBlock: | |
522 | self.datablock.fill(0) |
|
521 | self.datablock.fill(0) | |
523 | self.profileIndex = 0 |
|
522 | self.profileIndex = 0 | |
524 | self.setNextFile() |
|
523 | self.setNextFile() | |
525 |
|
524 | |||
526 | if self.profileIndex == 0: |
|
525 | if self.profileIndex == 0: | |
527 | self.setBasicHeader() |
|
526 | self.setBasicHeader() | |
528 |
|
527 | |||
529 | self.datablock[:,self.profileIndex,:] = self.dataOut.data |
|
528 | self.datablock[:,self.profileIndex,:] = self.dataOut.data | |
530 |
|
529 | |||
531 | self.profileIndex += 1 |
|
530 | self.profileIndex += 1 | |
532 |
|
531 | |||
533 | if self.hasAllDataInBuffer(): |
|
532 | if self.hasAllDataInBuffer(): | |
534 | #if self.flagIsNewFile: |
|
533 | #if self.flagIsNewFile: | |
535 | self.writeNextBlock() |
|
534 | self.writeNextBlock() | |
536 | # self.setFirstHeader() |
|
535 | # self.setFirstHeader() | |
537 |
|
536 | |||
538 | return 1 |
|
537 | return 1 | |
539 |
|
538 | |||
540 | def __getProcessFlags(self): |
|
539 | def __getProcessFlags(self): | |
541 |
|
540 | |||
542 | processFlags = 0 |
|
541 | processFlags = 0 | |
543 |
|
542 | |||
544 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
543 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
545 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
544 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
546 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
545 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
547 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
546 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
548 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
547 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
549 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
548 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
550 |
|
549 | |||
551 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] |
|
550 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
552 |
|
551 | |||
553 |
|
552 | |||
554 |
|
553 | |||
555 | datatypeValueList = [PROCFLAG.DATATYPE_CHAR, |
|
554 | datatypeValueList = [PROCFLAG.DATATYPE_CHAR, | |
556 | PROCFLAG.DATATYPE_SHORT, |
|
555 | PROCFLAG.DATATYPE_SHORT, | |
557 | PROCFLAG.DATATYPE_LONG, |
|
556 | PROCFLAG.DATATYPE_LONG, | |
558 | PROCFLAG.DATATYPE_INT64, |
|
557 | PROCFLAG.DATATYPE_INT64, | |
559 | PROCFLAG.DATATYPE_FLOAT, |
|
558 | PROCFLAG.DATATYPE_FLOAT, | |
560 | PROCFLAG.DATATYPE_DOUBLE] |
|
559 | PROCFLAG.DATATYPE_DOUBLE] | |
561 |
|
560 | |||
562 |
|
561 | |||
563 | for index in range(len(dtypeList)): |
|
562 | for index in range(len(dtypeList)): | |
564 | if self.dataOut.dtype == dtypeList[index]: |
|
563 | if self.dataOut.dtype == dtypeList[index]: | |
565 | dtypeValue = datatypeValueList[index] |
|
564 | dtypeValue = datatypeValueList[index] | |
566 | break |
|
565 | break | |
567 |
|
566 | |||
568 | processFlags += dtypeValue |
|
567 | processFlags += dtypeValue | |
569 |
|
568 | |||
570 | if self.dataOut.flagDecodeData: |
|
569 | if self.dataOut.flagDecodeData: | |
571 | processFlags += PROCFLAG.DECODE_DATA |
|
570 | processFlags += PROCFLAG.DECODE_DATA | |
572 |
|
571 | |||
573 | if self.dataOut.flagDeflipData: |
|
572 | if self.dataOut.flagDeflipData: | |
574 | processFlags += PROCFLAG.DEFLIP_DATA |
|
573 | processFlags += PROCFLAG.DEFLIP_DATA | |
575 |
|
574 | |||
576 | if self.dataOut.code != None: |
|
575 | if self.dataOut.code != None: | |
577 | processFlags += PROCFLAG.DEFINE_PROCESS_CODE |
|
576 | processFlags += PROCFLAG.DEFINE_PROCESS_CODE | |
578 |
|
577 | |||
579 | if self.dataOut.nCohInt > 1: |
|
578 | if self.dataOut.nCohInt > 1: | |
580 | processFlags += PROCFLAG.COHERENT_INTEGRATION |
|
579 | processFlags += PROCFLAG.COHERENT_INTEGRATION | |
581 |
|
580 | |||
582 | return processFlags |
|
581 | return processFlags | |
583 |
|
582 | |||
584 |
|
583 | |||
585 | def __getBlockSize(self): |
|
584 | def __getBlockSize(self): | |
586 | ''' |
|
585 | ''' | |
587 | Este metodos determina el cantidad de bytes para un bloque de datos de tipo Voltage |
|
586 | Este metodos determina el cantidad de bytes para un bloque de datos de tipo Voltage | |
588 | ''' |
|
587 | ''' | |
589 |
|
588 | |||
590 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
589 | dtype0 = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
591 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
590 | dtype1 = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
592 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
591 | dtype2 = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
593 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
592 | dtype3 = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
594 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
593 | dtype4 = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
595 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
594 | dtype5 = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
596 |
|
595 | |||
597 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] |
|
596 | dtypeList = [dtype0, dtype1, dtype2, dtype3, dtype4, dtype5] | |
598 | datatypeValueList = [1,2,4,8,4,8] |
|
597 | datatypeValueList = [1,2,4,8,4,8] | |
599 | for index in range(len(dtypeList)): |
|
598 | for index in range(len(dtypeList)): | |
600 | if self.dataOut.dtype == dtypeList[index]: |
|
599 | if self.dataOut.dtype == dtypeList[index]: | |
601 | datatypeValue = datatypeValueList[index] |
|
600 | datatypeValue = datatypeValueList[index] | |
602 | break |
|
601 | break | |
603 |
|
602 | |||
604 | blocksize = int(self.dataOut.nHeights * self.dataOut.nChannels * self.profilesPerBlock * datatypeValue * 2) |
|
603 | blocksize = int(self.dataOut.nHeights * self.dataOut.nChannels * self.profilesPerBlock * datatypeValue * 2) | |
605 |
|
604 | |||
606 | return blocksize |
|
605 | return blocksize | |
607 |
|
606 | |||
608 | def setFirstHeader(self): |
|
607 | def setFirstHeader(self): | |
609 |
|
608 | |||
610 | """ |
|
609 | """ | |
611 | Obtiene una copia del First Header |
|
610 | Obtiene una copia del First Header | |
612 |
|
611 | |||
613 | Affected: |
|
612 | Affected: | |
614 | self.systemHeaderObj |
|
613 | self.systemHeaderObj | |
615 | self.radarControllerHeaderObj |
|
614 | self.radarControllerHeaderObj | |
616 | self.dtype |
|
615 | self.dtype | |
617 |
|
616 | |||
618 | Return: |
|
617 | Return: | |
619 | None |
|
618 | None | |
620 | """ |
|
619 | """ | |
621 |
|
620 | |||
622 | self.systemHeaderObj = self.dataOut.systemHeaderObj.copy() |
|
621 | self.systemHeaderObj = self.dataOut.systemHeaderObj.copy() | |
623 | self.systemHeaderObj.nChannels = self.dataOut.nChannels |
|
622 | self.systemHeaderObj.nChannels = self.dataOut.nChannels | |
624 | self.radarControllerHeaderObj = self.dataOut.radarControllerHeaderObj.copy() |
|
623 | self.radarControllerHeaderObj = self.dataOut.radarControllerHeaderObj.copy() | |
625 |
|
624 | |||
626 | self.setBasicHeader() |
|
625 | self.setBasicHeader() | |
627 |
|
626 | |||
628 | processingHeaderSize = 40 # bytes |
|
627 | processingHeaderSize = 40 # bytes | |
629 | self.processingHeaderObj.dtype = 0 # Voltage |
|
628 | self.processingHeaderObj.dtype = 0 # Voltage | |
630 | self.processingHeaderObj.blockSize = self.__getBlockSize() |
|
629 | self.processingHeaderObj.blockSize = self.__getBlockSize() | |
631 | self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock |
|
630 | self.processingHeaderObj.profilesPerBlock = self.profilesPerBlock | |
632 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile |
|
631 | self.processingHeaderObj.dataBlocksPerFile = self.blocksPerFile | |
633 | self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows |
|
632 | self.processingHeaderObj.nWindows = 1 #podria ser 1 o self.dataOut.processingHeaderObj.nWindows | |
634 | self.processingHeaderObj.processFlags = self.__getProcessFlags() |
|
633 | self.processingHeaderObj.processFlags = self.__getProcessFlags() | |
635 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt |
|
634 | self.processingHeaderObj.nCohInt = self.dataOut.nCohInt | |
636 | self.processingHeaderObj.nIncohInt = 1 # Cuando la data de origen es de tipo Voltage |
|
635 | self.processingHeaderObj.nIncohInt = 1 # Cuando la data de origen es de tipo Voltage | |
637 | self.processingHeaderObj.totalSpectra = 0 # Cuando la data de origen es de tipo Voltage |
|
636 | self.processingHeaderObj.totalSpectra = 0 # Cuando la data de origen es de tipo Voltage | |
638 |
|
637 | |||
639 | # if self.dataOut.code != None: |
|
638 | # if self.dataOut.code != None: | |
640 | # self.processingHeaderObj.code = self.dataOut.code |
|
639 | # self.processingHeaderObj.code = self.dataOut.code | |
641 | # self.processingHeaderObj.nCode = self.dataOut.nCode |
|
640 | # self.processingHeaderObj.nCode = self.dataOut.nCode | |
642 | # self.processingHeaderObj.nBaud = self.dataOut.nBaud |
|
641 | # self.processingHeaderObj.nBaud = self.dataOut.nBaud | |
643 | # codesize = int(8 + 4 * self.dataOut.nCode * self.dataOut.nBaud) |
|
642 | # codesize = int(8 + 4 * self.dataOut.nCode * self.dataOut.nBaud) | |
644 | # processingHeaderSize += codesize |
|
643 | # processingHeaderSize += codesize | |
645 |
|
644 | |||
646 | if self.processingHeaderObj.nWindows != 0: |
|
645 | if self.processingHeaderObj.nWindows != 0: | |
647 | self.processingHeaderObj.firstHeight = self.dataOut.heightList[0] |
|
646 | self.processingHeaderObj.firstHeight = self.dataOut.heightList[0] | |
648 | self.processingHeaderObj.deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] |
|
647 | self.processingHeaderObj.deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] | |
649 | self.processingHeaderObj.nHeights = self.dataOut.nHeights |
|
648 | self.processingHeaderObj.nHeights = self.dataOut.nHeights | |
650 | self.processingHeaderObj.samplesWin = self.dataOut.nHeights |
|
649 | self.processingHeaderObj.samplesWin = self.dataOut.nHeights | |
651 | processingHeaderSize += 12 |
|
650 | processingHeaderSize += 12 | |
652 |
|
651 | |||
653 | self.processingHeaderObj.size = processingHeaderSize No newline at end of file |
|
652 | self.processingHeaderObj.size = processingHeaderSize |
@@ -1,1055 +1,1055 | |||||
1 | import numpy |
|
1 | import numpy | |
2 |
|
2 | |||
3 | from jroproc_base import ProcessingUnit, Operation |
|
3 | from jroproc_base import ProcessingUnit, Operation | |
4 | from schainpy.model.data.jrodata import Voltage |
|
4 | from schainpy.model.data.jrodata import Voltage | |
5 |
|
5 | |||
6 | class VoltageProc(ProcessingUnit): |
|
6 | class VoltageProc(ProcessingUnit): | |
7 |
|
7 | |||
8 |
|
8 | |||
9 | def __init__(self): |
|
9 | def __init__(self): | |
10 |
|
10 | |||
11 | ProcessingUnit.__init__(self) |
|
11 | ProcessingUnit.__init__(self) | |
12 |
|
12 | |||
13 | # self.objectDict = {} |
|
13 | # self.objectDict = {} | |
14 | self.dataOut = Voltage() |
|
14 | self.dataOut = Voltage() | |
15 | self.flip = 1 |
|
15 | self.flip = 1 | |
16 |
|
16 | |||
17 | def run(self): |
|
17 | def run(self): | |
18 | if self.dataIn.type == 'AMISR': |
|
18 | if self.dataIn.type == 'AMISR': | |
19 | self.__updateObjFromAmisrInput() |
|
19 | self.__updateObjFromAmisrInput() | |
20 |
|
20 | |||
21 | if self.dataIn.type == 'Voltage': |
|
21 | if self.dataIn.type == 'Voltage': | |
22 | self.dataOut.copy(self.dataIn) |
|
22 | self.dataOut.copy(self.dataIn) | |
23 |
|
23 | |||
24 | # self.dataOut.copy(self.dataIn) |
|
24 | # self.dataOut.copy(self.dataIn) | |
25 |
|
25 | |||
26 | def __updateObjFromAmisrInput(self): |
|
26 | def __updateObjFromAmisrInput(self): | |
27 |
|
27 | |||
28 | self.dataOut.timeZone = self.dataIn.timeZone |
|
28 | self.dataOut.timeZone = self.dataIn.timeZone | |
29 | self.dataOut.dstFlag = self.dataIn.dstFlag |
|
29 | self.dataOut.dstFlag = self.dataIn.dstFlag | |
30 | self.dataOut.errorCount = self.dataIn.errorCount |
|
30 | self.dataOut.errorCount = self.dataIn.errorCount | |
31 | self.dataOut.useLocalTime = self.dataIn.useLocalTime |
|
31 | self.dataOut.useLocalTime = self.dataIn.useLocalTime | |
32 |
|
32 | |||
33 | self.dataOut.flagNoData = self.dataIn.flagNoData |
|
33 | self.dataOut.flagNoData = self.dataIn.flagNoData | |
34 | self.dataOut.data = self.dataIn.data |
|
34 | self.dataOut.data = self.dataIn.data | |
35 | self.dataOut.utctime = self.dataIn.utctime |
|
35 | self.dataOut.utctime = self.dataIn.utctime | |
36 | self.dataOut.channelList = self.dataIn.channelList |
|
36 | self.dataOut.channelList = self.dataIn.channelList | |
37 | # self.dataOut.timeInterval = self.dataIn.timeInterval |
|
37 | # self.dataOut.timeInterval = self.dataIn.timeInterval | |
38 | self.dataOut.heightList = self.dataIn.heightList |
|
38 | self.dataOut.heightList = self.dataIn.heightList | |
39 | self.dataOut.nProfiles = self.dataIn.nProfiles |
|
39 | self.dataOut.nProfiles = self.dataIn.nProfiles | |
40 |
|
40 | |||
41 | self.dataOut.nCohInt = self.dataIn.nCohInt |
|
41 | self.dataOut.nCohInt = self.dataIn.nCohInt | |
42 | self.dataOut.ippSeconds = self.dataIn.ippSeconds |
|
42 | self.dataOut.ippSeconds = self.dataIn.ippSeconds | |
43 | self.dataOut.frequency = self.dataIn.frequency |
|
43 | self.dataOut.frequency = self.dataIn.frequency | |
44 |
|
44 | |||
45 | self.dataOut.azimuth = self.dataIn.azimuth |
|
45 | self.dataOut.azimuth = self.dataIn.azimuth | |
46 | self.dataOut.zenith = self.dataIn.zenith |
|
46 | self.dataOut.zenith = self.dataIn.zenith | |
47 |
|
47 | |||
48 | self.dataOut.beam.codeList = self.dataIn.beam.codeList |
|
48 | self.dataOut.beam.codeList = self.dataIn.beam.codeList | |
49 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList |
|
49 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList | |
50 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList |
|
50 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList | |
51 | # |
|
51 | # | |
52 | # pass# |
|
52 | # pass# | |
53 | # |
|
53 | # | |
54 | # def init(self): |
|
54 | # def init(self): | |
55 | # |
|
55 | # | |
56 | # |
|
56 | # | |
57 | # if self.dataIn.type == 'AMISR': |
|
57 | # if self.dataIn.type == 'AMISR': | |
58 | # self.__updateObjFromAmisrInput() |
|
58 | # self.__updateObjFromAmisrInput() | |
59 | # |
|
59 | # | |
60 | # if self.dataIn.type == 'Voltage': |
|
60 | # if self.dataIn.type == 'Voltage': | |
61 | # self.dataOut.copy(self.dataIn) |
|
61 | # self.dataOut.copy(self.dataIn) | |
62 | # # No necesita copiar en cada init() los atributos de dataIn |
|
62 | # # No necesita copiar en cada init() los atributos de dataIn | |
63 | # # la copia deberia hacerse por cada nuevo bloque de datos |
|
63 | # # la copia deberia hacerse por cada nuevo bloque de datos | |
64 |
|
64 | |||
65 | def selectChannels(self, channelList): |
|
65 | def selectChannels(self, channelList): | |
66 |
|
66 | |||
67 | channelIndexList = [] |
|
67 | channelIndexList = [] | |
68 |
|
68 | |||
69 | for channel in channelList: |
|
69 | for channel in channelList: | |
70 | if channel not in self.dataOut.channelList: |
|
70 | if channel not in self.dataOut.channelList: | |
71 | raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList)) |
|
71 | raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList)) | |
72 |
|
72 | |||
73 | index = self.dataOut.channelList.index(channel) |
|
73 | index = self.dataOut.channelList.index(channel) | |
74 | channelIndexList.append(index) |
|
74 | channelIndexList.append(index) | |
75 |
|
75 | |||
76 | self.selectChannelsByIndex(channelIndexList) |
|
76 | self.selectChannelsByIndex(channelIndexList) | |
77 |
|
77 | |||
78 | def selectChannelsByIndex(self, channelIndexList): |
|
78 | def selectChannelsByIndex(self, channelIndexList): | |
79 | """ |
|
79 | """ | |
80 | Selecciona un bloque de datos en base a canales segun el channelIndexList |
|
80 | Selecciona un bloque de datos en base a canales segun el channelIndexList | |
81 |
|
81 | |||
82 | Input: |
|
82 | Input: | |
83 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] |
|
83 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] | |
84 |
|
84 | |||
85 | Affected: |
|
85 | Affected: | |
86 | self.dataOut.data |
|
86 | self.dataOut.data | |
87 | self.dataOut.channelIndexList |
|
87 | self.dataOut.channelIndexList | |
88 | self.dataOut.nChannels |
|
88 | self.dataOut.nChannels | |
89 | self.dataOut.m_ProcessingHeader.totalSpectra |
|
89 | self.dataOut.m_ProcessingHeader.totalSpectra | |
90 | self.dataOut.systemHeaderObj.numChannels |
|
90 | self.dataOut.systemHeaderObj.numChannels | |
91 | self.dataOut.m_ProcessingHeader.blockSize |
|
91 | self.dataOut.m_ProcessingHeader.blockSize | |
92 |
|
92 | |||
93 | Return: |
|
93 | Return: | |
94 | None |
|
94 | None | |
95 | """ |
|
95 | """ | |
96 |
|
96 | |||
97 | for channelIndex in channelIndexList: |
|
97 | for channelIndex in channelIndexList: | |
98 | if channelIndex not in self.dataOut.channelIndexList: |
|
98 | if channelIndex not in self.dataOut.channelIndexList: | |
99 | print channelIndexList |
|
99 | print channelIndexList | |
100 | raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex |
|
100 | raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex | |
101 |
|
101 | |||
102 | # nChannels = len(channelIndexList) |
|
102 | # nChannels = len(channelIndexList) | |
103 | if self.dataOut.flagDataAsBlock: |
|
103 | if self.dataOut.flagDataAsBlock: | |
104 | """ |
|
104 | """ | |
105 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
105 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
106 | """ |
|
106 | """ | |
107 | data = self.dataOut.data[channelIndexList,:,:] |
|
107 | data = self.dataOut.data[channelIndexList,:,:] | |
108 | else: |
|
108 | else: | |
109 | data = self.dataOut.data[channelIndexList,:] |
|
109 | data = self.dataOut.data[channelIndexList,:] | |
110 |
|
110 | |||
111 | self.dataOut.data = data |
|
111 | self.dataOut.data = data | |
112 | self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] |
|
112 | self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] | |
113 | # self.dataOut.nChannels = nChannels |
|
113 | # self.dataOut.nChannels = nChannels | |
114 |
|
114 | |||
115 | return 1 |
|
115 | return 1 | |
116 |
|
116 | |||
117 | def selectHeights(self, minHei=None, maxHei=None): |
|
117 | def selectHeights(self, minHei=None, maxHei=None): | |
118 | """ |
|
118 | """ | |
119 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
119 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango | |
120 | minHei <= height <= maxHei |
|
120 | minHei <= height <= maxHei | |
121 |
|
121 | |||
122 | Input: |
|
122 | Input: | |
123 | minHei : valor minimo de altura a considerar |
|
123 | minHei : valor minimo de altura a considerar | |
124 | maxHei : valor maximo de altura a considerar |
|
124 | maxHei : valor maximo de altura a considerar | |
125 |
|
125 | |||
126 | Affected: |
|
126 | Affected: | |
127 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
127 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex | |
128 |
|
128 | |||
129 | Return: |
|
129 | Return: | |
130 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
130 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
131 | """ |
|
131 | """ | |
132 |
|
132 | |||
133 | if minHei == None: |
|
133 | if minHei == None: | |
134 | minHei = self.dataOut.heightList[0] |
|
134 | minHei = self.dataOut.heightList[0] | |
135 |
|
135 | |||
136 | if maxHei == None: |
|
136 | if maxHei == None: | |
137 | maxHei = self.dataOut.heightList[-1] |
|
137 | maxHei = self.dataOut.heightList[-1] | |
138 |
|
138 | |||
139 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): |
|
139 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): | |
140 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
140 | raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) | |
141 |
|
141 | |||
142 |
|
142 | |||
143 | if (maxHei > self.dataOut.heightList[-1]): |
|
143 | if (maxHei > self.dataOut.heightList[-1]): | |
144 | maxHei = self.dataOut.heightList[-1] |
|
144 | maxHei = self.dataOut.heightList[-1] | |
145 | # raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) |
|
145 | # raise ValueError, "some value in (%d,%d) is not valid" % (minHei, maxHei) | |
146 |
|
146 | |||
147 | minIndex = 0 |
|
147 | minIndex = 0 | |
148 | maxIndex = 0 |
|
148 | maxIndex = 0 | |
149 | heights = self.dataOut.heightList |
|
149 | heights = self.dataOut.heightList | |
150 |
|
150 | |||
151 | inda = numpy.where(heights >= minHei) |
|
151 | inda = numpy.where(heights >= minHei) | |
152 | indb = numpy.where(heights <= maxHei) |
|
152 | indb = numpy.where(heights <= maxHei) | |
153 |
|
153 | |||
154 | try: |
|
154 | try: | |
155 | minIndex = inda[0][0] |
|
155 | minIndex = inda[0][0] | |
156 | except: |
|
156 | except: | |
157 | minIndex = 0 |
|
157 | minIndex = 0 | |
158 |
|
158 | |||
159 | try: |
|
159 | try: | |
160 | maxIndex = indb[0][-1] |
|
160 | maxIndex = indb[0][-1] | |
161 | except: |
|
161 | except: | |
162 | maxIndex = len(heights) |
|
162 | maxIndex = len(heights) | |
163 |
|
163 | |||
164 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
164 | self.selectHeightsByIndex(minIndex, maxIndex) | |
165 |
|
165 | |||
166 | return 1 |
|
166 | return 1 | |
167 |
|
167 | |||
168 |
|
168 | |||
169 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
169 | def selectHeightsByIndex(self, minIndex, maxIndex): | |
170 | """ |
|
170 | """ | |
171 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
171 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango | |
172 | minIndex <= index <= maxIndex |
|
172 | minIndex <= index <= maxIndex | |
173 |
|
173 | |||
174 | Input: |
|
174 | Input: | |
175 | minIndex : valor de indice minimo de altura a considerar |
|
175 | minIndex : valor de indice minimo de altura a considerar | |
176 | maxIndex : valor de indice maximo de altura a considerar |
|
176 | maxIndex : valor de indice maximo de altura a considerar | |
177 |
|
177 | |||
178 | Affected: |
|
178 | Affected: | |
179 | self.dataOut.data |
|
179 | self.dataOut.data | |
180 | self.dataOut.heightList |
|
180 | self.dataOut.heightList | |
181 |
|
181 | |||
182 | Return: |
|
182 | Return: | |
183 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
183 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
184 | """ |
|
184 | """ | |
185 |
|
185 | |||
186 | if (minIndex < 0) or (minIndex > maxIndex): |
|
186 | if (minIndex < 0) or (minIndex > maxIndex): | |
187 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
187 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) | |
188 |
|
188 | |||
189 | if (maxIndex >= self.dataOut.nHeights): |
|
189 | if (maxIndex >= self.dataOut.nHeights): | |
190 | maxIndex = self.dataOut.nHeights |
|
190 | maxIndex = self.dataOut.nHeights | |
191 | # raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
191 | # raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) | |
192 |
|
192 | |||
193 | # nHeights = maxIndex - minIndex + 1 |
|
193 | # nHeights = maxIndex - minIndex + 1 | |
194 |
|
194 | |||
195 | #voltage |
|
195 | #voltage | |
196 | if self.dataOut.flagDataAsBlock: |
|
196 | if self.dataOut.flagDataAsBlock: | |
197 | """ |
|
197 | """ | |
198 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
198 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
199 | """ |
|
199 | """ | |
200 | data = self.dataOut.data[:,minIndex:maxIndex,:] |
|
200 | data = self.dataOut.data[:,minIndex:maxIndex,:] | |
201 | else: |
|
201 | else: | |
202 | data = self.dataOut.data[:,minIndex:maxIndex] |
|
202 | data = self.dataOut.data[:,minIndex:maxIndex] | |
203 |
|
203 | |||
204 | # firstHeight = self.dataOut.heightList[minIndex] |
|
204 | # firstHeight = self.dataOut.heightList[minIndex] | |
205 |
|
205 | |||
206 | self.dataOut.data = data |
|
206 | self.dataOut.data = data | |
207 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex] |
|
207 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex] | |
208 |
|
208 | |||
209 | if self.dataOut.nHeights <= 1: |
|
209 | if self.dataOut.nHeights <= 1: | |
210 | raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights) |
|
210 | raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights) | |
211 |
|
211 | |||
212 | return 1 |
|
212 | return 1 | |
213 |
|
213 | |||
214 |
|
214 | |||
215 | def filterByHeights(self, window): |
|
215 | def filterByHeights(self, window): | |
216 |
|
216 | |||
217 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] |
|
217 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] | |
218 |
|
218 | |||
219 | if window == None: |
|
219 | if window == None: | |
220 | window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight |
|
220 | window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight | |
221 |
|
221 | |||
222 | newdelta = deltaHeight * window |
|
222 | newdelta = deltaHeight * window | |
223 | r = self.dataOut.nHeights % window |
|
223 | r = self.dataOut.nHeights % window | |
224 | newheights = (self.dataOut.nHeights-r)/window |
|
224 | newheights = (self.dataOut.nHeights-r)/window | |
225 |
|
225 | |||
226 | if newheights <= 1: |
|
226 | if newheights <= 1: | |
227 | raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window) |
|
227 | raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window) | |
228 |
|
228 | |||
229 | if self.dataOut.flagDataAsBlock: |
|
229 | if self.dataOut.flagDataAsBlock: | |
230 | """ |
|
230 | """ | |
231 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
231 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
232 | """ |
|
232 | """ | |
233 | buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r] |
|
233 | buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r] | |
234 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window) |
|
234 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window) | |
235 | buffer = numpy.sum(buffer,3) |
|
235 | buffer = numpy.sum(buffer,3) | |
236 |
|
236 | |||
237 | else: |
|
237 | else: | |
238 | buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r] |
|
238 | buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r] | |
239 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window) |
|
239 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window) | |
240 | buffer = numpy.sum(buffer,2) |
|
240 | buffer = numpy.sum(buffer,2) | |
241 |
|
241 | |||
242 | self.dataOut.data = buffer |
|
242 | self.dataOut.data = buffer | |
243 | self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta |
|
243 | self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta | |
244 | self.dataOut.windowOfFilter = window |
|
244 | self.dataOut.windowOfFilter = window | |
245 |
|
245 | |||
246 | def setH0(self, h0, deltaHeight = None): |
|
246 | def setH0(self, h0, deltaHeight = None): | |
247 |
|
247 | |||
248 | if not deltaHeight: |
|
248 | if not deltaHeight: | |
249 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] |
|
249 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] | |
250 |
|
250 | |||
251 | nHeights = self.dataOut.nHeights |
|
251 | nHeights = self.dataOut.nHeights | |
252 |
|
252 | |||
253 | newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight |
|
253 | newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight | |
254 |
|
254 | |||
255 | self.dataOut.heightList = newHeiRange |
|
255 | self.dataOut.heightList = newHeiRange | |
256 |
|
256 | |||
257 | def deFlip(self, channelList = []): |
|
257 | def deFlip(self, channelList = []): | |
258 |
|
258 | |||
259 | data = self.dataOut.data.copy() |
|
259 | data = self.dataOut.data.copy() | |
260 |
|
260 | |||
261 | if self.dataOut.flagDataAsBlock: |
|
261 | if self.dataOut.flagDataAsBlock: | |
262 | flip = self.flip |
|
262 | flip = self.flip | |
263 | profileList = range(self.dataOut.nProfiles) |
|
263 | profileList = range(self.dataOut.nProfiles) | |
264 |
|
264 | |||
265 | if not channelList: |
|
265 | if not channelList: | |
266 | for thisProfile in profileList: |
|
266 | for thisProfile in profileList: | |
267 | data[:,thisProfile,:] = data[:,thisProfile,:]*flip |
|
267 | data[:,thisProfile,:] = data[:,thisProfile,:]*flip | |
268 | flip *= -1.0 |
|
268 | flip *= -1.0 | |
269 | else: |
|
269 | else: | |
270 | for thisChannel in channelList: |
|
270 | for thisChannel in channelList: | |
271 | if thisChannel not in self.dataOut.channelList: |
|
271 | if thisChannel not in self.dataOut.channelList: | |
272 | continue |
|
272 | continue | |
273 |
|
273 | |||
274 | for thisProfile in profileList: |
|
274 | for thisProfile in profileList: | |
275 | data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip |
|
275 | data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip | |
276 | flip *= -1.0 |
|
276 | flip *= -1.0 | |
277 |
|
277 | |||
278 | self.flip = flip |
|
278 | self.flip = flip | |
279 |
|
279 | |||
280 | else: |
|
280 | else: | |
281 | if not channelList: |
|
281 | if not channelList: | |
282 | data[:,:] = data[:,:]*self.flip |
|
282 | data[:,:] = data[:,:]*self.flip | |
283 | else: |
|
283 | else: | |
284 | for thisChannel in channelList: |
|
284 | for thisChannel in channelList: | |
285 | if thisChannel not in self.dataOut.channelList: |
|
285 | if thisChannel not in self.dataOut.channelList: | |
286 | continue |
|
286 | continue | |
287 |
|
287 | |||
288 | data[thisChannel,:] = data[thisChannel,:]*self.flip |
|
288 | data[thisChannel,:] = data[thisChannel,:]*self.flip | |
289 |
|
289 | |||
290 | self.flip *= -1. |
|
290 | self.flip *= -1. | |
291 |
|
291 | |||
292 | self.dataOut.data = data |
|
292 | self.dataOut.data = data | |
293 |
|
293 | |||
294 | def setRadarFrequency(self, frequency=None): |
|
294 | def setRadarFrequency(self, frequency=None): | |
295 |
|
295 | |||
296 | if frequency != None: |
|
296 | if frequency != None: | |
297 | self.dataOut.frequency = frequency |
|
297 | self.dataOut.frequency = frequency | |
298 |
|
298 | |||
299 | return 1 |
|
299 | return 1 | |
300 |
|
300 | |||
301 | class CohInt(Operation): |
|
301 | class CohInt(Operation): | |
302 |
|
302 | |||
303 | isConfig = False |
|
303 | isConfig = False | |
304 |
|
304 | |||
305 | __profIndex = 0 |
|
305 | __profIndex = 0 | |
306 | __withOverapping = False |
|
306 | __withOverapping = False | |
307 |
|
307 | |||
308 | __byTime = False |
|
308 | __byTime = False | |
309 | __initime = None |
|
309 | __initime = None | |
310 | __lastdatatime = None |
|
310 | __lastdatatime = None | |
311 | __integrationtime = None |
|
311 | __integrationtime = None | |
312 |
|
312 | |||
313 | __buffer = None |
|
313 | __buffer = None | |
314 |
|
314 | |||
315 | __dataReady = False |
|
315 | __dataReady = False | |
316 |
|
316 | |||
317 | n = None |
|
317 | n = None | |
318 |
|
318 | |||
319 |
|
319 | |||
320 | def __init__(self): |
|
320 | def __init__(self): | |
321 |
|
321 | |||
322 | Operation.__init__(self) |
|
322 | Operation.__init__(self) | |
323 |
|
323 | |||
324 | # self.isConfig = False |
|
324 | # self.isConfig = False | |
325 |
|
325 | |||
326 | def setup(self, n=None, timeInterval=None, overlapping=False, byblock=False): |
|
326 | def setup(self, n=None, timeInterval=None, overlapping=False, byblock=False): | |
327 | """ |
|
327 | """ | |
328 | Set the parameters of the integration class. |
|
328 | Set the parameters of the integration class. | |
329 |
|
329 | |||
330 | Inputs: |
|
330 | Inputs: | |
331 |
|
331 | |||
332 | n : Number of coherent integrations |
|
332 | n : Number of coherent integrations | |
333 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work |
|
333 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
334 | overlapping : |
|
334 | overlapping : | |
335 |
|
335 | |||
336 | """ |
|
336 | """ | |
337 |
|
337 | |||
338 | self.__initime = None |
|
338 | self.__initime = None | |
339 | self.__lastdatatime = 0 |
|
339 | self.__lastdatatime = 0 | |
340 | self.__buffer = None |
|
340 | self.__buffer = None | |
341 | self.__dataReady = False |
|
341 | self.__dataReady = False | |
342 | self.byblock = byblock |
|
342 | self.byblock = byblock | |
343 |
|
343 | |||
344 | if n == None and timeInterval == None: |
|
344 | if n == None and timeInterval == None: | |
345 | raise ValueError, "n or timeInterval should be specified ..." |
|
345 | raise ValueError, "n or timeInterval should be specified ..." | |
346 |
|
346 | |||
347 | if n != None: |
|
347 | if n != None: | |
348 | self.n = n |
|
348 | self.n = n | |
349 | self.__byTime = False |
|
349 | self.__byTime = False | |
350 | else: |
|
350 | else: | |
351 | self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line |
|
351 | self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line | |
352 | self.n = 9999 |
|
352 | self.n = 9999 | |
353 | self.__byTime = True |
|
353 | self.__byTime = True | |
354 |
|
354 | |||
355 | if overlapping: |
|
355 | if overlapping: | |
356 | self.__withOverapping = True |
|
356 | self.__withOverapping = True | |
357 | self.__buffer = None |
|
357 | self.__buffer = None | |
358 | else: |
|
358 | else: | |
359 | self.__withOverapping = False |
|
359 | self.__withOverapping = False | |
360 | self.__buffer = 0 |
|
360 | self.__buffer = 0 | |
361 |
|
361 | |||
362 | self.__profIndex = 0 |
|
362 | self.__profIndex = 0 | |
363 |
|
363 | |||
364 | def putData(self, data): |
|
364 | def putData(self, data): | |
365 |
|
365 | |||
366 | """ |
|
366 | """ | |
367 | Add a profile to the __buffer and increase in one the __profileIndex |
|
367 | Add a profile to the __buffer and increase in one the __profileIndex | |
368 |
|
368 | |||
369 | """ |
|
369 | """ | |
370 |
|
370 | |||
371 | if not self.__withOverapping: |
|
371 | if not self.__withOverapping: | |
372 | self.__buffer += data.copy() |
|
372 | self.__buffer += data.copy() | |
373 | self.__profIndex += 1 |
|
373 | self.__profIndex += 1 | |
374 | return |
|
374 | return | |
375 |
|
375 | |||
376 | #Overlapping data |
|
376 | #Overlapping data | |
377 | nChannels, nHeis = data.shape |
|
377 | nChannels, nHeis = data.shape | |
378 | data = numpy.reshape(data, (1, nChannels, nHeis)) |
|
378 | data = numpy.reshape(data, (1, nChannels, nHeis)) | |
379 |
|
379 | |||
380 | #If the buffer is empty then it takes the data value |
|
380 | #If the buffer is empty then it takes the data value | |
381 | if self.__buffer == None: |
|
381 | if self.__buffer == None: | |
382 | self.__buffer = data |
|
382 | self.__buffer = data | |
383 | self.__profIndex += 1 |
|
383 | self.__profIndex += 1 | |
384 | return |
|
384 | return | |
385 |
|
385 | |||
386 | #If the buffer length is lower than n then stakcing the data value |
|
386 | #If the buffer length is lower than n then stakcing the data value | |
387 | if self.__profIndex < self.n: |
|
387 | if self.__profIndex < self.n: | |
388 | self.__buffer = numpy.vstack((self.__buffer, data)) |
|
388 | self.__buffer = numpy.vstack((self.__buffer, data)) | |
389 | self.__profIndex += 1 |
|
389 | self.__profIndex += 1 | |
390 | return |
|
390 | return | |
391 |
|
391 | |||
392 | #If the buffer length is equal to n then replacing the last buffer value with the data value |
|
392 | #If the buffer length is equal to n then replacing the last buffer value with the data value | |
393 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) |
|
393 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) | |
394 | self.__buffer[self.n-1] = data |
|
394 | self.__buffer[self.n-1] = data | |
395 | self.__profIndex = self.n |
|
395 | self.__profIndex = self.n | |
396 | return |
|
396 | return | |
397 |
|
397 | |||
398 |
|
398 | |||
399 | def pushData(self): |
|
399 | def pushData(self): | |
400 | """ |
|
400 | """ | |
401 | Return the sum of the last profiles and the profiles used in the sum. |
|
401 | Return the sum of the last profiles and the profiles used in the sum. | |
402 |
|
402 | |||
403 | Affected: |
|
403 | Affected: | |
404 |
|
404 | |||
405 | self.__profileIndex |
|
405 | self.__profileIndex | |
406 |
|
406 | |||
407 | """ |
|
407 | """ | |
408 |
|
408 | |||
409 | if not self.__withOverapping: |
|
409 | if not self.__withOverapping: | |
410 | data = self.__buffer |
|
410 | data = self.__buffer | |
411 | n = self.__profIndex |
|
411 | n = self.__profIndex | |
412 |
|
412 | |||
413 | self.__buffer = 0 |
|
413 | self.__buffer = 0 | |
414 | self.__profIndex = 0 |
|
414 | self.__profIndex = 0 | |
415 |
|
415 | |||
416 | return data, n |
|
416 | return data, n | |
417 |
|
417 | |||
418 | #Integration with Overlapping |
|
418 | #Integration with Overlapping | |
419 | data = numpy.sum(self.__buffer, axis=0) |
|
419 | data = numpy.sum(self.__buffer, axis=0) | |
420 | n = self.__profIndex |
|
420 | n = self.__profIndex | |
421 |
|
421 | |||
422 | return data, n |
|
422 | return data, n | |
423 |
|
423 | |||
424 | def byProfiles(self, data): |
|
424 | def byProfiles(self, data): | |
425 |
|
425 | |||
426 | self.__dataReady = False |
|
426 | self.__dataReady = False | |
427 | avgdata = None |
|
427 | avgdata = None | |
428 | # n = None |
|
428 | # n = None | |
429 |
|
429 | |||
430 | self.putData(data) |
|
430 | self.putData(data) | |
431 |
|
431 | |||
432 | if self.__profIndex == self.n: |
|
432 | if self.__profIndex == self.n: | |
433 |
|
433 | |||
434 | avgdata, n = self.pushData() |
|
434 | avgdata, n = self.pushData() | |
435 | self.__dataReady = True |
|
435 | self.__dataReady = True | |
436 |
|
436 | |||
437 | return avgdata |
|
437 | return avgdata | |
438 |
|
438 | |||
439 | def byTime(self, data, datatime): |
|
439 | def byTime(self, data, datatime): | |
440 |
|
440 | |||
441 | self.__dataReady = False |
|
441 | self.__dataReady = False | |
442 | avgdata = None |
|
442 | avgdata = None | |
443 | n = None |
|
443 | n = None | |
444 |
|
444 | |||
445 | self.putData(data) |
|
445 | self.putData(data) | |
446 |
|
446 | |||
447 | if (datatime - self.__initime) >= self.__integrationtime: |
|
447 | if (datatime - self.__initime) >= self.__integrationtime: | |
448 | avgdata, n = self.pushData() |
|
448 | avgdata, n = self.pushData() | |
449 | self.n = n |
|
449 | self.n = n | |
450 | self.__dataReady = True |
|
450 | self.__dataReady = True | |
451 |
|
451 | |||
452 | return avgdata |
|
452 | return avgdata | |
453 |
|
453 | |||
454 | def integrate(self, data, datatime=None): |
|
454 | def integrate(self, data, datatime=None): | |
455 |
|
455 | |||
456 | if self.__initime == None: |
|
456 | if self.__initime == None: | |
457 | self.__initime = datatime |
|
457 | self.__initime = datatime | |
458 |
|
458 | |||
459 | if self.__byTime: |
|
459 | if self.__byTime: | |
460 | avgdata = self.byTime(data, datatime) |
|
460 | avgdata = self.byTime(data, datatime) | |
461 | else: |
|
461 | else: | |
462 | avgdata = self.byProfiles(data) |
|
462 | avgdata = self.byProfiles(data) | |
463 |
|
463 | |||
464 |
|
464 | |||
465 | self.__lastdatatime = datatime |
|
465 | self.__lastdatatime = datatime | |
466 |
|
466 | |||
467 | if avgdata == None: |
|
467 | if avgdata == None: | |
468 | return None, None |
|
468 | return None, None | |
469 |
|
469 | |||
470 | avgdatatime = self.__initime |
|
470 | avgdatatime = self.__initime | |
471 |
|
471 | |||
472 | deltatime = datatime -self.__lastdatatime |
|
472 | deltatime = datatime -self.__lastdatatime | |
473 |
|
473 | |||
474 | if not self.__withOverapping: |
|
474 | if not self.__withOverapping: | |
475 | self.__initime = datatime |
|
475 | self.__initime = datatime | |
476 | else: |
|
476 | else: | |
477 | self.__initime += deltatime |
|
477 | self.__initime += deltatime | |
478 |
|
478 | |||
479 | return avgdata, avgdatatime |
|
479 | return avgdata, avgdatatime | |
480 |
|
480 | |||
481 | def integrateByBlock(self, dataOut): |
|
481 | def integrateByBlock(self, dataOut): | |
482 |
|
482 | |||
483 | times = int(dataOut.data.shape[1]/self.n) |
|
483 | times = int(dataOut.data.shape[1]/self.n) | |
484 | avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex) |
|
484 | avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex) | |
485 |
|
485 | |||
486 | id_min = 0 |
|
486 | id_min = 0 | |
487 | id_max = self.n |
|
487 | id_max = self.n | |
488 |
|
488 | |||
489 | for i in range(times): |
|
489 | for i in range(times): | |
490 | junk = dataOut.data[:,id_min:id_max,:] |
|
490 | junk = dataOut.data[:,id_min:id_max,:] | |
491 | avgdata[:,i,:] = junk.sum(axis=1) |
|
491 | avgdata[:,i,:] = junk.sum(axis=1) | |
492 | id_min += self.n |
|
492 | id_min += self.n | |
493 | id_max += self.n |
|
493 | id_max += self.n | |
494 |
|
494 | |||
495 | timeInterval = dataOut.ippSeconds*self.n |
|
495 | timeInterval = dataOut.ippSeconds*self.n | |
496 | avgdatatime = (times - 1) * timeInterval + dataOut.utctime |
|
496 | avgdatatime = (times - 1) * timeInterval + dataOut.utctime | |
497 | self.__dataReady = True |
|
497 | self.__dataReady = True | |
498 | return avgdata, avgdatatime |
|
498 | return avgdata, avgdatatime | |
499 |
|
499 | |||
500 | def run(self, dataOut, **kwargs): |
|
500 | def run(self, dataOut, **kwargs): | |
501 |
|
501 | |||
502 | if not self.isConfig: |
|
502 | if not self.isConfig: | |
503 | self.setup(**kwargs) |
|
503 | self.setup(**kwargs) | |
504 | self.isConfig = True |
|
504 | self.isConfig = True | |
505 |
|
505 | |||
506 | if dataOut.flagDataAsBlock: |
|
506 | if dataOut.flagDataAsBlock: | |
507 | """ |
|
507 | """ | |
508 | Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
508 | Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
509 | """ |
|
509 | """ | |
510 | avgdata, avgdatatime = self.integrateByBlock(dataOut) |
|
510 | avgdata, avgdatatime = self.integrateByBlock(dataOut) | |
511 | else: |
|
511 | else: | |
512 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) |
|
512 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) | |
513 |
|
513 | |||
514 | # dataOut.timeInterval *= n |
|
514 | # dataOut.timeInterval *= n | |
515 | dataOut.flagNoData = True |
|
515 | dataOut.flagNoData = True | |
516 |
|
516 | |||
517 | if self.__dataReady: |
|
517 | if self.__dataReady: | |
518 | dataOut.data = avgdata |
|
518 | dataOut.data = avgdata | |
519 | dataOut.nCohInt *= self.n |
|
519 | dataOut.nCohInt *= self.n | |
520 | dataOut.utctime = avgdatatime |
|
520 | dataOut.utctime = avgdatatime | |
521 | # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt |
|
521 | # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt | |
522 | dataOut.flagNoData = False |
|
522 | dataOut.flagNoData = False | |
523 |
|
523 | |||
524 | class Decoder(Operation): |
|
524 | class Decoder(Operation): | |
525 |
|
525 | |||
526 | isConfig = False |
|
526 | isConfig = False | |
527 | __profIndex = 0 |
|
527 | __profIndex = 0 | |
528 |
|
528 | |||
529 | code = None |
|
529 | code = None | |
530 |
|
530 | |||
531 | nCode = None |
|
531 | nCode = None | |
532 | nBaud = None |
|
532 | nBaud = None | |
533 |
|
533 | |||
534 |
|
534 | |||
535 | def __init__(self): |
|
535 | def __init__(self): | |
536 |
|
536 | |||
537 | Operation.__init__(self) |
|
537 | Operation.__init__(self) | |
538 |
|
538 | |||
539 | self.times = None |
|
539 | self.times = None | |
540 | self.osamp = None |
|
540 | self.osamp = None | |
541 | # self.__setValues = False |
|
541 | # self.__setValues = False | |
542 | self.isConfig = False |
|
542 | self.isConfig = False | |
543 |
|
543 | |||
544 | def setup(self, code, osamp, dataOut): |
|
544 | def setup(self, code, osamp, dataOut): | |
545 |
|
545 | |||
546 | self.__profIndex = 0 |
|
546 | self.__profIndex = 0 | |
547 |
|
547 | |||
548 | self.code = code |
|
548 | self.code = code | |
549 |
|
549 | |||
550 | self.nCode = len(code) |
|
550 | self.nCode = len(code) | |
551 | self.nBaud = len(code[0]) |
|
551 | self.nBaud = len(code[0]) | |
552 |
|
552 | |||
553 | if (osamp != None) and (osamp >1): |
|
553 | if (osamp != None) and (osamp >1): | |
554 | self.osamp = osamp |
|
554 | self.osamp = osamp | |
555 | self.code = numpy.repeat(code, repeats=self.osamp, axis=1) |
|
555 | self.code = numpy.repeat(code, repeats=self.osamp, axis=1) | |
556 | self.nBaud = self.nBaud*self.osamp |
|
556 | self.nBaud = self.nBaud*self.osamp | |
557 |
|
557 | |||
558 | self.__nChannels = dataOut.nChannels |
|
558 | self.__nChannels = dataOut.nChannels | |
559 | self.__nProfiles = dataOut.nProfiles |
|
559 | self.__nProfiles = dataOut.nProfiles | |
560 | self.__nHeis = dataOut.nHeights |
|
560 | self.__nHeis = dataOut.nHeights | |
561 |
|
561 | |||
562 | if dataOut.flagDataAsBlock: |
|
562 | if dataOut.flagDataAsBlock: | |
563 |
|
563 | |||
564 | self.ndatadec = self.__nHeis #- self.nBaud + 1 |
|
564 | self.ndatadec = self.__nHeis #- self.nBaud + 1 | |
565 |
|
565 | |||
566 | self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex) |
|
566 | self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex) | |
567 |
|
567 | |||
568 | else: |
|
568 | else: | |
569 |
|
569 | |||
570 | __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex) |
|
570 | __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex) | |
571 |
|
571 | |||
572 | __codeBuffer[:,0:self.nBaud] = self.code |
|
572 | __codeBuffer[:,0:self.nBaud] = self.code | |
573 |
|
573 | |||
574 | self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1)) |
|
574 | self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1)) | |
575 |
|
575 | |||
576 | self.ndatadec = self.__nHeis #- self.nBaud + 1 |
|
576 | self.ndatadec = self.__nHeis #- self.nBaud + 1 | |
577 |
|
577 | |||
578 | self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex) |
|
578 | self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex) | |
579 |
|
579 | |||
580 | def convolutionInFreq(self, data): |
|
580 | def convolutionInFreq(self, data): | |
581 |
|
581 | |||
582 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
|
582 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) | |
583 |
|
583 | |||
584 | fft_data = numpy.fft.fft(data, axis=1) |
|
584 | fft_data = numpy.fft.fft(data, axis=1) | |
585 |
|
585 | |||
586 | conv = fft_data*fft_code |
|
586 | conv = fft_data*fft_code | |
587 |
|
587 | |||
588 | data = numpy.fft.ifft(conv,axis=1) |
|
588 | data = numpy.fft.ifft(conv,axis=1) | |
589 |
|
589 | |||
590 | datadec = data#[:,:] |
|
590 | datadec = data#[:,:] | |
591 |
|
591 | |||
592 | return datadec |
|
592 | return datadec | |
593 |
|
593 | |||
594 | def convolutionInFreqOpt(self, data): |
|
594 | def convolutionInFreqOpt(self, data): | |
595 |
|
595 | |||
596 | raise NotImplementedError |
|
596 | raise NotImplementedError | |
597 |
|
597 | |||
598 | # fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
|
598 | # fft_code = self.fft_code[self.__profIndex].reshape(1,-1) | |
599 | # |
|
599 | # | |
600 | # data = cfunctions.decoder(fft_code, data) |
|
600 | # data = cfunctions.decoder(fft_code, data) | |
601 | # |
|
601 | # | |
602 | # datadec = data#[:,:] |
|
602 | # datadec = data#[:,:] | |
603 | # |
|
603 | # | |
604 | # return datadec |
|
604 | # return datadec | |
605 |
|
605 | |||
606 | def convolutionInTime(self, data): |
|
606 | def convolutionInTime(self, data): | |
607 |
|
607 | |||
608 | code = self.code[self.__profIndex] |
|
608 | code = self.code[self.__profIndex] | |
609 |
|
609 | |||
610 | for i in range(self.__nChannels): |
|
610 | for i in range(self.__nChannels): | |
611 | self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='same') |
|
611 | self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='same') | |
612 |
|
612 | |||
613 | return self.datadecTime |
|
613 | return self.datadecTime | |
614 |
|
614 | |||
615 | def convolutionByBlockInTime(self, data): |
|
615 | def convolutionByBlockInTime(self, data): | |
616 |
|
616 | |||
617 | repetitions = self.__nProfiles / self.nCode |
|
617 | repetitions = self.__nProfiles / self.nCode | |
618 |
|
618 | |||
619 | junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize)) |
|
619 | junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize)) | |
620 | junk = junk.flatten() |
|
620 | junk = junk.flatten() | |
621 | code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud)) |
|
621 | code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud)) | |
622 |
|
622 | |||
623 | for i in range(self.__nChannels): |
|
623 | for i in range(self.__nChannels): | |
624 | for j in range(self.__nProfiles): |
|
624 | for j in range(self.__nProfiles): | |
625 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='same') |
|
625 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='same') | |
626 |
|
626 | |||
627 | return self.datadecTime |
|
627 | return self.datadecTime | |
628 |
|
628 | |||
629 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None): |
|
629 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None): | |
630 |
|
630 | |||
631 | if not self.isConfig: |
|
631 | if not self.isConfig: | |
632 |
|
632 | |||
633 | if code == None: |
|
633 | if code == None: | |
634 | code = dataOut.code |
|
634 | code = dataOut.code | |
635 | else: |
|
635 | else: | |
636 | code = numpy.array(code).reshape(nCode,nBaud) |
|
636 | code = numpy.array(code).reshape(nCode,nBaud) | |
637 |
|
637 | |||
638 | self.setup(code, osamp, dataOut) |
|
638 | self.setup(code, osamp, dataOut) | |
639 |
|
639 | |||
640 | self.isConfig = True |
|
640 | self.isConfig = True | |
641 |
|
641 | |||
642 | if dataOut.flagDataAsBlock: |
|
642 | if dataOut.flagDataAsBlock: | |
643 | """ |
|
643 | """ | |
644 | Decoding when data have been read as block, |
|
644 | Decoding when data have been read as block, | |
645 | """ |
|
645 | """ | |
646 | datadec = self.convolutionByBlockInTime(dataOut.data) |
|
646 | datadec = self.convolutionByBlockInTime(dataOut.data) | |
647 |
|
647 | |||
648 | else: |
|
648 | else: | |
649 | """ |
|
649 | """ | |
650 | Decoding when data have been read profile by profile |
|
650 | Decoding when data have been read profile by profile | |
651 | """ |
|
651 | """ | |
652 | if mode == 0: |
|
652 | if mode == 0: | |
653 | datadec = self.convolutionInTime(dataOut.data) |
|
653 | datadec = self.convolutionInTime(dataOut.data) | |
654 |
|
654 | |||
655 | if mode == 1: |
|
655 | if mode == 1: | |
656 | datadec = self.convolutionInFreq(dataOut.data) |
|
656 | datadec = self.convolutionInFreq(dataOut.data) | |
657 |
|
657 | |||
658 | if mode == 2: |
|
658 | if mode == 2: | |
659 | datadec = self.convolutionInFreqOpt(dataOut.data) |
|
659 | datadec = self.convolutionInFreqOpt(dataOut.data) | |
660 |
|
660 | |||
661 | dataOut.code = self.code |
|
661 | dataOut.code = self.code | |
662 | dataOut.nCode = self.nCode |
|
662 | dataOut.nCode = self.nCode | |
663 | dataOut.nBaud = self.nBaud |
|
663 | dataOut.nBaud = self.nBaud | |
664 |
|
664 | |||
665 | dataOut.data = datadec |
|
665 | dataOut.data = datadec | |
666 |
|
666 | |||
667 | dataOut.heightList = dataOut.heightList[0:self.ndatadec] |
|
667 | dataOut.heightList = dataOut.heightList[0:self.ndatadec] | |
668 |
|
668 | |||
669 | dataOut.flagDecodeData = True #asumo q la data esta decodificada |
|
669 | dataOut.flagDecodeData = True #asumo q la data esta decodificada | |
670 |
|
670 | |||
671 | if self.__profIndex == self.nCode-1: |
|
671 | if self.__profIndex == self.nCode-1: | |
672 | self.__profIndex = 0 |
|
672 | self.__profIndex = 0 | |
673 | return 1 |
|
673 | return 1 | |
674 |
|
674 | |||
675 | self.__profIndex += 1 |
|
675 | self.__profIndex += 1 | |
676 |
|
676 | |||
677 | return 1 |
|
677 | return 1 | |
678 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip |
|
678 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip | |
679 |
|
679 | |||
680 |
|
680 | |||
681 | class ProfileConcat(Operation): |
|
681 | class ProfileConcat(Operation): | |
682 |
|
682 | |||
683 | isConfig = False |
|
683 | isConfig = False | |
684 | buffer = None |
|
684 | buffer = None | |
685 |
|
685 | |||
686 | def __init__(self): |
|
686 | def __init__(self): | |
687 |
|
687 | |||
688 | Operation.__init__(self) |
|
688 | Operation.__init__(self) | |
689 | self.profileIndex = 0 |
|
689 | self.profileIndex = 0 | |
690 |
|
690 | |||
691 | def reset(self): |
|
691 | def reset(self): | |
692 | self.buffer = numpy.zeros_like(self.buffer) |
|
692 | self.buffer = numpy.zeros_like(self.buffer) | |
693 | self.start_index = 0 |
|
693 | self.start_index = 0 | |
694 | self.times = 1 |
|
694 | self.times = 1 | |
695 |
|
695 | |||
696 | def setup(self, data, m, n=1): |
|
696 | def setup(self, data, m, n=1): | |
697 | self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0])) |
|
697 | self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0])) | |
698 | self.nHeights = data.nHeights |
|
698 | self.nHeights = data.nHeights | |
699 | self.start_index = 0 |
|
699 | self.start_index = 0 | |
700 | self.times = 1 |
|
700 | self.times = 1 | |
701 |
|
701 | |||
702 | def concat(self, data): |
|
702 | def concat(self, data): | |
703 |
|
703 | |||
704 | self.buffer[:,self.start_index:self.profiles*self.times] = data.copy() |
|
704 | self.buffer[:,self.start_index:self.profiles*self.times] = data.copy() | |
705 | self.start_index = self.start_index + self.nHeights |
|
705 | self.start_index = self.start_index + self.nHeights | |
706 |
|
706 | |||
707 | def run(self, dataOut, m): |
|
707 | def run(self, dataOut, m): | |
708 |
|
708 | |||
709 | dataOut.flagNoData = True |
|
709 | dataOut.flagNoData = True | |
710 |
|
710 | |||
711 | if not self.isConfig: |
|
711 | if not self.isConfig: | |
712 | self.setup(dataOut.data, m, 1) |
|
712 | self.setup(dataOut.data, m, 1) | |
713 | self.isConfig = True |
|
713 | self.isConfig = True | |
714 |
|
714 | |||
715 | if dataOut.flagDataAsBlock: |
|
715 | if dataOut.flagDataAsBlock: | |
716 |
|
716 | |||
717 | raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False" |
|
717 | raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False" | |
718 |
|
718 | |||
719 | else: |
|
719 | else: | |
720 | self.concat(dataOut.data) |
|
720 | self.concat(dataOut.data) | |
721 | self.times += 1 |
|
721 | self.times += 1 | |
722 | if self.times > m: |
|
722 | if self.times > m: | |
723 | dataOut.data = self.buffer |
|
723 | dataOut.data = self.buffer | |
724 | self.reset() |
|
724 | self.reset() | |
725 | dataOut.flagNoData = False |
|
725 | dataOut.flagNoData = False | |
726 | # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas |
|
726 | # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas | |
727 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
727 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
728 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m |
|
728 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m | |
729 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) |
|
729 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) | |
730 | dataOut.ippSeconds *= m |
|
730 | dataOut.ippSeconds *= m | |
731 |
|
731 | |||
732 | class ProfileSelector(Operation): |
|
732 | class ProfileSelector(Operation): | |
733 |
|
733 | |||
734 | profileIndex = None |
|
734 | profileIndex = None | |
735 | # Tamanho total de los perfiles |
|
735 | # Tamanho total de los perfiles | |
736 | nProfiles = None |
|
736 | nProfiles = None | |
737 |
|
737 | |||
738 | def __init__(self): |
|
738 | def __init__(self): | |
739 |
|
739 | |||
740 | Operation.__init__(self) |
|
740 | Operation.__init__(self) | |
741 | self.profileIndex = 0 |
|
741 | self.profileIndex = 0 | |
742 |
|
742 | |||
743 | def incIndex(self): |
|
743 | def incIndex(self): | |
744 |
|
744 | |||
745 | self.profileIndex += 1 |
|
745 | self.profileIndex += 1 | |
746 |
|
746 | |||
747 | if self.profileIndex >= self.nProfiles: |
|
747 | if self.profileIndex >= self.nProfiles: | |
748 | self.profileIndex = 0 |
|
748 | self.profileIndex = 0 | |
749 |
|
749 | |||
750 | def isThisProfileInRange(self, profileIndex, minIndex, maxIndex): |
|
750 | def isThisProfileInRange(self, profileIndex, minIndex, maxIndex): | |
751 |
|
751 | |||
752 | if profileIndex < minIndex: |
|
752 | if profileIndex < minIndex: | |
753 | return False |
|
753 | return False | |
754 |
|
754 | |||
755 | if profileIndex > maxIndex: |
|
755 | if profileIndex > maxIndex: | |
756 | return False |
|
756 | return False | |
757 |
|
757 | |||
758 | return True |
|
758 | return True | |
759 |
|
759 | |||
760 | def isThisProfileInList(self, profileIndex, profileList): |
|
760 | def isThisProfileInList(self, profileIndex, profileList): | |
761 |
|
761 | |||
762 | if profileIndex not in profileList: |
|
762 | if profileIndex not in profileList: | |
763 | return False |
|
763 | return False | |
764 |
|
764 | |||
765 | return True |
|
765 | return True | |
766 |
|
766 | |||
767 | def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None): |
|
767 | def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None): | |
768 |
|
768 | |||
769 | """ |
|
769 | """ | |
770 | ProfileSelector: |
|
770 | ProfileSelector: | |
771 |
|
771 | |||
772 | Inputs: |
|
772 | Inputs: | |
773 | profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8) |
|
773 | profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8) | |
774 |
|
774 | |||
775 | profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30) |
|
775 | profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30) | |
776 |
|
776 | |||
777 | rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256)) |
|
777 | rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256)) | |
778 |
|
778 | |||
779 | """ |
|
779 | """ | |
780 |
|
780 | |||
781 | dataOut.flagNoData = True |
|
781 | dataOut.flagNoData = True | |
782 |
|
782 | |||
783 | if nProfiles: |
|
783 | if nProfiles: | |
784 | self.nProfiles = dataOut.nProfiles |
|
784 | self.nProfiles = dataOut.nProfiles | |
785 | else: |
|
785 | else: | |
786 | self.nProfiles = nProfiles |
|
786 | self.nProfiles = nProfiles | |
787 |
|
787 | |||
788 | if dataOut.flagDataAsBlock: |
|
788 | if dataOut.flagDataAsBlock: | |
789 | """ |
|
789 | """ | |
790 | data dimension = [nChannels, nProfiles, nHeis] |
|
790 | data dimension = [nChannels, nProfiles, nHeis] | |
791 | """ |
|
791 | """ | |
792 | if profileList != None: |
|
792 | if profileList != None: | |
793 | dataOut.data = dataOut.data[:,profileList,:] |
|
793 | dataOut.data = dataOut.data[:,profileList,:] | |
794 | dataOut.nProfiles = len(profileList) |
|
794 | dataOut.nProfiles = len(profileList) | |
795 | dataOut.profileIndex = dataOut.nProfiles - 1 |
|
795 | dataOut.profileIndex = dataOut.nProfiles - 1 | |
796 |
|
796 | |||
797 | if profileRangeList != None: |
|
797 | if profileRangeList != None: | |
798 | minIndex = profileRangeList[0] |
|
798 | minIndex = profileRangeList[0] | |
799 | maxIndex = profileRangeList[1] |
|
799 | maxIndex = profileRangeList[1] | |
800 |
|
800 | |||
801 | dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:] |
|
801 | dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:] | |
802 | dataOut.nProfiles = maxIndex - minIndex + 1 |
|
802 | dataOut.nProfiles = maxIndex - minIndex + 1 | |
803 | dataOut.profileIndex = dataOut.nProfiles - 1 |
|
803 | dataOut.profileIndex = dataOut.nProfiles - 1 | |
804 |
|
804 | |||
805 | if rangeList != None: |
|
805 | if rangeList != None: | |
806 | raise ValueError, "Profile Selector: Not implemented for rangeList yet" |
|
806 | raise ValueError, "Profile Selector: Not implemented for rangeList yet" | |
807 |
|
807 | |||
808 | dataOut.flagNoData = False |
|
808 | dataOut.flagNoData = False | |
809 |
|
809 | |||
810 | return True |
|
810 | return True | |
811 |
|
811 | |||
812 | else: |
|
812 | else: | |
813 | """ |
|
813 | """ | |
814 | data dimension = [nChannels, nHeis] |
|
814 | data dimension = [nChannels, nHeis] | |
815 |
|
815 | |||
816 | """ |
|
816 | """ | |
817 | if profileList != None: |
|
817 | if profileList != None: | |
818 |
|
818 | |||
819 | dataOut.nProfiles = len(profileList) |
|
819 | dataOut.nProfiles = len(profileList) | |
820 |
|
820 | |||
821 | if self.isThisProfileInList(dataOut.profileIndex, profileList): |
|
821 | if self.isThisProfileInList(dataOut.profileIndex, profileList): | |
822 | dataOut.flagNoData = False |
|
822 | dataOut.flagNoData = False | |
823 | dataOut.profileIndex = self.profileIndex |
|
823 | dataOut.profileIndex = self.profileIndex | |
824 |
|
824 | |||
825 | self.incIndex() |
|
825 | self.incIndex() | |
826 | return True |
|
826 | return True | |
827 |
|
827 | |||
828 |
|
828 | |||
829 | if profileRangeList != None: |
|
829 | if profileRangeList != None: | |
830 |
|
830 | |||
831 | minIndex = profileRangeList[0] |
|
831 | minIndex = profileRangeList[0] | |
832 | maxIndex = profileRangeList[1] |
|
832 | maxIndex = profileRangeList[1] | |
833 |
|
833 | |||
834 | dataOut.nProfiles = maxIndex - minIndex + 1 |
|
834 | dataOut.nProfiles = maxIndex - minIndex + 1 | |
835 |
|
835 | |||
836 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): |
|
836 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): | |
837 | dataOut.flagNoData = False |
|
837 | dataOut.flagNoData = False | |
838 | dataOut.profileIndex = self.profileIndex |
|
838 | dataOut.profileIndex = self.profileIndex | |
839 |
|
839 | |||
840 | self.incIndex() |
|
840 | self.incIndex() | |
841 | return True |
|
841 | return True | |
842 |
|
842 | |||
843 | if rangeList != None: |
|
843 | if rangeList != None: | |
844 |
|
844 | |||
845 | nProfiles = 0 |
|
845 | nProfiles = 0 | |
846 |
|
846 | |||
847 | for thisRange in rangeList: |
|
847 | for thisRange in rangeList: | |
848 | minIndex = thisRange[0] |
|
848 | minIndex = thisRange[0] | |
849 | maxIndex = thisRange[1] |
|
849 | maxIndex = thisRange[1] | |
850 |
|
850 | |||
851 | nProfiles += maxIndex - minIndex + 1 |
|
851 | nProfiles += maxIndex - minIndex + 1 | |
852 |
|
852 | |||
853 | dataOut.nProfiles = nProfiles |
|
853 | dataOut.nProfiles = nProfiles | |
854 |
|
854 | |||
855 | for thisRange in rangeList: |
|
855 | for thisRange in rangeList: | |
856 |
|
856 | |||
857 | minIndex = thisRange[0] |
|
857 | minIndex = thisRange[0] | |
858 | maxIndex = thisRange[1] |
|
858 | maxIndex = thisRange[1] | |
859 |
|
859 | |||
860 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): |
|
860 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): | |
861 |
|
861 | |||
862 | # print "profileIndex = ", dataOut.profileIndex |
|
862 | # print "profileIndex = ", dataOut.profileIndex | |
863 |
|
863 | |||
864 | dataOut.flagNoData = False |
|
864 | dataOut.flagNoData = False | |
865 | dataOut.profileIndex = self.profileIndex |
|
865 | dataOut.profileIndex = self.profileIndex | |
866 |
|
866 | |||
867 | self.incIndex() |
|
867 | self.incIndex() | |
868 | break |
|
868 | break | |
869 | return True |
|
869 | return True | |
870 |
|
870 | |||
871 |
|
871 | |||
872 | if beam != None: #beam is only for AMISR data |
|
872 | if beam != None: #beam is only for AMISR data | |
873 | if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]): |
|
873 | if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]): | |
874 | dataOut.flagNoData = False |
|
874 | dataOut.flagNoData = False | |
875 | dataOut.profileIndex = self.profileIndex |
|
875 | dataOut.profileIndex = self.profileIndex | |
876 |
|
876 | |||
877 | self.incIndex() |
|
877 | self.incIndex() | |
878 | return 1 |
|
878 | return 1 | |
879 |
|
879 | |||
880 | raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter" |
|
880 | raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter" | |
881 |
|
881 | |||
882 | return 0 |
|
882 | return 0 | |
883 |
|
883 | |||
884 |
|
884 | |||
885 |
|
885 | |||
886 | class Reshaper(Operation): |
|
886 | class Reshaper(Operation): | |
887 |
|
887 | |||
888 | def __init__(self): |
|
888 | def __init__(self): | |
889 |
|
889 | |||
890 | Operation.__init__(self) |
|
890 | Operation.__init__(self) | |
891 | self.updateNewHeights = True |
|
891 | self.updateNewHeights = True | |
892 |
|
892 | |||
893 | def run(self, dataOut, shape): |
|
893 | def run(self, dataOut, shape): | |
894 |
|
894 | |||
895 | if not dataOut.flagDataAsBlock: |
|
895 | if not dataOut.flagDataAsBlock: | |
896 | raise ValueError, "Reshaper can only be used when voltage have been read as Block, getBlock = True" |
|
896 | raise ValueError, "Reshaper can only be used when voltage have been read as Block, getBlock = True" | |
897 |
|
897 | |||
898 | if len(shape) != 3: |
|
898 | if len(shape) != 3: | |
899 | raise ValueError, "shape len should be equal to 3, (nChannels, nProfiles, nHeis)" |
|
899 | raise ValueError, "shape len should be equal to 3, (nChannels, nProfiles, nHeis)" | |
900 |
|
900 | |||
901 | shape_tuple = tuple(shape) |
|
901 | shape_tuple = tuple(shape) | |
902 | dataOut.data = numpy.reshape(dataOut.data, shape_tuple) |
|
902 | dataOut.data = numpy.reshape(dataOut.data, shape_tuple) | |
903 | dataOut.flagNoData = False |
|
903 | dataOut.flagNoData = False | |
904 |
|
904 | |||
905 | if self.updateNewHeights: |
|
905 | if self.updateNewHeights: | |
906 |
|
906 | |||
907 | old_nheights = dataOut.nHeights |
|
907 | old_nheights = dataOut.nHeights | |
908 | new_nheights = dataOut.data.shape[2] |
|
908 | new_nheights = dataOut.data.shape[2] | |
909 | factor = 1.0*new_nheights / old_nheights |
|
909 | factor = 1.0*new_nheights / old_nheights | |
910 |
|
910 | |||
911 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
911 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
912 |
|
912 | |||
913 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * factor |
|
913 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * factor | |
914 |
|
914 | |||
915 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) |
|
915 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) | |
916 |
|
916 | |||
917 | dataOut.nProfiles = dataOut.data.shape[1] |
|
917 | dataOut.nProfiles = dataOut.data.shape[1] | |
918 |
|
918 | |||
919 | dataOut.ippSeconds *= factor |
|
919 | dataOut.ippSeconds *= factor | |
920 |
|
920 | |||
921 | import collections |
|
921 | import collections | |
922 | from scipy.stats import mode |
|
922 | from scipy.stats import mode | |
923 |
|
923 | |||
924 | class Synchronize(Operation): |
|
924 | class Synchronize(Operation): | |
925 |
|
925 | |||
926 | isConfig = False |
|
926 | isConfig = False | |
927 | __profIndex = 0 |
|
927 | __profIndex = 0 | |
928 |
|
928 | |||
929 | def __init__(self): |
|
929 | def __init__(self): | |
930 |
|
930 | |||
931 | Operation.__init__(self) |
|
931 | Operation.__init__(self) | |
932 | # self.isConfig = False |
|
932 | # self.isConfig = False | |
933 | self.__powBuffer = None |
|
933 | self.__powBuffer = None | |
934 | self.__startIndex = 0 |
|
934 | self.__startIndex = 0 | |
935 | self.__pulseFound = False |
|
935 | self.__pulseFound = False | |
936 |
|
936 | |||
937 | def __findTxPulse(self, dataOut, channel=0, pulse_with = None): |
|
937 | def __findTxPulse(self, dataOut, channel=0, pulse_with = None): | |
938 |
|
938 | |||
939 | #Read data |
|
939 | #Read data | |
940 |
|
940 | |||
941 | powerdB = dataOut.getPower(channel = channel) |
|
941 | powerdB = dataOut.getPower(channel = channel) | |
942 | noisedB = dataOut.getNoise(channel = channel)[0] |
|
942 | noisedB = dataOut.getNoise(channel = channel)[0] | |
943 |
|
943 | |||
944 | self.__powBuffer.extend(powerdB.flatten()) |
|
944 | self.__powBuffer.extend(powerdB.flatten()) | |
945 |
|
945 | |||
946 | dataArray = numpy.array(self.__powBuffer) |
|
946 | dataArray = numpy.array(self.__powBuffer) | |
947 |
|
947 | |||
948 | filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same") |
|
948 | filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same") | |
949 |
|
949 | |||
950 | maxValue = numpy.nanmax(filteredPower) |
|
950 | maxValue = numpy.nanmax(filteredPower) | |
951 |
|
951 | |||
952 | if maxValue < noisedB + 10: |
|
952 | if maxValue < noisedB + 10: | |
953 | #No se encuentra ningun pulso de transmision |
|
953 | #No se encuentra ningun pulso de transmision | |
954 | return None |
|
954 | return None | |
955 |
|
955 | |||
956 | maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0] |
|
956 | maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0] | |
957 |
|
957 | |||
958 | if len(maxValuesIndex) < 2: |
|
958 | if len(maxValuesIndex) < 2: | |
959 | #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX |
|
959 | #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX | |
960 | return None |
|
960 | return None | |
961 |
|
961 | |||
962 | phasedMaxValuesIndex = maxValuesIndex - self.__nSamples |
|
962 | phasedMaxValuesIndex = maxValuesIndex - self.__nSamples | |
963 |
|
963 | |||
964 | #Seleccionar solo valores con un espaciamiento de nSamples |
|
964 | #Seleccionar solo valores con un espaciamiento de nSamples | |
965 | pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex) |
|
965 | pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex) | |
966 |
|
966 | |||
967 | if len(pulseIndex) < 2: |
|
967 | if len(pulseIndex) < 2: | |
968 | #Solo se encontro un pulso de transmision con ancho mayor a 1 |
|
968 | #Solo se encontro un pulso de transmision con ancho mayor a 1 | |
969 | return None |
|
969 | return None | |
970 |
|
970 | |||
971 | spacing = pulseIndex[1:] - pulseIndex[:-1] |
|
971 | spacing = pulseIndex[1:] - pulseIndex[:-1] | |
972 |
|
972 | |||
973 | #remover senales que se distancien menos de 10 unidades o muestras |
|
973 | #remover senales que se distancien menos de 10 unidades o muestras | |
974 | #(No deberian existir IPP menor a 10 unidades) |
|
974 | #(No deberian existir IPP menor a 10 unidades) | |
975 |
|
975 | |||
976 | realIndex = numpy.where(spacing > 10 )[0] |
|
976 | realIndex = numpy.where(spacing > 10 )[0] | |
977 |
|
977 | |||
978 | if len(realIndex) < 2: |
|
978 | if len(realIndex) < 2: | |
979 | #Solo se encontro un pulso de transmision con ancho mayor a 1 |
|
979 | #Solo se encontro un pulso de transmision con ancho mayor a 1 | |
980 | return None |
|
980 | return None | |
981 |
|
981 | |||
982 | #Eliminar pulsos anchos (deja solo la diferencia entre IPPs) |
|
982 | #Eliminar pulsos anchos (deja solo la diferencia entre IPPs) | |
983 | realPulseIndex = pulseIndex[realIndex] |
|
983 | realPulseIndex = pulseIndex[realIndex] | |
984 |
|
984 | |||
985 | period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0] |
|
985 | period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0] | |
986 |
|
986 | |||
987 | print "IPP = %d samples" %period |
|
987 | print "IPP = %d samples" %period | |
988 |
|
988 | |||
989 | self.__newNSamples = dataOut.nHeights #int(period) |
|
989 | self.__newNSamples = dataOut.nHeights #int(period) | |
990 | self.__startIndex = int(realPulseIndex[0]) |
|
990 | self.__startIndex = int(realPulseIndex[0]) | |
991 |
|
991 | |||
992 | return 1 |
|
992 | return 1 | |
993 |
|
993 | |||
994 |
|
994 | |||
995 | def setup(self, nSamples, nChannels, buffer_size = 4): |
|
995 | def setup(self, nSamples, nChannels, buffer_size = 4): | |
996 |
|
996 | |||
997 | self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float), |
|
997 | self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float), | |
998 | maxlen = buffer_size*nSamples) |
|
998 | maxlen = buffer_size*nSamples) | |
999 |
|
999 | |||
1000 | bufferList = [] |
|
1000 | bufferList = [] | |
1001 |
|
1001 | |||
1002 | for i in range(nChannels): |
|
1002 | for i in range(nChannels): | |
1003 | bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN, |
|
1003 | bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN, | |
1004 | maxlen = buffer_size*nSamples) |
|
1004 | maxlen = buffer_size*nSamples) | |
1005 |
|
1005 | |||
1006 | bufferList.append(bufferByChannel) |
|
1006 | bufferList.append(bufferByChannel) | |
1007 |
|
1007 | |||
1008 | self.__nSamples = nSamples |
|
1008 | self.__nSamples = nSamples | |
1009 | self.__nChannels = nChannels |
|
1009 | self.__nChannels = nChannels | |
1010 | self.__bufferList = bufferList |
|
1010 | self.__bufferList = bufferList | |
1011 |
|
1011 | |||
1012 | def run(self, dataOut, channel = 0): |
|
1012 | def run(self, dataOut, channel = 0): | |
1013 |
|
1013 | |||
1014 | if not self.isConfig: |
|
1014 | if not self.isConfig: | |
1015 | nSamples = dataOut.nHeights |
|
1015 | nSamples = dataOut.nHeights | |
1016 | nChannels = dataOut.nChannels |
|
1016 | nChannels = dataOut.nChannels | |
1017 | self.setup(nSamples, nChannels) |
|
1017 | self.setup(nSamples, nChannels) | |
1018 | self.isConfig = True |
|
1018 | self.isConfig = True | |
1019 |
|
1019 | |||
1020 | #Append new data to internal buffer |
|
1020 | #Append new data to internal buffer | |
1021 | for thisChannel in range(self.__nChannels): |
|
1021 | for thisChannel in range(self.__nChannels): | |
1022 | bufferByChannel = self.__bufferList[thisChannel] |
|
1022 | bufferByChannel = self.__bufferList[thisChannel] | |
1023 | bufferByChannel.extend(dataOut.data[thisChannel]) |
|
1023 | bufferByChannel.extend(dataOut.data[thisChannel]) | |
1024 |
|
1024 | |||
1025 | if self.__pulseFound: |
|
1025 | if self.__pulseFound: | |
1026 | self.__startIndex -= self.__nSamples |
|
1026 | self.__startIndex -= self.__nSamples | |
1027 |
|
1027 | |||
1028 | #Finding Tx Pulse |
|
1028 | #Finding Tx Pulse | |
1029 | if not self.__pulseFound: |
|
1029 | if not self.__pulseFound: | |
1030 | indexFound = self.__findTxPulse(dataOut, channel) |
|
1030 | indexFound = self.__findTxPulse(dataOut, channel) | |
1031 |
|
1031 | |||
1032 | if indexFound == None: |
|
1032 | if indexFound == None: | |
1033 | dataOut.flagNoData = True |
|
1033 | dataOut.flagNoData = True | |
1034 | return |
|
1034 | return | |
1035 |
|
1035 | |||
1036 | self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex) |
|
1036 | self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex) | |
1037 | self.__pulseFound = True |
|
1037 | self.__pulseFound = True | |
1038 | self.__startIndex = indexFound |
|
1038 | self.__startIndex = indexFound | |
1039 |
|
1039 | |||
1040 | #If pulse was found ... |
|
1040 | #If pulse was found ... | |
1041 | for thisChannel in range(self.__nChannels): |
|
1041 | for thisChannel in range(self.__nChannels): | |
1042 | bufferByChannel = self.__bufferList[thisChannel] |
|
1042 | bufferByChannel = self.__bufferList[thisChannel] | |
1043 | #print self.__startIndex |
|
1043 | #print self.__startIndex | |
1044 | x = numpy.array(bufferByChannel) |
|
1044 | x = numpy.array(bufferByChannel) | |
1045 | self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples] |
|
1045 | self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples] | |
1046 |
|
1046 | |||
1047 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1047 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1048 | dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight |
|
1048 | dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight | |
1049 | # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6 |
|
1049 | # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6 | |
1050 |
|
1050 | |||
1051 | dataOut.data = self.__arrayBuffer |
|
1051 | dataOut.data = self.__arrayBuffer | |
1052 |
|
1052 | |||
1053 | self.__startIndex += self.__newNSamples |
|
1053 | self.__startIndex += self.__newNSamples | |
1054 |
|
1054 | |||
1055 | return No newline at end of file |
|
1055 | return |
@@ -1,119 +1,119 | |||||
1 | import os, sys |
|
1 | import os, sys | |
2 | #import timeit |
|
2 | #import timeit | |
3 | import datetime |
|
3 | import datetime | |
4 |
|
4 | |||
5 | path = os.path.split(os.getcwd())[0] |
|
5 | path = os.path.split(os.getcwd())[0] | |
6 | path = os.path.split(path)[0] |
|
6 | path = os.path.split(path)[0] | |
7 |
|
7 | |||
8 |
sys.path. |
|
8 | sys.path.insert(0, path) | |
9 |
|
9 | |||
10 | from schainpy.controller import Project |
|
10 | from schainpy.controller import Project | |
11 |
|
11 | |||
12 | desc = "MST-ISR-EEJ Experiment Test" |
|
12 | desc = "MST-ISR-EEJ Experiment Test" | |
13 | filename = "mst_blocks.xml" |
|
13 | filename = "mst_blocks.xml" | |
14 |
|
14 | |||
15 | controllerObj = Project() |
|
15 | controllerObj = Project() | |
16 |
|
16 | |||
17 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
17 | controllerObj.setup(id = '191', name='test01', description=desc) | |
18 |
|
18 | |||
19 | #path = '/home/operaciones/mst_data/MST_ISR_EEJ/' |
|
19 | #path = '/home/operaciones/mst_data/MST_ISR_EEJ/' | |
20 | path ='/home/operaciones/mst_data' |
|
20 | path ='/home/operaciones/mst_data' | |
21 |
|
21 | |||
22 | figpath = '/home/operaciones/Pictures/mst_isr_eej/mst' |
|
22 | figpath = '/home/operaciones/Pictures/mst_isr_eej/mst' | |
23 |
|
23 | |||
24 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', |
|
24 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', | |
25 | path=path, |
|
25 | path=path, | |
26 | startDate='2014/05/01', |
|
26 | startDate='2014/05/01', | |
27 | endDate='2014/05/30', |
|
27 | endDate='2014/05/30', | |
28 | startTime='00:00:00', |
|
28 | startTime='00:00:00', | |
29 | endTime='23:59:59', |
|
29 | endTime='23:59:59', | |
30 | online=1, |
|
30 | online=1, | |
31 | delay=10, |
|
31 | delay=10, | |
32 | walk=1, |
|
32 | walk=1, | |
33 | getblock=1) |
|
33 | getblock=1) | |
34 |
|
34 | |||
35 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
35 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
36 |
|
36 | |||
37 | procUnitConfObjMST = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) |
|
37 | procUnitConfObjMST = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
38 |
|
38 | |||
39 | opObj11 = procUnitConfObjMST.addOperation(name='ProfileSelector', optype='other') |
|
39 | opObj11 = procUnitConfObjMST.addOperation(name='ProfileSelector', optype='other') | |
40 | profileIndex = '0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119' |
|
40 | profileIndex = '0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119' | |
41 | #profileIndex = '0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19' |
|
41 | #profileIndex = '0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19' | |
42 | opObj11.addParameter(name='profileList', value=profileIndex, format='intlist') |
|
42 | opObj11.addParameter(name='profileList', value=profileIndex, format='intlist') | |
43 | opObj11.addParameter(name='byblock', value='1', format='bool') |
|
43 | opObj11.addParameter(name='byblock', value='1', format='bool') | |
44 |
|
44 | |||
45 | opObj11 = procUnitConfObjMST.addOperation(name='Decoder', optype='other') |
|
45 | opObj11 = procUnitConfObjMST.addOperation(name='Decoder', optype='other') | |
46 | opObj11.addParameter(name='mode',value='3',format='int') |
|
46 | opObj11.addParameter(name='mode',value='3',format='int') | |
47 | opObj11.addParameter(name='times',value='10',format='int') |
|
47 | opObj11.addParameter(name='times',value='10',format='int') | |
48 |
|
48 | |||
49 | opObj11 = procUnitConfObjMST.addOperation(name='CohInt', optype='other') |
|
49 | opObj11 = procUnitConfObjMST.addOperation(name='CohInt', optype='other') | |
50 | opObj11.addParameter(name='n', value='20', format='int') |
|
50 | opObj11.addParameter(name='n', value='20', format='int') | |
51 | opObj11.addParameter(name='byblock', value='1', format='bool') |
|
51 | opObj11.addParameter(name='byblock', value='1', format='bool') | |
52 |
|
52 | |||
53 | procUnitConfObjMSTSpectra = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjMST.getId()) |
|
53 | procUnitConfObjMSTSpectra = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObjMST.getId()) | |
54 | procUnitConfObjMSTSpectra.addParameter(name='nFFTPoints', value='64', format='int') |
|
54 | procUnitConfObjMSTSpectra.addParameter(name='nFFTPoints', value='64', format='int') | |
55 | procUnitConfObjMSTSpectra.addParameter(name='nProfiles', value='64', format='int') |
|
55 | procUnitConfObjMSTSpectra.addParameter(name='nProfiles', value='64', format='int') | |
56 |
|
56 | |||
57 | opObj11 = procUnitConfObjMSTSpectra.addOperation(name='IncohInt', optype='other') |
|
57 | opObj11 = procUnitConfObjMSTSpectra.addOperation(name='IncohInt', optype='other') | |
58 | opObj11.addParameter(name='n', value='2', format='float') |
|
58 | opObj11.addParameter(name='n', value='2', format='float') | |
59 |
|
59 | |||
60 | opObj11 = procUnitConfObjMSTSpectra.addOperation(name='SpectraPlot', optype='other') |
|
60 | opObj11 = procUnitConfObjMSTSpectra.addOperation(name='SpectraPlot', optype='other') | |
61 | opObj11.addParameter(name='id', value='401', format='int') |
|
61 | opObj11.addParameter(name='id', value='401', format='int') | |
62 | opObj11.addParameter(name='wintitle', value='MST', format='str') |
|
62 | opObj11.addParameter(name='wintitle', value='MST', format='str') | |
63 | opObj11.addParameter(name='zmin', value='20', format='int') |
|
63 | opObj11.addParameter(name='zmin', value='20', format='int') | |
64 | opObj11.addParameter(name='zmax', value='40', format='int') |
|
64 | opObj11.addParameter(name='zmax', value='40', format='int') | |
65 | # # opObj11.addParameter(name='save', value='1', format='int') |
|
65 | # # opObj11.addParameter(name='save', value='1', format='int') | |
66 | opObj11.addParameter(name='figpath', value=figpath, format='str') |
|
66 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |
67 | opObj11.addParameter(name='wr_period', value='5', format='int') |
|
67 | opObj11.addParameter(name='wr_period', value='5', format='int') | |
68 | # # opObj11.addParameter(name='ftp', value='1', format='int') |
|
68 | # # opObj11.addParameter(name='ftp', value='1', format='int') | |
69 | # # opObj11.addParameter(name='server', value='jro-app.igp.gob.pe', format='str') |
|
69 | # # opObj11.addParameter(name='server', value='jro-app.igp.gob.pe', format='str') | |
70 | # # opObj11.addParameter(name='folder', value='/home/wmaster/graficos', format='str') |
|
70 | # # opObj11.addParameter(name='folder', value='/home/wmaster/graficos', format='str') | |
71 | # # opObj11.addParameter(name='username', value='wmaster', format='str') |
|
71 | # # opObj11.addParameter(name='username', value='wmaster', format='str') | |
72 | # # opObj11.addParameter(name='password', value='mst2010vhf', format='str') |
|
72 | # # opObj11.addParameter(name='password', value='mst2010vhf', format='str') | |
73 | # # opObj11.addParameter(name='ftp_wei', value='0', format='int') |
|
73 | # # opObj11.addParameter(name='ftp_wei', value='0', format='int') | |
74 | opObj11.addParameter(name='exp_code', value='19', format='int') |
|
74 | opObj11.addParameter(name='exp_code', value='19', format='int') | |
75 | # # opObj11.addParameter(name='sub_exp_code', value='0', format='int') |
|
75 | # # opObj11.addParameter(name='sub_exp_code', value='0', format='int') | |
76 | # # opObj11.addParameter(name='plot_pos', value='0', format='int') |
|
76 | # # opObj11.addParameter(name='plot_pos', value='0', format='int') | |
77 | # # |
|
77 | # # | |
78 | opObj11 = procUnitConfObjMSTSpectra.addOperation(name='RTIPlot', optype='other') |
|
78 | opObj11 = procUnitConfObjMSTSpectra.addOperation(name='RTIPlot', optype='other') | |
79 | opObj11.addParameter(name='id', value='402', format='int') |
|
79 | opObj11.addParameter(name='id', value='402', format='int') | |
80 | opObj11.addParameter(name='wintitle', value='MST', format='str') |
|
80 | opObj11.addParameter(name='wintitle', value='MST', format='str') | |
81 | opObj11.addParameter(name='showprofile', value='0', format='int') |
|
81 | opObj11.addParameter(name='showprofile', value='0', format='int') | |
82 | opObj11.addParameter(name='xmin', value='0', format='int') |
|
82 | opObj11.addParameter(name='xmin', value='0', format='int') | |
83 | opObj11.addParameter(name='xmax', value='24', format='int') |
|
83 | opObj11.addParameter(name='xmax', value='24', format='int') | |
84 | opObj11.addParameter(name='zmin', value='20', format='int') |
|
84 | opObj11.addParameter(name='zmin', value='20', format='int') | |
85 | opObj11.addParameter(name='zmax', value='40', format='int') |
|
85 | opObj11.addParameter(name='zmax', value='40', format='int') | |
86 | # # opObj11.addParameter(name='save', value='1', format='int') |
|
86 | # # opObj11.addParameter(name='save', value='1', format='int') | |
87 | opObj11.addParameter(name='figpath', value=figpath, format='str') |
|
87 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |
88 | opObj11.addParameter(name='wr_period', value='2', format='int') |
|
88 | opObj11.addParameter(name='wr_period', value='2', format='int') | |
89 | # # opObj11.addParameter(name='ftp', value='1', format='int') |
|
89 | # # opObj11.addParameter(name='ftp', value='1', format='int') | |
90 | # # opObj11.addParameter(name='server', value='jro-app.igp.gob.pe', format='str') |
|
90 | # # opObj11.addParameter(name='server', value='jro-app.igp.gob.pe', format='str') | |
91 | # # opObj11.addParameter(name='folder', value='/home/wmaster/graficos', format='str') |
|
91 | # # opObj11.addParameter(name='folder', value='/home/wmaster/graficos', format='str') | |
92 | # # opObj11.addParameter(name='username', value='wmaster', format='str') |
|
92 | # # opObj11.addParameter(name='username', value='wmaster', format='str') | |
93 | # # opObj11.addParameter(name='password', value='mst2010vhf', format='str') |
|
93 | # # opObj11.addParameter(name='password', value='mst2010vhf', format='str') | |
94 | # # opObj11.addParameter(name='ftp_wei', value='0', format='int') |
|
94 | # # opObj11.addParameter(name='ftp_wei', value='0', format='int') | |
95 | opObj11.addParameter(name='exp_code', value='19', format='int') |
|
95 | opObj11.addParameter(name='exp_code', value='19', format='int') | |
96 | # # opObj11.addParameter(name='sub_exp_code', value='0', format='int') |
|
96 | # # opObj11.addParameter(name='sub_exp_code', value='0', format='int') | |
97 | # # opObj11.addParameter(name='plot_pos', value='0', format='int') |
|
97 | # # opObj11.addParameter(name='plot_pos', value='0', format='int') | |
98 |
|
98 | |||
99 | opObj11 = procUnitConfObjMSTSpectra.addOperation(name='SendByFTP', optype='other') |
|
99 | opObj11 = procUnitConfObjMSTSpectra.addOperation(name='SendByFTP', optype='other') | |
100 | opObj11.addParameter(name='ext', value='*.png', format='str') |
|
100 | opObj11.addParameter(name='ext', value='*.png', format='str') | |
101 | opObj11.addParameter(name='localfolder', value=figpath, format='str') |
|
101 | opObj11.addParameter(name='localfolder', value=figpath, format='str') | |
102 | opObj11.addParameter(name='remotefolder', value='/home/wmaster/graficos', format='str') |
|
102 | opObj11.addParameter(name='remotefolder', value='/home/wmaster/graficos', format='str') | |
103 | opObj11.addParameter(name='server', value='10.10.120.125', format='str') |
|
103 | opObj11.addParameter(name='server', value='10.10.120.125', format='str') | |
104 | opObj11.addParameter(name='username', value='wmaster', format='str') |
|
104 | opObj11.addParameter(name='username', value='wmaster', format='str') | |
105 | opObj11.addParameter(name='password', value='mst2010vhf', format='str') |
|
105 | opObj11.addParameter(name='password', value='mst2010vhf', format='str') | |
106 | opObj11.addParameter(name='period', value='2', format='int') |
|
106 | opObj11.addParameter(name='period', value='2', format='int') | |
107 |
|
107 | |||
108 | print "Escribiendo el archivo XML" |
|
108 | print "Escribiendo el archivo XML" | |
109 | controllerObj.writeXml(filename) |
|
109 | controllerObj.writeXml(filename) | |
110 | print "Leyendo el archivo XML" |
|
110 | print "Leyendo el archivo XML" | |
111 | controllerObj.readXml(filename) |
|
111 | controllerObj.readXml(filename) | |
112 |
|
112 | |||
113 | controllerObj.createObjects() |
|
113 | controllerObj.createObjects() | |
114 | controllerObj.connectObjects() |
|
114 | controllerObj.connectObjects() | |
115 |
|
115 | |||
116 | #timeit.timeit('controllerObj.run()', number=2) |
|
116 | #timeit.timeit('controllerObj.run()', number=2) | |
117 |
|
117 | |||
118 | controllerObj.run() |
|
118 | controllerObj.run() | |
119 | #print fib(5) |
|
119 | #print fib(5) |
General Comments 0
You need to be logged in to leave comments.
Login now