@@ -1,1261 +1,1264 | |||||
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 | from schainpy import cSchain |
|
12 | from schainpy import cSchain | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | def getNumpyDtype(dataTypeCode): |
|
15 | def getNumpyDtype(dataTypeCode): | |
16 |
|
16 | |||
17 | if dataTypeCode == 0: |
|
17 | if dataTypeCode == 0: | |
18 | numpyDtype = numpy.dtype([('real', '<i1'), ('imag', '<i1')]) |
|
18 | numpyDtype = numpy.dtype([('real', '<i1'), ('imag', '<i1')]) | |
19 | elif dataTypeCode == 1: |
|
19 | elif dataTypeCode == 1: | |
20 | numpyDtype = numpy.dtype([('real', '<i2'), ('imag', '<i2')]) |
|
20 | numpyDtype = numpy.dtype([('real', '<i2'), ('imag', '<i2')]) | |
21 | elif dataTypeCode == 2: |
|
21 | elif dataTypeCode == 2: | |
22 | numpyDtype = numpy.dtype([('real', '<i4'), ('imag', '<i4')]) |
|
22 | numpyDtype = numpy.dtype([('real', '<i4'), ('imag', '<i4')]) | |
23 | elif dataTypeCode == 3: |
|
23 | elif dataTypeCode == 3: | |
24 | numpyDtype = numpy.dtype([('real', '<i8'), ('imag', '<i8')]) |
|
24 | numpyDtype = numpy.dtype([('real', '<i8'), ('imag', '<i8')]) | |
25 | elif dataTypeCode == 4: |
|
25 | elif dataTypeCode == 4: | |
26 | numpyDtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')]) |
|
26 | numpyDtype = numpy.dtype([('real', '<f4'), ('imag', '<f4')]) | |
27 | elif dataTypeCode == 5: |
|
27 | elif dataTypeCode == 5: | |
28 | numpyDtype = numpy.dtype([('real', '<f8'), ('imag', '<f8')]) |
|
28 | numpyDtype = numpy.dtype([('real', '<f8'), ('imag', '<f8')]) | |
29 | else: |
|
29 | else: | |
30 | raise ValueError, 'dataTypeCode was not defined' |
|
30 | raise ValueError, 'dataTypeCode was not defined' | |
31 |
|
31 | |||
32 | return numpyDtype |
|
32 | return numpyDtype | |
33 |
|
33 | |||
34 |
|
34 | |||
35 | def getDataTypeCode(numpyDtype): |
|
35 | def getDataTypeCode(numpyDtype): | |
36 |
|
36 | |||
37 | if numpyDtype == numpy.dtype([('real', '<i1'), ('imag', '<i1')]): |
|
37 | if numpyDtype == numpy.dtype([('real', '<i1'), ('imag', '<i1')]): | |
38 | datatype = 0 |
|
38 | datatype = 0 | |
39 | elif numpyDtype == numpy.dtype([('real', '<i2'), ('imag', '<i2')]): |
|
39 | elif numpyDtype == numpy.dtype([('real', '<i2'), ('imag', '<i2')]): | |
40 | datatype = 1 |
|
40 | datatype = 1 | |
41 | elif numpyDtype == numpy.dtype([('real', '<i4'), ('imag', '<i4')]): |
|
41 | elif numpyDtype == numpy.dtype([('real', '<i4'), ('imag', '<i4')]): | |
42 | datatype = 2 |
|
42 | datatype = 2 | |
43 | elif numpyDtype == numpy.dtype([('real', '<i8'), ('imag', '<i8')]): |
|
43 | elif numpyDtype == numpy.dtype([('real', '<i8'), ('imag', '<i8')]): | |
44 | datatype = 3 |
|
44 | datatype = 3 | |
45 | elif numpyDtype == numpy.dtype([('real', '<f4'), ('imag', '<f4')]): |
|
45 | elif numpyDtype == numpy.dtype([('real', '<f4'), ('imag', '<f4')]): | |
46 | datatype = 4 |
|
46 | datatype = 4 | |
47 | elif numpyDtype == numpy.dtype([('real', '<f8'), ('imag', '<f8')]): |
|
47 | elif numpyDtype == numpy.dtype([('real', '<f8'), ('imag', '<f8')]): | |
48 | datatype = 5 |
|
48 | datatype = 5 | |
49 | else: |
|
49 | else: | |
50 | datatype = None |
|
50 | datatype = None | |
51 |
|
51 | |||
52 | return datatype |
|
52 | return datatype | |
53 |
|
53 | |||
54 |
|
54 | |||
55 | def hildebrand_sekhon(data, navg): |
|
55 | def hildebrand_sekhon(data, navg): | |
56 | """ |
|
56 | """ | |
57 | This method is for the objective determination of the noise level in Doppler spectra. This |
|
57 | This method is for the objective determination of the noise level in Doppler spectra. This | |
58 | implementation technique is based on the fact that the standard deviation of the spectral |
|
58 | implementation technique is based on the fact that the standard deviation of the spectral | |
59 | densities is equal to the mean spectral density for white Gaussian noise |
|
59 | densities is equal to the mean spectral density for white Gaussian noise | |
60 |
|
60 | |||
61 | Inputs: |
|
61 | Inputs: | |
62 | Data : heights |
|
62 | Data : heights | |
63 | navg : numbers of averages |
|
63 | navg : numbers of averages | |
64 |
|
64 | |||
65 | Return: |
|
65 | Return: | |
66 | -1 : any error |
|
66 | -1 : any error | |
67 | anoise : noise's level |
|
67 | anoise : noise's level | |
68 | """ |
|
68 | """ | |
69 |
|
69 | |||
70 | sortdata = numpy.sort(data, axis=None) |
|
70 | sortdata = numpy.sort(data, axis=None) | |
71 | # lenOfData = len(sortdata) |
|
71 | # lenOfData = len(sortdata) | |
72 | # nums_min = lenOfData*0.2 |
|
72 | # nums_min = lenOfData*0.2 | |
73 | # |
|
73 | # | |
74 | # if nums_min <= 5: |
|
74 | # if nums_min <= 5: | |
75 | # nums_min = 5 |
|
75 | # nums_min = 5 | |
76 | # |
|
76 | # | |
77 | # sump = 0. |
|
77 | # sump = 0. | |
78 | # |
|
78 | # | |
79 | # sumq = 0. |
|
79 | # sumq = 0. | |
80 | # |
|
80 | # | |
81 | # j = 0 |
|
81 | # j = 0 | |
82 | # |
|
82 | # | |
83 | # cont = 1 |
|
83 | # cont = 1 | |
84 | # |
|
84 | # | |
85 | # while((cont==1)and(j<lenOfData)): |
|
85 | # while((cont==1)and(j<lenOfData)): | |
86 | # |
|
86 | # | |
87 | # sump += sortdata[j] |
|
87 | # sump += sortdata[j] | |
88 | # |
|
88 | # | |
89 | # sumq += sortdata[j]**2 |
|
89 | # sumq += sortdata[j]**2 | |
90 | # |
|
90 | # | |
91 | # if j > nums_min: |
|
91 | # if j > nums_min: | |
92 | # rtest = float(j)/(j-1) + 1.0/navg |
|
92 | # rtest = float(j)/(j-1) + 1.0/navg | |
93 | # if ((sumq*j) > (rtest*sump**2)): |
|
93 | # if ((sumq*j) > (rtest*sump**2)): | |
94 | # j = j - 1 |
|
94 | # j = j - 1 | |
95 | # sump = sump - sortdata[j] |
|
95 | # sump = sump - sortdata[j] | |
96 | # sumq = sumq - sortdata[j]**2 |
|
96 | # sumq = sumq - sortdata[j]**2 | |
97 | # cont = 0 |
|
97 | # cont = 0 | |
98 | # |
|
98 | # | |
99 | # j += 1 |
|
99 | # j += 1 | |
100 | # |
|
100 | # | |
101 | # lnoise = sump /j |
|
101 | # lnoise = sump /j | |
102 | # |
|
102 | # | |
103 | # return lnoise |
|
103 | # return lnoise | |
104 |
|
104 | |||
105 | return cSchain.hildebrand_sekhon(sortdata, navg) |
|
105 | return cSchain.hildebrand_sekhon(sortdata, navg) | |
106 |
|
106 | |||
107 |
|
107 | |||
108 | class Beam: |
|
108 | class Beam: | |
109 |
|
109 | |||
110 | def __init__(self): |
|
110 | def __init__(self): | |
111 | self.codeList = [] |
|
111 | self.codeList = [] | |
112 | self.azimuthList = [] |
|
112 | self.azimuthList = [] | |
113 | self.zenithList = [] |
|
113 | self.zenithList = [] | |
114 |
|
114 | |||
115 |
|
115 | |||
116 | class GenericData(object): |
|
116 | class GenericData(object): | |
117 |
|
117 | |||
118 | flagNoData = True |
|
118 | flagNoData = True | |
119 |
|
119 | |||
120 | def copy(self, inputObj=None): |
|
120 | def copy(self, inputObj=None): | |
121 |
|
121 | |||
122 | if inputObj == None: |
|
122 | if inputObj == None: | |
123 | return copy.deepcopy(self) |
|
123 | return copy.deepcopy(self) | |
124 |
|
124 | |||
125 | for key in inputObj.__dict__.keys(): |
|
125 | for key in inputObj.__dict__.keys(): | |
126 |
|
126 | |||
127 | attribute = inputObj.__dict__[key] |
|
127 | attribute = inputObj.__dict__[key] | |
128 |
|
128 | |||
129 | # If this attribute is a tuple or list |
|
129 | # If this attribute is a tuple or list | |
130 | if type(inputObj.__dict__[key]) in (tuple, list): |
|
130 | if type(inputObj.__dict__[key]) in (tuple, list): | |
131 | self.__dict__[key] = attribute[:] |
|
131 | self.__dict__[key] = attribute[:] | |
132 | continue |
|
132 | continue | |
133 |
|
133 | |||
134 | # If this attribute is another object or instance |
|
134 | # If this attribute is another object or instance | |
135 | if hasattr(attribute, '__dict__'): |
|
135 | if hasattr(attribute, '__dict__'): | |
136 | self.__dict__[key] = attribute.copy() |
|
136 | self.__dict__[key] = attribute.copy() | |
137 | continue |
|
137 | continue | |
138 |
|
138 | |||
139 | self.__dict__[key] = inputObj.__dict__[key] |
|
139 | self.__dict__[key] = inputObj.__dict__[key] | |
140 |
|
140 | |||
141 | def deepcopy(self): |
|
141 | def deepcopy(self): | |
142 |
|
142 | |||
143 | return copy.deepcopy(self) |
|
143 | return copy.deepcopy(self) | |
144 |
|
144 | |||
145 | def isEmpty(self): |
|
145 | def isEmpty(self): | |
146 |
|
146 | |||
147 | return self.flagNoData |
|
147 | return self.flagNoData | |
148 |
|
148 | |||
149 |
|
149 | |||
150 | class JROData(GenericData): |
|
150 | class JROData(GenericData): | |
151 |
|
151 | |||
152 | # m_BasicHeader = BasicHeader() |
|
152 | # m_BasicHeader = BasicHeader() | |
153 | # m_ProcessingHeader = ProcessingHeader() |
|
153 | # m_ProcessingHeader = ProcessingHeader() | |
154 |
|
154 | |||
155 | systemHeaderObj = SystemHeader() |
|
155 | systemHeaderObj = SystemHeader() | |
156 |
|
156 | |||
157 | radarControllerHeaderObj = RadarControllerHeader() |
|
157 | radarControllerHeaderObj = RadarControllerHeader() | |
158 |
|
158 | |||
159 | # data = None |
|
159 | # data = None | |
160 |
|
160 | |||
161 | type = None |
|
161 | type = None | |
162 |
|
162 | |||
163 | datatype = None # dtype but in string |
|
163 | datatype = None # dtype but in string | |
164 |
|
164 | |||
165 | # dtype = None |
|
165 | # dtype = None | |
166 |
|
166 | |||
167 | # nChannels = None |
|
167 | # nChannels = None | |
168 |
|
168 | |||
169 | # nHeights = None |
|
169 | # nHeights = None | |
170 |
|
170 | |||
171 | nProfiles = None |
|
171 | nProfiles = None | |
172 |
|
172 | |||
173 | heightList = None |
|
173 | heightList = None | |
174 |
|
174 | |||
175 | channelList = None |
|
175 | channelList = None | |
176 |
|
176 | |||
177 | flagDiscontinuousBlock = False |
|
177 | flagDiscontinuousBlock = False | |
178 |
|
178 | |||
179 | useLocalTime = False |
|
179 | useLocalTime = False | |
180 |
|
180 | |||
181 | utctime = None |
|
181 | utctime = None | |
182 |
|
182 | |||
183 | timeZone = None |
|
183 | timeZone = None | |
184 |
|
184 | |||
185 | dstFlag = None |
|
185 | dstFlag = None | |
186 |
|
186 | |||
187 | errorCount = None |
|
187 | errorCount = None | |
188 |
|
188 | |||
189 | blocksize = None |
|
189 | blocksize = None | |
190 |
|
190 | |||
191 | # nCode = None |
|
191 | # nCode = None | |
192 | # |
|
192 | # | |
193 | # nBaud = None |
|
193 | # nBaud = None | |
194 | # |
|
194 | # | |
195 | # code = None |
|
195 | # code = None | |
196 |
|
196 | |||
197 | flagDecodeData = False # asumo q la data no esta decodificada |
|
197 | flagDecodeData = False # asumo q la data no esta decodificada | |
198 |
|
198 | |||
199 | flagDeflipData = False # asumo q la data no esta sin flip |
|
199 | flagDeflipData = False # asumo q la data no esta sin flip | |
200 |
|
200 | |||
201 | flagShiftFFT = False |
|
201 | flagShiftFFT = False | |
202 |
|
202 | |||
203 | # ippSeconds = None |
|
203 | # ippSeconds = None | |
204 |
|
204 | |||
205 | # timeInterval = None |
|
205 | # timeInterval = None | |
206 |
|
206 | |||
207 | nCohInt = None |
|
207 | nCohInt = None | |
208 |
|
208 | |||
209 | # noise = None |
|
209 | # noise = None | |
210 |
|
210 | |||
211 | windowOfFilter = 1 |
|
211 | windowOfFilter = 1 | |
212 |
|
212 | |||
213 | # Speed of ligth |
|
213 | # Speed of ligth | |
214 | C = 3e8 |
|
214 | C = 3e8 | |
215 |
|
215 | |||
216 | frequency = 49.92e6 |
|
216 | frequency = 49.92e6 | |
217 |
|
217 | |||
218 | realtime = False |
|
218 | realtime = False | |
219 |
|
219 | |||
220 | beacon_heiIndexList = None |
|
220 | beacon_heiIndexList = None | |
221 |
|
221 | |||
222 | last_block = None |
|
222 | last_block = None | |
223 |
|
223 | |||
224 | blocknow = None |
|
224 | blocknow = None | |
225 |
|
225 | |||
226 | azimuth = None |
|
226 | azimuth = None | |
227 |
|
227 | |||
228 | zenith = None |
|
228 | zenith = None | |
229 |
|
229 | |||
230 | beam = Beam() |
|
230 | beam = Beam() | |
231 |
|
231 | |||
232 | profileIndex = None |
|
232 | profileIndex = None | |
233 |
|
233 | |||
234 | def getNoise(self): |
|
234 | def getNoise(self): | |
235 |
|
235 | |||
236 | raise NotImplementedError |
|
236 | raise NotImplementedError | |
237 |
|
237 | |||
238 | def getNChannels(self): |
|
238 | def getNChannels(self): | |
239 |
|
239 | |||
240 | return len(self.channelList) |
|
240 | return len(self.channelList) | |
241 |
|
241 | |||
242 | def getChannelIndexList(self): |
|
242 | def getChannelIndexList(self): | |
243 |
|
243 | |||
244 | return range(self.nChannels) |
|
244 | return range(self.nChannels) | |
245 |
|
245 | |||
246 | def getNHeights(self): |
|
246 | def getNHeights(self): | |
247 |
|
247 | |||
248 | return len(self.heightList) |
|
248 | return len(self.heightList) | |
249 |
|
249 | |||
250 | def getHeiRange(self, extrapoints=0): |
|
250 | def getHeiRange(self, extrapoints=0): | |
251 |
|
251 | |||
252 | heis = self.heightList |
|
252 | heis = self.heightList | |
253 | # deltah = self.heightList[1] - self.heightList[0] |
|
253 | # deltah = self.heightList[1] - self.heightList[0] | |
254 | # |
|
254 | # | |
255 | # heis.append(self.heightList[-1]) |
|
255 | # heis.append(self.heightList[-1]) | |
256 |
|
256 | |||
257 | return heis |
|
257 | return heis | |
258 |
|
258 | |||
259 | def getDeltaH(self): |
|
259 | def getDeltaH(self): | |
260 |
|
260 | |||
261 | delta = self.heightList[1] - self.heightList[0] |
|
261 | delta = self.heightList[1] - self.heightList[0] | |
262 |
|
262 | |||
263 | return delta |
|
263 | return delta | |
264 |
|
264 | |||
265 | def getltctime(self): |
|
265 | def getltctime(self): | |
266 |
|
266 | |||
267 | if self.useLocalTime: |
|
267 | if self.useLocalTime: | |
268 | return self.utctime - self.timeZone * 60 |
|
268 | return self.utctime - self.timeZone * 60 | |
269 |
|
269 | |||
270 | return self.utctime |
|
270 | return self.utctime | |
271 |
|
271 | |||
272 | def getDatatime(self): |
|
272 | def getDatatime(self): | |
273 |
|
273 | |||
274 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
274 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) | |
275 | return datatimeValue |
|
275 | return datatimeValue | |
276 |
|
276 | |||
277 | def getTimeRange(self): |
|
277 | def getTimeRange(self): | |
278 |
|
278 | |||
279 | datatime = [] |
|
279 | datatime = [] | |
280 |
|
280 | |||
281 | datatime.append(self.ltctime) |
|
281 | datatime.append(self.ltctime) | |
282 | datatime.append(self.ltctime + self.timeInterval + 1) |
|
282 | datatime.append(self.ltctime + self.timeInterval + 1) | |
283 |
|
283 | |||
284 | datatime = numpy.array(datatime) |
|
284 | datatime = numpy.array(datatime) | |
285 |
|
285 | |||
286 | return datatime |
|
286 | return datatime | |
287 |
|
287 | |||
288 | def getFmaxTimeResponse(self): |
|
288 | def getFmaxTimeResponse(self): | |
289 |
|
289 | |||
290 | period = (10**-6) * self.getDeltaH() / (0.15) |
|
290 | period = (10**-6) * self.getDeltaH() / (0.15) | |
291 |
|
291 | |||
292 | PRF = 1. / (period * self.nCohInt) |
|
292 | PRF = 1. / (period * self.nCohInt) | |
293 |
|
293 | |||
294 | fmax = PRF |
|
294 | fmax = PRF | |
295 |
|
295 | |||
296 | return fmax |
|
296 | return fmax | |
297 |
|
297 | |||
298 | def getFmax(self): |
|
298 | def getFmax(self): | |
299 | PRF = 1. / (self.ippSeconds * self.nCohInt) |
|
299 | PRF = 1. / (self.ippSeconds * self.nCohInt) | |
300 | #print "ippSeconds",self.ippSeconds |
|
300 | #print "ippSeconds",self.ippSeconds | |
301 | #print "nCohInt",self.nIncohInt |
|
301 | #print "nCohInt",self.nIncohInt | |
302 | #print PRF |
|
302 | #print PRF | |
303 | #import time |
|
303 | #import time | |
304 | #time.sleep(30) |
|
304 | #time.sleep(30) | |
305 | fmax = PRF |
|
305 | fmax = PRF | |
306 | return fmax |
|
306 | return fmax | |
307 |
|
307 | |||
308 | def getVmax(self): |
|
308 | def getVmax(self): | |
309 |
|
309 | |||
310 | _lambda = self.C / self.frequency |
|
310 | _lambda = self.C / self.frequency | |
311 |
|
311 | |||
312 | vmax = self.getFmax() * _lambda / 2 |
|
312 | vmax = self.getFmax() * _lambda / 2 | |
313 |
|
313 | |||
314 | return vmax |
|
314 | return vmax | |
315 |
|
315 | |||
316 | def get_ippSeconds(self): |
|
316 | def get_ippSeconds(self): | |
317 | ''' |
|
317 | ''' | |
318 | ''' |
|
318 | ''' | |
319 | return self.radarControllerHeaderObj.ippSeconds |
|
319 | return self.radarControllerHeaderObj.ippSeconds | |
320 |
|
320 | |||
321 | def set_ippSeconds(self, ippSeconds): |
|
321 | def set_ippSeconds(self, ippSeconds): | |
322 | ''' |
|
322 | ''' | |
323 | ''' |
|
323 | ''' | |
324 |
|
324 | |||
325 | self.radarControllerHeaderObj.ippSeconds = ippSeconds |
|
325 | self.radarControllerHeaderObj.ippSeconds = ippSeconds | |
326 |
|
326 | |||
327 | return |
|
327 | return | |
328 |
|
328 | |||
329 | def get_dtype(self): |
|
329 | def get_dtype(self): | |
330 | ''' |
|
330 | ''' | |
331 | ''' |
|
331 | ''' | |
332 | return getNumpyDtype(self.datatype) |
|
332 | return getNumpyDtype(self.datatype) | |
333 |
|
333 | |||
334 | def set_dtype(self, numpyDtype): |
|
334 | def set_dtype(self, numpyDtype): | |
335 | ''' |
|
335 | ''' | |
336 | ''' |
|
336 | ''' | |
337 |
|
337 | |||
338 | self.datatype = getDataTypeCode(numpyDtype) |
|
338 | self.datatype = getDataTypeCode(numpyDtype) | |
339 |
|
339 | |||
340 | def get_code(self): |
|
340 | def get_code(self): | |
341 | ''' |
|
341 | ''' | |
342 | ''' |
|
342 | ''' | |
343 | return self.radarControllerHeaderObj.code |
|
343 | return self.radarControllerHeaderObj.code | |
344 |
|
344 | |||
345 | def set_code(self, code): |
|
345 | def set_code(self, code): | |
346 | ''' |
|
346 | ''' | |
347 | ''' |
|
347 | ''' | |
348 | self.radarControllerHeaderObj.code = code |
|
348 | self.radarControllerHeaderObj.code = code | |
349 |
|
349 | |||
350 | return |
|
350 | return | |
351 |
|
351 | |||
352 | def get_ncode(self): |
|
352 | def get_ncode(self): | |
353 | ''' |
|
353 | ''' | |
354 | ''' |
|
354 | ''' | |
355 | return self.radarControllerHeaderObj.nCode |
|
355 | return self.radarControllerHeaderObj.nCode | |
356 |
|
356 | |||
357 | def set_ncode(self, nCode): |
|
357 | def set_ncode(self, nCode): | |
358 | ''' |
|
358 | ''' | |
359 | ''' |
|
359 | ''' | |
360 | self.radarControllerHeaderObj.nCode = nCode |
|
360 | self.radarControllerHeaderObj.nCode = nCode | |
361 |
|
361 | |||
362 | return |
|
362 | return | |
363 |
|
363 | |||
364 | def get_nbaud(self): |
|
364 | def get_nbaud(self): | |
365 | ''' |
|
365 | ''' | |
366 | ''' |
|
366 | ''' | |
367 | return self.radarControllerHeaderObj.nBaud |
|
367 | return self.radarControllerHeaderObj.nBaud | |
368 |
|
368 | |||
369 | def set_nbaud(self, nBaud): |
|
369 | def set_nbaud(self, nBaud): | |
370 | ''' |
|
370 | ''' | |
371 | ''' |
|
371 | ''' | |
372 | self.radarControllerHeaderObj.nBaud = nBaud |
|
372 | self.radarControllerHeaderObj.nBaud = nBaud | |
373 |
|
373 | |||
374 | return |
|
374 | return | |
375 |
|
375 | |||
376 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
376 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
377 | channelIndexList = property( |
|
377 | channelIndexList = property( | |
378 | getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
378 | getChannelIndexList, "I'm the 'channelIndexList' property.") | |
379 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
379 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
380 | #noise = property(getNoise, "I'm the 'nHeights' property.") |
|
380 | #noise = property(getNoise, "I'm the 'nHeights' property.") | |
381 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
381 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
382 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
382 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
383 | ippSeconds = property(get_ippSeconds, set_ippSeconds) |
|
383 | ippSeconds = property(get_ippSeconds, set_ippSeconds) | |
384 | dtype = property(get_dtype, set_dtype) |
|
384 | dtype = property(get_dtype, set_dtype) | |
385 | # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
385 | # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
386 | code = property(get_code, set_code) |
|
386 | code = property(get_code, set_code) | |
387 | nCode = property(get_ncode, set_ncode) |
|
387 | nCode = property(get_ncode, set_ncode) | |
388 | nBaud = property(get_nbaud, set_nbaud) |
|
388 | nBaud = property(get_nbaud, set_nbaud) | |
389 |
|
389 | |||
390 |
|
390 | |||
391 | class Voltage(JROData): |
|
391 | class Voltage(JROData): | |
392 |
|
392 | |||
393 | # data es un numpy array de 2 dmensiones (canales, alturas) |
|
393 | # data es un numpy array de 2 dmensiones (canales, alturas) | |
394 | data = None |
|
394 | data = None | |
395 |
|
395 | |||
396 | def __init__(self): |
|
396 | def __init__(self): | |
397 | ''' |
|
397 | ''' | |
398 | Constructor |
|
398 | Constructor | |
399 | ''' |
|
399 | ''' | |
400 |
|
400 | |||
401 | self.useLocalTime = True |
|
401 | self.useLocalTime = True | |
402 |
|
402 | |||
403 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
403 | self.radarControllerHeaderObj = RadarControllerHeader() | |
404 |
|
404 | |||
405 | self.systemHeaderObj = SystemHeader() |
|
405 | self.systemHeaderObj = SystemHeader() | |
406 |
|
406 | |||
407 | self.type = "Voltage" |
|
407 | self.type = "Voltage" | |
408 |
|
408 | |||
409 | self.data = None |
|
409 | self.data = None | |
410 |
|
410 | |||
411 | # self.dtype = None |
|
411 | # self.dtype = None | |
412 |
|
412 | |||
413 | # self.nChannels = 0 |
|
413 | # self.nChannels = 0 | |
414 |
|
414 | |||
415 | # self.nHeights = 0 |
|
415 | # self.nHeights = 0 | |
416 |
|
416 | |||
417 | self.nProfiles = None |
|
417 | self.nProfiles = None | |
418 |
|
418 | |||
419 | self.heightList = None |
|
419 | self.heightList = None | |
420 |
|
420 | |||
421 | self.channelList = None |
|
421 | self.channelList = None | |
422 |
|
422 | |||
423 | # self.channelIndexList = None |
|
423 | # self.channelIndexList = None | |
424 |
|
424 | |||
425 | self.flagNoData = True |
|
425 | self.flagNoData = True | |
426 |
|
426 | |||
427 | self.flagDiscontinuousBlock = False |
|
427 | self.flagDiscontinuousBlock = False | |
428 |
|
428 | |||
429 | self.utctime = None |
|
429 | self.utctime = None | |
430 |
|
430 | |||
431 | self.timeZone = None |
|
431 | self.timeZone = None | |
432 |
|
432 | |||
433 | self.dstFlag = None |
|
433 | self.dstFlag = None | |
434 |
|
434 | |||
435 | self.errorCount = None |
|
435 | self.errorCount = None | |
436 |
|
436 | |||
437 | self.nCohInt = None |
|
437 | self.nCohInt = None | |
438 |
|
438 | |||
439 | self.blocksize = None |
|
439 | self.blocksize = None | |
440 |
|
440 | |||
441 | self.flagDecodeData = False # asumo q la data no esta decodificada |
|
441 | self.flagDecodeData = False # asumo q la data no esta decodificada | |
442 |
|
442 | |||
443 | self.flagDeflipData = False # asumo q la data no esta sin flip |
|
443 | self.flagDeflipData = False # asumo q la data no esta sin flip | |
444 |
|
444 | |||
445 | self.flagShiftFFT = False |
|
445 | self.flagShiftFFT = False | |
446 |
|
446 | |||
447 | self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil |
|
447 | self.flagDataAsBlock = False # Asumo que la data es leida perfil a perfil | |
448 |
|
448 | |||
449 | self.profileIndex = 0 |
|
449 | self.profileIndex = 0 | |
450 |
|
450 | |||
451 | def getNoisebyHildebrand(self, channel=None): |
|
451 | def getNoisebyHildebrand(self, channel=None): | |
452 | """ |
|
452 | """ | |
453 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
453 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
454 |
|
454 | |||
455 | Return: |
|
455 | Return: | |
456 | noiselevel |
|
456 | noiselevel | |
457 | """ |
|
457 | """ | |
458 |
|
458 | |||
459 | if channel != None: |
|
459 | if channel != None: | |
460 | data = self.data[channel] |
|
460 | data = self.data[channel] | |
461 | nChannels = 1 |
|
461 | nChannels = 1 | |
462 | else: |
|
462 | else: | |
463 | data = self.data |
|
463 | data = self.data | |
464 | nChannels = self.nChannels |
|
464 | nChannels = self.nChannels | |
465 |
|
465 | |||
466 | noise = numpy.zeros(nChannels) |
|
466 | noise = numpy.zeros(nChannels) | |
467 | power = data * numpy.conjugate(data) |
|
467 | power = data * numpy.conjugate(data) | |
468 |
|
468 | |||
469 | for thisChannel in range(nChannels): |
|
469 | for thisChannel in range(nChannels): | |
470 | if nChannels == 1: |
|
470 | if nChannels == 1: | |
471 | daux = power[:].real |
|
471 | daux = power[:].real | |
472 | else: |
|
472 | else: | |
473 | daux = power[thisChannel, :].real |
|
473 | daux = power[thisChannel, :].real | |
474 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) |
|
474 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) | |
475 |
|
475 | |||
476 | return noise |
|
476 | return noise | |
477 |
|
477 | |||
478 | def getNoise(self, type=1, channel=None): |
|
478 | def getNoise(self, type=1, channel=None): | |
479 |
|
479 | |||
480 | if type == 1: |
|
480 | if type == 1: | |
481 | noise = self.getNoisebyHildebrand(channel) |
|
481 | noise = self.getNoisebyHildebrand(channel) | |
482 |
|
482 | |||
483 | return noise |
|
483 | return noise | |
484 |
|
484 | |||
485 | def getPower(self, channel=None): |
|
485 | def getPower(self, channel=None): | |
486 |
|
486 | |||
487 | if channel != None: |
|
487 | if channel != None: | |
488 | data = self.data[channel] |
|
488 | data = self.data[channel] | |
489 | else: |
|
489 | else: | |
490 | data = self.data |
|
490 | data = self.data | |
491 |
|
491 | |||
492 | power = data * numpy.conjugate(data) |
|
492 | power = data * numpy.conjugate(data) | |
493 | powerdB = 10 * numpy.log10(power.real) |
|
493 | powerdB = 10 * numpy.log10(power.real) | |
494 | powerdB = numpy.squeeze(powerdB) |
|
494 | powerdB = numpy.squeeze(powerdB) | |
495 |
|
495 | |||
496 | return powerdB |
|
496 | return powerdB | |
497 |
|
497 | |||
498 | def getTimeInterval(self): |
|
498 | def getTimeInterval(self): | |
499 |
|
499 | |||
500 | timeInterval = self.ippSeconds * self.nCohInt |
|
500 | timeInterval = self.ippSeconds * self.nCohInt | |
501 |
|
501 | |||
502 | return timeInterval |
|
502 | return timeInterval | |
503 |
|
503 | |||
504 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
504 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
505 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
505 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
506 |
|
506 | |||
507 |
|
507 | |||
508 | class Spectra(JROData): |
|
508 | class Spectra(JROData): | |
509 |
|
509 | |||
510 | # data spc es un numpy array de 2 dmensiones (canales, perfiles, alturas) |
|
510 | # data spc es un numpy array de 2 dmensiones (canales, perfiles, alturas) | |
511 | data_spc = None |
|
511 | data_spc = None | |
512 |
|
512 | |||
513 | # data cspc es un numpy array de 2 dmensiones (canales, pares, alturas) |
|
513 | # data cspc es un numpy array de 2 dmensiones (canales, pares, alturas) | |
514 | data_cspc = None |
|
514 | data_cspc = None | |
515 |
|
515 | |||
516 | # data dc es un numpy array de 2 dmensiones (canales, alturas) |
|
516 | # data dc es un numpy array de 2 dmensiones (canales, alturas) | |
517 | data_dc = None |
|
517 | data_dc = None | |
518 |
|
518 | |||
519 | # data power |
|
519 | # data power | |
520 | data_pwr = None |
|
520 | data_pwr = None | |
521 |
|
521 | |||
522 | nFFTPoints = None |
|
522 | nFFTPoints = None | |
523 |
|
523 | |||
524 | # nPairs = None |
|
524 | # nPairs = None | |
525 |
|
525 | |||
526 | pairsList = None |
|
526 | pairsList = None | |
527 |
|
527 | |||
528 | nIncohInt = None |
|
528 | nIncohInt = None | |
529 |
|
529 | |||
530 | wavelength = None # Necesario para cacular el rango de velocidad desde la frecuencia |
|
530 | wavelength = None # Necesario para cacular el rango de velocidad desde la frecuencia | |
531 |
|
531 | |||
532 | nCohInt = None # se requiere para determinar el valor de timeInterval |
|
532 | nCohInt = None # se requiere para determinar el valor de timeInterval | |
533 |
|
533 | |||
534 | ippFactor = None |
|
534 | ippFactor = None | |
535 |
|
535 | |||
536 | profileIndex = 0 |
|
536 | profileIndex = 0 | |
537 |
|
537 | |||
538 | plotting = "spectra" |
|
538 | plotting = "spectra" | |
539 |
|
539 | |||
540 | def __init__(self): |
|
540 | def __init__(self): | |
541 | ''' |
|
541 | ''' | |
542 | Constructor |
|
542 | Constructor | |
543 | ''' |
|
543 | ''' | |
544 |
|
544 | |||
545 | self.useLocalTime = True |
|
545 | self.useLocalTime = True | |
546 |
|
546 | |||
547 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
547 | self.radarControllerHeaderObj = RadarControllerHeader() | |
548 |
|
548 | |||
549 | self.systemHeaderObj = SystemHeader() |
|
549 | self.systemHeaderObj = SystemHeader() | |
550 |
|
550 | |||
551 | self.type = "Spectra" |
|
551 | self.type = "Spectra" | |
552 |
|
552 | |||
553 | # self.data = None |
|
553 | # self.data = None | |
554 |
|
554 | |||
555 | # self.dtype = None |
|
555 | # self.dtype = None | |
556 |
|
556 | |||
557 | # self.nChannels = 0 |
|
557 | # self.nChannels = 0 | |
558 |
|
558 | |||
559 | # self.nHeights = 0 |
|
559 | # self.nHeights = 0 | |
560 |
|
560 | |||
561 | self.nProfiles = None |
|
561 | self.nProfiles = None | |
562 |
|
562 | |||
563 | self.heightList = None |
|
563 | self.heightList = None | |
564 |
|
564 | |||
565 | self.channelList = None |
|
565 | self.channelList = None | |
566 |
|
566 | |||
567 | # self.channelIndexList = None |
|
567 | # self.channelIndexList = None | |
568 |
|
568 | |||
569 | self.pairsList = None |
|
569 | self.pairsList = None | |
570 |
|
570 | |||
571 | self.flagNoData = True |
|
571 | self.flagNoData = True | |
572 |
|
572 | |||
573 | self.flagDiscontinuousBlock = False |
|
573 | self.flagDiscontinuousBlock = False | |
574 |
|
574 | |||
575 | self.utctime = None |
|
575 | self.utctime = None | |
576 |
|
576 | |||
577 | self.nCohInt = None |
|
577 | self.nCohInt = None | |
578 |
|
578 | |||
579 | self.nIncohInt = None |
|
579 | self.nIncohInt = None | |
580 |
|
580 | |||
581 | self.blocksize = None |
|
581 | self.blocksize = None | |
582 |
|
582 | |||
583 | self.nFFTPoints = None |
|
583 | self.nFFTPoints = None | |
584 |
|
584 | |||
585 | self.wavelength = None |
|
585 | self.wavelength = None | |
586 |
|
586 | |||
587 | self.flagDecodeData = False # asumo q la data no esta decodificada |
|
587 | self.flagDecodeData = False # asumo q la data no esta decodificada | |
588 |
|
588 | |||
589 | self.flagDeflipData = False # asumo q la data no esta sin flip |
|
589 | self.flagDeflipData = False # asumo q la data no esta sin flip | |
590 |
|
590 | |||
591 | self.flagShiftFFT = False |
|
591 | self.flagShiftFFT = False | |
592 |
|
592 | |||
593 | self.ippFactor = 1 |
|
593 | self.ippFactor = 1 | |
594 |
|
594 | |||
595 | #self.noise = None |
|
595 | #self.noise = None | |
596 |
|
596 | |||
597 | self.beacon_heiIndexList = [] |
|
597 | self.beacon_heiIndexList = [] | |
598 |
|
598 | |||
599 | self.noise_estimation = None |
|
599 | self.noise_estimation = None | |
600 |
|
600 | |||
601 | def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): |
|
601 | def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): | |
602 | """ |
|
602 | """ | |
603 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
603 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
604 |
|
604 | |||
605 | Return: |
|
605 | Return: | |
606 | noiselevel |
|
606 | noiselevel | |
607 | """ |
|
607 | """ | |
608 |
|
608 | |||
609 | noise = numpy.zeros(self.nChannels) |
|
609 | noise = numpy.zeros(self.nChannels) | |
610 |
|
610 | |||
611 | for channel in range(self.nChannels): |
|
611 | for channel in range(self.nChannels): | |
612 | daux = self.data_spc[channel, |
|
612 | daux = self.data_spc[channel, | |
613 | xmin_index:xmax_index, ymin_index:ymax_index] |
|
613 | xmin_index:xmax_index, ymin_index:ymax_index] | |
614 |
|
614 | |||
615 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) |
|
615 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) | |
616 |
|
616 | |||
617 | return noise |
|
617 | return noise | |
618 |
|
618 | |||
619 | def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): |
|
619 | def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): | |
620 |
|
620 | |||
621 | if self.noise_estimation is not None: |
|
621 | if self.noise_estimation is not None: | |
622 | # this was estimated by getNoise Operation defined in jroproc_spectra.py |
|
622 | # this was estimated by getNoise Operation defined in jroproc_spectra.py | |
623 | return self.noise_estimation |
|
623 | return self.noise_estimation | |
624 | else: |
|
624 | else: | |
625 | noise = self.getNoisebyHildebrand( |
|
625 | noise = self.getNoisebyHildebrand( | |
626 | xmin_index, xmax_index, ymin_index, ymax_index) |
|
626 | xmin_index, xmax_index, ymin_index, ymax_index) | |
627 | return noise |
|
627 | return noise | |
628 |
|
628 | |||
629 | def getFreqRangeTimeResponse(self, extrapoints=0): |
|
629 | def getFreqRangeTimeResponse(self, extrapoints=0): | |
630 |
|
630 | |||
631 | deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints * self.ippFactor) |
|
631 | deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints * self.ippFactor) | |
632 | freqrange = deltafreq * \ |
|
632 | freqrange = deltafreq * \ | |
633 | (numpy.arange(self.nFFTPoints + extrapoints) - |
|
633 | (numpy.arange(self.nFFTPoints + extrapoints) - | |
634 | self.nFFTPoints / 2.) - deltafreq / 2 |
|
634 | self.nFFTPoints / 2.) - deltafreq / 2 | |
635 |
|
635 | |||
636 | return freqrange |
|
636 | return freqrange | |
637 |
|
637 | |||
638 | def getAcfRange(self, extrapoints=0): |
|
638 | def getAcfRange(self, extrapoints=0): | |
|
639 | #print "GET ACF RANGE" | |||
639 | #print "NFFTPoints",self.nFFTPoints |
|
640 | #print "NFFTPoints",self.nFFTPoints | |
640 | #print "IPPFactor", self.ippFactor |
|
641 | #print "IPPFactor", self.ippFactor | |
641 | deltafreq = 10. / ( self.getFmax() / (self.nFFTPoints * self.ippFactor) ) |
|
642 | #deltafreq = 10. / ( self.getFmax() / (self.nFFTPoints * self.ippFactor) ) | |
642 | #print "deltafreq",deltafreq |
|
643 | deltatime = 1./(self.getFmax()/ self.ippFactor) | |
|
644 | #print "getFmax",self.getFmax() | |||
643 | #import time |
|
645 | #import time | |
644 | #time.sleep(30) |
|
646 | #time.sleep(30) | |
645 |
|
|
647 | timerange = deltatime * \ | |
646 | (numpy.arange(self.nFFTPoints + extrapoints) - |
|
648 | (numpy.arange(self.nFFTPoints + extrapoints) - | |
647 |
self.nFFTPoints / 2.) |
|
649 | self.nFFTPoints / 2.) | |
648 |
|
650 | #- deltafreq / 2 | ||
649 | return freqrange |
|
651 | #print "timerange",timerange | |
|
652 | return timerange | |||
650 |
|
653 | |||
651 | def getFreqRange(self, extrapoints=0): |
|
654 | def getFreqRange(self, extrapoints=0): | |
652 |
|
655 | |||
653 | deltafreq = self.getFmax() / (self.nFFTPoints * self.ippFactor) |
|
656 | deltafreq = self.getFmax() / (self.nFFTPoints * self.ippFactor) | |
654 | #print "deltafreq", deltafreq |
|
657 | #print "deltafreq", deltafreq | |
655 | freqrange = deltafreq * \ |
|
658 | freqrange = deltafreq * \ | |
656 | (numpy.arange(self.nFFTPoints + extrapoints) - |
|
659 | (numpy.arange(self.nFFTPoints + extrapoints) - | |
657 | self.nFFTPoints / 2.) - deltafreq / 2 |
|
660 | self.nFFTPoints / 2.) - deltafreq / 2 | |
658 | #print "freqrange",freqrange |
|
661 | #print "freqrange",freqrange | |
659 | return freqrange |
|
662 | return freqrange | |
660 |
|
663 | |||
661 | def getVelRange(self, extrapoints=0): |
|
664 | def getVelRange(self, extrapoints=0): | |
662 |
|
665 | |||
663 | deltav = self.getVmax() / (self.nFFTPoints * self.ippFactor) |
|
666 | deltav = self.getVmax() / (self.nFFTPoints * self.ippFactor) | |
664 | velrange = deltav * (numpy.arange(self.nFFTPoints + |
|
667 | velrange = deltav * (numpy.arange(self.nFFTPoints + | |
665 | extrapoints) - self.nFFTPoints / 2.) # - deltav/2 |
|
668 | extrapoints) - self.nFFTPoints / 2.) # - deltav/2 | |
666 |
|
669 | |||
667 | return velrange |
|
670 | return velrange | |
668 |
|
671 | |||
669 | def getNPairs(self): |
|
672 | def getNPairs(self): | |
670 |
|
673 | |||
671 | return len(self.pairsList) |
|
674 | return len(self.pairsList) | |
672 |
|
675 | |||
673 | def getPairsIndexList(self): |
|
676 | def getPairsIndexList(self): | |
674 |
|
677 | |||
675 | return range(self.nPairs) |
|
678 | return range(self.nPairs) | |
676 |
|
679 | |||
677 | def getNormFactor(self): |
|
680 | def getNormFactor(self): | |
678 |
|
681 | |||
679 | pwcode = 1 |
|
682 | pwcode = 1 | |
680 |
|
683 | |||
681 | if self.flagDecodeData: |
|
684 | if self.flagDecodeData: | |
682 | pwcode = numpy.sum(self.code[0]**2) |
|
685 | pwcode = numpy.sum(self.code[0]**2) | |
683 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
686 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
684 | normFactor = self.nProfiles * self.nIncohInt * \ |
|
687 | normFactor = self.nProfiles * self.nIncohInt * \ | |
685 | self.nCohInt * pwcode * self.windowOfFilter |
|
688 | self.nCohInt * pwcode * self.windowOfFilter | |
686 |
|
689 | |||
687 | return normFactor |
|
690 | return normFactor | |
688 |
|
691 | |||
689 | def getFlagCspc(self): |
|
692 | def getFlagCspc(self): | |
690 |
|
693 | |||
691 | if self.data_cspc is None: |
|
694 | if self.data_cspc is None: | |
692 | return True |
|
695 | return True | |
693 |
|
696 | |||
694 | return False |
|
697 | return False | |
695 |
|
698 | |||
696 | def getFlagDc(self): |
|
699 | def getFlagDc(self): | |
697 |
|
700 | |||
698 | if self.data_dc is None: |
|
701 | if self.data_dc is None: | |
699 | return True |
|
702 | return True | |
700 |
|
703 | |||
701 | return False |
|
704 | return False | |
702 |
|
705 | |||
703 | def getTimeInterval(self): |
|
706 | def getTimeInterval(self): | |
704 |
|
707 | |||
705 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles * self.ippFactor |
|
708 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles * self.ippFactor | |
706 |
|
709 | |||
707 | return timeInterval |
|
710 | return timeInterval | |
708 |
|
711 | |||
709 | def getPower(self): |
|
712 | def getPower(self): | |
710 |
|
713 | |||
711 | factor = self.normFactor |
|
714 | factor = self.normFactor | |
712 | z = self.data_spc / factor |
|
715 | z = self.data_spc / factor | |
713 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
716 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
714 | avg = numpy.average(z, axis=1) |
|
717 | avg = numpy.average(z, axis=1) | |
715 |
|
718 | |||
716 | return 10 * numpy.log10(avg) |
|
719 | return 10 * numpy.log10(avg) | |
717 |
|
720 | |||
718 | def getCoherence(self, pairsList=None, phase=False): |
|
721 | def getCoherence(self, pairsList=None, phase=False): | |
719 |
|
722 | |||
720 | z = [] |
|
723 | z = [] | |
721 | if pairsList is None: |
|
724 | if pairsList is None: | |
722 | pairsIndexList = self.pairsIndexList |
|
725 | pairsIndexList = self.pairsIndexList | |
723 | else: |
|
726 | else: | |
724 | pairsIndexList = [] |
|
727 | pairsIndexList = [] | |
725 | for pair in pairsList: |
|
728 | for pair in pairsList: | |
726 | if pair not in self.pairsList: |
|
729 | if pair not in self.pairsList: | |
727 | raise ValueError, "Pair %s is not in dataOut.pairsList" % ( |
|
730 | raise ValueError, "Pair %s is not in dataOut.pairsList" % ( | |
728 | pair) |
|
731 | pair) | |
729 | pairsIndexList.append(self.pairsList.index(pair)) |
|
732 | pairsIndexList.append(self.pairsList.index(pair)) | |
730 | for i in range(len(pairsIndexList)): |
|
733 | for i in range(len(pairsIndexList)): | |
731 | pair = self.pairsList[pairsIndexList[i]] |
|
734 | pair = self.pairsList[pairsIndexList[i]] | |
732 | ccf = numpy.average( |
|
735 | ccf = numpy.average( | |
733 | self.data_cspc[pairsIndexList[i], :, :], axis=0) |
|
736 | self.data_cspc[pairsIndexList[i], :, :], axis=0) | |
734 | powa = numpy.average(self.data_spc[pair[0], :, :], axis=0) |
|
737 | powa = numpy.average(self.data_spc[pair[0], :, :], axis=0) | |
735 | powb = numpy.average(self.data_spc[pair[1], :, :], axis=0) |
|
738 | powb = numpy.average(self.data_spc[pair[1], :, :], axis=0) | |
736 | avgcoherenceComplex = ccf / numpy.sqrt(powa * powb) |
|
739 | avgcoherenceComplex = ccf / numpy.sqrt(powa * powb) | |
737 | if phase: |
|
740 | if phase: | |
738 | data = numpy.arctan2(avgcoherenceComplex.imag, |
|
741 | data = numpy.arctan2(avgcoherenceComplex.imag, | |
739 | avgcoherenceComplex.real) * 180 / numpy.pi |
|
742 | avgcoherenceComplex.real) * 180 / numpy.pi | |
740 | else: |
|
743 | else: | |
741 | data = numpy.abs(avgcoherenceComplex) |
|
744 | data = numpy.abs(avgcoherenceComplex) | |
742 |
|
745 | |||
743 | z.append(data) |
|
746 | z.append(data) | |
744 |
|
747 | |||
745 | return numpy.array(z) |
|
748 | return numpy.array(z) | |
746 |
|
749 | |||
747 | def setValue(self, value): |
|
750 | def setValue(self, value): | |
748 |
|
751 | |||
749 | print "This property should not be initialized" |
|
752 | print "This property should not be initialized" | |
750 |
|
753 | |||
751 | return |
|
754 | return | |
752 |
|
755 | |||
753 | nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.") |
|
756 | nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.") | |
754 | pairsIndexList = property( |
|
757 | pairsIndexList = property( | |
755 | getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.") |
|
758 | getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.") | |
756 | normFactor = property(getNormFactor, setValue, |
|
759 | normFactor = property(getNormFactor, setValue, | |
757 | "I'm the 'getNormFactor' property.") |
|
760 | "I'm the 'getNormFactor' property.") | |
758 | flag_cspc = property(getFlagCspc, setValue) |
|
761 | flag_cspc = property(getFlagCspc, setValue) | |
759 | flag_dc = property(getFlagDc, setValue) |
|
762 | flag_dc = property(getFlagDc, setValue) | |
760 | noise = property(getNoise, setValue, "I'm the 'nHeights' property.") |
|
763 | noise = property(getNoise, setValue, "I'm the 'nHeights' property.") | |
761 | timeInterval = property(getTimeInterval, setValue, |
|
764 | timeInterval = property(getTimeInterval, setValue, | |
762 | "I'm the 'timeInterval' property") |
|
765 | "I'm the 'timeInterval' property") | |
763 |
|
766 | |||
764 |
|
767 | |||
765 | class SpectraHeis(Spectra): |
|
768 | class SpectraHeis(Spectra): | |
766 |
|
769 | |||
767 | data_spc = None |
|
770 | data_spc = None | |
768 |
|
771 | |||
769 | data_cspc = None |
|
772 | data_cspc = None | |
770 |
|
773 | |||
771 | data_dc = None |
|
774 | data_dc = None | |
772 |
|
775 | |||
773 | nFFTPoints = None |
|
776 | nFFTPoints = None | |
774 |
|
777 | |||
775 | # nPairs = None |
|
778 | # nPairs = None | |
776 |
|
779 | |||
777 | pairsList = None |
|
780 | pairsList = None | |
778 |
|
781 | |||
779 | nCohInt = None |
|
782 | nCohInt = None | |
780 |
|
783 | |||
781 | nIncohInt = None |
|
784 | nIncohInt = None | |
782 |
|
785 | |||
783 | def __init__(self): |
|
786 | def __init__(self): | |
784 |
|
787 | |||
785 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
788 | self.radarControllerHeaderObj = RadarControllerHeader() | |
786 |
|
789 | |||
787 | self.systemHeaderObj = SystemHeader() |
|
790 | self.systemHeaderObj = SystemHeader() | |
788 |
|
791 | |||
789 | self.type = "SpectraHeis" |
|
792 | self.type = "SpectraHeis" | |
790 |
|
793 | |||
791 | # self.dtype = None |
|
794 | # self.dtype = None | |
792 |
|
795 | |||
793 | # self.nChannels = 0 |
|
796 | # self.nChannels = 0 | |
794 |
|
797 | |||
795 | # self.nHeights = 0 |
|
798 | # self.nHeights = 0 | |
796 |
|
799 | |||
797 | self.nProfiles = None |
|
800 | self.nProfiles = None | |
798 |
|
801 | |||
799 | self.heightList = None |
|
802 | self.heightList = None | |
800 |
|
803 | |||
801 | self.channelList = None |
|
804 | self.channelList = None | |
802 |
|
805 | |||
803 | # self.channelIndexList = None |
|
806 | # self.channelIndexList = None | |
804 |
|
807 | |||
805 | self.flagNoData = True |
|
808 | self.flagNoData = True | |
806 |
|
809 | |||
807 | self.flagDiscontinuousBlock = False |
|
810 | self.flagDiscontinuousBlock = False | |
808 |
|
811 | |||
809 | # self.nPairs = 0 |
|
812 | # self.nPairs = 0 | |
810 |
|
813 | |||
811 | self.utctime = None |
|
814 | self.utctime = None | |
812 |
|
815 | |||
813 | self.blocksize = None |
|
816 | self.blocksize = None | |
814 |
|
817 | |||
815 | self.profileIndex = 0 |
|
818 | self.profileIndex = 0 | |
816 |
|
819 | |||
817 | self.nCohInt = 1 |
|
820 | self.nCohInt = 1 | |
818 |
|
821 | |||
819 | self.nIncohInt = 1 |
|
822 | self.nIncohInt = 1 | |
820 |
|
823 | |||
821 | def getNormFactor(self): |
|
824 | def getNormFactor(self): | |
822 | pwcode = 1 |
|
825 | pwcode = 1 | |
823 | if self.flagDecodeData: |
|
826 | if self.flagDecodeData: | |
824 | pwcode = numpy.sum(self.code[0]**2) |
|
827 | pwcode = numpy.sum(self.code[0]**2) | |
825 |
|
828 | |||
826 | normFactor = self.nIncohInt * self.nCohInt * pwcode |
|
829 | normFactor = self.nIncohInt * self.nCohInt * pwcode | |
827 |
|
830 | |||
828 | return normFactor |
|
831 | return normFactor | |
829 |
|
832 | |||
830 | def getTimeInterval(self): |
|
833 | def getTimeInterval(self): | |
831 |
|
834 | |||
832 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
835 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
833 |
|
836 | |||
834 | return timeInterval |
|
837 | return timeInterval | |
835 |
|
838 | |||
836 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") |
|
839 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") | |
837 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
840 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
838 |
|
841 | |||
839 |
|
842 | |||
840 | class Fits(JROData): |
|
843 | class Fits(JROData): | |
841 |
|
844 | |||
842 | heightList = None |
|
845 | heightList = None | |
843 |
|
846 | |||
844 | channelList = None |
|
847 | channelList = None | |
845 |
|
848 | |||
846 | flagNoData = True |
|
849 | flagNoData = True | |
847 |
|
850 | |||
848 | flagDiscontinuousBlock = False |
|
851 | flagDiscontinuousBlock = False | |
849 |
|
852 | |||
850 | useLocalTime = False |
|
853 | useLocalTime = False | |
851 |
|
854 | |||
852 | utctime = None |
|
855 | utctime = None | |
853 |
|
856 | |||
854 | timeZone = None |
|
857 | timeZone = None | |
855 |
|
858 | |||
856 | # ippSeconds = None |
|
859 | # ippSeconds = None | |
857 |
|
860 | |||
858 | # timeInterval = None |
|
861 | # timeInterval = None | |
859 |
|
862 | |||
860 | nCohInt = None |
|
863 | nCohInt = None | |
861 |
|
864 | |||
862 | nIncohInt = None |
|
865 | nIncohInt = None | |
863 |
|
866 | |||
864 | noise = None |
|
867 | noise = None | |
865 |
|
868 | |||
866 | windowOfFilter = 1 |
|
869 | windowOfFilter = 1 | |
867 |
|
870 | |||
868 | # Speed of ligth |
|
871 | # Speed of ligth | |
869 | C = 3e8 |
|
872 | C = 3e8 | |
870 |
|
873 | |||
871 | frequency = 49.92e6 |
|
874 | frequency = 49.92e6 | |
872 |
|
875 | |||
873 | realtime = False |
|
876 | realtime = False | |
874 |
|
877 | |||
875 | def __init__(self): |
|
878 | def __init__(self): | |
876 |
|
879 | |||
877 | self.type = "Fits" |
|
880 | self.type = "Fits" | |
878 |
|
881 | |||
879 | self.nProfiles = None |
|
882 | self.nProfiles = None | |
880 |
|
883 | |||
881 | self.heightList = None |
|
884 | self.heightList = None | |
882 |
|
885 | |||
883 | self.channelList = None |
|
886 | self.channelList = None | |
884 |
|
887 | |||
885 | # self.channelIndexList = None |
|
888 | # self.channelIndexList = None | |
886 |
|
889 | |||
887 | self.flagNoData = True |
|
890 | self.flagNoData = True | |
888 |
|
891 | |||
889 | self.utctime = None |
|
892 | self.utctime = None | |
890 |
|
893 | |||
891 | self.nCohInt = 1 |
|
894 | self.nCohInt = 1 | |
892 |
|
895 | |||
893 | self.nIncohInt = 1 |
|
896 | self.nIncohInt = 1 | |
894 |
|
897 | |||
895 | self.useLocalTime = True |
|
898 | self.useLocalTime = True | |
896 |
|
899 | |||
897 | self.profileIndex = 0 |
|
900 | self.profileIndex = 0 | |
898 |
|
901 | |||
899 | # self.utctime = None |
|
902 | # self.utctime = None | |
900 | # self.timeZone = None |
|
903 | # self.timeZone = None | |
901 | # self.ltctime = None |
|
904 | # self.ltctime = None | |
902 | # self.timeInterval = None |
|
905 | # self.timeInterval = None | |
903 | # self.header = None |
|
906 | # self.header = None | |
904 | # self.data_header = None |
|
907 | # self.data_header = None | |
905 | # self.data = None |
|
908 | # self.data = None | |
906 | # self.datatime = None |
|
909 | # self.datatime = None | |
907 | # self.flagNoData = False |
|
910 | # self.flagNoData = False | |
908 | # self.expName = '' |
|
911 | # self.expName = '' | |
909 | # self.nChannels = None |
|
912 | # self.nChannels = None | |
910 | # self.nSamples = None |
|
913 | # self.nSamples = None | |
911 | # self.dataBlocksPerFile = None |
|
914 | # self.dataBlocksPerFile = None | |
912 | # self.comments = '' |
|
915 | # self.comments = '' | |
913 | # |
|
916 | # | |
914 |
|
917 | |||
915 | def getltctime(self): |
|
918 | def getltctime(self): | |
916 |
|
919 | |||
917 | if self.useLocalTime: |
|
920 | if self.useLocalTime: | |
918 | return self.utctime - self.timeZone * 60 |
|
921 | return self.utctime - self.timeZone * 60 | |
919 |
|
922 | |||
920 | return self.utctime |
|
923 | return self.utctime | |
921 |
|
924 | |||
922 | def getDatatime(self): |
|
925 | def getDatatime(self): | |
923 |
|
926 | |||
924 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
927 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) | |
925 | return datatime |
|
928 | return datatime | |
926 |
|
929 | |||
927 | def getTimeRange(self): |
|
930 | def getTimeRange(self): | |
928 |
|
931 | |||
929 | datatime = [] |
|
932 | datatime = [] | |
930 |
|
933 | |||
931 | datatime.append(self.ltctime) |
|
934 | datatime.append(self.ltctime) | |
932 | datatime.append(self.ltctime + self.timeInterval) |
|
935 | datatime.append(self.ltctime + self.timeInterval) | |
933 |
|
936 | |||
934 | datatime = numpy.array(datatime) |
|
937 | datatime = numpy.array(datatime) | |
935 |
|
938 | |||
936 | return datatime |
|
939 | return datatime | |
937 |
|
940 | |||
938 | def getHeiRange(self): |
|
941 | def getHeiRange(self): | |
939 |
|
942 | |||
940 | heis = self.heightList |
|
943 | heis = self.heightList | |
941 |
|
944 | |||
942 | return heis |
|
945 | return heis | |
943 |
|
946 | |||
944 | def getNHeights(self): |
|
947 | def getNHeights(self): | |
945 |
|
948 | |||
946 | return len(self.heightList) |
|
949 | return len(self.heightList) | |
947 |
|
950 | |||
948 | def getNChannels(self): |
|
951 | def getNChannels(self): | |
949 |
|
952 | |||
950 | return len(self.channelList) |
|
953 | return len(self.channelList) | |
951 |
|
954 | |||
952 | def getChannelIndexList(self): |
|
955 | def getChannelIndexList(self): | |
953 |
|
956 | |||
954 | return range(self.nChannels) |
|
957 | return range(self.nChannels) | |
955 |
|
958 | |||
956 | def getNoise(self, type=1): |
|
959 | def getNoise(self, type=1): | |
957 |
|
960 | |||
958 | #noise = numpy.zeros(self.nChannels) |
|
961 | #noise = numpy.zeros(self.nChannels) | |
959 |
|
962 | |||
960 | if type == 1: |
|
963 | if type == 1: | |
961 | noise = self.getNoisebyHildebrand() |
|
964 | noise = self.getNoisebyHildebrand() | |
962 |
|
965 | |||
963 | if type == 2: |
|
966 | if type == 2: | |
964 | noise = self.getNoisebySort() |
|
967 | noise = self.getNoisebySort() | |
965 |
|
968 | |||
966 | if type == 3: |
|
969 | if type == 3: | |
967 | noise = self.getNoisebyWindow() |
|
970 | noise = self.getNoisebyWindow() | |
968 |
|
971 | |||
969 | return noise |
|
972 | return noise | |
970 |
|
973 | |||
971 | def getTimeInterval(self): |
|
974 | def getTimeInterval(self): | |
972 |
|
975 | |||
973 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
976 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
974 |
|
977 | |||
975 | return timeInterval |
|
978 | return timeInterval | |
976 |
|
979 | |||
977 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
980 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
978 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
981 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
979 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
982 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
980 | channelIndexList = property( |
|
983 | channelIndexList = property( | |
981 | getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
984 | getChannelIndexList, "I'm the 'channelIndexList' property.") | |
982 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
985 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
983 |
|
986 | |||
984 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
987 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
985 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
988 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
986 |
|
989 | |||
987 |
|
990 | |||
988 | class Correlation(JROData): |
|
991 | class Correlation(JROData): | |
989 |
|
992 | |||
990 | noise = None |
|
993 | noise = None | |
991 |
|
994 | |||
992 | SNR = None |
|
995 | SNR = None | |
993 |
|
996 | |||
994 | #-------------------------------------------------- |
|
997 | #-------------------------------------------------- | |
995 |
|
998 | |||
996 | mode = None |
|
999 | mode = None | |
997 |
|
1000 | |||
998 | split = False |
|
1001 | split = False | |
999 |
|
1002 | |||
1000 | data_cf = None |
|
1003 | data_cf = None | |
1001 |
|
1004 | |||
1002 | lags = None |
|
1005 | lags = None | |
1003 |
|
1006 | |||
1004 | lagRange = None |
|
1007 | lagRange = None | |
1005 |
|
1008 | |||
1006 | pairsList = None |
|
1009 | pairsList = None | |
1007 |
|
1010 | |||
1008 | normFactor = None |
|
1011 | normFactor = None | |
1009 |
|
1012 | |||
1010 | #-------------------------------------------------- |
|
1013 | #-------------------------------------------------- | |
1011 |
|
1014 | |||
1012 | # calculateVelocity = None |
|
1015 | # calculateVelocity = None | |
1013 |
|
1016 | |||
1014 | nLags = None |
|
1017 | nLags = None | |
1015 |
|
1018 | |||
1016 | nPairs = None |
|
1019 | nPairs = None | |
1017 |
|
1020 | |||
1018 | nAvg = None |
|
1021 | nAvg = None | |
1019 |
|
1022 | |||
1020 | def __init__(self): |
|
1023 | def __init__(self): | |
1021 | ''' |
|
1024 | ''' | |
1022 | Constructor |
|
1025 | Constructor | |
1023 | ''' |
|
1026 | ''' | |
1024 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
1027 | self.radarControllerHeaderObj = RadarControllerHeader() | |
1025 |
|
1028 | |||
1026 | self.systemHeaderObj = SystemHeader() |
|
1029 | self.systemHeaderObj = SystemHeader() | |
1027 |
|
1030 | |||
1028 | self.type = "Correlation" |
|
1031 | self.type = "Correlation" | |
1029 |
|
1032 | |||
1030 | self.data = None |
|
1033 | self.data = None | |
1031 |
|
1034 | |||
1032 | self.dtype = None |
|
1035 | self.dtype = None | |
1033 |
|
1036 | |||
1034 | self.nProfiles = None |
|
1037 | self.nProfiles = None | |
1035 |
|
1038 | |||
1036 | self.heightList = None |
|
1039 | self.heightList = None | |
1037 |
|
1040 | |||
1038 | self.channelList = None |
|
1041 | self.channelList = None | |
1039 |
|
1042 | |||
1040 | self.flagNoData = True |
|
1043 | self.flagNoData = True | |
1041 |
|
1044 | |||
1042 | self.flagDiscontinuousBlock = False |
|
1045 | self.flagDiscontinuousBlock = False | |
1043 |
|
1046 | |||
1044 | self.utctime = None |
|
1047 | self.utctime = None | |
1045 |
|
1048 | |||
1046 | self.timeZone = None |
|
1049 | self.timeZone = None | |
1047 |
|
1050 | |||
1048 | self.dstFlag = None |
|
1051 | self.dstFlag = None | |
1049 |
|
1052 | |||
1050 | self.errorCount = None |
|
1053 | self.errorCount = None | |
1051 |
|
1054 | |||
1052 | self.blocksize = None |
|
1055 | self.blocksize = None | |
1053 |
|
1056 | |||
1054 | self.flagDecodeData = False # asumo q la data no esta decodificada |
|
1057 | self.flagDecodeData = False # asumo q la data no esta decodificada | |
1055 |
|
1058 | |||
1056 | self.flagDeflipData = False # asumo q la data no esta sin flip |
|
1059 | self.flagDeflipData = False # asumo q la data no esta sin flip | |
1057 |
|
1060 | |||
1058 | self.pairsList = None |
|
1061 | self.pairsList = None | |
1059 |
|
1062 | |||
1060 | self.nPoints = None |
|
1063 | self.nPoints = None | |
1061 |
|
1064 | |||
1062 | def getPairsList(self): |
|
1065 | def getPairsList(self): | |
1063 |
|
1066 | |||
1064 | return self.pairsList |
|
1067 | return self.pairsList | |
1065 |
|
1068 | |||
1066 | def getNoise(self, mode=2): |
|
1069 | def getNoise(self, mode=2): | |
1067 |
|
1070 | |||
1068 | indR = numpy.where(self.lagR == 0)[0][0] |
|
1071 | indR = numpy.where(self.lagR == 0)[0][0] | |
1069 | indT = numpy.where(self.lagT == 0)[0][0] |
|
1072 | indT = numpy.where(self.lagT == 0)[0][0] | |
1070 |
|
1073 | |||
1071 | jspectra0 = self.data_corr[:, :, indR, :] |
|
1074 | jspectra0 = self.data_corr[:, :, indR, :] | |
1072 | jspectra = copy.copy(jspectra0) |
|
1075 | jspectra = copy.copy(jspectra0) | |
1073 |
|
1076 | |||
1074 | num_chan = jspectra.shape[0] |
|
1077 | num_chan = jspectra.shape[0] | |
1075 | num_hei = jspectra.shape[2] |
|
1078 | num_hei = jspectra.shape[2] | |
1076 |
|
1079 | |||
1077 | freq_dc = jspectra.shape[1] / 2 |
|
1080 | freq_dc = jspectra.shape[1] / 2 | |
1078 | ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc |
|
1081 | ind_vel = numpy.array([-2, -1, 1, 2]) + freq_dc | |
1079 |
|
1082 | |||
1080 | if ind_vel[0] < 0: |
|
1083 | if ind_vel[0] < 0: | |
1081 | ind_vel[range(0, 1)] = ind_vel[range(0, 1)] + self.num_prof |
|
1084 | ind_vel[range(0, 1)] = ind_vel[range(0, 1)] + self.num_prof | |
1082 |
|
1085 | |||
1083 | if mode == 1: |
|
1086 | if mode == 1: | |
1084 | jspectra[:, freq_dc, :] = ( |
|
1087 | jspectra[:, freq_dc, :] = ( | |
1085 | jspectra[:, ind_vel[1], :] + jspectra[:, ind_vel[2], :]) / 2 # CORRECCION |
|
1088 | jspectra[:, ind_vel[1], :] + jspectra[:, ind_vel[2], :]) / 2 # CORRECCION | |
1086 |
|
1089 | |||
1087 | if mode == 2: |
|
1090 | if mode == 2: | |
1088 |
|
1091 | |||
1089 | vel = numpy.array([-2, -1, 1, 2]) |
|
1092 | vel = numpy.array([-2, -1, 1, 2]) | |
1090 | xx = numpy.zeros([4, 4]) |
|
1093 | xx = numpy.zeros([4, 4]) | |
1091 |
|
1094 | |||
1092 | for fil in range(4): |
|
1095 | for fil in range(4): | |
1093 | xx[fil, :] = vel[fil]**numpy.asarray(range(4)) |
|
1096 | xx[fil, :] = vel[fil]**numpy.asarray(range(4)) | |
1094 |
|
1097 | |||
1095 | xx_inv = numpy.linalg.inv(xx) |
|
1098 | xx_inv = numpy.linalg.inv(xx) | |
1096 | xx_aux = xx_inv[0, :] |
|
1099 | xx_aux = xx_inv[0, :] | |
1097 |
|
1100 | |||
1098 | for ich in range(num_chan): |
|
1101 | for ich in range(num_chan): | |
1099 | yy = jspectra[ich, ind_vel, :] |
|
1102 | yy = jspectra[ich, ind_vel, :] | |
1100 | jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy) |
|
1103 | jspectra[ich, freq_dc, :] = numpy.dot(xx_aux, yy) | |
1101 |
|
1104 | |||
1102 | junkid = jspectra[ich, freq_dc, :] <= 0 |
|
1105 | junkid = jspectra[ich, freq_dc, :] <= 0 | |
1103 | cjunkid = sum(junkid) |
|
1106 | cjunkid = sum(junkid) | |
1104 |
|
1107 | |||
1105 | if cjunkid.any(): |
|
1108 | if cjunkid.any(): | |
1106 | jspectra[ich, freq_dc, junkid.nonzero()] = ( |
|
1109 | jspectra[ich, freq_dc, junkid.nonzero()] = ( | |
1107 | jspectra[ich, ind_vel[1], junkid] + jspectra[ich, ind_vel[2], junkid]) / 2 |
|
1110 | jspectra[ich, ind_vel[1], junkid] + jspectra[ich, ind_vel[2], junkid]) / 2 | |
1108 |
|
1111 | |||
1109 | noise = jspectra0[:, freq_dc, :] - jspectra[:, freq_dc, :] |
|
1112 | noise = jspectra0[:, freq_dc, :] - jspectra[:, freq_dc, :] | |
1110 |
|
1113 | |||
1111 | return noise |
|
1114 | return noise | |
1112 |
|
1115 | |||
1113 | def getTimeInterval(self): |
|
1116 | def getTimeInterval(self): | |
1114 |
|
1117 | |||
1115 | timeInterval = self.ippSeconds * self.nCohInt * self.nProfiles |
|
1118 | timeInterval = self.ippSeconds * self.nCohInt * self.nProfiles | |
1116 |
|
1119 | |||
1117 | return timeInterval |
|
1120 | return timeInterval | |
1118 |
|
1121 | |||
1119 | def splitFunctions(self): |
|
1122 | def splitFunctions(self): | |
1120 |
|
1123 | |||
1121 | pairsList = self.pairsList |
|
1124 | pairsList = self.pairsList | |
1122 | ccf_pairs = [] |
|
1125 | ccf_pairs = [] | |
1123 | acf_pairs = [] |
|
1126 | acf_pairs = [] | |
1124 | ccf_ind = [] |
|
1127 | ccf_ind = [] | |
1125 | acf_ind = [] |
|
1128 | acf_ind = [] | |
1126 | for l in range(len(pairsList)): |
|
1129 | for l in range(len(pairsList)): | |
1127 | chan0 = pairsList[l][0] |
|
1130 | chan0 = pairsList[l][0] | |
1128 | chan1 = pairsList[l][1] |
|
1131 | chan1 = pairsList[l][1] | |
1129 |
|
1132 | |||
1130 | # Obteniendo pares de Autocorrelacion |
|
1133 | # Obteniendo pares de Autocorrelacion | |
1131 | if chan0 == chan1: |
|
1134 | if chan0 == chan1: | |
1132 | acf_pairs.append(chan0) |
|
1135 | acf_pairs.append(chan0) | |
1133 | acf_ind.append(l) |
|
1136 | acf_ind.append(l) | |
1134 | else: |
|
1137 | else: | |
1135 | ccf_pairs.append(pairsList[l]) |
|
1138 | ccf_pairs.append(pairsList[l]) | |
1136 | ccf_ind.append(l) |
|
1139 | ccf_ind.append(l) | |
1137 |
|
1140 | |||
1138 | data_acf = self.data_cf[acf_ind] |
|
1141 | data_acf = self.data_cf[acf_ind] | |
1139 | data_ccf = self.data_cf[ccf_ind] |
|
1142 | data_ccf = self.data_cf[ccf_ind] | |
1140 |
|
1143 | |||
1141 | return acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf |
|
1144 | return acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf | |
1142 |
|
1145 | |||
1143 | def getNormFactor(self): |
|
1146 | def getNormFactor(self): | |
1144 | acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf = self.splitFunctions() |
|
1147 | acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf = self.splitFunctions() | |
1145 | acf_pairs = numpy.array(acf_pairs) |
|
1148 | acf_pairs = numpy.array(acf_pairs) | |
1146 | normFactor = numpy.zeros((self.nPairs, self.nHeights)) |
|
1149 | normFactor = numpy.zeros((self.nPairs, self.nHeights)) | |
1147 |
|
1150 | |||
1148 | for p in range(self.nPairs): |
|
1151 | for p in range(self.nPairs): | |
1149 | pair = self.pairsList[p] |
|
1152 | pair = self.pairsList[p] | |
1150 |
|
1153 | |||
1151 | ch0 = pair[0] |
|
1154 | ch0 = pair[0] | |
1152 | ch1 = pair[1] |
|
1155 | ch1 = pair[1] | |
1153 |
|
1156 | |||
1154 | ch0_max = numpy.max(data_acf[acf_pairs == ch0, :, :], axis=1) |
|
1157 | ch0_max = numpy.max(data_acf[acf_pairs == ch0, :, :], axis=1) | |
1155 | ch1_max = numpy.max(data_acf[acf_pairs == ch1, :, :], axis=1) |
|
1158 | ch1_max = numpy.max(data_acf[acf_pairs == ch1, :, :], axis=1) | |
1156 | normFactor[p, :] = numpy.sqrt(ch0_max * ch1_max) |
|
1159 | normFactor[p, :] = numpy.sqrt(ch0_max * ch1_max) | |
1157 |
|
1160 | |||
1158 | return normFactor |
|
1161 | return normFactor | |
1159 |
|
1162 | |||
1160 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
1163 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
1161 | normFactor = property(getNormFactor, "I'm the 'normFactor property'") |
|
1164 | normFactor = property(getNormFactor, "I'm the 'normFactor property'") | |
1162 |
|
1165 | |||
1163 |
|
1166 | |||
1164 | class Parameters(Spectra): |
|
1167 | class Parameters(Spectra): | |
1165 |
|
1168 | |||
1166 | experimentInfo = None # Information about the experiment |
|
1169 | experimentInfo = None # Information about the experiment | |
1167 |
|
1170 | |||
1168 | # Information from previous data |
|
1171 | # Information from previous data | |
1169 |
|
1172 | |||
1170 | inputUnit = None # Type of data to be processed |
|
1173 | inputUnit = None # Type of data to be processed | |
1171 |
|
1174 | |||
1172 | operation = None # Type of operation to parametrize |
|
1175 | operation = None # Type of operation to parametrize | |
1173 |
|
1176 | |||
1174 | # normFactor = None #Normalization Factor |
|
1177 | # normFactor = None #Normalization Factor | |
1175 |
|
1178 | |||
1176 | groupList = None # List of Pairs, Groups, etc |
|
1179 | groupList = None # List of Pairs, Groups, etc | |
1177 |
|
1180 | |||
1178 | # Parameters |
|
1181 | # Parameters | |
1179 |
|
1182 | |||
1180 | data_param = None # Parameters obtained |
|
1183 | data_param = None # Parameters obtained | |
1181 |
|
1184 | |||
1182 | data_pre = None # Data Pre Parametrization |
|
1185 | data_pre = None # Data Pre Parametrization | |
1183 |
|
1186 | |||
1184 | data_SNR = None # Signal to Noise Ratio |
|
1187 | data_SNR = None # Signal to Noise Ratio | |
1185 |
|
1188 | |||
1186 | # heightRange = None #Heights |
|
1189 | # heightRange = None #Heights | |
1187 |
|
1190 | |||
1188 | abscissaList = None # Abscissa, can be velocities, lags or time |
|
1191 | abscissaList = None # Abscissa, can be velocities, lags or time | |
1189 |
|
1192 | |||
1190 | # noise = None #Noise Potency |
|
1193 | # noise = None #Noise Potency | |
1191 |
|
1194 | |||
1192 | utctimeInit = None # Initial UTC time |
|
1195 | utctimeInit = None # Initial UTC time | |
1193 |
|
1196 | |||
1194 | paramInterval = None # Time interval to calculate Parameters in seconds |
|
1197 | paramInterval = None # Time interval to calculate Parameters in seconds | |
1195 |
|
1198 | |||
1196 | useLocalTime = True |
|
1199 | useLocalTime = True | |
1197 |
|
1200 | |||
1198 | # Fitting |
|
1201 | # Fitting | |
1199 |
|
1202 | |||
1200 | data_error = None # Error of the estimation |
|
1203 | data_error = None # Error of the estimation | |
1201 |
|
1204 | |||
1202 | constants = None |
|
1205 | constants = None | |
1203 |
|
1206 | |||
1204 | library = None |
|
1207 | library = None | |
1205 |
|
1208 | |||
1206 | # Output signal |
|
1209 | # Output signal | |
1207 |
|
1210 | |||
1208 | outputInterval = None # Time interval to calculate output signal in seconds |
|
1211 | outputInterval = None # Time interval to calculate output signal in seconds | |
1209 |
|
1212 | |||
1210 | data_output = None # Out signal |
|
1213 | data_output = None # Out signal | |
1211 |
|
1214 | |||
1212 | nAvg = None |
|
1215 | nAvg = None | |
1213 |
|
1216 | |||
1214 | noise_estimation = None |
|
1217 | noise_estimation = None | |
1215 |
|
1218 | |||
1216 | GauSPC = None # Fit gaussian SPC |
|
1219 | GauSPC = None # Fit gaussian SPC | |
1217 |
|
1220 | |||
1218 | def __init__(self): |
|
1221 | def __init__(self): | |
1219 | ''' |
|
1222 | ''' | |
1220 | Constructor |
|
1223 | Constructor | |
1221 | ''' |
|
1224 | ''' | |
1222 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
1225 | self.radarControllerHeaderObj = RadarControllerHeader() | |
1223 |
|
1226 | |||
1224 | self.systemHeaderObj = SystemHeader() |
|
1227 | self.systemHeaderObj = SystemHeader() | |
1225 |
|
1228 | |||
1226 | self.type = "Parameters" |
|
1229 | self.type = "Parameters" | |
1227 |
|
1230 | |||
1228 | def getTimeRange1(self, interval): |
|
1231 | def getTimeRange1(self, interval): | |
1229 |
|
1232 | |||
1230 | datatime = [] |
|
1233 | datatime = [] | |
1231 |
|
1234 | |||
1232 | if self.useLocalTime: |
|
1235 | if self.useLocalTime: | |
1233 | time1 = self.utctimeInit - self.timeZone * 60 |
|
1236 | time1 = self.utctimeInit - self.timeZone * 60 | |
1234 | else: |
|
1237 | else: | |
1235 | time1 = self.utctimeInit |
|
1238 | time1 = self.utctimeInit | |
1236 |
|
1239 | |||
1237 | datatime.append(time1) |
|
1240 | datatime.append(time1) | |
1238 | datatime.append(time1 + interval) |
|
1241 | datatime.append(time1 + interval) | |
1239 | datatime = numpy.array(datatime) |
|
1242 | datatime = numpy.array(datatime) | |
1240 |
|
1243 | |||
1241 | return datatime |
|
1244 | return datatime | |
1242 |
|
1245 | |||
1243 | def getTimeInterval(self): |
|
1246 | def getTimeInterval(self): | |
1244 |
|
1247 | |||
1245 | if hasattr(self, 'timeInterval1'): |
|
1248 | if hasattr(self, 'timeInterval1'): | |
1246 | return self.timeInterval1 |
|
1249 | return self.timeInterval1 | |
1247 | else: |
|
1250 | else: | |
1248 | return self.paramInterval |
|
1251 | return self.paramInterval | |
1249 |
|
1252 | |||
1250 | def setValue(self, value): |
|
1253 | def setValue(self, value): | |
1251 |
|
1254 | |||
1252 | print "This property should not be initialized" |
|
1255 | print "This property should not be initialized" | |
1253 |
|
1256 | |||
1254 | return |
|
1257 | return | |
1255 |
|
1258 | |||
1256 | def getNoise(self): |
|
1259 | def getNoise(self): | |
1257 |
|
1260 | |||
1258 | return self.spc_noise |
|
1261 | return self.spc_noise | |
1259 |
|
1262 | |||
1260 | timeInterval = property(getTimeInterval) |
|
1263 | timeInterval = property(getTimeInterval) | |
1261 | noise = property(getNoise, setValue, "I'm the 'Noise' property.") |
|
1264 | noise = property(getNoise, setValue, "I'm the 'Noise' property.") |
@@ -1,1737 +1,1738 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jul 9, 2014 |
|
2 | Created on Jul 9, 2014 | |
3 |
|
3 | |||
4 | @author: roj-idl71 |
|
4 | @author: roj-idl71 | |
5 | ''' |
|
5 | ''' | |
6 | import os |
|
6 | import os | |
7 | import datetime |
|
7 | import datetime | |
8 | import numpy |
|
8 | import numpy | |
9 |
|
9 | |||
10 | from figure import Figure, isRealtime, isTimeInHourRange |
|
10 | from figure import Figure, isRealtime, isTimeInHourRange | |
11 | from plotting_codes import * |
|
11 | from plotting_codes import * | |
12 |
|
12 | |||
13 |
|
13 | |||
14 | class SpectraPlot(Figure): |
|
14 | class SpectraPlot(Figure): | |
15 |
|
15 | |||
16 | isConfig = None |
|
16 | isConfig = None | |
17 | __nsubplots = None |
|
17 | __nsubplots = None | |
18 |
|
18 | |||
19 | WIDTHPROF = None |
|
19 | WIDTHPROF = None | |
20 | HEIGHTPROF = None |
|
20 | HEIGHTPROF = None | |
21 | PREFIX = 'spc' |
|
21 | PREFIX = 'spc' | |
22 |
|
22 | |||
23 | def __init__(self, **kwargs): |
|
23 | def __init__(self, **kwargs): | |
24 | Figure.__init__(self, **kwargs) |
|
24 | Figure.__init__(self, **kwargs) | |
25 | self.isConfig = False |
|
25 | self.isConfig = False | |
26 | self.__nsubplots = 1 |
|
26 | self.__nsubplots = 1 | |
27 |
|
27 | |||
28 | self.WIDTH = 250 |
|
28 | self.WIDTH = 250 | |
29 | self.HEIGHT = 250 |
|
29 | self.HEIGHT = 250 | |
30 | self.WIDTHPROF = 120 |
|
30 | self.WIDTHPROF = 120 | |
31 | self.HEIGHTPROF = 0 |
|
31 | self.HEIGHTPROF = 0 | |
32 | self.counter_imagwr = 0 |
|
32 | self.counter_imagwr = 0 | |
33 |
|
33 | |||
34 | self.PLOT_CODE = SPEC_CODE |
|
34 | self.PLOT_CODE = SPEC_CODE | |
35 |
|
35 | |||
36 | self.FTP_WEI = None |
|
36 | self.FTP_WEI = None | |
37 | self.EXP_CODE = None |
|
37 | self.EXP_CODE = None | |
38 | self.SUB_EXP_CODE = None |
|
38 | self.SUB_EXP_CODE = None | |
39 | self.PLOT_POS = None |
|
39 | self.PLOT_POS = None | |
40 |
|
40 | |||
41 | self.__xfilter_ena = False |
|
41 | self.__xfilter_ena = False | |
42 | self.__yfilter_ena = False |
|
42 | self.__yfilter_ena = False | |
43 |
|
43 | |||
44 | def getSubplots(self): |
|
44 | def getSubplots(self): | |
45 |
|
45 | |||
46 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
46 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
47 | nrow = int(self.nplots*1./ncol + 0.9) |
|
47 | nrow = int(self.nplots*1./ncol + 0.9) | |
48 |
|
48 | |||
49 | return nrow, ncol |
|
49 | return nrow, ncol | |
50 |
|
50 | |||
51 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
51 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
52 |
|
52 | |||
53 | self.__showprofile = showprofile |
|
53 | self.__showprofile = showprofile | |
54 | self.nplots = nplots |
|
54 | self.nplots = nplots | |
55 |
|
55 | |||
56 | ncolspan = 1 |
|
56 | ncolspan = 1 | |
57 | colspan = 1 |
|
57 | colspan = 1 | |
58 | if showprofile: |
|
58 | if showprofile: | |
59 | ncolspan = 3 |
|
59 | ncolspan = 3 | |
60 | colspan = 2 |
|
60 | colspan = 2 | |
61 | self.__nsubplots = 2 |
|
61 | self.__nsubplots = 2 | |
62 |
|
62 | |||
63 | self.createFigure(id = id, |
|
63 | self.createFigure(id = id, | |
64 | wintitle = wintitle, |
|
64 | wintitle = wintitle, | |
65 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
65 | widthplot = self.WIDTH + self.WIDTHPROF, | |
66 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
66 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
67 | show=show) |
|
67 | show=show) | |
68 |
|
68 | |||
69 | nrow, ncol = self.getSubplots() |
|
69 | nrow, ncol = self.getSubplots() | |
70 |
|
70 | |||
71 | counter = 0 |
|
71 | counter = 0 | |
72 | for y in range(nrow): |
|
72 | for y in range(nrow): | |
73 | for x in range(ncol): |
|
73 | for x in range(ncol): | |
74 |
|
74 | |||
75 | if counter >= self.nplots: |
|
75 | if counter >= self.nplots: | |
76 | break |
|
76 | break | |
77 |
|
77 | |||
78 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
78 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
79 |
|
79 | |||
80 | if showprofile: |
|
80 | if showprofile: | |
81 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
81 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
82 |
|
82 | |||
83 | counter += 1 |
|
83 | counter += 1 | |
84 |
|
84 | |||
85 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
85 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
86 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
86 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
87 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
87 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
88 | server=None, folder=None, username=None, password=None, |
|
88 | server=None, folder=None, username=None, password=None, | |
89 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False, |
|
89 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False, | |
90 | xaxis="frequency", colormap='jet', normFactor=None): |
|
90 | xaxis="frequency", colormap='jet', normFactor=None): | |
91 |
|
91 | |||
92 | """ |
|
92 | """ | |
93 |
|
93 | |||
94 | Input: |
|
94 | Input: | |
95 | dataOut : |
|
95 | dataOut : | |
96 | id : |
|
96 | id : | |
97 | wintitle : |
|
97 | wintitle : | |
98 | channelList : |
|
98 | channelList : | |
99 | showProfile : |
|
99 | showProfile : | |
100 | xmin : None, |
|
100 | xmin : None, | |
101 | xmax : None, |
|
101 | xmax : None, | |
102 | ymin : None, |
|
102 | ymin : None, | |
103 | ymax : None, |
|
103 | ymax : None, | |
104 | zmin : None, |
|
104 | zmin : None, | |
105 | zmax : None |
|
105 | zmax : None | |
106 | """ |
|
106 | """ | |
107 | if realtime: |
|
107 | if realtime: | |
108 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
108 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
109 | print 'Skipping this plot function' |
|
109 | print 'Skipping this plot function' | |
110 | return |
|
110 | return | |
111 |
|
111 | |||
112 | if channelList == None: |
|
112 | if channelList == None: | |
113 | channelIndexList = dataOut.channelIndexList |
|
113 | channelIndexList = dataOut.channelIndexList | |
114 | else: |
|
114 | else: | |
115 | channelIndexList = [] |
|
115 | channelIndexList = [] | |
116 | for channel in channelList: |
|
116 | for channel in channelList: | |
117 | if channel not in dataOut.channelList: |
|
117 | if channel not in dataOut.channelList: | |
118 | raise ValueError, "Channel %d is not in dataOut.channelList" %channel |
|
118 | raise ValueError, "Channel %d is not in dataOut.channelList" %channel | |
119 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
119 | channelIndexList.append(dataOut.channelList.index(channel)) | |
120 |
|
120 | |||
121 | if normFactor is None: |
|
121 | if normFactor is None: | |
122 | factor = dataOut.normFactor |
|
122 | factor = dataOut.normFactor | |
123 | else: |
|
123 | else: | |
124 | factor = normFactor |
|
124 | factor = normFactor | |
125 | if xaxis == "frequency": |
|
125 | if xaxis == "frequency": | |
126 | x = dataOut.getFreqRange(1)/1000. |
|
126 | x = dataOut.getFreqRange(1)/1000. | |
127 | xlabel = "Frequency (kHz)" |
|
127 | xlabel = "Frequency (kHz)" | |
128 |
|
128 | |||
129 | elif xaxis == "time": |
|
129 | elif xaxis == "time": | |
130 | x = dataOut.getAcfRange(1) |
|
130 | x = dataOut.getAcfRange(1) | |
131 | xlabel = "Time (ms)" |
|
131 | xlabel = "Time (ms)" | |
132 |
|
132 | |||
133 | else: |
|
133 | else: | |
134 | x = dataOut.getVelRange(1) |
|
134 | x = dataOut.getVelRange(1) | |
135 | xlabel = "Velocity (m/s)" |
|
135 | xlabel = "Velocity (m/s)" | |
136 |
|
136 | |||
137 | ylabel = "Range (Km)" |
|
137 | ylabel = "Range (Km)" | |
138 |
|
138 | |||
139 | y = dataOut.getHeiRange() |
|
139 | y = dataOut.getHeiRange() | |
140 |
|
140 | |||
141 | z = dataOut.data_spc/factor |
|
141 | z = dataOut.data_spc/factor | |
142 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
142 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
143 | zdB = 10*numpy.log10(z) |
|
143 | zdB = 10*numpy.log10(z) | |
144 |
|
144 | |||
145 | #print "a000",dataOut.data_spc.dtype |
|
145 | #print "a000",dataOut.data_spc.dtype | |
146 | avg = numpy.average(z, axis=1) |
|
146 | avg = numpy.average(z, axis=1) | |
147 | avgdB = 10*numpy.log10(avg) |
|
147 | avgdB = 10*numpy.log10(avg) | |
148 | #print "before plot" |
|
148 | #print "before plot" | |
149 | noise = dataOut.getNoise()/factor |
|
149 | noise = dataOut.getNoise()/factor | |
150 | noisedB = 10*numpy.log10(noise) |
|
150 | noisedB = 10*numpy.log10(noise) | |
151 |
|
151 | |||
152 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
152 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
153 | title = wintitle + " Spectra" |
|
153 | title = wintitle + " Spectra" | |
154 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
154 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
155 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
155 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
156 |
|
156 | |||
157 | if not self.isConfig: |
|
157 | if not self.isConfig: | |
158 |
|
158 | |||
159 | nplots = len(channelIndexList) |
|
159 | nplots = len(channelIndexList) | |
160 |
|
160 | |||
161 | self.setup(id=id, |
|
161 | self.setup(id=id, | |
162 | nplots=nplots, |
|
162 | nplots=nplots, | |
163 | wintitle=wintitle, |
|
163 | wintitle=wintitle, | |
164 | showprofile=showprofile, |
|
164 | showprofile=showprofile, | |
165 | show=show) |
|
165 | show=show) | |
166 |
|
166 | |||
167 | if xmin == None: xmin = numpy.nanmin(x) |
|
167 | if xmin == None: xmin = numpy.nanmin(x) | |
168 | if xmax == None: xmax = numpy.nanmax(x) |
|
168 | if xmax == None: xmax = numpy.nanmax(x) | |
169 | if ymin == None: ymin = numpy.nanmin(y) |
|
169 | if ymin == None: ymin = numpy.nanmin(y) | |
170 | if ymax == None: ymax = numpy.nanmax(y) |
|
170 | if ymax == None: ymax = numpy.nanmax(y) | |
171 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 |
|
171 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 | |
172 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 |
|
172 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 | |
173 |
|
173 | |||
174 | self.FTP_WEI = ftp_wei |
|
174 | self.FTP_WEI = ftp_wei | |
175 | self.EXP_CODE = exp_code |
|
175 | self.EXP_CODE = exp_code | |
176 | self.SUB_EXP_CODE = sub_exp_code |
|
176 | self.SUB_EXP_CODE = sub_exp_code | |
177 | self.PLOT_POS = plot_pos |
|
177 | self.PLOT_POS = plot_pos | |
178 |
|
178 | |||
179 | self.isConfig = True |
|
179 | self.isConfig = True | |
180 |
|
180 | |||
181 | self.setWinTitle(title) |
|
181 | self.setWinTitle(title) | |
182 |
|
182 | |||
183 | for i in range(self.nplots): |
|
183 | for i in range(self.nplots): | |
184 | index = channelIndexList[i] |
|
184 | index = channelIndexList[i] | |
185 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
185 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
186 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime) |
|
186 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime) | |
187 | if len(dataOut.beam.codeList) != 0: |
|
187 | if len(dataOut.beam.codeList) != 0: | |
188 | title = "Ch%d:%4.2fdB,%2.2f,%2.2f:%s" %(dataOut.channelList[index], noisedB[index], dataOut.beam.azimuthList[index], dataOut.beam.zenithList[index], str_datetime) |
|
188 | title = "Ch%d:%4.2fdB,%2.2f,%2.2f:%s" %(dataOut.channelList[index], noisedB[index], dataOut.beam.azimuthList[index], dataOut.beam.zenithList[index], str_datetime) | |
189 |
|
189 | |||
190 | axes = self.axesList[i*self.__nsubplots] |
|
190 | axes = self.axesList[i*self.__nsubplots] | |
191 | axes.pcolor(x, y, zdB[index,:,:], |
|
191 | axes.pcolor(x, y, zdB[index,:,:], | |
192 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
192 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
193 | xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap, |
|
193 | xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap, | |
194 | ticksize=9, cblabel='') |
|
194 | ticksize=9, cblabel='') | |
195 |
|
195 | |||
196 | if self.__showprofile: |
|
196 | if self.__showprofile: | |
197 | axes = self.axesList[i*self.__nsubplots +1] |
|
197 | axes = self.axesList[i*self.__nsubplots +1] | |
198 | axes.pline(avgdB[index,:], y, |
|
198 | axes.pline(avgdB[index,:], y, | |
199 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
199 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
200 | xlabel='dB', ylabel='', title='', |
|
200 | xlabel='dB', ylabel='', title='', | |
201 | ytick_visible=False, |
|
201 | ytick_visible=False, | |
202 | grid='x') |
|
202 | grid='x') | |
203 |
|
203 | |||
204 | noiseline = numpy.repeat(noisedB[index], len(y)) |
|
204 | noiseline = numpy.repeat(noisedB[index], len(y)) | |
205 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
205 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
206 |
|
206 | |||
207 | self.draw() |
|
207 | self.draw() | |
208 |
|
208 | |||
209 | if figfile == None: |
|
209 | if figfile == None: | |
210 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
210 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
211 | name = str_datetime |
|
211 | name = str_datetime | |
212 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
212 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
213 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) |
|
213 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | |
214 | figfile = self.getFilename(name) |
|
214 | figfile = self.getFilename(name) | |
215 |
|
215 | |||
216 | self.save(figpath=figpath, |
|
216 | self.save(figpath=figpath, | |
217 | figfile=figfile, |
|
217 | figfile=figfile, | |
218 | save=save, |
|
218 | save=save, | |
219 | ftp=ftp, |
|
219 | ftp=ftp, | |
220 | wr_period=wr_period, |
|
220 | wr_period=wr_period, | |
221 | thisDatetime=thisDatetime) |
|
221 | thisDatetime=thisDatetime) | |
222 |
|
222 | |||
223 | class ACFPlot(Figure): |
|
223 | class ACFPlot(Figure): | |
224 |
|
224 | |||
225 | isConfig = None |
|
225 | isConfig = None | |
226 | __nsubplots = None |
|
226 | __nsubplots = None | |
227 |
|
227 | |||
228 | WIDTHPROF = None |
|
228 | WIDTHPROF = None | |
229 | HEIGHTPROF = None |
|
229 | HEIGHTPROF = None | |
230 | PREFIX = 'acf' |
|
230 | PREFIX = 'acf' | |
231 |
|
231 | |||
232 | def __init__(self, **kwargs): |
|
232 | def __init__(self, **kwargs): | |
233 | Figure.__init__(self, **kwargs) |
|
233 | Figure.__init__(self, **kwargs) | |
234 | self.isConfig = False |
|
234 | self.isConfig = False | |
235 | self.__nsubplots = 1 |
|
235 | self.__nsubplots = 1 | |
236 |
|
236 | |||
237 | self.PLOT_CODE = ACF_CODE |
|
237 | self.PLOT_CODE = ACF_CODE | |
238 |
|
238 | |||
239 | self.WIDTH = 900 |
|
239 | self.WIDTH = 900 | |
240 | self.HEIGHT = 700 |
|
240 | self.HEIGHT = 700 | |
241 | self.counter_imagwr = 0 |
|
241 | self.counter_imagwr = 0 | |
242 |
|
242 | |||
243 | def getSubplots(self): |
|
243 | def getSubplots(self): | |
244 | ncol = 1 |
|
244 | ncol = 1 | |
245 | nrow = 1 |
|
245 | nrow = 1 | |
246 |
|
246 | |||
247 | return nrow, ncol |
|
247 | return nrow, ncol | |
248 |
|
248 | |||
249 | def setup(self, id, nplots, wintitle, show): |
|
249 | def setup(self, id, nplots, wintitle, show): | |
250 |
|
250 | |||
251 | self.nplots = nplots |
|
251 | self.nplots = nplots | |
252 |
|
252 | |||
253 | ncolspan = 1 |
|
253 | ncolspan = 1 | |
254 | colspan = 1 |
|
254 | colspan = 1 | |
255 |
|
255 | |||
256 | self.createFigure(id = id, |
|
256 | self.createFigure(id = id, | |
257 | wintitle = wintitle, |
|
257 | wintitle = wintitle, | |
258 | widthplot = self.WIDTH, |
|
258 | widthplot = self.WIDTH, | |
259 | heightplot = self.HEIGHT, |
|
259 | heightplot = self.HEIGHT, | |
260 | show=show) |
|
260 | show=show) | |
261 |
|
261 | |||
262 | nrow, ncol = self.getSubplots() |
|
262 | nrow, ncol = self.getSubplots() | |
263 |
|
263 | |||
264 | counter = 0 |
|
264 | counter = 0 | |
265 | for y in range(nrow): |
|
265 | for y in range(nrow): | |
266 | for x in range(ncol): |
|
266 | for x in range(ncol): | |
267 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
267 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
268 |
|
268 | |||
269 | def run(self, dataOut, id, wintitle="", channelList=None,channel=None,nSamples=None, |
|
269 | def run(self, dataOut, id, wintitle="", channelList=None,channel=None,nSamples=None, | |
270 | nSampleList= None,resolutionFactor=None, |
|
270 | nSampleList= None,resolutionFactor=None, | |
271 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
271 | xmin=None, xmax=None, ymin=None, ymax=None, | |
272 | save=False, figpath='./', figfile=None, show=True, |
|
272 | save=False, figpath='./', figfile=None, show=True, | |
273 | ftp=False, wr_period=1, server=None, |
|
273 | ftp=False, wr_period=1, server=None, | |
274 | folder=None, username=None, password=None, |
|
274 | folder=None, username=None, password=None, | |
275 | xaxis="frequency"): |
|
275 | xaxis="frequency"): | |
276 |
|
276 | |||
277 | channel0 = channel |
|
277 | channel0 = channel | |
278 | nSamples = nSamples |
|
278 | nSamples = nSamples | |
279 | resFactor = resolutionFactor |
|
279 | resFactor = resolutionFactor | |
280 |
|
280 | |||
281 | if nSamples == None: |
|
281 | if nSamples == None: | |
282 | nSamples = 20 |
|
282 | nSamples = 20 | |
283 |
|
283 | |||
284 | if resFactor == None: |
|
284 | if resFactor == None: | |
285 | resFactor = 5 |
|
285 | resFactor = 5 | |
286 | #else: |
|
286 | #else: | |
287 | # if nSamples not in dataOut.channelList: |
|
287 | # if nSamples not in dataOut.channelList: | |
288 | # raise ValueError, "Channel %d is not in %s dataOut.channelList"%(channel0, dataOut.channelList) |
|
288 | # raise ValueError, "Channel %d is not in %s dataOut.channelList"%(channel0, dataOut.channelList) | |
289 |
|
289 | |||
290 | if channel0 == None: |
|
290 | if channel0 == None: | |
291 | channel0 = 0 |
|
291 | channel0 = 0 | |
292 | else: |
|
292 | else: | |
293 | if channel0 not in dataOut.channelList: |
|
293 | if channel0 not in dataOut.channelList: | |
294 | raise ValueError, "Channel %d is not in %s dataOut.channelList"%(channel0, dataOut.channelList) |
|
294 | raise ValueError, "Channel %d is not in %s dataOut.channelList"%(channel0, dataOut.channelList) | |
295 |
|
295 | |||
296 | if channelList == None: |
|
296 | if channelList == None: | |
297 | channelIndexList = dataOut.channelIndexList |
|
297 | channelIndexList = dataOut.channelIndexList | |
298 | channelList = dataOut.channelList |
|
298 | channelList = dataOut.channelList | |
299 | else: |
|
299 | else: | |
300 | channelIndexList = [] |
|
300 | channelIndexList = [] | |
301 | for channel in channelList: |
|
301 | for channel in channelList: | |
302 | if channel not in dataOut.channelList: |
|
302 | if channel not in dataOut.channelList: | |
303 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
303 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
304 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
304 | channelIndexList.append(dataOut.channelList.index(channel)) | |
305 |
|
305 | |||
306 | #z = dataOut.data_spc/factor |
|
306 | #z = dataOut.data_spc/factor | |
307 | factor = dataOut.normFactor |
|
307 | factor = dataOut.normFactor | |
308 | y = dataOut.getHeiRange() |
|
308 | y = dataOut.getHeiRange() | |
309 | deltaHeight = dataOut.heightList[1]-dataOut.heightList[0] |
|
309 | deltaHeight = dataOut.heightList[1]-dataOut.heightList[0] | |
310 | z = dataOut.data_acf |
|
310 | z = dataOut.data_acf | |
311 |
|
311 | |||
312 | #import matplotlib.pyplot as plt |
|
312 | #import matplotlib.pyplot as plt | |
313 | #plt.plot(z[0,:,85]) |
|
313 | #plt.plot(z[0,:,85]) | |
314 | #plt.show() |
|
314 | #plt.show() | |
315 | #import time |
|
315 | #import time | |
316 | #time.sleep(20) |
|
316 | #time.sleep(20) | |
317 |
|
317 | |||
318 |
|
318 | |||
319 | #z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
319 | #z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
320 | shape = dataOut.data_acf.shape |
|
320 | shape = dataOut.data_acf.shape | |
321 | print "shape_plot",shape |
|
321 | #print "shape_plot",shape | |
322 | hei_index = numpy.arange(shape[2]) |
|
322 | hei_index = numpy.arange(shape[2]) | |
323 | hei_plot = numpy.arange(nSamples)*resFactor |
|
323 | hei_plot = numpy.arange(nSamples)*resFactor | |
324 |
|
324 | |||
325 | if nSampleList is not None: |
|
325 | if nSampleList is not None: | |
326 | for nsample in nSampleList: |
|
326 | for nsample in nSampleList: | |
327 | if nsample not in dataOut.heightList/deltaHeight: |
|
327 | if nsample not in dataOut.heightList/deltaHeight: | |
328 | raise ValueError, "nsample %d is not in %s dataOut.heightList"%(nsample,dataOut.heightList) |
|
328 | raise ValueError, "nsample %d is not in %s dataOut.heightList"%(nsample,dataOut.heightList) | |
329 |
|
329 | |||
330 | if nSampleList is not None: |
|
330 | if nSampleList is not None: | |
331 | hei_plot = numpy.array(nSampleList)*resFactor |
|
331 | hei_plot = numpy.array(nSampleList)*resFactor | |
332 |
|
332 | |||
333 | if hei_plot[-1] >= hei_index[-1]: |
|
333 | if hei_plot[-1] >= hei_index[-1]: | |
334 | print ("La cantidad de puntos en altura es %d y la resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) |
|
334 | print ("La cantidad de puntos en altura es %d y la resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) | |
335 | raise ValueError, "resFactor %d multiplicado por el valor de %d nSamples es mayor a %d cantidad total de puntos"%(resFactor,nSamples,hei_index[-1]) |
|
335 | raise ValueError, "resFactor %d multiplicado por el valor de %d nSamples es mayor a %d cantidad total de puntos"%(resFactor,nSamples,hei_index[-1]) | |
336 |
|
336 | |||
337 | #escalamiento -1 a 1 a resolucion (factor de resolucion en altura)* deltaHeight |
|
337 | #escalamiento -1 a 1 a resolucion (factor de resolucion en altura)* deltaHeight | |
338 | min = numpy.min(z[0,:,0]) |
|
338 | min = numpy.min(z[0,:,0]) | |
339 | max =numpy.max(z[0,:,0]) |
|
339 | max =numpy.max(z[0,:,0]) | |
340 | for i in range(shape[0]): |
|
340 | for i in range(shape[0]): | |
341 | for j in range(shape[2]): |
|
341 | for j in range(shape[2]): | |
342 | z[i,:,j]= (((z[i,:,j]-min)/(max-min))*deltaHeight*resFactor + j*deltaHeight) |
|
342 | z[i,:,j]= (((z[i,:,j]-min)/(max-min))*deltaHeight*resFactor + j*deltaHeight) | |
343 |
|
343 | |||
344 | if xaxis == "frequency": |
|
344 | if xaxis == "frequency": | |
345 | x = dataOut.getFreqRange()/1000. |
|
345 | x = dataOut.getFreqRange()/1000. | |
346 | zdB = 10*numpy.log10(z[channel0,:,hei_plot]) |
|
346 | zdB = 10*numpy.log10(z[channel0,:,hei_plot]) | |
347 | xlabel = "Frequency (kHz)" |
|
347 | xlabel = "Frequency (kHz)" | |
348 | ylabel = "Power (dB)" |
|
348 | ylabel = "Power (dB)" | |
349 |
|
349 | |||
350 | elif xaxis == "time": |
|
350 | elif xaxis == "time": | |
351 | delta= dataOut.getAcfRange()[1]-dataOut.getAcfRange()[0] |
|
351 | #delta= dataOut.getAcfRange()[1]-dataOut.getAcfRange()[0] | |
352 | x = dataOut.getAcfRange()+delta/2.0 |
|
352 | #x = dataOut.getAcfRange()+delta/2.0 | |
|
353 | x = dataOut.getAcfRange()*1000 | |||
353 | zdB = z[channel0,:,hei_plot] |
|
354 | zdB = z[channel0,:,hei_plot] | |
354 | xlabel = "Time (ms)" |
|
355 | xlabel = "Time (ms)" | |
355 | ylabel = "ACF" |
|
356 | ylabel = "ACF" | |
356 |
|
357 | |||
357 | else: |
|
358 | else: | |
358 | x = dataOut.getVelRange() |
|
359 | x = dataOut.getVelRange() | |
359 | zdB = 10*numpy.log10(z[channel0,:,hei_plot]) |
|
360 | zdB = 10*numpy.log10(z[channel0,:,hei_plot]) | |
360 | xlabel = "Velocity (m/s)" |
|
361 | xlabel = "Velocity (m/s)" | |
361 | ylabel = "Power (dB)" |
|
362 | ylabel = "Power (dB)" | |
362 |
|
363 | |||
363 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
364 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
364 | title = wintitle + " ACF Plot Ch %s %s" %(channel0,thisDatetime.strftime("%d-%b-%Y")) |
|
365 | title = wintitle + " ACF Plot Ch %s %s" %(channel0,thisDatetime.strftime("%d-%b-%Y")) | |
365 |
|
366 | |||
366 | if not self.isConfig: |
|
367 | if not self.isConfig: | |
367 |
|
368 | |||
368 | nplots = 1 |
|
369 | nplots = 1 | |
369 |
|
370 | |||
370 | self.setup(id=id, |
|
371 | self.setup(id=id, | |
371 | nplots=nplots, |
|
372 | nplots=nplots, | |
372 | wintitle=wintitle, |
|
373 | wintitle=wintitle, | |
373 | show=show) |
|
374 | show=show) | |
374 |
|
375 | |||
375 | if xmin == None: xmin = numpy.nanmin(x)*0.9 |
|
376 | if xmin == None: xmin = numpy.nanmin(x)#*0.9 | |
376 | if xmax == None: xmax = numpy.nanmax(x)*1.1 |
|
377 | if xmax == None: xmax = numpy.nanmax(x)#*1.1 | |
377 | if ymin == None: ymin = numpy.nanmin(zdB) |
|
378 | if ymin == None: ymin = numpy.nanmin(zdB) | |
378 | if ymax == None: ymax = numpy.nanmax(zdB) |
|
379 | if ymax == None: ymax = numpy.nanmax(zdB) | |
379 |
|
380 | |||
380 | print ("El parametro resFactor es %d y la resolucion en altura es %f"%(resFactor,deltaHeight )) |
|
381 | print ("El parametro resFactor es %d y la resolucion en altura es %f"%(resFactor,deltaHeight )) | |
381 | print ("La cantidad de puntos en altura es %d y la nueva resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) |
|
382 | print ("La cantidad de puntos en altura es %d y la nueva resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) | |
382 | print ("La altura maxima es %d Km"%(hei_plot[-1]*deltaHeight )) |
|
383 | print ("La altura maxima es %d Km"%(hei_plot[-1]*deltaHeight )) | |
383 |
|
384 | |||
384 | self.isConfig = True |
|
385 | self.isConfig = True | |
385 |
|
386 | |||
386 | self.setWinTitle(title) |
|
387 | self.setWinTitle(title) | |
387 |
|
388 | |||
388 | title = "ACF Plot: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
389 | title = "ACF Plot: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
389 | axes = self.axesList[0] |
|
390 | axes = self.axesList[0] | |
390 |
|
391 | |||
391 | legendlabels = ["Range = %dKm" %y[i] for i in hei_plot] |
|
392 | legendlabels = ["Range = %dKm" %y[i] for i in hei_plot] | |
392 |
|
393 | |||
393 | axes.pmultilineyaxis( x, zdB, |
|
394 | axes.pmultilineyaxis( x, zdB, | |
394 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
395 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
395 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
396 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
396 | ytick_visible=True, nxticks=5, |
|
397 | ytick_visible=True, nxticks=5, | |
397 | grid='x') |
|
398 | grid='x') | |
398 |
|
399 | |||
399 | self.draw() |
|
400 | self.draw() | |
400 |
|
401 | |||
401 | if figfile == None: |
|
402 | if figfile == None: | |
402 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
403 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
403 | name = str_datetime |
|
404 | name = str_datetime | |
404 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
405 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
405 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) |
|
406 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | |
406 | figfile = self.getFilename(name) |
|
407 | figfile = self.getFilename(name) | |
407 |
|
408 | |||
408 | self.save(figpath=figpath, |
|
409 | self.save(figpath=figpath, | |
409 | figfile=figfile, |
|
410 | figfile=figfile, | |
410 | save=save, |
|
411 | save=save, | |
411 | ftp=ftp, |
|
412 | ftp=ftp, | |
412 | wr_period=wr_period, |
|
413 | wr_period=wr_period, | |
413 | thisDatetime=thisDatetime) |
|
414 | thisDatetime=thisDatetime) | |
414 |
|
415 | |||
415 |
|
416 | |||
416 |
|
417 | |||
417 | class CrossSpectraPlot(Figure): |
|
418 | class CrossSpectraPlot(Figure): | |
418 |
|
419 | |||
419 | isConfig = None |
|
420 | isConfig = None | |
420 | __nsubplots = None |
|
421 | __nsubplots = None | |
421 |
|
422 | |||
422 | WIDTH = None |
|
423 | WIDTH = None | |
423 | HEIGHT = None |
|
424 | HEIGHT = None | |
424 | WIDTHPROF = None |
|
425 | WIDTHPROF = None | |
425 | HEIGHTPROF = None |
|
426 | HEIGHTPROF = None | |
426 | PREFIX = 'cspc' |
|
427 | PREFIX = 'cspc' | |
427 |
|
428 | |||
428 | def __init__(self, **kwargs): |
|
429 | def __init__(self, **kwargs): | |
429 | Figure.__init__(self, **kwargs) |
|
430 | Figure.__init__(self, **kwargs) | |
430 | self.isConfig = False |
|
431 | self.isConfig = False | |
431 | self.__nsubplots = 4 |
|
432 | self.__nsubplots = 4 | |
432 | self.counter_imagwr = 0 |
|
433 | self.counter_imagwr = 0 | |
433 | self.WIDTH = 250 |
|
434 | self.WIDTH = 250 | |
434 | self.HEIGHT = 250 |
|
435 | self.HEIGHT = 250 | |
435 | self.WIDTHPROF = 0 |
|
436 | self.WIDTHPROF = 0 | |
436 | self.HEIGHTPROF = 0 |
|
437 | self.HEIGHTPROF = 0 | |
437 |
|
438 | |||
438 | self.PLOT_CODE = CROSS_CODE |
|
439 | self.PLOT_CODE = CROSS_CODE | |
439 | self.FTP_WEI = None |
|
440 | self.FTP_WEI = None | |
440 | self.EXP_CODE = None |
|
441 | self.EXP_CODE = None | |
441 | self.SUB_EXP_CODE = None |
|
442 | self.SUB_EXP_CODE = None | |
442 | self.PLOT_POS = None |
|
443 | self.PLOT_POS = None | |
443 |
|
444 | |||
444 | def getSubplots(self): |
|
445 | def getSubplots(self): | |
445 |
|
446 | |||
446 | ncol = 4 |
|
447 | ncol = 4 | |
447 | nrow = self.nplots |
|
448 | nrow = self.nplots | |
448 |
|
449 | |||
449 | return nrow, ncol |
|
450 | return nrow, ncol | |
450 |
|
451 | |||
451 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
452 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
452 |
|
453 | |||
453 | self.__showprofile = showprofile |
|
454 | self.__showprofile = showprofile | |
454 | self.nplots = nplots |
|
455 | self.nplots = nplots | |
455 |
|
456 | |||
456 | ncolspan = 1 |
|
457 | ncolspan = 1 | |
457 | colspan = 1 |
|
458 | colspan = 1 | |
458 |
|
459 | |||
459 | self.createFigure(id = id, |
|
460 | self.createFigure(id = id, | |
460 | wintitle = wintitle, |
|
461 | wintitle = wintitle, | |
461 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
462 | widthplot = self.WIDTH + self.WIDTHPROF, | |
462 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
463 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
463 | show=True) |
|
464 | show=True) | |
464 |
|
465 | |||
465 | nrow, ncol = self.getSubplots() |
|
466 | nrow, ncol = self.getSubplots() | |
466 |
|
467 | |||
467 | counter = 0 |
|
468 | counter = 0 | |
468 | for y in range(nrow): |
|
469 | for y in range(nrow): | |
469 | for x in range(ncol): |
|
470 | for x in range(ncol): | |
470 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
471 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
471 |
|
472 | |||
472 | counter += 1 |
|
473 | counter += 1 | |
473 |
|
474 | |||
474 | def run(self, dataOut, id, wintitle="", pairsList=None, |
|
475 | def run(self, dataOut, id, wintitle="", pairsList=None, | |
475 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
476 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
476 | coh_min=None, coh_max=None, phase_min=None, phase_max=None, |
|
477 | coh_min=None, coh_max=None, phase_min=None, phase_max=None, | |
477 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, |
|
478 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, | |
478 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True, |
|
479 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True, | |
479 | server=None, folder=None, username=None, password=None, |
|
480 | server=None, folder=None, username=None, password=None, | |
480 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, normFactor=None, |
|
481 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, normFactor=None, | |
481 | xaxis='frequency'): |
|
482 | xaxis='frequency'): | |
482 |
|
483 | |||
483 | """ |
|
484 | """ | |
484 |
|
485 | |||
485 | Input: |
|
486 | Input: | |
486 | dataOut : |
|
487 | dataOut : | |
487 | id : |
|
488 | id : | |
488 | wintitle : |
|
489 | wintitle : | |
489 | channelList : |
|
490 | channelList : | |
490 | showProfile : |
|
491 | showProfile : | |
491 | xmin : None, |
|
492 | xmin : None, | |
492 | xmax : None, |
|
493 | xmax : None, | |
493 | ymin : None, |
|
494 | ymin : None, | |
494 | ymax : None, |
|
495 | ymax : None, | |
495 | zmin : None, |
|
496 | zmin : None, | |
496 | zmax : None |
|
497 | zmax : None | |
497 | """ |
|
498 | """ | |
498 |
|
499 | |||
499 | if pairsList == None: |
|
500 | if pairsList == None: | |
500 | pairsIndexList = dataOut.pairsIndexList |
|
501 | pairsIndexList = dataOut.pairsIndexList | |
501 | else: |
|
502 | else: | |
502 | pairsIndexList = [] |
|
503 | pairsIndexList = [] | |
503 | for pair in pairsList: |
|
504 | for pair in pairsList: | |
504 | if pair not in dataOut.pairsList: |
|
505 | if pair not in dataOut.pairsList: | |
505 | raise ValueError, "Pair %s is not in dataOut.pairsList" %str(pair) |
|
506 | raise ValueError, "Pair %s is not in dataOut.pairsList" %str(pair) | |
506 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
507 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
507 |
|
508 | |||
508 | if not pairsIndexList: |
|
509 | if not pairsIndexList: | |
509 | return |
|
510 | return | |
510 |
|
511 | |||
511 | if len(pairsIndexList) > 4: |
|
512 | if len(pairsIndexList) > 4: | |
512 | pairsIndexList = pairsIndexList[0:4] |
|
513 | pairsIndexList = pairsIndexList[0:4] | |
513 |
|
514 | |||
514 | if normFactor is None: |
|
515 | if normFactor is None: | |
515 | factor = dataOut.normFactor |
|
516 | factor = dataOut.normFactor | |
516 | else: |
|
517 | else: | |
517 | factor = normFactor |
|
518 | factor = normFactor | |
518 | x = dataOut.getVelRange(1) |
|
519 | x = dataOut.getVelRange(1) | |
519 | y = dataOut.getHeiRange() |
|
520 | y = dataOut.getHeiRange() | |
520 | z = dataOut.data_spc[:,:,:]/factor |
|
521 | z = dataOut.data_spc[:,:,:]/factor | |
521 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
522 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
522 |
|
523 | |||
523 | noise = dataOut.noise/factor |
|
524 | noise = dataOut.noise/factor | |
524 |
|
525 | |||
525 | zdB = 10*numpy.log10(z) |
|
526 | zdB = 10*numpy.log10(z) | |
526 | noisedB = 10*numpy.log10(noise) |
|
527 | noisedB = 10*numpy.log10(noise) | |
527 |
|
528 | |||
528 | if coh_min == None: |
|
529 | if coh_min == None: | |
529 | coh_min = 0.0 |
|
530 | coh_min = 0.0 | |
530 | if coh_max == None: |
|
531 | if coh_max == None: | |
531 | coh_max = 1.0 |
|
532 | coh_max = 1.0 | |
532 |
|
533 | |||
533 | if phase_min == None: |
|
534 | if phase_min == None: | |
534 | phase_min = -180 |
|
535 | phase_min = -180 | |
535 | if phase_max == None: |
|
536 | if phase_max == None: | |
536 | phase_max = 180 |
|
537 | phase_max = 180 | |
537 |
|
538 | |||
538 | #thisDatetime = dataOut.datatime |
|
539 | #thisDatetime = dataOut.datatime | |
539 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
540 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
540 | title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
541 | title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
541 | # xlabel = "Velocity (m/s)" |
|
542 | # xlabel = "Velocity (m/s)" | |
542 | ylabel = "Range (Km)" |
|
543 | ylabel = "Range (Km)" | |
543 |
|
544 | |||
544 | if xaxis == "frequency": |
|
545 | if xaxis == "frequency": | |
545 | x = dataOut.getFreqRange(1)/1000. |
|
546 | x = dataOut.getFreqRange(1)/1000. | |
546 | xlabel = "Frequency (kHz)" |
|
547 | xlabel = "Frequency (kHz)" | |
547 |
|
548 | |||
548 | elif xaxis == "time": |
|
549 | elif xaxis == "time": | |
549 | x = dataOut.getAcfRange(1) |
|
550 | x = dataOut.getAcfRange(1) | |
550 | xlabel = "Time (ms)" |
|
551 | xlabel = "Time (ms)" | |
551 |
|
552 | |||
552 | else: |
|
553 | else: | |
553 | x = dataOut.getVelRange(1) |
|
554 | x = dataOut.getVelRange(1) | |
554 | xlabel = "Velocity (m/s)" |
|
555 | xlabel = "Velocity (m/s)" | |
555 |
|
556 | |||
556 | if not self.isConfig: |
|
557 | if not self.isConfig: | |
557 |
|
558 | |||
558 | nplots = len(pairsIndexList) |
|
559 | nplots = len(pairsIndexList) | |
559 |
|
560 | |||
560 | self.setup(id=id, |
|
561 | self.setup(id=id, | |
561 | nplots=nplots, |
|
562 | nplots=nplots, | |
562 | wintitle=wintitle, |
|
563 | wintitle=wintitle, | |
563 | showprofile=False, |
|
564 | showprofile=False, | |
564 | show=show) |
|
565 | show=show) | |
565 |
|
566 | |||
566 | avg = numpy.abs(numpy.average(z, axis=1)) |
|
567 | avg = numpy.abs(numpy.average(z, axis=1)) | |
567 | avgdB = 10*numpy.log10(avg) |
|
568 | avgdB = 10*numpy.log10(avg) | |
568 |
|
569 | |||
569 | if xmin == None: xmin = numpy.nanmin(x) |
|
570 | if xmin == None: xmin = numpy.nanmin(x) | |
570 | if xmax == None: xmax = numpy.nanmax(x) |
|
571 | if xmax == None: xmax = numpy.nanmax(x) | |
571 | if ymin == None: ymin = numpy.nanmin(y) |
|
572 | if ymin == None: ymin = numpy.nanmin(y) | |
572 | if ymax == None: ymax = numpy.nanmax(y) |
|
573 | if ymax == None: ymax = numpy.nanmax(y) | |
573 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 |
|
574 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 | |
574 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 |
|
575 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 | |
575 |
|
576 | |||
576 | self.FTP_WEI = ftp_wei |
|
577 | self.FTP_WEI = ftp_wei | |
577 | self.EXP_CODE = exp_code |
|
578 | self.EXP_CODE = exp_code | |
578 | self.SUB_EXP_CODE = sub_exp_code |
|
579 | self.SUB_EXP_CODE = sub_exp_code | |
579 | self.PLOT_POS = plot_pos |
|
580 | self.PLOT_POS = plot_pos | |
580 |
|
581 | |||
581 | self.isConfig = True |
|
582 | self.isConfig = True | |
582 |
|
583 | |||
583 | self.setWinTitle(title) |
|
584 | self.setWinTitle(title) | |
584 |
|
585 | |||
585 | for i in range(self.nplots): |
|
586 | for i in range(self.nplots): | |
586 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
587 | pair = dataOut.pairsList[pairsIndexList[i]] | |
587 |
|
588 | |||
588 | chan_index0 = dataOut.channelList.index(pair[0]) |
|
589 | chan_index0 = dataOut.channelList.index(pair[0]) | |
589 | chan_index1 = dataOut.channelList.index(pair[1]) |
|
590 | chan_index1 = dataOut.channelList.index(pair[1]) | |
590 |
|
591 | |||
591 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
592 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
592 | title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[chan_index0], str_datetime) |
|
593 | title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[chan_index0], str_datetime) | |
593 | zdB = 10.*numpy.log10(dataOut.data_spc[chan_index0,:,:]/factor) |
|
594 | zdB = 10.*numpy.log10(dataOut.data_spc[chan_index0,:,:]/factor) | |
594 | axes0 = self.axesList[i*self.__nsubplots] |
|
595 | axes0 = self.axesList[i*self.__nsubplots] | |
595 | axes0.pcolor(x, y, zdB, |
|
596 | axes0.pcolor(x, y, zdB, | |
596 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
597 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
597 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
598 | xlabel=xlabel, ylabel=ylabel, title=title, | |
598 | ticksize=9, colormap=power_cmap, cblabel='') |
|
599 | ticksize=9, colormap=power_cmap, cblabel='') | |
599 |
|
600 | |||
600 | title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[chan_index1], str_datetime) |
|
601 | title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[chan_index1], str_datetime) | |
601 | zdB = 10.*numpy.log10(dataOut.data_spc[chan_index1,:,:]/factor) |
|
602 | zdB = 10.*numpy.log10(dataOut.data_spc[chan_index1,:,:]/factor) | |
602 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
603 | axes0 = self.axesList[i*self.__nsubplots+1] | |
603 | axes0.pcolor(x, y, zdB, |
|
604 | axes0.pcolor(x, y, zdB, | |
604 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
605 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
605 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
606 | xlabel=xlabel, ylabel=ylabel, title=title, | |
606 | ticksize=9, colormap=power_cmap, cblabel='') |
|
607 | ticksize=9, colormap=power_cmap, cblabel='') | |
607 |
|
608 | |||
608 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[chan_index0,:,:]*dataOut.data_spc[chan_index1,:,:]) |
|
609 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[chan_index0,:,:]*dataOut.data_spc[chan_index1,:,:]) | |
609 | coherence = numpy.abs(coherenceComplex) |
|
610 | coherence = numpy.abs(coherenceComplex) | |
610 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
611 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
611 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi |
|
612 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi | |
612 |
|
613 | |||
613 | title = "Coherence Ch%d * Ch%d" %(pair[0], pair[1]) |
|
614 | title = "Coherence Ch%d * Ch%d" %(pair[0], pair[1]) | |
614 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
615 | axes0 = self.axesList[i*self.__nsubplots+2] | |
615 | axes0.pcolor(x, y, coherence, |
|
616 | axes0.pcolor(x, y, coherence, | |
616 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=coh_min, zmax=coh_max, |
|
617 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=coh_min, zmax=coh_max, | |
617 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
618 | xlabel=xlabel, ylabel=ylabel, title=title, | |
618 | ticksize=9, colormap=coherence_cmap, cblabel='') |
|
619 | ticksize=9, colormap=coherence_cmap, cblabel='') | |
619 |
|
620 | |||
620 | title = "Phase Ch%d * Ch%d" %(pair[0], pair[1]) |
|
621 | title = "Phase Ch%d * Ch%d" %(pair[0], pair[1]) | |
621 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
622 | axes0 = self.axesList[i*self.__nsubplots+3] | |
622 | axes0.pcolor(x, y, phase, |
|
623 | axes0.pcolor(x, y, phase, | |
623 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max, |
|
624 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max, | |
624 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
625 | xlabel=xlabel, ylabel=ylabel, title=title, | |
625 | ticksize=9, colormap=phase_cmap, cblabel='') |
|
626 | ticksize=9, colormap=phase_cmap, cblabel='') | |
626 |
|
627 | |||
627 |
|
628 | |||
628 |
|
629 | |||
629 | self.draw() |
|
630 | self.draw() | |
630 |
|
631 | |||
631 | self.save(figpath=figpath, |
|
632 | self.save(figpath=figpath, | |
632 | figfile=figfile, |
|
633 | figfile=figfile, | |
633 | save=save, |
|
634 | save=save, | |
634 | ftp=ftp, |
|
635 | ftp=ftp, | |
635 | wr_period=wr_period, |
|
636 | wr_period=wr_period, | |
636 | thisDatetime=thisDatetime) |
|
637 | thisDatetime=thisDatetime) | |
637 |
|
638 | |||
638 |
|
639 | |||
639 | class RTIPlot(Figure): |
|
640 | class RTIPlot(Figure): | |
640 |
|
641 | |||
641 | __isConfig = None |
|
642 | __isConfig = None | |
642 | __nsubplots = None |
|
643 | __nsubplots = None | |
643 |
|
644 | |||
644 | WIDTHPROF = None |
|
645 | WIDTHPROF = None | |
645 | HEIGHTPROF = None |
|
646 | HEIGHTPROF = None | |
646 | PREFIX = 'rti' |
|
647 | PREFIX = 'rti' | |
647 |
|
648 | |||
648 | def __init__(self, **kwargs): |
|
649 | def __init__(self, **kwargs): | |
649 |
|
650 | |||
650 | Figure.__init__(self, **kwargs) |
|
651 | Figure.__init__(self, **kwargs) | |
651 | self.timerange = None |
|
652 | self.timerange = None | |
652 | self.isConfig = False |
|
653 | self.isConfig = False | |
653 | self.__nsubplots = 1 |
|
654 | self.__nsubplots = 1 | |
654 |
|
655 | |||
655 | self.WIDTH = 800 |
|
656 | self.WIDTH = 800 | |
656 | self.HEIGHT = 180 |
|
657 | self.HEIGHT = 180 | |
657 | self.WIDTHPROF = 120 |
|
658 | self.WIDTHPROF = 120 | |
658 | self.HEIGHTPROF = 0 |
|
659 | self.HEIGHTPROF = 0 | |
659 | self.counter_imagwr = 0 |
|
660 | self.counter_imagwr = 0 | |
660 |
|
661 | |||
661 | self.PLOT_CODE = RTI_CODE |
|
662 | self.PLOT_CODE = RTI_CODE | |
662 |
|
663 | |||
663 | self.FTP_WEI = None |
|
664 | self.FTP_WEI = None | |
664 | self.EXP_CODE = None |
|
665 | self.EXP_CODE = None | |
665 | self.SUB_EXP_CODE = None |
|
666 | self.SUB_EXP_CODE = None | |
666 | self.PLOT_POS = None |
|
667 | self.PLOT_POS = None | |
667 | self.tmin = None |
|
668 | self.tmin = None | |
668 | self.tmax = None |
|
669 | self.tmax = None | |
669 |
|
670 | |||
670 | self.xmin = None |
|
671 | self.xmin = None | |
671 | self.xmax = None |
|
672 | self.xmax = None | |
672 |
|
673 | |||
673 | self.figfile = None |
|
674 | self.figfile = None | |
674 |
|
675 | |||
675 | def getSubplots(self): |
|
676 | def getSubplots(self): | |
676 |
|
677 | |||
677 | ncol = 1 |
|
678 | ncol = 1 | |
678 | nrow = self.nplots |
|
679 | nrow = self.nplots | |
679 |
|
680 | |||
680 | return nrow, ncol |
|
681 | return nrow, ncol | |
681 |
|
682 | |||
682 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
683 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
683 |
|
684 | |||
684 | self.__showprofile = showprofile |
|
685 | self.__showprofile = showprofile | |
685 | self.nplots = nplots |
|
686 | self.nplots = nplots | |
686 |
|
687 | |||
687 | ncolspan = 1 |
|
688 | ncolspan = 1 | |
688 | colspan = 1 |
|
689 | colspan = 1 | |
689 | if showprofile: |
|
690 | if showprofile: | |
690 | ncolspan = 7 |
|
691 | ncolspan = 7 | |
691 | colspan = 6 |
|
692 | colspan = 6 | |
692 | self.__nsubplots = 2 |
|
693 | self.__nsubplots = 2 | |
693 |
|
694 | |||
694 | self.createFigure(id = id, |
|
695 | self.createFigure(id = id, | |
695 | wintitle = wintitle, |
|
696 | wintitle = wintitle, | |
696 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
697 | widthplot = self.WIDTH + self.WIDTHPROF, | |
697 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
698 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
698 | show=show) |
|
699 | show=show) | |
699 |
|
700 | |||
700 | nrow, ncol = self.getSubplots() |
|
701 | nrow, ncol = self.getSubplots() | |
701 |
|
702 | |||
702 | counter = 0 |
|
703 | counter = 0 | |
703 | for y in range(nrow): |
|
704 | for y in range(nrow): | |
704 | for x in range(ncol): |
|
705 | for x in range(ncol): | |
705 |
|
706 | |||
706 | if counter >= self.nplots: |
|
707 | if counter >= self.nplots: | |
707 | break |
|
708 | break | |
708 |
|
709 | |||
709 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
710 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
710 |
|
711 | |||
711 | if showprofile: |
|
712 | if showprofile: | |
712 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
713 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
713 |
|
714 | |||
714 | counter += 1 |
|
715 | counter += 1 | |
715 |
|
716 | |||
716 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', |
|
717 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
717 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
718 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
718 | timerange=None, colormap='jet', |
|
719 | timerange=None, colormap='jet', | |
719 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
720 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
720 | server=None, folder=None, username=None, password=None, |
|
721 | server=None, folder=None, username=None, password=None, | |
721 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, normFactor=None, HEIGHT=None): |
|
722 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, normFactor=None, HEIGHT=None): | |
722 |
|
723 | |||
723 | """ |
|
724 | """ | |
724 |
|
725 | |||
725 | Input: |
|
726 | Input: | |
726 | dataOut : |
|
727 | dataOut : | |
727 | id : |
|
728 | id : | |
728 | wintitle : |
|
729 | wintitle : | |
729 | channelList : |
|
730 | channelList : | |
730 | showProfile : |
|
731 | showProfile : | |
731 | xmin : None, |
|
732 | xmin : None, | |
732 | xmax : None, |
|
733 | xmax : None, | |
733 | ymin : None, |
|
734 | ymin : None, | |
734 | ymax : None, |
|
735 | ymax : None, | |
735 | zmin : None, |
|
736 | zmin : None, | |
736 | zmax : None |
|
737 | zmax : None | |
737 | """ |
|
738 | """ | |
738 |
|
739 | |||
739 | #colormap = kwargs.get('colormap', 'jet') |
|
740 | #colormap = kwargs.get('colormap', 'jet') | |
740 | if HEIGHT is not None: |
|
741 | if HEIGHT is not None: | |
741 | self.HEIGHT = HEIGHT |
|
742 | self.HEIGHT = HEIGHT | |
742 |
|
743 | |||
743 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
744 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
744 | return |
|
745 | return | |
745 |
|
746 | |||
746 | if channelList == None: |
|
747 | if channelList == None: | |
747 | channelIndexList = dataOut.channelIndexList |
|
748 | channelIndexList = dataOut.channelIndexList | |
748 | else: |
|
749 | else: | |
749 | channelIndexList = [] |
|
750 | channelIndexList = [] | |
750 | for channel in channelList: |
|
751 | for channel in channelList: | |
751 | if channel not in dataOut.channelList: |
|
752 | if channel not in dataOut.channelList: | |
752 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
753 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
753 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
754 | channelIndexList.append(dataOut.channelList.index(channel)) | |
754 |
|
755 | |||
755 | if normFactor is None: |
|
756 | if normFactor is None: | |
756 | factor = dataOut.normFactor |
|
757 | factor = dataOut.normFactor | |
757 | else: |
|
758 | else: | |
758 | factor = normFactor |
|
759 | factor = normFactor | |
759 |
|
760 | |||
760 | # factor = dataOut.normFactor |
|
761 | # factor = dataOut.normFactor | |
761 | x = dataOut.getTimeRange() |
|
762 | x = dataOut.getTimeRange() | |
762 | y = dataOut.getHeiRange() |
|
763 | y = dataOut.getHeiRange() | |
763 |
|
764 | |||
764 | z = dataOut.data_spc/factor |
|
765 | z = dataOut.data_spc/factor | |
765 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
766 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
766 | avg = numpy.average(z, axis=1) |
|
767 | avg = numpy.average(z, axis=1) | |
767 | avgdB = 10.*numpy.log10(avg) |
|
768 | avgdB = 10.*numpy.log10(avg) | |
768 | # avgdB = dataOut.getPower() |
|
769 | # avgdB = dataOut.getPower() | |
769 |
|
770 | |||
770 |
|
771 | |||
771 | thisDatetime = dataOut.datatime |
|
772 | thisDatetime = dataOut.datatime | |
772 | # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
773 | # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
773 | title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
774 | title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
774 | xlabel = "" |
|
775 | xlabel = "" | |
775 | ylabel = "Range (Km)" |
|
776 | ylabel = "Range (Km)" | |
776 |
|
777 | |||
777 | update_figfile = False |
|
778 | update_figfile = False | |
778 |
|
779 | |||
779 | if dataOut.ltctime >= self.xmax: |
|
780 | if dataOut.ltctime >= self.xmax: | |
780 | self.counter_imagwr = wr_period |
|
781 | self.counter_imagwr = wr_period | |
781 | self.isConfig = False |
|
782 | self.isConfig = False | |
782 | update_figfile = True |
|
783 | update_figfile = True | |
783 |
|
784 | |||
784 | if not self.isConfig: |
|
785 | if not self.isConfig: | |
785 |
|
786 | |||
786 | nplots = len(channelIndexList) |
|
787 | nplots = len(channelIndexList) | |
787 |
|
788 | |||
788 | self.setup(id=id, |
|
789 | self.setup(id=id, | |
789 | nplots=nplots, |
|
790 | nplots=nplots, | |
790 | wintitle=wintitle, |
|
791 | wintitle=wintitle, | |
791 | showprofile=showprofile, |
|
792 | showprofile=showprofile, | |
792 | show=show) |
|
793 | show=show) | |
793 |
|
794 | |||
794 | if timerange != None: |
|
795 | if timerange != None: | |
795 | self.timerange = timerange |
|
796 | self.timerange = timerange | |
796 |
|
797 | |||
797 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
798 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
798 |
|
799 | |||
799 | noise = dataOut.noise/factor |
|
800 | noise = dataOut.noise/factor | |
800 | noisedB = 10*numpy.log10(noise) |
|
801 | noisedB = 10*numpy.log10(noise) | |
801 |
|
802 | |||
802 | if ymin == None: ymin = numpy.nanmin(y) |
|
803 | if ymin == None: ymin = numpy.nanmin(y) | |
803 | if ymax == None: ymax = numpy.nanmax(y) |
|
804 | if ymax == None: ymax = numpy.nanmax(y) | |
804 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 |
|
805 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 | |
805 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 |
|
806 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 | |
806 |
|
807 | |||
807 | self.FTP_WEI = ftp_wei |
|
808 | self.FTP_WEI = ftp_wei | |
808 | self.EXP_CODE = exp_code |
|
809 | self.EXP_CODE = exp_code | |
809 | self.SUB_EXP_CODE = sub_exp_code |
|
810 | self.SUB_EXP_CODE = sub_exp_code | |
810 | self.PLOT_POS = plot_pos |
|
811 | self.PLOT_POS = plot_pos | |
811 |
|
812 | |||
812 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
813 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
813 | self.isConfig = True |
|
814 | self.isConfig = True | |
814 | self.figfile = figfile |
|
815 | self.figfile = figfile | |
815 | update_figfile = True |
|
816 | update_figfile = True | |
816 |
|
817 | |||
817 | self.setWinTitle(title) |
|
818 | self.setWinTitle(title) | |
818 |
|
819 | |||
819 | for i in range(self.nplots): |
|
820 | for i in range(self.nplots): | |
820 | index = channelIndexList[i] |
|
821 | index = channelIndexList[i] | |
821 | title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
822 | title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
822 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
823 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
823 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
824 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
824 | axes = self.axesList[i*self.__nsubplots] |
|
825 | axes = self.axesList[i*self.__nsubplots] | |
825 | zdB = avgdB[index].reshape((1,-1)) |
|
826 | zdB = avgdB[index].reshape((1,-1)) | |
826 | axes.pcolorbuffer(x, y, zdB, |
|
827 | axes.pcolorbuffer(x, y, zdB, | |
827 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
828 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
828 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
829 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
829 | ticksize=9, cblabel='', cbsize="1%", colormap=colormap) |
|
830 | ticksize=9, cblabel='', cbsize="1%", colormap=colormap) | |
830 |
|
831 | |||
831 | if self.__showprofile: |
|
832 | if self.__showprofile: | |
832 | axes = self.axesList[i*self.__nsubplots +1] |
|
833 | axes = self.axesList[i*self.__nsubplots +1] | |
833 | axes.pline(avgdB[index], y, |
|
834 | axes.pline(avgdB[index], y, | |
834 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
835 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
835 | xlabel='dB', ylabel='', title='', |
|
836 | xlabel='dB', ylabel='', title='', | |
836 | ytick_visible=False, |
|
837 | ytick_visible=False, | |
837 | grid='x') |
|
838 | grid='x') | |
838 |
|
839 | |||
839 | self.draw() |
|
840 | self.draw() | |
840 |
|
841 | |||
841 | self.save(figpath=figpath, |
|
842 | self.save(figpath=figpath, | |
842 | figfile=figfile, |
|
843 | figfile=figfile, | |
843 | save=save, |
|
844 | save=save, | |
844 | ftp=ftp, |
|
845 | ftp=ftp, | |
845 | wr_period=wr_period, |
|
846 | wr_period=wr_period, | |
846 | thisDatetime=thisDatetime, |
|
847 | thisDatetime=thisDatetime, | |
847 | update_figfile=update_figfile) |
|
848 | update_figfile=update_figfile) | |
848 |
|
849 | |||
849 | class CoherenceMap(Figure): |
|
850 | class CoherenceMap(Figure): | |
850 | isConfig = None |
|
851 | isConfig = None | |
851 | __nsubplots = None |
|
852 | __nsubplots = None | |
852 |
|
853 | |||
853 | WIDTHPROF = None |
|
854 | WIDTHPROF = None | |
854 | HEIGHTPROF = None |
|
855 | HEIGHTPROF = None | |
855 | PREFIX = 'cmap' |
|
856 | PREFIX = 'cmap' | |
856 |
|
857 | |||
857 | def __init__(self, **kwargs): |
|
858 | def __init__(self, **kwargs): | |
858 | Figure.__init__(self, **kwargs) |
|
859 | Figure.__init__(self, **kwargs) | |
859 | self.timerange = 2*60*60 |
|
860 | self.timerange = 2*60*60 | |
860 | self.isConfig = False |
|
861 | self.isConfig = False | |
861 | self.__nsubplots = 1 |
|
862 | self.__nsubplots = 1 | |
862 |
|
863 | |||
863 | self.WIDTH = 800 |
|
864 | self.WIDTH = 800 | |
864 | self.HEIGHT = 180 |
|
865 | self.HEIGHT = 180 | |
865 | self.WIDTHPROF = 120 |
|
866 | self.WIDTHPROF = 120 | |
866 | self.HEIGHTPROF = 0 |
|
867 | self.HEIGHTPROF = 0 | |
867 | self.counter_imagwr = 0 |
|
868 | self.counter_imagwr = 0 | |
868 |
|
869 | |||
869 | self.PLOT_CODE = COH_CODE |
|
870 | self.PLOT_CODE = COH_CODE | |
870 |
|
871 | |||
871 | self.FTP_WEI = None |
|
872 | self.FTP_WEI = None | |
872 | self.EXP_CODE = None |
|
873 | self.EXP_CODE = None | |
873 | self.SUB_EXP_CODE = None |
|
874 | self.SUB_EXP_CODE = None | |
874 | self.PLOT_POS = None |
|
875 | self.PLOT_POS = None | |
875 | self.counter_imagwr = 0 |
|
876 | self.counter_imagwr = 0 | |
876 |
|
877 | |||
877 | self.xmin = None |
|
878 | self.xmin = None | |
878 | self.xmax = None |
|
879 | self.xmax = None | |
879 |
|
880 | |||
880 | def getSubplots(self): |
|
881 | def getSubplots(self): | |
881 | ncol = 1 |
|
882 | ncol = 1 | |
882 | nrow = self.nplots*2 |
|
883 | nrow = self.nplots*2 | |
883 |
|
884 | |||
884 | return nrow, ncol |
|
885 | return nrow, ncol | |
885 |
|
886 | |||
886 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
887 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
887 | self.__showprofile = showprofile |
|
888 | self.__showprofile = showprofile | |
888 | self.nplots = nplots |
|
889 | self.nplots = nplots | |
889 |
|
890 | |||
890 | ncolspan = 1 |
|
891 | ncolspan = 1 | |
891 | colspan = 1 |
|
892 | colspan = 1 | |
892 | if showprofile: |
|
893 | if showprofile: | |
893 | ncolspan = 7 |
|
894 | ncolspan = 7 | |
894 | colspan = 6 |
|
895 | colspan = 6 | |
895 | self.__nsubplots = 2 |
|
896 | self.__nsubplots = 2 | |
896 |
|
897 | |||
897 | self.createFigure(id = id, |
|
898 | self.createFigure(id = id, | |
898 | wintitle = wintitle, |
|
899 | wintitle = wintitle, | |
899 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
900 | widthplot = self.WIDTH + self.WIDTHPROF, | |
900 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
901 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
901 | show=True) |
|
902 | show=True) | |
902 |
|
903 | |||
903 | nrow, ncol = self.getSubplots() |
|
904 | nrow, ncol = self.getSubplots() | |
904 |
|
905 | |||
905 | for y in range(nrow): |
|
906 | for y in range(nrow): | |
906 | for x in range(ncol): |
|
907 | for x in range(ncol): | |
907 |
|
908 | |||
908 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
909 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
909 |
|
910 | |||
910 | if showprofile: |
|
911 | if showprofile: | |
911 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
912 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
912 |
|
913 | |||
913 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
914 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
914 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
915 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
915 | timerange=None, phase_min=None, phase_max=None, |
|
916 | timerange=None, phase_min=None, phase_max=None, | |
916 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, |
|
917 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, | |
917 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True, |
|
918 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True, | |
918 | server=None, folder=None, username=None, password=None, |
|
919 | server=None, folder=None, username=None, password=None, | |
919 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
920 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
920 |
|
921 | |||
921 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
922 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
922 | return |
|
923 | return | |
923 |
|
924 | |||
924 | if pairsList == None: |
|
925 | if pairsList == None: | |
925 | pairsIndexList = dataOut.pairsIndexList |
|
926 | pairsIndexList = dataOut.pairsIndexList | |
926 | else: |
|
927 | else: | |
927 | pairsIndexList = [] |
|
928 | pairsIndexList = [] | |
928 | for pair in pairsList: |
|
929 | for pair in pairsList: | |
929 | if pair not in dataOut.pairsList: |
|
930 | if pair not in dataOut.pairsList: | |
930 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
931 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
931 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
932 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
932 |
|
933 | |||
933 | if pairsIndexList == []: |
|
934 | if pairsIndexList == []: | |
934 | return |
|
935 | return | |
935 |
|
936 | |||
936 | if len(pairsIndexList) > 4: |
|
937 | if len(pairsIndexList) > 4: | |
937 | pairsIndexList = pairsIndexList[0:4] |
|
938 | pairsIndexList = pairsIndexList[0:4] | |
938 |
|
939 | |||
939 | if phase_min == None: |
|
940 | if phase_min == None: | |
940 | phase_min = -180 |
|
941 | phase_min = -180 | |
941 | if phase_max == None: |
|
942 | if phase_max == None: | |
942 | phase_max = 180 |
|
943 | phase_max = 180 | |
943 |
|
944 | |||
944 | x = dataOut.getTimeRange() |
|
945 | x = dataOut.getTimeRange() | |
945 | y = dataOut.getHeiRange() |
|
946 | y = dataOut.getHeiRange() | |
946 |
|
947 | |||
947 | thisDatetime = dataOut.datatime |
|
948 | thisDatetime = dataOut.datatime | |
948 |
|
949 | |||
949 | title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
950 | title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
950 | xlabel = "" |
|
951 | xlabel = "" | |
951 | ylabel = "Range (Km)" |
|
952 | ylabel = "Range (Km)" | |
952 | update_figfile = False |
|
953 | update_figfile = False | |
953 |
|
954 | |||
954 | if not self.isConfig: |
|
955 | if not self.isConfig: | |
955 | nplots = len(pairsIndexList) |
|
956 | nplots = len(pairsIndexList) | |
956 | self.setup(id=id, |
|
957 | self.setup(id=id, | |
957 | nplots=nplots, |
|
958 | nplots=nplots, | |
958 | wintitle=wintitle, |
|
959 | wintitle=wintitle, | |
959 | showprofile=showprofile, |
|
960 | showprofile=showprofile, | |
960 | show=show) |
|
961 | show=show) | |
961 |
|
962 | |||
962 | if timerange != None: |
|
963 | if timerange != None: | |
963 | self.timerange = timerange |
|
964 | self.timerange = timerange | |
964 |
|
965 | |||
965 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
966 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
966 |
|
967 | |||
967 | if ymin == None: ymin = numpy.nanmin(y) |
|
968 | if ymin == None: ymin = numpy.nanmin(y) | |
968 | if ymax == None: ymax = numpy.nanmax(y) |
|
969 | if ymax == None: ymax = numpy.nanmax(y) | |
969 | if zmin == None: zmin = 0. |
|
970 | if zmin == None: zmin = 0. | |
970 | if zmax == None: zmax = 1. |
|
971 | if zmax == None: zmax = 1. | |
971 |
|
972 | |||
972 | self.FTP_WEI = ftp_wei |
|
973 | self.FTP_WEI = ftp_wei | |
973 | self.EXP_CODE = exp_code |
|
974 | self.EXP_CODE = exp_code | |
974 | self.SUB_EXP_CODE = sub_exp_code |
|
975 | self.SUB_EXP_CODE = sub_exp_code | |
975 | self.PLOT_POS = plot_pos |
|
976 | self.PLOT_POS = plot_pos | |
976 |
|
977 | |||
977 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
978 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
978 |
|
979 | |||
979 | self.isConfig = True |
|
980 | self.isConfig = True | |
980 | update_figfile = True |
|
981 | update_figfile = True | |
981 |
|
982 | |||
982 | self.setWinTitle(title) |
|
983 | self.setWinTitle(title) | |
983 |
|
984 | |||
984 | for i in range(self.nplots): |
|
985 | for i in range(self.nplots): | |
985 |
|
986 | |||
986 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
987 | pair = dataOut.pairsList[pairsIndexList[i]] | |
987 |
|
988 | |||
988 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) |
|
989 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) | |
989 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) |
|
990 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) | |
990 | powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0) |
|
991 | powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0) | |
991 |
|
992 | |||
992 |
|
993 | |||
993 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
994 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
994 | coherence = numpy.abs(avgcoherenceComplex) |
|
995 | coherence = numpy.abs(avgcoherenceComplex) | |
995 |
|
996 | |||
996 | z = coherence.reshape((1,-1)) |
|
997 | z = coherence.reshape((1,-1)) | |
997 |
|
998 | |||
998 | counter = 0 |
|
999 | counter = 0 | |
999 |
|
1000 | |||
1000 | title = "Coherence Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1001 | title = "Coherence Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1001 | axes = self.axesList[i*self.__nsubplots*2] |
|
1002 | axes = self.axesList[i*self.__nsubplots*2] | |
1002 | axes.pcolorbuffer(x, y, z, |
|
1003 | axes.pcolorbuffer(x, y, z, | |
1003 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
1004 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
1004 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1005 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1005 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") |
|
1006 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") | |
1006 |
|
1007 | |||
1007 | if self.__showprofile: |
|
1008 | if self.__showprofile: | |
1008 | counter += 1 |
|
1009 | counter += 1 | |
1009 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
1010 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
1010 | axes.pline(coherence, y, |
|
1011 | axes.pline(coherence, y, | |
1011 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
1012 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
1012 | xlabel='', ylabel='', title='', ticksize=7, |
|
1013 | xlabel='', ylabel='', title='', ticksize=7, | |
1013 | ytick_visible=False, nxticks=5, |
|
1014 | ytick_visible=False, nxticks=5, | |
1014 | grid='x') |
|
1015 | grid='x') | |
1015 |
|
1016 | |||
1016 | counter += 1 |
|
1017 | counter += 1 | |
1017 |
|
1018 | |||
1018 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
1019 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
1019 |
|
1020 | |||
1020 | z = phase.reshape((1,-1)) |
|
1021 | z = phase.reshape((1,-1)) | |
1021 |
|
1022 | |||
1022 | title = "Phase Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1023 | title = "Phase Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1023 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
1024 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
1024 | axes.pcolorbuffer(x, y, z, |
|
1025 | axes.pcolorbuffer(x, y, z, | |
1025 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max, |
|
1026 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max, | |
1026 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1027 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1027 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") |
|
1028 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") | |
1028 |
|
1029 | |||
1029 | if self.__showprofile: |
|
1030 | if self.__showprofile: | |
1030 | counter += 1 |
|
1031 | counter += 1 | |
1031 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
1032 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
1032 | axes.pline(phase, y, |
|
1033 | axes.pline(phase, y, | |
1033 | xmin=phase_min, xmax=phase_max, ymin=ymin, ymax=ymax, |
|
1034 | xmin=phase_min, xmax=phase_max, ymin=ymin, ymax=ymax, | |
1034 | xlabel='', ylabel='', title='', ticksize=7, |
|
1035 | xlabel='', ylabel='', title='', ticksize=7, | |
1035 | ytick_visible=False, nxticks=4, |
|
1036 | ytick_visible=False, nxticks=4, | |
1036 | grid='x') |
|
1037 | grid='x') | |
1037 |
|
1038 | |||
1038 | self.draw() |
|
1039 | self.draw() | |
1039 |
|
1040 | |||
1040 | if dataOut.ltctime >= self.xmax: |
|
1041 | if dataOut.ltctime >= self.xmax: | |
1041 | self.counter_imagwr = wr_period |
|
1042 | self.counter_imagwr = wr_period | |
1042 | self.isConfig = False |
|
1043 | self.isConfig = False | |
1043 | update_figfile = True |
|
1044 | update_figfile = True | |
1044 |
|
1045 | |||
1045 | self.save(figpath=figpath, |
|
1046 | self.save(figpath=figpath, | |
1046 | figfile=figfile, |
|
1047 | figfile=figfile, | |
1047 | save=save, |
|
1048 | save=save, | |
1048 | ftp=ftp, |
|
1049 | ftp=ftp, | |
1049 | wr_period=wr_period, |
|
1050 | wr_period=wr_period, | |
1050 | thisDatetime=thisDatetime, |
|
1051 | thisDatetime=thisDatetime, | |
1051 | update_figfile=update_figfile) |
|
1052 | update_figfile=update_figfile) | |
1052 |
|
1053 | |||
1053 | class PowerProfilePlot(Figure): |
|
1054 | class PowerProfilePlot(Figure): | |
1054 |
|
1055 | |||
1055 | isConfig = None |
|
1056 | isConfig = None | |
1056 | __nsubplots = None |
|
1057 | __nsubplots = None | |
1057 |
|
1058 | |||
1058 | WIDTHPROF = None |
|
1059 | WIDTHPROF = None | |
1059 | HEIGHTPROF = None |
|
1060 | HEIGHTPROF = None | |
1060 | PREFIX = 'spcprofile' |
|
1061 | PREFIX = 'spcprofile' | |
1061 |
|
1062 | |||
1062 | def __init__(self, **kwargs): |
|
1063 | def __init__(self, **kwargs): | |
1063 | Figure.__init__(self, **kwargs) |
|
1064 | Figure.__init__(self, **kwargs) | |
1064 | self.isConfig = False |
|
1065 | self.isConfig = False | |
1065 | self.__nsubplots = 1 |
|
1066 | self.__nsubplots = 1 | |
1066 |
|
1067 | |||
1067 | self.PLOT_CODE = POWER_CODE |
|
1068 | self.PLOT_CODE = POWER_CODE | |
1068 |
|
1069 | |||
1069 | self.WIDTH = 300 |
|
1070 | self.WIDTH = 300 | |
1070 | self.HEIGHT = 500 |
|
1071 | self.HEIGHT = 500 | |
1071 | self.counter_imagwr = 0 |
|
1072 | self.counter_imagwr = 0 | |
1072 |
|
1073 | |||
1073 | def getSubplots(self): |
|
1074 | def getSubplots(self): | |
1074 | ncol = 1 |
|
1075 | ncol = 1 | |
1075 | nrow = 1 |
|
1076 | nrow = 1 | |
1076 |
|
1077 | |||
1077 | return nrow, ncol |
|
1078 | return nrow, ncol | |
1078 |
|
1079 | |||
1079 | def setup(self, id, nplots, wintitle, show): |
|
1080 | def setup(self, id, nplots, wintitle, show): | |
1080 |
|
1081 | |||
1081 | self.nplots = nplots |
|
1082 | self.nplots = nplots | |
1082 |
|
1083 | |||
1083 | ncolspan = 1 |
|
1084 | ncolspan = 1 | |
1084 | colspan = 1 |
|
1085 | colspan = 1 | |
1085 |
|
1086 | |||
1086 | self.createFigure(id = id, |
|
1087 | self.createFigure(id = id, | |
1087 | wintitle = wintitle, |
|
1088 | wintitle = wintitle, | |
1088 | widthplot = self.WIDTH, |
|
1089 | widthplot = self.WIDTH, | |
1089 | heightplot = self.HEIGHT, |
|
1090 | heightplot = self.HEIGHT, | |
1090 | show=show) |
|
1091 | show=show) | |
1091 |
|
1092 | |||
1092 | nrow, ncol = self.getSubplots() |
|
1093 | nrow, ncol = self.getSubplots() | |
1093 |
|
1094 | |||
1094 | counter = 0 |
|
1095 | counter = 0 | |
1095 | for y in range(nrow): |
|
1096 | for y in range(nrow): | |
1096 | for x in range(ncol): |
|
1097 | for x in range(ncol): | |
1097 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1098 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
1098 |
|
1099 | |||
1099 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
1100 | def run(self, dataOut, id, wintitle="", channelList=None, | |
1100 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1101 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1101 | save=False, figpath='./', figfile=None, show=True, |
|
1102 | save=False, figpath='./', figfile=None, show=True, | |
1102 | ftp=False, wr_period=1, server=None, |
|
1103 | ftp=False, wr_period=1, server=None, | |
1103 | folder=None, username=None, password=None): |
|
1104 | folder=None, username=None, password=None): | |
1104 |
|
1105 | |||
1105 |
|
1106 | |||
1106 | if channelList == None: |
|
1107 | if channelList == None: | |
1107 | channelIndexList = dataOut.channelIndexList |
|
1108 | channelIndexList = dataOut.channelIndexList | |
1108 | channelList = dataOut.channelList |
|
1109 | channelList = dataOut.channelList | |
1109 | else: |
|
1110 | else: | |
1110 | channelIndexList = [] |
|
1111 | channelIndexList = [] | |
1111 | for channel in channelList: |
|
1112 | for channel in channelList: | |
1112 | if channel not in dataOut.channelList: |
|
1113 | if channel not in dataOut.channelList: | |
1113 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1114 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1114 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1115 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1115 |
|
1116 | |||
1116 | factor = dataOut.normFactor |
|
1117 | factor = dataOut.normFactor | |
1117 |
|
1118 | |||
1118 | y = dataOut.getHeiRange() |
|
1119 | y = dataOut.getHeiRange() | |
1119 |
|
1120 | |||
1120 | #for voltage |
|
1121 | #for voltage | |
1121 | if dataOut.type == 'Voltage': |
|
1122 | if dataOut.type == 'Voltage': | |
1122 | x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
1123 | x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
1123 | x = x.real |
|
1124 | x = x.real | |
1124 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
1125 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
1125 |
|
1126 | |||
1126 | #for spectra |
|
1127 | #for spectra | |
1127 | if dataOut.type == 'Spectra': |
|
1128 | if dataOut.type == 'Spectra': | |
1128 | x = dataOut.data_spc[channelIndexList,:,:]/factor |
|
1129 | x = dataOut.data_spc[channelIndexList,:,:]/factor | |
1129 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
1130 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
1130 | x = numpy.average(x, axis=1) |
|
1131 | x = numpy.average(x, axis=1) | |
1131 |
|
1132 | |||
1132 |
|
1133 | |||
1133 | xdB = 10*numpy.log10(x) |
|
1134 | xdB = 10*numpy.log10(x) | |
1134 |
|
1135 | |||
1135 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
1136 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
1136 | title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1137 | title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1137 | xlabel = "dB" |
|
1138 | xlabel = "dB" | |
1138 | ylabel = "Range (Km)" |
|
1139 | ylabel = "Range (Km)" | |
1139 |
|
1140 | |||
1140 | if not self.isConfig: |
|
1141 | if not self.isConfig: | |
1141 |
|
1142 | |||
1142 | nplots = 1 |
|
1143 | nplots = 1 | |
1143 |
|
1144 | |||
1144 | self.setup(id=id, |
|
1145 | self.setup(id=id, | |
1145 | nplots=nplots, |
|
1146 | nplots=nplots, | |
1146 | wintitle=wintitle, |
|
1147 | wintitle=wintitle, | |
1147 | show=show) |
|
1148 | show=show) | |
1148 |
|
1149 | |||
1149 | if ymin == None: ymin = numpy.nanmin(y) |
|
1150 | if ymin == None: ymin = numpy.nanmin(y) | |
1150 | if ymax == None: ymax = numpy.nanmax(y) |
|
1151 | if ymax == None: ymax = numpy.nanmax(y) | |
1151 | if xmin == None: xmin = numpy.nanmin(xdB)*0.9 |
|
1152 | if xmin == None: xmin = numpy.nanmin(xdB)*0.9 | |
1152 | if xmax == None: xmax = numpy.nanmax(xdB)*1.1 |
|
1153 | if xmax == None: xmax = numpy.nanmax(xdB)*1.1 | |
1153 |
|
1154 | |||
1154 | self.isConfig = True |
|
1155 | self.isConfig = True | |
1155 |
|
1156 | |||
1156 | self.setWinTitle(title) |
|
1157 | self.setWinTitle(title) | |
1157 |
|
1158 | |||
1158 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1159 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1159 | axes = self.axesList[0] |
|
1160 | axes = self.axesList[0] | |
1160 |
|
1161 | |||
1161 | legendlabels = ["channel %d"%x for x in channelList] |
|
1162 | legendlabels = ["channel %d"%x for x in channelList] | |
1162 | axes.pmultiline(xdB, y, |
|
1163 | axes.pmultiline(xdB, y, | |
1163 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1164 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
1164 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
1165 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
1165 | ytick_visible=True, nxticks=5, |
|
1166 | ytick_visible=True, nxticks=5, | |
1166 | grid='x') |
|
1167 | grid='x') | |
1167 |
|
1168 | |||
1168 | self.draw() |
|
1169 | self.draw() | |
1169 |
|
1170 | |||
1170 | self.save(figpath=figpath, |
|
1171 | self.save(figpath=figpath, | |
1171 | figfile=figfile, |
|
1172 | figfile=figfile, | |
1172 | save=save, |
|
1173 | save=save, | |
1173 | ftp=ftp, |
|
1174 | ftp=ftp, | |
1174 | wr_period=wr_period, |
|
1175 | wr_period=wr_period, | |
1175 | thisDatetime=thisDatetime) |
|
1176 | thisDatetime=thisDatetime) | |
1176 |
|
1177 | |||
1177 | class SpectraCutPlot(Figure): |
|
1178 | class SpectraCutPlot(Figure): | |
1178 |
|
1179 | |||
1179 | isConfig = None |
|
1180 | isConfig = None | |
1180 | __nsubplots = None |
|
1181 | __nsubplots = None | |
1181 |
|
1182 | |||
1182 | WIDTHPROF = None |
|
1183 | WIDTHPROF = None | |
1183 | HEIGHTPROF = None |
|
1184 | HEIGHTPROF = None | |
1184 | PREFIX = 'spc_cut' |
|
1185 | PREFIX = 'spc_cut' | |
1185 |
|
1186 | |||
1186 | def __init__(self, **kwargs): |
|
1187 | def __init__(self, **kwargs): | |
1187 | Figure.__init__(self, **kwargs) |
|
1188 | Figure.__init__(self, **kwargs) | |
1188 | self.isConfig = False |
|
1189 | self.isConfig = False | |
1189 | self.__nsubplots = 1 |
|
1190 | self.__nsubplots = 1 | |
1190 |
|
1191 | |||
1191 | self.PLOT_CODE = POWER_CODE |
|
1192 | self.PLOT_CODE = POWER_CODE | |
1192 |
|
1193 | |||
1193 | self.WIDTH = 700 |
|
1194 | self.WIDTH = 700 | |
1194 | self.HEIGHT = 500 |
|
1195 | self.HEIGHT = 500 | |
1195 | self.counter_imagwr = 0 |
|
1196 | self.counter_imagwr = 0 | |
1196 |
|
1197 | |||
1197 | def getSubplots(self): |
|
1198 | def getSubplots(self): | |
1198 | ncol = 1 |
|
1199 | ncol = 1 | |
1199 | nrow = 1 |
|
1200 | nrow = 1 | |
1200 |
|
1201 | |||
1201 | return nrow, ncol |
|
1202 | return nrow, ncol | |
1202 |
|
1203 | |||
1203 | def setup(self, id, nplots, wintitle, show): |
|
1204 | def setup(self, id, nplots, wintitle, show): | |
1204 |
|
1205 | |||
1205 | self.nplots = nplots |
|
1206 | self.nplots = nplots | |
1206 |
|
1207 | |||
1207 | ncolspan = 1 |
|
1208 | ncolspan = 1 | |
1208 | colspan = 1 |
|
1209 | colspan = 1 | |
1209 |
|
1210 | |||
1210 | self.createFigure(id = id, |
|
1211 | self.createFigure(id = id, | |
1211 | wintitle = wintitle, |
|
1212 | wintitle = wintitle, | |
1212 | widthplot = self.WIDTH, |
|
1213 | widthplot = self.WIDTH, | |
1213 | heightplot = self.HEIGHT, |
|
1214 | heightplot = self.HEIGHT, | |
1214 | show=show) |
|
1215 | show=show) | |
1215 |
|
1216 | |||
1216 | nrow, ncol = self.getSubplots() |
|
1217 | nrow, ncol = self.getSubplots() | |
1217 |
|
1218 | |||
1218 | counter = 0 |
|
1219 | counter = 0 | |
1219 | for y in range(nrow): |
|
1220 | for y in range(nrow): | |
1220 | for x in range(ncol): |
|
1221 | for x in range(ncol): | |
1221 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1222 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
1222 |
|
1223 | |||
1223 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
1224 | def run(self, dataOut, id, wintitle="", channelList=None, | |
1224 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1225 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1225 | save=False, figpath='./', figfile=None, show=True, |
|
1226 | save=False, figpath='./', figfile=None, show=True, | |
1226 | ftp=False, wr_period=1, server=None, |
|
1227 | ftp=False, wr_period=1, server=None, | |
1227 | folder=None, username=None, password=None, |
|
1228 | folder=None, username=None, password=None, | |
1228 | xaxis="frequency"): |
|
1229 | xaxis="frequency"): | |
1229 |
|
1230 | |||
1230 |
|
1231 | |||
1231 | if channelList == None: |
|
1232 | if channelList == None: | |
1232 | channelIndexList = dataOut.channelIndexList |
|
1233 | channelIndexList = dataOut.channelIndexList | |
1233 | channelList = dataOut.channelList |
|
1234 | channelList = dataOut.channelList | |
1234 | else: |
|
1235 | else: | |
1235 | channelIndexList = [] |
|
1236 | channelIndexList = [] | |
1236 | for channel in channelList: |
|
1237 | for channel in channelList: | |
1237 | if channel not in dataOut.channelList: |
|
1238 | if channel not in dataOut.channelList: | |
1238 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1239 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1239 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1240 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1240 |
|
1241 | |||
1241 | factor = dataOut.normFactor |
|
1242 | factor = dataOut.normFactor | |
1242 |
|
1243 | |||
1243 | y = dataOut.getHeiRange() |
|
1244 | y = dataOut.getHeiRange() | |
1244 |
|
1245 | |||
1245 | z = dataOut.data_spc/factor |
|
1246 | z = dataOut.data_spc/factor | |
1246 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
1247 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
1247 |
|
1248 | |||
1248 | hei_index = numpy.arange(25)*3 + 20 |
|
1249 | hei_index = numpy.arange(25)*3 + 20 | |
1249 |
|
1250 | |||
1250 | if xaxis == "frequency": |
|
1251 | if xaxis == "frequency": | |
1251 | x = dataOut.getFreqRange()/1000. |
|
1252 | x = dataOut.getFreqRange()/1000. | |
1252 | zdB = 10*numpy.log10(z[0,:,hei_index]) |
|
1253 | zdB = 10*numpy.log10(z[0,:,hei_index]) | |
1253 | xlabel = "Frequency (kHz)" |
|
1254 | xlabel = "Frequency (kHz)" | |
1254 | ylabel = "Power (dB)" |
|
1255 | ylabel = "Power (dB)" | |
1255 |
|
1256 | |||
1256 | elif xaxis == "time": |
|
1257 | elif xaxis == "time": | |
1257 | x = dataOut.getAcfRange() |
|
1258 | x = dataOut.getAcfRange() | |
1258 | zdB = z[0,:,hei_index] |
|
1259 | zdB = z[0,:,hei_index] | |
1259 | xlabel = "Time (ms)" |
|
1260 | xlabel = "Time (ms)" | |
1260 | ylabel = "ACF" |
|
1261 | ylabel = "ACF" | |
1261 |
|
1262 | |||
1262 | else: |
|
1263 | else: | |
1263 | x = dataOut.getVelRange() |
|
1264 | x = dataOut.getVelRange() | |
1264 | zdB = 10*numpy.log10(z[0,:,hei_index]) |
|
1265 | zdB = 10*numpy.log10(z[0,:,hei_index]) | |
1265 | xlabel = "Velocity (m/s)" |
|
1266 | xlabel = "Velocity (m/s)" | |
1266 | ylabel = "Power (dB)" |
|
1267 | ylabel = "Power (dB)" | |
1267 |
|
1268 | |||
1268 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
1269 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
1269 | title = wintitle + " Range Cuts %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1270 | title = wintitle + " Range Cuts %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1270 |
|
1271 | |||
1271 | if not self.isConfig: |
|
1272 | if not self.isConfig: | |
1272 |
|
1273 | |||
1273 | nplots = 1 |
|
1274 | nplots = 1 | |
1274 |
|
1275 | |||
1275 | self.setup(id=id, |
|
1276 | self.setup(id=id, | |
1276 | nplots=nplots, |
|
1277 | nplots=nplots, | |
1277 | wintitle=wintitle, |
|
1278 | wintitle=wintitle, | |
1278 | show=show) |
|
1279 | show=show) | |
1279 |
|
1280 | |||
1280 | if xmin == None: xmin = numpy.nanmin(x)*0.9 |
|
1281 | if xmin == None: xmin = numpy.nanmin(x)*0.9 | |
1281 | if xmax == None: xmax = numpy.nanmax(x)*1.1 |
|
1282 | if xmax == None: xmax = numpy.nanmax(x)*1.1 | |
1282 | if ymin == None: ymin = numpy.nanmin(zdB) |
|
1283 | if ymin == None: ymin = numpy.nanmin(zdB) | |
1283 | if ymax == None: ymax = numpy.nanmax(zdB) |
|
1284 | if ymax == None: ymax = numpy.nanmax(zdB) | |
1284 |
|
1285 | |||
1285 | self.isConfig = True |
|
1286 | self.isConfig = True | |
1286 |
|
1287 | |||
1287 | self.setWinTitle(title) |
|
1288 | self.setWinTitle(title) | |
1288 |
|
1289 | |||
1289 | title = "Spectra Cuts: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1290 | title = "Spectra Cuts: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1290 | axes = self.axesList[0] |
|
1291 | axes = self.axesList[0] | |
1291 |
|
1292 | |||
1292 | legendlabels = ["Range = %dKm" %y[i] for i in hei_index] |
|
1293 | legendlabels = ["Range = %dKm" %y[i] for i in hei_index] | |
1293 |
|
1294 | |||
1294 | axes.pmultilineyaxis( x, zdB, |
|
1295 | axes.pmultilineyaxis( x, zdB, | |
1295 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1296 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
1296 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
1297 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
1297 | ytick_visible=True, nxticks=5, |
|
1298 | ytick_visible=True, nxticks=5, | |
1298 | grid='x') |
|
1299 | grid='x') | |
1299 |
|
1300 | |||
1300 | self.draw() |
|
1301 | self.draw() | |
1301 |
|
1302 | |||
1302 | self.save(figpath=figpath, |
|
1303 | self.save(figpath=figpath, | |
1303 | figfile=figfile, |
|
1304 | figfile=figfile, | |
1304 | save=save, |
|
1305 | save=save, | |
1305 | ftp=ftp, |
|
1306 | ftp=ftp, | |
1306 | wr_period=wr_period, |
|
1307 | wr_period=wr_period, | |
1307 | thisDatetime=thisDatetime) |
|
1308 | thisDatetime=thisDatetime) | |
1308 |
|
1309 | |||
1309 | class Noise(Figure): |
|
1310 | class Noise(Figure): | |
1310 |
|
1311 | |||
1311 | isConfig = None |
|
1312 | isConfig = None | |
1312 | __nsubplots = None |
|
1313 | __nsubplots = None | |
1313 |
|
1314 | |||
1314 | PREFIX = 'noise' |
|
1315 | PREFIX = 'noise' | |
1315 |
|
1316 | |||
1316 |
|
1317 | |||
1317 | def __init__(self, **kwargs): |
|
1318 | def __init__(self, **kwargs): | |
1318 | Figure.__init__(self, **kwargs) |
|
1319 | Figure.__init__(self, **kwargs) | |
1319 | self.timerange = 24*60*60 |
|
1320 | self.timerange = 24*60*60 | |
1320 | self.isConfig = False |
|
1321 | self.isConfig = False | |
1321 | self.__nsubplots = 1 |
|
1322 | self.__nsubplots = 1 | |
1322 | self.counter_imagwr = 0 |
|
1323 | self.counter_imagwr = 0 | |
1323 | self.WIDTH = 800 |
|
1324 | self.WIDTH = 800 | |
1324 | self.HEIGHT = 400 |
|
1325 | self.HEIGHT = 400 | |
1325 | self.WIDTHPROF = 120 |
|
1326 | self.WIDTHPROF = 120 | |
1326 | self.HEIGHTPROF = 0 |
|
1327 | self.HEIGHTPROF = 0 | |
1327 | self.xdata = None |
|
1328 | self.xdata = None | |
1328 | self.ydata = None |
|
1329 | self.ydata = None | |
1329 |
|
1330 | |||
1330 | self.PLOT_CODE = NOISE_CODE |
|
1331 | self.PLOT_CODE = NOISE_CODE | |
1331 |
|
1332 | |||
1332 | self.FTP_WEI = None |
|
1333 | self.FTP_WEI = None | |
1333 | self.EXP_CODE = None |
|
1334 | self.EXP_CODE = None | |
1334 | self.SUB_EXP_CODE = None |
|
1335 | self.SUB_EXP_CODE = None | |
1335 | self.PLOT_POS = None |
|
1336 | self.PLOT_POS = None | |
1336 | self.figfile = None |
|
1337 | self.figfile = None | |
1337 |
|
1338 | |||
1338 | self.xmin = None |
|
1339 | self.xmin = None | |
1339 | self.xmax = None |
|
1340 | self.xmax = None | |
1340 |
|
1341 | |||
1341 | def getSubplots(self): |
|
1342 | def getSubplots(self): | |
1342 |
|
1343 | |||
1343 | ncol = 1 |
|
1344 | ncol = 1 | |
1344 | nrow = 1 |
|
1345 | nrow = 1 | |
1345 |
|
1346 | |||
1346 | return nrow, ncol |
|
1347 | return nrow, ncol | |
1347 |
|
1348 | |||
1348 | def openfile(self, filename): |
|
1349 | def openfile(self, filename): | |
1349 | dirname = os.path.dirname(filename) |
|
1350 | dirname = os.path.dirname(filename) | |
1350 |
|
1351 | |||
1351 | if not os.path.exists(dirname): |
|
1352 | if not os.path.exists(dirname): | |
1352 | os.mkdir(dirname) |
|
1353 | os.mkdir(dirname) | |
1353 |
|
1354 | |||
1354 | f = open(filename,'w+') |
|
1355 | f = open(filename,'w+') | |
1355 | f.write('\n\n') |
|
1356 | f.write('\n\n') | |
1356 | f.write('JICAMARCA RADIO OBSERVATORY - Noise \n') |
|
1357 | f.write('JICAMARCA RADIO OBSERVATORY - Noise \n') | |
1357 | f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' ) |
|
1358 | f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' ) | |
1358 | f.close() |
|
1359 | f.close() | |
1359 |
|
1360 | |||
1360 | def save_data(self, filename_phase, data, data_datetime): |
|
1361 | def save_data(self, filename_phase, data, data_datetime): | |
1361 |
|
1362 | |||
1362 | f=open(filename_phase,'a') |
|
1363 | f=open(filename_phase,'a') | |
1363 |
|
1364 | |||
1364 | timetuple_data = data_datetime.timetuple() |
|
1365 | timetuple_data = data_datetime.timetuple() | |
1365 | day = str(timetuple_data.tm_mday) |
|
1366 | day = str(timetuple_data.tm_mday) | |
1366 | month = str(timetuple_data.tm_mon) |
|
1367 | month = str(timetuple_data.tm_mon) | |
1367 | year = str(timetuple_data.tm_year) |
|
1368 | year = str(timetuple_data.tm_year) | |
1368 | hour = str(timetuple_data.tm_hour) |
|
1369 | hour = str(timetuple_data.tm_hour) | |
1369 | minute = str(timetuple_data.tm_min) |
|
1370 | minute = str(timetuple_data.tm_min) | |
1370 | second = str(timetuple_data.tm_sec) |
|
1371 | second = str(timetuple_data.tm_sec) | |
1371 |
|
1372 | |||
1372 | data_msg = '' |
|
1373 | data_msg = '' | |
1373 | for i in range(len(data)): |
|
1374 | for i in range(len(data)): | |
1374 | data_msg += str(data[i]) + ' ' |
|
1375 | data_msg += str(data[i]) + ' ' | |
1375 |
|
1376 | |||
1376 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' ' + data_msg + '\n') |
|
1377 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' ' + data_msg + '\n') | |
1377 | f.close() |
|
1378 | f.close() | |
1378 |
|
1379 | |||
1379 |
|
1380 | |||
1380 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1381 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1381 |
|
1382 | |||
1382 | self.__showprofile = showprofile |
|
1383 | self.__showprofile = showprofile | |
1383 | self.nplots = nplots |
|
1384 | self.nplots = nplots | |
1384 |
|
1385 | |||
1385 | ncolspan = 7 |
|
1386 | ncolspan = 7 | |
1386 | colspan = 6 |
|
1387 | colspan = 6 | |
1387 | self.__nsubplots = 2 |
|
1388 | self.__nsubplots = 2 | |
1388 |
|
1389 | |||
1389 | self.createFigure(id = id, |
|
1390 | self.createFigure(id = id, | |
1390 | wintitle = wintitle, |
|
1391 | wintitle = wintitle, | |
1391 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1392 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1392 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1393 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1393 | show=show) |
|
1394 | show=show) | |
1394 |
|
1395 | |||
1395 | nrow, ncol = self.getSubplots() |
|
1396 | nrow, ncol = self.getSubplots() | |
1396 |
|
1397 | |||
1397 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1398 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1398 |
|
1399 | |||
1399 |
|
1400 | |||
1400 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', |
|
1401 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
1401 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1402 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1402 | timerange=None, |
|
1403 | timerange=None, | |
1403 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1404 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1404 | server=None, folder=None, username=None, password=None, |
|
1405 | server=None, folder=None, username=None, password=None, | |
1405 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1406 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1406 |
|
1407 | |||
1407 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
1408 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
1408 | return |
|
1409 | return | |
1409 |
|
1410 | |||
1410 | if channelList == None: |
|
1411 | if channelList == None: | |
1411 | channelIndexList = dataOut.channelIndexList |
|
1412 | channelIndexList = dataOut.channelIndexList | |
1412 | channelList = dataOut.channelList |
|
1413 | channelList = dataOut.channelList | |
1413 | else: |
|
1414 | else: | |
1414 | channelIndexList = [] |
|
1415 | channelIndexList = [] | |
1415 | for channel in channelList: |
|
1416 | for channel in channelList: | |
1416 | if channel not in dataOut.channelList: |
|
1417 | if channel not in dataOut.channelList: | |
1417 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1418 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1418 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1419 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1419 |
|
1420 | |||
1420 | x = dataOut.getTimeRange() |
|
1421 | x = dataOut.getTimeRange() | |
1421 | #y = dataOut.getHeiRange() |
|
1422 | #y = dataOut.getHeiRange() | |
1422 | factor = dataOut.normFactor |
|
1423 | factor = dataOut.normFactor | |
1423 | noise = dataOut.noise[channelIndexList]/factor |
|
1424 | noise = dataOut.noise[channelIndexList]/factor | |
1424 | noisedB = 10*numpy.log10(noise) |
|
1425 | noisedB = 10*numpy.log10(noise) | |
1425 |
|
1426 | |||
1426 | thisDatetime = dataOut.datatime |
|
1427 | thisDatetime = dataOut.datatime | |
1427 |
|
1428 | |||
1428 | title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1429 | title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1429 | xlabel = "" |
|
1430 | xlabel = "" | |
1430 | ylabel = "Intensity (dB)" |
|
1431 | ylabel = "Intensity (dB)" | |
1431 | update_figfile = False |
|
1432 | update_figfile = False | |
1432 |
|
1433 | |||
1433 | if not self.isConfig: |
|
1434 | if not self.isConfig: | |
1434 |
|
1435 | |||
1435 | nplots = 1 |
|
1436 | nplots = 1 | |
1436 |
|
1437 | |||
1437 | self.setup(id=id, |
|
1438 | self.setup(id=id, | |
1438 | nplots=nplots, |
|
1439 | nplots=nplots, | |
1439 | wintitle=wintitle, |
|
1440 | wintitle=wintitle, | |
1440 | showprofile=showprofile, |
|
1441 | showprofile=showprofile, | |
1441 | show=show) |
|
1442 | show=show) | |
1442 |
|
1443 | |||
1443 | if timerange != None: |
|
1444 | if timerange != None: | |
1444 | self.timerange = timerange |
|
1445 | self.timerange = timerange | |
1445 |
|
1446 | |||
1446 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1447 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1447 |
|
1448 | |||
1448 | if ymin == None: ymin = numpy.floor(numpy.nanmin(noisedB)) - 10.0 |
|
1449 | if ymin == None: ymin = numpy.floor(numpy.nanmin(noisedB)) - 10.0 | |
1449 | if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0 |
|
1450 | if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0 | |
1450 |
|
1451 | |||
1451 | self.FTP_WEI = ftp_wei |
|
1452 | self.FTP_WEI = ftp_wei | |
1452 | self.EXP_CODE = exp_code |
|
1453 | self.EXP_CODE = exp_code | |
1453 | self.SUB_EXP_CODE = sub_exp_code |
|
1454 | self.SUB_EXP_CODE = sub_exp_code | |
1454 | self.PLOT_POS = plot_pos |
|
1455 | self.PLOT_POS = plot_pos | |
1455 |
|
1456 | |||
1456 |
|
1457 | |||
1457 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1458 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1458 | self.isConfig = True |
|
1459 | self.isConfig = True | |
1459 | self.figfile = figfile |
|
1460 | self.figfile = figfile | |
1460 | self.xdata = numpy.array([]) |
|
1461 | self.xdata = numpy.array([]) | |
1461 | self.ydata = numpy.array([]) |
|
1462 | self.ydata = numpy.array([]) | |
1462 |
|
1463 | |||
1463 | update_figfile = True |
|
1464 | update_figfile = True | |
1464 |
|
1465 | |||
1465 | #open file beacon phase |
|
1466 | #open file beacon phase | |
1466 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1467 | path = '%s%03d' %(self.PREFIX, self.id) | |
1467 | noise_file = os.path.join(path,'%s.txt'%self.name) |
|
1468 | noise_file = os.path.join(path,'%s.txt'%self.name) | |
1468 | self.filename_noise = os.path.join(figpath,noise_file) |
|
1469 | self.filename_noise = os.path.join(figpath,noise_file) | |
1469 |
|
1470 | |||
1470 | self.setWinTitle(title) |
|
1471 | self.setWinTitle(title) | |
1471 |
|
1472 | |||
1472 | title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1473 | title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1473 |
|
1474 | |||
1474 | legendlabels = ["channel %d"%(idchannel) for idchannel in channelList] |
|
1475 | legendlabels = ["channel %d"%(idchannel) for idchannel in channelList] | |
1475 | axes = self.axesList[0] |
|
1476 | axes = self.axesList[0] | |
1476 |
|
1477 | |||
1477 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1478 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1478 |
|
1479 | |||
1479 | if len(self.ydata)==0: |
|
1480 | if len(self.ydata)==0: | |
1480 | self.ydata = noisedB.reshape(-1,1) |
|
1481 | self.ydata = noisedB.reshape(-1,1) | |
1481 | else: |
|
1482 | else: | |
1482 | self.ydata = numpy.hstack((self.ydata, noisedB.reshape(-1,1))) |
|
1483 | self.ydata = numpy.hstack((self.ydata, noisedB.reshape(-1,1))) | |
1483 |
|
1484 | |||
1484 |
|
1485 | |||
1485 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1486 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1486 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1487 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, | |
1487 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1488 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1488 | XAxisAsTime=True, grid='both' |
|
1489 | XAxisAsTime=True, grid='both' | |
1489 | ) |
|
1490 | ) | |
1490 |
|
1491 | |||
1491 | self.draw() |
|
1492 | self.draw() | |
1492 |
|
1493 | |||
1493 | if dataOut.ltctime >= self.xmax: |
|
1494 | if dataOut.ltctime >= self.xmax: | |
1494 | self.counter_imagwr = wr_period |
|
1495 | self.counter_imagwr = wr_period | |
1495 | self.isConfig = False |
|
1496 | self.isConfig = False | |
1496 | update_figfile = True |
|
1497 | update_figfile = True | |
1497 |
|
1498 | |||
1498 | self.save(figpath=figpath, |
|
1499 | self.save(figpath=figpath, | |
1499 | figfile=figfile, |
|
1500 | figfile=figfile, | |
1500 | save=save, |
|
1501 | save=save, | |
1501 | ftp=ftp, |
|
1502 | ftp=ftp, | |
1502 | wr_period=wr_period, |
|
1503 | wr_period=wr_period, | |
1503 | thisDatetime=thisDatetime, |
|
1504 | thisDatetime=thisDatetime, | |
1504 | update_figfile=update_figfile) |
|
1505 | update_figfile=update_figfile) | |
1505 |
|
1506 | |||
1506 | #store data beacon phase |
|
1507 | #store data beacon phase | |
1507 | if save: |
|
1508 | if save: | |
1508 | self.save_data(self.filename_noise, noisedB, thisDatetime) |
|
1509 | self.save_data(self.filename_noise, noisedB, thisDatetime) | |
1509 |
|
1510 | |||
1510 | class BeaconPhase(Figure): |
|
1511 | class BeaconPhase(Figure): | |
1511 |
|
1512 | |||
1512 | __isConfig = None |
|
1513 | __isConfig = None | |
1513 | __nsubplots = None |
|
1514 | __nsubplots = None | |
1514 |
|
1515 | |||
1515 | PREFIX = 'beacon_phase' |
|
1516 | PREFIX = 'beacon_phase' | |
1516 |
|
1517 | |||
1517 | def __init__(self, **kwargs): |
|
1518 | def __init__(self, **kwargs): | |
1518 | Figure.__init__(self, **kwargs) |
|
1519 | Figure.__init__(self, **kwargs) | |
1519 | self.timerange = 24*60*60 |
|
1520 | self.timerange = 24*60*60 | |
1520 | self.isConfig = False |
|
1521 | self.isConfig = False | |
1521 | self.__nsubplots = 1 |
|
1522 | self.__nsubplots = 1 | |
1522 | self.counter_imagwr = 0 |
|
1523 | self.counter_imagwr = 0 | |
1523 | self.WIDTH = 800 |
|
1524 | self.WIDTH = 800 | |
1524 | self.HEIGHT = 400 |
|
1525 | self.HEIGHT = 400 | |
1525 | self.WIDTHPROF = 120 |
|
1526 | self.WIDTHPROF = 120 | |
1526 | self.HEIGHTPROF = 0 |
|
1527 | self.HEIGHTPROF = 0 | |
1527 | self.xdata = None |
|
1528 | self.xdata = None | |
1528 | self.ydata = None |
|
1529 | self.ydata = None | |
1529 |
|
1530 | |||
1530 | self.PLOT_CODE = BEACON_CODE |
|
1531 | self.PLOT_CODE = BEACON_CODE | |
1531 |
|
1532 | |||
1532 | self.FTP_WEI = None |
|
1533 | self.FTP_WEI = None | |
1533 | self.EXP_CODE = None |
|
1534 | self.EXP_CODE = None | |
1534 | self.SUB_EXP_CODE = None |
|
1535 | self.SUB_EXP_CODE = None | |
1535 | self.PLOT_POS = None |
|
1536 | self.PLOT_POS = None | |
1536 |
|
1537 | |||
1537 | self.filename_phase = None |
|
1538 | self.filename_phase = None | |
1538 |
|
1539 | |||
1539 | self.figfile = None |
|
1540 | self.figfile = None | |
1540 |
|
1541 | |||
1541 | self.xmin = None |
|
1542 | self.xmin = None | |
1542 | self.xmax = None |
|
1543 | self.xmax = None | |
1543 |
|
1544 | |||
1544 | def getSubplots(self): |
|
1545 | def getSubplots(self): | |
1545 |
|
1546 | |||
1546 | ncol = 1 |
|
1547 | ncol = 1 | |
1547 | nrow = 1 |
|
1548 | nrow = 1 | |
1548 |
|
1549 | |||
1549 | return nrow, ncol |
|
1550 | return nrow, ncol | |
1550 |
|
1551 | |||
1551 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1552 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1552 |
|
1553 | |||
1553 | self.__showprofile = showprofile |
|
1554 | self.__showprofile = showprofile | |
1554 | self.nplots = nplots |
|
1555 | self.nplots = nplots | |
1555 |
|
1556 | |||
1556 | ncolspan = 7 |
|
1557 | ncolspan = 7 | |
1557 | colspan = 6 |
|
1558 | colspan = 6 | |
1558 | self.__nsubplots = 2 |
|
1559 | self.__nsubplots = 2 | |
1559 |
|
1560 | |||
1560 | self.createFigure(id = id, |
|
1561 | self.createFigure(id = id, | |
1561 | wintitle = wintitle, |
|
1562 | wintitle = wintitle, | |
1562 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1563 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1563 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1564 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1564 | show=show) |
|
1565 | show=show) | |
1565 |
|
1566 | |||
1566 | nrow, ncol = self.getSubplots() |
|
1567 | nrow, ncol = self.getSubplots() | |
1567 |
|
1568 | |||
1568 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1569 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1569 |
|
1570 | |||
1570 | def save_phase(self, filename_phase): |
|
1571 | def save_phase(self, filename_phase): | |
1571 | f = open(filename_phase,'w+') |
|
1572 | f = open(filename_phase,'w+') | |
1572 | f.write('\n\n') |
|
1573 | f.write('\n\n') | |
1573 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') |
|
1574 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') | |
1574 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) |
|
1575 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) | |
1575 | f.close() |
|
1576 | f.close() | |
1576 |
|
1577 | |||
1577 | def save_data(self, filename_phase, data, data_datetime): |
|
1578 | def save_data(self, filename_phase, data, data_datetime): | |
1578 | f=open(filename_phase,'a') |
|
1579 | f=open(filename_phase,'a') | |
1579 | timetuple_data = data_datetime.timetuple() |
|
1580 | timetuple_data = data_datetime.timetuple() | |
1580 | day = str(timetuple_data.tm_mday) |
|
1581 | day = str(timetuple_data.tm_mday) | |
1581 | month = str(timetuple_data.tm_mon) |
|
1582 | month = str(timetuple_data.tm_mon) | |
1582 | year = str(timetuple_data.tm_year) |
|
1583 | year = str(timetuple_data.tm_year) | |
1583 | hour = str(timetuple_data.tm_hour) |
|
1584 | hour = str(timetuple_data.tm_hour) | |
1584 | minute = str(timetuple_data.tm_min) |
|
1585 | minute = str(timetuple_data.tm_min) | |
1585 | second = str(timetuple_data.tm_sec) |
|
1586 | second = str(timetuple_data.tm_sec) | |
1586 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') |
|
1587 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') | |
1587 | f.close() |
|
1588 | f.close() | |
1588 |
|
1589 | |||
1589 |
|
1590 | |||
1590 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1591 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
1591 | xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None, |
|
1592 | xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None, | |
1592 | timerange=None, |
|
1593 | timerange=None, | |
1593 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1594 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1594 | server=None, folder=None, username=None, password=None, |
|
1595 | server=None, folder=None, username=None, password=None, | |
1595 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1596 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1596 |
|
1597 | |||
1597 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
1598 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
1598 | return |
|
1599 | return | |
1599 |
|
1600 | |||
1600 | if pairsList == None: |
|
1601 | if pairsList == None: | |
1601 | pairsIndexList = dataOut.pairsIndexList[:10] |
|
1602 | pairsIndexList = dataOut.pairsIndexList[:10] | |
1602 | else: |
|
1603 | else: | |
1603 | pairsIndexList = [] |
|
1604 | pairsIndexList = [] | |
1604 | for pair in pairsList: |
|
1605 | for pair in pairsList: | |
1605 | if pair not in dataOut.pairsList: |
|
1606 | if pair not in dataOut.pairsList: | |
1606 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
1607 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
1607 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
1608 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
1608 |
|
1609 | |||
1609 | if pairsIndexList == []: |
|
1610 | if pairsIndexList == []: | |
1610 | return |
|
1611 | return | |
1611 |
|
1612 | |||
1612 | # if len(pairsIndexList) > 4: |
|
1613 | # if len(pairsIndexList) > 4: | |
1613 | # pairsIndexList = pairsIndexList[0:4] |
|
1614 | # pairsIndexList = pairsIndexList[0:4] | |
1614 |
|
1615 | |||
1615 | hmin_index = None |
|
1616 | hmin_index = None | |
1616 | hmax_index = None |
|
1617 | hmax_index = None | |
1617 |
|
1618 | |||
1618 | if hmin != None and hmax != None: |
|
1619 | if hmin != None and hmax != None: | |
1619 | indexes = numpy.arange(dataOut.nHeights) |
|
1620 | indexes = numpy.arange(dataOut.nHeights) | |
1620 | hmin_list = indexes[dataOut.heightList >= hmin] |
|
1621 | hmin_list = indexes[dataOut.heightList >= hmin] | |
1621 | hmax_list = indexes[dataOut.heightList <= hmax] |
|
1622 | hmax_list = indexes[dataOut.heightList <= hmax] | |
1622 |
|
1623 | |||
1623 | if hmin_list.any(): |
|
1624 | if hmin_list.any(): | |
1624 | hmin_index = hmin_list[0] |
|
1625 | hmin_index = hmin_list[0] | |
1625 |
|
1626 | |||
1626 | if hmax_list.any(): |
|
1627 | if hmax_list.any(): | |
1627 | hmax_index = hmax_list[-1]+1 |
|
1628 | hmax_index = hmax_list[-1]+1 | |
1628 |
|
1629 | |||
1629 | x = dataOut.getTimeRange() |
|
1630 | x = dataOut.getTimeRange() | |
1630 | #y = dataOut.getHeiRange() |
|
1631 | #y = dataOut.getHeiRange() | |
1631 |
|
1632 | |||
1632 |
|
1633 | |||
1633 | thisDatetime = dataOut.datatime |
|
1634 | thisDatetime = dataOut.datatime | |
1634 |
|
1635 | |||
1635 | title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1636 | title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1636 | xlabel = "Local Time" |
|
1637 | xlabel = "Local Time" | |
1637 | ylabel = "Phase (degrees)" |
|
1638 | ylabel = "Phase (degrees)" | |
1638 |
|
1639 | |||
1639 | update_figfile = False |
|
1640 | update_figfile = False | |
1640 |
|
1641 | |||
1641 | nplots = len(pairsIndexList) |
|
1642 | nplots = len(pairsIndexList) | |
1642 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) |
|
1643 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) | |
1643 | phase_beacon = numpy.zeros(len(pairsIndexList)) |
|
1644 | phase_beacon = numpy.zeros(len(pairsIndexList)) | |
1644 | for i in range(nplots): |
|
1645 | for i in range(nplots): | |
1645 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
1646 | pair = dataOut.pairsList[pairsIndexList[i]] | |
1646 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0) |
|
1647 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0) | |
1647 | powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0) |
|
1648 | powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0) | |
1648 | powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0) |
|
1649 | powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0) | |
1649 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
1650 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
1650 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
1651 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
1651 |
|
1652 | |||
1652 | #print "Phase %d%d" %(pair[0], pair[1]) |
|
1653 | #print "Phase %d%d" %(pair[0], pair[1]) | |
1653 | #print phase[dataOut.beacon_heiIndexList] |
|
1654 | #print phase[dataOut.beacon_heiIndexList] | |
1654 |
|
1655 | |||
1655 | if dataOut.beacon_heiIndexList: |
|
1656 | if dataOut.beacon_heiIndexList: | |
1656 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) |
|
1657 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) | |
1657 | else: |
|
1658 | else: | |
1658 | phase_beacon[i] = numpy.average(phase) |
|
1659 | phase_beacon[i] = numpy.average(phase) | |
1659 |
|
1660 | |||
1660 | if not self.isConfig: |
|
1661 | if not self.isConfig: | |
1661 |
|
1662 | |||
1662 | nplots = len(pairsIndexList) |
|
1663 | nplots = len(pairsIndexList) | |
1663 |
|
1664 | |||
1664 | self.setup(id=id, |
|
1665 | self.setup(id=id, | |
1665 | nplots=nplots, |
|
1666 | nplots=nplots, | |
1666 | wintitle=wintitle, |
|
1667 | wintitle=wintitle, | |
1667 | showprofile=showprofile, |
|
1668 | showprofile=showprofile, | |
1668 | show=show) |
|
1669 | show=show) | |
1669 |
|
1670 | |||
1670 | if timerange != None: |
|
1671 | if timerange != None: | |
1671 | self.timerange = timerange |
|
1672 | self.timerange = timerange | |
1672 |
|
1673 | |||
1673 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1674 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1674 |
|
1675 | |||
1675 | if ymin == None: ymin = 0 |
|
1676 | if ymin == None: ymin = 0 | |
1676 | if ymax == None: ymax = 360 |
|
1677 | if ymax == None: ymax = 360 | |
1677 |
|
1678 | |||
1678 | self.FTP_WEI = ftp_wei |
|
1679 | self.FTP_WEI = ftp_wei | |
1679 | self.EXP_CODE = exp_code |
|
1680 | self.EXP_CODE = exp_code | |
1680 | self.SUB_EXP_CODE = sub_exp_code |
|
1681 | self.SUB_EXP_CODE = sub_exp_code | |
1681 | self.PLOT_POS = plot_pos |
|
1682 | self.PLOT_POS = plot_pos | |
1682 |
|
1683 | |||
1683 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1684 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1684 | self.isConfig = True |
|
1685 | self.isConfig = True | |
1685 | self.figfile = figfile |
|
1686 | self.figfile = figfile | |
1686 | self.xdata = numpy.array([]) |
|
1687 | self.xdata = numpy.array([]) | |
1687 | self.ydata = numpy.array([]) |
|
1688 | self.ydata = numpy.array([]) | |
1688 |
|
1689 | |||
1689 | update_figfile = True |
|
1690 | update_figfile = True | |
1690 |
|
1691 | |||
1691 | #open file beacon phase |
|
1692 | #open file beacon phase | |
1692 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1693 | path = '%s%03d' %(self.PREFIX, self.id) | |
1693 | beacon_file = os.path.join(path,'%s.txt'%self.name) |
|
1694 | beacon_file = os.path.join(path,'%s.txt'%self.name) | |
1694 | self.filename_phase = os.path.join(figpath,beacon_file) |
|
1695 | self.filename_phase = os.path.join(figpath,beacon_file) | |
1695 | #self.save_phase(self.filename_phase) |
|
1696 | #self.save_phase(self.filename_phase) | |
1696 |
|
1697 | |||
1697 |
|
1698 | |||
1698 | #store data beacon phase |
|
1699 | #store data beacon phase | |
1699 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) |
|
1700 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) | |
1700 |
|
1701 | |||
1701 | self.setWinTitle(title) |
|
1702 | self.setWinTitle(title) | |
1702 |
|
1703 | |||
1703 |
|
1704 | |||
1704 | title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1705 | title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1705 |
|
1706 | |||
1706 | legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList] |
|
1707 | legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList] | |
1707 |
|
1708 | |||
1708 | axes = self.axesList[0] |
|
1709 | axes = self.axesList[0] | |
1709 |
|
1710 | |||
1710 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1711 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1711 |
|
1712 | |||
1712 | if len(self.ydata)==0: |
|
1713 | if len(self.ydata)==0: | |
1713 | self.ydata = phase_beacon.reshape(-1,1) |
|
1714 | self.ydata = phase_beacon.reshape(-1,1) | |
1714 | else: |
|
1715 | else: | |
1715 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) |
|
1716 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) | |
1716 |
|
1717 | |||
1717 |
|
1718 | |||
1718 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1719 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1719 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1720 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, | |
1720 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1721 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1721 | XAxisAsTime=True, grid='both' |
|
1722 | XAxisAsTime=True, grid='both' | |
1722 | ) |
|
1723 | ) | |
1723 |
|
1724 | |||
1724 | self.draw() |
|
1725 | self.draw() | |
1725 |
|
1726 | |||
1726 | if dataOut.ltctime >= self.xmax: |
|
1727 | if dataOut.ltctime >= self.xmax: | |
1727 | self.counter_imagwr = wr_period |
|
1728 | self.counter_imagwr = wr_period | |
1728 | self.isConfig = False |
|
1729 | self.isConfig = False | |
1729 | update_figfile = True |
|
1730 | update_figfile = True | |
1730 |
|
1731 | |||
1731 | self.save(figpath=figpath, |
|
1732 | self.save(figpath=figpath, | |
1732 | figfile=figfile, |
|
1733 | figfile=figfile, | |
1733 | save=save, |
|
1734 | save=save, | |
1734 | ftp=ftp, |
|
1735 | ftp=ftp, | |
1735 | wr_period=wr_period, |
|
1736 | wr_period=wr_period, | |
1736 | thisDatetime=thisDatetime, |
|
1737 | thisDatetime=thisDatetime, | |
1737 | update_figfile=update_figfile) |
|
1738 | update_figfile=update_figfile) |
@@ -1,797 +1,760 | |||||
1 | import numpy |
|
1 | import numpy | |
2 |
|
2 | |||
3 | from jroproc_base import ProcessingUnit, Operation |
|
3 | from jroproc_base import ProcessingUnit, Operation | |
4 | from schainpy.model.data.jrodata import Spectra |
|
4 | from schainpy.model.data.jrodata import Spectra | |
5 | from schainpy.model.data.jrodata import hildebrand_sekhon |
|
5 | from schainpy.model.data.jrodata import hildebrand_sekhon | |
6 |
|
6 | |||
7 | class SpectraAFCProc(ProcessingUnit): |
|
7 | class SpectraAFCProc(ProcessingUnit): | |
8 |
|
8 | |||
9 | def __init__(self, **kwargs): |
|
9 | def __init__(self, **kwargs): | |
10 |
|
10 | |||
11 | ProcessingUnit.__init__(self, **kwargs) |
|
11 | ProcessingUnit.__init__(self, **kwargs) | |
12 |
|
12 | |||
13 | self.buffer = None |
|
13 | self.buffer = None | |
14 | self.firstdatatime = None |
|
14 | self.firstdatatime = None | |
15 | self.profIndex = 0 |
|
15 | self.profIndex = 0 | |
16 | self.dataOut = Spectra() |
|
16 | self.dataOut = Spectra() | |
17 | self.id_min = None |
|
17 | self.id_min = None | |
18 | self.id_max = None |
|
18 | self.id_max = None | |
19 |
|
19 | |||
20 | def __updateSpecFromVoltage(self): |
|
20 | def __updateSpecFromVoltage(self): | |
21 |
|
21 | |||
22 | self.dataOut.plotting = "spectra_acf" |
|
22 | self.dataOut.plotting = "spectra_acf" | |
23 |
|
23 | |||
24 | self.dataOut.timeZone = self.dataIn.timeZone |
|
24 | self.dataOut.timeZone = self.dataIn.timeZone | |
25 | self.dataOut.dstFlag = self.dataIn.dstFlag |
|
25 | self.dataOut.dstFlag = self.dataIn.dstFlag | |
26 | self.dataOut.errorCount = self.dataIn.errorCount |
|
26 | self.dataOut.errorCount = self.dataIn.errorCount | |
27 | self.dataOut.useLocalTime = self.dataIn.useLocalTime |
|
27 | self.dataOut.useLocalTime = self.dataIn.useLocalTime | |
28 |
|
28 | |||
29 | self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy() |
|
29 | self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy() | |
30 | self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy() |
|
30 | self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy() | |
31 | self.dataOut.ippSeconds = self.dataIn.getDeltaH()*(10**-6)/0.15 |
|
31 | self.dataOut.ippSeconds = self.dataIn.getDeltaH()*(10**-6)/0.15 | |
32 |
|
32 | |||
33 | self.dataOut.channelList = self.dataIn.channelList |
|
33 | self.dataOut.channelList = self.dataIn.channelList | |
34 | self.dataOut.heightList = self.dataIn.heightList |
|
34 | self.dataOut.heightList = self.dataIn.heightList | |
35 | self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
35 | self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
36 |
|
36 | |||
37 | self.dataOut.nBaud = self.dataIn.nBaud |
|
37 | self.dataOut.nBaud = self.dataIn.nBaud | |
38 | self.dataOut.nCode = self.dataIn.nCode |
|
38 | self.dataOut.nCode = self.dataIn.nCode | |
39 | self.dataOut.code = self.dataIn.code |
|
39 | self.dataOut.code = self.dataIn.code | |
40 | # self.dataOut.nProfiles = self.dataOut.nFFTPoints |
|
40 | # self.dataOut.nProfiles = self.dataOut.nFFTPoints | |
41 |
|
41 | |||
42 | self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock |
|
42 | self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock | |
43 | self.dataOut.utctime = self.firstdatatime |
|
43 | self.dataOut.utctime = self.firstdatatime | |
44 | self.dataOut.flagDecodeData = self.dataIn.flagDecodeData #asumo q la data esta decodificada |
|
44 | self.dataOut.flagDecodeData = self.dataIn.flagDecodeData #asumo q la data esta decodificada | |
45 | self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip |
|
45 | self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip | |
46 | self.dataOut.flagShiftFFT = False |
|
46 | self.dataOut.flagShiftFFT = False | |
47 |
|
47 | |||
48 | self.dataOut.nCohInt = self.dataIn.nCohInt |
|
48 | self.dataOut.nCohInt = self.dataIn.nCohInt | |
49 | self.dataOut.nIncohInt = 1 |
|
49 | self.dataOut.nIncohInt = 1 | |
50 |
|
50 | |||
51 | self.dataOut.windowOfFilter = self.dataIn.windowOfFilter |
|
51 | self.dataOut.windowOfFilter = self.dataIn.windowOfFilter | |
52 |
|
52 | |||
53 | self.dataOut.frequency = self.dataIn.frequency |
|
53 | self.dataOut.frequency = self.dataIn.frequency | |
54 | self.dataOut.realtime = self.dataIn.realtime |
|
54 | self.dataOut.realtime = self.dataIn.realtime | |
55 |
|
55 | |||
56 | self.dataOut.azimuth = self.dataIn.azimuth |
|
56 | self.dataOut.azimuth = self.dataIn.azimuth | |
57 | self.dataOut.zenith = self.dataIn.zenith |
|
57 | self.dataOut.zenith = self.dataIn.zenith | |
58 |
|
58 | |||
59 | self.dataOut.beam.codeList = self.dataIn.beam.codeList |
|
59 | self.dataOut.beam.codeList = self.dataIn.beam.codeList | |
60 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList |
|
60 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList | |
61 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList |
|
61 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList | |
62 |
|
62 | |||
63 | def __decodeData(self, nProfiles, code): |
|
63 | def __decodeData(self, nProfiles, code): | |
64 |
|
64 | |||
65 | if code is None: |
|
65 | if code is None: | |
66 | return |
|
66 | return | |
67 |
|
67 | |||
68 | for i in range(nProfiles): |
|
68 | for i in range(nProfiles): | |
69 | self.buffer[:,i,:] = self.buffer[:,i,:]*code[0][i] |
|
69 | self.buffer[:,i,:] = self.buffer[:,i,:]*code[0][i] | |
70 |
|
70 | |||
71 | def __getFft(self): |
|
71 | def __getFft(self): | |
72 | """ |
|
72 | """ | |
73 | Convierte valores de Voltaje a Spectra |
|
73 | Convierte valores de Voltaje a Spectra | |
74 |
|
74 | |||
75 | Affected: |
|
75 | Affected: | |
76 | self.dataOut.data_spc |
|
76 | self.dataOut.data_spc | |
77 | self.dataOut.data_cspc |
|
77 | self.dataOut.data_cspc | |
78 | self.dataOut.data_dc |
|
78 | self.dataOut.data_dc | |
79 | self.dataOut.heightList |
|
79 | self.dataOut.heightList | |
80 | self.profIndex |
|
80 | self.profIndex | |
81 | self.buffer |
|
81 | self.buffer | |
82 | self.dataOut.flagNoData |
|
82 | self.dataOut.flagNoData | |
83 | """ |
|
83 | """ | |
84 | nsegments = self.dataOut.nHeights |
|
84 | nsegments = self.dataOut.nHeights | |
85 |
|
85 | |||
86 | _fft_buffer = numpy.zeros((self.dataOut.nChannels, self.dataOut.nProfiles, nsegments), dtype='complex') |
|
86 | _fft_buffer = numpy.zeros((self.dataOut.nChannels, self.dataOut.nProfiles, nsegments), dtype='complex') | |
87 |
|
87 | |||
88 | for i in range(nsegments): |
|
88 | for i in range(nsegments): | |
89 | try: |
|
89 | try: | |
90 | _fft_buffer[:,:,i] = self.buffer[:,i:i+self.dataOut.nProfiles] |
|
90 | _fft_buffer[:,:,i] = self.buffer[:,i:i+self.dataOut.nProfiles] | |
91 |
|
91 | |||
92 | if self.code is not None: |
|
92 | if self.code is not None: | |
93 | _fft_buffer[:,:,i] = _fft_buffer[:,:,i]*self.code[0] |
|
93 | _fft_buffer[:,:,i] = _fft_buffer[:,:,i]*self.code[0] | |
94 | except: |
|
94 | except: | |
95 | pass |
|
95 | pass | |
96 |
|
96 | |||
97 | fft_volt = numpy.fft.fft(_fft_buffer, n=self.dataOut.nFFTPoints, axis=1) |
|
97 | fft_volt = numpy.fft.fft(_fft_buffer, n=self.dataOut.nFFTPoints, axis=1) | |
98 | fft_volt = fft_volt.astype(numpy.dtype('complex')) |
|
98 | fft_volt = fft_volt.astype(numpy.dtype('complex')) | |
99 | dc = fft_volt[:,0,:] |
|
99 | dc = fft_volt[:,0,:] | |
100 |
|
100 | |||
101 | #calculo de self-spectra |
|
101 | #calculo de self-spectra | |
102 | spc = fft_volt * numpy.conjugate(fft_volt) |
|
102 | spc = fft_volt * numpy.conjugate(fft_volt) | |
103 | data = numpy.fft.ifft(spc, axis=1) |
|
103 | data = numpy.fft.ifft(spc, axis=1) | |
104 | data = numpy.fft.fftshift(data, axes=(1,)) |
|
104 | data = numpy.fft.fftshift(data, axes=(1,)) | |
105 |
|
105 | |||
106 | spc = data |
|
106 | spc = data | |
107 |
|
107 | |||
108 | blocksize = 0 |
|
108 | blocksize = 0 | |
109 | blocksize += dc.size |
|
109 | blocksize += dc.size | |
110 | blocksize += spc.size |
|
110 | blocksize += spc.size | |
111 |
|
111 | |||
112 | cspc = None |
|
112 | cspc = None | |
113 | pairIndex = 0 |
|
113 | pairIndex = 0 | |
114 |
|
114 | |||
115 | if self.dataOut.pairsList != None: |
|
115 | if self.dataOut.pairsList != None: | |
116 | #calculo de cross-spectra |
|
116 | #calculo de cross-spectra | |
117 | cspc = numpy.zeros((self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') |
|
117 | cspc = numpy.zeros((self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex') | |
118 | for pair in self.dataOut.pairsList: |
|
118 | for pair in self.dataOut.pairsList: | |
119 | if pair[0] not in self.dataOut.channelList: |
|
119 | if pair[0] not in self.dataOut.channelList: | |
120 | raise ValueError, "Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList)) |
|
120 | raise ValueError, "Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList)) | |
121 | if pair[1] not in self.dataOut.channelList: |
|
121 | if pair[1] not in self.dataOut.channelList: | |
122 | raise ValueError, "Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList)) |
|
122 | raise ValueError, "Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList)) | |
123 |
|
123 | |||
124 | chan_index0 = self.dataOut.channelList.index(pair[0]) |
|
124 | chan_index0 = self.dataOut.channelList.index(pair[0]) | |
125 | chan_index1 = self.dataOut.channelList.index(pair[1]) |
|
125 | chan_index1 = self.dataOut.channelList.index(pair[1]) | |
126 |
|
126 | |||
127 | cspc[pairIndex,:,:] = fft_volt[chan_index0,:,:] * numpy.conjugate(fft_volt[chan_index1,:,:]) |
|
127 | cspc[pairIndex,:,:] = fft_volt[chan_index0,:,:] * numpy.conjugate(fft_volt[chan_index1,:,:]) | |
128 | pairIndex += 1 |
|
128 | pairIndex += 1 | |
129 | blocksize += cspc.size |
|
129 | blocksize += cspc.size | |
130 |
|
130 | |||
131 | self.dataOut.data_spc = spc |
|
131 | self.dataOut.data_spc = spc | |
132 | self.dataOut.data_cspc = cspc |
|
132 | self.dataOut.data_cspc = cspc | |
133 | self.dataOut.data_dc = dc |
|
133 | self.dataOut.data_dc = dc | |
134 | self.dataOut.blockSize = blocksize |
|
134 | self.dataOut.blockSize = blocksize | |
135 | self.dataOut.flagShiftFFT = True |
|
135 | self.dataOut.flagShiftFFT = True | |
136 |
|
136 | |||
137 | def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], code=None, nCode=1, nBaud=1,real= None, imag=None): |
|
137 | def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], code=None, nCode=1, nBaud=1,real= None, imag=None): | |
138 |
|
138 | |||
139 | self.dataOut.flagNoData = True |
|
139 | self.dataOut.flagNoData = True | |
140 |
|
140 | |||
141 | if self.dataIn.type == "Spectra": |
|
141 | if self.dataIn.type == "Spectra": | |
142 | self.dataOut.copy(self.dataIn) |
|
142 | self.dataOut.copy(self.dataIn) | |
143 | spc = self.dataOut.data_spc |
|
143 | spc = self.dataOut.data_spc | |
144 |
|
|
144 | data = numpy.fft.fftshift( spc, axes=(1,)) | |
145 |
data = numpy.fft. |
|
145 | data = numpy.fft.ifft(data, axis=1) | |
|
146 | data = numpy.fft.fftshift( data, axes=(1,)) | |||
146 | acf = numpy.abs(data) # Autocorrelacion LLAMAR A ESTE VALOR ACF |
|
147 | acf = numpy.abs(data) # Autocorrelacion LLAMAR A ESTE VALOR ACF | |
147 | if real: |
|
148 | if real: | |
148 | acf = data.real |
|
149 | acf = data.real | |
149 | if imag: |
|
150 | if imag: | |
150 | acf = data.imag |
|
151 | acf = data.imag | |
151 | shape = acf.shape # nchannels, nprofiles, nsamples |
|
152 | shape = acf.shape # nchannels, nprofiles, nsamples //nchannles, lags , alturas | |
152 |
|
153 | |||
153 | #import matplotlib.pyplot as plt |
|
|||
154 | #print "test",acf.shape |
|
|||
155 | #acf_tmp=acf[0,:,] |
|
|||
156 | #plt.plot(acf_tmp) |
|
|||
157 | #plt.show() |
|
|||
158 | #import time |
|
|||
159 | #time.sleep(10) |
|
|||
160 |
|
||||
161 | for j in range(shape[0]): |
|
154 | for j in range(shape[0]): | |
162 |
for i in range(shape[ |
|
155 | for i in range(shape[2]): | |
163 | tmp = numpy.argmax(acf[j,:,i]) |
|
156 | tmp = shape[1]/2 | |
164 | if i>30: |
|
157 | value = (acf[j,:,i][tmp-1]+acf[j,:,i][tmp+1])/2.0 | |
165 | value = (acf[j,:,i][tmp+3]+acf[j,:,i][tmp+4])/2.0 |
|
158 | acf[j,:,i][tmp] = value | |
166 | acf[j,:,i][tmp] = value |
|
|||
167 | acf[j,:,i][tmp-1] = value |
|
|||
168 | acf[j,:,i][tmp+1] = value |
|
|||
169 | acf[j,:,i][tmp-2] = value |
|
|||
170 | acf[j,:,i][tmp+2] = value |
|
|||
171 |
|
||||
172 | import scipy as sp |
|
|||
173 | from scipy import signal |
|
|||
174 | #acf[3,:,i] = sp.signal.medfilt(acf[3,:,i],21) |
|
|||
175 |
|
||||
176 |
|
||||
177 |
|
||||
178 | #print numpy.argmax(acf[0,:,85]) |
|
|||
179 | #import matplotlib.pyplot as plt |
|
|||
180 | #plt.plot(acf[0,:,85]) |
|
|||
181 | #a= acf[0,:,85] |
|
|||
182 | #b= acf[0,:,0] |
|
|||
183 | #print a[200],a[198],a[199], a[201],a[202],a[203] |
|
|||
184 | #plt.show() |
|
|||
185 | #import time |
|
|||
186 | #time.sleep(10) |
|
|||
187 |
|
||||
188 |
|
||||
189 | # Normalizando |
|
159 | # Normalizando | |
190 | for i in range(shape[0]): |
|
160 | for i in range(shape[0]): | |
191 | for j in range(shape[2]): |
|
161 | for j in range(shape[2]): | |
192 | acf[i,:,j]= acf[i,:,j] / numpy.max(numpy.abs(acf[i,:,j])) |
|
162 | acf[i,:,j]= acf[i,:,j] / numpy.max(numpy.abs(acf[i,:,j])) | |
193 |
|
163 | |||
194 | #import matplotlib.pyplot as plt |
|
|||
195 | #plt.plot(acf[0,:,85]) |
|
|||
196 | #plt.show() |
|
|||
197 | #import time |
|
|||
198 | #time.sleep(20) |
|
|||
199 |
|
||||
200 |
|
||||
201 | self.dataOut.data_acf = acf |
|
164 | self.dataOut.data_acf = acf | |
202 | return True |
|
165 | return True | |
203 |
|
166 | |||
204 | if code is not None: |
|
167 | if code is not None: | |
205 | self.code = numpy.array(code).reshape(nCode,nBaud) |
|
168 | self.code = numpy.array(code).reshape(nCode,nBaud) | |
206 | else: |
|
169 | else: | |
207 | self.code = None |
|
170 | self.code = None | |
208 |
|
171 | |||
209 | if self.dataIn.type == "Voltage": |
|
172 | if self.dataIn.type == "Voltage": | |
210 |
|
173 | |||
211 | if nFFTPoints == None: |
|
174 | if nFFTPoints == None: | |
212 | raise ValueError, "This SpectraProc.run() need nFFTPoints input variable" |
|
175 | raise ValueError, "This SpectraProc.run() need nFFTPoints input variable" | |
213 |
|
176 | |||
214 | if nProfiles == None: |
|
177 | if nProfiles == None: | |
215 | nProfiles = nFFTPoints |
|
178 | nProfiles = nFFTPoints | |
216 |
|
179 | |||
217 | self.dataOut.ippFactor = 1 |
|
180 | self.dataOut.ippFactor = 1 | |
218 |
|
181 | |||
219 | self.dataOut.nFFTPoints = nFFTPoints |
|
182 | self.dataOut.nFFTPoints = nFFTPoints | |
220 | self.dataOut.nProfiles = nProfiles |
|
183 | self.dataOut.nProfiles = nProfiles | |
221 | self.dataOut.pairsList = pairsList |
|
184 | self.dataOut.pairsList = pairsList | |
222 |
|
185 | |||
223 | # if self.buffer is None: |
|
186 | # if self.buffer is None: | |
224 | # self.buffer = numpy.zeros( (self.dataIn.nChannels, nProfiles, self.dataIn.nHeights), |
|
187 | # self.buffer = numpy.zeros( (self.dataIn.nChannels, nProfiles, self.dataIn.nHeights), | |
225 | # dtype='complex') |
|
188 | # dtype='complex') | |
226 |
|
189 | |||
227 | if not self.dataIn.flagDataAsBlock: |
|
190 | if not self.dataIn.flagDataAsBlock: | |
228 | self.buffer = self.dataIn.data.copy() |
|
191 | self.buffer = self.dataIn.data.copy() | |
229 |
|
192 | |||
230 | # for i in range(self.dataIn.nHeights): |
|
193 | # for i in range(self.dataIn.nHeights): | |
231 | # self.buffer[:, self.profIndex, self.profIndex:] = voltage_data[:,:self.dataIn.nHeights - self.profIndex] |
|
194 | # self.buffer[:, self.profIndex, self.profIndex:] = voltage_data[:,:self.dataIn.nHeights - self.profIndex] | |
232 | # |
|
195 | # | |
233 | # self.profIndex += 1 |
|
196 | # self.profIndex += 1 | |
234 |
|
197 | |||
235 | else: |
|
198 | else: | |
236 | raise ValueError, "" |
|
199 | raise ValueError, "" | |
237 |
|
200 | |||
238 | self.firstdatatime = self.dataIn.utctime |
|
201 | self.firstdatatime = self.dataIn.utctime | |
239 |
|
202 | |||
240 | self.profIndex == nProfiles |
|
203 | self.profIndex == nProfiles | |
241 |
|
204 | |||
242 | self.__updateSpecFromVoltage() |
|
205 | self.__updateSpecFromVoltage() | |
243 |
|
206 | |||
244 | self.__getFft() |
|
207 | self.__getFft() | |
245 |
|
208 | |||
246 | self.dataOut.flagNoData = False |
|
209 | self.dataOut.flagNoData = False | |
247 |
|
210 | |||
248 | return True |
|
211 | return True | |
249 |
|
212 | |||
250 | raise ValueError, "The type of input object '%s' is not valid"%(self.dataIn.type) |
|
213 | raise ValueError, "The type of input object '%s' is not valid"%(self.dataIn.type) | |
251 |
|
214 | |||
252 | def __selectPairs(self, pairsList): |
|
215 | def __selectPairs(self, pairsList): | |
253 |
|
216 | |||
254 | if channelList == None: |
|
217 | if channelList == None: | |
255 | return |
|
218 | return | |
256 |
|
219 | |||
257 | pairsIndexListSelected = [] |
|
220 | pairsIndexListSelected = [] | |
258 |
|
221 | |||
259 | for thisPair in pairsList: |
|
222 | for thisPair in pairsList: | |
260 |
|
223 | |||
261 | if thisPair not in self.dataOut.pairsList: |
|
224 | if thisPair not in self.dataOut.pairsList: | |
262 | continue |
|
225 | continue | |
263 |
|
226 | |||
264 | pairIndex = self.dataOut.pairsList.index(thisPair) |
|
227 | pairIndex = self.dataOut.pairsList.index(thisPair) | |
265 |
|
228 | |||
266 | pairsIndexListSelected.append(pairIndex) |
|
229 | pairsIndexListSelected.append(pairIndex) | |
267 |
|
230 | |||
268 | if not pairsIndexListSelected: |
|
231 | if not pairsIndexListSelected: | |
269 | self.dataOut.data_cspc = None |
|
232 | self.dataOut.data_cspc = None | |
270 | self.dataOut.pairsList = [] |
|
233 | self.dataOut.pairsList = [] | |
271 | return |
|
234 | return | |
272 |
|
235 | |||
273 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected] |
|
236 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected] | |
274 | self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected] |
|
237 | self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected] | |
275 |
|
238 | |||
276 | return |
|
239 | return | |
277 |
|
240 | |||
278 | def __selectPairsByChannel(self, channelList=None): |
|
241 | def __selectPairsByChannel(self, channelList=None): | |
279 |
|
242 | |||
280 | if channelList == None: |
|
243 | if channelList == None: | |
281 | return |
|
244 | return | |
282 |
|
245 | |||
283 | pairsIndexListSelected = [] |
|
246 | pairsIndexListSelected = [] | |
284 | for pairIndex in self.dataOut.pairsIndexList: |
|
247 | for pairIndex in self.dataOut.pairsIndexList: | |
285 | #First pair |
|
248 | #First pair | |
286 | if self.dataOut.pairsList[pairIndex][0] not in channelList: |
|
249 | if self.dataOut.pairsList[pairIndex][0] not in channelList: | |
287 | continue |
|
250 | continue | |
288 | #Second pair |
|
251 | #Second pair | |
289 | if self.dataOut.pairsList[pairIndex][1] not in channelList: |
|
252 | if self.dataOut.pairsList[pairIndex][1] not in channelList: | |
290 | continue |
|
253 | continue | |
291 |
|
254 | |||
292 | pairsIndexListSelected.append(pairIndex) |
|
255 | pairsIndexListSelected.append(pairIndex) | |
293 |
|
256 | |||
294 | if not pairsIndexListSelected: |
|
257 | if not pairsIndexListSelected: | |
295 | self.dataOut.data_cspc = None |
|
258 | self.dataOut.data_cspc = None | |
296 | self.dataOut.pairsList = [] |
|
259 | self.dataOut.pairsList = [] | |
297 | return |
|
260 | return | |
298 |
|
261 | |||
299 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected] |
|
262 | self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected] | |
300 | self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected] |
|
263 | self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected] | |
301 |
|
264 | |||
302 | return |
|
265 | return | |
303 |
|
266 | |||
304 | def selectChannels(self, channelList): |
|
267 | def selectChannels(self, channelList): | |
305 |
|
268 | |||
306 | channelIndexList = [] |
|
269 | channelIndexList = [] | |
307 |
|
270 | |||
308 | for channel in channelList: |
|
271 | for channel in channelList: | |
309 | if channel not in self.dataOut.channelList: |
|
272 | if channel not in self.dataOut.channelList: | |
310 | raise ValueError, "Error selecting channels, Channel %d is not valid.\nAvailable channels = %s" %(channel, str(self.dataOut.channelList)) |
|
273 | raise ValueError, "Error selecting channels, Channel %d is not valid.\nAvailable channels = %s" %(channel, str(self.dataOut.channelList)) | |
311 |
|
274 | |||
312 | index = self.dataOut.channelList.index(channel) |
|
275 | index = self.dataOut.channelList.index(channel) | |
313 | channelIndexList.append(index) |
|
276 | channelIndexList.append(index) | |
314 |
|
277 | |||
315 | self.selectChannelsByIndex(channelIndexList) |
|
278 | self.selectChannelsByIndex(channelIndexList) | |
316 |
|
279 | |||
317 | def selectChannelsByIndex(self, channelIndexList): |
|
280 | def selectChannelsByIndex(self, channelIndexList): | |
318 | """ |
|
281 | """ | |
319 | Selecciona un bloque de datos en base a canales segun el channelIndexList |
|
282 | Selecciona un bloque de datos en base a canales segun el channelIndexList | |
320 |
|
283 | |||
321 | Input: |
|
284 | Input: | |
322 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] |
|
285 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] | |
323 |
|
286 | |||
324 | Affected: |
|
287 | Affected: | |
325 | self.dataOut.data_spc |
|
288 | self.dataOut.data_spc | |
326 | self.dataOut.channelIndexList |
|
289 | self.dataOut.channelIndexList | |
327 | self.dataOut.nChannels |
|
290 | self.dataOut.nChannels | |
328 |
|
291 | |||
329 | Return: |
|
292 | Return: | |
330 | None |
|
293 | None | |
331 | """ |
|
294 | """ | |
332 |
|
295 | |||
333 | for channelIndex in channelIndexList: |
|
296 | for channelIndex in channelIndexList: | |
334 | if channelIndex not in self.dataOut.channelIndexList: |
|
297 | if channelIndex not in self.dataOut.channelIndexList: | |
335 | raise ValueError, "Error selecting channels: The value %d in channelIndexList is not valid.\nAvailable channel indexes = " %(channelIndex, self.dataOut.channelIndexList) |
|
298 | raise ValueError, "Error selecting channels: The value %d in channelIndexList is not valid.\nAvailable channel indexes = " %(channelIndex, self.dataOut.channelIndexList) | |
336 |
|
299 | |||
337 | # nChannels = len(channelIndexList) |
|
300 | # nChannels = len(channelIndexList) | |
338 |
|
301 | |||
339 | data_spc = self.dataOut.data_spc[channelIndexList,:] |
|
302 | data_spc = self.dataOut.data_spc[channelIndexList,:] | |
340 | data_dc = self.dataOut.data_dc[channelIndexList,:] |
|
303 | data_dc = self.dataOut.data_dc[channelIndexList,:] | |
341 |
|
304 | |||
342 | self.dataOut.data_spc = data_spc |
|
305 | self.dataOut.data_spc = data_spc | |
343 | self.dataOut.data_dc = data_dc |
|
306 | self.dataOut.data_dc = data_dc | |
344 |
|
307 | |||
345 | self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] |
|
308 | self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] | |
346 | # self.dataOut.nChannels = nChannels |
|
309 | # self.dataOut.nChannels = nChannels | |
347 |
|
310 | |||
348 | self.__selectPairsByChannel(self.dataOut.channelList) |
|
311 | self.__selectPairsByChannel(self.dataOut.channelList) | |
349 |
|
312 | |||
350 | return 1 |
|
313 | return 1 | |
351 |
|
314 | |||
352 | def selectHeights(self, minHei, maxHei): |
|
315 | def selectHeights(self, minHei, maxHei): | |
353 | """ |
|
316 | """ | |
354 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
317 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango | |
355 | minHei <= height <= maxHei |
|
318 | minHei <= height <= maxHei | |
356 |
|
319 | |||
357 | Input: |
|
320 | Input: | |
358 | minHei : valor minimo de altura a considerar |
|
321 | minHei : valor minimo de altura a considerar | |
359 | maxHei : valor maximo de altura a considerar |
|
322 | maxHei : valor maximo de altura a considerar | |
360 |
|
323 | |||
361 | Affected: |
|
324 | Affected: | |
362 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
325 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex | |
363 |
|
326 | |||
364 | Return: |
|
327 | Return: | |
365 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
328 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
366 | """ |
|
329 | """ | |
367 |
|
330 | |||
368 | if (minHei > maxHei): |
|
331 | if (minHei > maxHei): | |
369 | raise ValueError, "Error selecting heights: Height range (%d,%d) is not valid" % (minHei, maxHei) |
|
332 | raise ValueError, "Error selecting heights: Height range (%d,%d) is not valid" % (minHei, maxHei) | |
370 |
|
333 | |||
371 | if (minHei < self.dataOut.heightList[0]): |
|
334 | if (minHei < self.dataOut.heightList[0]): | |
372 | minHei = self.dataOut.heightList[0] |
|
335 | minHei = self.dataOut.heightList[0] | |
373 |
|
336 | |||
374 | if (maxHei > self.dataOut.heightList[-1]): |
|
337 | if (maxHei > self.dataOut.heightList[-1]): | |
375 | maxHei = self.dataOut.heightList[-1] |
|
338 | maxHei = self.dataOut.heightList[-1] | |
376 |
|
339 | |||
377 | minIndex = 0 |
|
340 | minIndex = 0 | |
378 | maxIndex = 0 |
|
341 | maxIndex = 0 | |
379 | heights = self.dataOut.heightList |
|
342 | heights = self.dataOut.heightList | |
380 |
|
343 | |||
381 | inda = numpy.where(heights >= minHei) |
|
344 | inda = numpy.where(heights >= minHei) | |
382 | indb = numpy.where(heights <= maxHei) |
|
345 | indb = numpy.where(heights <= maxHei) | |
383 |
|
346 | |||
384 | try: |
|
347 | try: | |
385 | minIndex = inda[0][0] |
|
348 | minIndex = inda[0][0] | |
386 | except: |
|
349 | except: | |
387 | minIndex = 0 |
|
350 | minIndex = 0 | |
388 |
|
351 | |||
389 | try: |
|
352 | try: | |
390 | maxIndex = indb[0][-1] |
|
353 | maxIndex = indb[0][-1] | |
391 | except: |
|
354 | except: | |
392 | maxIndex = len(heights) |
|
355 | maxIndex = len(heights) | |
393 |
|
356 | |||
394 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
357 | self.selectHeightsByIndex(minIndex, maxIndex) | |
395 |
|
358 | |||
396 | return 1 |
|
359 | return 1 | |
397 |
|
360 | |||
398 | def getBeaconSignal(self, tauindex = 0, channelindex = 0, hei_ref=None): |
|
361 | def getBeaconSignal(self, tauindex = 0, channelindex = 0, hei_ref=None): | |
399 | newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex]) |
|
362 | newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex]) | |
400 |
|
363 | |||
401 | if hei_ref != None: |
|
364 | if hei_ref != None: | |
402 | newheis = numpy.where(self.dataOut.heightList>hei_ref) |
|
365 | newheis = numpy.where(self.dataOut.heightList>hei_ref) | |
403 |
|
366 | |||
404 | minIndex = min(newheis[0]) |
|
367 | minIndex = min(newheis[0]) | |
405 | maxIndex = max(newheis[0]) |
|
368 | maxIndex = max(newheis[0]) | |
406 | data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1] |
|
369 | data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1] | |
407 | heightList = self.dataOut.heightList[minIndex:maxIndex+1] |
|
370 | heightList = self.dataOut.heightList[minIndex:maxIndex+1] | |
408 |
|
371 | |||
409 | # determina indices |
|
372 | # determina indices | |
410 | nheis = int(self.dataOut.radarControllerHeaderObj.txB/(self.dataOut.heightList[1]-self.dataOut.heightList[0])) |
|
373 | nheis = int(self.dataOut.radarControllerHeaderObj.txB/(self.dataOut.heightList[1]-self.dataOut.heightList[0])) | |
411 | avg_dB = 10*numpy.log10(numpy.sum(data_spc[channelindex,:,:],axis=0)) |
|
374 | avg_dB = 10*numpy.log10(numpy.sum(data_spc[channelindex,:,:],axis=0)) | |
412 | beacon_dB = numpy.sort(avg_dB)[-nheis:] |
|
375 | beacon_dB = numpy.sort(avg_dB)[-nheis:] | |
413 | beacon_heiIndexList = [] |
|
376 | beacon_heiIndexList = [] | |
414 | for val in avg_dB.tolist(): |
|
377 | for val in avg_dB.tolist(): | |
415 | if val >= beacon_dB[0]: |
|
378 | if val >= beacon_dB[0]: | |
416 | beacon_heiIndexList.append(avg_dB.tolist().index(val)) |
|
379 | beacon_heiIndexList.append(avg_dB.tolist().index(val)) | |
417 |
|
380 | |||
418 | #data_spc = data_spc[:,:,beacon_heiIndexList] |
|
381 | #data_spc = data_spc[:,:,beacon_heiIndexList] | |
419 | data_cspc = None |
|
382 | data_cspc = None | |
420 | if self.dataOut.data_cspc is not None: |
|
383 | if self.dataOut.data_cspc is not None: | |
421 | data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1] |
|
384 | data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1] | |
422 | #data_cspc = data_cspc[:,:,beacon_heiIndexList] |
|
385 | #data_cspc = data_cspc[:,:,beacon_heiIndexList] | |
423 |
|
386 | |||
424 | data_dc = None |
|
387 | data_dc = None | |
425 | if self.dataOut.data_dc is not None: |
|
388 | if self.dataOut.data_dc is not None: | |
426 | data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1] |
|
389 | data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1] | |
427 | #data_dc = data_dc[:,beacon_heiIndexList] |
|
390 | #data_dc = data_dc[:,beacon_heiIndexList] | |
428 |
|
391 | |||
429 | self.dataOut.data_spc = data_spc |
|
392 | self.dataOut.data_spc = data_spc | |
430 | self.dataOut.data_cspc = data_cspc |
|
393 | self.dataOut.data_cspc = data_cspc | |
431 | self.dataOut.data_dc = data_dc |
|
394 | self.dataOut.data_dc = data_dc | |
432 | self.dataOut.heightList = heightList |
|
395 | self.dataOut.heightList = heightList | |
433 | self.dataOut.beacon_heiIndexList = beacon_heiIndexList |
|
396 | self.dataOut.beacon_heiIndexList = beacon_heiIndexList | |
434 |
|
397 | |||
435 | return 1 |
|
398 | return 1 | |
436 |
|
399 | |||
437 |
|
400 | |||
438 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
401 | def selectHeightsByIndex(self, minIndex, maxIndex): | |
439 | """ |
|
402 | """ | |
440 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
403 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango | |
441 | minIndex <= index <= maxIndex |
|
404 | minIndex <= index <= maxIndex | |
442 |
|
405 | |||
443 | Input: |
|
406 | Input: | |
444 | minIndex : valor de indice minimo de altura a considerar |
|
407 | minIndex : valor de indice minimo de altura a considerar | |
445 | maxIndex : valor de indice maximo de altura a considerar |
|
408 | maxIndex : valor de indice maximo de altura a considerar | |
446 |
|
409 | |||
447 | Affected: |
|
410 | Affected: | |
448 | self.dataOut.data_spc |
|
411 | self.dataOut.data_spc | |
449 | self.dataOut.data_cspc |
|
412 | self.dataOut.data_cspc | |
450 | self.dataOut.data_dc |
|
413 | self.dataOut.data_dc | |
451 | self.dataOut.heightList |
|
414 | self.dataOut.heightList | |
452 |
|
415 | |||
453 | Return: |
|
416 | Return: | |
454 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
417 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
455 | """ |
|
418 | """ | |
456 |
|
419 | |||
457 | if (minIndex < 0) or (minIndex > maxIndex): |
|
420 | if (minIndex < 0) or (minIndex > maxIndex): | |
458 | raise ValueError, "Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex) |
|
421 | raise ValueError, "Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex) | |
459 |
|
422 | |||
460 | if (maxIndex >= self.dataOut.nHeights): |
|
423 | if (maxIndex >= self.dataOut.nHeights): | |
461 | maxIndex = self.dataOut.nHeights-1 |
|
424 | maxIndex = self.dataOut.nHeights-1 | |
462 |
|
425 | |||
463 | #Spectra |
|
426 | #Spectra | |
464 | data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1] |
|
427 | data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1] | |
465 |
|
428 | |||
466 | data_cspc = None |
|
429 | data_cspc = None | |
467 | if self.dataOut.data_cspc is not None: |
|
430 | if self.dataOut.data_cspc is not None: | |
468 | data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1] |
|
431 | data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1] | |
469 |
|
432 | |||
470 | data_dc = None |
|
433 | data_dc = None | |
471 | if self.dataOut.data_dc is not None: |
|
434 | if self.dataOut.data_dc is not None: | |
472 | data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1] |
|
435 | data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1] | |
473 |
|
436 | |||
474 | self.dataOut.data_spc = data_spc |
|
437 | self.dataOut.data_spc = data_spc | |
475 | self.dataOut.data_cspc = data_cspc |
|
438 | self.dataOut.data_cspc = data_cspc | |
476 | self.dataOut.data_dc = data_dc |
|
439 | self.dataOut.data_dc = data_dc | |
477 |
|
440 | |||
478 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex+1] |
|
441 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex+1] | |
479 |
|
442 | |||
480 | return 1 |
|
443 | return 1 | |
481 |
|
444 | |||
482 | def removeDC(self, mode = 2): |
|
445 | def removeDC(self, mode = 2): | |
483 | jspectra = self.dataOut.data_spc |
|
446 | jspectra = self.dataOut.data_spc | |
484 | jcspectra = self.dataOut.data_cspc |
|
447 | jcspectra = self.dataOut.data_cspc | |
485 |
|
448 | |||
486 |
|
449 | |||
487 | num_chan = jspectra.shape[0] |
|
450 | num_chan = jspectra.shape[0] | |
488 | num_hei = jspectra.shape[2] |
|
451 | num_hei = jspectra.shape[2] | |
489 |
|
452 | |||
490 | if jcspectra is not None: |
|
453 | if jcspectra is not None: | |
491 | jcspectraExist = True |
|
454 | jcspectraExist = True | |
492 | num_pairs = jcspectra.shape[0] |
|
455 | num_pairs = jcspectra.shape[0] | |
493 | else: jcspectraExist = False |
|
456 | else: jcspectraExist = False | |
494 |
|
457 | |||
495 | freq_dc = jspectra.shape[1]/2 |
|
458 | freq_dc = jspectra.shape[1]/2 | |
496 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc |
|
459 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc | |
497 |
|
460 | |||
498 | if ind_vel[0]<0: |
|
461 | if ind_vel[0]<0: | |
499 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof |
|
462 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof | |
500 |
|
463 | |||
501 | if mode == 1: |
|
464 | if mode == 1: | |
502 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION |
|
465 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION | |
503 |
|
466 | |||
504 | if jcspectraExist: |
|
467 | if jcspectraExist: | |
505 | jcspectra[:,freq_dc,:] = (jcspectra[:,ind_vel[1],:] + jcspectra[:,ind_vel[2],:])/2 |
|
468 | jcspectra[:,freq_dc,:] = (jcspectra[:,ind_vel[1],:] + jcspectra[:,ind_vel[2],:])/2 | |
506 |
|
469 | |||
507 | if mode == 2: |
|
470 | if mode == 2: | |
508 |
|
471 | |||
509 | vel = numpy.array([-2,-1,1,2]) |
|
472 | vel = numpy.array([-2,-1,1,2]) | |
510 | xx = numpy.zeros([4,4]) |
|
473 | xx = numpy.zeros([4,4]) | |
511 |
|
474 | |||
512 | for fil in range(4): |
|
475 | for fil in range(4): | |
513 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) |
|
476 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) | |
514 |
|
477 | |||
515 | xx_inv = numpy.linalg.inv(xx) |
|
478 | xx_inv = numpy.linalg.inv(xx) | |
516 | xx_aux = xx_inv[0,:] |
|
479 | xx_aux = xx_inv[0,:] | |
517 |
|
480 | |||
518 | for ich in range(num_chan): |
|
481 | for ich in range(num_chan): | |
519 | yy = jspectra[ich,ind_vel,:] |
|
482 | yy = jspectra[ich,ind_vel,:] | |
520 | jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy) |
|
483 | jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy) | |
521 |
|
484 | |||
522 | junkid = jspectra[ich,freq_dc,:]<=0 |
|
485 | junkid = jspectra[ich,freq_dc,:]<=0 | |
523 | cjunkid = sum(junkid) |
|
486 | cjunkid = sum(junkid) | |
524 |
|
487 | |||
525 | if cjunkid.any(): |
|
488 | if cjunkid.any(): | |
526 | jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2 |
|
489 | jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2 | |
527 |
|
490 | |||
528 | if jcspectraExist: |
|
491 | if jcspectraExist: | |
529 | for ip in range(num_pairs): |
|
492 | for ip in range(num_pairs): | |
530 | yy = jcspectra[ip,ind_vel,:] |
|
493 | yy = jcspectra[ip,ind_vel,:] | |
531 | jcspectra[ip,freq_dc,:] = numpy.dot(xx_aux,yy) |
|
494 | jcspectra[ip,freq_dc,:] = numpy.dot(xx_aux,yy) | |
532 |
|
495 | |||
533 |
|
496 | |||
534 | self.dataOut.data_spc = jspectra |
|
497 | self.dataOut.data_spc = jspectra | |
535 | self.dataOut.data_cspc = jcspectra |
|
498 | self.dataOut.data_cspc = jcspectra | |
536 |
|
499 | |||
537 | return 1 |
|
500 | return 1 | |
538 |
|
501 | |||
539 | def removeInterference(self, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None): |
|
502 | def removeInterference(self, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None): | |
540 |
|
503 | |||
541 | jspectra = self.dataOut.data_spc |
|
504 | jspectra = self.dataOut.data_spc | |
542 | jcspectra = self.dataOut.data_cspc |
|
505 | jcspectra = self.dataOut.data_cspc | |
543 | jnoise = self.dataOut.getNoise() |
|
506 | jnoise = self.dataOut.getNoise() | |
544 | num_incoh = self.dataOut.nIncohInt |
|
507 | num_incoh = self.dataOut.nIncohInt | |
545 |
|
508 | |||
546 | num_channel = jspectra.shape[0] |
|
509 | num_channel = jspectra.shape[0] | |
547 | num_prof = jspectra.shape[1] |
|
510 | num_prof = jspectra.shape[1] | |
548 | num_hei = jspectra.shape[2] |
|
511 | num_hei = jspectra.shape[2] | |
549 |
|
512 | |||
550 | #hei_interf |
|
513 | #hei_interf | |
551 | if hei_interf is None: |
|
514 | if hei_interf is None: | |
552 | count_hei = num_hei/2 #Como es entero no importa |
|
515 | count_hei = num_hei/2 #Como es entero no importa | |
553 | hei_interf = numpy.asmatrix(range(count_hei)) + num_hei - count_hei |
|
516 | hei_interf = numpy.asmatrix(range(count_hei)) + num_hei - count_hei | |
554 | hei_interf = numpy.asarray(hei_interf)[0] |
|
517 | hei_interf = numpy.asarray(hei_interf)[0] | |
555 | #nhei_interf |
|
518 | #nhei_interf | |
556 | if (nhei_interf == None): |
|
519 | if (nhei_interf == None): | |
557 | nhei_interf = 5 |
|
520 | nhei_interf = 5 | |
558 | if (nhei_interf < 1): |
|
521 | if (nhei_interf < 1): | |
559 | nhei_interf = 1 |
|
522 | nhei_interf = 1 | |
560 | if (nhei_interf > count_hei): |
|
523 | if (nhei_interf > count_hei): | |
561 | nhei_interf = count_hei |
|
524 | nhei_interf = count_hei | |
562 | if (offhei_interf == None): |
|
525 | if (offhei_interf == None): | |
563 | offhei_interf = 0 |
|
526 | offhei_interf = 0 | |
564 |
|
527 | |||
565 | ind_hei = range(num_hei) |
|
528 | ind_hei = range(num_hei) | |
566 | # mask_prof = numpy.asarray(range(num_prof - 2)) + 1 |
|
529 | # mask_prof = numpy.asarray(range(num_prof - 2)) + 1 | |
567 | # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1 |
|
530 | # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1 | |
568 | mask_prof = numpy.asarray(range(num_prof)) |
|
531 | mask_prof = numpy.asarray(range(num_prof)) | |
569 | num_mask_prof = mask_prof.size |
|
532 | num_mask_prof = mask_prof.size | |
570 | comp_mask_prof = [0, num_prof/2] |
|
533 | comp_mask_prof = [0, num_prof/2] | |
571 |
|
534 | |||
572 |
|
535 | |||
573 | #noise_exist: Determina si la variable jnoise ha sido definida y contiene la informacion del ruido de cada canal |
|
536 | #noise_exist: Determina si la variable jnoise ha sido definida y contiene la informacion del ruido de cada canal | |
574 | if (jnoise.size < num_channel or numpy.isnan(jnoise).any()): |
|
537 | if (jnoise.size < num_channel or numpy.isnan(jnoise).any()): | |
575 | jnoise = numpy.nan |
|
538 | jnoise = numpy.nan | |
576 | noise_exist = jnoise[0] < numpy.Inf |
|
539 | noise_exist = jnoise[0] < numpy.Inf | |
577 |
|
540 | |||
578 | #Subrutina de Remocion de la Interferencia |
|
541 | #Subrutina de Remocion de la Interferencia | |
579 | for ich in range(num_channel): |
|
542 | for ich in range(num_channel): | |
580 | #Se ordena los espectros segun su potencia (menor a mayor) |
|
543 | #Se ordena los espectros segun su potencia (menor a mayor) | |
581 | power = jspectra[ich,mask_prof,:] |
|
544 | power = jspectra[ich,mask_prof,:] | |
582 | power = power[:,hei_interf] |
|
545 | power = power[:,hei_interf] | |
583 | power = power.sum(axis = 0) |
|
546 | power = power.sum(axis = 0) | |
584 | psort = power.ravel().argsort() |
|
547 | psort = power.ravel().argsort() | |
585 |
|
548 | |||
586 | #Se estima la interferencia promedio en los Espectros de Potencia empleando |
|
549 | #Se estima la interferencia promedio en los Espectros de Potencia empleando | |
587 | junkspc_interf = jspectra[ich,:,hei_interf[psort[range(offhei_interf, nhei_interf + offhei_interf)]]] |
|
550 | junkspc_interf = jspectra[ich,:,hei_interf[psort[range(offhei_interf, nhei_interf + offhei_interf)]]] | |
588 |
|
551 | |||
589 | if noise_exist: |
|
552 | if noise_exist: | |
590 | # tmp_noise = jnoise[ich] / num_prof |
|
553 | # tmp_noise = jnoise[ich] / num_prof | |
591 | tmp_noise = jnoise[ich] |
|
554 | tmp_noise = jnoise[ich] | |
592 | junkspc_interf = junkspc_interf - tmp_noise |
|
555 | junkspc_interf = junkspc_interf - tmp_noise | |
593 | #junkspc_interf[:,comp_mask_prof] = 0 |
|
556 | #junkspc_interf[:,comp_mask_prof] = 0 | |
594 |
|
557 | |||
595 | jspc_interf = junkspc_interf.sum(axis = 0) / nhei_interf |
|
558 | jspc_interf = junkspc_interf.sum(axis = 0) / nhei_interf | |
596 | jspc_interf = jspc_interf.transpose() |
|
559 | jspc_interf = jspc_interf.transpose() | |
597 | #Calculando el espectro de interferencia promedio |
|
560 | #Calculando el espectro de interferencia promedio | |
598 | noiseid = numpy.where(jspc_interf <= tmp_noise/ numpy.sqrt(num_incoh)) |
|
561 | noiseid = numpy.where(jspc_interf <= tmp_noise/ numpy.sqrt(num_incoh)) | |
599 | noiseid = noiseid[0] |
|
562 | noiseid = noiseid[0] | |
600 | cnoiseid = noiseid.size |
|
563 | cnoiseid = noiseid.size | |
601 | interfid = numpy.where(jspc_interf > tmp_noise/ numpy.sqrt(num_incoh)) |
|
564 | interfid = numpy.where(jspc_interf > tmp_noise/ numpy.sqrt(num_incoh)) | |
602 | interfid = interfid[0] |
|
565 | interfid = interfid[0] | |
603 | cinterfid = interfid.size |
|
566 | cinterfid = interfid.size | |
604 |
|
567 | |||
605 | if (cnoiseid > 0): jspc_interf[noiseid] = 0 |
|
568 | if (cnoiseid > 0): jspc_interf[noiseid] = 0 | |
606 |
|
569 | |||
607 | #Expandiendo los perfiles a limpiar |
|
570 | #Expandiendo los perfiles a limpiar | |
608 | if (cinterfid > 0): |
|
571 | if (cinterfid > 0): | |
609 | new_interfid = (numpy.r_[interfid - 1, interfid, interfid + 1] + num_prof)%num_prof |
|
572 | new_interfid = (numpy.r_[interfid - 1, interfid, interfid + 1] + num_prof)%num_prof | |
610 | new_interfid = numpy.asarray(new_interfid) |
|
573 | new_interfid = numpy.asarray(new_interfid) | |
611 | new_interfid = {x for x in new_interfid} |
|
574 | new_interfid = {x for x in new_interfid} | |
612 | new_interfid = numpy.array(list(new_interfid)) |
|
575 | new_interfid = numpy.array(list(new_interfid)) | |
613 | new_cinterfid = new_interfid.size |
|
576 | new_cinterfid = new_interfid.size | |
614 | else: new_cinterfid = 0 |
|
577 | else: new_cinterfid = 0 | |
615 |
|
578 | |||
616 | for ip in range(new_cinterfid): |
|
579 | for ip in range(new_cinterfid): | |
617 | ind = junkspc_interf[:,new_interfid[ip]].ravel().argsort() |
|
580 | ind = junkspc_interf[:,new_interfid[ip]].ravel().argsort() | |
618 | jspc_interf[new_interfid[ip]] = junkspc_interf[ind[nhei_interf/2],new_interfid[ip]] |
|
581 | jspc_interf[new_interfid[ip]] = junkspc_interf[ind[nhei_interf/2],new_interfid[ip]] | |
619 |
|
582 | |||
620 |
|
583 | |||
621 | jspectra[ich,:,ind_hei] = jspectra[ich,:,ind_hei] - jspc_interf #Corregir indices |
|
584 | jspectra[ich,:,ind_hei] = jspectra[ich,:,ind_hei] - jspc_interf #Corregir indices | |
622 |
|
585 | |||
623 | #Removiendo la interferencia del punto de mayor interferencia |
|
586 | #Removiendo la interferencia del punto de mayor interferencia | |
624 | ListAux = jspc_interf[mask_prof].tolist() |
|
587 | ListAux = jspc_interf[mask_prof].tolist() | |
625 | maxid = ListAux.index(max(ListAux)) |
|
588 | maxid = ListAux.index(max(ListAux)) | |
626 |
|
589 | |||
627 |
|
590 | |||
628 | if cinterfid > 0: |
|
591 | if cinterfid > 0: | |
629 | for ip in range(cinterfid*(interf == 2) - 1): |
|
592 | for ip in range(cinterfid*(interf == 2) - 1): | |
630 | ind = (jspectra[ich,interfid[ip],:] < tmp_noise*(1 + 1/numpy.sqrt(num_incoh))).nonzero() |
|
593 | ind = (jspectra[ich,interfid[ip],:] < tmp_noise*(1 + 1/numpy.sqrt(num_incoh))).nonzero() | |
631 | cind = len(ind) |
|
594 | cind = len(ind) | |
632 |
|
595 | |||
633 | if (cind > 0): |
|
596 | if (cind > 0): | |
634 | jspectra[ich,interfid[ip],ind] = tmp_noise*(1 + (numpy.random.uniform(cind) - 0.5)/numpy.sqrt(num_incoh)) |
|
597 | jspectra[ich,interfid[ip],ind] = tmp_noise*(1 + (numpy.random.uniform(cind) - 0.5)/numpy.sqrt(num_incoh)) | |
635 |
|
598 | |||
636 | ind = numpy.array([-2,-1,1,2]) |
|
599 | ind = numpy.array([-2,-1,1,2]) | |
637 | xx = numpy.zeros([4,4]) |
|
600 | xx = numpy.zeros([4,4]) | |
638 |
|
601 | |||
639 | for id1 in range(4): |
|
602 | for id1 in range(4): | |
640 | xx[:,id1] = ind[id1]**numpy.asarray(range(4)) |
|
603 | xx[:,id1] = ind[id1]**numpy.asarray(range(4)) | |
641 |
|
604 | |||
642 | xx_inv = numpy.linalg.inv(xx) |
|
605 | xx_inv = numpy.linalg.inv(xx) | |
643 | xx = xx_inv[:,0] |
|
606 | xx = xx_inv[:,0] | |
644 | ind = (ind + maxid + num_mask_prof)%num_mask_prof |
|
607 | ind = (ind + maxid + num_mask_prof)%num_mask_prof | |
645 | yy = jspectra[ich,mask_prof[ind],:] |
|
608 | yy = jspectra[ich,mask_prof[ind],:] | |
646 | jspectra[ich,mask_prof[maxid],:] = numpy.dot(yy.transpose(),xx) |
|
609 | jspectra[ich,mask_prof[maxid],:] = numpy.dot(yy.transpose(),xx) | |
647 |
|
610 | |||
648 |
|
611 | |||
649 | indAux = (jspectra[ich,:,:] < tmp_noise*(1-1/numpy.sqrt(num_incoh))).nonzero() |
|
612 | indAux = (jspectra[ich,:,:] < tmp_noise*(1-1/numpy.sqrt(num_incoh))).nonzero() | |
650 | jspectra[ich,indAux[0],indAux[1]] = tmp_noise * (1 - 1/numpy.sqrt(num_incoh)) |
|
613 | jspectra[ich,indAux[0],indAux[1]] = tmp_noise * (1 - 1/numpy.sqrt(num_incoh)) | |
651 |
|
614 | |||
652 | #Remocion de Interferencia en el Cross Spectra |
|
615 | #Remocion de Interferencia en el Cross Spectra | |
653 | if jcspectra is None: return jspectra, jcspectra |
|
616 | if jcspectra is None: return jspectra, jcspectra | |
654 | num_pairs = jcspectra.size/(num_prof*num_hei) |
|
617 | num_pairs = jcspectra.size/(num_prof*num_hei) | |
655 | jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei) |
|
618 | jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei) | |
656 |
|
619 | |||
657 | for ip in range(num_pairs): |
|
620 | for ip in range(num_pairs): | |
658 |
|
621 | |||
659 | #------------------------------------------- |
|
622 | #------------------------------------------- | |
660 |
|
623 | |||
661 | cspower = numpy.abs(jcspectra[ip,mask_prof,:]) |
|
624 | cspower = numpy.abs(jcspectra[ip,mask_prof,:]) | |
662 | cspower = cspower[:,hei_interf] |
|
625 | cspower = cspower[:,hei_interf] | |
663 | cspower = cspower.sum(axis = 0) |
|
626 | cspower = cspower.sum(axis = 0) | |
664 |
|
627 | |||
665 | cspsort = cspower.ravel().argsort() |
|
628 | cspsort = cspower.ravel().argsort() | |
666 | junkcspc_interf = jcspectra[ip,:,hei_interf[cspsort[range(offhei_interf, nhei_interf + offhei_interf)]]] |
|
629 | junkcspc_interf = jcspectra[ip,:,hei_interf[cspsort[range(offhei_interf, nhei_interf + offhei_interf)]]] | |
667 | junkcspc_interf = junkcspc_interf.transpose() |
|
630 | junkcspc_interf = junkcspc_interf.transpose() | |
668 | jcspc_interf = junkcspc_interf.sum(axis = 1)/nhei_interf |
|
631 | jcspc_interf = junkcspc_interf.sum(axis = 1)/nhei_interf | |
669 |
|
632 | |||
670 | ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort() |
|
633 | ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort() | |
671 |
|
634 | |||
672 | median_real = numpy.median(numpy.real(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:])) |
|
635 | median_real = numpy.median(numpy.real(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:])) | |
673 | median_imag = numpy.median(numpy.imag(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:])) |
|
636 | median_imag = numpy.median(numpy.imag(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:])) | |
674 | junkcspc_interf[comp_mask_prof,:] = numpy.complex(median_real, median_imag) |
|
637 | junkcspc_interf[comp_mask_prof,:] = numpy.complex(median_real, median_imag) | |
675 |
|
638 | |||
676 | for iprof in range(num_prof): |
|
639 | for iprof in range(num_prof): | |
677 | ind = numpy.abs(junkcspc_interf[iprof,:]).ravel().argsort() |
|
640 | ind = numpy.abs(junkcspc_interf[iprof,:]).ravel().argsort() | |
678 | jcspc_interf[iprof] = junkcspc_interf[iprof, ind[nhei_interf/2]] |
|
641 | jcspc_interf[iprof] = junkcspc_interf[iprof, ind[nhei_interf/2]] | |
679 |
|
642 | |||
680 | #Removiendo la Interferencia |
|
643 | #Removiendo la Interferencia | |
681 | jcspectra[ip,:,ind_hei] = jcspectra[ip,:,ind_hei] - jcspc_interf |
|
644 | jcspectra[ip,:,ind_hei] = jcspectra[ip,:,ind_hei] - jcspc_interf | |
682 |
|
645 | |||
683 | ListAux = numpy.abs(jcspc_interf[mask_prof]).tolist() |
|
646 | ListAux = numpy.abs(jcspc_interf[mask_prof]).tolist() | |
684 | maxid = ListAux.index(max(ListAux)) |
|
647 | maxid = ListAux.index(max(ListAux)) | |
685 |
|
648 | |||
686 | ind = numpy.array([-2,-1,1,2]) |
|
649 | ind = numpy.array([-2,-1,1,2]) | |
687 | xx = numpy.zeros([4,4]) |
|
650 | xx = numpy.zeros([4,4]) | |
688 |
|
651 | |||
689 | for id1 in range(4): |
|
652 | for id1 in range(4): | |
690 | xx[:,id1] = ind[id1]**numpy.asarray(range(4)) |
|
653 | xx[:,id1] = ind[id1]**numpy.asarray(range(4)) | |
691 |
|
654 | |||
692 | xx_inv = numpy.linalg.inv(xx) |
|
655 | xx_inv = numpy.linalg.inv(xx) | |
693 | xx = xx_inv[:,0] |
|
656 | xx = xx_inv[:,0] | |
694 |
|
657 | |||
695 | ind = (ind + maxid + num_mask_prof)%num_mask_prof |
|
658 | ind = (ind + maxid + num_mask_prof)%num_mask_prof | |
696 | yy = jcspectra[ip,mask_prof[ind],:] |
|
659 | yy = jcspectra[ip,mask_prof[ind],:] | |
697 | jcspectra[ip,mask_prof[maxid],:] = numpy.dot(yy.transpose(),xx) |
|
660 | jcspectra[ip,mask_prof[maxid],:] = numpy.dot(yy.transpose(),xx) | |
698 |
|
661 | |||
699 | #Guardar Resultados |
|
662 | #Guardar Resultados | |
700 | self.dataOut.data_spc = jspectra |
|
663 | self.dataOut.data_spc = jspectra | |
701 | self.dataOut.data_cspc = jcspectra |
|
664 | self.dataOut.data_cspc = jcspectra | |
702 |
|
665 | |||
703 | return 1 |
|
666 | return 1 | |
704 |
|
667 | |||
705 | def setRadarFrequency(self, frequency=None): |
|
668 | def setRadarFrequency(self, frequency=None): | |
706 |
|
669 | |||
707 | if frequency != None: |
|
670 | if frequency != None: | |
708 | self.dataOut.frequency = frequency |
|
671 | self.dataOut.frequency = frequency | |
709 |
|
672 | |||
710 | return 1 |
|
673 | return 1 | |
711 |
|
674 | |||
712 | def getNoise(self, minHei=None, maxHei=None, minVel=None, maxVel=None): |
|
675 | def getNoise(self, minHei=None, maxHei=None, minVel=None, maxVel=None): | |
713 | #validacion de rango |
|
676 | #validacion de rango | |
714 | if minHei == None: |
|
677 | if minHei == None: | |
715 | minHei = self.dataOut.heightList[0] |
|
678 | minHei = self.dataOut.heightList[0] | |
716 |
|
679 | |||
717 | if maxHei == None: |
|
680 | if maxHei == None: | |
718 | maxHei = self.dataOut.heightList[-1] |
|
681 | maxHei = self.dataOut.heightList[-1] | |
719 |
|
682 | |||
720 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): |
|
683 | if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei): | |
721 | print 'minHei: %.2f is out of the heights range'%(minHei) |
|
684 | print 'minHei: %.2f is out of the heights range'%(minHei) | |
722 | print 'minHei is setting to %.2f'%(self.dataOut.heightList[0]) |
|
685 | print 'minHei is setting to %.2f'%(self.dataOut.heightList[0]) | |
723 | minHei = self.dataOut.heightList[0] |
|
686 | minHei = self.dataOut.heightList[0] | |
724 |
|
687 | |||
725 | if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei): |
|
688 | if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei): | |
726 | print 'maxHei: %.2f is out of the heights range'%(maxHei) |
|
689 | print 'maxHei: %.2f is out of the heights range'%(maxHei) | |
727 | print 'maxHei is setting to %.2f'%(self.dataOut.heightList[-1]) |
|
690 | print 'maxHei is setting to %.2f'%(self.dataOut.heightList[-1]) | |
728 | maxHei = self.dataOut.heightList[-1] |
|
691 | maxHei = self.dataOut.heightList[-1] | |
729 |
|
692 | |||
730 | # validacion de velocidades |
|
693 | # validacion de velocidades | |
731 | velrange = self.dataOut.getVelRange(1) |
|
694 | velrange = self.dataOut.getVelRange(1) | |
732 |
|
695 | |||
733 | if minVel == None: |
|
696 | if minVel == None: | |
734 | minVel = velrange[0] |
|
697 | minVel = velrange[0] | |
735 |
|
698 | |||
736 | if maxVel == None: |
|
699 | if maxVel == None: | |
737 | maxVel = velrange[-1] |
|
700 | maxVel = velrange[-1] | |
738 |
|
701 | |||
739 | if (minVel < velrange[0]) or (minVel > maxVel): |
|
702 | if (minVel < velrange[0]) or (minVel > maxVel): | |
740 | print 'minVel: %.2f is out of the velocity range'%(minVel) |
|
703 | print 'minVel: %.2f is out of the velocity range'%(minVel) | |
741 | print 'minVel is setting to %.2f'%(velrange[0]) |
|
704 | print 'minVel is setting to %.2f'%(velrange[0]) | |
742 | minVel = velrange[0] |
|
705 | minVel = velrange[0] | |
743 |
|
706 | |||
744 | if (maxVel > velrange[-1]) or (maxVel < minVel): |
|
707 | if (maxVel > velrange[-1]) or (maxVel < minVel): | |
745 | print 'maxVel: %.2f is out of the velocity range'%(maxVel) |
|
708 | print 'maxVel: %.2f is out of the velocity range'%(maxVel) | |
746 | print 'maxVel is setting to %.2f'%(velrange[-1]) |
|
709 | print 'maxVel is setting to %.2f'%(velrange[-1]) | |
747 | maxVel = velrange[-1] |
|
710 | maxVel = velrange[-1] | |
748 |
|
711 | |||
749 | # seleccion de indices para rango |
|
712 | # seleccion de indices para rango | |
750 | minIndex = 0 |
|
713 | minIndex = 0 | |
751 | maxIndex = 0 |
|
714 | maxIndex = 0 | |
752 | heights = self.dataOut.heightList |
|
715 | heights = self.dataOut.heightList | |
753 |
|
716 | |||
754 | inda = numpy.where(heights >= minHei) |
|
717 | inda = numpy.where(heights >= minHei) | |
755 | indb = numpy.where(heights <= maxHei) |
|
718 | indb = numpy.where(heights <= maxHei) | |
756 |
|
719 | |||
757 | try: |
|
720 | try: | |
758 | minIndex = inda[0][0] |
|
721 | minIndex = inda[0][0] | |
759 | except: |
|
722 | except: | |
760 | minIndex = 0 |
|
723 | minIndex = 0 | |
761 |
|
724 | |||
762 | try: |
|
725 | try: | |
763 | maxIndex = indb[0][-1] |
|
726 | maxIndex = indb[0][-1] | |
764 | except: |
|
727 | except: | |
765 | maxIndex = len(heights) |
|
728 | maxIndex = len(heights) | |
766 |
|
729 | |||
767 | if (minIndex < 0) or (minIndex > maxIndex): |
|
730 | if (minIndex < 0) or (minIndex > maxIndex): | |
768 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) |
|
731 | raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex) | |
769 |
|
732 | |||
770 | if (maxIndex >= self.dataOut.nHeights): |
|
733 | if (maxIndex >= self.dataOut.nHeights): | |
771 | maxIndex = self.dataOut.nHeights-1 |
|
734 | maxIndex = self.dataOut.nHeights-1 | |
772 |
|
735 | |||
773 | # seleccion de indices para velocidades |
|
736 | # seleccion de indices para velocidades | |
774 | indminvel = numpy.where(velrange >= minVel) |
|
737 | indminvel = numpy.where(velrange >= minVel) | |
775 | indmaxvel = numpy.where(velrange <= maxVel) |
|
738 | indmaxvel = numpy.where(velrange <= maxVel) | |
776 | try: |
|
739 | try: | |
777 | minIndexVel = indminvel[0][0] |
|
740 | minIndexVel = indminvel[0][0] | |
778 | except: |
|
741 | except: | |
779 | minIndexVel = 0 |
|
742 | minIndexVel = 0 | |
780 |
|
743 | |||
781 | try: |
|
744 | try: | |
782 | maxIndexVel = indmaxvel[0][-1] |
|
745 | maxIndexVel = indmaxvel[0][-1] | |
783 | except: |
|
746 | except: | |
784 | maxIndexVel = len(velrange) |
|
747 | maxIndexVel = len(velrange) | |
785 |
|
748 | |||
786 | #seleccion del espectro |
|
749 | #seleccion del espectro | |
787 | data_spc = self.dataOut.data_spc[:,minIndexVel:maxIndexVel+1,minIndex:maxIndex+1] |
|
750 | data_spc = self.dataOut.data_spc[:,minIndexVel:maxIndexVel+1,minIndex:maxIndex+1] | |
788 | #estimacion de ruido |
|
751 | #estimacion de ruido | |
789 | noise = numpy.zeros(self.dataOut.nChannels) |
|
752 | noise = numpy.zeros(self.dataOut.nChannels) | |
790 |
|
753 | |||
791 | for channel in range(self.dataOut.nChannels): |
|
754 | for channel in range(self.dataOut.nChannels): | |
792 | daux = data_spc[channel,:,:] |
|
755 | daux = data_spc[channel,:,:] | |
793 | noise[channel] = hildebrand_sekhon(daux, self.dataOut.nIncohInt) |
|
756 | noise[channel] = hildebrand_sekhon(daux, self.dataOut.nIncohInt) | |
794 |
|
757 | |||
795 | self.dataOut.noise_estimation = noise.copy() |
|
758 | self.dataOut.noise_estimation = noise.copy() | |
796 |
|
759 | |||
797 | return 1 |
|
760 | return 1 |
@@ -1,1540 +1,1540 | |||||
1 | import sys |
|
1 | import sys | |
2 | import numpy |
|
2 | import numpy | |
3 | from scipy import interpolate |
|
3 | from scipy import interpolate | |
4 | from schainpy import cSchain |
|
4 | from schainpy import cSchain | |
5 | from jroproc_base import ProcessingUnit, Operation |
|
5 | from jroproc_base import ProcessingUnit, Operation | |
6 | from schainpy.model.data.jrodata import Voltage |
|
6 | from schainpy.model.data.jrodata import Voltage | |
7 | from time import time |
|
7 | from time import time | |
8 |
|
8 | |||
9 | import math |
|
9 | import math | |
10 |
|
10 | |||
11 | def rep_seq(x, rep=10): |
|
11 | def rep_seq(x, rep=10): | |
12 | L = len(x) * rep |
|
12 | L = len(x) * rep | |
13 | res = numpy.zeros(L, dtype=x.dtype) |
|
13 | res = numpy.zeros(L, dtype=x.dtype) | |
14 | idx = numpy.arange(len(x)) * rep |
|
14 | idx = numpy.arange(len(x)) * rep | |
15 | for i in numpy.arange(rep): |
|
15 | for i in numpy.arange(rep): | |
16 | res[idx + i] = x |
|
16 | res[idx + i] = x | |
17 | return(res) |
|
17 | return(res) | |
18 |
|
18 | |||
19 |
|
19 | |||
20 | def create_pseudo_random_code(clen=10000, seed=0): |
|
20 | def create_pseudo_random_code(clen=10000, seed=0): | |
21 | """ |
|
21 | """ | |
22 | seed is a way of reproducing the random code without |
|
22 | seed is a way of reproducing the random code without | |
23 | having to store all actual codes. the seed can then |
|
23 | having to store all actual codes. the seed can then | |
24 | act as a sort of station_id. |
|
24 | act as a sort of station_id. | |
25 |
|
25 | |||
26 | """ |
|
26 | """ | |
27 | numpy.random.seed(seed) |
|
27 | numpy.random.seed(seed) | |
28 | phases = numpy.array( |
|
28 | phases = numpy.array( | |
29 | numpy.exp(1.0j * 2.0 * math.pi * numpy.random.random(clen)), |
|
29 | numpy.exp(1.0j * 2.0 * math.pi * numpy.random.random(clen)), | |
30 | dtype=numpy.complex64, |
|
30 | dtype=numpy.complex64, | |
31 | ) |
|
31 | ) | |
32 | return(phases) |
|
32 | return(phases) | |
33 |
|
33 | |||
34 |
|
34 | |||
35 | def periodic_convolution_matrix(envelope, rmin=0, rmax=100): |
|
35 | def periodic_convolution_matrix(envelope, rmin=0, rmax=100): | |
36 | """ |
|
36 | """ | |
37 | we imply that the number of measurements is equal to the number of elements |
|
37 | we imply that the number of measurements is equal to the number of elements | |
38 | in code |
|
38 | in code | |
39 |
|
39 | |||
40 | """ |
|
40 | """ | |
41 | L = len(envelope) |
|
41 | L = len(envelope) | |
42 | ridx = numpy.arange(rmin, rmax) |
|
42 | ridx = numpy.arange(rmin, rmax) | |
43 | A = numpy.zeros([L, rmax-rmin], dtype=numpy.complex64) |
|
43 | A = numpy.zeros([L, rmax-rmin], dtype=numpy.complex64) | |
44 | for i in numpy.arange(L): |
|
44 | for i in numpy.arange(L): | |
45 | A[i, :] = envelope[(i-ridx) % L] |
|
45 | A[i, :] = envelope[(i-ridx) % L] | |
46 | result = {} |
|
46 | result = {} | |
47 | result['A'] = A |
|
47 | result['A'] = A | |
48 | result['ridx'] = ridx |
|
48 | result['ridx'] = ridx | |
49 | return(result) |
|
49 | return(result) | |
50 |
|
50 | |||
51 |
|
51 | |||
52 | B_cache = 0 |
|
52 | B_cache = 0 | |
53 | r_cache = 0 |
|
53 | r_cache = 0 | |
54 | B_cached = False |
|
54 | B_cached = False | |
55 | def create_estimation_matrix(code, rmin=0, rmax=1000, cache=True): |
|
55 | def create_estimation_matrix(code, rmin=0, rmax=1000, cache=True): | |
56 | global B_cache |
|
56 | global B_cache | |
57 | global r_cache |
|
57 | global r_cache | |
58 | global B_cached |
|
58 | global B_cached | |
59 |
|
59 | |||
60 | if not cache or not B_cached: |
|
60 | if not cache or not B_cached: | |
61 | r_cache = periodic_convolution_matrix( |
|
61 | r_cache = periodic_convolution_matrix( | |
62 | envelope=code, rmin=rmin, rmax=rmax, |
|
62 | envelope=code, rmin=rmin, rmax=rmax, | |
63 | ) |
|
63 | ) | |
64 | A = r_cache['A'] |
|
64 | A = r_cache['A'] | |
65 | Ah = numpy.transpose(numpy.conjugate(A)) |
|
65 | Ah = numpy.transpose(numpy.conjugate(A)) | |
66 | B_cache = numpy.dot(numpy.linalg.inv(numpy.dot(Ah, A)), Ah) |
|
66 | B_cache = numpy.dot(numpy.linalg.inv(numpy.dot(Ah, A)), Ah) | |
67 | r_cache['B'] = B_cache |
|
67 | r_cache['B'] = B_cache | |
68 | B_cached = True |
|
68 | B_cached = True | |
69 | return(r_cache) |
|
69 | return(r_cache) | |
70 | else: |
|
70 | else: | |
71 | return(r_cache) |
|
71 | return(r_cache) | |
72 |
|
72 | |||
73 | class VoltageProc(ProcessingUnit): |
|
73 | class VoltageProc(ProcessingUnit): | |
74 |
|
74 | |||
75 |
|
75 | |||
76 | def __init__(self, **kwargs): |
|
76 | def __init__(self, **kwargs): | |
77 |
|
77 | |||
78 | ProcessingUnit.__init__(self, **kwargs) |
|
78 | ProcessingUnit.__init__(self, **kwargs) | |
79 |
|
79 | |||
80 | # self.objectDict = {} |
|
80 | # self.objectDict = {} | |
81 | self.dataOut = Voltage() |
|
81 | self.dataOut = Voltage() | |
82 | self.flip = 1 |
|
82 | self.flip = 1 | |
83 |
|
83 | |||
84 | def run(self): |
|
84 | def run(self): | |
85 | if self.dataIn.type == 'AMISR': |
|
85 | if self.dataIn.type == 'AMISR': | |
86 | self.__updateObjFromAmisrInput() |
|
86 | self.__updateObjFromAmisrInput() | |
87 |
|
87 | |||
88 | if self.dataIn.type == 'Voltage': |
|
88 | if self.dataIn.type == 'Voltage': | |
89 | self.dataOut.copy(self.dataIn) |
|
89 | self.dataOut.copy(self.dataIn) | |
90 |
|
90 | |||
91 | # self.dataOut.copy(self.dataIn) |
|
91 | # self.dataOut.copy(self.dataIn) | |
92 |
|
92 | |||
93 | def __updateObjFromAmisrInput(self): |
|
93 | def __updateObjFromAmisrInput(self): | |
94 |
|
94 | |||
95 | self.dataOut.timeZone = self.dataIn.timeZone |
|
95 | self.dataOut.timeZone = self.dataIn.timeZone | |
96 | self.dataOut.dstFlag = self.dataIn.dstFlag |
|
96 | self.dataOut.dstFlag = self.dataIn.dstFlag | |
97 | self.dataOut.errorCount = self.dataIn.errorCount |
|
97 | self.dataOut.errorCount = self.dataIn.errorCount | |
98 | self.dataOut.useLocalTime = self.dataIn.useLocalTime |
|
98 | self.dataOut.useLocalTime = self.dataIn.useLocalTime | |
99 |
|
99 | |||
100 | self.dataOut.flagNoData = self.dataIn.flagNoData |
|
100 | self.dataOut.flagNoData = self.dataIn.flagNoData | |
101 | self.dataOut.data = self.dataIn.data |
|
101 | self.dataOut.data = self.dataIn.data | |
102 | self.dataOut.utctime = self.dataIn.utctime |
|
102 | self.dataOut.utctime = self.dataIn.utctime | |
103 | self.dataOut.channelList = self.dataIn.channelList |
|
103 | self.dataOut.channelList = self.dataIn.channelList | |
104 | # self.dataOut.timeInterval = self.dataIn.timeInterval |
|
104 | # self.dataOut.timeInterval = self.dataIn.timeInterval | |
105 | self.dataOut.heightList = self.dataIn.heightList |
|
105 | self.dataOut.heightList = self.dataIn.heightList | |
106 | self.dataOut.nProfiles = self.dataIn.nProfiles |
|
106 | self.dataOut.nProfiles = self.dataIn.nProfiles | |
107 |
|
107 | |||
108 | self.dataOut.nCohInt = self.dataIn.nCohInt |
|
108 | self.dataOut.nCohInt = self.dataIn.nCohInt | |
109 | self.dataOut.ippSeconds = self.dataIn.ippSeconds |
|
109 | self.dataOut.ippSeconds = self.dataIn.ippSeconds | |
110 | self.dataOut.frequency = self.dataIn.frequency |
|
110 | self.dataOut.frequency = self.dataIn.frequency | |
111 |
|
111 | |||
112 | self.dataOut.azimuth = self.dataIn.azimuth |
|
112 | self.dataOut.azimuth = self.dataIn.azimuth | |
113 | self.dataOut.zenith = self.dataIn.zenith |
|
113 | self.dataOut.zenith = self.dataIn.zenith | |
114 |
|
114 | |||
115 | self.dataOut.beam.codeList = self.dataIn.beam.codeList |
|
115 | self.dataOut.beam.codeList = self.dataIn.beam.codeList | |
116 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList |
|
116 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList | |
117 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList |
|
117 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList | |
118 | # |
|
118 | # | |
119 | # pass# |
|
119 | # pass# | |
120 | # |
|
120 | # | |
121 | # def init(self): |
|
121 | # def init(self): | |
122 | # |
|
122 | # | |
123 | # |
|
123 | # | |
124 | # if self.dataIn.type == 'AMISR': |
|
124 | # if self.dataIn.type == 'AMISR': | |
125 | # self.__updateObjFromAmisrInput() |
|
125 | # self.__updateObjFromAmisrInput() | |
126 | # |
|
126 | # | |
127 | # if self.dataIn.type == 'Voltage': |
|
127 | # if self.dataIn.type == 'Voltage': | |
128 | # self.dataOut.copy(self.dataIn) |
|
128 | # self.dataOut.copy(self.dataIn) | |
129 | # # No necesita copiar en cada init() los atributos de dataIn |
|
129 | # # No necesita copiar en cada init() los atributos de dataIn | |
130 | # # la copia deberia hacerse por cada nuevo bloque de datos |
|
130 | # # la copia deberia hacerse por cada nuevo bloque de datos | |
131 |
|
131 | |||
132 | def selectChannels(self, channelList): |
|
132 | def selectChannels(self, channelList): | |
133 |
|
133 | |||
134 | channelIndexList = [] |
|
134 | channelIndexList = [] | |
135 |
|
135 | |||
136 | for channel in channelList: |
|
136 | for channel in channelList: | |
137 | if channel not in self.dataOut.channelList: |
|
137 | if channel not in self.dataOut.channelList: | |
138 | raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList)) |
|
138 | raise ValueError, "Channel %d is not in %s" %(channel, str(self.dataOut.channelList)) | |
139 |
|
139 | |||
140 | index = self.dataOut.channelList.index(channel) |
|
140 | index = self.dataOut.channelList.index(channel) | |
141 | channelIndexList.append(index) |
|
141 | channelIndexList.append(index) | |
142 |
|
142 | |||
143 | self.selectChannelsByIndex(channelIndexList) |
|
143 | self.selectChannelsByIndex(channelIndexList) | |
144 |
|
144 | |||
145 | def selectChannelsByIndex(self, channelIndexList): |
|
145 | def selectChannelsByIndex(self, channelIndexList): | |
146 | """ |
|
146 | """ | |
147 | Selecciona un bloque de datos en base a canales segun el channelIndexList |
|
147 | Selecciona un bloque de datos en base a canales segun el channelIndexList | |
148 |
|
148 | |||
149 | Input: |
|
149 | Input: | |
150 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] |
|
150 | channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7] | |
151 |
|
151 | |||
152 | Affected: |
|
152 | Affected: | |
153 | self.dataOut.data |
|
153 | self.dataOut.data | |
154 | self.dataOut.channelIndexList |
|
154 | self.dataOut.channelIndexList | |
155 | self.dataOut.nChannels |
|
155 | self.dataOut.nChannels | |
156 | self.dataOut.m_ProcessingHeader.totalSpectra |
|
156 | self.dataOut.m_ProcessingHeader.totalSpectra | |
157 | self.dataOut.systemHeaderObj.numChannels |
|
157 | self.dataOut.systemHeaderObj.numChannels | |
158 | self.dataOut.m_ProcessingHeader.blockSize |
|
158 | self.dataOut.m_ProcessingHeader.blockSize | |
159 |
|
159 | |||
160 | Return: |
|
160 | Return: | |
161 | None |
|
161 | None | |
162 | """ |
|
162 | """ | |
163 |
|
163 | |||
164 | for channelIndex in channelIndexList: |
|
164 | for channelIndex in channelIndexList: | |
165 | if channelIndex not in self.dataOut.channelIndexList: |
|
165 | if channelIndex not in self.dataOut.channelIndexList: | |
166 | print channelIndexList |
|
166 | print channelIndexList | |
167 | raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex |
|
167 | raise ValueError, "The value %d in channelIndexList is not valid" %channelIndex | |
168 |
|
168 | |||
169 | if self.dataOut.flagDataAsBlock: |
|
169 | if self.dataOut.flagDataAsBlock: | |
170 | """ |
|
170 | """ | |
171 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
171 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
172 | """ |
|
172 | """ | |
173 | data = self.dataOut.data[channelIndexList,:,:] |
|
173 | data = self.dataOut.data[channelIndexList,:,:] | |
174 | else: |
|
174 | else: | |
175 | data = self.dataOut.data[channelIndexList,:] |
|
175 | data = self.dataOut.data[channelIndexList,:] | |
176 |
|
176 | |||
177 | self.dataOut.data = data |
|
177 | self.dataOut.data = data | |
178 | self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] |
|
178 | self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList] | |
179 | # self.dataOut.nChannels = nChannels |
|
179 | # self.dataOut.nChannels = nChannels | |
180 |
|
180 | |||
181 | return 1 |
|
181 | return 1 | |
182 |
|
182 | |||
183 | def selectHeights(self, minHei=None, maxHei=None): |
|
183 | def selectHeights(self, minHei=None, maxHei=None): | |
184 | """ |
|
184 | """ | |
185 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango |
|
185 | Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango | |
186 | minHei <= height <= maxHei |
|
186 | minHei <= height <= maxHei | |
187 |
|
187 | |||
188 | Input: |
|
188 | Input: | |
189 | minHei : valor minimo de altura a considerar |
|
189 | minHei : valor minimo de altura a considerar | |
190 | maxHei : valor maximo de altura a considerar |
|
190 | maxHei : valor maximo de altura a considerar | |
191 |
|
191 | |||
192 | Affected: |
|
192 | Affected: | |
193 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex |
|
193 | Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex | |
194 |
|
194 | |||
195 | Return: |
|
195 | Return: | |
196 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
196 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
197 | """ |
|
197 | """ | |
198 |
|
198 | |||
199 | if minHei == None: |
|
199 | if minHei == None: | |
200 | minHei = self.dataOut.heightList[0] |
|
200 | minHei = self.dataOut.heightList[0] | |
201 |
|
201 | |||
202 | if maxHei == None: |
|
202 | if maxHei == None: | |
203 | maxHei = self.dataOut.heightList[-1] |
|
203 | maxHei = self.dataOut.heightList[-1] | |
204 |
|
204 | |||
205 | if (minHei < self.dataOut.heightList[0]): |
|
205 | if (minHei < self.dataOut.heightList[0]): | |
206 | minHei = self.dataOut.heightList[0] |
|
206 | minHei = self.dataOut.heightList[0] | |
207 |
|
207 | |||
208 | if (maxHei > self.dataOut.heightList[-1]): |
|
208 | if (maxHei > self.dataOut.heightList[-1]): | |
209 | maxHei = self.dataOut.heightList[-1] |
|
209 | maxHei = self.dataOut.heightList[-1] | |
210 |
|
210 | |||
211 | minIndex = 0 |
|
211 | minIndex = 0 | |
212 | maxIndex = 0 |
|
212 | maxIndex = 0 | |
213 | heights = self.dataOut.heightList |
|
213 | heights = self.dataOut.heightList | |
214 |
|
214 | |||
215 | inda = numpy.where(heights >= minHei) |
|
215 | inda = numpy.where(heights >= minHei) | |
216 | indb = numpy.where(heights <= maxHei) |
|
216 | indb = numpy.where(heights <= maxHei) | |
217 |
|
217 | |||
218 | try: |
|
218 | try: | |
219 | minIndex = inda[0][0] |
|
219 | minIndex = inda[0][0] | |
220 | except: |
|
220 | except: | |
221 | minIndex = 0 |
|
221 | minIndex = 0 | |
222 |
|
222 | |||
223 | try: |
|
223 | try: | |
224 | maxIndex = indb[0][-1] |
|
224 | maxIndex = indb[0][-1] | |
225 | except: |
|
225 | except: | |
226 | maxIndex = len(heights) |
|
226 | maxIndex = len(heights) | |
227 |
|
227 | |||
228 | self.selectHeightsByIndex(minIndex, maxIndex) |
|
228 | self.selectHeightsByIndex(minIndex, maxIndex) | |
229 |
|
229 | |||
230 | return 1 |
|
230 | return 1 | |
231 |
|
231 | |||
232 |
|
232 | |||
233 | def selectHeightsByIndex(self, minIndex, maxIndex): |
|
233 | def selectHeightsByIndex(self, minIndex, maxIndex): | |
234 | """ |
|
234 | """ | |
235 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango |
|
235 | Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango | |
236 | minIndex <= index <= maxIndex |
|
236 | minIndex <= index <= maxIndex | |
237 |
|
237 | |||
238 | Input: |
|
238 | Input: | |
239 | minIndex : valor de indice minimo de altura a considerar |
|
239 | minIndex : valor de indice minimo de altura a considerar | |
240 | maxIndex : valor de indice maximo de altura a considerar |
|
240 | maxIndex : valor de indice maximo de altura a considerar | |
241 |
|
241 | |||
242 | Affected: |
|
242 | Affected: | |
243 | self.dataOut.data |
|
243 | self.dataOut.data | |
244 | self.dataOut.heightList |
|
244 | self.dataOut.heightList | |
245 |
|
245 | |||
246 | Return: |
|
246 | Return: | |
247 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 |
|
247 | 1 si el metodo se ejecuto con exito caso contrario devuelve 0 | |
248 | """ |
|
248 | """ | |
249 |
|
249 | |||
250 | if (minIndex < 0) or (minIndex > maxIndex): |
|
250 | if (minIndex < 0) or (minIndex > maxIndex): | |
251 | raise ValueError, "Height index range (%d,%d) is not valid" % (minIndex, maxIndex) |
|
251 | raise ValueError, "Height index range (%d,%d) is not valid" % (minIndex, maxIndex) | |
252 |
|
252 | |||
253 | if (maxIndex >= self.dataOut.nHeights): |
|
253 | if (maxIndex >= self.dataOut.nHeights): | |
254 | maxIndex = self.dataOut.nHeights |
|
254 | maxIndex = self.dataOut.nHeights | |
255 |
|
255 | |||
256 | #voltage |
|
256 | #voltage | |
257 | if self.dataOut.flagDataAsBlock: |
|
257 | if self.dataOut.flagDataAsBlock: | |
258 | """ |
|
258 | """ | |
259 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
259 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
260 | """ |
|
260 | """ | |
261 | data = self.dataOut.data[:,:, minIndex:maxIndex] |
|
261 | data = self.dataOut.data[:,:, minIndex:maxIndex] | |
262 | else: |
|
262 | else: | |
263 | data = self.dataOut.data[:, minIndex:maxIndex] |
|
263 | data = self.dataOut.data[:, minIndex:maxIndex] | |
264 |
|
264 | |||
265 | # firstHeight = self.dataOut.heightList[minIndex] |
|
265 | # firstHeight = self.dataOut.heightList[minIndex] | |
266 |
|
266 | |||
267 | self.dataOut.data = data |
|
267 | self.dataOut.data = data | |
268 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex] |
|
268 | self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex] | |
269 |
|
269 | |||
270 | if self.dataOut.nHeights <= 1: |
|
270 | if self.dataOut.nHeights <= 1: | |
271 | raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights) |
|
271 | raise ValueError, "selectHeights: Too few heights. Current number of heights is %d" %(self.dataOut.nHeights) | |
272 |
|
272 | |||
273 | return 1 |
|
273 | return 1 | |
274 |
|
274 | |||
275 |
|
275 | |||
276 | def filterByHeights(self, window): |
|
276 | def filterByHeights(self, window): | |
277 |
|
277 | |||
278 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] |
|
278 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] | |
279 |
|
279 | |||
280 | if window == None: |
|
280 | if window == None: | |
281 | window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight |
|
281 | window = (self.dataOut.radarControllerHeaderObj.txA/self.dataOut.radarControllerHeaderObj.nBaud) / deltaHeight | |
282 |
|
282 | |||
283 | newdelta = deltaHeight * window |
|
283 | newdelta = deltaHeight * window | |
284 | r = self.dataOut.nHeights % window |
|
284 | r = self.dataOut.nHeights % window | |
285 | newheights = (self.dataOut.nHeights-r)/window |
|
285 | newheights = (self.dataOut.nHeights-r)/window | |
286 |
|
286 | |||
287 | if newheights <= 1: |
|
287 | if newheights <= 1: | |
288 | raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window) |
|
288 | raise ValueError, "filterByHeights: Too few heights. Current number of heights is %d and window is %d" %(self.dataOut.nHeights, window) | |
289 |
|
289 | |||
290 | if self.dataOut.flagDataAsBlock: |
|
290 | if self.dataOut.flagDataAsBlock: | |
291 | """ |
|
291 | """ | |
292 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
292 | Si la data es obtenida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
293 | """ |
|
293 | """ | |
294 | buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r] |
|
294 | buffer = self.dataOut.data[:, :, 0:self.dataOut.nHeights-r] | |
295 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window) |
|
295 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nProfiles,self.dataOut.nHeights/window,window) | |
296 | buffer = numpy.sum(buffer,3) |
|
296 | buffer = numpy.sum(buffer,3) | |
297 |
|
297 | |||
298 | else: |
|
298 | else: | |
299 | buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r] |
|
299 | buffer = self.dataOut.data[:,0:self.dataOut.nHeights-r] | |
300 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window) |
|
300 | buffer = buffer.reshape(self.dataOut.nChannels,self.dataOut.nHeights/window,window) | |
301 | buffer = numpy.sum(buffer,2) |
|
301 | buffer = numpy.sum(buffer,2) | |
302 |
|
302 | |||
303 | self.dataOut.data = buffer |
|
303 | self.dataOut.data = buffer | |
304 | self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta |
|
304 | self.dataOut.heightList = self.dataOut.heightList[0] + numpy.arange( newheights )*newdelta | |
305 | self.dataOut.windowOfFilter = window |
|
305 | self.dataOut.windowOfFilter = window | |
306 |
|
306 | |||
307 | def setH0(self, h0, deltaHeight = None): |
|
307 | def setH0(self, h0, deltaHeight = None): | |
308 |
|
308 | |||
309 | if not deltaHeight: |
|
309 | if not deltaHeight: | |
310 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] |
|
310 | deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0] | |
311 |
|
311 | |||
312 | nHeights = self.dataOut.nHeights |
|
312 | nHeights = self.dataOut.nHeights | |
313 |
|
313 | |||
314 | newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight |
|
314 | newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight | |
315 |
|
315 | |||
316 | self.dataOut.heightList = newHeiRange |
|
316 | self.dataOut.heightList = newHeiRange | |
317 |
|
317 | |||
318 | def deFlip(self, channelList = []): |
|
318 | def deFlip(self, channelList = []): | |
319 |
|
319 | |||
320 | data = self.dataOut.data.copy() |
|
320 | data = self.dataOut.data.copy() | |
321 |
|
321 | |||
322 | if self.dataOut.flagDataAsBlock: |
|
322 | if self.dataOut.flagDataAsBlock: | |
323 | flip = self.flip |
|
323 | flip = self.flip | |
324 | profileList = range(self.dataOut.nProfiles) |
|
324 | profileList = range(self.dataOut.nProfiles) | |
325 |
|
325 | |||
326 | if not channelList: |
|
326 | if not channelList: | |
327 | for thisProfile in profileList: |
|
327 | for thisProfile in profileList: | |
328 | data[:,thisProfile,:] = data[:,thisProfile,:]*flip |
|
328 | data[:,thisProfile,:] = data[:,thisProfile,:]*flip | |
329 | flip *= -1.0 |
|
329 | flip *= -1.0 | |
330 | else: |
|
330 | else: | |
331 | for thisChannel in channelList: |
|
331 | for thisChannel in channelList: | |
332 | if thisChannel not in self.dataOut.channelList: |
|
332 | if thisChannel not in self.dataOut.channelList: | |
333 | continue |
|
333 | continue | |
334 |
|
334 | |||
335 | for thisProfile in profileList: |
|
335 | for thisProfile in profileList: | |
336 | data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip |
|
336 | data[thisChannel,thisProfile,:] = data[thisChannel,thisProfile,:]*flip | |
337 | flip *= -1.0 |
|
337 | flip *= -1.0 | |
338 |
|
338 | |||
339 | self.flip = flip |
|
339 | self.flip = flip | |
340 |
|
340 | |||
341 | else: |
|
341 | else: | |
342 | if not channelList: |
|
342 | if not channelList: | |
343 | data[:,:] = data[:,:]*self.flip |
|
343 | data[:,:] = data[:,:]*self.flip | |
344 | else: |
|
344 | else: | |
345 | for thisChannel in channelList: |
|
345 | for thisChannel in channelList: | |
346 | if thisChannel not in self.dataOut.channelList: |
|
346 | if thisChannel not in self.dataOut.channelList: | |
347 | continue |
|
347 | continue | |
348 |
|
348 | |||
349 | data[thisChannel,:] = data[thisChannel,:]*self.flip |
|
349 | data[thisChannel,:] = data[thisChannel,:]*self.flip | |
350 |
|
350 | |||
351 | self.flip *= -1. |
|
351 | self.flip *= -1. | |
352 |
|
352 | |||
353 | self.dataOut.data = data |
|
353 | self.dataOut.data = data | |
354 |
|
354 | |||
355 | def setRadarFrequency(self, frequency=None): |
|
355 | def setRadarFrequency(self, frequency=None): | |
356 |
|
356 | |||
357 | if frequency != None: |
|
357 | if frequency != None: | |
358 | self.dataOut.frequency = frequency |
|
358 | self.dataOut.frequency = frequency | |
359 |
|
359 | |||
360 | return 1 |
|
360 | return 1 | |
361 |
|
361 | |||
362 | def interpolateHeights(self, topLim, botLim): |
|
362 | def interpolateHeights(self, topLim, botLim): | |
363 | #69 al 72 para julia |
|
363 | #69 al 72 para julia | |
364 | #82-84 para meteoros |
|
364 | #82-84 para meteoros | |
365 | if len(numpy.shape(self.dataOut.data))==2: |
|
365 | if len(numpy.shape(self.dataOut.data))==2: | |
366 | sampInterp = (self.dataOut.data[:,botLim-1] + self.dataOut.data[:,topLim+1])/2 |
|
366 | sampInterp = (self.dataOut.data[:,botLim-1] + self.dataOut.data[:,topLim+1])/2 | |
367 | sampInterp = numpy.transpose(numpy.tile(sampInterp,(topLim-botLim + 1,1))) |
|
367 | sampInterp = numpy.transpose(numpy.tile(sampInterp,(topLim-botLim + 1,1))) | |
368 | #self.dataOut.data[:,botLim:limSup+1] = sampInterp |
|
368 | #self.dataOut.data[:,botLim:limSup+1] = sampInterp | |
369 | self.dataOut.data[:,botLim:topLim+1] = sampInterp |
|
369 | self.dataOut.data[:,botLim:topLim+1] = sampInterp | |
370 | else: |
|
370 | else: | |
371 | nHeights = self.dataOut.data.shape[2] |
|
371 | nHeights = self.dataOut.data.shape[2] | |
372 | x = numpy.hstack((numpy.arange(botLim),numpy.arange(topLim+1,nHeights))) |
|
372 | x = numpy.hstack((numpy.arange(botLim),numpy.arange(topLim+1,nHeights))) | |
373 | y = self.dataOut.data[:,:,range(botLim)+range(topLim+1,nHeights)] |
|
373 | y = self.dataOut.data[:,:,range(botLim)+range(topLim+1,nHeights)] | |
374 | f = interpolate.interp1d(x, y, axis = 2) |
|
374 | f = interpolate.interp1d(x, y, axis = 2) | |
375 | xnew = numpy.arange(botLim,topLim+1) |
|
375 | xnew = numpy.arange(botLim,topLim+1) | |
376 | ynew = f(xnew) |
|
376 | ynew = f(xnew) | |
377 |
|
377 | |||
378 | self.dataOut.data[:,:,botLim:topLim+1] = ynew |
|
378 | self.dataOut.data[:,:,botLim:topLim+1] = ynew | |
379 |
|
379 | |||
380 | # import collections |
|
380 | # import collections | |
381 |
|
381 | |||
382 | class CohInt(Operation): |
|
382 | class CohInt(Operation): | |
383 |
|
383 | |||
384 | isConfig = False |
|
384 | isConfig = False | |
385 | __profIndex = 0 |
|
385 | __profIndex = 0 | |
386 | __byTime = False |
|
386 | __byTime = False | |
387 | __initime = None |
|
387 | __initime = None | |
388 | __lastdatatime = None |
|
388 | __lastdatatime = None | |
389 | __integrationtime = None |
|
389 | __integrationtime = None | |
390 | __buffer = None |
|
390 | __buffer = None | |
391 | __bufferStride = [] |
|
391 | __bufferStride = [] | |
392 | __dataReady = False |
|
392 | __dataReady = False | |
393 | __profIndexStride = 0 |
|
393 | __profIndexStride = 0 | |
394 | __dataToPutStride = False |
|
394 | __dataToPutStride = False | |
395 | n = None |
|
395 | n = None | |
396 |
|
396 | |||
397 | def __init__(self, **kwargs): |
|
397 | def __init__(self, **kwargs): | |
398 |
|
398 | |||
399 | Operation.__init__(self, **kwargs) |
|
399 | Operation.__init__(self, **kwargs) | |
400 |
|
400 | |||
401 | # self.isConfig = False |
|
401 | # self.isConfig = False | |
402 |
|
402 | |||
403 | def setup(self, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False): |
|
403 | def setup(self, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False): | |
404 | """ |
|
404 | """ | |
405 | Set the parameters of the integration class. |
|
405 | Set the parameters of the integration class. | |
406 |
|
406 | |||
407 | Inputs: |
|
407 | Inputs: | |
408 |
|
408 | |||
409 | n : Number of coherent integrations |
|
409 | n : Number of coherent integrations | |
410 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work |
|
410 | timeInterval : Time of integration. If the parameter "n" is selected this one does not work | |
411 | overlapping : |
|
411 | overlapping : | |
412 | """ |
|
412 | """ | |
413 |
|
413 | |||
414 | self.__initime = None |
|
414 | self.__initime = None | |
415 | self.__lastdatatime = 0 |
|
415 | self.__lastdatatime = 0 | |
416 | self.__buffer = None |
|
416 | self.__buffer = None | |
417 | self.__dataReady = False |
|
417 | self.__dataReady = False | |
418 | self.byblock = byblock |
|
418 | self.byblock = byblock | |
419 | self.stride = stride |
|
419 | self.stride = stride | |
420 |
|
420 | |||
421 | if n == None and timeInterval == None: |
|
421 | if n == None and timeInterval == None: | |
422 | raise ValueError, "n or timeInterval should be specified ..." |
|
422 | raise ValueError, "n or timeInterval should be specified ..." | |
423 |
|
423 | |||
424 | if n != None: |
|
424 | if n != None: | |
425 | self.n = n |
|
425 | self.n = n | |
426 | self.__byTime = False |
|
426 | self.__byTime = False | |
427 | else: |
|
427 | else: | |
428 | self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line |
|
428 | self.__integrationtime = timeInterval #* 60. #if (type(timeInterval)!=integer) -> change this line | |
429 | self.n = 9999 |
|
429 | self.n = 9999 | |
430 | self.__byTime = True |
|
430 | self.__byTime = True | |
431 |
|
431 | |||
432 | if overlapping: |
|
432 | if overlapping: | |
433 | self.__withOverlapping = True |
|
433 | self.__withOverlapping = True | |
434 | self.__buffer = None |
|
434 | self.__buffer = None | |
435 | else: |
|
435 | else: | |
436 | self.__withOverlapping = False |
|
436 | self.__withOverlapping = False | |
437 | self.__buffer = 0 |
|
437 | self.__buffer = 0 | |
438 |
|
438 | |||
439 | self.__profIndex = 0 |
|
439 | self.__profIndex = 0 | |
440 |
|
440 | |||
441 | def putData(self, data): |
|
441 | def putData(self, data): | |
442 |
|
442 | |||
443 | """ |
|
443 | """ | |
444 | Add a profile to the __buffer and increase in one the __profileIndex |
|
444 | Add a profile to the __buffer and increase in one the __profileIndex | |
445 |
|
445 | |||
446 | """ |
|
446 | """ | |
447 |
|
447 | |||
448 | if not self.__withOverlapping: |
|
448 | if not self.__withOverlapping: | |
449 | self.__buffer += data.copy() |
|
449 | self.__buffer += data.copy() | |
450 | self.__profIndex += 1 |
|
450 | self.__profIndex += 1 | |
451 | return |
|
451 | return | |
452 |
|
452 | |||
453 | #Overlapping data |
|
453 | #Overlapping data | |
454 | nChannels, nHeis = data.shape |
|
454 | nChannels, nHeis = data.shape | |
455 | data = numpy.reshape(data, (1, nChannels, nHeis)) |
|
455 | data = numpy.reshape(data, (1, nChannels, nHeis)) | |
456 |
|
456 | |||
457 | #If the buffer is empty then it takes the data value |
|
457 | #If the buffer is empty then it takes the data value | |
458 | if self.__buffer is None: |
|
458 | if self.__buffer is None: | |
459 | self.__buffer = data |
|
459 | self.__buffer = data | |
460 | self.__profIndex += 1 |
|
460 | self.__profIndex += 1 | |
461 | return |
|
461 | return | |
462 |
|
462 | |||
463 | #If the buffer length is lower than n then stakcing the data value |
|
463 | #If the buffer length is lower than n then stakcing the data value | |
464 | if self.__profIndex < self.n: |
|
464 | if self.__profIndex < self.n: | |
465 | self.__buffer = numpy.vstack((self.__buffer, data)) |
|
465 | self.__buffer = numpy.vstack((self.__buffer, data)) | |
466 | self.__profIndex += 1 |
|
466 | self.__profIndex += 1 | |
467 | return |
|
467 | return | |
468 |
|
468 | |||
469 | #If the buffer length is equal to n then replacing the last buffer value with the data value |
|
469 | #If the buffer length is equal to n then replacing the last buffer value with the data value | |
470 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) |
|
470 | self.__buffer = numpy.roll(self.__buffer, -1, axis=0) | |
471 | self.__buffer[self.n-1] = data |
|
471 | self.__buffer[self.n-1] = data | |
472 | self.__profIndex = self.n |
|
472 | self.__profIndex = self.n | |
473 | return |
|
473 | return | |
474 |
|
474 | |||
475 |
|
475 | |||
476 | def pushData(self): |
|
476 | def pushData(self): | |
477 | """ |
|
477 | """ | |
478 | Return the sum of the last profiles and the profiles used in the sum. |
|
478 | Return the sum of the last profiles and the profiles used in the sum. | |
479 |
|
479 | |||
480 | Affected: |
|
480 | Affected: | |
481 |
|
481 | |||
482 | self.__profileIndex |
|
482 | self.__profileIndex | |
483 |
|
483 | |||
484 | """ |
|
484 | """ | |
485 |
|
485 | |||
486 | if not self.__withOverlapping: |
|
486 | if not self.__withOverlapping: | |
487 | data = self.__buffer |
|
487 | data = self.__buffer | |
488 | n = self.__profIndex |
|
488 | n = self.__profIndex | |
489 |
|
489 | |||
490 | self.__buffer = 0 |
|
490 | self.__buffer = 0 | |
491 | self.__profIndex = 0 |
|
491 | self.__profIndex = 0 | |
492 |
|
492 | |||
493 | return data, n |
|
493 | return data, n | |
494 |
|
494 | |||
495 | #Integration with Overlapping |
|
495 | #Integration with Overlapping | |
496 | data = numpy.sum(self.__buffer, axis=0) |
|
496 | data = numpy.sum(self.__buffer, axis=0) | |
497 | # print data |
|
497 | # print data | |
498 | # raise |
|
498 | # raise | |
499 | n = self.__profIndex |
|
499 | n = self.__profIndex | |
500 |
|
500 | |||
501 | return data, n |
|
501 | return data, n | |
502 |
|
502 | |||
503 | def byProfiles(self, data): |
|
503 | def byProfiles(self, data): | |
504 |
|
504 | |||
505 | self.__dataReady = False |
|
505 | self.__dataReady = False | |
506 | avgdata = None |
|
506 | avgdata = None | |
507 | # n = None |
|
507 | # n = None | |
508 | # print data |
|
508 | # print data | |
509 | # raise |
|
509 | # raise | |
510 | self.putData(data) |
|
510 | self.putData(data) | |
511 |
|
511 | |||
512 | if self.__profIndex == self.n: |
|
512 | if self.__profIndex == self.n: | |
513 | avgdata, n = self.pushData() |
|
513 | avgdata, n = self.pushData() | |
514 | self.__dataReady = True |
|
514 | self.__dataReady = True | |
515 |
|
515 | |||
516 | return avgdata |
|
516 | return avgdata | |
517 |
|
517 | |||
518 | def byTime(self, data, datatime): |
|
518 | def byTime(self, data, datatime): | |
519 |
|
519 | |||
520 | self.__dataReady = False |
|
520 | self.__dataReady = False | |
521 | avgdata = None |
|
521 | avgdata = None | |
522 | n = None |
|
522 | n = None | |
523 |
|
523 | |||
524 | self.putData(data) |
|
524 | self.putData(data) | |
525 |
|
525 | |||
526 | if (datatime - self.__initime) >= self.__integrationtime: |
|
526 | if (datatime - self.__initime) >= self.__integrationtime: | |
527 | avgdata, n = self.pushData() |
|
527 | avgdata, n = self.pushData() | |
528 | self.n = n |
|
528 | self.n = n | |
529 | self.__dataReady = True |
|
529 | self.__dataReady = True | |
530 |
|
530 | |||
531 | return avgdata |
|
531 | return avgdata | |
532 |
|
532 | |||
533 | def integrateByStride(self, data, datatime): |
|
533 | def integrateByStride(self, data, datatime): | |
534 | # print data |
|
534 | # print data | |
535 | if self.__profIndex == 0: |
|
535 | if self.__profIndex == 0: | |
536 | self.__buffer = [[data.copy(), datatime]] |
|
536 | self.__buffer = [[data.copy(), datatime]] | |
537 | else: |
|
537 | else: | |
538 | self.__buffer.append([data.copy(),datatime]) |
|
538 | self.__buffer.append([data.copy(),datatime]) | |
539 | self.__profIndex += 1 |
|
539 | self.__profIndex += 1 | |
540 | self.__dataReady = False |
|
540 | self.__dataReady = False | |
541 |
|
541 | |||
542 | if self.__profIndex == self.n * self.stride : |
|
542 | if self.__profIndex == self.n * self.stride : | |
543 | self.__dataToPutStride = True |
|
543 | self.__dataToPutStride = True | |
544 | self.__profIndexStride = 0 |
|
544 | self.__profIndexStride = 0 | |
545 | self.__profIndex = 0 |
|
545 | self.__profIndex = 0 | |
546 | self.__bufferStride = [] |
|
546 | self.__bufferStride = [] | |
547 | for i in range(self.stride): |
|
547 | for i in range(self.stride): | |
548 | current = self.__buffer[i::self.stride] |
|
548 | current = self.__buffer[i::self.stride] | |
549 | data = numpy.sum([t[0] for t in current], axis=0) |
|
549 | data = numpy.sum([t[0] for t in current], axis=0) | |
550 | avgdatatime = numpy.average([t[1] for t in current]) |
|
550 | avgdatatime = numpy.average([t[1] for t in current]) | |
551 | # print data |
|
551 | # print data | |
552 | self.__bufferStride.append((data, avgdatatime)) |
|
552 | self.__bufferStride.append((data, avgdatatime)) | |
553 |
|
553 | |||
554 | if self.__dataToPutStride: |
|
554 | if self.__dataToPutStride: | |
555 | self.__dataReady = True |
|
555 | self.__dataReady = True | |
556 | self.__profIndexStride += 1 |
|
556 | self.__profIndexStride += 1 | |
557 | if self.__profIndexStride == self.stride: |
|
557 | if self.__profIndexStride == self.stride: | |
558 | self.__dataToPutStride = False |
|
558 | self.__dataToPutStride = False | |
559 | # print self.__bufferStride[self.__profIndexStride - 1] |
|
559 | # print self.__bufferStride[self.__profIndexStride - 1] | |
560 | # raise |
|
560 | # raise | |
561 | return self.__bufferStride[self.__profIndexStride - 1] |
|
561 | return self.__bufferStride[self.__profIndexStride - 1] | |
562 |
|
562 | |||
563 |
|
563 | |||
564 | return None, None |
|
564 | return None, None | |
565 |
|
565 | |||
566 | def integrate(self, data, datatime=None): |
|
566 | def integrate(self, data, datatime=None): | |
567 |
|
567 | |||
568 | if self.__initime == None: |
|
568 | if self.__initime == None: | |
569 | self.__initime = datatime |
|
569 | self.__initime = datatime | |
570 |
|
570 | |||
571 | if self.__byTime: |
|
571 | if self.__byTime: | |
572 | avgdata = self.byTime(data, datatime) |
|
572 | avgdata = self.byTime(data, datatime) | |
573 | else: |
|
573 | else: | |
574 | avgdata = self.byProfiles(data) |
|
574 | avgdata = self.byProfiles(data) | |
575 |
|
575 | |||
576 |
|
576 | |||
577 | self.__lastdatatime = datatime |
|
577 | self.__lastdatatime = datatime | |
578 |
|
578 | |||
579 | if avgdata is None: |
|
579 | if avgdata is None: | |
580 | return None, None |
|
580 | return None, None | |
581 |
|
581 | |||
582 | avgdatatime = self.__initime |
|
582 | avgdatatime = self.__initime | |
583 |
|
583 | |||
584 | deltatime = datatime - self.__lastdatatime |
|
584 | deltatime = datatime - self.__lastdatatime | |
585 |
|
585 | |||
586 | if not self.__withOverlapping: |
|
586 | if not self.__withOverlapping: | |
587 | self.__initime = datatime |
|
587 | self.__initime = datatime | |
588 | else: |
|
588 | else: | |
589 | self.__initime += deltatime |
|
589 | self.__initime += deltatime | |
590 |
|
590 | |||
591 | return avgdata, avgdatatime |
|
591 | return avgdata, avgdatatime | |
592 |
|
592 | |||
593 | def integrateByBlock(self, dataOut): |
|
593 | def integrateByBlock(self, dataOut): | |
594 |
|
594 | |||
595 | times = int(dataOut.data.shape[1]/self.n) |
|
595 | times = int(dataOut.data.shape[1]/self.n) | |
596 | avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex) |
|
596 | avgdata = numpy.zeros((dataOut.nChannels, times, dataOut.nHeights), dtype=numpy.complex) | |
597 |
|
597 | |||
598 | id_min = 0 |
|
598 | id_min = 0 | |
599 | id_max = self.n |
|
599 | id_max = self.n | |
600 |
|
600 | |||
601 | for i in range(times): |
|
601 | for i in range(times): | |
602 | junk = dataOut.data[:,id_min:id_max,:] |
|
602 | junk = dataOut.data[:,id_min:id_max,:] | |
603 | avgdata[:,i,:] = junk.sum(axis=1) |
|
603 | avgdata[:,i,:] = junk.sum(axis=1) | |
604 | id_min += self.n |
|
604 | id_min += self.n | |
605 | id_max += self.n |
|
605 | id_max += self.n | |
606 |
|
606 | |||
607 | timeInterval = dataOut.ippSeconds*self.n |
|
607 | timeInterval = dataOut.ippSeconds*self.n | |
608 | avgdatatime = (times - 1) * timeInterval + dataOut.utctime |
|
608 | avgdatatime = (times - 1) * timeInterval + dataOut.utctime | |
609 | self.__dataReady = True |
|
609 | self.__dataReady = True | |
610 | return avgdata, avgdatatime |
|
610 | return avgdata, avgdatatime | |
611 |
|
611 | |||
612 | def run(self, dataOut, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False, **kwargs): |
|
612 | def run(self, dataOut, n=None, timeInterval=None, stride=None, overlapping=False, byblock=False, **kwargs): | |
613 | if not self.isConfig: |
|
613 | if not self.isConfig: | |
614 | self.setup(n=n, stride=stride, timeInterval=timeInterval, overlapping=overlapping, byblock=byblock, **kwargs) |
|
614 | self.setup(n=n, stride=stride, timeInterval=timeInterval, overlapping=overlapping, byblock=byblock, **kwargs) | |
615 | self.isConfig = True |
|
615 | self.isConfig = True | |
616 |
|
616 | |||
617 | if dataOut.flagDataAsBlock: |
|
617 | if dataOut.flagDataAsBlock: | |
618 | """ |
|
618 | """ | |
619 | Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis] |
|
619 | Si la data es leida por bloques, dimension = [nChannels, nProfiles, nHeis] | |
620 | """ |
|
620 | """ | |
621 | avgdata, avgdatatime = self.integrateByBlock(dataOut) |
|
621 | avgdata, avgdatatime = self.integrateByBlock(dataOut) | |
622 | dataOut.nProfiles /= self.n |
|
622 | dataOut.nProfiles /= self.n | |
623 | else: |
|
623 | else: | |
624 | if stride is None: |
|
624 | if stride is None: | |
625 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) |
|
625 | avgdata, avgdatatime = self.integrate(dataOut.data, dataOut.utctime) | |
626 | else: |
|
626 | else: | |
627 | avgdata, avgdatatime = self.integrateByStride(dataOut.data, dataOut.utctime) |
|
627 | avgdata, avgdatatime = self.integrateByStride(dataOut.data, dataOut.utctime) | |
628 |
|
628 | |||
629 |
|
629 | |||
630 | # dataOut.timeInterval *= n |
|
630 | # dataOut.timeInterval *= n | |
631 | dataOut.flagNoData = True |
|
631 | dataOut.flagNoData = True | |
632 |
|
632 | |||
633 | if self.__dataReady: |
|
633 | if self.__dataReady: | |
634 | dataOut.data = avgdata |
|
634 | dataOut.data = avgdata | |
635 | dataOut.nCohInt *= self.n |
|
635 | dataOut.nCohInt *= self.n | |
636 | dataOut.utctime = avgdatatime |
|
636 | dataOut.utctime = avgdatatime | |
637 | # print avgdata, avgdatatime |
|
637 | # print avgdata, avgdatatime | |
638 | # raise |
|
638 | # raise | |
639 | # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt |
|
639 | # dataOut.timeInterval = dataOut.ippSeconds * dataOut.nCohInt | |
640 | dataOut.flagNoData = False |
|
640 | dataOut.flagNoData = False | |
641 |
|
641 | |||
642 | class Decoder(Operation): |
|
642 | class Decoder(Operation): | |
643 |
|
643 | |||
644 | isConfig = False |
|
644 | isConfig = False | |
645 | __profIndex = 0 |
|
645 | __profIndex = 0 | |
646 |
|
646 | |||
647 | code = None |
|
647 | code = None | |
648 |
|
648 | |||
649 | nCode = None |
|
649 | nCode = None | |
650 | nBaud = None |
|
650 | nBaud = None | |
651 |
|
651 | |||
652 | def __init__(self, **kwargs): |
|
652 | def __init__(self, **kwargs): | |
653 |
|
653 | |||
654 | Operation.__init__(self, **kwargs) |
|
654 | Operation.__init__(self, **kwargs) | |
655 |
|
655 | |||
656 | self.times = None |
|
656 | self.times = None | |
657 | self.osamp = None |
|
657 | self.osamp = None | |
658 | # self.__setValues = False |
|
658 | # self.__setValues = False | |
659 | self.isConfig = False |
|
659 | self.isConfig = False | |
660 |
|
660 | |||
661 | def setup(self, code, osamp, dataOut): |
|
661 | def setup(self, code, osamp, dataOut): | |
662 |
|
662 | |||
663 | self.__profIndex = 0 |
|
663 | self.__profIndex = 0 | |
664 |
|
664 | |||
665 | self.code = code |
|
665 | self.code = code | |
666 |
|
666 | |||
667 | self.nCode = len(code) |
|
667 | self.nCode = len(code) | |
668 | self.nBaud = len(code[0]) |
|
668 | self.nBaud = len(code[0]) | |
669 |
|
669 | |||
670 | if (osamp != None) and (osamp >1): |
|
670 | if (osamp != None) and (osamp >1): | |
671 | self.osamp = osamp |
|
671 | self.osamp = osamp | |
672 | self.code = numpy.repeat(code, repeats=self.osamp, axis=1) |
|
672 | self.code = numpy.repeat(code, repeats=self.osamp, axis=1) | |
673 | self.nBaud = self.nBaud*self.osamp |
|
673 | self.nBaud = self.nBaud*self.osamp | |
674 |
|
674 | |||
675 | self.__nChannels = dataOut.nChannels |
|
675 | self.__nChannels = dataOut.nChannels | |
676 | self.__nProfiles = dataOut.nProfiles |
|
676 | self.__nProfiles = dataOut.nProfiles | |
677 | self.__nHeis = dataOut.nHeights |
|
677 | self.__nHeis = dataOut.nHeights | |
678 |
|
678 | |||
679 | if self.__nHeis < self.nBaud: |
|
679 | if self.__nHeis < self.nBaud: | |
680 | raise ValueError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud) |
|
680 | raise ValueError, 'Number of heights (%d) should be greater than number of bauds (%d)' %(self.__nHeis, self.nBaud) | |
681 |
|
681 | |||
682 | #Frequency |
|
682 | #Frequency | |
683 | __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex) |
|
683 | __codeBuffer = numpy.zeros((self.nCode, self.__nHeis), dtype=numpy.complex) | |
684 |
|
684 | |||
685 | __codeBuffer[:,0:self.nBaud] = self.code |
|
685 | __codeBuffer[:,0:self.nBaud] = self.code | |
686 |
|
686 | |||
687 | self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1)) |
|
687 | self.fft_code = numpy.conj(numpy.fft.fft(__codeBuffer, axis=1)) | |
688 |
|
688 | |||
689 | if dataOut.flagDataAsBlock: |
|
689 | if dataOut.flagDataAsBlock: | |
690 |
|
690 | |||
691 | self.ndatadec = self.__nHeis #- self.nBaud + 1 |
|
691 | self.ndatadec = self.__nHeis #- self.nBaud + 1 | |
692 |
|
692 | |||
693 | self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex) |
|
693 | self.datadecTime = numpy.zeros((self.__nChannels, self.__nProfiles, self.ndatadec), dtype=numpy.complex) | |
694 |
|
694 | |||
695 | else: |
|
695 | else: | |
696 |
|
696 | |||
697 | #Time |
|
697 | #Time | |
698 | self.ndatadec = self.__nHeis #- self.nBaud + 1 |
|
698 | self.ndatadec = self.__nHeis #- self.nBaud + 1 | |
699 |
|
699 | |||
700 | self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex) |
|
700 | self.datadecTime = numpy.zeros((self.__nChannels, self.ndatadec), dtype=numpy.complex) | |
701 |
|
701 | |||
702 | def __convolutionInFreq(self, data): |
|
702 | def __convolutionInFreq(self, data): | |
703 |
|
703 | |||
704 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
|
704 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) | |
705 |
|
705 | |||
706 | fft_data = numpy.fft.fft(data, axis=1) |
|
706 | fft_data = numpy.fft.fft(data, axis=1) | |
707 |
|
707 | |||
708 | conv = fft_data*fft_code |
|
708 | conv = fft_data*fft_code | |
709 |
|
709 | |||
710 | data = numpy.fft.ifft(conv,axis=1) |
|
710 | data = numpy.fft.ifft(conv,axis=1) | |
711 |
|
711 | |||
712 | return data |
|
712 | return data | |
713 |
|
713 | |||
714 | def __convolutionInFreqOpt(self, data): |
|
714 | def __convolutionInFreqOpt(self, data): | |
715 |
|
715 | |||
716 | raise NotImplementedError |
|
716 | raise NotImplementedError | |
717 |
|
717 | |||
718 | def __convolutionInTime(self, data): |
|
718 | def __convolutionInTime(self, data): | |
719 |
|
719 | |||
720 | code = self.code[self.__profIndex] |
|
720 | code = self.code[self.__profIndex] | |
721 | for i in range(self.__nChannels): |
|
721 | for i in range(self.__nChannels): | |
722 | self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:] |
|
722 | self.datadecTime[i,:] = numpy.correlate(data[i,:], code, mode='full')[self.nBaud-1:] | |
723 |
|
723 | |||
724 | return self.datadecTime |
|
724 | return self.datadecTime | |
725 |
|
725 | |||
726 | def __convolutionByBlockInTime(self, data): |
|
726 | def __convolutionByBlockInTime(self, data): | |
727 |
|
727 | |||
728 | repetitions = self.__nProfiles / self.nCode |
|
728 | repetitions = self.__nProfiles / self.nCode | |
729 |
|
729 | |||
730 | junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize)) |
|
730 | junk = numpy.lib.stride_tricks.as_strided(self.code, (repetitions, self.code.size), (0, self.code.itemsize)) | |
731 | junk = junk.flatten() |
|
731 | junk = junk.flatten() | |
732 | code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud)) |
|
732 | code_block = numpy.reshape(junk, (self.nCode*repetitions, self.nBaud)) | |
733 | profilesList = xrange(self.__nProfiles) |
|
733 | profilesList = xrange(self.__nProfiles) | |
734 |
|
734 | |||
735 | for i in range(self.__nChannels): |
|
735 | for i in range(self.__nChannels): | |
736 | for j in profilesList: |
|
736 | for j in profilesList: | |
737 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:] |
|
737 | self.datadecTime[i,j,:] = numpy.correlate(data[i,j,:], code_block[j,:], mode='full')[self.nBaud-1:] | |
738 | return self.datadecTime |
|
738 | return self.datadecTime | |
739 |
|
739 | |||
740 | def __convolutionByBlockInFreq(self, data): |
|
740 | def __convolutionByBlockInFreq(self, data): | |
741 |
|
741 | |||
742 | raise NotImplementedError, "Decoder by frequency fro Blocks not implemented" |
|
742 | raise NotImplementedError, "Decoder by frequency fro Blocks not implemented" | |
743 |
|
743 | |||
744 |
|
744 | |||
745 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) |
|
745 | fft_code = self.fft_code[self.__profIndex].reshape(1,-1) | |
746 |
|
746 | |||
747 | fft_data = numpy.fft.fft(data, axis=2) |
|
747 | fft_data = numpy.fft.fft(data, axis=2) | |
748 |
|
748 | |||
749 | conv = fft_data*fft_code |
|
749 | conv = fft_data*fft_code | |
750 |
|
750 | |||
751 | data = numpy.fft.ifft(conv,axis=2) |
|
751 | data = numpy.fft.ifft(conv,axis=2) | |
752 |
|
752 | |||
753 | return data |
|
753 | return data | |
754 |
|
754 | |||
755 |
|
755 | |||
756 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None): |
|
756 | def run(self, dataOut, code=None, nCode=None, nBaud=None, mode = 0, osamp=None, times=None): | |
757 |
|
757 | |||
758 | if dataOut.flagDecodeData: |
|
758 | if dataOut.flagDecodeData: | |
759 | print "This data is already decoded, recoding again ..." |
|
759 | print "This data is already decoded, recoding again ..." | |
760 |
|
760 | |||
761 | if not self.isConfig: |
|
761 | if not self.isConfig: | |
762 |
|
762 | |||
763 | if code is None: |
|
763 | if code is None: | |
764 | if dataOut.code is None: |
|
764 | if dataOut.code is None: | |
765 | raise ValueError, "Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type |
|
765 | raise ValueError, "Code could not be read from %s instance. Enter a value in Code parameter" %dataOut.type | |
766 |
|
766 | |||
767 | code = dataOut.code |
|
767 | code = dataOut.code | |
768 | else: |
|
768 | else: | |
769 | code = numpy.array(code).reshape(nCode,nBaud) |
|
769 | code = numpy.array(code).reshape(nCode,nBaud) | |
770 | self.setup(code, osamp, dataOut) |
|
770 | self.setup(code, osamp, dataOut) | |
771 |
|
771 | |||
772 | self.isConfig = True |
|
772 | self.isConfig = True | |
773 |
|
773 | |||
774 | if mode == 3: |
|
774 | if mode == 3: | |
775 | sys.stderr.write("Decoder Warning: mode=%d is not valid, using mode=0\n" %mode) |
|
775 | sys.stderr.write("Decoder Warning: mode=%d is not valid, using mode=0\n" %mode) | |
776 |
|
776 | |||
777 | if times != None: |
|
777 | if times != None: | |
778 | sys.stderr.write("Decoder Warning: Argument 'times' in not used anymore\n") |
|
778 | sys.stderr.write("Decoder Warning: Argument 'times' in not used anymore\n") | |
779 |
|
779 | |||
780 | if self.code is None: |
|
780 | if self.code is None: | |
781 | print "Fail decoding: Code is not defined." |
|
781 | print "Fail decoding: Code is not defined." | |
782 | return |
|
782 | return | |
783 |
|
783 | |||
784 | self.__nProfiles = dataOut.nProfiles |
|
784 | self.__nProfiles = dataOut.nProfiles | |
785 | datadec = None |
|
785 | datadec = None | |
786 |
|
786 | |||
787 | if mode == 3: |
|
787 | if mode == 3: | |
788 | mode = 0 |
|
788 | mode = 0 | |
789 |
|
789 | |||
790 | if dataOut.flagDataAsBlock: |
|
790 | if dataOut.flagDataAsBlock: | |
791 | """ |
|
791 | """ | |
792 | Decoding when data have been read as block, |
|
792 | Decoding when data have been read as block, | |
793 | """ |
|
793 | """ | |
794 |
|
794 | |||
795 | if mode == 0: |
|
795 | if mode == 0: | |
796 | datadec = self.__convolutionByBlockInTime(dataOut.data) |
|
796 | datadec = self.__convolutionByBlockInTime(dataOut.data) | |
797 | if mode == 1: |
|
797 | if mode == 1: | |
798 | datadec = self.__convolutionByBlockInFreq(dataOut.data) |
|
798 | datadec = self.__convolutionByBlockInFreq(dataOut.data) | |
799 | else: |
|
799 | else: | |
800 | """ |
|
800 | """ | |
801 | Decoding when data have been read profile by profile |
|
801 | Decoding when data have been read profile by profile | |
802 | """ |
|
802 | """ | |
803 | if mode == 0: |
|
803 | if mode == 0: | |
804 | datadec = self.__convolutionInTime(dataOut.data) |
|
804 | datadec = self.__convolutionInTime(dataOut.data) | |
805 |
|
805 | |||
806 | if mode == 1: |
|
806 | if mode == 1: | |
807 | datadec = self.__convolutionInFreq(dataOut.data) |
|
807 | datadec = self.__convolutionInFreq(dataOut.data) | |
808 |
|
808 | |||
809 | if mode == 2: |
|
809 | if mode == 2: | |
810 | datadec = self.__convolutionInFreqOpt(dataOut.data) |
|
810 | datadec = self.__convolutionInFreqOpt(dataOut.data) | |
811 |
|
811 | |||
812 | if datadec is None: |
|
812 | if datadec is None: | |
813 | raise ValueError, "Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode |
|
813 | raise ValueError, "Codification mode selected is not valid: mode=%d. Try selecting 0 or 1" %mode | |
814 |
|
814 | |||
815 | dataOut.code = self.code |
|
815 | dataOut.code = self.code | |
816 | dataOut.nCode = self.nCode |
|
816 | dataOut.nCode = self.nCode | |
817 | dataOut.nBaud = self.nBaud |
|
817 | dataOut.nBaud = self.nBaud | |
818 |
|
818 | |||
819 | dataOut.data = datadec |
|
819 | dataOut.data = datadec | |
820 |
|
820 | |||
821 | dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]] |
|
821 | dataOut.heightList = dataOut.heightList[0:datadec.shape[-1]] | |
822 |
|
822 | |||
823 | dataOut.flagDecodeData = True #asumo q la data esta decodificada |
|
823 | dataOut.flagDecodeData = True #asumo q la data esta decodificada | |
824 |
|
824 | |||
825 | if self.__profIndex == self.nCode-1: |
|
825 | if self.__profIndex == self.nCode-1: | |
826 | self.__profIndex = 0 |
|
826 | self.__profIndex = 0 | |
827 | return 1 |
|
827 | return 1 | |
828 |
|
828 | |||
829 | self.__profIndex += 1 |
|
829 | self.__profIndex += 1 | |
830 |
|
830 | |||
831 | return 1 |
|
831 | return 1 | |
832 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip |
|
832 | # dataOut.flagDeflipData = True #asumo q la data no esta sin flip | |
833 |
|
833 | |||
834 |
|
834 | |||
835 | class ProfileConcat(Operation): |
|
835 | class ProfileConcat(Operation): | |
836 |
|
836 | |||
837 | isConfig = False |
|
837 | isConfig = False | |
838 | buffer = None |
|
838 | buffer = None | |
839 | concat_m =None |
|
839 | concat_m =None | |
840 |
|
840 | |||
841 | def __init__(self, **kwargs): |
|
841 | def __init__(self, **kwargs): | |
842 |
|
842 | |||
843 | Operation.__init__(self, **kwargs) |
|
843 | Operation.__init__(self, **kwargs) | |
844 | self.profileIndex = 0 |
|
844 | self.profileIndex = 0 | |
845 |
|
845 | |||
846 | def reset(self): |
|
846 | def reset(self): | |
847 | self.buffer = numpy.zeros_like(self.buffer) |
|
847 | self.buffer = numpy.zeros_like(self.buffer) | |
848 | self.start_index = 0 |
|
848 | self.start_index = 0 | |
849 | self.times = 1 |
|
849 | self.times = 1 | |
850 |
|
850 | |||
851 | def setup(self, data, m, n=1): |
|
851 | def setup(self, data, m, n=1): | |
852 | self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0])) |
|
852 | self.buffer = numpy.zeros((data.shape[0],data.shape[1]*m),dtype=type(data[0,0])) | |
853 | self.nHeights = data.shape[1]#.nHeights |
|
853 | self.nHeights = data.shape[1]#.nHeights | |
854 | self.start_index = 0 |
|
854 | self.start_index = 0 | |
855 | self.times = 1 |
|
855 | self.times = 1 | |
856 |
|
856 | |||
857 | def concat(self, data): |
|
857 | def concat(self, data): | |
858 |
|
858 | |||
859 | self.buffer[:,self.start_index:self.nHeights*self.times] = data.copy() |
|
859 | self.buffer[:,self.start_index:self.nHeights*self.times] = data.copy() | |
860 | self.start_index = self.start_index + self.nHeights |
|
860 | self.start_index = self.start_index + self.nHeights | |
861 |
|
861 | |||
862 | def run(self, dataOut, m): |
|
862 | def run(self, dataOut, m): | |
863 |
|
863 | |||
864 | self.concat_m= m |
|
864 | self.concat_m= m | |
865 | dataOut.flagNoData = True |
|
865 | dataOut.flagNoData = True | |
866 |
|
866 | |||
867 | if not self.isConfig: |
|
867 | if not self.isConfig: | |
868 | self.setup(dataOut.data, m, 1) |
|
868 | self.setup(dataOut.data, m, 1) | |
869 | self.isConfig = True |
|
869 | self.isConfig = True | |
870 |
|
870 | |||
871 | if dataOut.flagDataAsBlock: |
|
871 | if dataOut.flagDataAsBlock: | |
872 | raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False" |
|
872 | raise ValueError, "ProfileConcat can only be used when voltage have been read profile by profile, getBlock = False" | |
873 |
|
873 | |||
874 | else: |
|
874 | else: | |
875 | self.concat(dataOut.data) |
|
875 | self.concat(dataOut.data) | |
876 | self.times += 1 |
|
876 | self.times += 1 | |
877 | if self.times > m: |
|
877 | if self.times > m: | |
878 | dataOut.data = self.buffer |
|
878 | dataOut.data = self.buffer | |
879 | self.reset() |
|
879 | self.reset() | |
880 | dataOut.flagNoData = False |
|
880 | dataOut.flagNoData = False | |
881 | # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas |
|
881 | # se deben actualizar mas propiedades del header y del objeto dataOut, por ejemplo, las alturas | |
882 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
882 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
883 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m |
|
883 | xf = dataOut.heightList[0] + dataOut.nHeights * deltaHeight * m | |
884 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) |
|
884 | dataOut.heightList = numpy.arange(dataOut.heightList[0], xf, deltaHeight) | |
885 | dataOut.ippSeconds *= m |
|
885 | dataOut.ippSeconds *= m | |
886 | dataOut.concat_m = int(m) |
|
886 | dataOut.concat_m = int(m) | |
887 |
|
887 | |||
888 | class ProfileSelector(Operation): |
|
888 | class ProfileSelector(Operation): | |
889 |
|
889 | |||
890 | profileIndex = None |
|
890 | profileIndex = None | |
891 | # Tamanho total de los perfiles |
|
891 | # Tamanho total de los perfiles | |
892 | nProfiles = None |
|
892 | nProfiles = None | |
893 |
|
893 | |||
894 | def __init__(self, **kwargs): |
|
894 | def __init__(self, **kwargs): | |
895 |
|
895 | |||
896 | Operation.__init__(self, **kwargs) |
|
896 | Operation.__init__(self, **kwargs) | |
897 | self.profileIndex = 0 |
|
897 | self.profileIndex = 0 | |
898 |
|
898 | |||
899 | def incProfileIndex(self): |
|
899 | def incProfileIndex(self): | |
900 |
|
900 | |||
901 | self.profileIndex += 1 |
|
901 | self.profileIndex += 1 | |
902 |
|
902 | |||
903 | if self.profileIndex >= self.nProfiles: |
|
903 | if self.profileIndex >= self.nProfiles: | |
904 | self.profileIndex = 0 |
|
904 | self.profileIndex = 0 | |
905 |
|
905 | |||
906 | def isThisProfileInRange(self, profileIndex, minIndex, maxIndex): |
|
906 | def isThisProfileInRange(self, profileIndex, minIndex, maxIndex): | |
907 |
|
907 | |||
908 | if profileIndex < minIndex: |
|
908 | if profileIndex < minIndex: | |
909 | return False |
|
909 | return False | |
910 |
|
910 | |||
911 | if profileIndex > maxIndex: |
|
911 | if profileIndex > maxIndex: | |
912 | return False |
|
912 | return False | |
913 |
|
913 | |||
914 | return True |
|
914 | return True | |
915 |
|
915 | |||
916 | def isThisProfileInList(self, profileIndex, profileList): |
|
916 | def isThisProfileInList(self, profileIndex, profileList): | |
917 |
|
917 | |||
918 | if profileIndex not in profileList: |
|
918 | if profileIndex not in profileList: | |
919 | return False |
|
919 | return False | |
920 |
|
920 | |||
921 | return True |
|
921 | return True | |
922 |
|
922 | |||
923 | def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None): |
|
923 | def run(self, dataOut, profileList=None, profileRangeList=None, beam=None, byblock=False, rangeList = None, nProfiles=None): | |
924 |
|
924 | |||
925 | """ |
|
925 | """ | |
926 | ProfileSelector: |
|
926 | ProfileSelector: | |
927 |
|
927 | |||
928 | Inputs: |
|
928 | Inputs: | |
929 | profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8) |
|
929 | profileList : Index of profiles selected. Example: profileList = (0,1,2,7,8) | |
930 |
|
930 | |||
931 | profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30) |
|
931 | profileRangeList : Minimum and maximum profile indexes. Example: profileRangeList = (4, 30) | |
932 |
|
932 | |||
933 | rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256)) |
|
933 | rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256)) | |
934 |
|
934 | |||
935 | """ |
|
935 | """ | |
936 |
|
936 | |||
937 | if rangeList is not None: |
|
937 | if rangeList is not None: | |
938 | if type(rangeList[0]) not in (tuple, list): |
|
938 | if type(rangeList[0]) not in (tuple, list): | |
939 | rangeList = [rangeList] |
|
939 | rangeList = [rangeList] | |
940 |
|
940 | |||
941 | dataOut.flagNoData = True |
|
941 | dataOut.flagNoData = True | |
942 |
|
942 | |||
943 | if dataOut.flagDataAsBlock: |
|
943 | if dataOut.flagDataAsBlock: | |
944 | """ |
|
944 | """ | |
945 | data dimension = [nChannels, nProfiles, nHeis] |
|
945 | data dimension = [nChannels, nProfiles, nHeis] | |
946 | """ |
|
946 | """ | |
947 | if profileList != None: |
|
947 | if profileList != None: | |
948 | dataOut.data = dataOut.data[:,profileList,:] |
|
948 | dataOut.data = dataOut.data[:,profileList,:] | |
949 |
|
949 | |||
950 | if profileRangeList != None: |
|
950 | if profileRangeList != None: | |
951 | minIndex = profileRangeList[0] |
|
951 | minIndex = profileRangeList[0] | |
952 | maxIndex = profileRangeList[1] |
|
952 | maxIndex = profileRangeList[1] | |
953 | profileList = range(minIndex, maxIndex+1) |
|
953 | profileList = range(minIndex, maxIndex+1) | |
954 |
|
954 | |||
955 | dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:] |
|
955 | dataOut.data = dataOut.data[:,minIndex:maxIndex+1,:] | |
956 |
|
956 | |||
957 | if rangeList != None: |
|
957 | if rangeList != None: | |
958 |
|
958 | |||
959 | profileList = [] |
|
959 | profileList = [] | |
960 |
|
960 | |||
961 | for thisRange in rangeList: |
|
961 | for thisRange in rangeList: | |
962 | minIndex = thisRange[0] |
|
962 | minIndex = thisRange[0] | |
963 | maxIndex = thisRange[1] |
|
963 | maxIndex = thisRange[1] | |
964 |
|
964 | |||
965 | profileList.extend(range(minIndex, maxIndex+1)) |
|
965 | profileList.extend(range(minIndex, maxIndex+1)) | |
966 |
|
966 | |||
967 | dataOut.data = dataOut.data[:,profileList,:] |
|
967 | dataOut.data = dataOut.data[:,profileList,:] | |
968 |
|
968 | |||
969 | dataOut.nProfiles = len(profileList) |
|
969 | dataOut.nProfiles = len(profileList) | |
970 | dataOut.profileIndex = dataOut.nProfiles - 1 |
|
970 | dataOut.profileIndex = dataOut.nProfiles - 1 | |
971 | dataOut.flagNoData = False |
|
971 | dataOut.flagNoData = False | |
972 |
|
972 | |||
973 | return True |
|
973 | return True | |
974 |
|
974 | |||
975 | """ |
|
975 | """ | |
976 | data dimension = [nChannels, nHeis] |
|
976 | data dimension = [nChannels, nHeis] | |
977 | """ |
|
977 | """ | |
978 |
|
978 | |||
979 | if profileList != None: |
|
979 | if profileList != None: | |
980 |
|
980 | |||
981 | if self.isThisProfileInList(dataOut.profileIndex, profileList): |
|
981 | if self.isThisProfileInList(dataOut.profileIndex, profileList): | |
982 |
|
982 | |||
983 | self.nProfiles = len(profileList) |
|
983 | self.nProfiles = len(profileList) | |
984 | dataOut.nProfiles = self.nProfiles |
|
984 | dataOut.nProfiles = self.nProfiles | |
985 | dataOut.profileIndex = self.profileIndex |
|
985 | dataOut.profileIndex = self.profileIndex | |
986 | dataOut.flagNoData = False |
|
986 | dataOut.flagNoData = False | |
987 |
|
987 | |||
988 | self.incProfileIndex() |
|
988 | self.incProfileIndex() | |
989 | return True |
|
989 | return True | |
990 |
|
990 | |||
991 | if profileRangeList != None: |
|
991 | if profileRangeList != None: | |
992 |
|
992 | |||
993 | minIndex = profileRangeList[0] |
|
993 | minIndex = profileRangeList[0] | |
994 | maxIndex = profileRangeList[1] |
|
994 | maxIndex = profileRangeList[1] | |
995 |
|
995 | |||
996 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): |
|
996 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): | |
997 |
|
997 | |||
998 | self.nProfiles = maxIndex - minIndex + 1 |
|
998 | self.nProfiles = maxIndex - minIndex + 1 | |
999 | dataOut.nProfiles = self.nProfiles |
|
999 | dataOut.nProfiles = self.nProfiles | |
1000 | dataOut.profileIndex = self.profileIndex |
|
1000 | dataOut.profileIndex = self.profileIndex | |
1001 | dataOut.flagNoData = False |
|
1001 | dataOut.flagNoData = False | |
1002 |
|
1002 | |||
1003 | self.incProfileIndex() |
|
1003 | self.incProfileIndex() | |
1004 | return True |
|
1004 | return True | |
1005 |
|
1005 | |||
1006 | if rangeList != None: |
|
1006 | if rangeList != None: | |
1007 |
|
1007 | |||
1008 | nProfiles = 0 |
|
1008 | nProfiles = 0 | |
1009 |
|
1009 | |||
1010 | for thisRange in rangeList: |
|
1010 | for thisRange in rangeList: | |
1011 | minIndex = thisRange[0] |
|
1011 | minIndex = thisRange[0] | |
1012 | maxIndex = thisRange[1] |
|
1012 | maxIndex = thisRange[1] | |
1013 |
|
1013 | |||
1014 | nProfiles += maxIndex - minIndex + 1 |
|
1014 | nProfiles += maxIndex - minIndex + 1 | |
1015 |
|
1015 | |||
1016 | for thisRange in rangeList: |
|
1016 | for thisRange in rangeList: | |
1017 |
|
1017 | |||
1018 | minIndex = thisRange[0] |
|
1018 | minIndex = thisRange[0] | |
1019 | maxIndex = thisRange[1] |
|
1019 | maxIndex = thisRange[1] | |
1020 |
|
1020 | |||
1021 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): |
|
1021 | if self.isThisProfileInRange(dataOut.profileIndex, minIndex, maxIndex): | |
1022 |
|
1022 | |||
1023 | self.nProfiles = nProfiles |
|
1023 | self.nProfiles = nProfiles | |
1024 | dataOut.nProfiles = self.nProfiles |
|
1024 | dataOut.nProfiles = self.nProfiles | |
1025 | dataOut.profileIndex = self.profileIndex |
|
1025 | dataOut.profileIndex = self.profileIndex | |
1026 | dataOut.flagNoData = False |
|
1026 | dataOut.flagNoData = False | |
1027 |
|
1027 | |||
1028 | self.incProfileIndex() |
|
1028 | self.incProfileIndex() | |
1029 |
|
1029 | |||
1030 | break |
|
1030 | break | |
1031 |
|
1031 | |||
1032 | return True |
|
1032 | return True | |
1033 |
|
1033 | |||
1034 |
|
1034 | |||
1035 | if beam != None: #beam is only for AMISR data |
|
1035 | if beam != None: #beam is only for AMISR data | |
1036 | if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]): |
|
1036 | if self.isThisProfileInList(dataOut.profileIndex, dataOut.beamRangeDict[beam]): | |
1037 | dataOut.flagNoData = False |
|
1037 | dataOut.flagNoData = False | |
1038 | dataOut.profileIndex = self.profileIndex |
|
1038 | dataOut.profileIndex = self.profileIndex | |
1039 |
|
1039 | |||
1040 | self.incProfileIndex() |
|
1040 | self.incProfileIndex() | |
1041 |
|
1041 | |||
1042 | return True |
|
1042 | return True | |
1043 |
|
1043 | |||
1044 | raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter" |
|
1044 | raise ValueError, "ProfileSelector needs profileList, profileRangeList or rangeList parameter" | |
1045 |
|
1045 | |||
1046 | return False |
|
1046 | return False | |
1047 |
|
1047 | |||
1048 | class Reshaper(Operation): |
|
1048 | class Reshaper(Operation): | |
1049 |
|
1049 | |||
1050 | def __init__(self, **kwargs): |
|
1050 | def __init__(self, **kwargs): | |
1051 |
|
1051 | |||
1052 | Operation.__init__(self, **kwargs) |
|
1052 | Operation.__init__(self, **kwargs) | |
1053 |
|
1053 | |||
1054 | self.__buffer = None |
|
1054 | self.__buffer = None | |
1055 | self.__nitems = 0 |
|
1055 | self.__nitems = 0 | |
1056 |
|
1056 | |||
1057 | def __appendProfile(self, dataOut, nTxs): |
|
1057 | def __appendProfile(self, dataOut, nTxs): | |
1058 |
|
1058 | |||
1059 | if self.__buffer is None: |
|
1059 | if self.__buffer is None: | |
1060 | shape = (dataOut.nChannels, int(dataOut.nHeights/nTxs) ) |
|
1060 | shape = (dataOut.nChannels, int(dataOut.nHeights/nTxs) ) | |
1061 | self.__buffer = numpy.empty(shape, dtype = dataOut.data.dtype) |
|
1061 | self.__buffer = numpy.empty(shape, dtype = dataOut.data.dtype) | |
1062 |
|
1062 | |||
1063 | ini = dataOut.nHeights * self.__nitems |
|
1063 | ini = dataOut.nHeights * self.__nitems | |
1064 | end = ini + dataOut.nHeights |
|
1064 | end = ini + dataOut.nHeights | |
1065 |
|
1065 | |||
1066 | self.__buffer[:, ini:end] = dataOut.data |
|
1066 | self.__buffer[:, ini:end] = dataOut.data | |
1067 |
|
1067 | |||
1068 | self.__nitems += 1 |
|
1068 | self.__nitems += 1 | |
1069 |
|
1069 | |||
1070 | return int(self.__nitems*nTxs) |
|
1070 | return int(self.__nitems*nTxs) | |
1071 |
|
1071 | |||
1072 | def __getBuffer(self): |
|
1072 | def __getBuffer(self): | |
1073 |
|
1073 | |||
1074 | if self.__nitems == int(1./self.__nTxs): |
|
1074 | if self.__nitems == int(1./self.__nTxs): | |
1075 |
|
1075 | |||
1076 | self.__nitems = 0 |
|
1076 | self.__nitems = 0 | |
1077 |
|
1077 | |||
1078 | return self.__buffer.copy() |
|
1078 | return self.__buffer.copy() | |
1079 |
|
1079 | |||
1080 | return None |
|
1080 | return None | |
1081 |
|
1081 | |||
1082 | def __checkInputs(self, dataOut, shape, nTxs): |
|
1082 | def __checkInputs(self, dataOut, shape, nTxs): | |
1083 |
|
1083 | |||
1084 | if shape is None and nTxs is None: |
|
1084 | if shape is None and nTxs is None: | |
1085 | raise ValueError, "Reshaper: shape of factor should be defined" |
|
1085 | raise ValueError, "Reshaper: shape of factor should be defined" | |
1086 |
|
1086 | |||
1087 | if nTxs: |
|
1087 | if nTxs: | |
1088 | if nTxs < 0: |
|
1088 | if nTxs < 0: | |
1089 | raise ValueError, "nTxs should be greater than 0" |
|
1089 | raise ValueError, "nTxs should be greater than 0" | |
1090 |
|
1090 | |||
1091 | if nTxs < 1 and dataOut.nProfiles % (1./nTxs) != 0: |
|
1091 | if nTxs < 1 and dataOut.nProfiles % (1./nTxs) != 0: | |
1092 | raise ValueError, "nProfiles= %d is not divisibled by (1./nTxs) = %f" %(dataOut.nProfiles, (1./nTxs)) |
|
1092 | raise ValueError, "nProfiles= %d is not divisibled by (1./nTxs) = %f" %(dataOut.nProfiles, (1./nTxs)) | |
1093 |
|
1093 | |||
1094 | shape = [dataOut.nChannels, dataOut.nProfiles*nTxs, dataOut.nHeights/nTxs] |
|
1094 | shape = [dataOut.nChannels, dataOut.nProfiles*nTxs, dataOut.nHeights/nTxs] | |
1095 |
|
1095 | |||
1096 | return shape, nTxs |
|
1096 | return shape, nTxs | |
1097 |
|
1097 | |||
1098 | if len(shape) != 2 and len(shape) != 3: |
|
1098 | if len(shape) != 2 and len(shape) != 3: | |
1099 | raise ValueError, "shape dimension should be equal to 2 or 3. shape = (nProfiles, nHeis) or (nChannels, nProfiles, nHeis). Actually shape = (%d, %d, %d)" %(dataOut.nChannels, dataOut.nProfiles, dataOut.nHeights) |
|
1099 | raise ValueError, "shape dimension should be equal to 2 or 3. shape = (nProfiles, nHeis) or (nChannels, nProfiles, nHeis). Actually shape = (%d, %d, %d)" %(dataOut.nChannels, dataOut.nProfiles, dataOut.nHeights) | |
1100 |
|
1100 | |||
1101 | if len(shape) == 2: |
|
1101 | if len(shape) == 2: | |
1102 | shape_tuple = [dataOut.nChannels] |
|
1102 | shape_tuple = [dataOut.nChannels] | |
1103 | shape_tuple.extend(shape) |
|
1103 | shape_tuple.extend(shape) | |
1104 | else: |
|
1104 | else: | |
1105 | shape_tuple = list(shape) |
|
1105 | shape_tuple = list(shape) | |
1106 |
|
1106 | |||
1107 | nTxs = 1.0*shape_tuple[1]/dataOut.nProfiles |
|
1107 | nTxs = 1.0*shape_tuple[1]/dataOut.nProfiles | |
1108 |
|
1108 | |||
1109 | return shape_tuple, nTxs |
|
1109 | return shape_tuple, nTxs | |
1110 |
|
1110 | |||
1111 | def run(self, dataOut, shape=None, nTxs=None): |
|
1111 | def run(self, dataOut, shape=None, nTxs=None): | |
1112 |
|
1112 | |||
1113 | shape_tuple, self.__nTxs = self.__checkInputs(dataOut, shape, nTxs) |
|
1113 | shape_tuple, self.__nTxs = self.__checkInputs(dataOut, shape, nTxs) | |
1114 |
|
1114 | |||
1115 | dataOut.flagNoData = True |
|
1115 | dataOut.flagNoData = True | |
1116 | profileIndex = None |
|
1116 | profileIndex = None | |
1117 |
|
1117 | |||
1118 | if dataOut.flagDataAsBlock: |
|
1118 | if dataOut.flagDataAsBlock: | |
1119 |
|
1119 | |||
1120 | dataOut.data = numpy.reshape(dataOut.data, shape_tuple) |
|
1120 | dataOut.data = numpy.reshape(dataOut.data, shape_tuple) | |
1121 | dataOut.flagNoData = False |
|
1121 | dataOut.flagNoData = False | |
1122 |
|
1122 | |||
1123 | profileIndex = int(dataOut.nProfiles*self.__nTxs) - 1 |
|
1123 | profileIndex = int(dataOut.nProfiles*self.__nTxs) - 1 | |
1124 |
|
1124 | |||
1125 | else: |
|
1125 | else: | |
1126 |
|
1126 | |||
1127 | if self.__nTxs < 1: |
|
1127 | if self.__nTxs < 1: | |
1128 |
|
1128 | |||
1129 | self.__appendProfile(dataOut, self.__nTxs) |
|
1129 | self.__appendProfile(dataOut, self.__nTxs) | |
1130 | new_data = self.__getBuffer() |
|
1130 | new_data = self.__getBuffer() | |
1131 |
|
1131 | |||
1132 | if new_data is not None: |
|
1132 | if new_data is not None: | |
1133 | dataOut.data = new_data |
|
1133 | dataOut.data = new_data | |
1134 | dataOut.flagNoData = False |
|
1134 | dataOut.flagNoData = False | |
1135 |
|
1135 | |||
1136 | profileIndex = dataOut.profileIndex*nTxs |
|
1136 | profileIndex = dataOut.profileIndex*nTxs | |
1137 |
|
1137 | |||
1138 | else: |
|
1138 | else: | |
1139 | raise ValueError, "nTxs should be greater than 0 and lower than 1, or use VoltageReader(..., getblock=True)" |
|
1139 | raise ValueError, "nTxs should be greater than 0 and lower than 1, or use VoltageReader(..., getblock=True)" | |
1140 |
|
1140 | |||
1141 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1141 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1142 |
|
1142 | |||
1143 | dataOut.heightList = numpy.arange(dataOut.nHeights/self.__nTxs) * deltaHeight + dataOut.heightList[0] |
|
1143 | dataOut.heightList = numpy.arange(dataOut.nHeights/self.__nTxs) * deltaHeight + dataOut.heightList[0] | |
1144 |
|
1144 | |||
1145 | dataOut.nProfiles = int(dataOut.nProfiles*self.__nTxs) |
|
1145 | dataOut.nProfiles = int(dataOut.nProfiles*self.__nTxs) | |
1146 |
|
1146 | |||
1147 | dataOut.profileIndex = profileIndex |
|
1147 | dataOut.profileIndex = profileIndex | |
1148 |
|
1148 | |||
1149 | dataOut.ippSeconds /= self.__nTxs |
|
1149 | dataOut.ippSeconds /= self.__nTxs | |
1150 |
|
1150 | |||
1151 | class SplitProfiles(Operation): |
|
1151 | class SplitProfiles(Operation): | |
1152 |
|
1152 | |||
1153 | def __init__(self, **kwargs): |
|
1153 | def __init__(self, **kwargs): | |
1154 |
|
1154 | |||
1155 | Operation.__init__(self, **kwargs) |
|
1155 | Operation.__init__(self, **kwargs) | |
1156 |
|
1156 | |||
1157 | def run(self, dataOut, n): |
|
1157 | def run(self, dataOut, n): | |
1158 |
|
1158 | |||
1159 | dataOut.flagNoData = True |
|
1159 | dataOut.flagNoData = True | |
1160 | profileIndex = None |
|
1160 | profileIndex = None | |
1161 |
|
1161 | |||
1162 | if dataOut.flagDataAsBlock: |
|
1162 | if dataOut.flagDataAsBlock: | |
1163 |
|
1163 | |||
1164 | #nchannels, nprofiles, nsamples |
|
1164 | #nchannels, nprofiles, nsamples | |
1165 | shape = dataOut.data.shape |
|
1165 | shape = dataOut.data.shape | |
1166 |
|
1166 | |||
1167 | if shape[2] % n != 0: |
|
1167 | if shape[2] % n != 0: | |
1168 | raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[2]) |
|
1168 | raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[2]) | |
1169 |
|
1169 | |||
1170 | new_shape = shape[0], shape[1]*n, shape[2]/n |
|
1170 | new_shape = shape[0], shape[1]*n, shape[2]/n | |
1171 |
|
1171 | |||
1172 | dataOut.data = numpy.reshape(dataOut.data, new_shape) |
|
1172 | dataOut.data = numpy.reshape(dataOut.data, new_shape) | |
1173 | dataOut.flagNoData = False |
|
1173 | dataOut.flagNoData = False | |
1174 |
|
1174 | |||
1175 | profileIndex = int(dataOut.nProfiles/n) - 1 |
|
1175 | profileIndex = int(dataOut.nProfiles/n) - 1 | |
1176 |
|
1176 | |||
1177 | else: |
|
1177 | else: | |
1178 |
|
1178 | |||
1179 | raise ValueError, "Could not split the data when is read Profile by Profile. Use VoltageReader(..., getblock=True)" |
|
1179 | raise ValueError, "Could not split the data when is read Profile by Profile. Use VoltageReader(..., getblock=True)" | |
1180 |
|
1180 | |||
1181 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1181 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1182 |
|
1182 | |||
1183 | dataOut.heightList = numpy.arange(dataOut.nHeights/n) * deltaHeight + dataOut.heightList[0] |
|
1183 | dataOut.heightList = numpy.arange(dataOut.nHeights/n) * deltaHeight + dataOut.heightList[0] | |
1184 |
|
1184 | |||
1185 | dataOut.nProfiles = int(dataOut.nProfiles*n) |
|
1185 | dataOut.nProfiles = int(dataOut.nProfiles*n) | |
1186 |
|
1186 | |||
1187 | dataOut.profileIndex = profileIndex |
|
1187 | dataOut.profileIndex = profileIndex | |
1188 |
|
1188 | |||
1189 | dataOut.ippSeconds /= n |
|
1189 | dataOut.ippSeconds /= n | |
1190 |
|
1190 | |||
1191 | class CombineProfiles(Operation): |
|
1191 | class CombineProfiles(Operation): | |
1192 |
|
1192 | |||
1193 | def __init__(self, **kwargs): |
|
1193 | def __init__(self, **kwargs): | |
1194 |
|
1194 | |||
1195 | Operation.__init__(self, **kwargs) |
|
1195 | Operation.__init__(self, **kwargs) | |
1196 |
|
1196 | |||
1197 | self.__remData = None |
|
1197 | self.__remData = None | |
1198 | self.__profileIndex = 0 |
|
1198 | self.__profileIndex = 0 | |
1199 |
|
1199 | |||
1200 | def run(self, dataOut, n): |
|
1200 | def run(self, dataOut, n): | |
1201 |
|
1201 | |||
1202 | dataOut.flagNoData = True |
|
1202 | dataOut.flagNoData = True | |
1203 | profileIndex = None |
|
1203 | profileIndex = None | |
1204 |
|
1204 | |||
1205 | if dataOut.flagDataAsBlock: |
|
1205 | if dataOut.flagDataAsBlock: | |
1206 |
|
1206 | |||
1207 | #nchannels, nprofiles, nsamples |
|
1207 | #nchannels, nprofiles, nsamples | |
1208 | shape = dataOut.data.shape |
|
1208 | shape = dataOut.data.shape | |
1209 | new_shape = shape[0], shape[1]/n, shape[2]*n |
|
1209 | new_shape = shape[0], shape[1]/n, shape[2]*n | |
1210 |
|
1210 | |||
1211 | if shape[1] % n != 0: |
|
1211 | if shape[1] % n != 0: | |
1212 | raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[1]) |
|
1212 | raise ValueError, "Could not split the data, n=%d has to be multiple of %d" %(n, shape[1]) | |
1213 |
|
1213 | |||
1214 | dataOut.data = numpy.reshape(dataOut.data, new_shape) |
|
1214 | dataOut.data = numpy.reshape(dataOut.data, new_shape) | |
1215 | dataOut.flagNoData = False |
|
1215 | dataOut.flagNoData = False | |
1216 |
|
1216 | |||
1217 | profileIndex = int(dataOut.nProfiles*n) - 1 |
|
1217 | profileIndex = int(dataOut.nProfiles*n) - 1 | |
1218 |
|
1218 | |||
1219 | else: |
|
1219 | else: | |
1220 |
|
1220 | |||
1221 | #nchannels, nsamples |
|
1221 | #nchannels, nsamples | |
1222 | if self.__remData is None: |
|
1222 | if self.__remData is None: | |
1223 | newData = dataOut.data |
|
1223 | newData = dataOut.data | |
1224 | else: |
|
1224 | else: | |
1225 | newData = numpy.concatenate((self.__remData, dataOut.data), axis=1) |
|
1225 | newData = numpy.concatenate((self.__remData, dataOut.data), axis=1) | |
1226 |
|
1226 | |||
1227 | self.__profileIndex += 1 |
|
1227 | self.__profileIndex += 1 | |
1228 |
|
1228 | |||
1229 | if self.__profileIndex < n: |
|
1229 | if self.__profileIndex < n: | |
1230 | self.__remData = newData |
|
1230 | self.__remData = newData | |
1231 | #continue |
|
1231 | #continue | |
1232 | return |
|
1232 | return | |
1233 |
|
1233 | |||
1234 | self.__profileIndex = 0 |
|
1234 | self.__profileIndex = 0 | |
1235 | self.__remData = None |
|
1235 | self.__remData = None | |
1236 |
|
1236 | |||
1237 | dataOut.data = newData |
|
1237 | dataOut.data = newData | |
1238 | dataOut.flagNoData = False |
|
1238 | dataOut.flagNoData = False | |
1239 |
|
1239 | |||
1240 | profileIndex = dataOut.profileIndex/n |
|
1240 | profileIndex = dataOut.profileIndex/n | |
1241 |
|
1241 | |||
1242 |
|
1242 | |||
1243 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1243 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1244 |
|
1244 | |||
1245 | dataOut.heightList = numpy.arange(dataOut.nHeights*n) * deltaHeight + dataOut.heightList[0] |
|
1245 | dataOut.heightList = numpy.arange(dataOut.nHeights*n) * deltaHeight + dataOut.heightList[0] | |
1246 |
|
1246 | |||
1247 | dataOut.nProfiles = int(dataOut.nProfiles/n) |
|
1247 | dataOut.nProfiles = int(dataOut.nProfiles/n) | |
1248 |
|
1248 | |||
1249 | dataOut.profileIndex = profileIndex |
|
1249 | dataOut.profileIndex = profileIndex | |
1250 |
|
1250 | |||
1251 | dataOut.ippSeconds *= n |
|
1251 | dataOut.ippSeconds *= n | |
1252 |
|
1252 | |||
1253 |
|
1253 | |||
1254 | class SSheightProfiles(Operation): |
|
1254 | class SSheightProfiles(Operation): | |
1255 |
|
1255 | |||
1256 | step = None |
|
1256 | step = None | |
1257 | nsamples = None |
|
1257 | nsamples = None | |
1258 | bufferShape = None |
|
1258 | bufferShape = None | |
1259 | profileShape = None |
|
1259 | profileShape = None | |
1260 | sshProfiles = None |
|
1260 | sshProfiles = None | |
1261 | profileIndex = None |
|
1261 | profileIndex = None | |
1262 |
|
1262 | |||
1263 | def __init__(self, **kwargs): |
|
1263 | def __init__(self, **kwargs): | |
1264 |
|
1264 | |||
1265 | Operation.__init__(self, **kwargs) |
|
1265 | Operation.__init__(self, **kwargs) | |
1266 | self.isConfig = False |
|
1266 | self.isConfig = False | |
1267 |
|
1267 | |||
1268 | def setup(self,dataOut ,step = None , nsamples = None): |
|
1268 | def setup(self,dataOut ,step = None , nsamples = None): | |
1269 |
|
1269 | |||
1270 | if step == None and nsamples == None: |
|
1270 | if step == None and nsamples == None: | |
1271 | raise ValueError, "step or nheights should be specified ..." |
|
1271 | raise ValueError, "step or nheights should be specified ..." | |
1272 |
|
1272 | |||
1273 | self.step = step |
|
1273 | self.step = step | |
1274 | self.nsamples = nsamples |
|
1274 | self.nsamples = nsamples | |
1275 | self.__nChannels = dataOut.nChannels |
|
1275 | self.__nChannels = dataOut.nChannels | |
1276 | self.__nProfiles = dataOut.nProfiles |
|
1276 | self.__nProfiles = dataOut.nProfiles | |
1277 | self.__nHeis = dataOut.nHeights |
|
1277 | self.__nHeis = dataOut.nHeights | |
1278 | shape = dataOut.data.shape #nchannels, nprofiles, nsamples |
|
1278 | shape = dataOut.data.shape #nchannels, nprofiles, nsamples | |
1279 | print "input nChannels",self.__nChannels |
|
1279 | print "input nChannels",self.__nChannels | |
1280 | print "input nProfiles",self.__nProfiles |
|
1280 | print "input nProfiles",self.__nProfiles | |
1281 | print "input nHeis",self.__nHeis |
|
1281 | print "input nHeis",self.__nHeis | |
1282 | print "input Shape",shape |
|
1282 | print "input Shape",shape | |
1283 |
|
1283 | |||
1284 |
|
1284 | |||
1285 |
|
1285 | |||
1286 | residue = (shape[1] - self.nsamples) % self.step |
|
1286 | residue = (shape[1] - self.nsamples) % self.step | |
1287 | if residue != 0: |
|
1287 | if residue != 0: | |
1288 | print "The residue is %d, step=%d should be multiple of %d to avoid loss of %d samples"%(residue,step,shape[1] - self.nsamples,residue) |
|
1288 | print "The residue is %d, step=%d should be multiple of %d to avoid loss of %d samples"%(residue,step,shape[1] - self.nsamples,residue) | |
1289 |
|
1289 | |||
1290 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1290 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1291 | numberProfile = self.nsamples |
|
1291 | numberProfile = self.nsamples | |
1292 | numberSamples = (shape[1] - self.nsamples)/self.step |
|
1292 | numberSamples = (shape[1] - self.nsamples)/self.step | |
1293 |
|
1293 | |||
1294 | print "new numberProfile",numberProfile |
|
1294 | print "new numberProfile",numberProfile | |
1295 | print "new numberSamples",numberSamples |
|
1295 | print "new numberSamples",numberSamples | |
1296 |
|
1296 | |||
1297 | print "New number of profile: %d, number of height: %d, Resolution %f Km"%(numberProfile,numberSamples,deltaHeight*self.step) |
|
1297 | print "New number of profile: %d, number of height: %d, Resolution %f Km"%(numberProfile,numberSamples,deltaHeight*self.step) | |
1298 |
|
1298 | |||
1299 | self.bufferShape = shape[0], numberSamples, numberProfile # nchannels, nsamples , nprofiles |
|
1299 | self.bufferShape = shape[0], numberSamples, numberProfile # nchannels, nsamples , nprofiles | |
1300 | self.profileShape = shape[0], numberProfile, numberSamples # nchannels, nprofiles, nsamples |
|
1300 | self.profileShape = shape[0], numberProfile, numberSamples # nchannels, nprofiles, nsamples | |
1301 |
|
1301 | |||
1302 | self.buffer = numpy.zeros(self.bufferShape , dtype=numpy.complex) |
|
1302 | self.buffer = numpy.zeros(self.bufferShape , dtype=numpy.complex) | |
1303 | self.sshProfiles = numpy.zeros(self.profileShape, dtype=numpy.complex) |
|
1303 | self.sshProfiles = numpy.zeros(self.profileShape, dtype=numpy.complex) | |
1304 |
|
1304 | |||
1305 | def run(self, dataOut, step, nsamples): |
|
1305 | def run(self, dataOut, step, nsamples): | |
1306 |
|
1306 | |||
1307 | dataOut.flagNoData = True |
|
1307 | dataOut.flagNoData = True | |
1308 | dataOut.flagDataAsBlock = False |
|
1308 | dataOut.flagDataAsBlock = False | |
1309 | profileIndex = None |
|
1309 | profileIndex = None | |
1310 |
|
1310 | |||
1311 |
|
1311 | |||
1312 | if not self.isConfig: |
|
1312 | if not self.isConfig: | |
1313 | self.setup(dataOut, step=step , nsamples=nsamples) |
|
1313 | self.setup(dataOut, step=step , nsamples=nsamples) | |
1314 | self.isConfig = True |
|
1314 | self.isConfig = True | |
1315 |
|
1315 | |||
1316 | for i in range(self.buffer.shape[1]): |
|
1316 | for i in range(self.buffer.shape[1]): | |
1317 | #self.buffer[:,i] = numpy.flip(dataOut.data[:,i*self.step:i*self.step + self.nsamples]) |
|
1317 | #self.buffer[:,i] = numpy.flip(dataOut.data[:,i*self.step:i*self.step + self.nsamples]) | |
1318 | self.buffer[:,i] = dataOut.data[:,i*self.step:i*self.step + self.nsamples] |
|
1318 | self.buffer[:,i] = dataOut.data[:,i*self.step:i*self.step + self.nsamples] | |
1319 |
|
1319 | #self.buffer[:,j,self.__nHeis-j*self.step - self.nheights:self.__nHeis-j*self.step] = numpy.flip(dataOut.data[:,j*self.step:j*self.step + self.nheights]) | ||
1320 | #self.buffer[:,j,self.__nHeis-j*self.step - self.nheights:self.__nHeis-j*self.step] = numpy.flip(dataOut.data[:,j*self.step:j*self.step + self.nheights]) |
|
|||
1321 |
|
1320 | |||
1322 | for j in range(self.buffer.shape[0]): |
|
1321 | for j in range(self.buffer.shape[0]): | |
1323 | self.sshProfiles[j] = numpy.transpose(self.buffer[j]) |
|
1322 | self.sshProfiles[j] = numpy.transpose(self.buffer[j]) | |
1324 |
|
1323 | |||
1325 | profileIndex = self.nsamples |
|
1324 | profileIndex = self.nsamples | |
1326 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1325 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1327 | ippSeconds = (deltaHeight*1.0e-6)/(0.15) |
|
1326 | ippSeconds = (deltaHeight*1.0e-6)/(0.15) | |
|
1327 | #print "ippSeconds",ippSeconds | |||
1328 | try: |
|
1328 | try: | |
1329 | if dataOut.concat_m is not None: |
|
1329 | if dataOut.concat_m is not None: | |
1330 | ippSeconds= ippSeconds/float(dataOut.concat_m) |
|
1330 | ippSeconds= ippSeconds/float(dataOut.concat_m) | |
1331 | #print "Profile concat %d"%dataOut.concat_m |
|
1331 | #print "Profile concat %d"%dataOut.concat_m | |
1332 | except: |
|
1332 | except: | |
1333 | pass |
|
1333 | pass | |
1334 |
|
1334 | |||
1335 | dataOut.data = self.sshProfiles |
|
1335 | dataOut.data = self.sshProfiles | |
1336 | dataOut.flagNoData = False |
|
1336 | dataOut.flagNoData = False | |
1337 | dataOut.heightList = numpy.arange(self.buffer.shape[1]) *self.step*deltaHeight + dataOut.heightList[0] |
|
1337 | dataOut.heightList = numpy.arange(self.buffer.shape[1]) *self.step*deltaHeight + dataOut.heightList[0] | |
1338 | dataOut.nProfiles = int(dataOut.nProfiles*self.nsamples) |
|
1338 | dataOut.nProfiles = int(dataOut.nProfiles*self.nsamples) | |
1339 | dataOut.profileIndex = profileIndex |
|
1339 | dataOut.profileIndex = profileIndex | |
1340 | dataOut.flagDataAsBlock = True |
|
1340 | dataOut.flagDataAsBlock = True | |
1341 | dataOut.ippSeconds = ippSeconds |
|
1341 | dataOut.ippSeconds = ippSeconds | |
1342 | dataOut.step = self.step |
|
1342 | dataOut.step = self.step | |
1343 |
|
1343 | |||
1344 |
|
1344 | |||
1345 | import time |
|
1345 | import time | |
1346 | ################################################# |
|
1346 | ################################################# | |
1347 |
|
1347 | |||
1348 | class decoPseudorandom(Operation): |
|
1348 | class decoPseudorandom(Operation): | |
1349 |
|
1349 | |||
1350 | nProfiles= 0 |
|
1350 | nProfiles= 0 | |
1351 | buffer= None |
|
1351 | buffer= None | |
1352 | isConfig = False |
|
1352 | isConfig = False | |
1353 |
|
1353 | |||
1354 | def setup(self, clen= 10000,seed= 0,Nranges= 1000,oversample=1): |
|
1354 | def setup(self, clen= 10000,seed= 0,Nranges= 1000,oversample=1): | |
1355 | #code = create_pseudo_random_code(clen=clen, seed=seed) |
|
1355 | #code = create_pseudo_random_code(clen=clen, seed=seed) | |
1356 | code= rep_seq(create_pseudo_random_code(clen=clen, seed=seed),rep=oversample) |
|
1356 | code= rep_seq(create_pseudo_random_code(clen=clen, seed=seed),rep=oversample) | |
1357 | #print ("code_rx", code.shape) |
|
1357 | #print ("code_rx", code.shape) | |
1358 | #N = int(an_len/clen) # 100 |
|
1358 | #N = int(an_len/clen) # 100 | |
1359 | B_cache = 0 |
|
1359 | B_cache = 0 | |
1360 | r_cache = 0 |
|
1360 | r_cache = 0 | |
1361 | B_cached = False |
|
1361 | B_cached = False | |
1362 | r = create_estimation_matrix(code=code, cache=True, rmax=Nranges) |
|
1362 | r = create_estimation_matrix(code=code, cache=True, rmax=Nranges) | |
1363 | #print ("code shape", code.shape) |
|
1363 | #print ("code shape", code.shape) | |
1364 | #print ("seed",seed) |
|
1364 | #print ("seed",seed) | |
1365 | #print ("Code", code[0:10]) |
|
1365 | #print ("Code", code[0:10]) | |
1366 | self.B = r['B'] |
|
1366 | self.B = r['B'] | |
1367 |
|
1367 | |||
1368 |
|
1368 | |||
1369 | def run (self,dataOut,length_code= 10000,seed= 0,Nranges= 1000,oversample=1): |
|
1369 | def run (self,dataOut,length_code= 10000,seed= 0,Nranges= 1000,oversample=1): | |
1370 | #print((dataOut.data.shape)) |
|
1370 | #print((dataOut.data.shape)) | |
1371 | if not self.isConfig: |
|
1371 | if not self.isConfig: | |
1372 | self.setup(clen= length_code,seed= seed,Nranges= Nranges,oversample=oversample) |
|
1372 | self.setup(clen= length_code,seed= seed,Nranges= Nranges,oversample=oversample) | |
1373 | self.isConfig = True |
|
1373 | self.isConfig = True | |
1374 |
|
1374 | |||
1375 | dataOut.flagNoData = True |
|
1375 | dataOut.flagNoData = True | |
1376 | data =dataOut.data |
|
1376 | data =dataOut.data | |
1377 | #print "length_CODE",length_code |
|
1377 | #print "length_CODE",length_code | |
1378 | data_shape = (data.shape[1]) |
|
1378 | data_shape = (data.shape[1]) | |
1379 | #print "data_shape",data_shape |
|
1379 | #print "data_shape",data_shape | |
1380 | n = (length_code /data_shape) |
|
1380 | n = (length_code /data_shape) | |
1381 | #print "we need this number of sample",n |
|
1381 | #print "we need this number of sample",n | |
1382 |
|
1382 | |||
1383 | if n>0 and self.buffer is None: |
|
1383 | if n>0 and self.buffer is None: | |
1384 | self.buffer = numpy.zeros([1, length_code], dtype=numpy.complex64) |
|
1384 | self.buffer = numpy.zeros([1, length_code], dtype=numpy.complex64) | |
1385 | self.buffer[0][0:data_shape] = data[0] |
|
1385 | self.buffer[0][0:data_shape] = data[0] | |
1386 | #print "FIRST CREATION",self.buffer.shape |
|
1386 | #print "FIRST CREATION",self.buffer.shape | |
1387 |
|
1387 | |||
1388 | else: |
|
1388 | else: | |
1389 | self.buffer[0][self.nProfiles*data_shape:(self.nProfiles+1)*data_shape]=data[0] |
|
1389 | self.buffer[0][self.nProfiles*data_shape:(self.nProfiles+1)*data_shape]=data[0] | |
1390 |
|
1390 | |||
1391 | #print "buffer_shape",(self.buffer.shape) |
|
1391 | #print "buffer_shape",(self.buffer.shape) | |
1392 | self.nProfiles += 1 |
|
1392 | self.nProfiles += 1 | |
1393 | #print "count",self.nProfiles |
|
1393 | #print "count",self.nProfiles | |
1394 |
|
1394 | |||
1395 | if self.nProfiles== n: |
|
1395 | if self.nProfiles== n: | |
1396 | temporal = numpy.dot(self.B, numpy.transpose(self.buffer)) |
|
1396 | temporal = numpy.dot(self.B, numpy.transpose(self.buffer)) | |
1397 | #print temporal.shape |
|
1397 | #print temporal.shape | |
1398 | #import time |
|
1398 | #import time | |
1399 | #time.sleep(40) |
|
1399 | #time.sleep(40) | |
1400 | dataOut.data=numpy.transpose(temporal) |
|
1400 | dataOut.data=numpy.transpose(temporal) | |
1401 |
|
1401 | |||
1402 | dataOut.flagNoData = False |
|
1402 | dataOut.flagNoData = False | |
1403 | self.buffer= None |
|
1403 | self.buffer= None | |
1404 | self.nProfiles = 0 |
|
1404 | self.nProfiles = 0 | |
1405 |
|
1405 | |||
1406 | # import collections |
|
1406 | # import collections | |
1407 | # from scipy.stats import mode |
|
1407 | # from scipy.stats import mode | |
1408 | # |
|
1408 | # | |
1409 | # class Synchronize(Operation): |
|
1409 | # class Synchronize(Operation): | |
1410 | # |
|
1410 | # | |
1411 | # isConfig = False |
|
1411 | # isConfig = False | |
1412 | # __profIndex = 0 |
|
1412 | # __profIndex = 0 | |
1413 | # |
|
1413 | # | |
1414 | # def __init__(self, **kwargs): |
|
1414 | # def __init__(self, **kwargs): | |
1415 | # |
|
1415 | # | |
1416 | # Operation.__init__(self, **kwargs) |
|
1416 | # Operation.__init__(self, **kwargs) | |
1417 | # # self.isConfig = False |
|
1417 | # # self.isConfig = False | |
1418 | # self.__powBuffer = None |
|
1418 | # self.__powBuffer = None | |
1419 | # self.__startIndex = 0 |
|
1419 | # self.__startIndex = 0 | |
1420 | # self.__pulseFound = False |
|
1420 | # self.__pulseFound = False | |
1421 | # |
|
1421 | # | |
1422 | # def __findTxPulse(self, dataOut, channel=0, pulse_with = None): |
|
1422 | # def __findTxPulse(self, dataOut, channel=0, pulse_with = None): | |
1423 | # |
|
1423 | # | |
1424 | # #Read data |
|
1424 | # #Read data | |
1425 | # |
|
1425 | # | |
1426 | # powerdB = dataOut.getPower(channel = channel) |
|
1426 | # powerdB = dataOut.getPower(channel = channel) | |
1427 | # noisedB = dataOut.getNoise(channel = channel)[0] |
|
1427 | # noisedB = dataOut.getNoise(channel = channel)[0] | |
1428 | # |
|
1428 | # | |
1429 | # self.__powBuffer.extend(powerdB.flatten()) |
|
1429 | # self.__powBuffer.extend(powerdB.flatten()) | |
1430 | # |
|
1430 | # | |
1431 | # dataArray = numpy.array(self.__powBuffer) |
|
1431 | # dataArray = numpy.array(self.__powBuffer) | |
1432 | # |
|
1432 | # | |
1433 | # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same") |
|
1433 | # filteredPower = numpy.correlate(dataArray, dataArray[0:self.__nSamples], "same") | |
1434 | # |
|
1434 | # | |
1435 | # maxValue = numpy.nanmax(filteredPower) |
|
1435 | # maxValue = numpy.nanmax(filteredPower) | |
1436 | # |
|
1436 | # | |
1437 | # if maxValue < noisedB + 10: |
|
1437 | # if maxValue < noisedB + 10: | |
1438 | # #No se encuentra ningun pulso de transmision |
|
1438 | # #No se encuentra ningun pulso de transmision | |
1439 | # return None |
|
1439 | # return None | |
1440 | # |
|
1440 | # | |
1441 | # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0] |
|
1441 | # maxValuesIndex = numpy.where(filteredPower > maxValue - 0.1*abs(maxValue))[0] | |
1442 | # |
|
1442 | # | |
1443 | # if len(maxValuesIndex) < 2: |
|
1443 | # if len(maxValuesIndex) < 2: | |
1444 | # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX |
|
1444 | # #Solo se encontro un solo pulso de transmision de un baudio, esperando por el siguiente TX | |
1445 | # return None |
|
1445 | # return None | |
1446 | # |
|
1446 | # | |
1447 | # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples |
|
1447 | # phasedMaxValuesIndex = maxValuesIndex - self.__nSamples | |
1448 | # |
|
1448 | # | |
1449 | # #Seleccionar solo valores con un espaciamiento de nSamples |
|
1449 | # #Seleccionar solo valores con un espaciamiento de nSamples | |
1450 | # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex) |
|
1450 | # pulseIndex = numpy.intersect1d(maxValuesIndex, phasedMaxValuesIndex) | |
1451 | # |
|
1451 | # | |
1452 | # if len(pulseIndex) < 2: |
|
1452 | # if len(pulseIndex) < 2: | |
1453 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 |
|
1453 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 | |
1454 | # return None |
|
1454 | # return None | |
1455 | # |
|
1455 | # | |
1456 | # spacing = pulseIndex[1:] - pulseIndex[:-1] |
|
1456 | # spacing = pulseIndex[1:] - pulseIndex[:-1] | |
1457 | # |
|
1457 | # | |
1458 | # #remover senales que se distancien menos de 10 unidades o muestras |
|
1458 | # #remover senales que se distancien menos de 10 unidades o muestras | |
1459 | # #(No deberian existir IPP menor a 10 unidades) |
|
1459 | # #(No deberian existir IPP menor a 10 unidades) | |
1460 | # |
|
1460 | # | |
1461 | # realIndex = numpy.where(spacing > 10 )[0] |
|
1461 | # realIndex = numpy.where(spacing > 10 )[0] | |
1462 | # |
|
1462 | # | |
1463 | # if len(realIndex) < 2: |
|
1463 | # if len(realIndex) < 2: | |
1464 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 |
|
1464 | # #Solo se encontro un pulso de transmision con ancho mayor a 1 | |
1465 | # return None |
|
1465 | # return None | |
1466 | # |
|
1466 | # | |
1467 | # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs) |
|
1467 | # #Eliminar pulsos anchos (deja solo la diferencia entre IPPs) | |
1468 | # realPulseIndex = pulseIndex[realIndex] |
|
1468 | # realPulseIndex = pulseIndex[realIndex] | |
1469 | # |
|
1469 | # | |
1470 | # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0] |
|
1470 | # period = mode(realPulseIndex[1:] - realPulseIndex[:-1])[0][0] | |
1471 | # |
|
1471 | # | |
1472 | # print "IPP = %d samples" %period |
|
1472 | # print "IPP = %d samples" %period | |
1473 | # |
|
1473 | # | |
1474 | # self.__newNSamples = dataOut.nHeights #int(period) |
|
1474 | # self.__newNSamples = dataOut.nHeights #int(period) | |
1475 | # self.__startIndex = int(realPulseIndex[0]) |
|
1475 | # self.__startIndex = int(realPulseIndex[0]) | |
1476 | # |
|
1476 | # | |
1477 | # return 1 |
|
1477 | # return 1 | |
1478 | # |
|
1478 | # | |
1479 | # |
|
1479 | # | |
1480 | # def setup(self, nSamples, nChannels, buffer_size = 4): |
|
1480 | # def setup(self, nSamples, nChannels, buffer_size = 4): | |
1481 | # |
|
1481 | # | |
1482 | # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float), |
|
1482 | # self.__powBuffer = collections.deque(numpy.zeros( buffer_size*nSamples,dtype=numpy.float), | |
1483 | # maxlen = buffer_size*nSamples) |
|
1483 | # maxlen = buffer_size*nSamples) | |
1484 | # |
|
1484 | # | |
1485 | # bufferList = [] |
|
1485 | # bufferList = [] | |
1486 | # |
|
1486 | # | |
1487 | # for i in range(nChannels): |
|
1487 | # for i in range(nChannels): | |
1488 | # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN, |
|
1488 | # bufferByChannel = collections.deque(numpy.zeros( buffer_size*nSamples, dtype=numpy.complex) + numpy.NAN, | |
1489 | # maxlen = buffer_size*nSamples) |
|
1489 | # maxlen = buffer_size*nSamples) | |
1490 | # |
|
1490 | # | |
1491 | # bufferList.append(bufferByChannel) |
|
1491 | # bufferList.append(bufferByChannel) | |
1492 | # |
|
1492 | # | |
1493 | # self.__nSamples = nSamples |
|
1493 | # self.__nSamples = nSamples | |
1494 | # self.__nChannels = nChannels |
|
1494 | # self.__nChannels = nChannels | |
1495 | # self.__bufferList = bufferList |
|
1495 | # self.__bufferList = bufferList | |
1496 | # |
|
1496 | # | |
1497 | # def run(self, dataOut, channel = 0): |
|
1497 | # def run(self, dataOut, channel = 0): | |
1498 | # |
|
1498 | # | |
1499 | # if not self.isConfig: |
|
1499 | # if not self.isConfig: | |
1500 | # nSamples = dataOut.nHeights |
|
1500 | # nSamples = dataOut.nHeights | |
1501 | # nChannels = dataOut.nChannels |
|
1501 | # nChannels = dataOut.nChannels | |
1502 | # self.setup(nSamples, nChannels) |
|
1502 | # self.setup(nSamples, nChannels) | |
1503 | # self.isConfig = True |
|
1503 | # self.isConfig = True | |
1504 | # |
|
1504 | # | |
1505 | # #Append new data to internal buffer |
|
1505 | # #Append new data to internal buffer | |
1506 | # for thisChannel in range(self.__nChannels): |
|
1506 | # for thisChannel in range(self.__nChannels): | |
1507 | # bufferByChannel = self.__bufferList[thisChannel] |
|
1507 | # bufferByChannel = self.__bufferList[thisChannel] | |
1508 | # bufferByChannel.extend(dataOut.data[thisChannel]) |
|
1508 | # bufferByChannel.extend(dataOut.data[thisChannel]) | |
1509 | # |
|
1509 | # | |
1510 | # if self.__pulseFound: |
|
1510 | # if self.__pulseFound: | |
1511 | # self.__startIndex -= self.__nSamples |
|
1511 | # self.__startIndex -= self.__nSamples | |
1512 | # |
|
1512 | # | |
1513 | # #Finding Tx Pulse |
|
1513 | # #Finding Tx Pulse | |
1514 | # if not self.__pulseFound: |
|
1514 | # if not self.__pulseFound: | |
1515 | # indexFound = self.__findTxPulse(dataOut, channel) |
|
1515 | # indexFound = self.__findTxPulse(dataOut, channel) | |
1516 | # |
|
1516 | # | |
1517 | # if indexFound == None: |
|
1517 | # if indexFound == None: | |
1518 | # dataOut.flagNoData = True |
|
1518 | # dataOut.flagNoData = True | |
1519 | # return |
|
1519 | # return | |
1520 | # |
|
1520 | # | |
1521 | # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex) |
|
1521 | # self.__arrayBuffer = numpy.zeros((self.__nChannels, self.__newNSamples), dtype = numpy.complex) | |
1522 | # self.__pulseFound = True |
|
1522 | # self.__pulseFound = True | |
1523 | # self.__startIndex = indexFound |
|
1523 | # self.__startIndex = indexFound | |
1524 | # |
|
1524 | # | |
1525 | # #If pulse was found ... |
|
1525 | # #If pulse was found ... | |
1526 | # for thisChannel in range(self.__nChannels): |
|
1526 | # for thisChannel in range(self.__nChannels): | |
1527 | # bufferByChannel = self.__bufferList[thisChannel] |
|
1527 | # bufferByChannel = self.__bufferList[thisChannel] | |
1528 | # #print self.__startIndex |
|
1528 | # #print self.__startIndex | |
1529 | # x = numpy.array(bufferByChannel) |
|
1529 | # x = numpy.array(bufferByChannel) | |
1530 | # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples] |
|
1530 | # self.__arrayBuffer[thisChannel] = x[self.__startIndex:self.__startIndex+self.__newNSamples] | |
1531 | # |
|
1531 | # | |
1532 | # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1532 | # deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1533 | # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight |
|
1533 | # dataOut.heightList = numpy.arange(self.__newNSamples)*deltaHeight | |
1534 | # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6 |
|
1534 | # # dataOut.ippSeconds = (self.__newNSamples / deltaHeight)/1e6 | |
1535 | # |
|
1535 | # | |
1536 | # dataOut.data = self.__arrayBuffer |
|
1536 | # dataOut.data = self.__arrayBuffer | |
1537 | # |
|
1537 | # | |
1538 | # self.__startIndex += self.__newNSamples |
|
1538 | # self.__startIndex += self.__newNSamples | |
1539 | # |
|
1539 | # | |
1540 | # return |
|
1540 | # return |
@@ -1,144 +1,145 | |||||
1 | #!/usr/bin/env python |
|
1 | #!/usr/bin/env python | |
2 | ''' |
|
2 | ''' | |
3 | Created on Jul 7, 2014 |
|
3 | Created on Jul 7, 2014 | |
4 |
|
4 | |||
5 | @author: roj-idl71 |
|
5 | @author: roj-idl71 | |
6 | ''' |
|
6 | ''' | |
7 | import os, sys |
|
7 | import os, sys | |
8 |
|
8 | |||
9 | #path = os.path.dirname(os.getcwd()) |
|
9 | #path = os.path.dirname(os.getcwd()) | |
10 | #path = os.path.join(path, 'source') |
|
10 | #path = os.path.join(path, 'source') | |
11 | #sys.path.insert(0, path) |
|
11 | #sys.path.insert(0, path) | |
12 |
|
12 | |||
13 | from schainpy.controller import Project |
|
13 | from schainpy.controller import Project | |
14 |
|
14 | |||
15 | if __name__ == '__main__': |
|
15 | if __name__ == '__main__': | |
16 |
|
16 | |||
17 | desc = "High altitude experiment SHORT " |
|
17 | desc = "High altitude experiment SHORT " | |
18 | filename = "schain.xml" |
|
18 | filename = "schain.xml" | |
19 | dpath = '/home/soporte/test_avp' |
|
19 | dpath = '/home/soporte/test_avp' | |
20 | figpath = "/home/soporte/pics" |
|
20 | figpath = "/home/soporte/pics" | |
21 | remotefolder = "/home/wmaster/graficos" |
|
21 | remotefolder = "/home/wmaster/graficos" | |
22 | t=['0','24'] |
|
22 | t=['0','24'] | |
23 | db_range=['15','35'] |
|
23 | db_range=['15','35'] | |
24 | db_range=['25','45'] |
|
24 | db_range=['25','45'] | |
25 | db_range=['0','35'] |
|
25 | db_range=['0','35'] | |
26 | period=60 |
|
26 | period=60 | |
27 |
|
27 | |||
28 | controllerObj = Project() |
|
28 | controllerObj = Project() | |
29 |
|
29 | |||
30 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
30 | controllerObj.setup(id = '191', name='test01', description=desc) | |
31 |
|
31 | |||
32 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', |
|
32 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
33 | path=dpath, |
|
33 | path=dpath, | |
34 | startDate='2019/10/14', |
|
34 | startDate='2019/10/14', | |
35 | # startDate='2018/06/18', |
|
35 | # startDate='2018/06/18', | |
36 | endDate='2019/10/14', |
|
36 | endDate='2019/10/14', | |
37 | # endDate='2018/06/18', |
|
37 | # endDate='2018/06/18', | |
38 | startTime='14:00:00', |
|
38 | startTime='14:00:00', | |
39 | endTime='23:59:59', |
|
39 | endTime='23:59:59', | |
40 | online=0, |
|
40 | online=0, | |
41 | walk=0, |
|
41 | walk=0, | |
42 | expLabel='', |
|
42 | expLabel='', | |
43 | delay=20) |
|
43 | delay=20) | |
44 |
|
44 | |||
45 |
|
45 | |||
46 | opObj00 = readUnitConfObj.addOperation(name='printInfo') |
|
46 | opObj00 = readUnitConfObj.addOperation(name='printInfo') | |
47 | opObj00 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
47 | opObj00 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
48 |
|
48 | |||
49 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
49 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
50 |
|
50 | |||
51 | opObj11 = procUnitConfObj1.addOperation(name='ProfileSelector', optype='other') |
|
51 | opObj11 = procUnitConfObj1.addOperation(name='ProfileSelector', optype='other') | |
52 | #opObj11.addParameter(name='profileList', value='(0, 1, 2, 3, 20, 21, 22, 23, 40, 41, 42, 43, 60, 61, 62, 63, 80, 81, 82, 83)', format='intlist') |
|
52 | #opObj11.addParameter(name='profileList', value='(0, 1, 2, 3, 20, 21, 22, 23, 40, 41, 42, 43, 60, 61, 62, 63, 80, 81, 82, 83)', format='intlist') | |
53 | opObj11.addParameter(name='rangeList', value='(0,127)', format='intlist') # (0,63),(127,149) |
|
53 | opObj11.addParameter(name='rangeList', value='(0,127)', format='intlist') # (0,63),(127,149) | |
54 |
|
54 | |||
55 | opObj11 = procUnitConfObj1.addOperation(name='selectHeights') |
|
55 | opObj11 = procUnitConfObj1.addOperation(name='selectHeights') | |
56 | opObj11.addParameter(name='minHei', value='0', format='int') |
|
56 | opObj11.addParameter(name='minHei', value='0', format='int') | |
57 | opObj11.addParameter(name='maxHei', value='3000', format='int') |
|
57 | opObj11.addParameter(name='maxHei', value='3000', format='int') | |
58 |
|
58 | |||
59 |
|
59 | |||
60 | #opObj11 = procUnitConfObj1.addOperation(name='filterByHeights') |
|
60 | #opObj11 = procUnitConfObj1.addOperation(name='filterByHeights') | |
61 | #opObj11.addParameter(name='window', value='4', format='int') |
|
61 | #opObj11.addParameter(name='window', value='4', format='int') | |
62 |
|
62 | |||
63 | # opObj11 = procUnitConfObj1.addOperation(name='deFlip') |
|
63 | # opObj11 = procUnitConfObj1.addOperation(name='deFlip') | |
64 | # opObj11.addParameter(name='channelList', value='1,3,5,7', format='intlist') |
|
64 | # opObj11.addParameter(name='channelList', value='1,3,5,7', format='intlist') | |
65 |
|
65 | |||
66 | opObj11 = procUnitConfObj1.addOperation(name='SSheightProfiles', optype='other') |
|
66 | opObj11 = procUnitConfObj1.addOperation(name='SSheightProfiles', optype='other') | |
67 | opObj11.addParameter(name='step', value='1', format='int') |
|
67 | opObj11.addParameter(name='step', value='1', format='int') | |
68 | opObj11.addParameter(name='nsamples', value='64', format='int') |
|
68 | opObj11.addParameter(name='nsamples', value='64', format='int') | |
69 |
|
69 | |||
70 |
|
70 | |||
71 | procUnitConfObj1SPC = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) |
|
71 | procUnitConfObj1SPC = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj1.getId()) | |
72 | procUnitConfObj1SPC.addParameter(name='nFFTPoints', value='128', format='int') |
|
72 | procUnitConfObj1SPC.addParameter(name='nFFTPoints', value='128', format='int') | |
73 | procUnitConfObj1SPC.addParameter(name='nProfiles', value='64', format='int') |
|
73 | procUnitConfObj1SPC.addParameter(name='nProfiles', value='64', format='int') | |
74 | # procUnitConfObj1SPC.addParameter(name='pairsList', value='(1,0),(3,2),(5,4),(7,6)', format='pairsList') |
|
74 | # procUnitConfObj1SPC.addParameter(name='pairsList', value='(1,0),(3,2),(5,4),(7,6)', format='pairsList') | |
75 |
|
75 | |||
76 | opObj11 = procUnitConfObj1SPC.addOperation(name='IncohInt', optype='other') |
|
76 | opObj11 = procUnitConfObj1SPC.addOperation(name='IncohInt', optype='other') | |
77 |
opObj11.addParameter(name='timeInterval', value=' |
|
77 | opObj11.addParameter(name='timeInterval', value='10', format='int') | |
78 |
|
78 | |||
79 | procUnitConfObj2SPC = controllerObj.addProcUnit(datatype='SpectraAFCProc', inputId=procUnitConfObj1SPC.getId()) |
|
79 | procUnitConfObj2SPC = controllerObj.addProcUnit(datatype='SpectraAFCProc', inputId=procUnitConfObj1SPC.getId()) | |
|
80 | procUnitConfObj2SPC.addParameter(name='real', value='1', format='int') | |||
80 |
|
81 | |||
81 | opObj11 = procUnitConfObj1SPC.addOperation(name='SpectraPlot', optype='other') |
|
82 | opObj11 = procUnitConfObj1SPC.addOperation(name='SpectraPlot', optype='other') | |
82 | opObj11.addParameter(name='id', value='1', format='int') |
|
83 | opObj11.addParameter(name='id', value='1', format='int') | |
83 | opObj11.addParameter(name='wintitle', value='October 2019', format='str') |
|
84 | opObj11.addParameter(name='wintitle', value='October 2019', format='str') | |
84 | #opObj11.addParameter(name='xaxis', value='time', format='str') |
|
85 | #opObj11.addParameter(name='xaxis', value='time', format='str') | |
85 |
|
86 | |||
86 | #opObj11.addParameter(name='zmin', value=db_range[0], format='int') |
|
87 | #opObj11.addParameter(name='zmin', value=db_range[0], format='int') | |
87 | #opObj11.addParameter(name='zmax', value=db_range[1], format='int') |
|
88 | #opObj11.addParameter(name='zmax', value=db_range[1], format='int') | |
88 | #opObj11.addParameter(name='ymin', value='0', format='int') |
|
89 | #opObj11.addParameter(name='ymin', value='0', format='int') | |
89 | #opObj11.addParameter(name='ymax', value='1500', format='int') |
|
90 | #opObj11.addParameter(name='ymax', value='1500', format='int') | |
90 | #opObj11.addParameter(name='xmin', value='-5', format='int') |
|
91 | #opObj11.addParameter(name='xmin', value='-5', format='int') | |
91 | #opObj11.addParameter(name='xmax', value='5', format='int') |
|
92 | #opObj11.addParameter(name='xmax', value='5', format='int') | |
92 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
93 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
93 | opObj11.addParameter(name='save', value='1', format='int') |
|
94 | opObj11.addParameter(name='save', value='1', format='int') | |
94 | opObj11.addParameter(name='figpath', value=figpath) |
|
95 | opObj11.addParameter(name='figpath', value=figpath) | |
95 |
|
96 | |||
96 | opObj11 = procUnitConfObj1SPC.addOperation(name='RTIPlot', optype='other') |
|
97 | opObj11 = procUnitConfObj1SPC.addOperation(name='RTIPlot', optype='other') | |
97 | opObj11.addParameter(name='id', value='2', format='int') |
|
98 | opObj11.addParameter(name='id', value='2', format='int') | |
98 | opObj11.addParameter(name='wintitle', value='October 2019', format='str') |
|
99 | opObj11.addParameter(name='wintitle', value='October 2019', format='str') | |
99 | opObj11.addParameter(name='xmin', value=t[0], format='float') |
|
100 | opObj11.addParameter(name='xmin', value=t[0], format='float') | |
100 | opObj11.addParameter(name='xmax', value=t[1], format='float') |
|
101 | opObj11.addParameter(name='xmax', value=t[1], format='float') | |
101 | #opObj11.addParameter(name='ymin', value='0', format='int') |
|
102 | #opObj11.addParameter(name='ymin', value='0', format='int') | |
102 | #opObj11.addParameter(name='ymax', value='1500', format='int') |
|
103 | #opObj11.addParameter(name='ymax', value='1500', format='int') | |
103 | #opObj11.addParameter(name='zmin', value=db_range[0], format='int') |
|
104 | #opObj11.addParameter(name='zmin', value=db_range[0], format='int') | |
104 | #opObj11.addParameter(name='zmax', value=db_range[1], format='int') |
|
105 | #opObj11.addParameter(name='zmax', value=db_range[1], format='int') | |
105 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
106 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
106 | opObj11.addParameter(name='save', value='1', format='int') |
|
107 | opObj11.addParameter(name='save', value='1', format='int') | |
107 | opObj11.addParameter(name='figpath', value=figpath) |
|
108 | opObj11.addParameter(name='figpath', value=figpath) | |
108 |
|
109 | |||
109 |
|
110 | |||
110 |
|
111 | |||
111 | opObj11 = procUnitConfObj2SPC.addOperation(name='ACFPlot', optype='other') |
|
112 | opObj11 = procUnitConfObj2SPC.addOperation(name='ACFPlot', optype='other') | |
112 | opObj11.addParameter(name='id', value='3', format='int') |
|
113 | opObj11.addParameter(name='id', value='3', format='int') | |
113 | opObj11.addParameter(name='wintitle', value = 'October 2019', format='str') |
|
114 | opObj11.addParameter(name='wintitle', value = 'October 2019', format='str') | |
114 | opObj11.addParameter(name='xaxis', value='time', format='str') |
|
115 | opObj11.addParameter(name='xaxis', value='time', format='str') | |
115 | opObj11.addParameter(name='channel', value='0', format='int') |
|
116 | opObj11.addParameter(name='channel', value='0', format='int') | |
116 |
opObj11.addParameter(name='nSampleList', value='( |
|
117 | #opObj11.addParameter(name='nSampleList', value='(50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70)', format='intList') | |
117 |
opObj11.addParameter(name='resolutionFactor', value=' |
|
118 | opObj11.addParameter(name='resolutionFactor', value='15', format='int') | |
118 | #opObj11.addParameter(name='zmin', value=0.5, format='int') |
|
119 | #opObj11.addParameter(name='zmin', value=0.5, format='int') | |
119 | #opObj11.addParameter(name='zmax', value=-0.5, format='int') |
|
120 | #opObj11.addParameter(name='zmax', value=-0.5, format='int') | |
120 | #opObj11.addParameter(name='ymin', value='0', format='int') |
|
121 | #opObj11.addParameter(name='ymin', value='0', format='int') | |
121 | #opObj11.addParameter(name='ymax', value='0.5', format='int') |
|
122 | #opObj11.addParameter(name='ymax', value='0.5', format='int') | |
122 | #opObj11.addParameter(name='xmin', value='-1.2', format='int') |
|
123 | #opObj11.addParameter(name='xmin', value='-1.2', format='int') | |
123 | #opObj11.addParameter(name='xmax', value='1.2', format='int') |
|
124 | #opObj11.addParameter(name='xmax', value='1.2', format='int') | |
124 | opObj11.addParameter(name='show', value='1', format='int') |
|
125 | opObj11.addParameter(name='show', value='1', format='int') | |
125 | opObj11.addParameter(name='save', value='1', format='int') |
|
126 | opObj11.addParameter(name='save', value='1', format='int') | |
126 | opObj11.addParameter(name='figpath', value=figpath) |
|
127 | opObj11.addParameter(name='figpath', value=figpath) | |
127 |
|
128 | |||
128 | ''' |
|
129 | ''' | |
129 | opObj11 = procUnitConfObj1SPC.addOperation(name='Noise', optype='other') |
|
130 | opObj11 = procUnitConfObj1SPC.addOperation(name='Noise', optype='other') | |
130 | opObj11.addParameter(name='id', value='3', format='int') |
|
131 | opObj11.addParameter(name='id', value='3', format='int') | |
131 | opObj11.addParameter(name='wintitle', value='Short Valley August 2019', format='str') |
|
132 | opObj11.addParameter(name='wintitle', value='Short Valley August 2019', format='str') | |
132 | opObj11.addParameter(name='xmin', value=t[0], format='float') |
|
133 | opObj11.addParameter(name='xmin', value=t[0], format='float') | |
133 | opObj11.addParameter(name='xmax', value=t[1], format='float') |
|
134 | opObj11.addParameter(name='xmax', value=t[1], format='float') | |
134 | opObj11.addParameter(name='ymin', value=db_range[0], format='int') |
|
135 | opObj11.addParameter(name='ymin', value=db_range[0], format='int') | |
135 | opObj11.addParameter(name='ymax', value=db_range[1], format='int') |
|
136 | opObj11.addParameter(name='ymax', value=db_range[1], format='int') | |
136 | opObj11.addParameter(name='showprofile', value='1', format='int') |
|
137 | opObj11.addParameter(name='showprofile', value='1', format='int') | |
137 | opObj11.addParameter(name='save', value='1', format='int') |
|
138 | opObj11.addParameter(name='save', value='1', format='int') | |
138 | opObj11.addParameter(name='figpath', value=figpath) |
|
139 | opObj11.addParameter(name='figpath', value=figpath) | |
139 |
|
140 | |||
140 |
|
141 | |||
141 | ''' |
|
142 | ''' | |
142 |
|
143 | |||
143 |
|
144 | |||
144 | controllerObj.start() |
|
145 | controllerObj.start() |
General Comments 0
You need to be logged in to leave comments.
Login now