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