##// END OF EJS Templates
Changes in data Parameters
Julio Valdez -
r802:16a66dcd77c0
parent child
Show More
@@ -1,1167 +1,1169
1 '''
1 '''
2
2
3 $Author: murco $
3 $Author: murco $
4 $Id: JROData.py 173 2012-11-20 15:06:21Z murco $
4 $Id: JROData.py 173 2012-11-20 15:06:21Z murco $
5 '''
5 '''
6
6
7 import copy
7 import copy
8 import numpy
8 import numpy
9 import datetime
9 import datetime
10
10
11 from jroheaderIO import SystemHeader, RadarControllerHeader
11 from jroheaderIO import SystemHeader, RadarControllerHeader
12
12
13 def getNumpyDtype(dataTypeCode):
13 def getNumpyDtype(dataTypeCode):
14
14
15 if dataTypeCode == 0:
15 if dataTypeCode == 0:
16 numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')])
16 numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')])
17 elif dataTypeCode == 1:
17 elif dataTypeCode == 1:
18 numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')])
18 numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')])
19 elif dataTypeCode == 2:
19 elif dataTypeCode == 2:
20 numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')])
20 numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')])
21 elif dataTypeCode == 3:
21 elif dataTypeCode == 3:
22 numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')])
22 numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')])
23 elif dataTypeCode == 4:
23 elif dataTypeCode == 4:
24 numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')])
24 numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')])
25 elif dataTypeCode == 5:
25 elif dataTypeCode == 5:
26 numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')])
26 numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')])
27 else:
27 else:
28 raise ValueError, 'dataTypeCode was not defined'
28 raise ValueError, 'dataTypeCode was not defined'
29
29
30 return numpyDtype
30 return numpyDtype
31
31
32 def getDataTypeCode(numpyDtype):
32 def getDataTypeCode(numpyDtype):
33
33
34 if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]):
34 if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]):
35 datatype = 0
35 datatype = 0
36 elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]):
36 elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]):
37 datatype = 1
37 datatype = 1
38 elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]):
38 elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]):
39 datatype = 2
39 datatype = 2
40 elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]):
40 elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]):
41 datatype = 3
41 datatype = 3
42 elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]):
42 elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]):
43 datatype = 4
43 datatype = 4
44 elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]):
44 elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]):
45 datatype = 5
45 datatype = 5
46 else:
46 else:
47 datatype = None
47 datatype = None
48
48
49 return datatype
49 return datatype
50
50
51 def hildebrand_sekhon(data, navg):
51 def hildebrand_sekhon(data, navg):
52 """
52 """
53 This method is for the objective determination of the noise level in Doppler spectra. This
53 This method is for the objective determination of the noise level in Doppler spectra. This
54 implementation technique is based on the fact that the standard deviation of the spectral
54 implementation technique is based on the fact that the standard deviation of the spectral
55 densities is equal to the mean spectral density for white Gaussian noise
55 densities is equal to the mean spectral density for white Gaussian noise
56
56
57 Inputs:
57 Inputs:
58 Data : heights
58 Data : heights
59 navg : numbers of averages
59 navg : numbers of averages
60
60
61 Return:
61 Return:
62 -1 : any error
62 -1 : any error
63 anoise : noise's level
63 anoise : noise's level
64 """
64 """
65
65
66 sortdata = numpy.sort(data,axis=None)
66 sortdata = numpy.sort(data,axis=None)
67 lenOfData = len(sortdata)
67 lenOfData = len(sortdata)
68 nums_min = lenOfData*0.2
68 nums_min = lenOfData*0.2
69
69
70 if nums_min <= 5:
70 if nums_min <= 5:
71 nums_min = 5
71 nums_min = 5
72
72
73 sump = 0.
73 sump = 0.
74
74
75 sumq = 0.
75 sumq = 0.
76
76
77 j = 0
77 j = 0
78
78
79 cont = 1
79 cont = 1
80
80
81 while((cont==1)and(j<lenOfData)):
81 while((cont==1)and(j<lenOfData)):
82
82
83 sump += sortdata[j]
83 sump += sortdata[j]
84
84
85 sumq += sortdata[j]**2
85 sumq += sortdata[j]**2
86
86
87 if j > nums_min:
87 if j > nums_min:
88 rtest = float(j)/(j-1) + 1.0/navg
88 rtest = float(j)/(j-1) + 1.0/navg
89 if ((sumq*j) > (rtest*sump**2)):
89 if ((sumq*j) > (rtest*sump**2)):
90 j = j - 1
90 j = j - 1
91 sump = sump - sortdata[j]
91 sump = sump - sortdata[j]
92 sumq = sumq - sortdata[j]**2
92 sumq = sumq - sortdata[j]**2
93 cont = 0
93 cont = 0
94
94
95 j += 1
95 j += 1
96
96
97 lnoise = sump /j
97 lnoise = sump /j
98 # stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1))
98 # stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1))
99 return lnoise
99 return lnoise
100
100
101 class Beam:
101 class Beam:
102 def __init__(self):
102 def __init__(self):
103 self.codeList = []
103 self.codeList = []
104 self.azimuthList = []
104 self.azimuthList = []
105 self.zenithList = []
105 self.zenithList = []
106
106
107 class GenericData(object):
107 class GenericData(object):
108
108
109 flagNoData = True
109 flagNoData = True
110
110
111 def __init__(self):
111 def __init__(self):
112
112
113 raise NotImplementedError
113 raise NotImplementedError
114
114
115 def copy(self, inputObj=None):
115 def copy(self, inputObj=None):
116
116
117 if inputObj == None:
117 if inputObj == None:
118 return copy.deepcopy(self)
118 return copy.deepcopy(self)
119
119
120 for key in inputObj.__dict__.keys():
120 for key in inputObj.__dict__.keys():
121
121
122 attribute = inputObj.__dict__[key]
122 attribute = inputObj.__dict__[key]
123
123
124 #If this attribute is a tuple or list
124 #If this attribute is a tuple or list
125 if type(inputObj.__dict__[key]) in (tuple, list):
125 if type(inputObj.__dict__[key]) in (tuple, list):
126 self.__dict__[key] = attribute[:]
126 self.__dict__[key] = attribute[:]
127 continue
127 continue
128
128
129 #If this attribute is another object or instance
129 #If this attribute is another object or instance
130 if hasattr(attribute, '__dict__'):
130 if hasattr(attribute, '__dict__'):
131 self.__dict__[key] = attribute.copy()
131 self.__dict__[key] = attribute.copy()
132 continue
132 continue
133
133
134 self.__dict__[key] = inputObj.__dict__[key]
134 self.__dict__[key] = inputObj.__dict__[key]
135
135
136 def deepcopy(self):
136 def deepcopy(self):
137
137
138 return copy.deepcopy(self)
138 return copy.deepcopy(self)
139
139
140 def isEmpty(self):
140 def isEmpty(self):
141
141
142 return self.flagNoData
142 return self.flagNoData
143
143
144 class JROData(GenericData):
144 class JROData(GenericData):
145
145
146 # m_BasicHeader = BasicHeader()
146 # m_BasicHeader = BasicHeader()
147 # m_ProcessingHeader = ProcessingHeader()
147 # m_ProcessingHeader = ProcessingHeader()
148
148
149 systemHeaderObj = SystemHeader()
149 systemHeaderObj = SystemHeader()
150
150
151 radarControllerHeaderObj = RadarControllerHeader()
151 radarControllerHeaderObj = RadarControllerHeader()
152
152
153 # data = None
153 # data = None
154
154
155 type = None
155 type = None
156
156
157 datatype = None #dtype but in string
157 datatype = None #dtype but in string
158
158
159 # dtype = None
159 # dtype = None
160
160
161 # nChannels = None
161 # nChannels = None
162
162
163 # nHeights = None
163 # nHeights = None
164
164
165 nProfiles = None
165 nProfiles = None
166
166
167 heightList = None
167 heightList = None
168
168
169 channelList = None
169 channelList = None
170
170
171 flagDiscontinuousBlock = False
171 flagDiscontinuousBlock = False
172
172
173 useLocalTime = False
173 useLocalTime = False
174
174
175 utctime = None
175 utctime = None
176
176
177 timeZone = None
177 timeZone = None
178
178
179 dstFlag = None
179 dstFlag = None
180
180
181 errorCount = None
181 errorCount = None
182
182
183 blocksize = None
183 blocksize = None
184
184
185 # nCode = None
185 # nCode = None
186 #
186 #
187 # nBaud = None
187 # nBaud = None
188 #
188 #
189 # code = None
189 # code = None
190
190
191 flagDecodeData = False #asumo q la data no esta decodificada
191 flagDecodeData = False #asumo q la data no esta decodificada
192
192
193 flagDeflipData = False #asumo q la data no esta sin flip
193 flagDeflipData = False #asumo q la data no esta sin flip
194
194
195 flagShiftFFT = False
195 flagShiftFFT = False
196
196
197 # ippSeconds = None
197 # ippSeconds = None
198
198
199 # timeInterval = None
199 # timeInterval = None
200
200
201 nCohInt = None
201 nCohInt = None
202
202
203 # noise = None
203 # noise = None
204
204
205 windowOfFilter = 1
205 windowOfFilter = 1
206
206
207 #Speed of ligth
207 #Speed of ligth
208 C = 3e8
208 C = 3e8
209
209
210 frequency = 49.92e6
210 frequency = 49.92e6
211
211
212 realtime = False
212 realtime = False
213
213
214 beacon_heiIndexList = None
214 beacon_heiIndexList = None
215
215
216 last_block = None
216 last_block = None
217
217
218 blocknow = None
218 blocknow = None
219
219
220 azimuth = None
220 azimuth = None
221
221
222 zenith = None
222 zenith = None
223
223
224 beam = Beam()
224 beam = Beam()
225
225
226 profileIndex = None
226 profileIndex = None
227
227
228 def __init__(self):
228 def __init__(self):
229
229
230 raise NotImplementedError
230 raise NotImplementedError
231
231
232 def getNoise(self):
232 def getNoise(self):
233
233
234 raise NotImplementedError
234 raise NotImplementedError
235
235
236 def getNChannels(self):
236 def getNChannels(self):
237
237
238 return len(self.channelList)
238 return len(self.channelList)
239
239
240 def getChannelIndexList(self):
240 def getChannelIndexList(self):
241
241
242 return range(self.nChannels)
242 return range(self.nChannels)
243
243
244 def getNHeights(self):
244 def getNHeights(self):
245
245
246 return len(self.heightList)
246 return len(self.heightList)
247
247
248 def getHeiRange(self, extrapoints=0):
248 def getHeiRange(self, extrapoints=0):
249
249
250 heis = self.heightList
250 heis = self.heightList
251 # deltah = self.heightList[1] - self.heightList[0]
251 # deltah = self.heightList[1] - self.heightList[0]
252 #
252 #
253 # heis.append(self.heightList[-1])
253 # heis.append(self.heightList[-1])
254
254
255 return heis
255 return heis
256
256
257 def getDeltaH(self):
257 def getDeltaH(self):
258
258
259 delta = self.heightList[1] - self.heightList[0]
259 delta = self.heightList[1] - self.heightList[0]
260
260
261 return delta
261 return delta
262
262
263 def getltctime(self):
263 def getltctime(self):
264
264
265 if self.useLocalTime:
265 if self.useLocalTime:
266 return self.utctime - self.timeZone*60
266 return self.utctime - self.timeZone*60
267
267
268 return self.utctime
268 return self.utctime
269
269
270 def getDatatime(self):
270 def getDatatime(self):
271
271
272 datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime)
272 datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime)
273 return datatimeValue
273 return datatimeValue
274
274
275 def getTimeRange(self):
275 def getTimeRange(self):
276
276
277 datatime = []
277 datatime = []
278
278
279 datatime.append(self.ltctime)
279 datatime.append(self.ltctime)
280 datatime.append(self.ltctime + self.timeInterval+60)
280 datatime.append(self.ltctime + self.timeInterval+60)
281
281
282 datatime = numpy.array(datatime)
282 datatime = numpy.array(datatime)
283
283
284 return datatime
284 return datatime
285
285
286 def getFmaxTimeResponse(self):
286 def getFmaxTimeResponse(self):
287
287
288 period = (10**-6)*self.getDeltaH()/(0.15)
288 period = (10**-6)*self.getDeltaH()/(0.15)
289
289
290 PRF = 1./(period * self.nCohInt)
290 PRF = 1./(period * self.nCohInt)
291
291
292 fmax = PRF
292 fmax = PRF
293
293
294 return fmax
294 return fmax
295
295
296 def getFmax(self):
296 def getFmax(self):
297
297
298 PRF = 1./(self.ippSeconds * self.nCohInt)
298 PRF = 1./(self.ippSeconds * self.nCohInt)
299
299
300 fmax = PRF
300 fmax = PRF
301
301
302 return fmax
302 return fmax
303
303
304 def getVmax(self):
304 def getVmax(self):
305
305
306 _lambda = self.C/self.frequency
306 _lambda = self.C/self.frequency
307
307
308 vmax = self.getFmax() * _lambda
308 vmax = self.getFmax() * _lambda
309
309
310 return vmax
310 return vmax
311
311
312 def get_ippSeconds(self):
312 def get_ippSeconds(self):
313 '''
313 '''
314 '''
314 '''
315 return self.radarControllerHeaderObj.ippSeconds
315 return self.radarControllerHeaderObj.ippSeconds
316
316
317 def set_ippSeconds(self, ippSeconds):
317 def set_ippSeconds(self, ippSeconds):
318 '''
318 '''
319 '''
319 '''
320
320
321 self.radarControllerHeaderObj.ippSeconds = ippSeconds
321 self.radarControllerHeaderObj.ippSeconds = ippSeconds
322
322
323 return
323 return
324
324
325 def get_dtype(self):
325 def get_dtype(self):
326 '''
326 '''
327 '''
327 '''
328 return getNumpyDtype(self.datatype)
328 return getNumpyDtype(self.datatype)
329
329
330 def set_dtype(self, numpyDtype):
330 def set_dtype(self, numpyDtype):
331 '''
331 '''
332 '''
332 '''
333
333
334 self.datatype = getDataTypeCode(numpyDtype)
334 self.datatype = getDataTypeCode(numpyDtype)
335
335
336 def get_code(self):
336 def get_code(self):
337 '''
337 '''
338 '''
338 '''
339 return self.radarControllerHeaderObj.code
339 return self.radarControllerHeaderObj.code
340
340
341 def set_code(self, code):
341 def set_code(self, code):
342 '''
342 '''
343 '''
343 '''
344 self.radarControllerHeaderObj.code = code
344 self.radarControllerHeaderObj.code = code
345
345
346 return
346 return
347
347
348 def get_ncode(self):
348 def get_ncode(self):
349 '''
349 '''
350 '''
350 '''
351 return self.radarControllerHeaderObj.nCode
351 return self.radarControllerHeaderObj.nCode
352
352
353 def set_ncode(self, nCode):
353 def set_ncode(self, nCode):
354 '''
354 '''
355 '''
355 '''
356 self.radarControllerHeaderObj.nCode = nCode
356 self.radarControllerHeaderObj.nCode = nCode
357
357
358 return
358 return
359
359
360 def get_nbaud(self):
360 def get_nbaud(self):
361 '''
361 '''
362 '''
362 '''
363 return self.radarControllerHeaderObj.nBaud
363 return self.radarControllerHeaderObj.nBaud
364
364
365 def set_nbaud(self, nBaud):
365 def set_nbaud(self, nBaud):
366 '''
366 '''
367 '''
367 '''
368 self.radarControllerHeaderObj.nBaud = nBaud
368 self.radarControllerHeaderObj.nBaud = nBaud
369
369
370 return
370 return
371
371
372 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
372 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
373 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
373 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
374 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
374 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
375 #noise = property(getNoise, "I'm the 'nHeights' property.")
375 #noise = property(getNoise, "I'm the 'nHeights' property.")
376 datatime = property(getDatatime, "I'm the 'datatime' property")
376 datatime = property(getDatatime, "I'm the 'datatime' property")
377 ltctime = property(getltctime, "I'm the 'ltctime' property")
377 ltctime = property(getltctime, "I'm the 'ltctime' property")
378 ippSeconds = property(get_ippSeconds, set_ippSeconds)
378 ippSeconds = property(get_ippSeconds, set_ippSeconds)
379 dtype = property(get_dtype, set_dtype)
379 dtype = property(get_dtype, set_dtype)
380 # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
380 # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
381 code = property(get_code, set_code)
381 code = property(get_code, set_code)
382 nCode = property(get_ncode, set_ncode)
382 nCode = property(get_ncode, set_ncode)
383 nBaud = property(get_nbaud, set_nbaud)
383 nBaud = property(get_nbaud, set_nbaud)
384
384
385 class Voltage(JROData):
385 class Voltage(JROData):
386
386
387 #data es un numpy array de 2 dmensiones (canales, alturas)
387 #data es un numpy array de 2 dmensiones (canales, alturas)
388 data = None
388 data = None
389
389
390 def __init__(self):
390 def __init__(self):
391 '''
391 '''
392 Constructor
392 Constructor
393 '''
393 '''
394
394
395 self.useLocalTime = True
395 self.useLocalTime = True
396
396
397 self.radarControllerHeaderObj = RadarControllerHeader()
397 self.radarControllerHeaderObj = RadarControllerHeader()
398
398
399 self.systemHeaderObj = SystemHeader()
399 self.systemHeaderObj = SystemHeader()
400
400
401 self.type = "Voltage"
401 self.type = "Voltage"
402
402
403 self.data = None
403 self.data = None
404
404
405 # self.dtype = None
405 # self.dtype = None
406
406
407 # self.nChannels = 0
407 # self.nChannels = 0
408
408
409 # self.nHeights = 0
409 # self.nHeights = 0
410
410
411 self.nProfiles = None
411 self.nProfiles = None
412
412
413 self.heightList = None
413 self.heightList = None
414
414
415 self.channelList = None
415 self.channelList = None
416
416
417 # self.channelIndexList = None
417 # self.channelIndexList = None
418
418
419 self.flagNoData = True
419 self.flagNoData = True
420
420
421 self.flagDiscontinuousBlock = False
421 self.flagDiscontinuousBlock = False
422
422
423 self.utctime = None
423 self.utctime = None
424
424
425 self.timeZone = None
425 self.timeZone = None
426
426
427 self.dstFlag = None
427 self.dstFlag = None
428
428
429 self.errorCount = None
429 self.errorCount = None
430
430
431 self.nCohInt = None
431 self.nCohInt = None
432
432
433 self.blocksize = None
433 self.blocksize = None
434
434
435 self.flagDecodeData = False #asumo q la data no esta decodificada
435 self.flagDecodeData = False #asumo q la data no esta decodificada
436
436
437 self.flagDeflipData = False #asumo q la data no esta sin flip
437 self.flagDeflipData = False #asumo q la data no esta sin flip
438
438
439 self.flagShiftFFT = False
439 self.flagShiftFFT = False
440
440
441 self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil
441 self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil
442
442
443 self.profileIndex = 0
443 self.profileIndex = 0
444
444
445 def getNoisebyHildebrand(self, channel = None):
445 def getNoisebyHildebrand(self, channel = None):
446 """
446 """
447 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
447 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
448
448
449 Return:
449 Return:
450 noiselevel
450 noiselevel
451 """
451 """
452
452
453 if channel != None:
453 if channel != None:
454 data = self.data[channel]
454 data = self.data[channel]
455 nChannels = 1
455 nChannels = 1
456 else:
456 else:
457 data = self.data
457 data = self.data
458 nChannels = self.nChannels
458 nChannels = self.nChannels
459
459
460 noise = numpy.zeros(nChannels)
460 noise = numpy.zeros(nChannels)
461 power = data * numpy.conjugate(data)
461 power = data * numpy.conjugate(data)
462
462
463 for thisChannel in range(nChannels):
463 for thisChannel in range(nChannels):
464 if nChannels == 1:
464 if nChannels == 1:
465 daux = power[:].real
465 daux = power[:].real
466 else:
466 else:
467 daux = power[thisChannel,:].real
467 daux = power[thisChannel,:].real
468 noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt)
468 noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt)
469
469
470 return noise
470 return noise
471
471
472 def getNoise(self, type = 1, channel = None):
472 def getNoise(self, type = 1, channel = None):
473
473
474 if type == 1:
474 if type == 1:
475 noise = self.getNoisebyHildebrand(channel)
475 noise = self.getNoisebyHildebrand(channel)
476
476
477 return noise
477 return noise
478
478
479 def getPower(self, channel = None):
479 def getPower(self, channel = None):
480
480
481 if channel != None:
481 if channel != None:
482 data = self.data[channel]
482 data = self.data[channel]
483 else:
483 else:
484 data = self.data
484 data = self.data
485
485
486 power = data * numpy.conjugate(data)
486 power = data * numpy.conjugate(data)
487
487
488 return 10*numpy.log10(power.real)
488 return 10*numpy.log10(power.real)
489
489
490 def getTimeInterval(self):
490 def getTimeInterval(self):
491
491
492 timeInterval = self.ippSeconds * self.nCohInt
492 timeInterval = self.ippSeconds * self.nCohInt
493
493
494 return timeInterval
494 return timeInterval
495
495
496 noise = property(getNoise, "I'm the 'nHeights' property.")
496 noise = property(getNoise, "I'm the 'nHeights' property.")
497 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
497 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
498
498
499 class Spectra(JROData):
499 class Spectra(JROData):
500
500
501 #data es un numpy array de 2 dmensiones (canales, perfiles, alturas)
501 #data es un numpy array de 2 dmensiones (canales, perfiles, alturas)
502 data_spc = None
502 data_spc = None
503
503
504 #data es un numpy array de 2 dmensiones (canales, pares, alturas)
504 #data es un numpy array de 2 dmensiones (canales, pares, alturas)
505 data_cspc = None
505 data_cspc = None
506
506
507 #data es un numpy array de 2 dmensiones (canales, alturas)
507 #data es un numpy array de 2 dmensiones (canales, alturas)
508 data_dc = None
508 data_dc = None
509
509
510 nFFTPoints = None
510 nFFTPoints = None
511
511
512 # nPairs = None
512 # nPairs = None
513
513
514 pairsList = None
514 pairsList = None
515
515
516 nIncohInt = None
516 nIncohInt = None
517
517
518 wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia
518 wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia
519
519
520 nCohInt = None #se requiere para determinar el valor de timeInterval
520 nCohInt = None #se requiere para determinar el valor de timeInterval
521
521
522 ippFactor = None
522 ippFactor = None
523
523
524 profileIndex = 0
524 profileIndex = 0
525
525
526 plotting = "spectra"
526 plotting = "spectra"
527
527
528 def __init__(self):
528 def __init__(self):
529 '''
529 '''
530 Constructor
530 Constructor
531 '''
531 '''
532
532
533 self.useLocalTime = True
533 self.useLocalTime = True
534
534
535 self.radarControllerHeaderObj = RadarControllerHeader()
535 self.radarControllerHeaderObj = RadarControllerHeader()
536
536
537 self.systemHeaderObj = SystemHeader()
537 self.systemHeaderObj = SystemHeader()
538
538
539 self.type = "Spectra"
539 self.type = "Spectra"
540
540
541 # self.data = None
541 # self.data = None
542
542
543 # self.dtype = None
543 # self.dtype = None
544
544
545 # self.nChannels = 0
545 # self.nChannels = 0
546
546
547 # self.nHeights = 0
547 # self.nHeights = 0
548
548
549 self.nProfiles = None
549 self.nProfiles = None
550
550
551 self.heightList = None
551 self.heightList = None
552
552
553 self.channelList = None
553 self.channelList = None
554
554
555 # self.channelIndexList = None
555 # self.channelIndexList = None
556
556
557 self.pairsList = None
557 self.pairsList = None
558
558
559 self.flagNoData = True
559 self.flagNoData = True
560
560
561 self.flagDiscontinuousBlock = False
561 self.flagDiscontinuousBlock = False
562
562
563 self.utctime = None
563 self.utctime = None
564
564
565 self.nCohInt = None
565 self.nCohInt = None
566
566
567 self.nIncohInt = None
567 self.nIncohInt = None
568
568
569 self.blocksize = None
569 self.blocksize = None
570
570
571 self.nFFTPoints = None
571 self.nFFTPoints = None
572
572
573 self.wavelength = None
573 self.wavelength = None
574
574
575 self.flagDecodeData = False #asumo q la data no esta decodificada
575 self.flagDecodeData = False #asumo q la data no esta decodificada
576
576
577 self.flagDeflipData = False #asumo q la data no esta sin flip
577 self.flagDeflipData = False #asumo q la data no esta sin flip
578
578
579 self.flagShiftFFT = False
579 self.flagShiftFFT = False
580
580
581 self.ippFactor = 1
581 self.ippFactor = 1
582
582
583 #self.noise = None
583 #self.noise = None
584
584
585 self.beacon_heiIndexList = []
585 self.beacon_heiIndexList = []
586
586
587 self.noise_estimation = None
587 self.noise_estimation = None
588
588
589
589
590 def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
590 def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
591 """
591 """
592 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
592 Determino el nivel de ruido usando el metodo Hildebrand-Sekhon
593
593
594 Return:
594 Return:
595 noiselevel
595 noiselevel
596 """
596 """
597
597
598 noise = numpy.zeros(self.nChannels)
598 noise = numpy.zeros(self.nChannels)
599
599
600 for channel in range(self.nChannels):
600 for channel in range(self.nChannels):
601 daux = self.data_spc[channel,xmin_index:xmax_index,ymin_index:ymax_index]
601 daux = self.data_spc[channel,xmin_index:xmax_index,ymin_index:ymax_index]
602 noise[channel] = hildebrand_sekhon(daux, self.nIncohInt)
602 noise[channel] = hildebrand_sekhon(daux, self.nIncohInt)
603
603
604 return noise
604 return noise
605
605
606 def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
606 def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None):
607
607
608 if self.noise_estimation is not None:
608 if self.noise_estimation is not None:
609 return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py
609 return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py
610 else:
610 else:
611 noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index)
611 noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index)
612 return noise
612 return noise
613
613
614 def getFreqRangeTimeResponse(self, extrapoints=0):
614 def getFreqRangeTimeResponse(self, extrapoints=0):
615
615
616 deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints*self.ippFactor)
616 deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints*self.ippFactor)
617 freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
617 freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
618
618
619 return freqrange
619 return freqrange
620
620
621 def getAcfRange(self, extrapoints=0):
621 def getAcfRange(self, extrapoints=0):
622
622
623 deltafreq = 10./(self.getFmax() / (self.nFFTPoints*self.ippFactor))
623 deltafreq = 10./(self.getFmax() / (self.nFFTPoints*self.ippFactor))
624 freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
624 freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
625
625
626 return freqrange
626 return freqrange
627
627
628 def getFreqRange(self, extrapoints=0):
628 def getFreqRange(self, extrapoints=0):
629
629
630 deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor)
630 deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor)
631 freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
631 freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2
632
632
633 return freqrange
633 return freqrange
634
634
635 def getVelRange(self, extrapoints=0):
635 def getVelRange(self, extrapoints=0):
636
636
637 deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor)
637 deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor)
638 velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2
638 velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2
639
639
640 return velrange
640 return velrange
641
641
642 def getNPairs(self):
642 def getNPairs(self):
643
643
644 return len(self.pairsList)
644 return len(self.pairsList)
645
645
646 def getPairsIndexList(self):
646 def getPairsIndexList(self):
647
647
648 return range(self.nPairs)
648 return range(self.nPairs)
649
649
650 def getNormFactor(self):
650 def getNormFactor(self):
651
651
652 pwcode = 1
652 pwcode = 1
653
653
654 if self.flagDecodeData:
654 if self.flagDecodeData:
655 pwcode = numpy.sum(self.code[0]**2)
655 pwcode = numpy.sum(self.code[0]**2)
656 #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
656 #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
657 normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
657 normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter
658
658
659 return normFactor
659 return normFactor
660
660
661 def getFlagCspc(self):
661 def getFlagCspc(self):
662
662
663 if self.data_cspc is None:
663 if self.data_cspc is None:
664 return True
664 return True
665
665
666 return False
666 return False
667
667
668 def getFlagDc(self):
668 def getFlagDc(self):
669
669
670 if self.data_dc is None:
670 if self.data_dc is None:
671 return True
671 return True
672
672
673 return False
673 return False
674
674
675 def getTimeInterval(self):
675 def getTimeInterval(self):
676
676
677 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles
677 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles
678
678
679 return timeInterval
679 return timeInterval
680
680
681 def setValue(self, value):
681 def setValue(self, value):
682
682
683 print "This property should not be initialized"
683 print "This property should not be initialized"
684
684
685 return
685 return
686
686
687 nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.")
687 nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.")
688 pairsIndexList = property(getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.")
688 pairsIndexList = property(getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.")
689 normFactor = property(getNormFactor, setValue, "I'm the 'getNormFactor' property.")
689 normFactor = property(getNormFactor, setValue, "I'm the 'getNormFactor' property.")
690 flag_cspc = property(getFlagCspc, setValue)
690 flag_cspc = property(getFlagCspc, setValue)
691 flag_dc = property(getFlagDc, setValue)
691 flag_dc = property(getFlagDc, setValue)
692 noise = property(getNoise, setValue, "I'm the 'nHeights' property.")
692 noise = property(getNoise, setValue, "I'm the 'nHeights' property.")
693 timeInterval = property(getTimeInterval, setValue, "I'm the 'timeInterval' property")
693 timeInterval = property(getTimeInterval, setValue, "I'm the 'timeInterval' property")
694
694
695 class SpectraHeis(Spectra):
695 class SpectraHeis(Spectra):
696
696
697 data_spc = None
697 data_spc = None
698
698
699 data_cspc = None
699 data_cspc = None
700
700
701 data_dc = None
701 data_dc = None
702
702
703 nFFTPoints = None
703 nFFTPoints = None
704
704
705 # nPairs = None
705 # nPairs = None
706
706
707 pairsList = None
707 pairsList = None
708
708
709 nCohInt = None
709 nCohInt = None
710
710
711 nIncohInt = None
711 nIncohInt = None
712
712
713 def __init__(self):
713 def __init__(self):
714
714
715 self.radarControllerHeaderObj = RadarControllerHeader()
715 self.radarControllerHeaderObj = RadarControllerHeader()
716
716
717 self.systemHeaderObj = SystemHeader()
717 self.systemHeaderObj = SystemHeader()
718
718
719 self.type = "SpectraHeis"
719 self.type = "SpectraHeis"
720
720
721 # self.dtype = None
721 # self.dtype = None
722
722
723 # self.nChannels = 0
723 # self.nChannels = 0
724
724
725 # self.nHeights = 0
725 # self.nHeights = 0
726
726
727 self.nProfiles = None
727 self.nProfiles = None
728
728
729 self.heightList = None
729 self.heightList = None
730
730
731 self.channelList = None
731 self.channelList = None
732
732
733 # self.channelIndexList = None
733 # self.channelIndexList = None
734
734
735 self.flagNoData = True
735 self.flagNoData = True
736
736
737 self.flagDiscontinuousBlock = False
737 self.flagDiscontinuousBlock = False
738
738
739 # self.nPairs = 0
739 # self.nPairs = 0
740
740
741 self.utctime = None
741 self.utctime = None
742
742
743 self.blocksize = None
743 self.blocksize = None
744
744
745 self.profileIndex = 0
745 self.profileIndex = 0
746
746
747 self.nCohInt = 1
747 self.nCohInt = 1
748
748
749 self.nIncohInt = 1
749 self.nIncohInt = 1
750
750
751 def getNormFactor(self):
751 def getNormFactor(self):
752 pwcode = 1
752 pwcode = 1
753 if self.flagDecodeData:
753 if self.flagDecodeData:
754 pwcode = numpy.sum(self.code[0]**2)
754 pwcode = numpy.sum(self.code[0]**2)
755
755
756 normFactor = self.nIncohInt*self.nCohInt*pwcode
756 normFactor = self.nIncohInt*self.nCohInt*pwcode
757
757
758 return normFactor
758 return normFactor
759
759
760 def getTimeInterval(self):
760 def getTimeInterval(self):
761
761
762 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
762 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
763
763
764 return timeInterval
764 return timeInterval
765
765
766 normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.")
766 normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.")
767 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
767 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
768
768
769 class Fits(JROData):
769 class Fits(JROData):
770
770
771 heightList = None
771 heightList = None
772
772
773 channelList = None
773 channelList = None
774
774
775 flagNoData = True
775 flagNoData = True
776
776
777 flagDiscontinuousBlock = False
777 flagDiscontinuousBlock = False
778
778
779 useLocalTime = False
779 useLocalTime = False
780
780
781 utctime = None
781 utctime = None
782
782
783 timeZone = None
783 timeZone = None
784
784
785 # ippSeconds = None
785 # ippSeconds = None
786
786
787 # timeInterval = None
787 # timeInterval = None
788
788
789 nCohInt = None
789 nCohInt = None
790
790
791 nIncohInt = None
791 nIncohInt = None
792
792
793 noise = None
793 noise = None
794
794
795 windowOfFilter = 1
795 windowOfFilter = 1
796
796
797 #Speed of ligth
797 #Speed of ligth
798 C = 3e8
798 C = 3e8
799
799
800 frequency = 49.92e6
800 frequency = 49.92e6
801
801
802 realtime = False
802 realtime = False
803
803
804
804
805 def __init__(self):
805 def __init__(self):
806
806
807 self.type = "Fits"
807 self.type = "Fits"
808
808
809 self.nProfiles = None
809 self.nProfiles = None
810
810
811 self.heightList = None
811 self.heightList = None
812
812
813 self.channelList = None
813 self.channelList = None
814
814
815 # self.channelIndexList = None
815 # self.channelIndexList = None
816
816
817 self.flagNoData = True
817 self.flagNoData = True
818
818
819 self.utctime = None
819 self.utctime = None
820
820
821 self.nCohInt = 1
821 self.nCohInt = 1
822
822
823 self.nIncohInt = 1
823 self.nIncohInt = 1
824
824
825 self.useLocalTime = True
825 self.useLocalTime = True
826
826
827 self.profileIndex = 0
827 self.profileIndex = 0
828
828
829 # self.utctime = None
829 # self.utctime = None
830 # self.timeZone = None
830 # self.timeZone = None
831 # self.ltctime = None
831 # self.ltctime = None
832 # self.timeInterval = None
832 # self.timeInterval = None
833 # self.header = None
833 # self.header = None
834 # self.data_header = None
834 # self.data_header = None
835 # self.data = None
835 # self.data = None
836 # self.datatime = None
836 # self.datatime = None
837 # self.flagNoData = False
837 # self.flagNoData = False
838 # self.expName = ''
838 # self.expName = ''
839 # self.nChannels = None
839 # self.nChannels = None
840 # self.nSamples = None
840 # self.nSamples = None
841 # self.dataBlocksPerFile = None
841 # self.dataBlocksPerFile = None
842 # self.comments = ''
842 # self.comments = ''
843 #
843 #
844
844
845
845
846 def getltctime(self):
846 def getltctime(self):
847
847
848 if self.useLocalTime:
848 if self.useLocalTime:
849 return self.utctime - self.timeZone*60
849 return self.utctime - self.timeZone*60
850
850
851 return self.utctime
851 return self.utctime
852
852
853 def getDatatime(self):
853 def getDatatime(self):
854
854
855 datatime = datetime.datetime.utcfromtimestamp(self.ltctime)
855 datatime = datetime.datetime.utcfromtimestamp(self.ltctime)
856 return datatime
856 return datatime
857
857
858 def getTimeRange(self):
858 def getTimeRange(self):
859
859
860 datatime = []
860 datatime = []
861
861
862 datatime.append(self.ltctime)
862 datatime.append(self.ltctime)
863 datatime.append(self.ltctime + self.timeInterval)
863 datatime.append(self.ltctime + self.timeInterval)
864
864
865 datatime = numpy.array(datatime)
865 datatime = numpy.array(datatime)
866
866
867 return datatime
867 return datatime
868
868
869 def getHeiRange(self):
869 def getHeiRange(self):
870
870
871 heis = self.heightList
871 heis = self.heightList
872
872
873 return heis
873 return heis
874
874
875 def getNHeights(self):
875 def getNHeights(self):
876
876
877 return len(self.heightList)
877 return len(self.heightList)
878
878
879 def getNChannels(self):
879 def getNChannels(self):
880
880
881 return len(self.channelList)
881 return len(self.channelList)
882
882
883 def getChannelIndexList(self):
883 def getChannelIndexList(self):
884
884
885 return range(self.nChannels)
885 return range(self.nChannels)
886
886
887 def getNoise(self, type = 1):
887 def getNoise(self, type = 1):
888
888
889 #noise = numpy.zeros(self.nChannels)
889 #noise = numpy.zeros(self.nChannels)
890
890
891 if type == 1:
891 if type == 1:
892 noise = self.getNoisebyHildebrand()
892 noise = self.getNoisebyHildebrand()
893
893
894 if type == 2:
894 if type == 2:
895 noise = self.getNoisebySort()
895 noise = self.getNoisebySort()
896
896
897 if type == 3:
897 if type == 3:
898 noise = self.getNoisebyWindow()
898 noise = self.getNoisebyWindow()
899
899
900 return noise
900 return noise
901
901
902 def getTimeInterval(self):
902 def getTimeInterval(self):
903
903
904 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
904 timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt
905
905
906 return timeInterval
906 return timeInterval
907
907
908 datatime = property(getDatatime, "I'm the 'datatime' property")
908 datatime = property(getDatatime, "I'm the 'datatime' property")
909 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
909 nHeights = property(getNHeights, "I'm the 'nHeights' property.")
910 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
910 nChannels = property(getNChannels, "I'm the 'nChannel' property.")
911 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
911 channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.")
912 noise = property(getNoise, "I'm the 'nHeights' property.")
912 noise = property(getNoise, "I'm the 'nHeights' property.")
913
913
914 ltctime = property(getltctime, "I'm the 'ltctime' property")
914 ltctime = property(getltctime, "I'm the 'ltctime' property")
915 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
915 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
916
916
917 class Correlation(JROData):
917 class Correlation(JROData):
918
918
919 noise = None
919 noise = None
920
920
921 SNR = None
921 SNR = None
922
922
923 pairsAutoCorr = None #Pairs of Autocorrelation
923 pairsAutoCorr = None #Pairs of Autocorrelation
924
924
925 #--------------------------------------------------
925 #--------------------------------------------------
926
926
927 data_corr = None
927 data_corr = None
928
928
929 data_volt = None
929 data_volt = None
930
930
931 lagT = None # each element value is a profileIndex
931 lagT = None # each element value is a profileIndex
932
932
933 lagR = None # each element value is in km
933 lagR = None # each element value is in km
934
934
935 pairsList = None
935 pairsList = None
936
936
937 calculateVelocity = None
937 calculateVelocity = None
938
938
939 nPoints = None
939 nPoints = None
940
940
941 nAvg = None
941 nAvg = None
942
942
943 bufferSize = None
943 bufferSize = None
944
944
945 def __init__(self):
945 def __init__(self):
946 '''
946 '''
947 Constructor
947 Constructor
948 '''
948 '''
949 self.radarControllerHeaderObj = RadarControllerHeader()
949 self.radarControllerHeaderObj = RadarControllerHeader()
950
950
951 self.systemHeaderObj = SystemHeader()
951 self.systemHeaderObj = SystemHeader()
952
952
953 self.type = "Correlation"
953 self.type = "Correlation"
954
954
955 self.data = None
955 self.data = None
956
956
957 self.dtype = None
957 self.dtype = None
958
958
959 self.nProfiles = None
959 self.nProfiles = None
960
960
961 self.heightList = None
961 self.heightList = None
962
962
963 self.channelList = None
963 self.channelList = None
964
964
965 self.flagNoData = True
965 self.flagNoData = True
966
966
967 self.flagDiscontinuousBlock = False
967 self.flagDiscontinuousBlock = False
968
968
969 self.utctime = None
969 self.utctime = None
970
970
971 self.timeZone = None
971 self.timeZone = None
972
972
973 self.dstFlag = None
973 self.dstFlag = None
974
974
975 self.errorCount = None
975 self.errorCount = None
976
976
977 self.blocksize = None
977 self.blocksize = None
978
978
979 self.flagDecodeData = False #asumo q la data no esta decodificada
979 self.flagDecodeData = False #asumo q la data no esta decodificada
980
980
981 self.flagDeflipData = False #asumo q la data no esta sin flip
981 self.flagDeflipData = False #asumo q la data no esta sin flip
982
982
983 self.pairsList = None
983 self.pairsList = None
984
984
985 self.nPoints = None
985 self.nPoints = None
986
986
987 def getLagTRange(self, extrapoints=0):
987 def getLagTRange(self, extrapoints=0):
988
988
989 lagTRange = self.lagT
989 lagTRange = self.lagT
990 diff = lagTRange[1] - lagTRange[0]
990 diff = lagTRange[1] - lagTRange[0]
991 extra = numpy.arange(1,extrapoints + 1)*diff + lagTRange[-1]
991 extra = numpy.arange(1,extrapoints + 1)*diff + lagTRange[-1]
992 lagTRange = numpy.hstack((lagTRange, extra))
992 lagTRange = numpy.hstack((lagTRange, extra))
993
993
994 return lagTRange
994 return lagTRange
995
995
996 def getLagRRange(self, extrapoints=0):
996 def getLagRRange(self, extrapoints=0):
997
997
998 return self.lagR
998 return self.lagR
999
999
1000 def getPairsList(self):
1000 def getPairsList(self):
1001
1001
1002 return self.pairsList
1002 return self.pairsList
1003
1003
1004 def getCalculateVelocity(self):
1004 def getCalculateVelocity(self):
1005
1005
1006 return self.calculateVelocity
1006 return self.calculateVelocity
1007
1007
1008 def getNPoints(self):
1008 def getNPoints(self):
1009
1009
1010 return self.nPoints
1010 return self.nPoints
1011
1011
1012 def getNAvg(self):
1012 def getNAvg(self):
1013
1013
1014 return self.nAvg
1014 return self.nAvg
1015
1015
1016 def getBufferSize(self):
1016 def getBufferSize(self):
1017
1017
1018 return self.bufferSize
1018 return self.bufferSize
1019
1019
1020 def getPairsAutoCorr(self):
1020 def getPairsAutoCorr(self):
1021 pairsList = self.pairsList
1021 pairsList = self.pairsList
1022 pairsAutoCorr = numpy.zeros(self.nChannels, dtype = 'int')*numpy.nan
1022 pairsAutoCorr = numpy.zeros(self.nChannels, dtype = 'int')*numpy.nan
1023
1023
1024 for l in range(len(pairsList)):
1024 for l in range(len(pairsList)):
1025 firstChannel = pairsList[l][0]
1025 firstChannel = pairsList[l][0]
1026 secondChannel = pairsList[l][1]
1026 secondChannel = pairsList[l][1]
1027
1027
1028 #Obteniendo pares de Autocorrelacion
1028 #Obteniendo pares de Autocorrelacion
1029 if firstChannel == secondChannel:
1029 if firstChannel == secondChannel:
1030 pairsAutoCorr[firstChannel] = int(l)
1030 pairsAutoCorr[firstChannel] = int(l)
1031
1031
1032 pairsAutoCorr = pairsAutoCorr.astype(int)
1032 pairsAutoCorr = pairsAutoCorr.astype(int)
1033
1033
1034 return pairsAutoCorr
1034 return pairsAutoCorr
1035
1035
1036 def getNoise(self, mode = 2):
1036 def getNoise(self, mode = 2):
1037
1037
1038 indR = numpy.where(self.lagR == 0)[0][0]
1038 indR = numpy.where(self.lagR == 0)[0][0]
1039 indT = numpy.where(self.lagT == 0)[0][0]
1039 indT = numpy.where(self.lagT == 0)[0][0]
1040
1040
1041 jspectra0 = self.data_corr[:,:,indR,:]
1041 jspectra0 = self.data_corr[:,:,indR,:]
1042 jspectra = copy.copy(jspectra0)
1042 jspectra = copy.copy(jspectra0)
1043
1043
1044 num_chan = jspectra.shape[0]
1044 num_chan = jspectra.shape[0]
1045 num_hei = jspectra.shape[2]
1045 num_hei = jspectra.shape[2]
1046
1046
1047 freq_dc = jspectra.shape[1]/2
1047 freq_dc = jspectra.shape[1]/2
1048 ind_vel = numpy.array([-2,-1,1,2]) + freq_dc
1048 ind_vel = numpy.array([-2,-1,1,2]) + freq_dc
1049
1049
1050 if ind_vel[0]<0:
1050 if ind_vel[0]<0:
1051 ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof
1051 ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof
1052
1052
1053 if mode == 1:
1053 if mode == 1:
1054 jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION
1054 jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION
1055
1055
1056 if mode == 2:
1056 if mode == 2:
1057
1057
1058 vel = numpy.array([-2,-1,1,2])
1058 vel = numpy.array([-2,-1,1,2])
1059 xx = numpy.zeros([4,4])
1059 xx = numpy.zeros([4,4])
1060
1060
1061 for fil in range(4):
1061 for fil in range(4):
1062 xx[fil,:] = vel[fil]**numpy.asarray(range(4))
1062 xx[fil,:] = vel[fil]**numpy.asarray(range(4))
1063
1063
1064 xx_inv = numpy.linalg.inv(xx)
1064 xx_inv = numpy.linalg.inv(xx)
1065 xx_aux = xx_inv[0,:]
1065 xx_aux = xx_inv[0,:]
1066
1066
1067 for ich in range(num_chan):
1067 for ich in range(num_chan):
1068 yy = jspectra[ich,ind_vel,:]
1068 yy = jspectra[ich,ind_vel,:]
1069 jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy)
1069 jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy)
1070
1070
1071 junkid = jspectra[ich,freq_dc,:]<=0
1071 junkid = jspectra[ich,freq_dc,:]<=0
1072 cjunkid = sum(junkid)
1072 cjunkid = sum(junkid)
1073
1073
1074 if cjunkid.any():
1074 if cjunkid.any():
1075 jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2
1075 jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2
1076
1076
1077 noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:]
1077 noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:]
1078
1078
1079 return noise
1079 return noise
1080
1080
1081 def getTimeInterval(self):
1081 def getTimeInterval(self):
1082
1082
1083 timeInterval = self.ippSeconds * self.nCohInt * self.nPoints
1083 timeInterval = self.ippSeconds * self.nCohInt * self.nPoints
1084
1084
1085 return timeInterval
1085 return timeInterval
1086
1086
1087 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
1087 timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property")
1088 # pairsList = property(getPairsList, "I'm the 'pairsList' property.")
1088 # pairsList = property(getPairsList, "I'm the 'pairsList' property.")
1089 # nPoints = property(getNPoints, "I'm the 'nPoints' property.")
1089 # nPoints = property(getNPoints, "I'm the 'nPoints' property.")
1090 calculateVelocity = property(getCalculateVelocity, "I'm the 'calculateVelocity' property.")
1090 calculateVelocity = property(getCalculateVelocity, "I'm the 'calculateVelocity' property.")
1091 nAvg = property(getNAvg, "I'm the 'nAvg' property.")
1091 nAvg = property(getNAvg, "I'm the 'nAvg' property.")
1092 bufferSize = property(getBufferSize, "I'm the 'bufferSize' property.")
1092 bufferSize = property(getBufferSize, "I'm the 'bufferSize' property.")
1093
1093
1094
1094
1095 class Parameters(JROData):
1095 class Parameters(JROData):
1096
1096
1097 #Information from previous data
1097 #Information from previous data
1098
1098
1099 inputUnit = None #Type of data to be processed
1099 inputUnit = None #Type of data to be processed
1100
1100
1101 operation = None #Type of operation to parametrize
1101 operation = None #Type of operation to parametrize
1102
1102
1103 normFactor = None #Normalization Factor
1103 normFactor = None #Normalization Factor
1104
1104
1105 groupList = None #List of Pairs, Groups, etc
1105 groupList = None #List of Pairs, Groups, etc
1106
1106
1107 #Parameters
1107 #Parameters
1108
1108
1109 data_param = None #Parameters obtained
1109 data_param = None #Parameters obtained
1110
1110
1111 data_pre = None #Data Pre Parametrization
1111 data_pre = None #Data Pre Parametrization
1112
1112
1113 data_SNR = None #Signal to Noise Ratio
1113 data_SNR = None #Signal to Noise Ratio
1114
1114
1115 # heightRange = None #Heights
1115 # heightRange = None #Heights
1116
1116
1117 abscissaList = None #Abscissa, can be velocities, lags or time
1117 abscissaList = None #Abscissa, can be velocities, lags or time
1118
1118
1119 noise = None #Noise Potency
1119 noise = None #Noise Potency
1120
1120
1121 utctimeInit = None #Initial UTC time
1121 utctimeInit = None #Initial UTC time
1122
1122
1123 paramInterval = None #Time interval to calculate Parameters in seconds
1123 paramInterval = None #Time interval to calculate Parameters in seconds
1124
1124
1125 useLocalTime = True
1126
1125 #Fitting
1127 #Fitting
1126
1128
1127 data_error = None #Error of the estimation
1129 data_error = None #Error of the estimation
1128
1130
1129 constants = None
1131 constants = None
1130
1132
1131 library = None
1133 library = None
1132
1134
1133 #Output signal
1135 #Output signal
1134
1136
1135 outputInterval = None #Time interval to calculate output signal in seconds
1137 outputInterval = None #Time interval to calculate output signal in seconds
1136
1138
1137 data_output = None #Out signal
1139 data_output = None #Out signal
1138
1140
1139
1141
1140
1142
1141 def __init__(self):
1143 def __init__(self):
1142 '''
1144 '''
1143 Constructor
1145 Constructor
1144 '''
1146 '''
1145 self.radarControllerHeaderObj = RadarControllerHeader()
1147 self.radarControllerHeaderObj = RadarControllerHeader()
1146
1148
1147 self.systemHeaderObj = SystemHeader()
1149 self.systemHeaderObj = SystemHeader()
1148
1150
1149 self.type = "Parameters"
1151 self.type = "Parameters"
1150
1152
1151 def getTimeRange1(self):
1153 def getTimeRange1(self):
1152
1154
1153 datatime = []
1155 datatime = []
1154
1156
1155 if self.useLocalTime:
1157 if self.useLocalTime:
1156 time1 = self.utctimeInit - self.timeZone*60
1158 time1 = self.utctimeInit - self.timeZone*60
1157 else:
1159 else:
1158 time1 = utctimeInit
1160 time1 = self.utctimeInit
1159
1161
1160 # datatime.append(self.utctimeInit)
1162 # datatime.append(self.utctimeInit)
1161 # datatime.append(self.utctimeInit + self.outputInterval)
1163 # datatime.append(self.utctimeInit + self.outputInterval)
1162 datatime.append(time1)
1164 datatime.append(time1)
1163 datatime.append(time1 + self.outputInterval)
1165 datatime.append(time1 + self.outputInterval)
1164
1166
1165 datatime = numpy.array(datatime)
1167 datatime = numpy.array(datatime)
1166
1168
1167 return datatime
1169 return datatime
General Comments 0
You need to be logged in to leave comments. Login now