@@ -1,1229 +1,1229 | |||||
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 | def getDataTypeCode(numpyDtype): |
|
34 | def getDataTypeCode(numpyDtype): | |
35 |
|
35 | |||
36 | if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]): |
|
36 | if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]): | |
37 | datatype = 0 |
|
37 | datatype = 0 | |
38 | elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]): |
|
38 | elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]): | |
39 | datatype = 1 |
|
39 | datatype = 1 | |
40 | elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]): |
|
40 | elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]): | |
41 | datatype = 2 |
|
41 | datatype = 2 | |
42 | elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]): |
|
42 | elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]): | |
43 | datatype = 3 |
|
43 | datatype = 3 | |
44 | elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]): |
|
44 | elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]): | |
45 | datatype = 4 |
|
45 | datatype = 4 | |
46 | elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]): |
|
46 | elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]): | |
47 | datatype = 5 |
|
47 | datatype = 5 | |
48 | else: |
|
48 | else: | |
49 | datatype = None |
|
49 | datatype = None | |
50 |
|
50 | |||
51 | return datatype |
|
51 | return datatype | |
52 |
|
52 | |||
53 | def hildebrand_sekhon(data, navg): |
|
53 | def hildebrand_sekhon(data, navg): | |
54 | """ |
|
54 | """ | |
55 | This method is for the objective determination of the noise level in Doppler spectra. This |
|
55 | This method is for the objective determination of the noise level in Doppler spectra. This | |
56 | implementation technique is based on the fact that the standard deviation of the spectral |
|
56 | implementation technique is based on the fact that the standard deviation of the spectral | |
57 | densities is equal to the mean spectral density for white Gaussian noise |
|
57 | densities is equal to the mean spectral density for white Gaussian noise | |
58 |
|
58 | |||
59 | Inputs: |
|
59 | Inputs: | |
60 | Data : heights |
|
60 | Data : heights | |
61 | navg : numbers of averages |
|
61 | navg : numbers of averages | |
62 |
|
62 | |||
63 | Return: |
|
63 | Return: | |
64 | -1 : any error |
|
64 | -1 : any error | |
65 | anoise : noise's level |
|
65 | anoise : noise's level | |
66 | """ |
|
66 | """ | |
67 |
|
67 | |||
68 | sortdata = numpy.sort(data, axis=None) |
|
68 | sortdata = numpy.sort(data, axis=None) | |
69 | # lenOfData = len(sortdata) |
|
69 | # lenOfData = len(sortdata) | |
70 | # nums_min = lenOfData*0.2 |
|
70 | # nums_min = lenOfData*0.2 | |
71 | # |
|
71 | # | |
72 | # if nums_min <= 5: |
|
72 | # if nums_min <= 5: | |
73 | # nums_min = 5 |
|
73 | # nums_min = 5 | |
74 | # |
|
74 | # | |
75 | # sump = 0. |
|
75 | # sump = 0. | |
76 | # |
|
76 | # | |
77 | # sumq = 0. |
|
77 | # sumq = 0. | |
78 | # |
|
78 | # | |
79 | # j = 0 |
|
79 | # j = 0 | |
80 | # |
|
80 | # | |
81 | # cont = 1 |
|
81 | # cont = 1 | |
82 | # |
|
82 | # | |
83 | # while((cont==1)and(j<lenOfData)): |
|
83 | # while((cont==1)and(j<lenOfData)): | |
84 | # |
|
84 | # | |
85 | # sump += sortdata[j] |
|
85 | # sump += sortdata[j] | |
86 | # |
|
86 | # | |
87 | # sumq += sortdata[j]**2 |
|
87 | # sumq += sortdata[j]**2 | |
88 | # |
|
88 | # | |
89 | # if j > nums_min: |
|
89 | # if j > nums_min: | |
90 | # rtest = float(j)/(j-1) + 1.0/navg |
|
90 | # rtest = float(j)/(j-1) + 1.0/navg | |
91 | # if ((sumq*j) > (rtest*sump**2)): |
|
91 | # if ((sumq*j) > (rtest*sump**2)): | |
92 | # j = j - 1 |
|
92 | # j = j - 1 | |
93 | # sump = sump - sortdata[j] |
|
93 | # sump = sump - sortdata[j] | |
94 | # sumq = sumq - sortdata[j]**2 |
|
94 | # sumq = sumq - sortdata[j]**2 | |
95 | # cont = 0 |
|
95 | # cont = 0 | |
96 | # |
|
96 | # | |
97 | # j += 1 |
|
97 | # j += 1 | |
98 | # |
|
98 | # | |
99 | # lnoise = sump /j |
|
99 | # lnoise = sump /j | |
100 | # |
|
100 | # | |
101 | # return lnoise |
|
101 | # return lnoise | |
102 |
|
102 | |||
103 | return cSchain.hildebrand_sekhon(sortdata, navg) |
|
103 | return cSchain.hildebrand_sekhon(sortdata, navg) | |
104 |
|
104 | |||
105 |
|
105 | |||
106 | class Beam: |
|
106 | class Beam: | |
107 |
|
107 | |||
108 | def __init__(self): |
|
108 | def __init__(self): | |
109 | self.codeList = [] |
|
109 | self.codeList = [] | |
110 | self.azimuthList = [] |
|
110 | self.azimuthList = [] | |
111 | self.zenithList = [] |
|
111 | self.zenithList = [] | |
112 |
|
112 | |||
113 | class GenericData(object): |
|
113 | class GenericData(object): | |
114 |
|
114 | |||
115 | flagNoData = True |
|
115 | flagNoData = True | |
116 |
|
116 | |||
117 | def copy(self, inputObj=None): |
|
117 | def copy(self, inputObj=None): | |
118 |
|
118 | |||
119 | if inputObj == None: |
|
119 | if inputObj == None: | |
120 | return copy.deepcopy(self) |
|
120 | return copy.deepcopy(self) | |
121 |
|
121 | |||
122 | for key in inputObj.__dict__.keys(): |
|
122 | for key in inputObj.__dict__.keys(): | |
123 |
|
123 | |||
124 | attribute = inputObj.__dict__[key] |
|
124 | attribute = inputObj.__dict__[key] | |
125 |
|
125 | |||
126 | #If this attribute is a tuple or list |
|
126 | #If this attribute is a tuple or list | |
127 | if type(inputObj.__dict__[key]) in (tuple, list): |
|
127 | if type(inputObj.__dict__[key]) in (tuple, list): | |
128 | self.__dict__[key] = attribute[:] |
|
128 | self.__dict__[key] = attribute[:] | |
129 | continue |
|
129 | continue | |
130 |
|
130 | |||
131 | #If this attribute is another object or instance |
|
131 | #If this attribute is another object or instance | |
132 | if hasattr(attribute, '__dict__'): |
|
132 | if hasattr(attribute, '__dict__'): | |
133 | self.__dict__[key] = attribute.copy() |
|
133 | self.__dict__[key] = attribute.copy() | |
134 | continue |
|
134 | continue | |
135 |
|
135 | |||
136 | self.__dict__[key] = inputObj.__dict__[key] |
|
136 | self.__dict__[key] = inputObj.__dict__[key] | |
137 |
|
137 | |||
138 | def deepcopy(self): |
|
138 | def deepcopy(self): | |
139 |
|
139 | |||
140 | return copy.deepcopy(self) |
|
140 | return copy.deepcopy(self) | |
141 |
|
141 | |||
142 | def isEmpty(self): |
|
142 | def isEmpty(self): | |
143 |
|
143 | |||
144 | return self.flagNoData |
|
144 | return self.flagNoData | |
145 |
|
145 | |||
146 | class JROData(GenericData): |
|
146 | class JROData(GenericData): | |
147 |
|
147 | |||
148 | # m_BasicHeader = BasicHeader() |
|
148 | # m_BasicHeader = BasicHeader() | |
149 | # m_ProcessingHeader = ProcessingHeader() |
|
149 | # m_ProcessingHeader = ProcessingHeader() | |
150 |
|
150 | |||
151 | systemHeaderObj = SystemHeader() |
|
151 | systemHeaderObj = SystemHeader() | |
152 |
|
152 | |||
153 | radarControllerHeaderObj = RadarControllerHeader() |
|
153 | radarControllerHeaderObj = RadarControllerHeader() | |
154 |
|
154 | |||
155 | # data = None |
|
155 | # data = None | |
156 |
|
156 | |||
157 | type = None |
|
157 | type = None | |
158 |
|
158 | |||
159 | datatype = None #dtype but in string |
|
159 | datatype = None #dtype but in string | |
160 |
|
160 | |||
161 | # dtype = None |
|
161 | # dtype = None | |
162 |
|
162 | |||
163 | # nChannels = None |
|
163 | # nChannels = None | |
164 |
|
164 | |||
165 | # nHeights = None |
|
165 | # nHeights = None | |
166 |
|
166 | |||
167 | nProfiles = None |
|
167 | nProfiles = None | |
168 |
|
168 | |||
169 | heightList = None |
|
169 | heightList = None | |
170 |
|
170 | |||
171 | channelList = None |
|
171 | channelList = None | |
172 |
|
172 | |||
173 | flagDiscontinuousBlock = False |
|
173 | flagDiscontinuousBlock = False | |
174 |
|
174 | |||
175 | useLocalTime = False |
|
175 | useLocalTime = False | |
176 |
|
176 | |||
177 | utctime = None |
|
177 | utctime = None | |
178 |
|
178 | |||
179 | timeZone = None |
|
179 | timeZone = None | |
180 |
|
180 | |||
181 | dstFlag = None |
|
181 | dstFlag = None | |
182 |
|
182 | |||
183 | errorCount = None |
|
183 | errorCount = None | |
184 |
|
184 | |||
185 | blocksize = None |
|
185 | blocksize = None | |
186 |
|
186 | |||
187 | # nCode = None |
|
187 | # nCode = None | |
188 | # |
|
188 | # | |
189 | # nBaud = None |
|
189 | # nBaud = None | |
190 | # |
|
190 | # | |
191 | # code = None |
|
191 | # code = None | |
192 |
|
192 | |||
193 | flagDecodeData = False #asumo q la data no esta decodificada |
|
193 | flagDecodeData = False #asumo q la data no esta decodificada | |
194 |
|
194 | |||
195 | flagDeflipData = False #asumo q la data no esta sin flip |
|
195 | flagDeflipData = False #asumo q la data no esta sin flip | |
196 |
|
196 | |||
197 | flagShiftFFT = False |
|
197 | flagShiftFFT = False | |
198 |
|
198 | |||
199 | # ippSeconds = None |
|
199 | # ippSeconds = None | |
200 |
|
200 | |||
201 | # timeInterval = None |
|
201 | # timeInterval = None | |
202 |
|
202 | |||
203 | nCohInt = None |
|
203 | nCohInt = None | |
204 |
|
204 | |||
205 | # noise = None |
|
205 | # noise = None | |
206 |
|
206 | |||
207 | windowOfFilter = 1 |
|
207 | windowOfFilter = 1 | |
208 |
|
208 | |||
209 | #Speed of ligth |
|
209 | #Speed of ligth | |
210 | C = 3e8 |
|
210 | C = 3e8 | |
211 |
|
211 | |||
212 | frequency = 49.92e6 |
|
212 | frequency = 49.92e6 | |
213 |
|
213 | |||
214 | realtime = False |
|
214 | realtime = False | |
215 |
|
215 | |||
216 | beacon_heiIndexList = None |
|
216 | beacon_heiIndexList = None | |
217 |
|
217 | |||
218 | last_block = None |
|
218 | last_block = None | |
219 |
|
219 | |||
220 | blocknow = None |
|
220 | blocknow = None | |
221 |
|
221 | |||
222 | azimuth = None |
|
222 | azimuth = None | |
223 |
|
223 | |||
224 | zenith = None |
|
224 | zenith = None | |
225 |
|
225 | |||
226 | beam = Beam() |
|
226 | beam = Beam() | |
227 |
|
227 | |||
228 | profileIndex = None |
|
228 | profileIndex = None | |
229 |
|
229 | |||
230 | def getNoise(self): |
|
230 | def getNoise(self): | |
231 |
|
231 | |||
232 | raise NotImplementedError |
|
232 | raise NotImplementedError | |
233 |
|
233 | |||
234 | def getNChannels(self): |
|
234 | def getNChannels(self): | |
235 |
|
235 | |||
236 | return len(self.channelList) |
|
236 | return len(self.channelList) | |
237 |
|
237 | |||
238 | def getChannelIndexList(self): |
|
238 | def getChannelIndexList(self): | |
239 |
|
239 | |||
240 | return range(self.nChannels) |
|
240 | return range(self.nChannels) | |
241 |
|
241 | |||
242 | def getNHeights(self): |
|
242 | def getNHeights(self): | |
243 |
|
243 | |||
244 | return len(self.heightList) |
|
244 | return len(self.heightList) | |
245 |
|
245 | |||
246 | def getHeiRange(self, extrapoints=0): |
|
246 | def getHeiRange(self, extrapoints=0): | |
247 |
|
247 | |||
248 | heis = self.heightList |
|
248 | heis = self.heightList | |
249 | # deltah = self.heightList[1] - self.heightList[0] |
|
249 | # deltah = self.heightList[1] - self.heightList[0] | |
250 | # |
|
250 | # | |
251 | # heis.append(self.heightList[-1]) |
|
251 | # heis.append(self.heightList[-1]) | |
252 |
|
252 | |||
253 | return heis |
|
253 | return heis | |
254 |
|
254 | |||
255 | def getDeltaH(self): |
|
255 | def getDeltaH(self): | |
256 |
|
256 | |||
257 | delta = self.heightList[1] - self.heightList[0] |
|
257 | delta = self.heightList[1] - self.heightList[0] | |
258 |
|
258 | |||
259 | return delta |
|
259 | return delta | |
260 |
|
260 | |||
261 | def getltctime(self): |
|
261 | def getltctime(self): | |
262 |
|
262 | |||
263 | if self.useLocalTime: |
|
263 | if self.useLocalTime: | |
264 | return self.utctime - self.timeZone*60 |
|
264 | return self.utctime - self.timeZone*60 | |
265 |
|
265 | |||
266 | return self.utctime |
|
266 | return self.utctime | |
267 |
|
267 | |||
268 | def getDatatime(self): |
|
268 | def getDatatime(self): | |
269 |
|
269 | |||
270 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
270 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) | |
271 | return datatimeValue |
|
271 | return datatimeValue | |
272 |
|
272 | |||
273 | def getTimeRange(self): |
|
273 | def getTimeRange(self): | |
274 |
|
274 | |||
275 | datatime = [] |
|
275 | datatime = [] | |
276 |
|
276 | |||
277 | datatime.append(self.ltctime) |
|
277 | datatime.append(self.ltctime) | |
278 | datatime.append(self.ltctime + self.timeInterval+1) |
|
278 | datatime.append(self.ltctime + self.timeInterval+1) | |
279 |
|
279 | |||
280 | datatime = numpy.array(datatime) |
|
280 | datatime = numpy.array(datatime) | |
281 |
|
281 | |||
282 | return datatime |
|
282 | return datatime | |
283 |
|
283 | |||
284 | def getFmaxTimeResponse(self): |
|
284 | def getFmaxTimeResponse(self): | |
285 |
|
285 | |||
286 | period = (10**-6)*self.getDeltaH()/(0.15) |
|
286 | period = (10**-6)*self.getDeltaH()/(0.15) | |
287 |
|
287 | |||
288 | PRF = 1./(period * self.nCohInt) |
|
288 | PRF = 1./(period * self.nCohInt) | |
289 |
|
289 | |||
290 | fmax = PRF |
|
290 | fmax = PRF | |
291 |
|
291 | |||
292 | return fmax |
|
292 | return fmax | |
293 |
|
293 | |||
294 | def getFmax(self): |
|
294 | def getFmax(self): | |
295 |
|
295 | |||
296 | PRF = 1./(self.ippSeconds * self.nCohInt) |
|
296 | PRF = 1./(self.ippSeconds * self.nCohInt) | |
297 |
|
297 | |||
298 | fmax = PRF |
|
298 | fmax = PRF | |
299 |
|
299 | |||
300 | return fmax |
|
300 | return fmax | |
301 |
|
301 | |||
302 | def getVmax(self): |
|
302 | def getVmax(self): | |
303 |
|
303 | |||
304 | _lambda = self.C/self.frequency |
|
304 | _lambda = self.C/self.frequency | |
305 |
|
305 | |||
306 | vmax = self.getFmax() * _lambda/2 |
|
306 | vmax = self.getFmax() * _lambda/2 | |
307 |
|
307 | |||
308 | return vmax |
|
308 | return vmax | |
309 |
|
309 | |||
310 | def get_ippSeconds(self): |
|
310 | def get_ippSeconds(self): | |
311 | ''' |
|
311 | ''' | |
312 | ''' |
|
312 | ''' | |
313 | return self.radarControllerHeaderObj.ippSeconds |
|
313 | return self.radarControllerHeaderObj.ippSeconds | |
314 |
|
314 | |||
315 | def set_ippSeconds(self, ippSeconds): |
|
315 | def set_ippSeconds(self, ippSeconds): | |
316 | ''' |
|
316 | ''' | |
317 | ''' |
|
317 | ''' | |
318 |
|
318 | |||
319 | self.radarControllerHeaderObj.ippSeconds = ippSeconds |
|
319 | self.radarControllerHeaderObj.ippSeconds = ippSeconds | |
320 |
|
320 | |||
321 | return |
|
321 | return | |
322 |
|
322 | |||
323 | def get_dtype(self): |
|
323 | def get_dtype(self): | |
324 | ''' |
|
324 | ''' | |
325 | ''' |
|
325 | ''' | |
326 | return getNumpyDtype(self.datatype) |
|
326 | return getNumpyDtype(self.datatype) | |
327 |
|
327 | |||
328 | def set_dtype(self, numpyDtype): |
|
328 | def set_dtype(self, numpyDtype): | |
329 | ''' |
|
329 | ''' | |
330 | ''' |
|
330 | ''' | |
331 |
|
331 | |||
332 | self.datatype = getDataTypeCode(numpyDtype) |
|
332 | self.datatype = getDataTypeCode(numpyDtype) | |
333 |
|
333 | |||
334 | def get_code(self): |
|
334 | def get_code(self): | |
335 | ''' |
|
335 | ''' | |
336 | ''' |
|
336 | ''' | |
337 | return self.radarControllerHeaderObj.code |
|
337 | return self.radarControllerHeaderObj.code | |
338 |
|
338 | |||
339 | def set_code(self, code): |
|
339 | def set_code(self, code): | |
340 | ''' |
|
340 | ''' | |
341 | ''' |
|
341 | ''' | |
342 | self.radarControllerHeaderObj.code = code |
|
342 | self.radarControllerHeaderObj.code = code | |
343 |
|
343 | |||
344 | return |
|
344 | return | |
345 |
|
345 | |||
346 | def get_ncode(self): |
|
346 | def get_ncode(self): | |
347 | ''' |
|
347 | ''' | |
348 | ''' |
|
348 | ''' | |
349 | return self.radarControllerHeaderObj.nCode |
|
349 | return self.radarControllerHeaderObj.nCode | |
350 |
|
350 | |||
351 | def set_ncode(self, nCode): |
|
351 | def set_ncode(self, nCode): | |
352 | ''' |
|
352 | ''' | |
353 | ''' |
|
353 | ''' | |
354 | self.radarControllerHeaderObj.nCode = nCode |
|
354 | self.radarControllerHeaderObj.nCode = nCode | |
355 |
|
355 | |||
356 | return |
|
356 | return | |
357 |
|
357 | |||
358 | def get_nbaud(self): |
|
358 | def get_nbaud(self): | |
359 | ''' |
|
359 | ''' | |
360 | ''' |
|
360 | ''' | |
361 | return self.radarControllerHeaderObj.nBaud |
|
361 | return self.radarControllerHeaderObj.nBaud | |
362 |
|
362 | |||
363 | def set_nbaud(self, nBaud): |
|
363 | def set_nbaud(self, nBaud): | |
364 | ''' |
|
364 | ''' | |
365 | ''' |
|
365 | ''' | |
366 | self.radarControllerHeaderObj.nBaud = nBaud |
|
366 | self.radarControllerHeaderObj.nBaud = nBaud | |
367 |
|
367 | |||
368 | return |
|
368 | return | |
369 |
|
369 | |||
370 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
370 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
371 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
371 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
372 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
372 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
373 | #noise = property(getNoise, "I'm the 'nHeights' property.") |
|
373 | #noise = property(getNoise, "I'm the 'nHeights' property.") | |
374 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
374 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
375 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
375 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
376 | ippSeconds = property(get_ippSeconds, set_ippSeconds) |
|
376 | ippSeconds = property(get_ippSeconds, set_ippSeconds) | |
377 | dtype = property(get_dtype, set_dtype) |
|
377 | dtype = property(get_dtype, set_dtype) | |
378 | # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
378 | # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
379 | code = property(get_code, set_code) |
|
379 | code = property(get_code, set_code) | |
380 | nCode = property(get_ncode, set_ncode) |
|
380 | nCode = property(get_ncode, set_ncode) | |
381 | nBaud = property(get_nbaud, set_nbaud) |
|
381 | nBaud = property(get_nbaud, set_nbaud) | |
382 |
|
382 | |||
383 | class Voltage(JROData): |
|
383 | class Voltage(JROData): | |
384 |
|
384 | |||
385 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
385 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
386 | data = None |
|
386 | data = None | |
387 |
|
387 | |||
388 | def __init__(self): |
|
388 | def __init__(self): | |
389 | ''' |
|
389 | ''' | |
390 | Constructor |
|
390 | Constructor | |
391 | ''' |
|
391 | ''' | |
392 |
|
392 | |||
393 | self.useLocalTime = True |
|
393 | self.useLocalTime = True | |
394 |
|
394 | |||
395 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
395 | self.radarControllerHeaderObj = RadarControllerHeader() | |
396 |
|
396 | |||
397 | self.systemHeaderObj = SystemHeader() |
|
397 | self.systemHeaderObj = SystemHeader() | |
398 |
|
398 | |||
399 | self.type = "Voltage" |
|
399 | self.type = "Voltage" | |
400 |
|
400 | |||
401 | self.data = None |
|
401 | self.data = None | |
402 |
|
402 | |||
403 | # self.dtype = None |
|
403 | # self.dtype = None | |
404 |
|
404 | |||
405 | # self.nChannels = 0 |
|
405 | # self.nChannels = 0 | |
406 |
|
406 | |||
407 | # self.nHeights = 0 |
|
407 | # self.nHeights = 0 | |
408 |
|
408 | |||
409 | self.nProfiles = None |
|
409 | self.nProfiles = None | |
410 |
|
410 | |||
411 | self.heightList = None |
|
411 | self.heightList = None | |
412 |
|
412 | |||
413 | self.channelList = None |
|
413 | self.channelList = None | |
414 |
|
414 | |||
415 | # self.channelIndexList = None |
|
415 | # self.channelIndexList = None | |
416 |
|
416 | |||
417 | self.flagNoData = True |
|
417 | self.flagNoData = True | |
418 |
|
418 | |||
419 | self.flagDiscontinuousBlock = False |
|
419 | self.flagDiscontinuousBlock = False | |
420 |
|
420 | |||
421 | self.utctime = None |
|
421 | self.utctime = None | |
422 |
|
422 | |||
423 | self.timeZone = None |
|
423 | self.timeZone = None | |
424 |
|
424 | |||
425 | self.dstFlag = None |
|
425 | self.dstFlag = None | |
426 |
|
426 | |||
427 | self.errorCount = None |
|
427 | self.errorCount = None | |
428 |
|
428 | |||
429 | self.nCohInt = None |
|
429 | self.nCohInt = None | |
430 |
|
430 | |||
431 | self.blocksize = None |
|
431 | self.blocksize = None | |
432 |
|
432 | |||
433 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
433 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
434 |
|
434 | |||
435 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
435 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
436 |
|
436 | |||
437 | self.flagShiftFFT = False |
|
437 | self.flagShiftFFT = False | |
438 |
|
438 | |||
439 | self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil |
|
439 | self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil | |
440 |
|
440 | |||
441 | self.profileIndex = 0 |
|
441 | self.profileIndex = 0 | |
442 |
|
442 | |||
443 | def getNoisebyHildebrand(self, channel = None): |
|
443 | def getNoisebyHildebrand(self, channel = None): | |
444 | """ |
|
444 | """ | |
445 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
445 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
446 |
|
446 | |||
447 | Return: |
|
447 | Return: | |
448 | noiselevel |
|
448 | noiselevel | |
449 | """ |
|
449 | """ | |
450 |
|
450 | |||
451 | if channel != None: |
|
451 | if channel != None: | |
452 | data = self.data[channel] |
|
452 | data = self.data[channel] | |
453 | nChannels = 1 |
|
453 | nChannels = 1 | |
454 | else: |
|
454 | else: | |
455 | data = self.data |
|
455 | data = self.data | |
456 | nChannels = self.nChannels |
|
456 | nChannels = self.nChannels | |
457 |
|
457 | |||
458 | noise = numpy.zeros(nChannels) |
|
458 | noise = numpy.zeros(nChannels) | |
459 | power = data * numpy.conjugate(data) |
|
459 | power = data * numpy.conjugate(data) | |
460 |
|
460 | |||
461 | for thisChannel in range(nChannels): |
|
461 | for thisChannel in range(nChannels): | |
462 | if nChannels == 1: |
|
462 | if nChannels == 1: | |
463 | daux = power[:].real |
|
463 | daux = power[:].real | |
464 | else: |
|
464 | else: | |
465 | daux = power[thisChannel,:].real |
|
465 | daux = power[thisChannel,:].real | |
466 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) |
|
466 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) | |
467 |
|
467 | |||
468 | return noise |
|
468 | return noise | |
469 |
|
469 | |||
470 | def getNoise(self, type = 1, channel = None): |
|
470 | def getNoise(self, type = 1, channel = None): | |
471 |
|
471 | |||
472 | if type == 1: |
|
472 | if type == 1: | |
473 | noise = self.getNoisebyHildebrand(channel) |
|
473 | noise = self.getNoisebyHildebrand(channel) | |
474 |
|
474 | |||
475 | return noise |
|
475 | return noise | |
476 |
|
476 | |||
477 | def getPower(self, channel = None): |
|
477 | def getPower(self, channel = None): | |
478 |
|
478 | |||
479 | if channel != None: |
|
479 | if channel != None: | |
480 | data = self.data[channel] |
|
480 | data = self.data[channel] | |
481 | else: |
|
481 | else: | |
482 | data = self.data |
|
482 | data = self.data | |
483 |
|
483 | |||
484 | power = data * numpy.conjugate(data) |
|
484 | power = data * numpy.conjugate(data) | |
485 | powerdB = 10*numpy.log10(power.real) |
|
485 | powerdB = 10*numpy.log10(power.real) | |
486 | powerdB = numpy.squeeze(powerdB) |
|
486 | powerdB = numpy.squeeze(powerdB) | |
487 |
|
487 | |||
488 | return powerdB |
|
488 | return powerdB | |
489 |
|
489 | |||
490 | def getTimeInterval(self): |
|
490 | def getTimeInterval(self): | |
491 |
|
491 | |||
492 | timeInterval = self.ippSeconds * self.nCohInt |
|
492 | timeInterval = self.ippSeconds * self.nCohInt | |
493 |
|
493 | |||
494 | return timeInterval |
|
494 | return timeInterval | |
495 |
|
495 | |||
496 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
496 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
497 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
497 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
498 |
|
498 | |||
499 | class Spectra(JROData): |
|
499 | class Spectra(JROData): | |
500 |
|
500 | |||
501 | #data spc es un numpy array de 2 dmensiones (canales, perfiles, alturas) |
|
501 | #data spc es un numpy array de 2 dmensiones (canales, perfiles, alturas) | |
502 | data_spc = None |
|
502 | data_spc = None | |
503 |
|
503 | |||
504 | #data cspc es un numpy array de 2 dmensiones (canales, pares, alturas) |
|
504 | #data cspc es un numpy array de 2 dmensiones (canales, pares, alturas) | |
505 | data_cspc = None |
|
505 | data_cspc = None | |
506 |
|
506 | |||
507 | #data dc es un numpy array de 2 dmensiones (canales, alturas) |
|
507 | #data dc es un numpy array de 2 dmensiones (canales, alturas) | |
508 | data_dc = None |
|
508 | data_dc = None | |
509 |
|
509 | |||
510 | #data power |
|
510 | #data power | |
511 | data_pwr = None |
|
511 | data_pwr = None | |
512 |
|
512 | |||
513 | nFFTPoints = None |
|
513 | nFFTPoints = None | |
514 |
|
514 | |||
515 | # nPairs = None |
|
515 | # nPairs = None | |
516 |
|
516 | |||
517 | pairsList = None |
|
517 | pairsList = None | |
518 |
|
518 | |||
519 | nIncohInt = None |
|
519 | nIncohInt = None | |
520 |
|
520 | |||
521 | wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia |
|
521 | wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia | |
522 |
|
522 | |||
523 | nCohInt = None #se requiere para determinar el valor de timeInterval |
|
523 | nCohInt = None #se requiere para determinar el valor de timeInterval | |
524 |
|
524 | |||
525 | ippFactor = None |
|
525 | ippFactor = None | |
526 |
|
526 | |||
527 | profileIndex = 0 |
|
527 | profileIndex = 0 | |
528 |
|
528 | |||
529 | plotting = "spectra" |
|
529 | plotting = "spectra" | |
530 |
|
530 | |||
531 | def __init__(self): |
|
531 | def __init__(self): | |
532 | ''' |
|
532 | ''' | |
533 | Constructor |
|
533 | Constructor | |
534 | ''' |
|
534 | ''' | |
535 |
|
535 | |||
536 | self.useLocalTime = True |
|
536 | self.useLocalTime = True | |
537 |
|
537 | |||
538 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
538 | self.radarControllerHeaderObj = RadarControllerHeader() | |
539 |
|
539 | |||
540 | self.systemHeaderObj = SystemHeader() |
|
540 | self.systemHeaderObj = SystemHeader() | |
541 |
|
541 | |||
542 | self.type = "Spectra" |
|
542 | self.type = "Spectra" | |
543 |
|
543 | |||
544 | # self.data = None |
|
544 | # self.data = None | |
545 |
|
545 | |||
546 | # self.dtype = None |
|
546 | # self.dtype = None | |
547 |
|
547 | |||
548 | # self.nChannels = 0 |
|
548 | # self.nChannels = 0 | |
549 |
|
549 | |||
550 | # self.nHeights = 0 |
|
550 | # self.nHeights = 0 | |
551 |
|
551 | |||
552 | self.nProfiles = None |
|
552 | self.nProfiles = None | |
553 |
|
553 | |||
554 | self.heightList = None |
|
554 | self.heightList = None | |
555 |
|
555 | |||
556 | self.channelList = None |
|
556 | self.channelList = None | |
557 |
|
557 | |||
558 | # self.channelIndexList = None |
|
558 | # self.channelIndexList = None | |
559 |
|
559 | |||
560 | self.pairsList = None |
|
560 | self.pairsList = None | |
561 |
|
561 | |||
562 | self.flagNoData = True |
|
562 | self.flagNoData = True | |
563 |
|
563 | |||
564 | self.flagDiscontinuousBlock = False |
|
564 | self.flagDiscontinuousBlock = False | |
565 |
|
565 | |||
566 | self.utctime = None |
|
566 | self.utctime = None | |
567 |
|
567 | |||
568 | self.nCohInt = None |
|
568 | self.nCohInt = None | |
569 |
|
569 | |||
570 | self.nIncohInt = None |
|
570 | self.nIncohInt = None | |
571 |
|
571 | |||
572 | self.blocksize = None |
|
572 | self.blocksize = None | |
573 |
|
573 | |||
574 | self.nFFTPoints = None |
|
574 | self.nFFTPoints = None | |
575 |
|
575 | |||
576 | self.wavelength = None |
|
576 | self.wavelength = None | |
577 |
|
577 | |||
578 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
578 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
579 |
|
579 | |||
580 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
580 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
581 |
|
581 | |||
582 | self.flagShiftFFT = False |
|
582 | self.flagShiftFFT = False | |
583 |
|
583 | |||
584 | self.ippFactor = 1 |
|
584 | self.ippFactor = 1 | |
585 |
|
585 | |||
586 | #self.noise = None |
|
586 | #self.noise = None | |
587 |
|
587 | |||
588 | self.beacon_heiIndexList = [] |
|
588 | self.beacon_heiIndexList = [] | |
589 |
|
589 | |||
590 | self.noise_estimation = None |
|
590 | self.noise_estimation = None | |
591 |
|
591 | |||
592 |
|
592 | |||
593 | def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): |
|
593 | def getNoisebyHildebrand(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): | |
594 | """ |
|
594 | """ | |
595 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
595 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
596 |
|
596 | |||
597 | Return: |
|
597 | Return: | |
598 | noiselevel |
|
598 | noiselevel | |
599 | """ |
|
599 | """ | |
600 |
|
600 | |||
601 | noise = numpy.zeros(self.nChannels) |
|
601 | noise = numpy.zeros(self.nChannels) | |
602 |
|
602 | |||
603 | for channel in range(self.nChannels): |
|
603 | for channel in range(self.nChannels): | |
604 | daux = self.data_spc[channel,xmin_index:xmax_index,ymin_index:ymax_index] |
|
604 | daux = self.data_spc[channel,xmin_index:xmax_index,ymin_index:ymax_index] | |
605 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) |
|
605 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) | |
606 |
|
606 | |||
607 | return noise |
|
607 | return noise | |
608 |
|
608 | |||
609 | def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): |
|
609 | def getNoise(self, xmin_index=None, xmax_index=None, ymin_index=None, ymax_index=None): | |
610 |
|
610 | |||
611 | if self.noise_estimation is not None: |
|
611 | if self.noise_estimation is not None: | |
612 | return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py |
|
612 | return self.noise_estimation #this was estimated by getNoise Operation defined in jroproc_spectra.py | |
613 | else: |
|
613 | else: | |
614 | noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index) |
|
614 | noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index) | |
615 | return noise |
|
615 | return noise | |
616 |
|
616 | |||
617 | def getFreqRangeTimeResponse(self, extrapoints=0): |
|
617 | def getFreqRangeTimeResponse(self, extrapoints=0): | |
618 |
|
618 | |||
619 | deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints*self.ippFactor) |
|
619 | deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints*self.ippFactor) | |
620 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 |
|
620 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 | |
621 |
|
621 | |||
622 | return freqrange |
|
622 | return freqrange | |
623 |
|
623 | |||
624 | def getAcfRange(self, extrapoints=0): |
|
624 | def getAcfRange(self, extrapoints=0): | |
625 |
|
625 | |||
626 | deltafreq = 10./(self.getFmax() / (self.nFFTPoints*self.ippFactor)) |
|
626 | deltafreq = 10./(self.getFmax() / (self.nFFTPoints*self.ippFactor)) | |
627 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 |
|
627 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 | |
628 |
|
628 | |||
629 | return freqrange |
|
629 | return freqrange | |
630 |
|
630 | |||
631 | def getFreqRange(self, extrapoints=0): |
|
631 | def getFreqRange(self, extrapoints=0): | |
632 |
|
632 | |||
633 | deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor) |
|
633 | deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor) | |
634 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 |
|
634 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 | |
635 |
|
635 | |||
636 | return freqrange |
|
636 | return freqrange | |
637 |
|
637 | |||
638 | def getVelRange(self, extrapoints=0): |
|
638 | def getVelRange(self, extrapoints=0): | |
639 |
|
639 | |||
640 | deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor) |
|
640 | deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor) | |
641 | velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) #- deltav/2 |
|
641 | velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) #- deltav/2 | |
642 |
|
642 | |||
643 | return velrange |
|
643 | return velrange | |
644 |
|
644 | |||
645 | def getNPairs(self): |
|
645 | def getNPairs(self): | |
646 |
|
646 | |||
647 | return len(self.pairsList) |
|
647 | return len(self.pairsList) | |
648 |
|
648 | |||
649 | def getPairsIndexList(self): |
|
649 | def getPairsIndexList(self): | |
650 |
|
650 | |||
651 | return range(self.nPairs) |
|
651 | return range(self.nPairs) | |
652 |
|
652 | |||
653 | def getNormFactor(self): |
|
653 | def getNormFactor(self): | |
654 |
|
654 | |||
655 | pwcode = 1 |
|
655 | pwcode = 1 | |
656 |
|
656 | |||
657 | if self.flagDecodeData: |
|
657 | if self.flagDecodeData: | |
658 | pwcode = numpy.sum(self.code[0]**2) |
|
658 | pwcode = numpy.sum(self.code[0]**2) | |
659 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
659 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
660 | normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
660 | normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
661 |
|
661 | |||
662 | return normFactor |
|
662 | return normFactor | |
663 |
|
663 | |||
664 | def getFlagCspc(self): |
|
664 | def getFlagCspc(self): | |
665 |
|
665 | |||
666 | if self.data_cspc is None: |
|
666 | if self.data_cspc is None: | |
667 | return True |
|
667 | return True | |
668 |
|
668 | |||
669 | return False |
|
669 | return False | |
670 |
|
670 | |||
671 | def getFlagDc(self): |
|
671 | def getFlagDc(self): | |
672 |
|
672 | |||
673 | if self.data_dc is None: |
|
673 | if self.data_dc is None: | |
674 | return True |
|
674 | return True | |
675 |
|
675 | |||
676 | return False |
|
676 | return False | |
677 |
|
677 | |||
678 | def getTimeInterval(self): |
|
678 | def getTimeInterval(self): | |
679 |
|
679 | |||
680 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles |
|
680 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles | |
681 |
|
681 | |||
682 | return timeInterval |
|
682 | return timeInterval | |
683 |
|
683 | |||
684 | def getPower(self): |
|
684 | def getPower(self): | |
685 |
|
685 | |||
686 | factor = self.normFactor |
|
686 | factor = self.normFactor | |
687 | z = self.data_spc/factor |
|
687 | z = self.data_spc/factor | |
688 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
688 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
689 | avg = numpy.average(z, axis=1) |
|
689 | avg = numpy.average(z, axis=1) | |
690 |
|
690 | |||
691 | return 10*numpy.log10(avg) |
|
691 | return 10*numpy.log10(avg) | |
692 |
|
692 | |||
693 | def getCoherence(self, pairsList=None, phase=False): |
|
693 | def getCoherence(self, pairsList=None, phase=False): | |
694 |
|
694 | |||
695 | z = [] |
|
695 | z = [] | |
696 | if pairsList is None: |
|
696 | if pairsList is None: | |
697 | pairsIndexList = self.pairsIndexList |
|
697 | pairsIndexList = self.pairsIndexList | |
698 | else: |
|
698 | else: | |
699 | pairsIndexList = [] |
|
699 | pairsIndexList = [] | |
700 | for pair in pairsList: |
|
700 | for pair in pairsList: | |
701 | if pair not in self.pairsList: |
|
701 | if pair not in self.pairsList: | |
702 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
702 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
703 | pairsIndexList.append(self.pairsList.index(pair)) |
|
703 | pairsIndexList.append(self.pairsList.index(pair)) | |
704 | for i in range(len(pairsIndexList)): |
|
704 | for i in range(len(pairsIndexList)): | |
705 | pair = self.pairsList[pairsIndexList[i]] |
|
705 | pair = self.pairsList[pairsIndexList[i]] | |
706 | ccf = numpy.average(self.data_cspc[pairsIndexList[i], :, :], axis=0) |
|
706 | ccf = numpy.average(self.data_cspc[pairsIndexList[i], :, :], axis=0) | |
707 | powa = numpy.average(self.data_spc[pair[0], :, :], axis=0) |
|
707 | powa = numpy.average(self.data_spc[pair[0], :, :], axis=0) | |
708 | powb = numpy.average(self.data_spc[pair[1], :, :], axis=0) |
|
708 | powb = numpy.average(self.data_spc[pair[1], :, :], axis=0) | |
709 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
709 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
710 | if phase: |
|
710 | if phase: | |
711 | data = numpy.arctan2(avgcoherenceComplex.imag, |
|
711 | data = numpy.arctan2(avgcoherenceComplex.imag, | |
712 | avgcoherenceComplex.real)*180/numpy.pi |
|
712 | avgcoherenceComplex.real)*180/numpy.pi | |
713 | else: |
|
713 | else: | |
714 | data = numpy.abs(avgcoherenceComplex) |
|
714 | data = numpy.abs(avgcoherenceComplex) | |
715 |
|
715 | |||
716 | z.append(data) |
|
716 | z.append(data) | |
717 |
|
717 | |||
718 | return numpy.array(z) |
|
718 | return numpy.array(z) | |
719 |
|
719 | |||
720 | def setValue(self, value): |
|
720 | def setValue(self, value): | |
721 |
|
721 | |||
722 | print "This property should not be initialized" |
|
722 | print "This property should not be initialized" | |
723 |
|
723 | |||
724 | return |
|
724 | return | |
725 |
|
725 | |||
726 | nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.") |
|
726 | nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.") | |
727 | pairsIndexList = property(getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.") |
|
727 | pairsIndexList = property(getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.") | |
728 | normFactor = property(getNormFactor, setValue, "I'm the 'getNormFactor' property.") |
|
728 | normFactor = property(getNormFactor, setValue, "I'm the 'getNormFactor' property.") | |
729 | flag_cspc = property(getFlagCspc, setValue) |
|
729 | flag_cspc = property(getFlagCspc, setValue) | |
730 | flag_dc = property(getFlagDc, setValue) |
|
730 | flag_dc = property(getFlagDc, setValue) | |
731 | noise = property(getNoise, setValue, "I'm the 'nHeights' property.") |
|
731 | noise = property(getNoise, setValue, "I'm the 'nHeights' property.") | |
732 | timeInterval = property(getTimeInterval, setValue, "I'm the 'timeInterval' property") |
|
732 | timeInterval = property(getTimeInterval, setValue, "I'm the 'timeInterval' property") | |
733 |
|
733 | |||
734 | class SpectraHeis(Spectra): |
|
734 | class SpectraHeis(Spectra): | |
735 |
|
735 | |||
736 | data_spc = None |
|
736 | data_spc = None | |
737 |
|
737 | |||
738 | data_cspc = None |
|
738 | data_cspc = None | |
739 |
|
739 | |||
740 | data_dc = None |
|
740 | data_dc = None | |
741 |
|
741 | |||
742 | nFFTPoints = None |
|
742 | nFFTPoints = None | |
743 |
|
743 | |||
744 | # nPairs = None |
|
744 | # nPairs = None | |
745 |
|
745 | |||
746 | pairsList = None |
|
746 | pairsList = None | |
747 |
|
747 | |||
748 | nCohInt = None |
|
748 | nCohInt = None | |
749 |
|
749 | |||
750 | nIncohInt = None |
|
750 | nIncohInt = None | |
751 |
|
751 | |||
752 | def __init__(self): |
|
752 | def __init__(self): | |
753 |
|
753 | |||
754 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
754 | self.radarControllerHeaderObj = RadarControllerHeader() | |
755 |
|
755 | |||
756 | self.systemHeaderObj = SystemHeader() |
|
756 | self.systemHeaderObj = SystemHeader() | |
757 |
|
757 | |||
758 | self.type = "SpectraHeis" |
|
758 | self.type = "SpectraHeis" | |
759 |
|
759 | |||
760 | # self.dtype = None |
|
760 | # self.dtype = None | |
761 |
|
761 | |||
762 | # self.nChannels = 0 |
|
762 | # self.nChannels = 0 | |
763 |
|
763 | |||
764 | # self.nHeights = 0 |
|
764 | # self.nHeights = 0 | |
765 |
|
765 | |||
766 | self.nProfiles = None |
|
766 | self.nProfiles = None | |
767 |
|
767 | |||
768 | self.heightList = None |
|
768 | self.heightList = None | |
769 |
|
769 | |||
770 | self.channelList = None |
|
770 | self.channelList = None | |
771 |
|
771 | |||
772 | # self.channelIndexList = None |
|
772 | # self.channelIndexList = None | |
773 |
|
773 | |||
774 | self.flagNoData = True |
|
774 | self.flagNoData = True | |
775 |
|
775 | |||
776 | self.flagDiscontinuousBlock = False |
|
776 | self.flagDiscontinuousBlock = False | |
777 |
|
777 | |||
778 | # self.nPairs = 0 |
|
778 | # self.nPairs = 0 | |
779 |
|
779 | |||
780 | self.utctime = None |
|
780 | self.utctime = None | |
781 |
|
781 | |||
782 | self.blocksize = None |
|
782 | self.blocksize = None | |
783 |
|
783 | |||
784 | self.profileIndex = 0 |
|
784 | self.profileIndex = 0 | |
785 |
|
785 | |||
786 | self.nCohInt = 1 |
|
786 | self.nCohInt = 1 | |
787 |
|
787 | |||
788 | self.nIncohInt = 1 |
|
788 | self.nIncohInt = 1 | |
789 |
|
789 | |||
790 | def getNormFactor(self): |
|
790 | def getNormFactor(self): | |
791 | pwcode = 1 |
|
791 | pwcode = 1 | |
792 | if self.flagDecodeData: |
|
792 | if self.flagDecodeData: | |
793 | pwcode = numpy.sum(self.code[0]**2) |
|
793 | pwcode = numpy.sum(self.code[0]**2) | |
794 |
|
794 | |||
795 | normFactor = self.nIncohInt*self.nCohInt*pwcode |
|
795 | normFactor = self.nIncohInt*self.nCohInt*pwcode | |
796 |
|
796 | |||
797 | return normFactor |
|
797 | return normFactor | |
798 |
|
798 | |||
799 | def getTimeInterval(self): |
|
799 | def getTimeInterval(self): | |
800 |
|
800 | |||
801 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
801 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
802 |
|
802 | |||
803 | return timeInterval |
|
803 | return timeInterval | |
804 |
|
804 | |||
805 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") |
|
805 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") | |
806 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
806 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
807 |
|
807 | |||
808 | class Fits(JROData): |
|
808 | class Fits(JROData): | |
809 |
|
809 | |||
810 | heightList = None |
|
810 | heightList = None | |
811 |
|
811 | |||
812 | channelList = None |
|
812 | channelList = None | |
813 |
|
813 | |||
814 | flagNoData = True |
|
814 | flagNoData = True | |
815 |
|
815 | |||
816 | flagDiscontinuousBlock = False |
|
816 | flagDiscontinuousBlock = False | |
817 |
|
817 | |||
818 | useLocalTime = False |
|
818 | useLocalTime = False | |
819 |
|
819 | |||
820 | utctime = None |
|
820 | utctime = None | |
821 |
|
821 | |||
822 | timeZone = None |
|
822 | timeZone = None | |
823 |
|
823 | |||
824 | # ippSeconds = None |
|
824 | # ippSeconds = None | |
825 |
|
825 | |||
826 | # timeInterval = None |
|
826 | # timeInterval = None | |
827 |
|
827 | |||
828 | nCohInt = None |
|
828 | nCohInt = None | |
829 |
|
829 | |||
830 | nIncohInt = None |
|
830 | nIncohInt = None | |
831 |
|
831 | |||
832 | noise = None |
|
832 | noise = None | |
833 |
|
833 | |||
834 | windowOfFilter = 1 |
|
834 | windowOfFilter = 1 | |
835 |
|
835 | |||
836 | #Speed of ligth |
|
836 | #Speed of ligth | |
837 | C = 3e8 |
|
837 | C = 3e8 | |
838 |
|
838 | |||
839 | frequency = 49.92e6 |
|
839 | frequency = 49.92e6 | |
840 |
|
840 | |||
841 | realtime = False |
|
841 | realtime = False | |
842 |
|
842 | |||
843 |
|
843 | |||
844 | def __init__(self): |
|
844 | def __init__(self): | |
845 |
|
845 | |||
846 | self.type = "Fits" |
|
846 | self.type = "Fits" | |
847 |
|
847 | |||
848 | self.nProfiles = None |
|
848 | self.nProfiles = None | |
849 |
|
849 | |||
850 | self.heightList = None |
|
850 | self.heightList = None | |
851 |
|
851 | |||
852 | self.channelList = None |
|
852 | self.channelList = None | |
853 |
|
853 | |||
854 | # self.channelIndexList = None |
|
854 | # self.channelIndexList = None | |
855 |
|
855 | |||
856 | self.flagNoData = True |
|
856 | self.flagNoData = True | |
857 |
|
857 | |||
858 | self.utctime = None |
|
858 | self.utctime = None | |
859 |
|
859 | |||
860 | self.nCohInt = 1 |
|
860 | self.nCohInt = 1 | |
861 |
|
861 | |||
862 | self.nIncohInt = 1 |
|
862 | self.nIncohInt = 1 | |
863 |
|
863 | |||
864 | self.useLocalTime = True |
|
864 | self.useLocalTime = True | |
865 |
|
865 | |||
866 | self.profileIndex = 0 |
|
866 | self.profileIndex = 0 | |
867 |
|
867 | |||
868 | # self.utctime = None |
|
868 | # self.utctime = None | |
869 | # self.timeZone = None |
|
869 | # self.timeZone = None | |
870 | # self.ltctime = None |
|
870 | # self.ltctime = None | |
871 | # self.timeInterval = None |
|
871 | # self.timeInterval = None | |
872 | # self.header = None |
|
872 | # self.header = None | |
873 | # self.data_header = None |
|
873 | # self.data_header = None | |
874 | # self.data = None |
|
874 | # self.data = None | |
875 | # self.datatime = None |
|
875 | # self.datatime = None | |
876 | # self.flagNoData = False |
|
876 | # self.flagNoData = False | |
877 | # self.expName = '' |
|
877 | # self.expName = '' | |
878 | # self.nChannels = None |
|
878 | # self.nChannels = None | |
879 | # self.nSamples = None |
|
879 | # self.nSamples = None | |
880 | # self.dataBlocksPerFile = None |
|
880 | # self.dataBlocksPerFile = None | |
881 | # self.comments = '' |
|
881 | # self.comments = '' | |
882 | # |
|
882 | # | |
883 |
|
883 | |||
884 |
|
884 | |||
885 | def getltctime(self): |
|
885 | def getltctime(self): | |
886 |
|
886 | |||
887 | if self.useLocalTime: |
|
887 | if self.useLocalTime: | |
888 | return self.utctime - self.timeZone*60 |
|
888 | return self.utctime - self.timeZone*60 | |
889 |
|
889 | |||
890 | return self.utctime |
|
890 | return self.utctime | |
891 |
|
891 | |||
892 | def getDatatime(self): |
|
892 | def getDatatime(self): | |
893 |
|
893 | |||
894 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
894 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) | |
895 | return datatime |
|
895 | return datatime | |
896 |
|
896 | |||
897 | def getTimeRange(self): |
|
897 | def getTimeRange(self): | |
898 |
|
898 | |||
899 | datatime = [] |
|
899 | datatime = [] | |
900 |
|
900 | |||
901 | datatime.append(self.ltctime) |
|
901 | datatime.append(self.ltctime) | |
902 | datatime.append(self.ltctime + self.timeInterval) |
|
902 | datatime.append(self.ltctime + self.timeInterval) | |
903 |
|
903 | |||
904 | datatime = numpy.array(datatime) |
|
904 | datatime = numpy.array(datatime) | |
905 |
|
905 | |||
906 | return datatime |
|
906 | return datatime | |
907 |
|
907 | |||
908 | def getHeiRange(self): |
|
908 | def getHeiRange(self): | |
909 |
|
909 | |||
910 | heis = self.heightList |
|
910 | heis = self.heightList | |
911 |
|
911 | |||
912 | return heis |
|
912 | return heis | |
913 |
|
913 | |||
914 | def getNHeights(self): |
|
914 | def getNHeights(self): | |
915 |
|
915 | |||
916 | return len(self.heightList) |
|
916 | return len(self.heightList) | |
917 |
|
917 | |||
918 | def getNChannels(self): |
|
918 | def getNChannels(self): | |
919 |
|
919 | |||
920 | return len(self.channelList) |
|
920 | return len(self.channelList) | |
921 |
|
921 | |||
922 | def getChannelIndexList(self): |
|
922 | def getChannelIndexList(self): | |
923 |
|
923 | |||
924 | return range(self.nChannels) |
|
924 | return range(self.nChannels) | |
925 |
|
925 | |||
926 | def getNoise(self, type = 1): |
|
926 | def getNoise(self, type = 1): | |
927 |
|
927 | |||
928 | #noise = numpy.zeros(self.nChannels) |
|
928 | #noise = numpy.zeros(self.nChannels) | |
929 |
|
929 | |||
930 | if type == 1: |
|
930 | if type == 1: | |
931 | noise = self.getNoisebyHildebrand() |
|
931 | noise = self.getNoisebyHildebrand() | |
932 |
|
932 | |||
933 | if type == 2: |
|
933 | if type == 2: | |
934 | noise = self.getNoisebySort() |
|
934 | noise = self.getNoisebySort() | |
935 |
|
935 | |||
936 | if type == 3: |
|
936 | if type == 3: | |
937 | noise = self.getNoisebyWindow() |
|
937 | noise = self.getNoisebyWindow() | |
938 |
|
938 | |||
939 | return noise |
|
939 | return noise | |
940 |
|
940 | |||
941 | def getTimeInterval(self): |
|
941 | def getTimeInterval(self): | |
942 |
|
942 | |||
943 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
943 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
944 |
|
944 | |||
945 | return timeInterval |
|
945 | return timeInterval | |
946 |
|
946 | |||
947 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
947 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
948 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
948 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
949 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
949 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
950 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
950 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
951 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
951 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
952 |
|
952 | |||
953 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
953 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
954 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
954 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
955 |
|
955 | |||
956 |
|
956 | |||
957 | class Correlation(JROData): |
|
957 | class Correlation(JROData): | |
958 |
|
958 | |||
959 | noise = None |
|
959 | noise = None | |
960 |
|
960 | |||
961 | SNR = None |
|
961 | SNR = None | |
962 |
|
962 | |||
963 | #-------------------------------------------------- |
|
963 | #-------------------------------------------------- | |
964 |
|
964 | |||
965 | mode = None |
|
965 | mode = None | |
966 |
|
966 | |||
967 | split = False |
|
967 | split = False | |
968 |
|
968 | |||
969 | data_cf = None |
|
969 | data_cf = None | |
970 |
|
970 | |||
971 | lags = None |
|
971 | lags = None | |
972 |
|
972 | |||
973 | lagRange = None |
|
973 | lagRange = None | |
974 |
|
974 | |||
975 | pairsList = None |
|
975 | pairsList = None | |
976 |
|
976 | |||
977 | normFactor = None |
|
977 | normFactor = None | |
978 |
|
978 | |||
979 | #-------------------------------------------------- |
|
979 | #-------------------------------------------------- | |
980 |
|
980 | |||
981 | # calculateVelocity = None |
|
981 | # calculateVelocity = None | |
982 |
|
982 | |||
983 | nLags = None |
|
983 | nLags = None | |
984 |
|
984 | |||
985 | nPairs = None |
|
985 | nPairs = None | |
986 |
|
986 | |||
987 | nAvg = None |
|
987 | nAvg = None | |
988 |
|
988 | |||
989 |
|
989 | |||
990 | def __init__(self): |
|
990 | def __init__(self): | |
991 | ''' |
|
991 | ''' | |
992 | Constructor |
|
992 | Constructor | |
993 | ''' |
|
993 | ''' | |
994 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
994 | self.radarControllerHeaderObj = RadarControllerHeader() | |
995 |
|
995 | |||
996 | self.systemHeaderObj = SystemHeader() |
|
996 | self.systemHeaderObj = SystemHeader() | |
997 |
|
997 | |||
998 | self.type = "Correlation" |
|
998 | self.type = "Correlation" | |
999 |
|
999 | |||
1000 | self.data = None |
|
1000 | self.data = None | |
1001 |
|
1001 | |||
1002 | self.dtype = None |
|
1002 | self.dtype = None | |
1003 |
|
1003 | |||
1004 | self.nProfiles = None |
|
1004 | self.nProfiles = None | |
1005 |
|
1005 | |||
1006 | self.heightList = None |
|
1006 | self.heightList = None | |
1007 |
|
1007 | |||
1008 | self.channelList = None |
|
1008 | self.channelList = None | |
1009 |
|
1009 | |||
1010 | self.flagNoData = True |
|
1010 | self.flagNoData = True | |
1011 |
|
1011 | |||
1012 | self.flagDiscontinuousBlock = False |
|
1012 | self.flagDiscontinuousBlock = False | |
1013 |
|
1013 | |||
1014 | self.utctime = None |
|
1014 | self.utctime = None | |
1015 |
|
1015 | |||
1016 | self.timeZone = None |
|
1016 | self.timeZone = None | |
1017 |
|
1017 | |||
1018 | self.dstFlag = None |
|
1018 | self.dstFlag = None | |
1019 |
|
1019 | |||
1020 | self.errorCount = None |
|
1020 | self.errorCount = None | |
1021 |
|
1021 | |||
1022 | self.blocksize = None |
|
1022 | self.blocksize = None | |
1023 |
|
1023 | |||
1024 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
1024 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
1025 |
|
1025 | |||
1026 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
1026 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
1027 |
|
1027 | |||
1028 | self.pairsList = None |
|
1028 | self.pairsList = None | |
1029 |
|
1029 | |||
1030 | self.nPoints = None |
|
1030 | self.nPoints = None | |
1031 |
|
1031 | |||
1032 | def getPairsList(self): |
|
1032 | def getPairsList(self): | |
1033 |
|
1033 | |||
1034 | return self.pairsList |
|
1034 | return self.pairsList | |
1035 |
|
1035 | |||
1036 | def getNoise(self, mode = 2): |
|
1036 | def getNoise(self, mode = 2): | |
1037 |
|
1037 | |||
1038 | indR = numpy.where(self.lagR == 0)[0][0] |
|
1038 | indR = numpy.where(self.lagR == 0)[0][0] | |
1039 | indT = numpy.where(self.lagT == 0)[0][0] |
|
1039 | indT = numpy.where(self.lagT == 0)[0][0] | |
1040 |
|
1040 | |||
1041 | jspectra0 = self.data_corr[:,:,indR,:] |
|
1041 | jspectra0 = self.data_corr[:,:,indR,:] | |
1042 | jspectra = copy.copy(jspectra0) |
|
1042 | jspectra = copy.copy(jspectra0) | |
1043 |
|
1043 | |||
1044 | num_chan = jspectra.shape[0] |
|
1044 | num_chan = jspectra.shape[0] | |
1045 | num_hei = jspectra.shape[2] |
|
1045 | num_hei = jspectra.shape[2] | |
1046 |
|
1046 | |||
1047 | freq_dc = jspectra.shape[1]/2 |
|
1047 | freq_dc = jspectra.shape[1]/2 | |
1048 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc |
|
1048 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc | |
1049 |
|
1049 | |||
1050 | if ind_vel[0]<0: |
|
1050 | if ind_vel[0]<0: | |
1051 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof |
|
1051 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof | |
1052 |
|
1052 | |||
1053 | if mode == 1: |
|
1053 | if mode == 1: | |
1054 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION |
|
1054 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION | |
1055 |
|
1055 | |||
1056 | if mode == 2: |
|
1056 | if mode == 2: | |
1057 |
|
1057 | |||
1058 | vel = numpy.array([-2,-1,1,2]) |
|
1058 | vel = numpy.array([-2,-1,1,2]) | |
1059 | xx = numpy.zeros([4,4]) |
|
1059 | xx = numpy.zeros([4,4]) | |
1060 |
|
1060 | |||
1061 | for fil in range(4): |
|
1061 | for fil in range(4): | |
1062 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) |
|
1062 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) | |
1063 |
|
1063 | |||
1064 | xx_inv = numpy.linalg.inv(xx) |
|
1064 | xx_inv = numpy.linalg.inv(xx) | |
1065 | xx_aux = xx_inv[0,:] |
|
1065 | xx_aux = xx_inv[0,:] | |
1066 |
|
1066 | |||
1067 | for ich in range(num_chan): |
|
1067 | for ich in range(num_chan): | |
1068 | yy = jspectra[ich,ind_vel,:] |
|
1068 | yy = jspectra[ich,ind_vel,:] | |
1069 | jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy) |
|
1069 | jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy) | |
1070 |
|
1070 | |||
1071 | junkid = jspectra[ich,freq_dc,:]<=0 |
|
1071 | junkid = jspectra[ich,freq_dc,:]<=0 | |
1072 | cjunkid = sum(junkid) |
|
1072 | cjunkid = sum(junkid) | |
1073 |
|
1073 | |||
1074 | if cjunkid.any(): |
|
1074 | if cjunkid.any(): | |
1075 | jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2 |
|
1075 | jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2 | |
1076 |
|
1076 | |||
1077 | noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:] |
|
1077 | noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:] | |
1078 |
|
1078 | |||
1079 | return noise |
|
1079 | return noise | |
1080 |
|
1080 | |||
1081 | def getTimeInterval(self): |
|
1081 | def getTimeInterval(self): | |
1082 |
|
1082 | |||
1083 | timeInterval = self.ippSeconds * self.nCohInt * self.nProfiles |
|
1083 | timeInterval = self.ippSeconds * self.nCohInt * self.nProfiles | |
1084 |
|
1084 | |||
1085 | return timeInterval |
|
1085 | return timeInterval | |
1086 |
|
1086 | |||
1087 | def splitFunctions(self): |
|
1087 | def splitFunctions(self): | |
1088 |
|
1088 | |||
1089 | pairsList = self.pairsList |
|
1089 | pairsList = self.pairsList | |
1090 | ccf_pairs = [] |
|
1090 | ccf_pairs = [] | |
1091 | acf_pairs = [] |
|
1091 | acf_pairs = [] | |
1092 | ccf_ind = [] |
|
1092 | ccf_ind = [] | |
1093 | acf_ind = [] |
|
1093 | acf_ind = [] | |
1094 | for l in range(len(pairsList)): |
|
1094 | for l in range(len(pairsList)): | |
1095 | chan0 = pairsList[l][0] |
|
1095 | chan0 = pairsList[l][0] | |
1096 | chan1 = pairsList[l][1] |
|
1096 | chan1 = pairsList[l][1] | |
1097 |
|
1097 | |||
1098 | #Obteniendo pares de Autocorrelacion |
|
1098 | #Obteniendo pares de Autocorrelacion | |
1099 | if chan0 == chan1: |
|
1099 | if chan0 == chan1: | |
1100 | acf_pairs.append(chan0) |
|
1100 | acf_pairs.append(chan0) | |
1101 | acf_ind.append(l) |
|
1101 | acf_ind.append(l) | |
1102 | else: |
|
1102 | else: | |
1103 | ccf_pairs.append(pairsList[l]) |
|
1103 | ccf_pairs.append(pairsList[l]) | |
1104 | ccf_ind.append(l) |
|
1104 | ccf_ind.append(l) | |
1105 |
|
1105 | |||
1106 | data_acf = self.data_cf[acf_ind] |
|
1106 | data_acf = self.data_cf[acf_ind] | |
1107 | data_ccf = self.data_cf[ccf_ind] |
|
1107 | data_ccf = self.data_cf[ccf_ind] | |
1108 |
|
1108 | |||
1109 | return acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf |
|
1109 | return acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf | |
1110 |
|
1110 | |||
1111 | def getNormFactor(self): |
|
1111 | def getNormFactor(self): | |
1112 | acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf = self.splitFunctions() |
|
1112 | acf_ind, ccf_ind, acf_pairs, ccf_pairs, data_acf, data_ccf = self.splitFunctions() | |
1113 | acf_pairs = numpy.array(acf_pairs) |
|
1113 | acf_pairs = numpy.array(acf_pairs) | |
1114 | normFactor = numpy.zeros((self.nPairs,self.nHeights)) |
|
1114 | normFactor = numpy.zeros((self.nPairs,self.nHeights)) | |
1115 |
|
1115 | |||
1116 | for p in range(self.nPairs): |
|
1116 | for p in range(self.nPairs): | |
1117 | pair = self.pairsList[p] |
|
1117 | pair = self.pairsList[p] | |
1118 |
|
1118 | |||
1119 | ch0 = pair[0] |
|
1119 | ch0 = pair[0] | |
1120 | ch1 = pair[1] |
|
1120 | ch1 = pair[1] | |
1121 |
|
1121 | |||
1122 | ch0_max = numpy.max(data_acf[acf_pairs==ch0,:,:], axis=1) |
|
1122 | ch0_max = numpy.max(data_acf[acf_pairs==ch0,:,:], axis=1) | |
1123 | ch1_max = numpy.max(data_acf[acf_pairs==ch1,:,:], axis=1) |
|
1123 | ch1_max = numpy.max(data_acf[acf_pairs==ch1,:,:], axis=1) | |
1124 | normFactor[p,:] = numpy.sqrt(ch0_max*ch1_max) |
|
1124 | normFactor[p,:] = numpy.sqrt(ch0_max*ch1_max) | |
1125 |
|
1125 | |||
1126 | return normFactor |
|
1126 | return normFactor | |
1127 |
|
1127 | |||
1128 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
1128 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
1129 | normFactor = property(getNormFactor, "I'm the 'normFactor property'") |
|
1129 | normFactor = property(getNormFactor, "I'm the 'normFactor property'") | |
1130 |
|
1130 | |||
1131 | class Parameters(Spectra): |
|
1131 | class Parameters(Spectra): | |
1132 |
|
1132 | |||
1133 | experimentInfo = None #Information about the experiment |
|
1133 | experimentInfo = None #Information about the experiment | |
1134 |
|
1134 | |||
1135 | #Information from previous data |
|
1135 | #Information from previous data | |
1136 |
|
1136 | |||
1137 | inputUnit = None #Type of data to be processed |
|
1137 | inputUnit = None #Type of data to be processed | |
1138 |
|
1138 | |||
1139 | operation = None #Type of operation to parametrize |
|
1139 | operation = None #Type of operation to parametrize | |
1140 |
|
1140 | |||
1141 | #normFactor = None #Normalization Factor |
|
1141 | #normFactor = None #Normalization Factor | |
1142 |
|
1142 | |||
1143 | groupList = None #List of Pairs, Groups, etc |
|
1143 | groupList = None #List of Pairs, Groups, etc | |
1144 |
|
1144 | |||
1145 | #Parameters |
|
1145 | #Parameters | |
1146 |
|
1146 | |||
1147 | data_param = None #Parameters obtained |
|
1147 | data_param = None #Parameters obtained | |
1148 |
|
1148 | |||
1149 | data_pre = None #Data Pre Parametrization |
|
1149 | data_pre = None #Data Pre Parametrization | |
1150 |
|
1150 | |||
1151 | data_SNR = None #Signal to Noise Ratio |
|
1151 | data_SNR = None #Signal to Noise Ratio | |
1152 |
|
1152 | |||
1153 | # heightRange = None #Heights |
|
1153 | # heightRange = None #Heights | |
1154 |
|
1154 | |||
1155 | abscissaList = None #Abscissa, can be velocities, lags or time |
|
1155 | abscissaList = None #Abscissa, can be velocities, lags or time | |
1156 |
|
1156 | |||
1157 | # noise = None #Noise Potency |
|
1157 | # noise = None #Noise Potency | |
1158 |
|
1158 | |||
1159 | utctimeInit = None #Initial UTC time |
|
1159 | utctimeInit = None #Initial UTC time | |
1160 |
|
1160 | |||
1161 | paramInterval = None #Time interval to calculate Parameters in seconds |
|
1161 | paramInterval = None #Time interval to calculate Parameters in seconds | |
1162 |
|
1162 | |||
1163 | useLocalTime = True |
|
1163 | useLocalTime = True | |
1164 |
|
1164 | |||
1165 | #Fitting |
|
1165 | #Fitting | |
1166 |
|
1166 | |||
1167 | data_error = None #Error of the estimation |
|
1167 | data_error = None #Error of the estimation | |
1168 |
|
1168 | |||
1169 | constants = None |
|
1169 | constants = None | |
1170 |
|
1170 | |||
1171 | library = None |
|
1171 | library = None | |
1172 |
|
1172 | |||
1173 | #Output signal |
|
1173 | #Output signal | |
1174 |
|
1174 | |||
1175 | outputInterval = None #Time interval to calculate output signal in seconds |
|
1175 | outputInterval = None #Time interval to calculate output signal in seconds | |
1176 |
|
1176 | |||
1177 | data_output = None #Out signal |
|
1177 | data_output = None #Out signal | |
1178 |
|
1178 | |||
1179 | nAvg = None |
|
1179 | nAvg = None | |
1180 |
|
1180 | |||
1181 | noise_estimation = None |
|
1181 | noise_estimation = None | |
1182 |
|
1182 | |||
1183 | GauSPC = None #Fit gaussian SPC |
|
1183 | GauSPC = None #Fit gaussian SPC | |
1184 |
|
1184 | |||
1185 |
|
1185 | |||
1186 | def __init__(self): |
|
1186 | def __init__(self): | |
1187 | ''' |
|
1187 | ''' | |
1188 | Constructor |
|
1188 | Constructor | |
1189 | ''' |
|
1189 | ''' | |
1190 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
1190 | self.radarControllerHeaderObj = RadarControllerHeader() | |
1191 |
|
1191 | |||
1192 | self.systemHeaderObj = SystemHeader() |
|
1192 | self.systemHeaderObj = SystemHeader() | |
1193 |
|
1193 | |||
1194 | self.type = "Parameters" |
|
1194 | self.type = "Parameters" | |
1195 |
|
1195 | |||
1196 | def getTimeRange1(self, interval): |
|
1196 | def getTimeRange1(self, interval): | |
1197 |
|
1197 | |||
1198 | datatime = [] |
|
1198 | datatime = [] | |
1199 |
|
1199 | |||
1200 | if self.useLocalTime: |
|
1200 | if self.useLocalTime: | |
1201 | time1 = self.utctimeInit - self.timeZone*60 |
|
1201 | time1 = self.utctimeInit - self.timeZone*60 | |
1202 | else: |
|
1202 | else: | |
1203 | time1 = self.utctimeInit |
|
1203 | time1 = self.utctimeInit | |
1204 | print 'interval',interval |
|
1204 | ||
1205 | datatime.append(time1) |
|
1205 | datatime.append(time1) | |
1206 | datatime.append(time1 + interval) |
|
1206 | datatime.append(time1 + interval) | |
1207 | datatime = numpy.array(datatime) |
|
1207 | datatime = numpy.array(datatime) | |
1208 |
|
1208 | |||
1209 | return datatime |
|
1209 | return datatime | |
1210 |
|
1210 | |||
1211 | def getTimeInterval(self): |
|
1211 | def getTimeInterval(self): | |
1212 |
|
1212 | |||
1213 | if hasattr(self, 'timeInterval1'): |
|
1213 | if hasattr(self, 'timeInterval1'): | |
1214 | return self.timeInterval1 |
|
1214 | return self.timeInterval1 | |
1215 | else: |
|
1215 | else: | |
1216 | return self.paramInterval |
|
1216 | return self.paramInterval | |
1217 |
|
1217 | |||
1218 | def setValue(self, value): |
|
1218 | def setValue(self, value): | |
1219 |
|
1219 | |||
1220 | print "This property should not be initialized" |
|
1220 | print "This property should not be initialized" | |
1221 |
|
1221 | |||
1222 | return |
|
1222 | return | |
1223 |
|
1223 | |||
1224 | def getNoise(self): |
|
1224 | def getNoise(self): | |
1225 |
|
1225 | |||
1226 | return self.spc_noise |
|
1226 | return self.spc_noise | |
1227 |
|
1227 | |||
1228 | timeInterval = property(getTimeInterval) |
|
1228 | timeInterval = property(getTimeInterval) | |
1229 | noise = property(getNoise, setValue, "I'm the 'Noise' property.") |
|
1229 | noise = property(getNoise, setValue, "I'm the 'Noise' property.") |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,2159 +1,2154 | |||||
1 | import os |
|
1 | import os | |
2 | import datetime |
|
2 | import datetime | |
3 | import numpy |
|
3 | import numpy | |
4 | import inspect |
|
4 | import inspect | |
5 | from figure import Figure, isRealtime, isTimeInHourRange |
|
5 | from figure import Figure, isRealtime, isTimeInHourRange | |
6 | from plotting_codes import * |
|
6 | from plotting_codes import * | |
7 |
|
7 | |||
8 |
|
8 | |||
9 | class FitGauPlot(Figure): |
|
9 | class FitGauPlot(Figure): | |
10 |
|
10 | |||
11 | isConfig = None |
|
11 | isConfig = None | |
12 | __nsubplots = None |
|
12 | __nsubplots = None | |
13 |
|
13 | |||
14 | WIDTHPROF = None |
|
14 | WIDTHPROF = None | |
15 | HEIGHTPROF = None |
|
15 | HEIGHTPROF = None | |
16 | PREFIX = 'fitgau' |
|
16 | PREFIX = 'fitgau' | |
17 |
|
17 | |||
18 | def __init__(self, **kwargs): |
|
18 | def __init__(self, **kwargs): | |
19 | Figure.__init__(self, **kwargs) |
|
19 | Figure.__init__(self, **kwargs) | |
20 | self.isConfig = False |
|
20 | self.isConfig = False | |
21 | self.__nsubplots = 1 |
|
21 | self.__nsubplots = 1 | |
22 |
|
22 | |||
23 | self.WIDTH = 250 |
|
23 | self.WIDTH = 250 | |
24 | self.HEIGHT = 250 |
|
24 | self.HEIGHT = 250 | |
25 | self.WIDTHPROF = 120 |
|
25 | self.WIDTHPROF = 120 | |
26 | self.HEIGHTPROF = 0 |
|
26 | self.HEIGHTPROF = 0 | |
27 | self.counter_imagwr = 0 |
|
27 | self.counter_imagwr = 0 | |
28 |
|
28 | |||
29 | self.PLOT_CODE = SPEC_CODE |
|
29 | self.PLOT_CODE = SPEC_CODE | |
30 |
|
30 | |||
31 | self.FTP_WEI = None |
|
31 | self.FTP_WEI = None | |
32 | self.EXP_CODE = None |
|
32 | self.EXP_CODE = None | |
33 | self.SUB_EXP_CODE = None |
|
33 | self.SUB_EXP_CODE = None | |
34 | self.PLOT_POS = None |
|
34 | self.PLOT_POS = None | |
35 |
|
35 | |||
36 | self.__xfilter_ena = False |
|
36 | self.__xfilter_ena = False | |
37 | self.__yfilter_ena = False |
|
37 | self.__yfilter_ena = False | |
38 |
|
38 | |||
39 | def getSubplots(self): |
|
39 | def getSubplots(self): | |
40 |
|
40 | |||
41 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
41 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
42 | nrow = int(self.nplots*1./ncol + 0.9) |
|
42 | nrow = int(self.nplots*1./ncol + 0.9) | |
43 |
|
43 | |||
44 | return nrow, ncol |
|
44 | return nrow, ncol | |
45 |
|
45 | |||
46 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
46 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
47 |
|
47 | |||
48 | self.__showprofile = showprofile |
|
48 | self.__showprofile = showprofile | |
49 | self.nplots = nplots |
|
49 | self.nplots = nplots | |
50 |
|
50 | |||
51 | ncolspan = 1 |
|
51 | ncolspan = 1 | |
52 | colspan = 1 |
|
52 | colspan = 1 | |
53 | if showprofile: |
|
53 | if showprofile: | |
54 | ncolspan = 3 |
|
54 | ncolspan = 3 | |
55 | colspan = 2 |
|
55 | colspan = 2 | |
56 | self.__nsubplots = 2 |
|
56 | self.__nsubplots = 2 | |
57 |
|
57 | |||
58 | self.createFigure(id = id, |
|
58 | self.createFigure(id = id, | |
59 | wintitle = wintitle, |
|
59 | wintitle = wintitle, | |
60 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
60 | widthplot = self.WIDTH + self.WIDTHPROF, | |
61 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
61 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
62 | show=show) |
|
62 | show=show) | |
63 |
|
63 | |||
64 | nrow, ncol = self.getSubplots() |
|
64 | nrow, ncol = self.getSubplots() | |
65 |
|
65 | |||
66 | counter = 0 |
|
66 | counter = 0 | |
67 | for y in range(nrow): |
|
67 | for y in range(nrow): | |
68 | for x in range(ncol): |
|
68 | for x in range(ncol): | |
69 |
|
69 | |||
70 | if counter >= self.nplots: |
|
70 | if counter >= self.nplots: | |
71 | break |
|
71 | break | |
72 |
|
72 | |||
73 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
73 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
74 |
|
74 | |||
75 | if showprofile: |
|
75 | if showprofile: | |
76 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
76 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
77 |
|
77 | |||
78 | counter += 1 |
|
78 | counter += 1 | |
79 |
|
79 | |||
80 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
80 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
81 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
81 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
82 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
82 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
83 | server=None, folder=None, username=None, password=None, |
|
83 | server=None, folder=None, username=None, password=None, | |
84 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False, |
|
84 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False, | |
85 | xaxis="frequency", colormap='jet', normFactor=None , GauSelector = 1): |
|
85 | xaxis="frequency", colormap='jet', normFactor=None , GauSelector = 1): | |
86 |
|
86 | |||
87 | """ |
|
87 | """ | |
88 |
|
88 | |||
89 | Input: |
|
89 | Input: | |
90 | dataOut : |
|
90 | dataOut : | |
91 | id : |
|
91 | id : | |
92 | wintitle : |
|
92 | wintitle : | |
93 | channelList : |
|
93 | channelList : | |
94 | showProfile : |
|
94 | showProfile : | |
95 | xmin : None, |
|
95 | xmin : None, | |
96 | xmax : None, |
|
96 | xmax : None, | |
97 | ymin : None, |
|
97 | ymin : None, | |
98 | ymax : None, |
|
98 | ymax : None, | |
99 | zmin : None, |
|
99 | zmin : None, | |
100 | zmax : None |
|
100 | zmax : None | |
101 | """ |
|
101 | """ | |
102 | if realtime: |
|
102 | if realtime: | |
103 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
103 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
104 | print 'Skipping this plot function' |
|
104 | print 'Skipping this plot function' | |
105 | return |
|
105 | return | |
106 |
|
106 | |||
107 | if channelList == None: |
|
107 | if channelList == None: | |
108 | channelIndexList = dataOut.channelIndexList |
|
108 | channelIndexList = dataOut.channelIndexList | |
109 | else: |
|
109 | else: | |
110 | channelIndexList = [] |
|
110 | channelIndexList = [] | |
111 | for channel in channelList: |
|
111 | for channel in channelList: | |
112 | if channel not in dataOut.channelList: |
|
112 | if channel not in dataOut.channelList: | |
113 | raise ValueError, "Channel %d is not in dataOut.channelList" %channel |
|
113 | raise ValueError, "Channel %d is not in dataOut.channelList" %channel | |
114 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
114 | channelIndexList.append(dataOut.channelList.index(channel)) | |
115 |
|
115 | |||
116 | # if normFactor is None: |
|
116 | # if normFactor is None: | |
117 | # factor = dataOut.normFactor |
|
117 | # factor = dataOut.normFactor | |
118 | # else: |
|
118 | # else: | |
119 | # factor = normFactor |
|
119 | # factor = normFactor | |
120 | if xaxis == "frequency": |
|
120 | if xaxis == "frequency": | |
121 | x = dataOut.spc_range[0] |
|
121 | x = dataOut.spc_range[0] | |
122 | xlabel = "Frequency (kHz)" |
|
122 | xlabel = "Frequency (kHz)" | |
123 |
|
123 | |||
124 | elif xaxis == "time": |
|
124 | elif xaxis == "time": | |
125 | x = dataOut.spc_range[1] |
|
125 | x = dataOut.spc_range[1] | |
126 | xlabel = "Time (ms)" |
|
126 | xlabel = "Time (ms)" | |
127 |
|
127 | |||
128 | else: |
|
128 | else: | |
129 | x = dataOut.spc_range[2] |
|
129 | x = dataOut.spc_range[2] | |
130 | xlabel = "Velocity (m/s)" |
|
130 | xlabel = "Velocity (m/s)" | |
131 |
|
131 | |||
132 | ylabel = "Range (Km)" |
|
132 | ylabel = "Range (Km)" | |
133 |
|
133 | |||
134 | y = dataOut.getHeiRange() |
|
134 | y = dataOut.getHeiRange() | |
135 |
|
135 | |||
136 | z = dataOut.GauSPC[:,GauSelector,:,:] #GauSelector] #dataOut.data_spc/factor |
|
136 | z = dataOut.GauSPC[:,GauSelector,:,:] #GauSelector] #dataOut.data_spc/factor | |
137 | print 'GausSPC', z[0,32,10:40] |
|
137 | print 'GausSPC', z[0,32,10:40] | |
138 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
138 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
139 | zdB = 10*numpy.log10(z) |
|
139 | zdB = 10*numpy.log10(z) | |
140 |
|
140 | |||
141 | avg = numpy.average(z, axis=1) |
|
141 | avg = numpy.average(z, axis=1) | |
142 | avgdB = 10*numpy.log10(avg) |
|
142 | avgdB = 10*numpy.log10(avg) | |
143 |
|
143 | |||
144 | noise = dataOut.spc_noise |
|
144 | noise = dataOut.spc_noise | |
145 | noisedB = 10*numpy.log10(noise) |
|
145 | noisedB = 10*numpy.log10(noise) | |
146 |
|
146 | |||
147 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
147 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
148 | title = wintitle + " Spectra" |
|
148 | title = wintitle + " Spectra" | |
149 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
149 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
150 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
150 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
151 |
|
151 | |||
152 | if not self.isConfig: |
|
152 | if not self.isConfig: | |
153 |
|
153 | |||
154 | nplots = len(channelIndexList) |
|
154 | nplots = len(channelIndexList) | |
155 |
|
155 | |||
156 | self.setup(id=id, |
|
156 | self.setup(id=id, | |
157 | nplots=nplots, |
|
157 | nplots=nplots, | |
158 | wintitle=wintitle, |
|
158 | wintitle=wintitle, | |
159 | showprofile=showprofile, |
|
159 | showprofile=showprofile, | |
160 | show=show) |
|
160 | show=show) | |
161 |
|
161 | |||
162 | if xmin == None: xmin = numpy.nanmin(x) |
|
162 | if xmin == None: xmin = numpy.nanmin(x) | |
163 | if xmax == None: xmax = numpy.nanmax(x) |
|
163 | if xmax == None: xmax = numpy.nanmax(x) | |
164 | if ymin == None: ymin = numpy.nanmin(y) |
|
164 | if ymin == None: ymin = numpy.nanmin(y) | |
165 | if ymax == None: ymax = numpy.nanmax(y) |
|
165 | if ymax == None: ymax = numpy.nanmax(y) | |
166 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 |
|
166 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 | |
167 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 |
|
167 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 | |
168 |
|
168 | |||
169 | self.FTP_WEI = ftp_wei |
|
169 | self.FTP_WEI = ftp_wei | |
170 | self.EXP_CODE = exp_code |
|
170 | self.EXP_CODE = exp_code | |
171 | self.SUB_EXP_CODE = sub_exp_code |
|
171 | self.SUB_EXP_CODE = sub_exp_code | |
172 | self.PLOT_POS = plot_pos |
|
172 | self.PLOT_POS = plot_pos | |
173 |
|
173 | |||
174 | self.isConfig = True |
|
174 | self.isConfig = True | |
175 |
|
175 | |||
176 | self.setWinTitle(title) |
|
176 | self.setWinTitle(title) | |
177 |
|
177 | |||
178 | for i in range(self.nplots): |
|
178 | for i in range(self.nplots): | |
179 | index = channelIndexList[i] |
|
179 | index = channelIndexList[i] | |
180 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
180 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
181 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime) |
|
181 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime) | |
182 | if len(dataOut.beam.codeList) != 0: |
|
182 | if len(dataOut.beam.codeList) != 0: | |
183 | 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) |
|
183 | 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) | |
184 |
|
184 | |||
185 | axes = self.axesList[i*self.__nsubplots] |
|
185 | axes = self.axesList[i*self.__nsubplots] | |
186 | axes.pcolor(x, y, zdB[index,:,:], |
|
186 | axes.pcolor(x, y, zdB[index,:,:], | |
187 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
187 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
188 | xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap, |
|
188 | xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap, | |
189 | ticksize=9, cblabel='') |
|
189 | ticksize=9, cblabel='') | |
190 |
|
190 | |||
191 | if self.__showprofile: |
|
191 | if self.__showprofile: | |
192 | axes = self.axesList[i*self.__nsubplots +1] |
|
192 | axes = self.axesList[i*self.__nsubplots +1] | |
193 | axes.pline(avgdB[index,:], y, |
|
193 | axes.pline(avgdB[index,:], y, | |
194 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
194 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
195 | xlabel='dB', ylabel='', title='', |
|
195 | xlabel='dB', ylabel='', title='', | |
196 | ytick_visible=False, |
|
196 | ytick_visible=False, | |
197 | grid='x') |
|
197 | grid='x') | |
198 |
|
198 | |||
199 | noiseline = numpy.repeat(noisedB[index], len(y)) |
|
199 | noiseline = numpy.repeat(noisedB[index], len(y)) | |
200 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
200 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
201 |
|
201 | |||
202 | self.draw() |
|
202 | self.draw() | |
203 |
|
203 | |||
204 | if figfile == None: |
|
204 | if figfile == None: | |
205 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
205 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
206 | name = str_datetime |
|
206 | name = str_datetime | |
207 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
207 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
208 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) |
|
208 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | |
209 | figfile = self.getFilename(name) |
|
209 | figfile = self.getFilename(name) | |
210 |
|
210 | |||
211 | self.save(figpath=figpath, |
|
211 | self.save(figpath=figpath, | |
212 | figfile=figfile, |
|
212 | figfile=figfile, | |
213 | save=save, |
|
213 | save=save, | |
214 | ftp=ftp, |
|
214 | ftp=ftp, | |
215 | wr_period=wr_period, |
|
215 | wr_period=wr_period, | |
216 | thisDatetime=thisDatetime) |
|
216 | thisDatetime=thisDatetime) | |
217 |
|
217 | |||
218 |
|
218 | |||
219 |
|
219 | |||
220 | class MomentsPlot(Figure): |
|
220 | class MomentsPlot(Figure): | |
221 |
|
221 | |||
222 | isConfig = None |
|
222 | isConfig = None | |
223 | __nsubplots = None |
|
223 | __nsubplots = None | |
224 |
|
224 | |||
225 | WIDTHPROF = None |
|
225 | WIDTHPROF = None | |
226 | HEIGHTPROF = None |
|
226 | HEIGHTPROF = None | |
227 | PREFIX = 'prm' |
|
227 | PREFIX = 'prm' | |
228 |
|
228 | |||
229 | def __init__(self, **kwargs): |
|
229 | def __init__(self, **kwargs): | |
230 | Figure.__init__(self, **kwargs) |
|
230 | Figure.__init__(self, **kwargs) | |
231 | self.isConfig = False |
|
231 | self.isConfig = False | |
232 | self.__nsubplots = 1 |
|
232 | self.__nsubplots = 1 | |
233 |
|
233 | |||
234 | self.WIDTH = 280 |
|
234 | self.WIDTH = 280 | |
235 | self.HEIGHT = 250 |
|
235 | self.HEIGHT = 250 | |
236 | self.WIDTHPROF = 120 |
|
236 | self.WIDTHPROF = 120 | |
237 | self.HEIGHTPROF = 0 |
|
237 | self.HEIGHTPROF = 0 | |
238 | self.counter_imagwr = 0 |
|
238 | self.counter_imagwr = 0 | |
239 |
|
239 | |||
240 | self.PLOT_CODE = MOMENTS_CODE |
|
240 | self.PLOT_CODE = MOMENTS_CODE | |
241 |
|
241 | |||
242 | self.FTP_WEI = None |
|
242 | self.FTP_WEI = None | |
243 | self.EXP_CODE = None |
|
243 | self.EXP_CODE = None | |
244 | self.SUB_EXP_CODE = None |
|
244 | self.SUB_EXP_CODE = None | |
245 | self.PLOT_POS = None |
|
245 | self.PLOT_POS = None | |
246 |
|
246 | |||
247 | def getSubplots(self): |
|
247 | def getSubplots(self): | |
248 |
|
248 | |||
249 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
249 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
250 | nrow = int(self.nplots*1./ncol + 0.9) |
|
250 | nrow = int(self.nplots*1./ncol + 0.9) | |
251 |
|
251 | |||
252 | return nrow, ncol |
|
252 | return nrow, ncol | |
253 |
|
253 | |||
254 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
254 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
255 |
|
255 | |||
256 | self.__showprofile = showprofile |
|
256 | self.__showprofile = showprofile | |
257 | self.nplots = nplots |
|
257 | self.nplots = nplots | |
258 |
|
258 | |||
259 | ncolspan = 1 |
|
259 | ncolspan = 1 | |
260 | colspan = 1 |
|
260 | colspan = 1 | |
261 | if showprofile: |
|
261 | if showprofile: | |
262 | ncolspan = 3 |
|
262 | ncolspan = 3 | |
263 | colspan = 2 |
|
263 | colspan = 2 | |
264 | self.__nsubplots = 2 |
|
264 | self.__nsubplots = 2 | |
265 |
|
265 | |||
266 | self.createFigure(id = id, |
|
266 | self.createFigure(id = id, | |
267 | wintitle = wintitle, |
|
267 | wintitle = wintitle, | |
268 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
268 | widthplot = self.WIDTH + self.WIDTHPROF, | |
269 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
269 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
270 | show=show) |
|
270 | show=show) | |
271 |
|
271 | |||
272 | nrow, ncol = self.getSubplots() |
|
272 | nrow, ncol = self.getSubplots() | |
273 |
|
273 | |||
274 | counter = 0 |
|
274 | counter = 0 | |
275 | for y in range(nrow): |
|
275 | for y in range(nrow): | |
276 | for x in range(ncol): |
|
276 | for x in range(ncol): | |
277 |
|
277 | |||
278 | if counter >= self.nplots: |
|
278 | if counter >= self.nplots: | |
279 | break |
|
279 | break | |
280 |
|
280 | |||
281 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
281 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
282 |
|
282 | |||
283 | if showprofile: |
|
283 | if showprofile: | |
284 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
284 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
285 |
|
285 | |||
286 | counter += 1 |
|
286 | counter += 1 | |
287 |
|
287 | |||
288 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
288 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
289 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
289 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
290 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
290 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
291 | server=None, folder=None, username=None, password=None, |
|
291 | server=None, folder=None, username=None, password=None, | |
292 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): |
|
292 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | |
293 |
|
293 | |||
294 | """ |
|
294 | """ | |
295 |
|
295 | |||
296 | Input: |
|
296 | Input: | |
297 | dataOut : |
|
297 | dataOut : | |
298 | id : |
|
298 | id : | |
299 | wintitle : |
|
299 | wintitle : | |
300 | channelList : |
|
300 | channelList : | |
301 | showProfile : |
|
301 | showProfile : | |
302 | xmin : None, |
|
302 | xmin : None, | |
303 | xmax : None, |
|
303 | xmax : None, | |
304 | ymin : None, |
|
304 | ymin : None, | |
305 | ymax : None, |
|
305 | ymax : None, | |
306 | zmin : None, |
|
306 | zmin : None, | |
307 | zmax : None |
|
307 | zmax : None | |
308 | """ |
|
308 | """ | |
309 |
|
309 | |||
310 | if dataOut.flagNoData: |
|
310 | if dataOut.flagNoData: | |
311 | return None |
|
311 | return None | |
312 |
|
312 | |||
313 | if realtime: |
|
313 | if realtime: | |
314 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
314 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
315 | print 'Skipping this plot function' |
|
315 | print 'Skipping this plot function' | |
316 | return |
|
316 | return | |
317 |
|
317 | |||
318 | if channelList == None: |
|
318 | if channelList == None: | |
319 | channelIndexList = dataOut.channelIndexList |
|
319 | channelIndexList = dataOut.channelIndexList | |
320 | else: |
|
320 | else: | |
321 | channelIndexList = [] |
|
321 | channelIndexList = [] | |
322 | for channel in channelList: |
|
322 | for channel in channelList: | |
323 | if channel not in dataOut.channelList: |
|
323 | if channel not in dataOut.channelList: | |
324 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
324 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
325 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
325 | channelIndexList.append(dataOut.channelList.index(channel)) | |
326 |
|
326 | |||
327 | factor = dataOut.normFactor |
|
327 | factor = dataOut.normFactor | |
328 | x = dataOut.abscissaList |
|
328 | x = dataOut.abscissaList | |
329 | y = dataOut.heightList |
|
329 | y = dataOut.heightList | |
330 |
|
330 | |||
331 | z = dataOut.data_pre[channelIndexList,:,:]/factor |
|
331 | z = dataOut.data_pre[channelIndexList,:,:]/factor | |
332 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
332 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
333 | avg = numpy.average(z, axis=1) |
|
333 | avg = numpy.average(z, axis=1) | |
334 | noise = dataOut.noise/factor |
|
334 | noise = dataOut.noise/factor | |
335 |
|
335 | |||
336 | zdB = 10*numpy.log10(z) |
|
336 | zdB = 10*numpy.log10(z) | |
337 | avgdB = 10*numpy.log10(avg) |
|
337 | avgdB = 10*numpy.log10(avg) | |
338 | noisedB = 10*numpy.log10(noise) |
|
338 | noisedB = 10*numpy.log10(noise) | |
339 |
|
339 | |||
340 | #thisDatetime = dataOut.datatime |
|
340 | #thisDatetime = dataOut.datatime | |
341 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
341 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
342 | title = wintitle + " Parameters" |
|
342 | title = wintitle + " Parameters" | |
343 | xlabel = "Velocity (m/s)" |
|
343 | xlabel = "Velocity (m/s)" | |
344 | ylabel = "Range (Km)" |
|
344 | ylabel = "Range (Km)" | |
345 |
|
345 | |||
346 | update_figfile = False |
|
346 | update_figfile = False | |
347 |
|
347 | |||
348 | if not self.isConfig: |
|
348 | if not self.isConfig: | |
349 |
|
349 | |||
350 | nplots = len(channelIndexList) |
|
350 | nplots = len(channelIndexList) | |
351 |
|
351 | |||
352 | self.setup(id=id, |
|
352 | self.setup(id=id, | |
353 | nplots=nplots, |
|
353 | nplots=nplots, | |
354 | wintitle=wintitle, |
|
354 | wintitle=wintitle, | |
355 | showprofile=showprofile, |
|
355 | showprofile=showprofile, | |
356 | show=show) |
|
356 | show=show) | |
357 |
|
357 | |||
358 | if xmin == None: xmin = numpy.nanmin(x) |
|
358 | if xmin == None: xmin = numpy.nanmin(x) | |
359 | if xmax == None: xmax = numpy.nanmax(x) |
|
359 | if xmax == None: xmax = numpy.nanmax(x) | |
360 | if ymin == None: ymin = numpy.nanmin(y) |
|
360 | if ymin == None: ymin = numpy.nanmin(y) | |
361 | if ymax == None: ymax = numpy.nanmax(y) |
|
361 | if ymax == None: ymax = numpy.nanmax(y) | |
362 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
362 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
363 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
363 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
364 |
|
364 | |||
365 | self.FTP_WEI = ftp_wei |
|
365 | self.FTP_WEI = ftp_wei | |
366 | self.EXP_CODE = exp_code |
|
366 | self.EXP_CODE = exp_code | |
367 | self.SUB_EXP_CODE = sub_exp_code |
|
367 | self.SUB_EXP_CODE = sub_exp_code | |
368 | self.PLOT_POS = plot_pos |
|
368 | self.PLOT_POS = plot_pos | |
369 |
|
369 | |||
370 | self.isConfig = True |
|
370 | self.isConfig = True | |
371 | update_figfile = True |
|
371 | update_figfile = True | |
372 |
|
372 | |||
373 | self.setWinTitle(title) |
|
373 | self.setWinTitle(title) | |
374 |
|
374 | |||
375 | for i in range(self.nplots): |
|
375 | for i in range(self.nplots): | |
376 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
376 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
377 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime) |
|
377 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime) | |
378 | axes = self.axesList[i*self.__nsubplots] |
|
378 | axes = self.axesList[i*self.__nsubplots] | |
379 | axes.pcolor(x, y, zdB[i,:,:], |
|
379 | axes.pcolor(x, y, zdB[i,:,:], | |
380 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
380 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
381 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
381 | xlabel=xlabel, ylabel=ylabel, title=title, | |
382 | ticksize=9, cblabel='') |
|
382 | ticksize=9, cblabel='') | |
383 | #Mean Line |
|
383 | #Mean Line | |
384 | mean = dataOut.data_param[i, 1, :] |
|
384 | mean = dataOut.data_param[i, 1, :] | |
385 | axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1) |
|
385 | axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1) | |
386 |
|
386 | |||
387 | if self.__showprofile: |
|
387 | if self.__showprofile: | |
388 | axes = self.axesList[i*self.__nsubplots +1] |
|
388 | axes = self.axesList[i*self.__nsubplots +1] | |
389 | axes.pline(avgdB[i], y, |
|
389 | axes.pline(avgdB[i], y, | |
390 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
390 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
391 | xlabel='dB', ylabel='', title='', |
|
391 | xlabel='dB', ylabel='', title='', | |
392 | ytick_visible=False, |
|
392 | ytick_visible=False, | |
393 | grid='x') |
|
393 | grid='x') | |
394 |
|
394 | |||
395 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
395 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
396 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
396 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
397 |
|
397 | |||
398 | self.draw() |
|
398 | self.draw() | |
399 |
|
399 | |||
400 | self.save(figpath=figpath, |
|
400 | self.save(figpath=figpath, | |
401 | figfile=figfile, |
|
401 | figfile=figfile, | |
402 | save=save, |
|
402 | save=save, | |
403 | ftp=ftp, |
|
403 | ftp=ftp, | |
404 | wr_period=wr_period, |
|
404 | wr_period=wr_period, | |
405 | thisDatetime=thisDatetime) |
|
405 | thisDatetime=thisDatetime) | |
406 |
|
406 | |||
407 |
|
407 | |||
408 |
|
408 | |||
409 | class SkyMapPlot(Figure): |
|
409 | class SkyMapPlot(Figure): | |
410 |
|
410 | |||
411 | __isConfig = None |
|
411 | __isConfig = None | |
412 | __nsubplots = None |
|
412 | __nsubplots = None | |
413 |
|
413 | |||
414 | WIDTHPROF = None |
|
414 | WIDTHPROF = None | |
415 | HEIGHTPROF = None |
|
415 | HEIGHTPROF = None | |
416 | PREFIX = 'mmap' |
|
416 | PREFIX = 'mmap' | |
417 |
|
417 | |||
418 | def __init__(self, **kwargs): |
|
418 | def __init__(self, **kwargs): | |
419 | Figure.__init__(self, **kwargs) |
|
419 | Figure.__init__(self, **kwargs) | |
420 | self.isConfig = False |
|
420 | self.isConfig = False | |
421 | self.__nsubplots = 1 |
|
421 | self.__nsubplots = 1 | |
422 |
|
422 | |||
423 | # self.WIDTH = 280 |
|
423 | # self.WIDTH = 280 | |
424 | # self.HEIGHT = 250 |
|
424 | # self.HEIGHT = 250 | |
425 | self.WIDTH = 600 |
|
425 | self.WIDTH = 600 | |
426 | self.HEIGHT = 600 |
|
426 | self.HEIGHT = 600 | |
427 | self.WIDTHPROF = 120 |
|
427 | self.WIDTHPROF = 120 | |
428 | self.HEIGHTPROF = 0 |
|
428 | self.HEIGHTPROF = 0 | |
429 | self.counter_imagwr = 0 |
|
429 | self.counter_imagwr = 0 | |
430 |
|
430 | |||
431 | self.PLOT_CODE = MSKYMAP_CODE |
|
431 | self.PLOT_CODE = MSKYMAP_CODE | |
432 |
|
432 | |||
433 | self.FTP_WEI = None |
|
433 | self.FTP_WEI = None | |
434 | self.EXP_CODE = None |
|
434 | self.EXP_CODE = None | |
435 | self.SUB_EXP_CODE = None |
|
435 | self.SUB_EXP_CODE = None | |
436 | self.PLOT_POS = None |
|
436 | self.PLOT_POS = None | |
437 |
|
437 | |||
438 | def getSubplots(self): |
|
438 | def getSubplots(self): | |
439 |
|
439 | |||
440 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
440 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
441 | nrow = int(self.nplots*1./ncol + 0.9) |
|
441 | nrow = int(self.nplots*1./ncol + 0.9) | |
442 |
|
442 | |||
443 | return nrow, ncol |
|
443 | return nrow, ncol | |
444 |
|
444 | |||
445 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): |
|
445 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): | |
446 |
|
446 | |||
447 | self.__showprofile = showprofile |
|
447 | self.__showprofile = showprofile | |
448 | self.nplots = nplots |
|
448 | self.nplots = nplots | |
449 |
|
449 | |||
450 | ncolspan = 1 |
|
450 | ncolspan = 1 | |
451 | colspan = 1 |
|
451 | colspan = 1 | |
452 |
|
452 | |||
453 | self.createFigure(id = id, |
|
453 | self.createFigure(id = id, | |
454 | wintitle = wintitle, |
|
454 | wintitle = wintitle, | |
455 | widthplot = self.WIDTH, #+ self.WIDTHPROF, |
|
455 | widthplot = self.WIDTH, #+ self.WIDTHPROF, | |
456 | heightplot = self.HEIGHT,# + self.HEIGHTPROF, |
|
456 | heightplot = self.HEIGHT,# + self.HEIGHTPROF, | |
457 | show=show) |
|
457 | show=show) | |
458 |
|
458 | |||
459 | nrow, ncol = 1,1 |
|
459 | nrow, ncol = 1,1 | |
460 | counter = 0 |
|
460 | counter = 0 | |
461 | x = 0 |
|
461 | x = 0 | |
462 | y = 0 |
|
462 | y = 0 | |
463 | self.addAxes(1, 1, 0, 0, 1, 1, True) |
|
463 | self.addAxes(1, 1, 0, 0, 1, 1, True) | |
464 |
|
464 | |||
465 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, |
|
465 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | |
466 | tmin=0, tmax=24, timerange=None, |
|
466 | tmin=0, tmax=24, timerange=None, | |
467 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
467 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
468 | server=None, folder=None, username=None, password=None, |
|
468 | server=None, folder=None, username=None, password=None, | |
469 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): |
|
469 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | |
470 |
|
470 | |||
471 | """ |
|
471 | """ | |
472 |
|
472 | |||
473 | Input: |
|
473 | Input: | |
474 | dataOut : |
|
474 | dataOut : | |
475 | id : |
|
475 | id : | |
476 | wintitle : |
|
476 | wintitle : | |
477 | channelList : |
|
477 | channelList : | |
478 | showProfile : |
|
478 | showProfile : | |
479 | xmin : None, |
|
479 | xmin : None, | |
480 | xmax : None, |
|
480 | xmax : None, | |
481 | ymin : None, |
|
481 | ymin : None, | |
482 | ymax : None, |
|
482 | ymax : None, | |
483 | zmin : None, |
|
483 | zmin : None, | |
484 | zmax : None |
|
484 | zmax : None | |
485 | """ |
|
485 | """ | |
486 |
|
486 | |||
487 | arrayParameters = dataOut.data_param |
|
487 | arrayParameters = dataOut.data_param | |
488 | error = arrayParameters[:,-1] |
|
488 | error = arrayParameters[:,-1] | |
489 | indValid = numpy.where(error == 0)[0] |
|
489 | indValid = numpy.where(error == 0)[0] | |
490 | finalMeteor = arrayParameters[indValid,:] |
|
490 | finalMeteor = arrayParameters[indValid,:] | |
491 | finalAzimuth = finalMeteor[:,3] |
|
491 | finalAzimuth = finalMeteor[:,3] | |
492 | finalZenith = finalMeteor[:,4] |
|
492 | finalZenith = finalMeteor[:,4] | |
493 |
|
493 | |||
494 | x = finalAzimuth*numpy.pi/180 |
|
494 | x = finalAzimuth*numpy.pi/180 | |
495 | y = finalZenith |
|
495 | y = finalZenith | |
496 | x1 = [dataOut.ltctime, dataOut.ltctime] |
|
496 | x1 = [dataOut.ltctime, dataOut.ltctime] | |
497 |
|
497 | |||
498 | #thisDatetime = dataOut.datatime |
|
498 | #thisDatetime = dataOut.datatime | |
499 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) |
|
499 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | |
500 | title = wintitle + " Parameters" |
|
500 | title = wintitle + " Parameters" | |
501 | xlabel = "Zonal Zenith Angle (deg) " |
|
501 | xlabel = "Zonal Zenith Angle (deg) " | |
502 | ylabel = "Meridional Zenith Angle (deg)" |
|
502 | ylabel = "Meridional Zenith Angle (deg)" | |
503 | update_figfile = False |
|
503 | update_figfile = False | |
504 |
|
504 | |||
505 | if not self.isConfig: |
|
505 | if not self.isConfig: | |
506 |
|
506 | |||
507 | nplots = 1 |
|
507 | nplots = 1 | |
508 |
|
508 | |||
509 | self.setup(id=id, |
|
509 | self.setup(id=id, | |
510 | nplots=nplots, |
|
510 | nplots=nplots, | |
511 | wintitle=wintitle, |
|
511 | wintitle=wintitle, | |
512 | showprofile=showprofile, |
|
512 | showprofile=showprofile, | |
513 | show=show) |
|
513 | show=show) | |
514 |
|
514 | |||
515 | if self.xmin is None and self.xmax is None: |
|
515 | if self.xmin is None and self.xmax is None: | |
516 | self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange) |
|
516 | self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange) | |
517 |
|
517 | |||
518 | if timerange != None: |
|
518 | if timerange != None: | |
519 | self.timerange = timerange |
|
519 | self.timerange = timerange | |
520 | else: |
|
520 | else: | |
521 | self.timerange = self.xmax - self.xmin |
|
521 | self.timerange = self.xmax - self.xmin | |
522 |
|
522 | |||
523 | self.FTP_WEI = ftp_wei |
|
523 | self.FTP_WEI = ftp_wei | |
524 | self.EXP_CODE = exp_code |
|
524 | self.EXP_CODE = exp_code | |
525 | self.SUB_EXP_CODE = sub_exp_code |
|
525 | self.SUB_EXP_CODE = sub_exp_code | |
526 | self.PLOT_POS = plot_pos |
|
526 | self.PLOT_POS = plot_pos | |
527 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
527 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
528 | self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
528 | self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
529 | self.isConfig = True |
|
529 | self.isConfig = True | |
530 | update_figfile = True |
|
530 | update_figfile = True | |
531 |
|
531 | |||
532 | self.setWinTitle(title) |
|
532 | self.setWinTitle(title) | |
533 |
|
533 | |||
534 | i = 0 |
|
534 | i = 0 | |
535 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
535 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
536 |
|
536 | |||
537 | axes = self.axesList[i*self.__nsubplots] |
|
537 | axes = self.axesList[i*self.__nsubplots] | |
538 | nevents = axes.x_buffer.shape[0] + x.shape[0] |
|
538 | nevents = axes.x_buffer.shape[0] + x.shape[0] | |
539 | title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents) |
|
539 | title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents) | |
540 | axes.polar(x, y, |
|
540 | axes.polar(x, y, | |
541 | title=title, xlabel=xlabel, ylabel=ylabel, |
|
541 | title=title, xlabel=xlabel, ylabel=ylabel, | |
542 | ticksize=9, cblabel='') |
|
542 | ticksize=9, cblabel='') | |
543 |
|
543 | |||
544 | self.draw() |
|
544 | self.draw() | |
545 |
|
545 | |||
546 | self.save(figpath=figpath, |
|
546 | self.save(figpath=figpath, | |
547 | figfile=figfile, |
|
547 | figfile=figfile, | |
548 | save=save, |
|
548 | save=save, | |
549 | ftp=ftp, |
|
549 | ftp=ftp, | |
550 | wr_period=wr_period, |
|
550 | wr_period=wr_period, | |
551 | thisDatetime=thisDatetime, |
|
551 | thisDatetime=thisDatetime, | |
552 | update_figfile=update_figfile) |
|
552 | update_figfile=update_figfile) | |
553 |
|
553 | |||
554 | if dataOut.ltctime >= self.xmax: |
|
554 | if dataOut.ltctime >= self.xmax: | |
555 | self.isConfigmagwr = wr_period |
|
555 | self.isConfigmagwr = wr_period | |
556 | self.isConfig = False |
|
556 | self.isConfig = False | |
557 | update_figfile = True |
|
557 | update_figfile = True | |
558 | axes.__firsttime = True |
|
558 | axes.__firsttime = True | |
559 | self.xmin += self.timerange |
|
559 | self.xmin += self.timerange | |
560 | self.xmax += self.timerange |
|
560 | self.xmax += self.timerange | |
561 |
|
561 | |||
562 |
|
562 | |||
563 |
|
563 | |||
564 |
|
564 | |||
565 | class WindProfilerPlot(Figure): |
|
565 | class WindProfilerPlot(Figure): | |
566 |
|
566 | |||
567 | __isConfig = None |
|
567 | __isConfig = None | |
568 | __nsubplots = None |
|
568 | __nsubplots = None | |
569 |
|
569 | |||
570 | WIDTHPROF = None |
|
570 | WIDTHPROF = None | |
571 | HEIGHTPROF = None |
|
571 | HEIGHTPROF = None | |
572 | PREFIX = 'wind' |
|
572 | PREFIX = 'wind' | |
573 |
|
573 | |||
574 | def __init__(self, **kwargs): |
|
574 | def __init__(self, **kwargs): | |
575 | Figure.__init__(self, **kwargs) |
|
575 | Figure.__init__(self, **kwargs) | |
576 | self.timerange = None |
|
576 | self.timerange = None | |
577 | self.isConfig = False |
|
577 | self.isConfig = False | |
578 | self.__nsubplots = 1 |
|
578 | self.__nsubplots = 1 | |
579 |
|
579 | |||
580 | self.WIDTH = 800 |
|
580 | self.WIDTH = 800 | |
581 | self.HEIGHT = 300 |
|
581 | self.HEIGHT = 300 | |
582 | self.WIDTHPROF = 120 |
|
582 | self.WIDTHPROF = 120 | |
583 | self.HEIGHTPROF = 0 |
|
583 | self.HEIGHTPROF = 0 | |
584 | self.counter_imagwr = 0 |
|
584 | self.counter_imagwr = 0 | |
585 |
|
585 | |||
586 | self.PLOT_CODE = WIND_CODE |
|
586 | self.PLOT_CODE = WIND_CODE | |
587 |
|
587 | |||
588 | self.FTP_WEI = None |
|
588 | self.FTP_WEI = None | |
589 | self.EXP_CODE = None |
|
589 | self.EXP_CODE = None | |
590 | self.SUB_EXP_CODE = None |
|
590 | self.SUB_EXP_CODE = None | |
591 | self.PLOT_POS = None |
|
591 | self.PLOT_POS = None | |
592 | self.tmin = None |
|
592 | self.tmin = None | |
593 | self.tmax = None |
|
593 | self.tmax = None | |
594 |
|
594 | |||
595 | self.xmin = None |
|
595 | self.xmin = None | |
596 | self.xmax = None |
|
596 | self.xmax = None | |
597 |
|
597 | |||
598 | self.figfile = None |
|
598 | self.figfile = None | |
599 |
|
599 | |||
600 | def getSubplots(self): |
|
600 | def getSubplots(self): | |
601 |
|
601 | |||
602 | ncol = 1 |
|
602 | ncol = 1 | |
603 | nrow = self.nplots |
|
603 | nrow = self.nplots | |
604 |
|
604 | |||
605 | return nrow, ncol |
|
605 | return nrow, ncol | |
606 |
|
606 | |||
607 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
607 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
608 |
|
608 | |||
609 | self.__showprofile = showprofile |
|
609 | self.__showprofile = showprofile | |
610 | self.nplots = nplots |
|
610 | self.nplots = nplots | |
611 |
|
611 | |||
612 | ncolspan = 1 |
|
612 | ncolspan = 1 | |
613 | colspan = 1 |
|
613 | colspan = 1 | |
614 |
|
614 | |||
615 | self.createFigure(id = id, |
|
615 | self.createFigure(id = id, | |
616 | wintitle = wintitle, |
|
616 | wintitle = wintitle, | |
617 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
617 | widthplot = self.WIDTH + self.WIDTHPROF, | |
618 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
618 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
619 | show=show) |
|
619 | show=show) | |
620 |
|
620 | |||
621 | nrow, ncol = self.getSubplots() |
|
621 | nrow, ncol = self.getSubplots() | |
622 |
|
622 | |||
623 | counter = 0 |
|
623 | counter = 0 | |
624 | for y in range(nrow): |
|
624 | for y in range(nrow): | |
625 | if counter >= self.nplots: |
|
625 | if counter >= self.nplots: | |
626 | break |
|
626 | break | |
627 |
|
627 | |||
628 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) |
|
628 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) | |
629 | counter += 1 |
|
629 | counter += 1 | |
630 |
|
630 | |||
631 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False', |
|
631 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False', | |
632 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
632 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
633 | zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None, |
|
633 | zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None, | |
634 | timerange=None, SNRthresh = None, |
|
634 | timerange=None, SNRthresh = None, | |
635 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
635 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
636 | server=None, folder=None, username=None, password=None, |
|
636 | server=None, folder=None, username=None, password=None, | |
637 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
637 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
638 | """ |
|
638 | """ | |
639 |
|
639 | |||
640 | Input: |
|
640 | Input: | |
641 | dataOut : |
|
641 | dataOut : | |
642 | id : |
|
642 | id : | |
643 | wintitle : |
|
643 | wintitle : | |
644 | channelList : |
|
644 | channelList : | |
645 | showProfile : |
|
645 | showProfile : | |
646 | xmin : None, |
|
646 | xmin : None, | |
647 | xmax : None, |
|
647 | xmax : None, | |
648 | ymin : None, |
|
648 | ymin : None, | |
649 | ymax : None, |
|
649 | ymax : None, | |
650 | zmin : None, |
|
650 | zmin : None, | |
651 | zmax : None |
|
651 | zmax : None | |
652 | """ |
|
652 | """ | |
653 |
|
653 | |||
654 | # if timerange is not None: |
|
654 | # if timerange is not None: | |
655 | # self.timerange = timerange |
|
655 | # self.timerange = timerange | |
656 | # |
|
656 | # | |
657 | # tmin = None |
|
657 | # tmin = None | |
658 | # tmax = None |
|
658 | # tmax = None | |
659 |
|
659 | |||
660 | x = dataOut.getTimeRange1(dataOut.paramInterval) |
|
660 | x = dataOut.getTimeRange1(dataOut.paramInterval) | |
661 | y = dataOut.heightList |
|
661 | y = dataOut.heightList | |
662 | z = dataOut.data_output.copy() |
|
662 | z = dataOut.data_output.copy() | |
663 | print ' ' |
|
|||
664 | print 'Xvel',z[0] |
|
|||
665 | print ' ' |
|
|||
666 | print 'Yvel',z[1] |
|
|||
667 | print ' ' |
|
|||
668 | nplots = z.shape[0] #Number of wind dimensions estimated |
|
663 | nplots = z.shape[0] #Number of wind dimensions estimated | |
669 | nplotsw = nplots |
|
664 | nplotsw = nplots | |
670 |
|
665 | |||
671 |
|
666 | |||
672 | #If there is a SNR function defined |
|
667 | #If there is a SNR function defined | |
673 | if dataOut.data_SNR is not None: |
|
668 | if dataOut.data_SNR is not None: | |
674 | nplots += 1 |
|
669 | nplots += 1 | |
675 | SNR = dataOut.data_SNR |
|
670 | SNR = dataOut.data_SNR | |
676 | SNRavg = numpy.average(SNR, axis=0) |
|
671 | SNRavg = numpy.average(SNR, axis=0) | |
677 |
|
672 | |||
678 | SNRdB = 10*numpy.log10(SNR) |
|
673 | SNRdB = 10*numpy.log10(SNR) | |
679 | SNRavgdB = 10*numpy.log10(SNRavg) |
|
674 | SNRavgdB = 10*numpy.log10(SNRavg) | |
680 |
|
675 | |||
681 | if SNRthresh == None: SNRthresh = -5.0 |
|
676 | if SNRthresh == None: SNRthresh = -5.0 | |
682 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] |
|
677 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] | |
683 |
|
678 | |||
684 | for i in range(nplotsw): |
|
679 | for i in range(nplotsw): | |
685 | z[i,ind] = numpy.nan |
|
680 | z[i,ind] = numpy.nan | |
686 |
|
681 | |||
687 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) |
|
682 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | |
688 | #thisDatetime = datetime.datetime.now() |
|
683 | #thisDatetime = datetime.datetime.now() | |
689 | title = wintitle + "Wind" |
|
684 | title = wintitle + "Wind" | |
690 | xlabel = "" |
|
685 | xlabel = "" | |
691 | ylabel = "Height (km)" |
|
686 | ylabel = "Height (km)" | |
692 | update_figfile = False |
|
687 | update_figfile = False | |
693 |
|
688 | |||
694 | if not self.isConfig: |
|
689 | if not self.isConfig: | |
695 |
|
690 | |||
696 | self.setup(id=id, |
|
691 | self.setup(id=id, | |
697 | nplots=nplots, |
|
692 | nplots=nplots, | |
698 | wintitle=wintitle, |
|
693 | wintitle=wintitle, | |
699 | showprofile=showprofile, |
|
694 | showprofile=showprofile, | |
700 | show=show) |
|
695 | show=show) | |
701 |
|
696 | |||
702 | if timerange is not None: |
|
697 | if timerange is not None: | |
703 | self.timerange = timerange |
|
698 | self.timerange = timerange | |
704 |
|
699 | |||
705 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
700 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
706 |
|
701 | |||
707 | if ymin == None: ymin = numpy.nanmin(y) |
|
702 | if ymin == None: ymin = numpy.nanmin(y) | |
708 | if ymax == None: ymax = numpy.nanmax(y) |
|
703 | if ymax == None: ymax = numpy.nanmax(y) | |
709 |
|
704 | |||
710 | if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:])) |
|
705 | if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:])) | |
711 | #if numpy.isnan(zmax): zmax = 50 |
|
706 | #if numpy.isnan(zmax): zmax = 50 | |
712 | if zmin == None: zmin = -zmax |
|
707 | if zmin == None: zmin = -zmax | |
713 |
|
708 | |||
714 | if nplotsw == 3: |
|
709 | if nplotsw == 3: | |
715 | if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:])) |
|
710 | if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:])) | |
716 | if zmin_ver == None: zmin_ver = -zmax_ver |
|
711 | if zmin_ver == None: zmin_ver = -zmax_ver | |
717 |
|
712 | |||
718 | if dataOut.data_SNR is not None: |
|
713 | if dataOut.data_SNR is not None: | |
719 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) |
|
714 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | |
720 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) |
|
715 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | |
721 |
|
716 | |||
722 |
|
717 | |||
723 | self.FTP_WEI = ftp_wei |
|
718 | self.FTP_WEI = ftp_wei | |
724 | self.EXP_CODE = exp_code |
|
719 | self.EXP_CODE = exp_code | |
725 | self.SUB_EXP_CODE = sub_exp_code |
|
720 | self.SUB_EXP_CODE = sub_exp_code | |
726 | self.PLOT_POS = plot_pos |
|
721 | self.PLOT_POS = plot_pos | |
727 |
|
722 | |||
728 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
723 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
729 | self.isConfig = True |
|
724 | self.isConfig = True | |
730 | self.figfile = figfile |
|
725 | self.figfile = figfile | |
731 | update_figfile = True |
|
726 | update_figfile = True | |
732 |
|
727 | |||
733 | self.setWinTitle(title) |
|
728 | self.setWinTitle(title) | |
734 |
|
729 | |||
735 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
730 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
736 | x[1] = self.xmax |
|
731 | x[1] = self.xmax | |
737 |
|
732 | |||
738 | strWind = ['Zonal', 'Meridional', 'Vertical'] |
|
733 | strWind = ['Zonal', 'Meridional', 'Vertical'] | |
739 | strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] |
|
734 | strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] | |
740 | zmaxVector = [zmax, zmax, zmax_ver] |
|
735 | zmaxVector = [zmax, zmax, zmax_ver] | |
741 | zminVector = [zmin, zmin, zmin_ver] |
|
736 | zminVector = [zmin, zmin, zmin_ver] | |
742 | windFactor = [1,1,100] |
|
737 | windFactor = [1,1,100] | |
743 |
|
738 | |||
744 | for i in range(nplotsw): |
|
739 | for i in range(nplotsw): | |
745 |
|
740 | |||
746 | title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
741 | title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
747 | axes = self.axesList[i*self.__nsubplots] |
|
742 | axes = self.axesList[i*self.__nsubplots] | |
748 |
|
743 | |||
749 | z1 = z[i,:].reshape((1,-1))*windFactor[i] |
|
744 | z1 = z[i,:].reshape((1,-1))*windFactor[i] | |
750 | #z1=numpy.ma.masked_where(z1==0.,z1) |
|
745 | #z1=numpy.ma.masked_where(z1==0.,z1) | |
751 |
|
746 | |||
752 | axes.pcolorbuffer(x, y, z1, |
|
747 | axes.pcolorbuffer(x, y, z1, | |
753 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], |
|
748 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], | |
754 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
749 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
755 | ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="seismic" ) |
|
750 | ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="seismic" ) | |
756 |
|
751 | |||
757 | if dataOut.data_SNR is not None: |
|
752 | if dataOut.data_SNR is not None: | |
758 | i += 1 |
|
753 | i += 1 | |
759 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
754 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
760 | axes = self.axesList[i*self.__nsubplots] |
|
755 | axes = self.axesList[i*self.__nsubplots] | |
761 | SNRavgdB = SNRavgdB.reshape((1,-1)) |
|
756 | SNRavgdB = SNRavgdB.reshape((1,-1)) | |
762 | axes.pcolorbuffer(x, y, SNRavgdB, |
|
757 | axes.pcolorbuffer(x, y, SNRavgdB, | |
763 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
758 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
764 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
759 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
765 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") |
|
760 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") | |
766 |
|
761 | |||
767 | self.draw() |
|
762 | self.draw() | |
768 |
|
763 | |||
769 | self.save(figpath=figpath, |
|
764 | self.save(figpath=figpath, | |
770 | figfile=figfile, |
|
765 | figfile=figfile, | |
771 | save=save, |
|
766 | save=save, | |
772 | ftp=ftp, |
|
767 | ftp=ftp, | |
773 | wr_period=wr_period, |
|
768 | wr_period=wr_period, | |
774 | thisDatetime=thisDatetime, |
|
769 | thisDatetime=thisDatetime, | |
775 | update_figfile=update_figfile) |
|
770 | update_figfile=update_figfile) | |
776 |
|
771 | |||
777 | if dataOut.ltctime + dataOut.paramInterval >= self.xmax: |
|
772 | if dataOut.ltctime + dataOut.paramInterval >= self.xmax: | |
778 | self.counter_imagwr = wr_period |
|
773 | self.counter_imagwr = wr_period | |
779 | self.isConfig = False |
|
774 | self.isConfig = False | |
780 | update_figfile = True |
|
775 | update_figfile = True | |
781 |
|
776 | |||
782 |
|
777 | |||
783 | class ParametersPlot(Figure): |
|
778 | class ParametersPlot(Figure): | |
784 |
|
779 | |||
785 | __isConfig = None |
|
780 | __isConfig = None | |
786 | __nsubplots = None |
|
781 | __nsubplots = None | |
787 |
|
782 | |||
788 | WIDTHPROF = None |
|
783 | WIDTHPROF = None | |
789 | HEIGHTPROF = None |
|
784 | HEIGHTPROF = None | |
790 | PREFIX = 'param' |
|
785 | PREFIX = 'param' | |
791 |
|
786 | |||
792 | nplots = None |
|
787 | nplots = None | |
793 | nchan = None |
|
788 | nchan = None | |
794 |
|
789 | |||
795 | def __init__(self, **kwargs): |
|
790 | def __init__(self, **kwargs): | |
796 | Figure.__init__(self, **kwargs) |
|
791 | Figure.__init__(self, **kwargs) | |
797 | self.timerange = None |
|
792 | self.timerange = None | |
798 | self.isConfig = False |
|
793 | self.isConfig = False | |
799 | self.__nsubplots = 1 |
|
794 | self.__nsubplots = 1 | |
800 |
|
795 | |||
801 | self.WIDTH = 800 |
|
796 | self.WIDTH = 800 | |
802 | self.HEIGHT = 180 |
|
797 | self.HEIGHT = 180 | |
803 | self.WIDTHPROF = 120 |
|
798 | self.WIDTHPROF = 120 | |
804 | self.HEIGHTPROF = 0 |
|
799 | self.HEIGHTPROF = 0 | |
805 | self.counter_imagwr = 0 |
|
800 | self.counter_imagwr = 0 | |
806 |
|
801 | |||
807 | self.PLOT_CODE = RTI_CODE |
|
802 | self.PLOT_CODE = RTI_CODE | |
808 |
|
803 | |||
809 | self.FTP_WEI = None |
|
804 | self.FTP_WEI = None | |
810 | self.EXP_CODE = None |
|
805 | self.EXP_CODE = None | |
811 | self.SUB_EXP_CODE = None |
|
806 | self.SUB_EXP_CODE = None | |
812 | self.PLOT_POS = None |
|
807 | self.PLOT_POS = None | |
813 | self.tmin = None |
|
808 | self.tmin = None | |
814 | self.tmax = None |
|
809 | self.tmax = None | |
815 |
|
810 | |||
816 | self.xmin = None |
|
811 | self.xmin = None | |
817 | self.xmax = None |
|
812 | self.xmax = None | |
818 |
|
813 | |||
819 | self.figfile = None |
|
814 | self.figfile = None | |
820 |
|
815 | |||
821 | def getSubplots(self): |
|
816 | def getSubplots(self): | |
822 |
|
817 | |||
823 | ncol = 1 |
|
818 | ncol = 1 | |
824 | nrow = self.nplots |
|
819 | nrow = self.nplots | |
825 |
|
820 | |||
826 | return nrow, ncol |
|
821 | return nrow, ncol | |
827 |
|
822 | |||
828 | def setup(self, id, nplots, wintitle, show=True): |
|
823 | def setup(self, id, nplots, wintitle, show=True): | |
829 |
|
824 | |||
830 | self.nplots = nplots |
|
825 | self.nplots = nplots | |
831 |
|
826 | |||
832 | ncolspan = 1 |
|
827 | ncolspan = 1 | |
833 | colspan = 1 |
|
828 | colspan = 1 | |
834 |
|
829 | |||
835 | self.createFigure(id = id, |
|
830 | self.createFigure(id = id, | |
836 | wintitle = wintitle, |
|
831 | wintitle = wintitle, | |
837 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
832 | widthplot = self.WIDTH + self.WIDTHPROF, | |
838 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
833 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
839 | show=show) |
|
834 | show=show) | |
840 |
|
835 | |||
841 | nrow, ncol = self.getSubplots() |
|
836 | nrow, ncol = self.getSubplots() | |
842 |
|
837 | |||
843 | counter = 0 |
|
838 | counter = 0 | |
844 | for y in range(nrow): |
|
839 | for y in range(nrow): | |
845 | for x in range(ncol): |
|
840 | for x in range(ncol): | |
846 |
|
841 | |||
847 | if counter >= self.nplots: |
|
842 | if counter >= self.nplots: | |
848 | break |
|
843 | break | |
849 |
|
844 | |||
850 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
845 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
851 |
|
846 | |||
852 | counter += 1 |
|
847 | counter += 1 | |
853 |
|
848 | |||
854 | def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap="jet", |
|
849 | def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap="jet", | |
855 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None, |
|
850 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None, | |
856 | showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None, |
|
851 | showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None, | |
857 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
852 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
858 | server=None, folder=None, username=None, password=None, |
|
853 | server=None, folder=None, username=None, password=None, | |
859 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, HEIGHT=None): |
|
854 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, HEIGHT=None): | |
860 | """ |
|
855 | """ | |
861 |
|
856 | |||
862 | Input: |
|
857 | Input: | |
863 | dataOut : |
|
858 | dataOut : | |
864 | id : |
|
859 | id : | |
865 | wintitle : |
|
860 | wintitle : | |
866 | channelList : |
|
861 | channelList : | |
867 | showProfile : |
|
862 | showProfile : | |
868 | xmin : None, |
|
863 | xmin : None, | |
869 | xmax : None, |
|
864 | xmax : None, | |
870 | ymin : None, |
|
865 | ymin : None, | |
871 | ymax : None, |
|
866 | ymax : None, | |
872 | zmin : None, |
|
867 | zmin : None, | |
873 | zmax : None |
|
868 | zmax : None | |
874 | """ |
|
869 | """ | |
875 |
|
870 | |||
876 | if HEIGHT is not None: |
|
871 | if HEIGHT is not None: | |
877 | self.HEIGHT = HEIGHT |
|
872 | self.HEIGHT = HEIGHT | |
878 |
|
873 | |||
879 |
|
874 | |||
880 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
875 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
881 | return |
|
876 | return | |
882 |
|
877 | |||
883 | if channelList == None: |
|
878 | if channelList == None: | |
884 | channelIndexList = range(dataOut.data_param.shape[0]) |
|
879 | channelIndexList = range(dataOut.data_param.shape[0]) | |
885 | else: |
|
880 | else: | |
886 | channelIndexList = [] |
|
881 | channelIndexList = [] | |
887 | for channel in channelList: |
|
882 | for channel in channelList: | |
888 | if channel not in dataOut.channelList: |
|
883 | if channel not in dataOut.channelList: | |
889 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
884 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
890 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
885 | channelIndexList.append(dataOut.channelList.index(channel)) | |
891 |
|
886 | |||
892 | x = dataOut.getTimeRange1(dataOut.paramInterval) |
|
887 | x = dataOut.getTimeRange1(dataOut.paramInterval) | |
893 | y = dataOut.getHeiRange() |
|
888 | y = dataOut.getHeiRange() | |
894 |
|
889 | |||
895 | if dataOut.data_param.ndim == 3: |
|
890 | if dataOut.data_param.ndim == 3: | |
896 | z = dataOut.data_param[channelIndexList,paramIndex,:] |
|
891 | z = dataOut.data_param[channelIndexList,paramIndex,:] | |
897 | else: |
|
892 | else: | |
898 | z = dataOut.data_param[channelIndexList,:] |
|
893 | z = dataOut.data_param[channelIndexList,:] | |
899 |
|
894 | |||
900 | if showSNR: |
|
895 | if showSNR: | |
901 | #SNR data |
|
896 | #SNR data | |
902 | SNRarray = dataOut.data_SNR[channelIndexList,:] |
|
897 | SNRarray = dataOut.data_SNR[channelIndexList,:] | |
903 | SNRdB = 10*numpy.log10(SNRarray) |
|
898 | SNRdB = 10*numpy.log10(SNRarray) | |
904 | ind = numpy.where(SNRdB < SNRthresh) |
|
899 | ind = numpy.where(SNRdB < SNRthresh) | |
905 | z[ind] = numpy.nan |
|
900 | z[ind] = numpy.nan | |
906 |
|
901 | |||
907 | thisDatetime = dataOut.datatime |
|
902 | thisDatetime = dataOut.datatime | |
908 | # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
903 | # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
909 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
904 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
910 | xlabel = "" |
|
905 | xlabel = "" | |
911 | ylabel = "Range (Km)" |
|
906 | ylabel = "Range (Km)" | |
912 |
|
907 | |||
913 | update_figfile = False |
|
908 | update_figfile = False | |
914 |
|
909 | |||
915 | if not self.isConfig: |
|
910 | if not self.isConfig: | |
916 |
|
911 | |||
917 | nchan = len(channelIndexList) |
|
912 | nchan = len(channelIndexList) | |
918 | self.nchan = nchan |
|
913 | self.nchan = nchan | |
919 | self.plotFact = 1 |
|
914 | self.plotFact = 1 | |
920 | nplots = nchan |
|
915 | nplots = nchan | |
921 |
|
916 | |||
922 | if showSNR: |
|
917 | if showSNR: | |
923 | nplots = nchan*2 |
|
918 | nplots = nchan*2 | |
924 | self.plotFact = 2 |
|
919 | self.plotFact = 2 | |
925 | if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) |
|
920 | if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) | |
926 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) |
|
921 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) | |
927 |
|
922 | |||
928 | self.setup(id=id, |
|
923 | self.setup(id=id, | |
929 | nplots=nplots, |
|
924 | nplots=nplots, | |
930 | wintitle=wintitle, |
|
925 | wintitle=wintitle, | |
931 | show=show) |
|
926 | show=show) | |
932 |
|
927 | |||
933 | if timerange != None: |
|
928 | if timerange != None: | |
934 | self.timerange = timerange |
|
929 | self.timerange = timerange | |
935 |
|
930 | |||
936 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
931 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
937 |
|
932 | |||
938 | if ymin == None: ymin = numpy.nanmin(y) |
|
933 | if ymin == None: ymin = numpy.nanmin(y) | |
939 | if ymax == None: ymax = numpy.nanmax(y) |
|
934 | if ymax == None: ymax = numpy.nanmax(y) | |
940 | if zmin == None: zmin = numpy.nanmin(z) |
|
935 | if zmin == None: zmin = numpy.nanmin(z) | |
941 | if zmax == None: zmax = numpy.nanmax(z) |
|
936 | if zmax == None: zmax = numpy.nanmax(z) | |
942 |
|
937 | |||
943 | self.FTP_WEI = ftp_wei |
|
938 | self.FTP_WEI = ftp_wei | |
944 | self.EXP_CODE = exp_code |
|
939 | self.EXP_CODE = exp_code | |
945 | self.SUB_EXP_CODE = sub_exp_code |
|
940 | self.SUB_EXP_CODE = sub_exp_code | |
946 | self.PLOT_POS = plot_pos |
|
941 | self.PLOT_POS = plot_pos | |
947 |
|
942 | |||
948 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
943 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
949 | self.isConfig = True |
|
944 | self.isConfig = True | |
950 | self.figfile = figfile |
|
945 | self.figfile = figfile | |
951 | update_figfile = True |
|
946 | update_figfile = True | |
952 |
|
947 | |||
953 | self.setWinTitle(title) |
|
948 | self.setWinTitle(title) | |
954 |
|
949 | |||
955 | for i in range(self.nchan): |
|
950 | for i in range(self.nchan): | |
956 | index = channelIndexList[i] |
|
951 | index = channelIndexList[i] | |
957 | title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
952 | title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
958 | axes = self.axesList[i*self.plotFact] |
|
953 | axes = self.axesList[i*self.plotFact] | |
959 | z1 = z[i,:].reshape((1,-1)) |
|
954 | z1 = z[i,:].reshape((1,-1)) | |
960 | axes.pcolorbuffer(x, y, z1, |
|
955 | axes.pcolorbuffer(x, y, z1, | |
961 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
956 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
962 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
957 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
963 | ticksize=9, cblabel='', cbsize="1%",colormap=colormap) |
|
958 | ticksize=9, cblabel='', cbsize="1%",colormap=colormap) | |
964 |
|
959 | |||
965 | if showSNR: |
|
960 | if showSNR: | |
966 | title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
961 | title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
967 | axes = self.axesList[i*self.plotFact + 1] |
|
962 | axes = self.axesList[i*self.plotFact + 1] | |
968 | SNRdB1 = SNRdB[i,:].reshape((1,-1)) |
|
963 | SNRdB1 = SNRdB[i,:].reshape((1,-1)) | |
969 | axes.pcolorbuffer(x, y, SNRdB1, |
|
964 | axes.pcolorbuffer(x, y, SNRdB1, | |
970 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
965 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
971 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
966 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
972 | ticksize=9, cblabel='', cbsize="1%",colormap='jet') |
|
967 | ticksize=9, cblabel='', cbsize="1%",colormap='jet') | |
973 |
|
968 | |||
974 |
|
969 | |||
975 | self.draw() |
|
970 | self.draw() | |
976 |
|
971 | |||
977 | if dataOut.ltctime >= self.xmax: |
|
972 | if dataOut.ltctime >= self.xmax: | |
978 | self.counter_imagwr = wr_period |
|
973 | self.counter_imagwr = wr_period | |
979 | self.isConfig = False |
|
974 | self.isConfig = False | |
980 | update_figfile = True |
|
975 | update_figfile = True | |
981 |
|
976 | |||
982 | self.save(figpath=figpath, |
|
977 | self.save(figpath=figpath, | |
983 | figfile=figfile, |
|
978 | figfile=figfile, | |
984 | save=save, |
|
979 | save=save, | |
985 | ftp=ftp, |
|
980 | ftp=ftp, | |
986 | wr_period=wr_period, |
|
981 | wr_period=wr_period, | |
987 | thisDatetime=thisDatetime, |
|
982 | thisDatetime=thisDatetime, | |
988 | update_figfile=update_figfile) |
|
983 | update_figfile=update_figfile) | |
989 |
|
984 | |||
990 |
|
985 | |||
991 |
|
986 | |||
992 | class Parameters1Plot(Figure): |
|
987 | class Parameters1Plot(Figure): | |
993 |
|
988 | |||
994 | __isConfig = None |
|
989 | __isConfig = None | |
995 | __nsubplots = None |
|
990 | __nsubplots = None | |
996 |
|
991 | |||
997 | WIDTHPROF = None |
|
992 | WIDTHPROF = None | |
998 | HEIGHTPROF = None |
|
993 | HEIGHTPROF = None | |
999 | PREFIX = 'prm' |
|
994 | PREFIX = 'prm' | |
1000 |
|
995 | |||
1001 | def __init__(self, **kwargs): |
|
996 | def __init__(self, **kwargs): | |
1002 | Figure.__init__(self, **kwargs) |
|
997 | Figure.__init__(self, **kwargs) | |
1003 | self.timerange = 2*60*60 |
|
998 | self.timerange = 2*60*60 | |
1004 | self.isConfig = False |
|
999 | self.isConfig = False | |
1005 | self.__nsubplots = 1 |
|
1000 | self.__nsubplots = 1 | |
1006 |
|
1001 | |||
1007 | self.WIDTH = 800 |
|
1002 | self.WIDTH = 800 | |
1008 | self.HEIGHT = 180 |
|
1003 | self.HEIGHT = 180 | |
1009 | self.WIDTHPROF = 120 |
|
1004 | self.WIDTHPROF = 120 | |
1010 | self.HEIGHTPROF = 0 |
|
1005 | self.HEIGHTPROF = 0 | |
1011 | self.counter_imagwr = 0 |
|
1006 | self.counter_imagwr = 0 | |
1012 |
|
1007 | |||
1013 | self.PLOT_CODE = PARMS_CODE |
|
1008 | self.PLOT_CODE = PARMS_CODE | |
1014 |
|
1009 | |||
1015 | self.FTP_WEI = None |
|
1010 | self.FTP_WEI = None | |
1016 | self.EXP_CODE = None |
|
1011 | self.EXP_CODE = None | |
1017 | self.SUB_EXP_CODE = None |
|
1012 | self.SUB_EXP_CODE = None | |
1018 | self.PLOT_POS = None |
|
1013 | self.PLOT_POS = None | |
1019 | self.tmin = None |
|
1014 | self.tmin = None | |
1020 | self.tmax = None |
|
1015 | self.tmax = None | |
1021 |
|
1016 | |||
1022 | self.xmin = None |
|
1017 | self.xmin = None | |
1023 | self.xmax = None |
|
1018 | self.xmax = None | |
1024 |
|
1019 | |||
1025 | self.figfile = None |
|
1020 | self.figfile = None | |
1026 |
|
1021 | |||
1027 | def getSubplots(self): |
|
1022 | def getSubplots(self): | |
1028 |
|
1023 | |||
1029 | ncol = 1 |
|
1024 | ncol = 1 | |
1030 | nrow = self.nplots |
|
1025 | nrow = self.nplots | |
1031 |
|
1026 | |||
1032 | return nrow, ncol |
|
1027 | return nrow, ncol | |
1033 |
|
1028 | |||
1034 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1029 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1035 |
|
1030 | |||
1036 | self.__showprofile = showprofile |
|
1031 | self.__showprofile = showprofile | |
1037 | self.nplots = nplots |
|
1032 | self.nplots = nplots | |
1038 |
|
1033 | |||
1039 | ncolspan = 1 |
|
1034 | ncolspan = 1 | |
1040 | colspan = 1 |
|
1035 | colspan = 1 | |
1041 |
|
1036 | |||
1042 | self.createFigure(id = id, |
|
1037 | self.createFigure(id = id, | |
1043 | wintitle = wintitle, |
|
1038 | wintitle = wintitle, | |
1044 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1039 | widthplot = self.WIDTH + self.WIDTHPROF, | |
1045 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1040 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
1046 | show=show) |
|
1041 | show=show) | |
1047 |
|
1042 | |||
1048 | nrow, ncol = self.getSubplots() |
|
1043 | nrow, ncol = self.getSubplots() | |
1049 |
|
1044 | |||
1050 | counter = 0 |
|
1045 | counter = 0 | |
1051 | for y in range(nrow): |
|
1046 | for y in range(nrow): | |
1052 | for x in range(ncol): |
|
1047 | for x in range(ncol): | |
1053 |
|
1048 | |||
1054 | if counter >= self.nplots: |
|
1049 | if counter >= self.nplots: | |
1055 | break |
|
1050 | break | |
1056 |
|
1051 | |||
1057 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1052 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
1058 |
|
1053 | |||
1059 | if showprofile: |
|
1054 | if showprofile: | |
1060 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
1055 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
1061 |
|
1056 | |||
1062 | counter += 1 |
|
1057 | counter += 1 | |
1063 |
|
1058 | |||
1064 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, |
|
1059 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | |
1065 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None, |
|
1060 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None, | |
1066 | parameterIndex = None, onlyPositive = False, |
|
1061 | parameterIndex = None, onlyPositive = False, | |
1067 | SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False, |
|
1062 | SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False, | |
1068 | DOP = True, |
|
1063 | DOP = True, | |
1069 | zlabel = "", parameterName = "", parameterObject = "data_param", |
|
1064 | zlabel = "", parameterName = "", parameterObject = "data_param", | |
1070 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
1065 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
1071 | server=None, folder=None, username=None, password=None, |
|
1066 | server=None, folder=None, username=None, password=None, | |
1072 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1067 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1073 | #print inspect.getargspec(self.run).args |
|
1068 | #print inspect.getargspec(self.run).args | |
1074 | """ |
|
1069 | """ | |
1075 |
|
1070 | |||
1076 | Input: |
|
1071 | Input: | |
1077 | dataOut : |
|
1072 | dataOut : | |
1078 | id : |
|
1073 | id : | |
1079 | wintitle : |
|
1074 | wintitle : | |
1080 | channelList : |
|
1075 | channelList : | |
1081 | showProfile : |
|
1076 | showProfile : | |
1082 | xmin : None, |
|
1077 | xmin : None, | |
1083 | xmax : None, |
|
1078 | xmax : None, | |
1084 | ymin : None, |
|
1079 | ymin : None, | |
1085 | ymax : None, |
|
1080 | ymax : None, | |
1086 | zmin : None, |
|
1081 | zmin : None, | |
1087 | zmax : None |
|
1082 | zmax : None | |
1088 | """ |
|
1083 | """ | |
1089 |
|
1084 | |||
1090 | data_param = getattr(dataOut, parameterObject) |
|
1085 | data_param = getattr(dataOut, parameterObject) | |
1091 |
|
1086 | |||
1092 | if channelList == None: |
|
1087 | if channelList == None: | |
1093 | channelIndexList = numpy.arange(data_param.shape[0]) |
|
1088 | channelIndexList = numpy.arange(data_param.shape[0]) | |
1094 | else: |
|
1089 | else: | |
1095 | channelIndexList = numpy.array(channelList) |
|
1090 | channelIndexList = numpy.array(channelList) | |
1096 |
|
1091 | |||
1097 | nchan = len(channelIndexList) #Number of channels being plotted |
|
1092 | nchan = len(channelIndexList) #Number of channels being plotted | |
1098 |
|
1093 | |||
1099 | if nchan < 1: |
|
1094 | if nchan < 1: | |
1100 | return |
|
1095 | return | |
1101 |
|
1096 | |||
1102 | nGraphsByChannel = 0 |
|
1097 | nGraphsByChannel = 0 | |
1103 |
|
1098 | |||
1104 | if SNR: |
|
1099 | if SNR: | |
1105 | nGraphsByChannel += 1 |
|
1100 | nGraphsByChannel += 1 | |
1106 | if DOP: |
|
1101 | if DOP: | |
1107 | nGraphsByChannel += 1 |
|
1102 | nGraphsByChannel += 1 | |
1108 |
|
1103 | |||
1109 | if nGraphsByChannel < 1: |
|
1104 | if nGraphsByChannel < 1: | |
1110 | return |
|
1105 | return | |
1111 |
|
1106 | |||
1112 | nplots = nGraphsByChannel*nchan |
|
1107 | nplots = nGraphsByChannel*nchan | |
1113 |
|
1108 | |||
1114 | if timerange is not None: |
|
1109 | if timerange is not None: | |
1115 | self.timerange = timerange |
|
1110 | self.timerange = timerange | |
1116 |
|
1111 | |||
1117 | #tmin = None |
|
1112 | #tmin = None | |
1118 | #tmax = None |
|
1113 | #tmax = None | |
1119 | if parameterIndex == None: |
|
1114 | if parameterIndex == None: | |
1120 | parameterIndex = 1 |
|
1115 | parameterIndex = 1 | |
1121 |
|
1116 | |||
1122 | x = dataOut.getTimeRange1(dataOut.paramInterval) |
|
1117 | x = dataOut.getTimeRange1(dataOut.paramInterval) | |
1123 | y = dataOut.heightList |
|
1118 | y = dataOut.heightList | |
1124 | z = data_param[channelIndexList,parameterIndex,:].copy() |
|
1119 | z = data_param[channelIndexList,parameterIndex,:].copy() | |
1125 |
|
1120 | |||
1126 | zRange = dataOut.abscissaList |
|
1121 | zRange = dataOut.abscissaList | |
1127 | # nChannels = z.shape[0] #Number of wind dimensions estimated |
|
1122 | # nChannels = z.shape[0] #Number of wind dimensions estimated | |
1128 | # thisDatetime = dataOut.datatime |
|
1123 | # thisDatetime = dataOut.datatime | |
1129 |
|
1124 | |||
1130 | if dataOut.data_SNR is not None: |
|
1125 | if dataOut.data_SNR is not None: | |
1131 | SNRarray = dataOut.data_SNR[channelIndexList,:] |
|
1126 | SNRarray = dataOut.data_SNR[channelIndexList,:] | |
1132 | SNRdB = 10*numpy.log10(SNRarray) |
|
1127 | SNRdB = 10*numpy.log10(SNRarray) | |
1133 | # SNRavgdB = 10*numpy.log10(SNRavg) |
|
1128 | # SNRavgdB = 10*numpy.log10(SNRavg) | |
1134 | ind = numpy.where(SNRdB < 10**(SNRthresh/10)) |
|
1129 | ind = numpy.where(SNRdB < 10**(SNRthresh/10)) | |
1135 | z[ind] = numpy.nan |
|
1130 | z[ind] = numpy.nan | |
1136 |
|
1131 | |||
1137 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
1132 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
1138 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1133 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1139 | xlabel = "" |
|
1134 | xlabel = "" | |
1140 | ylabel = "Range (Km)" |
|
1135 | ylabel = "Range (Km)" | |
1141 |
|
1136 | |||
1142 | if (SNR and not onlySNR): nplots = 2*nplots |
|
1137 | if (SNR and not onlySNR): nplots = 2*nplots | |
1143 |
|
1138 | |||
1144 | if onlyPositive: |
|
1139 | if onlyPositive: | |
1145 | colormap = "jet" |
|
1140 | colormap = "jet" | |
1146 | zmin = 0 |
|
1141 | zmin = 0 | |
1147 | else: colormap = "RdBu_r" |
|
1142 | else: colormap = "RdBu_r" | |
1148 |
|
1143 | |||
1149 | if not self.isConfig: |
|
1144 | if not self.isConfig: | |
1150 |
|
1145 | |||
1151 | self.setup(id=id, |
|
1146 | self.setup(id=id, | |
1152 | nplots=nplots, |
|
1147 | nplots=nplots, | |
1153 | wintitle=wintitle, |
|
1148 | wintitle=wintitle, | |
1154 | showprofile=showprofile, |
|
1149 | showprofile=showprofile, | |
1155 | show=show) |
|
1150 | show=show) | |
1156 |
|
1151 | |||
1157 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1152 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1158 |
|
1153 | |||
1159 | if ymin == None: ymin = numpy.nanmin(y) |
|
1154 | if ymin == None: ymin = numpy.nanmin(y) | |
1160 | if ymax == None: ymax = numpy.nanmax(y) |
|
1155 | if ymax == None: ymax = numpy.nanmax(y) | |
1161 | if zmin == None: zmin = numpy.nanmin(zRange) |
|
1156 | if zmin == None: zmin = numpy.nanmin(zRange) | |
1162 | if zmax == None: zmax = numpy.nanmax(zRange) |
|
1157 | if zmax == None: zmax = numpy.nanmax(zRange) | |
1163 |
|
1158 | |||
1164 | if SNR: |
|
1159 | if SNR: | |
1165 | if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) |
|
1160 | if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) | |
1166 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) |
|
1161 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) | |
1167 |
|
1162 | |||
1168 | self.FTP_WEI = ftp_wei |
|
1163 | self.FTP_WEI = ftp_wei | |
1169 | self.EXP_CODE = exp_code |
|
1164 | self.EXP_CODE = exp_code | |
1170 | self.SUB_EXP_CODE = sub_exp_code |
|
1165 | self.SUB_EXP_CODE = sub_exp_code | |
1171 | self.PLOT_POS = plot_pos |
|
1166 | self.PLOT_POS = plot_pos | |
1172 |
|
1167 | |||
1173 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1168 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1174 | self.isConfig = True |
|
1169 | self.isConfig = True | |
1175 | self.figfile = figfile |
|
1170 | self.figfile = figfile | |
1176 |
|
1171 | |||
1177 | self.setWinTitle(title) |
|
1172 | self.setWinTitle(title) | |
1178 |
|
1173 | |||
1179 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
1174 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
1180 | x[1] = self.xmax |
|
1175 | x[1] = self.xmax | |
1181 |
|
1176 | |||
1182 | for i in range(nchan): |
|
1177 | for i in range(nchan): | |
1183 |
|
1178 | |||
1184 | if (SNR and not onlySNR): j = 2*i |
|
1179 | if (SNR and not onlySNR): j = 2*i | |
1185 | else: j = i |
|
1180 | else: j = i | |
1186 |
|
1181 | |||
1187 | j = nGraphsByChannel*i |
|
1182 | j = nGraphsByChannel*i | |
1188 |
|
1183 | |||
1189 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
1184 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
1190 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
1185 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
1191 |
|
1186 | |||
1192 | if not onlySNR: |
|
1187 | if not onlySNR: | |
1193 | axes = self.axesList[j*self.__nsubplots] |
|
1188 | axes = self.axesList[j*self.__nsubplots] | |
1194 | z1 = z[i,:].reshape((1,-1)) |
|
1189 | z1 = z[i,:].reshape((1,-1)) | |
1195 | axes.pcolorbuffer(x, y, z1, |
|
1190 | axes.pcolorbuffer(x, y, z1, | |
1196 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
1191 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
1197 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, |
|
1192 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, | |
1198 | ticksize=9, cblabel=zlabel, cbsize="1%") |
|
1193 | ticksize=9, cblabel=zlabel, cbsize="1%") | |
1199 |
|
1194 | |||
1200 | if DOP: |
|
1195 | if DOP: | |
1201 | title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1196 | title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1202 |
|
1197 | |||
1203 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
1198 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
1204 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
1199 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
1205 | axes = self.axesList[j] |
|
1200 | axes = self.axesList[j] | |
1206 | z1 = z[i,:].reshape((1,-1)) |
|
1201 | z1 = z[i,:].reshape((1,-1)) | |
1207 | axes.pcolorbuffer(x, y, z1, |
|
1202 | axes.pcolorbuffer(x, y, z1, | |
1208 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
1203 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
1209 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, |
|
1204 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, | |
1210 | ticksize=9, cblabel=zlabel, cbsize="1%") |
|
1205 | ticksize=9, cblabel=zlabel, cbsize="1%") | |
1211 |
|
1206 | |||
1212 | if SNR: |
|
1207 | if SNR: | |
1213 | title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1208 | title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1214 | axes = self.axesList[(j)*self.__nsubplots] |
|
1209 | axes = self.axesList[(j)*self.__nsubplots] | |
1215 | if not onlySNR: |
|
1210 | if not onlySNR: | |
1216 | axes = self.axesList[(j + 1)*self.__nsubplots] |
|
1211 | axes = self.axesList[(j + 1)*self.__nsubplots] | |
1217 |
|
1212 | |||
1218 | axes = self.axesList[(j + nGraphsByChannel-1)] |
|
1213 | axes = self.axesList[(j + nGraphsByChannel-1)] | |
1219 |
|
1214 | |||
1220 | z1 = SNRdB[i,:].reshape((1,-1)) |
|
1215 | z1 = SNRdB[i,:].reshape((1,-1)) | |
1221 | axes.pcolorbuffer(x, y, z1, |
|
1216 | axes.pcolorbuffer(x, y, z1, | |
1222 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
1217 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
1223 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet", |
|
1218 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet", | |
1224 | ticksize=9, cblabel=zlabel, cbsize="1%") |
|
1219 | ticksize=9, cblabel=zlabel, cbsize="1%") | |
1225 |
|
1220 | |||
1226 |
|
1221 | |||
1227 |
|
1222 | |||
1228 | self.draw() |
|
1223 | self.draw() | |
1229 |
|
1224 | |||
1230 | if x[1] >= self.axesList[0].xmax: |
|
1225 | if x[1] >= self.axesList[0].xmax: | |
1231 | self.counter_imagwr = wr_period |
|
1226 | self.counter_imagwr = wr_period | |
1232 | self.isConfig = False |
|
1227 | self.isConfig = False | |
1233 | self.figfile = None |
|
1228 | self.figfile = None | |
1234 |
|
1229 | |||
1235 | self.save(figpath=figpath, |
|
1230 | self.save(figpath=figpath, | |
1236 | figfile=figfile, |
|
1231 | figfile=figfile, | |
1237 | save=save, |
|
1232 | save=save, | |
1238 | ftp=ftp, |
|
1233 | ftp=ftp, | |
1239 | wr_period=wr_period, |
|
1234 | wr_period=wr_period, | |
1240 | thisDatetime=thisDatetime, |
|
1235 | thisDatetime=thisDatetime, | |
1241 | update_figfile=False) |
|
1236 | update_figfile=False) | |
1242 |
|
1237 | |||
1243 | class SpectralFittingPlot(Figure): |
|
1238 | class SpectralFittingPlot(Figure): | |
1244 |
|
1239 | |||
1245 | __isConfig = None |
|
1240 | __isConfig = None | |
1246 | __nsubplots = None |
|
1241 | __nsubplots = None | |
1247 |
|
1242 | |||
1248 | WIDTHPROF = None |
|
1243 | WIDTHPROF = None | |
1249 | HEIGHTPROF = None |
|
1244 | HEIGHTPROF = None | |
1250 | PREFIX = 'prm' |
|
1245 | PREFIX = 'prm' | |
1251 |
|
1246 | |||
1252 |
|
1247 | |||
1253 | N = None |
|
1248 | N = None | |
1254 | ippSeconds = None |
|
1249 | ippSeconds = None | |
1255 |
|
1250 | |||
1256 | def __init__(self, **kwargs): |
|
1251 | def __init__(self, **kwargs): | |
1257 | Figure.__init__(self, **kwargs) |
|
1252 | Figure.__init__(self, **kwargs) | |
1258 | self.isConfig = False |
|
1253 | self.isConfig = False | |
1259 | self.__nsubplots = 1 |
|
1254 | self.__nsubplots = 1 | |
1260 |
|
1255 | |||
1261 | self.PLOT_CODE = SPECFIT_CODE |
|
1256 | self.PLOT_CODE = SPECFIT_CODE | |
1262 |
|
1257 | |||
1263 | self.WIDTH = 450 |
|
1258 | self.WIDTH = 450 | |
1264 | self.HEIGHT = 250 |
|
1259 | self.HEIGHT = 250 | |
1265 | self.WIDTHPROF = 0 |
|
1260 | self.WIDTHPROF = 0 | |
1266 | self.HEIGHTPROF = 0 |
|
1261 | self.HEIGHTPROF = 0 | |
1267 |
|
1262 | |||
1268 | def getSubplots(self): |
|
1263 | def getSubplots(self): | |
1269 |
|
1264 | |||
1270 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
1265 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
1271 | nrow = int(self.nplots*1./ncol + 0.9) |
|
1266 | nrow = int(self.nplots*1./ncol + 0.9) | |
1272 |
|
1267 | |||
1273 | return nrow, ncol |
|
1268 | return nrow, ncol | |
1274 |
|
1269 | |||
1275 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): |
|
1270 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): | |
1276 |
|
1271 | |||
1277 | showprofile = False |
|
1272 | showprofile = False | |
1278 | self.__showprofile = showprofile |
|
1273 | self.__showprofile = showprofile | |
1279 | self.nplots = nplots |
|
1274 | self.nplots = nplots | |
1280 |
|
1275 | |||
1281 | ncolspan = 5 |
|
1276 | ncolspan = 5 | |
1282 | colspan = 4 |
|
1277 | colspan = 4 | |
1283 | if showprofile: |
|
1278 | if showprofile: | |
1284 | ncolspan = 5 |
|
1279 | ncolspan = 5 | |
1285 | colspan = 4 |
|
1280 | colspan = 4 | |
1286 | self.__nsubplots = 2 |
|
1281 | self.__nsubplots = 2 | |
1287 |
|
1282 | |||
1288 | self.createFigure(id = id, |
|
1283 | self.createFigure(id = id, | |
1289 | wintitle = wintitle, |
|
1284 | wintitle = wintitle, | |
1290 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1285 | widthplot = self.WIDTH + self.WIDTHPROF, | |
1291 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1286 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
1292 | show=show) |
|
1287 | show=show) | |
1293 |
|
1288 | |||
1294 | nrow, ncol = self.getSubplots() |
|
1289 | nrow, ncol = self.getSubplots() | |
1295 |
|
1290 | |||
1296 | counter = 0 |
|
1291 | counter = 0 | |
1297 | for y in range(nrow): |
|
1292 | for y in range(nrow): | |
1298 | for x in range(ncol): |
|
1293 | for x in range(ncol): | |
1299 |
|
1294 | |||
1300 | if counter >= self.nplots: |
|
1295 | if counter >= self.nplots: | |
1301 | break |
|
1296 | break | |
1302 |
|
1297 | |||
1303 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1298 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
1304 |
|
1299 | |||
1305 | if showprofile: |
|
1300 | if showprofile: | |
1306 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
1301 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
1307 |
|
1302 | |||
1308 | counter += 1 |
|
1303 | counter += 1 | |
1309 |
|
1304 | |||
1310 | def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True, |
|
1305 | def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True, | |
1311 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1306 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1312 | save=False, figpath='./', figfile=None, show=True): |
|
1307 | save=False, figpath='./', figfile=None, show=True): | |
1313 |
|
1308 | |||
1314 | """ |
|
1309 | """ | |
1315 |
|
1310 | |||
1316 | Input: |
|
1311 | Input: | |
1317 | dataOut : |
|
1312 | dataOut : | |
1318 | id : |
|
1313 | id : | |
1319 | wintitle : |
|
1314 | wintitle : | |
1320 | channelList : |
|
1315 | channelList : | |
1321 | showProfile : |
|
1316 | showProfile : | |
1322 | xmin : None, |
|
1317 | xmin : None, | |
1323 | xmax : None, |
|
1318 | xmax : None, | |
1324 | zmin : None, |
|
1319 | zmin : None, | |
1325 | zmax : None |
|
1320 | zmax : None | |
1326 | """ |
|
1321 | """ | |
1327 |
|
1322 | |||
1328 | if cutHeight==None: |
|
1323 | if cutHeight==None: | |
1329 | h=270 |
|
1324 | h=270 | |
1330 | heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin() |
|
1325 | heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin() | |
1331 | cutHeight = dataOut.heightList[heightindex] |
|
1326 | cutHeight = dataOut.heightList[heightindex] | |
1332 |
|
1327 | |||
1333 | factor = dataOut.normFactor |
|
1328 | factor = dataOut.normFactor | |
1334 | x = dataOut.abscissaList[:-1] |
|
1329 | x = dataOut.abscissaList[:-1] | |
1335 | #y = dataOut.getHeiRange() |
|
1330 | #y = dataOut.getHeiRange() | |
1336 |
|
1331 | |||
1337 | z = dataOut.data_pre[:,:,heightindex]/factor |
|
1332 | z = dataOut.data_pre[:,:,heightindex]/factor | |
1338 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
1333 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
1339 | avg = numpy.average(z, axis=1) |
|
1334 | avg = numpy.average(z, axis=1) | |
1340 | listChannels = z.shape[0] |
|
1335 | listChannels = z.shape[0] | |
1341 |
|
1336 | |||
1342 | #Reconstruct Function |
|
1337 | #Reconstruct Function | |
1343 | if fit==True: |
|
1338 | if fit==True: | |
1344 | groupArray = dataOut.groupList |
|
1339 | groupArray = dataOut.groupList | |
1345 | listChannels = groupArray.reshape((groupArray.size)) |
|
1340 | listChannels = groupArray.reshape((groupArray.size)) | |
1346 | listChannels.sort() |
|
1341 | listChannels.sort() | |
1347 | spcFitLine = numpy.zeros(z.shape) |
|
1342 | spcFitLine = numpy.zeros(z.shape) | |
1348 | constants = dataOut.constants |
|
1343 | constants = dataOut.constants | |
1349 |
|
1344 | |||
1350 | nGroups = groupArray.shape[0] |
|
1345 | nGroups = groupArray.shape[0] | |
1351 | nChannels = groupArray.shape[1] |
|
1346 | nChannels = groupArray.shape[1] | |
1352 | nProfiles = z.shape[1] |
|
1347 | nProfiles = z.shape[1] | |
1353 |
|
1348 | |||
1354 | for f in range(nGroups): |
|
1349 | for f in range(nGroups): | |
1355 | groupChann = groupArray[f,:] |
|
1350 | groupChann = groupArray[f,:] | |
1356 | p = dataOut.data_param[f,:,heightindex] |
|
1351 | p = dataOut.data_param[f,:,heightindex] | |
1357 | # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167]) |
|
1352 | # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167]) | |
1358 | fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles |
|
1353 | fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles | |
1359 | fitLineAux = fitLineAux.reshape((nChannels,nProfiles)) |
|
1354 | fitLineAux = fitLineAux.reshape((nChannels,nProfiles)) | |
1360 | spcFitLine[groupChann,:] = fitLineAux |
|
1355 | spcFitLine[groupChann,:] = fitLineAux | |
1361 | # spcFitLine = spcFitLine/factor |
|
1356 | # spcFitLine = spcFitLine/factor | |
1362 |
|
1357 | |||
1363 | z = z[listChannels,:] |
|
1358 | z = z[listChannels,:] | |
1364 | spcFitLine = spcFitLine[listChannels,:] |
|
1359 | spcFitLine = spcFitLine[listChannels,:] | |
1365 | spcFitLinedB = 10*numpy.log10(spcFitLine) |
|
1360 | spcFitLinedB = 10*numpy.log10(spcFitLine) | |
1366 |
|
1361 | |||
1367 | zdB = 10*numpy.log10(z) |
|
1362 | zdB = 10*numpy.log10(z) | |
1368 | #thisDatetime = dataOut.datatime |
|
1363 | #thisDatetime = dataOut.datatime | |
1369 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
1364 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
1370 | title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1365 | title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1371 | xlabel = "Velocity (m/s)" |
|
1366 | xlabel = "Velocity (m/s)" | |
1372 | ylabel = "Spectrum" |
|
1367 | ylabel = "Spectrum" | |
1373 |
|
1368 | |||
1374 | if not self.isConfig: |
|
1369 | if not self.isConfig: | |
1375 |
|
1370 | |||
1376 | nplots = listChannels.size |
|
1371 | nplots = listChannels.size | |
1377 |
|
1372 | |||
1378 | self.setup(id=id, |
|
1373 | self.setup(id=id, | |
1379 | nplots=nplots, |
|
1374 | nplots=nplots, | |
1380 | wintitle=wintitle, |
|
1375 | wintitle=wintitle, | |
1381 | showprofile=showprofile, |
|
1376 | showprofile=showprofile, | |
1382 | show=show) |
|
1377 | show=show) | |
1383 |
|
1378 | |||
1384 | if xmin == None: xmin = numpy.nanmin(x) |
|
1379 | if xmin == None: xmin = numpy.nanmin(x) | |
1385 | if xmax == None: xmax = numpy.nanmax(x) |
|
1380 | if xmax == None: xmax = numpy.nanmax(x) | |
1386 | if ymin == None: ymin = numpy.nanmin(zdB) |
|
1381 | if ymin == None: ymin = numpy.nanmin(zdB) | |
1387 | if ymax == None: ymax = numpy.nanmax(zdB)+2 |
|
1382 | if ymax == None: ymax = numpy.nanmax(zdB)+2 | |
1388 |
|
1383 | |||
1389 | self.isConfig = True |
|
1384 | self.isConfig = True | |
1390 |
|
1385 | |||
1391 | self.setWinTitle(title) |
|
1386 | self.setWinTitle(title) | |
1392 | for i in range(self.nplots): |
|
1387 | for i in range(self.nplots): | |
1393 | # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i]) |
|
1388 | # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i]) | |
1394 | title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]) |
|
1389 | title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]) | |
1395 | axes = self.axesList[i*self.__nsubplots] |
|
1390 | axes = self.axesList[i*self.__nsubplots] | |
1396 | if fit == False: |
|
1391 | if fit == False: | |
1397 | axes.pline(x, zdB[i,:], |
|
1392 | axes.pline(x, zdB[i,:], | |
1398 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1393 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
1399 | xlabel=xlabel, ylabel=ylabel, title=title |
|
1394 | xlabel=xlabel, ylabel=ylabel, title=title | |
1400 | ) |
|
1395 | ) | |
1401 | if fit == True: |
|
1396 | if fit == True: | |
1402 | fitline=spcFitLinedB[i,:] |
|
1397 | fitline=spcFitLinedB[i,:] | |
1403 | y=numpy.vstack([zdB[i,:],fitline] ) |
|
1398 | y=numpy.vstack([zdB[i,:],fitline] ) | |
1404 | legendlabels=['Data','Fitting'] |
|
1399 | legendlabels=['Data','Fitting'] | |
1405 | axes.pmultilineyaxis(x, y, |
|
1400 | axes.pmultilineyaxis(x, y, | |
1406 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1401 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
1407 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
1402 | xlabel=xlabel, ylabel=ylabel, title=title, | |
1408 | legendlabels=legendlabels, marker=None, |
|
1403 | legendlabels=legendlabels, marker=None, | |
1409 | linestyle='solid', grid='both') |
|
1404 | linestyle='solid', grid='both') | |
1410 |
|
1405 | |||
1411 | self.draw() |
|
1406 | self.draw() | |
1412 |
|
1407 | |||
1413 | self.save(figpath=figpath, |
|
1408 | self.save(figpath=figpath, | |
1414 | figfile=figfile, |
|
1409 | figfile=figfile, | |
1415 | save=save, |
|
1410 | save=save, | |
1416 | ftp=ftp, |
|
1411 | ftp=ftp, | |
1417 | wr_period=wr_period, |
|
1412 | wr_period=wr_period, | |
1418 | thisDatetime=thisDatetime) |
|
1413 | thisDatetime=thisDatetime) | |
1419 |
|
1414 | |||
1420 |
|
1415 | |||
1421 | class EWDriftsPlot(Figure): |
|
1416 | class EWDriftsPlot(Figure): | |
1422 |
|
1417 | |||
1423 | __isConfig = None |
|
1418 | __isConfig = None | |
1424 | __nsubplots = None |
|
1419 | __nsubplots = None | |
1425 |
|
1420 | |||
1426 | WIDTHPROF = None |
|
1421 | WIDTHPROF = None | |
1427 | HEIGHTPROF = None |
|
1422 | HEIGHTPROF = None | |
1428 | PREFIX = 'drift' |
|
1423 | PREFIX = 'drift' | |
1429 |
|
1424 | |||
1430 | def __init__(self, **kwargs): |
|
1425 | def __init__(self, **kwargs): | |
1431 | Figure.__init__(self, **kwargs) |
|
1426 | Figure.__init__(self, **kwargs) | |
1432 | self.timerange = 2*60*60 |
|
1427 | self.timerange = 2*60*60 | |
1433 | self.isConfig = False |
|
1428 | self.isConfig = False | |
1434 | self.__nsubplots = 1 |
|
1429 | self.__nsubplots = 1 | |
1435 |
|
1430 | |||
1436 | self.WIDTH = 800 |
|
1431 | self.WIDTH = 800 | |
1437 | self.HEIGHT = 150 |
|
1432 | self.HEIGHT = 150 | |
1438 | self.WIDTHPROF = 120 |
|
1433 | self.WIDTHPROF = 120 | |
1439 | self.HEIGHTPROF = 0 |
|
1434 | self.HEIGHTPROF = 0 | |
1440 | self.counter_imagwr = 0 |
|
1435 | self.counter_imagwr = 0 | |
1441 |
|
1436 | |||
1442 | self.PLOT_CODE = EWDRIFT_CODE |
|
1437 | self.PLOT_CODE = EWDRIFT_CODE | |
1443 |
|
1438 | |||
1444 | self.FTP_WEI = None |
|
1439 | self.FTP_WEI = None | |
1445 | self.EXP_CODE = None |
|
1440 | self.EXP_CODE = None | |
1446 | self.SUB_EXP_CODE = None |
|
1441 | self.SUB_EXP_CODE = None | |
1447 | self.PLOT_POS = None |
|
1442 | self.PLOT_POS = None | |
1448 | self.tmin = None |
|
1443 | self.tmin = None | |
1449 | self.tmax = None |
|
1444 | self.tmax = None | |
1450 |
|
1445 | |||
1451 | self.xmin = None |
|
1446 | self.xmin = None | |
1452 | self.xmax = None |
|
1447 | self.xmax = None | |
1453 |
|
1448 | |||
1454 | self.figfile = None |
|
1449 | self.figfile = None | |
1455 |
|
1450 | |||
1456 | def getSubplots(self): |
|
1451 | def getSubplots(self): | |
1457 |
|
1452 | |||
1458 | ncol = 1 |
|
1453 | ncol = 1 | |
1459 | nrow = self.nplots |
|
1454 | nrow = self.nplots | |
1460 |
|
1455 | |||
1461 | return nrow, ncol |
|
1456 | return nrow, ncol | |
1462 |
|
1457 | |||
1463 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1458 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1464 |
|
1459 | |||
1465 | self.__showprofile = showprofile |
|
1460 | self.__showprofile = showprofile | |
1466 | self.nplots = nplots |
|
1461 | self.nplots = nplots | |
1467 |
|
1462 | |||
1468 | ncolspan = 1 |
|
1463 | ncolspan = 1 | |
1469 | colspan = 1 |
|
1464 | colspan = 1 | |
1470 |
|
1465 | |||
1471 | self.createFigure(id = id, |
|
1466 | self.createFigure(id = id, | |
1472 | wintitle = wintitle, |
|
1467 | wintitle = wintitle, | |
1473 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1468 | widthplot = self.WIDTH + self.WIDTHPROF, | |
1474 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1469 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
1475 | show=show) |
|
1470 | show=show) | |
1476 |
|
1471 | |||
1477 | nrow, ncol = self.getSubplots() |
|
1472 | nrow, ncol = self.getSubplots() | |
1478 |
|
1473 | |||
1479 | counter = 0 |
|
1474 | counter = 0 | |
1480 | for y in range(nrow): |
|
1475 | for y in range(nrow): | |
1481 | if counter >= self.nplots: |
|
1476 | if counter >= self.nplots: | |
1482 | break |
|
1477 | break | |
1483 |
|
1478 | |||
1484 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) |
|
1479 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) | |
1485 | counter += 1 |
|
1480 | counter += 1 | |
1486 |
|
1481 | |||
1487 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
1482 | def run(self, dataOut, id, wintitle="", channelList=None, | |
1488 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
1483 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
1489 | zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None, |
|
1484 | zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None, | |
1490 | timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False, |
|
1485 | timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False, | |
1491 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
1486 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
1492 | server=None, folder=None, username=None, password=None, |
|
1487 | server=None, folder=None, username=None, password=None, | |
1493 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1488 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1494 | """ |
|
1489 | """ | |
1495 |
|
1490 | |||
1496 | Input: |
|
1491 | Input: | |
1497 | dataOut : |
|
1492 | dataOut : | |
1498 | id : |
|
1493 | id : | |
1499 | wintitle : |
|
1494 | wintitle : | |
1500 | channelList : |
|
1495 | channelList : | |
1501 | showProfile : |
|
1496 | showProfile : | |
1502 | xmin : None, |
|
1497 | xmin : None, | |
1503 | xmax : None, |
|
1498 | xmax : None, | |
1504 | ymin : None, |
|
1499 | ymin : None, | |
1505 | ymax : None, |
|
1500 | ymax : None, | |
1506 | zmin : None, |
|
1501 | zmin : None, | |
1507 | zmax : None |
|
1502 | zmax : None | |
1508 | """ |
|
1503 | """ | |
1509 |
|
1504 | |||
1510 | if timerange is not None: |
|
1505 | if timerange is not None: | |
1511 | self.timerange = timerange |
|
1506 | self.timerange = timerange | |
1512 |
|
1507 | |||
1513 | tmin = None |
|
1508 | tmin = None | |
1514 | tmax = None |
|
1509 | tmax = None | |
1515 |
|
1510 | |||
1516 | x = dataOut.getTimeRange1(dataOut.outputInterval) |
|
1511 | x = dataOut.getTimeRange1(dataOut.outputInterval) | |
1517 | # y = dataOut.heightList |
|
1512 | # y = dataOut.heightList | |
1518 | y = dataOut.heightList |
|
1513 | y = dataOut.heightList | |
1519 |
|
1514 | |||
1520 | z = dataOut.data_output |
|
1515 | z = dataOut.data_output | |
1521 | nplots = z.shape[0] #Number of wind dimensions estimated |
|
1516 | nplots = z.shape[0] #Number of wind dimensions estimated | |
1522 | nplotsw = nplots |
|
1517 | nplotsw = nplots | |
1523 |
|
1518 | |||
1524 | #If there is a SNR function defined |
|
1519 | #If there is a SNR function defined | |
1525 | if dataOut.data_SNR is not None: |
|
1520 | if dataOut.data_SNR is not None: | |
1526 | nplots += 1 |
|
1521 | nplots += 1 | |
1527 | SNR = dataOut.data_SNR |
|
1522 | SNR = dataOut.data_SNR | |
1528 |
|
1523 | |||
1529 | if SNR_1: |
|
1524 | if SNR_1: | |
1530 | SNR += 1 |
|
1525 | SNR += 1 | |
1531 |
|
1526 | |||
1532 | SNRavg = numpy.average(SNR, axis=0) |
|
1527 | SNRavg = numpy.average(SNR, axis=0) | |
1533 |
|
1528 | |||
1534 | SNRdB = 10*numpy.log10(SNR) |
|
1529 | SNRdB = 10*numpy.log10(SNR) | |
1535 | SNRavgdB = 10*numpy.log10(SNRavg) |
|
1530 | SNRavgdB = 10*numpy.log10(SNRavg) | |
1536 |
|
1531 | |||
1537 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] |
|
1532 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] | |
1538 |
|
1533 | |||
1539 | for i in range(nplotsw): |
|
1534 | for i in range(nplotsw): | |
1540 | z[i,ind] = numpy.nan |
|
1535 | z[i,ind] = numpy.nan | |
1541 |
|
1536 | |||
1542 |
|
1537 | |||
1543 | showprofile = False |
|
1538 | showprofile = False | |
1544 | # thisDatetime = dataOut.datatime |
|
1539 | # thisDatetime = dataOut.datatime | |
1545 | thisDatetime = datetime.datetime.utcfromtimestamp(x[1]) |
|
1540 | thisDatetime = datetime.datetime.utcfromtimestamp(x[1]) | |
1546 | title = wintitle + " EW Drifts" |
|
1541 | title = wintitle + " EW Drifts" | |
1547 | xlabel = "" |
|
1542 | xlabel = "" | |
1548 | ylabel = "Height (Km)" |
|
1543 | ylabel = "Height (Km)" | |
1549 |
|
1544 | |||
1550 | if not self.isConfig: |
|
1545 | if not self.isConfig: | |
1551 |
|
1546 | |||
1552 | self.setup(id=id, |
|
1547 | self.setup(id=id, | |
1553 | nplots=nplots, |
|
1548 | nplots=nplots, | |
1554 | wintitle=wintitle, |
|
1549 | wintitle=wintitle, | |
1555 | showprofile=showprofile, |
|
1550 | showprofile=showprofile, | |
1556 | show=show) |
|
1551 | show=show) | |
1557 |
|
1552 | |||
1558 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1553 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1559 |
|
1554 | |||
1560 | if ymin == None: ymin = numpy.nanmin(y) |
|
1555 | if ymin == None: ymin = numpy.nanmin(y) | |
1561 | if ymax == None: ymax = numpy.nanmax(y) |
|
1556 | if ymax == None: ymax = numpy.nanmax(y) | |
1562 |
|
1557 | |||
1563 | if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:])) |
|
1558 | if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:])) | |
1564 | if zminZonal == None: zminZonal = -zmaxZonal |
|
1559 | if zminZonal == None: zminZonal = -zmaxZonal | |
1565 | if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:])) |
|
1560 | if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:])) | |
1566 | if zminVertical == None: zminVertical = -zmaxVertical |
|
1561 | if zminVertical == None: zminVertical = -zmaxVertical | |
1567 |
|
1562 | |||
1568 | if dataOut.data_SNR is not None: |
|
1563 | if dataOut.data_SNR is not None: | |
1569 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) |
|
1564 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | |
1570 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) |
|
1565 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | |
1571 |
|
1566 | |||
1572 | self.FTP_WEI = ftp_wei |
|
1567 | self.FTP_WEI = ftp_wei | |
1573 | self.EXP_CODE = exp_code |
|
1568 | self.EXP_CODE = exp_code | |
1574 | self.SUB_EXP_CODE = sub_exp_code |
|
1569 | self.SUB_EXP_CODE = sub_exp_code | |
1575 | self.PLOT_POS = plot_pos |
|
1570 | self.PLOT_POS = plot_pos | |
1576 |
|
1571 | |||
1577 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1572 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1578 | self.isConfig = True |
|
1573 | self.isConfig = True | |
1579 |
|
1574 | |||
1580 |
|
1575 | |||
1581 | self.setWinTitle(title) |
|
1576 | self.setWinTitle(title) | |
1582 |
|
1577 | |||
1583 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
1578 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
1584 | x[1] = self.xmax |
|
1579 | x[1] = self.xmax | |
1585 |
|
1580 | |||
1586 | strWind = ['Zonal','Vertical'] |
|
1581 | strWind = ['Zonal','Vertical'] | |
1587 | strCb = 'Velocity (m/s)' |
|
1582 | strCb = 'Velocity (m/s)' | |
1588 | zmaxVector = [zmaxZonal, zmaxVertical] |
|
1583 | zmaxVector = [zmaxZonal, zmaxVertical] | |
1589 | zminVector = [zminZonal, zminVertical] |
|
1584 | zminVector = [zminZonal, zminVertical] | |
1590 |
|
1585 | |||
1591 | for i in range(nplotsw): |
|
1586 | for i in range(nplotsw): | |
1592 |
|
1587 | |||
1593 | title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1588 | title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1594 | axes = self.axesList[i*self.__nsubplots] |
|
1589 | axes = self.axesList[i*self.__nsubplots] | |
1595 |
|
1590 | |||
1596 | z1 = z[i,:].reshape((1,-1)) |
|
1591 | z1 = z[i,:].reshape((1,-1)) | |
1597 |
|
1592 | |||
1598 | axes.pcolorbuffer(x, y, z1, |
|
1593 | axes.pcolorbuffer(x, y, z1, | |
1599 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], |
|
1594 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], | |
1600 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1595 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1601 | ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r") |
|
1596 | ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r") | |
1602 |
|
1597 | |||
1603 | if dataOut.data_SNR is not None: |
|
1598 | if dataOut.data_SNR is not None: | |
1604 | i += 1 |
|
1599 | i += 1 | |
1605 | if SNR_1: |
|
1600 | if SNR_1: | |
1606 | title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1601 | title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1607 | else: |
|
1602 | else: | |
1608 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1603 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1609 | axes = self.axesList[i*self.__nsubplots] |
|
1604 | axes = self.axesList[i*self.__nsubplots] | |
1610 | SNRavgdB = SNRavgdB.reshape((1,-1)) |
|
1605 | SNRavgdB = SNRavgdB.reshape((1,-1)) | |
1611 |
|
1606 | |||
1612 | axes.pcolorbuffer(x, y, SNRavgdB, |
|
1607 | axes.pcolorbuffer(x, y, SNRavgdB, | |
1613 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
1608 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
1614 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1609 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1615 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") |
|
1610 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") | |
1616 |
|
1611 | |||
1617 | self.draw() |
|
1612 | self.draw() | |
1618 |
|
1613 | |||
1619 | if x[1] >= self.axesList[0].xmax: |
|
1614 | if x[1] >= self.axesList[0].xmax: | |
1620 | self.counter_imagwr = wr_period |
|
1615 | self.counter_imagwr = wr_period | |
1621 | self.isConfig = False |
|
1616 | self.isConfig = False | |
1622 | self.figfile = None |
|
1617 | self.figfile = None | |
1623 |
|
1618 | |||
1624 |
|
1619 | |||
1625 |
|
1620 | |||
1626 |
|
1621 | |||
1627 | class PhasePlot(Figure): |
|
1622 | class PhasePlot(Figure): | |
1628 |
|
1623 | |||
1629 | __isConfig = None |
|
1624 | __isConfig = None | |
1630 | __nsubplots = None |
|
1625 | __nsubplots = None | |
1631 |
|
1626 | |||
1632 | PREFIX = 'mphase' |
|
1627 | PREFIX = 'mphase' | |
1633 |
|
1628 | |||
1634 | def __init__(self, **kwargs): |
|
1629 | def __init__(self, **kwargs): | |
1635 | Figure.__init__(self, **kwargs) |
|
1630 | Figure.__init__(self, **kwargs) | |
1636 | self.timerange = 24*60*60 |
|
1631 | self.timerange = 24*60*60 | |
1637 | self.isConfig = False |
|
1632 | self.isConfig = False | |
1638 | self.__nsubplots = 1 |
|
1633 | self.__nsubplots = 1 | |
1639 | self.counter_imagwr = 0 |
|
1634 | self.counter_imagwr = 0 | |
1640 | self.WIDTH = 600 |
|
1635 | self.WIDTH = 600 | |
1641 | self.HEIGHT = 300 |
|
1636 | self.HEIGHT = 300 | |
1642 | self.WIDTHPROF = 120 |
|
1637 | self.WIDTHPROF = 120 | |
1643 | self.HEIGHTPROF = 0 |
|
1638 | self.HEIGHTPROF = 0 | |
1644 | self.xdata = None |
|
1639 | self.xdata = None | |
1645 | self.ydata = None |
|
1640 | self.ydata = None | |
1646 |
|
1641 | |||
1647 | self.PLOT_CODE = MPHASE_CODE |
|
1642 | self.PLOT_CODE = MPHASE_CODE | |
1648 |
|
1643 | |||
1649 | self.FTP_WEI = None |
|
1644 | self.FTP_WEI = None | |
1650 | self.EXP_CODE = None |
|
1645 | self.EXP_CODE = None | |
1651 | self.SUB_EXP_CODE = None |
|
1646 | self.SUB_EXP_CODE = None | |
1652 | self.PLOT_POS = None |
|
1647 | self.PLOT_POS = None | |
1653 |
|
1648 | |||
1654 |
|
1649 | |||
1655 | self.filename_phase = None |
|
1650 | self.filename_phase = None | |
1656 |
|
1651 | |||
1657 | self.figfile = None |
|
1652 | self.figfile = None | |
1658 |
|
1653 | |||
1659 | def getSubplots(self): |
|
1654 | def getSubplots(self): | |
1660 |
|
1655 | |||
1661 | ncol = 1 |
|
1656 | ncol = 1 | |
1662 | nrow = 1 |
|
1657 | nrow = 1 | |
1663 |
|
1658 | |||
1664 | return nrow, ncol |
|
1659 | return nrow, ncol | |
1665 |
|
1660 | |||
1666 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1661 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1667 |
|
1662 | |||
1668 | self.__showprofile = showprofile |
|
1663 | self.__showprofile = showprofile | |
1669 | self.nplots = nplots |
|
1664 | self.nplots = nplots | |
1670 |
|
1665 | |||
1671 | ncolspan = 7 |
|
1666 | ncolspan = 7 | |
1672 | colspan = 6 |
|
1667 | colspan = 6 | |
1673 | self.__nsubplots = 2 |
|
1668 | self.__nsubplots = 2 | |
1674 |
|
1669 | |||
1675 | self.createFigure(id = id, |
|
1670 | self.createFigure(id = id, | |
1676 | wintitle = wintitle, |
|
1671 | wintitle = wintitle, | |
1677 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1672 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1678 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1673 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1679 | show=show) |
|
1674 | show=show) | |
1680 |
|
1675 | |||
1681 | nrow, ncol = self.getSubplots() |
|
1676 | nrow, ncol = self.getSubplots() | |
1682 |
|
1677 | |||
1683 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1678 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1684 |
|
1679 | |||
1685 |
|
1680 | |||
1686 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1681 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
1687 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1682 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1688 | timerange=None, |
|
1683 | timerange=None, | |
1689 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1684 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1690 | server=None, folder=None, username=None, password=None, |
|
1685 | server=None, folder=None, username=None, password=None, | |
1691 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1686 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1692 |
|
1687 | |||
1693 |
|
1688 | |||
1694 | tmin = None |
|
1689 | tmin = None | |
1695 | tmax = None |
|
1690 | tmax = None | |
1696 | x = dataOut.getTimeRange1(dataOut.outputInterval) |
|
1691 | x = dataOut.getTimeRange1(dataOut.outputInterval) | |
1697 | y = dataOut.getHeiRange() |
|
1692 | y = dataOut.getHeiRange() | |
1698 |
|
1693 | |||
1699 |
|
1694 | |||
1700 | #thisDatetime = dataOut.datatime |
|
1695 | #thisDatetime = dataOut.datatime | |
1701 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) |
|
1696 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | |
1702 | title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1697 | title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1703 | xlabel = "Local Time" |
|
1698 | xlabel = "Local Time" | |
1704 | ylabel = "Phase" |
|
1699 | ylabel = "Phase" | |
1705 |
|
1700 | |||
1706 |
|
1701 | |||
1707 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) |
|
1702 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) | |
1708 | phase_beacon = dataOut.data_output |
|
1703 | phase_beacon = dataOut.data_output | |
1709 | update_figfile = False |
|
1704 | update_figfile = False | |
1710 |
|
1705 | |||
1711 | if not self.isConfig: |
|
1706 | if not self.isConfig: | |
1712 |
|
1707 | |||
1713 | self.nplots = phase_beacon.size |
|
1708 | self.nplots = phase_beacon.size | |
1714 |
|
1709 | |||
1715 | self.setup(id=id, |
|
1710 | self.setup(id=id, | |
1716 | nplots=self.nplots, |
|
1711 | nplots=self.nplots, | |
1717 | wintitle=wintitle, |
|
1712 | wintitle=wintitle, | |
1718 | showprofile=showprofile, |
|
1713 | showprofile=showprofile, | |
1719 | show=show) |
|
1714 | show=show) | |
1720 |
|
1715 | |||
1721 | if timerange is not None: |
|
1716 | if timerange is not None: | |
1722 | self.timerange = timerange |
|
1717 | self.timerange = timerange | |
1723 |
|
1718 | |||
1724 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1719 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1725 |
|
1720 | |||
1726 | if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0 |
|
1721 | if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0 | |
1727 | if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0 |
|
1722 | if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0 | |
1728 |
|
1723 | |||
1729 | self.FTP_WEI = ftp_wei |
|
1724 | self.FTP_WEI = ftp_wei | |
1730 | self.EXP_CODE = exp_code |
|
1725 | self.EXP_CODE = exp_code | |
1731 | self.SUB_EXP_CODE = sub_exp_code |
|
1726 | self.SUB_EXP_CODE = sub_exp_code | |
1732 | self.PLOT_POS = plot_pos |
|
1727 | self.PLOT_POS = plot_pos | |
1733 |
|
1728 | |||
1734 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1729 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1735 | self.isConfig = True |
|
1730 | self.isConfig = True | |
1736 | self.figfile = figfile |
|
1731 | self.figfile = figfile | |
1737 | self.xdata = numpy.array([]) |
|
1732 | self.xdata = numpy.array([]) | |
1738 | self.ydata = numpy.array([]) |
|
1733 | self.ydata = numpy.array([]) | |
1739 |
|
1734 | |||
1740 | #open file beacon phase |
|
1735 | #open file beacon phase | |
1741 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1736 | path = '%s%03d' %(self.PREFIX, self.id) | |
1742 | beacon_file = os.path.join(path,'%s.txt'%self.name) |
|
1737 | beacon_file = os.path.join(path,'%s.txt'%self.name) | |
1743 | self.filename_phase = os.path.join(figpath,beacon_file) |
|
1738 | self.filename_phase = os.path.join(figpath,beacon_file) | |
1744 | update_figfile = True |
|
1739 | update_figfile = True | |
1745 |
|
1740 | |||
1746 |
|
1741 | |||
1747 | #store data beacon phase |
|
1742 | #store data beacon phase | |
1748 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) |
|
1743 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) | |
1749 |
|
1744 | |||
1750 | self.setWinTitle(title) |
|
1745 | self.setWinTitle(title) | |
1751 |
|
1746 | |||
1752 |
|
1747 | |||
1753 | title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1748 | title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1754 |
|
1749 | |||
1755 | legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)] |
|
1750 | legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)] | |
1756 |
|
1751 | |||
1757 | axes = self.axesList[0] |
|
1752 | axes = self.axesList[0] | |
1758 |
|
1753 | |||
1759 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1754 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1760 |
|
1755 | |||
1761 | if len(self.ydata)==0: |
|
1756 | if len(self.ydata)==0: | |
1762 | self.ydata = phase_beacon.reshape(-1,1) |
|
1757 | self.ydata = phase_beacon.reshape(-1,1) | |
1763 | else: |
|
1758 | else: | |
1764 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) |
|
1759 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) | |
1765 |
|
1760 | |||
1766 |
|
1761 | |||
1767 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1762 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1768 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1763 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, | |
1769 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1764 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1770 | XAxisAsTime=True, grid='both' |
|
1765 | XAxisAsTime=True, grid='both' | |
1771 | ) |
|
1766 | ) | |
1772 |
|
1767 | |||
1773 | self.draw() |
|
1768 | self.draw() | |
1774 |
|
1769 | |||
1775 | self.save(figpath=figpath, |
|
1770 | self.save(figpath=figpath, | |
1776 | figfile=figfile, |
|
1771 | figfile=figfile, | |
1777 | save=save, |
|
1772 | save=save, | |
1778 | ftp=ftp, |
|
1773 | ftp=ftp, | |
1779 | wr_period=wr_period, |
|
1774 | wr_period=wr_period, | |
1780 | thisDatetime=thisDatetime, |
|
1775 | thisDatetime=thisDatetime, | |
1781 | update_figfile=update_figfile) |
|
1776 | update_figfile=update_figfile) | |
1782 |
|
1777 | |||
1783 | if dataOut.ltctime + dataOut.outputInterval >= self.xmax: |
|
1778 | if dataOut.ltctime + dataOut.outputInterval >= self.xmax: | |
1784 | self.counter_imagwr = wr_period |
|
1779 | self.counter_imagwr = wr_period | |
1785 | self.isConfig = False |
|
1780 | self.isConfig = False | |
1786 | update_figfile = True |
|
1781 | update_figfile = True | |
1787 |
|
1782 | |||
1788 |
|
1783 | |||
1789 |
|
1784 | |||
1790 | class NSMeteorDetection1Plot(Figure): |
|
1785 | class NSMeteorDetection1Plot(Figure): | |
1791 |
|
1786 | |||
1792 | isConfig = None |
|
1787 | isConfig = None | |
1793 | __nsubplots = None |
|
1788 | __nsubplots = None | |
1794 |
|
1789 | |||
1795 | WIDTHPROF = None |
|
1790 | WIDTHPROF = None | |
1796 | HEIGHTPROF = None |
|
1791 | HEIGHTPROF = None | |
1797 | PREFIX = 'nsm' |
|
1792 | PREFIX = 'nsm' | |
1798 |
|
1793 | |||
1799 | zminList = None |
|
1794 | zminList = None | |
1800 | zmaxList = None |
|
1795 | zmaxList = None | |
1801 | cmapList = None |
|
1796 | cmapList = None | |
1802 | titleList = None |
|
1797 | titleList = None | |
1803 | nPairs = None |
|
1798 | nPairs = None | |
1804 | nChannels = None |
|
1799 | nChannels = None | |
1805 | nParam = None |
|
1800 | nParam = None | |
1806 |
|
1801 | |||
1807 | def __init__(self, **kwargs): |
|
1802 | def __init__(self, **kwargs): | |
1808 | Figure.__init__(self, **kwargs) |
|
1803 | Figure.__init__(self, **kwargs) | |
1809 | self.isConfig = False |
|
1804 | self.isConfig = False | |
1810 | self.__nsubplots = 1 |
|
1805 | self.__nsubplots = 1 | |
1811 |
|
1806 | |||
1812 | self.WIDTH = 750 |
|
1807 | self.WIDTH = 750 | |
1813 | self.HEIGHT = 250 |
|
1808 | self.HEIGHT = 250 | |
1814 | self.WIDTHPROF = 120 |
|
1809 | self.WIDTHPROF = 120 | |
1815 | self.HEIGHTPROF = 0 |
|
1810 | self.HEIGHTPROF = 0 | |
1816 | self.counter_imagwr = 0 |
|
1811 | self.counter_imagwr = 0 | |
1817 |
|
1812 | |||
1818 | self.PLOT_CODE = SPEC_CODE |
|
1813 | self.PLOT_CODE = SPEC_CODE | |
1819 |
|
1814 | |||
1820 | self.FTP_WEI = None |
|
1815 | self.FTP_WEI = None | |
1821 | self.EXP_CODE = None |
|
1816 | self.EXP_CODE = None | |
1822 | self.SUB_EXP_CODE = None |
|
1817 | self.SUB_EXP_CODE = None | |
1823 | self.PLOT_POS = None |
|
1818 | self.PLOT_POS = None | |
1824 |
|
1819 | |||
1825 | self.__xfilter_ena = False |
|
1820 | self.__xfilter_ena = False | |
1826 | self.__yfilter_ena = False |
|
1821 | self.__yfilter_ena = False | |
1827 |
|
1822 | |||
1828 | def getSubplots(self): |
|
1823 | def getSubplots(self): | |
1829 |
|
1824 | |||
1830 | ncol = 3 |
|
1825 | ncol = 3 | |
1831 | nrow = int(numpy.ceil(self.nplots/3.0)) |
|
1826 | nrow = int(numpy.ceil(self.nplots/3.0)) | |
1832 |
|
1827 | |||
1833 | return nrow, ncol |
|
1828 | return nrow, ncol | |
1834 |
|
1829 | |||
1835 | def setup(self, id, nplots, wintitle, show=True): |
|
1830 | def setup(self, id, nplots, wintitle, show=True): | |
1836 |
|
1831 | |||
1837 | self.nplots = nplots |
|
1832 | self.nplots = nplots | |
1838 |
|
1833 | |||
1839 | ncolspan = 1 |
|
1834 | ncolspan = 1 | |
1840 | colspan = 1 |
|
1835 | colspan = 1 | |
1841 |
|
1836 | |||
1842 | self.createFigure(id = id, |
|
1837 | self.createFigure(id = id, | |
1843 | wintitle = wintitle, |
|
1838 | wintitle = wintitle, | |
1844 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1839 | widthplot = self.WIDTH + self.WIDTHPROF, | |
1845 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1840 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
1846 | show=show) |
|
1841 | show=show) | |
1847 |
|
1842 | |||
1848 | nrow, ncol = self.getSubplots() |
|
1843 | nrow, ncol = self.getSubplots() | |
1849 |
|
1844 | |||
1850 | counter = 0 |
|
1845 | counter = 0 | |
1851 | for y in range(nrow): |
|
1846 | for y in range(nrow): | |
1852 | for x in range(ncol): |
|
1847 | for x in range(ncol): | |
1853 |
|
1848 | |||
1854 | if counter >= self.nplots: |
|
1849 | if counter >= self.nplots: | |
1855 | break |
|
1850 | break | |
1856 |
|
1851 | |||
1857 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1852 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
1858 |
|
1853 | |||
1859 | counter += 1 |
|
1854 | counter += 1 | |
1860 |
|
1855 | |||
1861 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
1856 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
1862 | xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None, |
|
1857 | xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None, | |
1863 | vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA', |
|
1858 | vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA', | |
1864 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1859 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1865 | server=None, folder=None, username=None, password=None, |
|
1860 | server=None, folder=None, username=None, password=None, | |
1866 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False, |
|
1861 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False, | |
1867 | xaxis="frequency"): |
|
1862 | xaxis="frequency"): | |
1868 |
|
1863 | |||
1869 | """ |
|
1864 | """ | |
1870 |
|
1865 | |||
1871 | Input: |
|
1866 | Input: | |
1872 | dataOut : |
|
1867 | dataOut : | |
1873 | id : |
|
1868 | id : | |
1874 | wintitle : |
|
1869 | wintitle : | |
1875 | channelList : |
|
1870 | channelList : | |
1876 | showProfile : |
|
1871 | showProfile : | |
1877 | xmin : None, |
|
1872 | xmin : None, | |
1878 | xmax : None, |
|
1873 | xmax : None, | |
1879 | ymin : None, |
|
1874 | ymin : None, | |
1880 | ymax : None, |
|
1875 | ymax : None, | |
1881 | zmin : None, |
|
1876 | zmin : None, | |
1882 | zmax : None |
|
1877 | zmax : None | |
1883 | """ |
|
1878 | """ | |
1884 | #SEPARAR EN DOS PLOTS |
|
1879 | #SEPARAR EN DOS PLOTS | |
1885 | nParam = dataOut.data_param.shape[1] - 3 |
|
1880 | nParam = dataOut.data_param.shape[1] - 3 | |
1886 |
|
1881 | |||
1887 | utctime = dataOut.data_param[0,0] |
|
1882 | utctime = dataOut.data_param[0,0] | |
1888 | tmet = dataOut.data_param[:,1].astype(int) |
|
1883 | tmet = dataOut.data_param[:,1].astype(int) | |
1889 | hmet = dataOut.data_param[:,2].astype(int) |
|
1884 | hmet = dataOut.data_param[:,2].astype(int) | |
1890 |
|
1885 | |||
1891 | x = dataOut.abscissaList |
|
1886 | x = dataOut.abscissaList | |
1892 | y = dataOut.heightList |
|
1887 | y = dataOut.heightList | |
1893 |
|
1888 | |||
1894 | z = numpy.zeros((nParam, y.size, x.size - 1)) |
|
1889 | z = numpy.zeros((nParam, y.size, x.size - 1)) | |
1895 | z[:,:] = numpy.nan |
|
1890 | z[:,:] = numpy.nan | |
1896 | z[:,hmet,tmet] = dataOut.data_param[:,3:].T |
|
1891 | z[:,hmet,tmet] = dataOut.data_param[:,3:].T | |
1897 | z[0,:,:] = 10*numpy.log10(z[0,:,:]) |
|
1892 | z[0,:,:] = 10*numpy.log10(z[0,:,:]) | |
1898 |
|
1893 | |||
1899 | xlabel = "Time (s)" |
|
1894 | xlabel = "Time (s)" | |
1900 | ylabel = "Range (km)" |
|
1895 | ylabel = "Range (km)" | |
1901 |
|
1896 | |||
1902 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) |
|
1897 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | |
1903 |
|
1898 | |||
1904 | if not self.isConfig: |
|
1899 | if not self.isConfig: | |
1905 |
|
1900 | |||
1906 | nplots = nParam |
|
1901 | nplots = nParam | |
1907 |
|
1902 | |||
1908 | self.setup(id=id, |
|
1903 | self.setup(id=id, | |
1909 | nplots=nplots, |
|
1904 | nplots=nplots, | |
1910 | wintitle=wintitle, |
|
1905 | wintitle=wintitle, | |
1911 | show=show) |
|
1906 | show=show) | |
1912 |
|
1907 | |||
1913 | if xmin is None: xmin = numpy.nanmin(x) |
|
1908 | if xmin is None: xmin = numpy.nanmin(x) | |
1914 | if xmax is None: xmax = numpy.nanmax(x) |
|
1909 | if xmax is None: xmax = numpy.nanmax(x) | |
1915 | if ymin is None: ymin = numpy.nanmin(y) |
|
1910 | if ymin is None: ymin = numpy.nanmin(y) | |
1916 | if ymax is None: ymax = numpy.nanmax(y) |
|
1911 | if ymax is None: ymax = numpy.nanmax(y) | |
1917 | if SNRmin is None: SNRmin = numpy.nanmin(z[0,:]) |
|
1912 | if SNRmin is None: SNRmin = numpy.nanmin(z[0,:]) | |
1918 | if SNRmax is None: SNRmax = numpy.nanmax(z[0,:]) |
|
1913 | if SNRmax is None: SNRmax = numpy.nanmax(z[0,:]) | |
1919 | if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:])) |
|
1914 | if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:])) | |
1920 | if vmin is None: vmin = -vmax |
|
1915 | if vmin is None: vmin = -vmax | |
1921 | if wmin is None: wmin = 0 |
|
1916 | if wmin is None: wmin = 0 | |
1922 | if wmax is None: wmax = 50 |
|
1917 | if wmax is None: wmax = 50 | |
1923 |
|
1918 | |||
1924 | pairsList = dataOut.groupList |
|
1919 | pairsList = dataOut.groupList | |
1925 | self.nPairs = len(dataOut.groupList) |
|
1920 | self.nPairs = len(dataOut.groupList) | |
1926 |
|
1921 | |||
1927 | zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs |
|
1922 | zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs | |
1928 | zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs |
|
1923 | zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs | |
1929 | titleList = ["SNR","Radial Velocity","Coherence"] |
|
1924 | titleList = ["SNR","Radial Velocity","Coherence"] | |
1930 | cmapList = ["jet","RdBu_r","jet"] |
|
1925 | cmapList = ["jet","RdBu_r","jet"] | |
1931 |
|
1926 | |||
1932 | for i in range(self.nPairs): |
|
1927 | for i in range(self.nPairs): | |
1933 | strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1]) |
|
1928 | strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1]) | |
1934 | titleList = titleList + [strAux1] |
|
1929 | titleList = titleList + [strAux1] | |
1935 | cmapList = cmapList + ["RdBu_r"] |
|
1930 | cmapList = cmapList + ["RdBu_r"] | |
1936 |
|
1931 | |||
1937 | self.zminList = zminList |
|
1932 | self.zminList = zminList | |
1938 | self.zmaxList = zmaxList |
|
1933 | self.zmaxList = zmaxList | |
1939 | self.cmapList = cmapList |
|
1934 | self.cmapList = cmapList | |
1940 | self.titleList = titleList |
|
1935 | self.titleList = titleList | |
1941 |
|
1936 | |||
1942 | self.FTP_WEI = ftp_wei |
|
1937 | self.FTP_WEI = ftp_wei | |
1943 | self.EXP_CODE = exp_code |
|
1938 | self.EXP_CODE = exp_code | |
1944 | self.SUB_EXP_CODE = sub_exp_code |
|
1939 | self.SUB_EXP_CODE = sub_exp_code | |
1945 | self.PLOT_POS = plot_pos |
|
1940 | self.PLOT_POS = plot_pos | |
1946 |
|
1941 | |||
1947 | self.isConfig = True |
|
1942 | self.isConfig = True | |
1948 |
|
1943 | |||
1949 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
1944 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
1950 |
|
1945 | |||
1951 | for i in range(nParam): |
|
1946 | for i in range(nParam): | |
1952 | title = self.titleList[i] + ": " +str_datetime |
|
1947 | title = self.titleList[i] + ": " +str_datetime | |
1953 | axes = self.axesList[i] |
|
1948 | axes = self.axesList[i] | |
1954 | axes.pcolor(x, y, z[i,:].T, |
|
1949 | axes.pcolor(x, y, z[i,:].T, | |
1955 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i], |
|
1950 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i], | |
1956 | xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='') |
|
1951 | xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='') | |
1957 | self.draw() |
|
1952 | self.draw() | |
1958 |
|
1953 | |||
1959 | if figfile == None: |
|
1954 | if figfile == None: | |
1960 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1955 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1961 | name = str_datetime |
|
1956 | name = str_datetime | |
1962 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
1957 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
1963 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) |
|
1958 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | |
1964 | figfile = self.getFilename(name) |
|
1959 | figfile = self.getFilename(name) | |
1965 |
|
1960 | |||
1966 | self.save(figpath=figpath, |
|
1961 | self.save(figpath=figpath, | |
1967 | figfile=figfile, |
|
1962 | figfile=figfile, | |
1968 | save=save, |
|
1963 | save=save, | |
1969 | ftp=ftp, |
|
1964 | ftp=ftp, | |
1970 | wr_period=wr_period, |
|
1965 | wr_period=wr_period, | |
1971 | thisDatetime=thisDatetime) |
|
1966 | thisDatetime=thisDatetime) | |
1972 |
|
1967 | |||
1973 |
|
1968 | |||
1974 | class NSMeteorDetection2Plot(Figure): |
|
1969 | class NSMeteorDetection2Plot(Figure): | |
1975 |
|
1970 | |||
1976 | isConfig = None |
|
1971 | isConfig = None | |
1977 | __nsubplots = None |
|
1972 | __nsubplots = None | |
1978 |
|
1973 | |||
1979 | WIDTHPROF = None |
|
1974 | WIDTHPROF = None | |
1980 | HEIGHTPROF = None |
|
1975 | HEIGHTPROF = None | |
1981 | PREFIX = 'nsm' |
|
1976 | PREFIX = 'nsm' | |
1982 |
|
1977 | |||
1983 | zminList = None |
|
1978 | zminList = None | |
1984 | zmaxList = None |
|
1979 | zmaxList = None | |
1985 | cmapList = None |
|
1980 | cmapList = None | |
1986 | titleList = None |
|
1981 | titleList = None | |
1987 | nPairs = None |
|
1982 | nPairs = None | |
1988 | nChannels = None |
|
1983 | nChannels = None | |
1989 | nParam = None |
|
1984 | nParam = None | |
1990 |
|
1985 | |||
1991 | def __init__(self, **kwargs): |
|
1986 | def __init__(self, **kwargs): | |
1992 | Figure.__init__(self, **kwargs) |
|
1987 | Figure.__init__(self, **kwargs) | |
1993 | self.isConfig = False |
|
1988 | self.isConfig = False | |
1994 | self.__nsubplots = 1 |
|
1989 | self.__nsubplots = 1 | |
1995 |
|
1990 | |||
1996 | self.WIDTH = 750 |
|
1991 | self.WIDTH = 750 | |
1997 | self.HEIGHT = 250 |
|
1992 | self.HEIGHT = 250 | |
1998 | self.WIDTHPROF = 120 |
|
1993 | self.WIDTHPROF = 120 | |
1999 | self.HEIGHTPROF = 0 |
|
1994 | self.HEIGHTPROF = 0 | |
2000 | self.counter_imagwr = 0 |
|
1995 | self.counter_imagwr = 0 | |
2001 |
|
1996 | |||
2002 | self.PLOT_CODE = SPEC_CODE |
|
1997 | self.PLOT_CODE = SPEC_CODE | |
2003 |
|
1998 | |||
2004 | self.FTP_WEI = None |
|
1999 | self.FTP_WEI = None | |
2005 | self.EXP_CODE = None |
|
2000 | self.EXP_CODE = None | |
2006 | self.SUB_EXP_CODE = None |
|
2001 | self.SUB_EXP_CODE = None | |
2007 | self.PLOT_POS = None |
|
2002 | self.PLOT_POS = None | |
2008 |
|
2003 | |||
2009 | self.__xfilter_ena = False |
|
2004 | self.__xfilter_ena = False | |
2010 | self.__yfilter_ena = False |
|
2005 | self.__yfilter_ena = False | |
2011 |
|
2006 | |||
2012 | def getSubplots(self): |
|
2007 | def getSubplots(self): | |
2013 |
|
2008 | |||
2014 | ncol = 3 |
|
2009 | ncol = 3 | |
2015 | nrow = int(numpy.ceil(self.nplots/3.0)) |
|
2010 | nrow = int(numpy.ceil(self.nplots/3.0)) | |
2016 |
|
2011 | |||
2017 | return nrow, ncol |
|
2012 | return nrow, ncol | |
2018 |
|
2013 | |||
2019 | def setup(self, id, nplots, wintitle, show=True): |
|
2014 | def setup(self, id, nplots, wintitle, show=True): | |
2020 |
|
2015 | |||
2021 | self.nplots = nplots |
|
2016 | self.nplots = nplots | |
2022 |
|
2017 | |||
2023 | ncolspan = 1 |
|
2018 | ncolspan = 1 | |
2024 | colspan = 1 |
|
2019 | colspan = 1 | |
2025 |
|
2020 | |||
2026 | self.createFigure(id = id, |
|
2021 | self.createFigure(id = id, | |
2027 | wintitle = wintitle, |
|
2022 | wintitle = wintitle, | |
2028 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
2023 | widthplot = self.WIDTH + self.WIDTHPROF, | |
2029 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
2024 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
2030 | show=show) |
|
2025 | show=show) | |
2031 |
|
2026 | |||
2032 | nrow, ncol = self.getSubplots() |
|
2027 | nrow, ncol = self.getSubplots() | |
2033 |
|
2028 | |||
2034 | counter = 0 |
|
2029 | counter = 0 | |
2035 | for y in range(nrow): |
|
2030 | for y in range(nrow): | |
2036 | for x in range(ncol): |
|
2031 | for x in range(ncol): | |
2037 |
|
2032 | |||
2038 | if counter >= self.nplots: |
|
2033 | if counter >= self.nplots: | |
2039 | break |
|
2034 | break | |
2040 |
|
2035 | |||
2041 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
2036 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
2042 |
|
2037 | |||
2043 | counter += 1 |
|
2038 | counter += 1 | |
2044 |
|
2039 | |||
2045 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
2040 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
2046 | xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None, |
|
2041 | xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None, | |
2047 | vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA', |
|
2042 | vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA', | |
2048 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
2043 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
2049 | server=None, folder=None, username=None, password=None, |
|
2044 | server=None, folder=None, username=None, password=None, | |
2050 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False, |
|
2045 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False, | |
2051 | xaxis="frequency"): |
|
2046 | xaxis="frequency"): | |
2052 |
|
2047 | |||
2053 | """ |
|
2048 | """ | |
2054 |
|
2049 | |||
2055 | Input: |
|
2050 | Input: | |
2056 | dataOut : |
|
2051 | dataOut : | |
2057 | id : |
|
2052 | id : | |
2058 | wintitle : |
|
2053 | wintitle : | |
2059 | channelList : |
|
2054 | channelList : | |
2060 | showProfile : |
|
2055 | showProfile : | |
2061 | xmin : None, |
|
2056 | xmin : None, | |
2062 | xmax : None, |
|
2057 | xmax : None, | |
2063 | ymin : None, |
|
2058 | ymin : None, | |
2064 | ymax : None, |
|
2059 | ymax : None, | |
2065 | zmin : None, |
|
2060 | zmin : None, | |
2066 | zmax : None |
|
2061 | zmax : None | |
2067 | """ |
|
2062 | """ | |
2068 | #Rebuild matrix |
|
2063 | #Rebuild matrix | |
2069 | utctime = dataOut.data_param[0,0] |
|
2064 | utctime = dataOut.data_param[0,0] | |
2070 | cmet = dataOut.data_param[:,1].astype(int) |
|
2065 | cmet = dataOut.data_param[:,1].astype(int) | |
2071 | tmet = dataOut.data_param[:,2].astype(int) |
|
2066 | tmet = dataOut.data_param[:,2].astype(int) | |
2072 | hmet = dataOut.data_param[:,3].astype(int) |
|
2067 | hmet = dataOut.data_param[:,3].astype(int) | |
2073 |
|
2068 | |||
2074 | nParam = 3 |
|
2069 | nParam = 3 | |
2075 | nChan = len(dataOut.groupList) |
|
2070 | nChan = len(dataOut.groupList) | |
2076 | x = dataOut.abscissaList |
|
2071 | x = dataOut.abscissaList | |
2077 | y = dataOut.heightList |
|
2072 | y = dataOut.heightList | |
2078 |
|
2073 | |||
2079 | z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan) |
|
2074 | z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan) | |
2080 | z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:] |
|
2075 | z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:] | |
2081 | z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale |
|
2076 | z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale | |
2082 | z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1)) |
|
2077 | z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1)) | |
2083 |
|
2078 | |||
2084 | xlabel = "Time (s)" |
|
2079 | xlabel = "Time (s)" | |
2085 | ylabel = "Range (km)" |
|
2080 | ylabel = "Range (km)" | |
2086 |
|
2081 | |||
2087 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) |
|
2082 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | |
2088 |
|
2083 | |||
2089 | if not self.isConfig: |
|
2084 | if not self.isConfig: | |
2090 |
|
2085 | |||
2091 | nplots = nParam*nChan |
|
2086 | nplots = nParam*nChan | |
2092 |
|
2087 | |||
2093 | self.setup(id=id, |
|
2088 | self.setup(id=id, | |
2094 | nplots=nplots, |
|
2089 | nplots=nplots, | |
2095 | wintitle=wintitle, |
|
2090 | wintitle=wintitle, | |
2096 | show=show) |
|
2091 | show=show) | |
2097 |
|
2092 | |||
2098 | if xmin is None: xmin = numpy.nanmin(x) |
|
2093 | if xmin is None: xmin = numpy.nanmin(x) | |
2099 | if xmax is None: xmax = numpy.nanmax(x) |
|
2094 | if xmax is None: xmax = numpy.nanmax(x) | |
2100 | if ymin is None: ymin = numpy.nanmin(y) |
|
2095 | if ymin is None: ymin = numpy.nanmin(y) | |
2101 | if ymax is None: ymax = numpy.nanmax(y) |
|
2096 | if ymax is None: ymax = numpy.nanmax(y) | |
2102 | if SNRmin is None: SNRmin = numpy.nanmin(z[0,:]) |
|
2097 | if SNRmin is None: SNRmin = numpy.nanmin(z[0,:]) | |
2103 | if SNRmax is None: SNRmax = numpy.nanmax(z[0,:]) |
|
2098 | if SNRmax is None: SNRmax = numpy.nanmax(z[0,:]) | |
2104 | if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:])) |
|
2099 | if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:])) | |
2105 | if vmin is None: vmin = -vmax |
|
2100 | if vmin is None: vmin = -vmax | |
2106 | if wmin is None: wmin = 0 |
|
2101 | if wmin is None: wmin = 0 | |
2107 | if wmax is None: wmax = 50 |
|
2102 | if wmax is None: wmax = 50 | |
2108 |
|
2103 | |||
2109 | self.nChannels = nChan |
|
2104 | self.nChannels = nChan | |
2110 |
|
2105 | |||
2111 | zminList = [] |
|
2106 | zminList = [] | |
2112 | zmaxList = [] |
|
2107 | zmaxList = [] | |
2113 | titleList = [] |
|
2108 | titleList = [] | |
2114 | cmapList = [] |
|
2109 | cmapList = [] | |
2115 | for i in range(self.nChannels): |
|
2110 | for i in range(self.nChannels): | |
2116 | strAux1 = "SNR Channel "+ str(i) |
|
2111 | strAux1 = "SNR Channel "+ str(i) | |
2117 | strAux2 = "Radial Velocity Channel "+ str(i) |
|
2112 | strAux2 = "Radial Velocity Channel "+ str(i) | |
2118 | strAux3 = "Spectral Width Channel "+ str(i) |
|
2113 | strAux3 = "Spectral Width Channel "+ str(i) | |
2119 |
|
2114 | |||
2120 | titleList = titleList + [strAux1,strAux2,strAux3] |
|
2115 | titleList = titleList + [strAux1,strAux2,strAux3] | |
2121 | cmapList = cmapList + ["jet","RdBu_r","jet"] |
|
2116 | cmapList = cmapList + ["jet","RdBu_r","jet"] | |
2122 | zminList = zminList + [SNRmin,vmin,wmin] |
|
2117 | zminList = zminList + [SNRmin,vmin,wmin] | |
2123 | zmaxList = zmaxList + [SNRmax,vmax,wmax] |
|
2118 | zmaxList = zmaxList + [SNRmax,vmax,wmax] | |
2124 |
|
2119 | |||
2125 | self.zminList = zminList |
|
2120 | self.zminList = zminList | |
2126 | self.zmaxList = zmaxList |
|
2121 | self.zmaxList = zmaxList | |
2127 | self.cmapList = cmapList |
|
2122 | self.cmapList = cmapList | |
2128 | self.titleList = titleList |
|
2123 | self.titleList = titleList | |
2129 |
|
2124 | |||
2130 | self.FTP_WEI = ftp_wei |
|
2125 | self.FTP_WEI = ftp_wei | |
2131 | self.EXP_CODE = exp_code |
|
2126 | self.EXP_CODE = exp_code | |
2132 | self.SUB_EXP_CODE = sub_exp_code |
|
2127 | self.SUB_EXP_CODE = sub_exp_code | |
2133 | self.PLOT_POS = plot_pos |
|
2128 | self.PLOT_POS = plot_pos | |
2134 |
|
2129 | |||
2135 | self.isConfig = True |
|
2130 | self.isConfig = True | |
2136 |
|
2131 | |||
2137 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
2132 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
2138 |
|
2133 | |||
2139 | for i in range(self.nplots): |
|
2134 | for i in range(self.nplots): | |
2140 | title = self.titleList[i] + ": " +str_datetime |
|
2135 | title = self.titleList[i] + ": " +str_datetime | |
2141 | axes = self.axesList[i] |
|
2136 | axes = self.axesList[i] | |
2142 | axes.pcolor(x, y, z[i,:].T, |
|
2137 | axes.pcolor(x, y, z[i,:].T, | |
2143 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i], |
|
2138 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i], | |
2144 | xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='') |
|
2139 | xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='') | |
2145 | self.draw() |
|
2140 | self.draw() | |
2146 |
|
2141 | |||
2147 | if figfile == None: |
|
2142 | if figfile == None: | |
2148 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
2143 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
2149 | name = str_datetime |
|
2144 | name = str_datetime | |
2150 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
2145 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
2151 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) |
|
2146 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | |
2152 | figfile = self.getFilename(name) |
|
2147 | figfile = self.getFilename(name) | |
2153 |
|
2148 | |||
2154 | self.save(figpath=figpath, |
|
2149 | self.save(figpath=figpath, | |
2155 | figfile=figfile, |
|
2150 | figfile=figfile, | |
2156 | save=save, |
|
2151 | save=save, | |
2157 | ftp=ftp, |
|
2152 | ftp=ftp, | |
2158 | wr_period=wr_period, |
|
2153 | wr_period=wr_period, | |
2159 | thisDatetime=thisDatetime) |
|
2154 | thisDatetime=thisDatetime) |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,364 +1,364 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Nov 9, 2016 |
|
2 | Created on Nov 9, 2016 | |
3 |
|
3 | |||
4 | @author: roj- LouVD |
|
4 | @author: roj- LouVD | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 |
|
7 | |||
8 | import os |
|
8 | import os | |
9 | import sys |
|
9 | import sys | |
10 | import time |
|
10 | import time | |
11 | import glob |
|
11 | import glob | |
12 | import datetime |
|
12 | import datetime | |
|
13 | ||||
13 | import numpy |
|
14 | import numpy | |
14 |
|
15 | |||
15 | from schainpy.model.proc.jroproc_base import ProcessingUnit |
|
16 | from schainpy.model.proc.jroproc_base import ProcessingUnit | |
16 | from schainpy.model.data.jrodata import Parameters |
|
17 | from schainpy.model.data.jrodata import Parameters | |
17 | from schainpy.model.io.jroIO_base import JRODataReader, isNumber |
|
18 | from schainpy.model.io.jroIO_base import JRODataReader, isNumber | |
18 |
|
19 | |||
19 | FILE_HEADER_STRUCTURE = numpy.dtype([ |
|
20 | FILE_HEADER_STRUCTURE = numpy.dtype([ | |
20 | ('FMN', '<u4'), |
|
21 | ('FMN', '<u4'), | |
21 | ('nrec', '<u4'), |
|
22 | ('nrec', '<u4'), | |
22 | ('fr_offset', '<u4'), |
|
23 | ('fr_offset', '<u4'), | |
23 | ('id', '<u4'), |
|
24 | ('id', '<u4'), | |
24 | ('site', 'u1', (32,)) |
|
25 | ('site', 'u1', (32,)) | |
25 | ]) |
|
26 | ]) | |
26 |
|
27 | |||
27 | REC_HEADER_STRUCTURE = numpy.dtype([ |
|
28 | REC_HEADER_STRUCTURE = numpy.dtype([ | |
28 | ('rmn', '<u4'), |
|
29 | ('rmn', '<u4'), | |
29 | ('rcounter', '<u4'), |
|
30 | ('rcounter', '<u4'), | |
30 | ('nr_offset', '<u4'), |
|
31 | ('nr_offset', '<u4'), | |
31 | ('tr_offset', '<u4'), |
|
32 | ('tr_offset', '<u4'), | |
32 | ('time', '<u4'), |
|
33 | ('time', '<u4'), | |
33 | ('time_msec', '<u4'), |
|
34 | ('time_msec', '<u4'), | |
34 | ('tag', 'u1', (32,)), |
|
35 | ('tag', 'u1', (32,)), | |
35 | ('comments', 'u1', (32,)), |
|
36 | ('comments', 'u1', (32,)), | |
36 | ('lat', '<f4'), |
|
37 | ('lat', '<f4'), | |
37 | ('lon', '<f4'), |
|
38 | ('lon', '<f4'), | |
38 | ('gps_status', '<u4'), |
|
39 | ('gps_status', '<u4'), | |
39 | ('freq', '<u4'), |
|
40 | ('freq', '<u4'), | |
40 | ('freq0', '<u4'), |
|
41 | ('freq0', '<u4'), | |
41 | ('nchan', '<u4'), |
|
42 | ('nchan', '<u4'), | |
42 | ('delta_r', '<u4'), |
|
43 | ('delta_r', '<u4'), | |
43 | ('nranges', '<u4'), |
|
44 | ('nranges', '<u4'), | |
44 | ('r0', '<u4'), |
|
45 | ('r0', '<u4'), | |
45 | ('prf', '<u4'), |
|
46 | ('prf', '<u4'), | |
46 | ('ncoh', '<u4'), |
|
47 | ('ncoh', '<u4'), | |
47 | ('npoints', '<u4'), |
|
48 | ('npoints', '<u4'), | |
48 | ('polarization', '<i4'), |
|
49 | ('polarization', '<i4'), | |
49 | ('rx_filter', '<u4'), |
|
50 | ('rx_filter', '<u4'), | |
50 | ('nmodes', '<u4'), |
|
51 | ('nmodes', '<u4'), | |
51 | ('dmode_index', '<u4'), |
|
52 | ('dmode_index', '<u4'), | |
52 | ('dmode_rngcorr', '<u4'), |
|
53 | ('dmode_rngcorr', '<u4'), | |
53 | ('nrxs', '<u4'), |
|
54 | ('nrxs', '<u4'), | |
54 | ('acf_length', '<u4'), |
|
55 | ('acf_length', '<u4'), | |
55 | ('acf_lags', '<u4'), |
|
56 | ('acf_lags', '<u4'), | |
56 | ('sea_to_atmos', '<f4'), |
|
57 | ('sea_to_atmos', '<f4'), | |
57 | ('sea_notch', '<u4'), |
|
58 | ('sea_notch', '<u4'), | |
58 | ('lh_sea', '<u4'), |
|
59 | ('lh_sea', '<u4'), | |
59 | ('hh_sea', '<u4'), |
|
60 | ('hh_sea', '<u4'), | |
60 | ('nbins_sea', '<u4'), |
|
61 | ('nbins_sea', '<u4'), | |
61 | ('min_snr', '<f4'), |
|
62 | ('min_snr', '<f4'), | |
62 | ('min_cc', '<f4'), |
|
63 | ('min_cc', '<f4'), | |
63 | ('max_time_diff', '<f4') |
|
64 | ('max_time_diff', '<f4') | |
64 | ]) |
|
65 | ]) | |
65 |
|
66 | |||
66 | DATA_STRUCTURE = numpy.dtype([ |
|
67 | DATA_STRUCTURE = numpy.dtype([ | |
67 | ('range', '<u4'), |
|
68 | ('range', '<u4'), | |
68 | ('status', '<u4'), |
|
69 | ('status', '<u4'), | |
69 | ('zonal', '<f4'), |
|
70 | ('zonal', '<f4'), | |
70 | ('meridional', '<f4'), |
|
71 | ('meridional', '<f4'), | |
71 | ('vertical', '<f4'), |
|
72 | ('vertical', '<f4'), | |
72 | ('zonal_a', '<f4'), |
|
73 | ('zonal_a', '<f4'), | |
73 | ('meridional_a', '<f4'), |
|
74 | ('meridional_a', '<f4'), | |
74 | ('corrected_fading', '<f4'), # seconds |
|
75 | ('corrected_fading', '<f4'), # seconds | |
75 | ('uncorrected_fading', '<f4'), # seconds |
|
76 | ('uncorrected_fading', '<f4'), # seconds | |
76 | ('time_diff', '<f4'), |
|
77 | ('time_diff', '<f4'), | |
77 | ('major_axis', '<f4'), |
|
78 | ('major_axis', '<f4'), | |
78 | ('axial_ratio', '<f4'), |
|
79 | ('axial_ratio', '<f4'), | |
79 | ('orientation', '<f4'), |
|
80 | ('orientation', '<f4'), | |
80 | ('sea_power', '<u4'), |
|
81 | ('sea_power', '<u4'), | |
81 | ('sea_algorithm', '<u4') |
|
82 | ('sea_algorithm', '<u4') | |
82 | ]) |
|
83 | ]) | |
83 |
|
84 | |||
84 | class BLTRParamReader(JRODataReader, ProcessingUnit): |
|
85 | class BLTRParamReader(JRODataReader, ProcessingUnit): | |
85 | ''' |
|
86 | ''' | |
86 | Boundary Layer and Tropospheric Radar (BLTR) reader, Wind velocities and SNR from *.sswma files |
|
87 | Boundary Layer and Tropospheric Radar (BLTR) reader, Wind velocities and SNR from *.sswma files | |
87 | ''' |
|
88 | ''' | |
88 |
|
89 | |||
89 | ext = '.sswma' |
|
90 | ext = '.sswma' | |
90 |
|
91 | |||
91 | def __init__(self, **kwargs): |
|
92 | def __init__(self, **kwargs): | |
92 |
|
93 | |||
93 | ProcessingUnit.__init__(self , **kwargs) |
|
94 | ProcessingUnit.__init__(self , **kwargs) | |
94 |
|
95 | |||
95 | self.dataOut = Parameters() |
|
96 | self.dataOut = Parameters() | |
96 | self.counter_records = 0 |
|
97 | self.counter_records = 0 | |
97 | self.flagNoMoreFiles = 0 |
|
98 | self.flagNoMoreFiles = 0 | |
98 | self.isConfig = False |
|
99 | self.isConfig = False | |
99 | self.filename = None |
|
100 | self.filename = None | |
100 |
|
101 | |||
101 | def setup(self, |
|
102 | def setup(self, | |
102 | path=None, |
|
103 | path=None, | |
103 | startDate=None, |
|
104 | startDate=None, | |
104 | endDate=None, |
|
105 | endDate=None, | |
105 | ext=None, |
|
106 | ext=None, | |
106 | startTime=datetime.time(0, 0, 0), |
|
107 | startTime=datetime.time(0, 0, 0), | |
107 | endTime=datetime.time(23, 59, 59), |
|
108 | endTime=datetime.time(23, 59, 59), | |
108 | timezone=0, |
|
109 | timezone=0, | |
109 | status_value=0, |
|
110 | status_value=0, | |
110 | **kwargs): |
|
111 | **kwargs): | |
111 |
|
112 | |||
112 | self.path = path |
|
113 | self.path = path | |
113 | self.startTime = startTime |
|
114 | self.startTime = startTime | |
114 | self.endTime = endTime |
|
115 | self.endTime = endTime | |
115 | self.status_value = status_value |
|
116 | self.status_value = status_value | |
116 |
|
117 | |||
117 | if self.path is None: |
|
118 | if self.path is None: | |
118 | raise ValueError, "The path is not valid" |
|
119 | raise ValueError, "The path is not valid" | |
119 |
|
120 | |||
120 | if ext is None: |
|
121 | if ext is None: | |
121 | ext = self.ext |
|
122 | ext = self.ext | |
122 |
|
123 | |||
123 | self.search_files(self.path, startDate, endDate, ext) |
|
124 | self.search_files(self.path, startDate, endDate, ext) | |
124 | self.timezone = timezone |
|
125 | self.timezone = timezone | |
125 | self.fileIndex = 0 |
|
126 | self.fileIndex = 0 | |
126 |
|
127 | |||
127 | if not self.fileList: |
|
128 | if not self.fileList: | |
128 | raise Warning, "There is no files matching these date in the folder: %s. \n Check 'startDate' and 'endDate' "%(path) |
|
129 | raise Warning, "There is no files matching these date in the folder: %s. \n Check 'startDate' and 'endDate' "%(path) | |
129 |
|
130 | |||
130 | self.setNextFile() |
|
131 | self.setNextFile() | |
131 |
|
132 | |||
132 | def search_files(self, path, startDate, endDate, ext): |
|
133 | def search_files(self, path, startDate, endDate, ext): | |
133 | ''' |
|
134 | ''' | |
134 | Searching for BLTR rawdata file in path |
|
135 | Searching for BLTR rawdata file in path | |
135 | Creating a list of file to proces included in [startDate,endDate] |
|
136 | Creating a list of file to proces included in [startDate,endDate] | |
136 |
|
137 | |||
137 | Input: |
|
138 | Input: | |
138 | path - Path to find BLTR rawdata files |
|
139 | path - Path to find BLTR rawdata files | |
139 | startDate - Select file from this date |
|
140 | startDate - Select file from this date | |
140 | enDate - Select file until this date |
|
141 | enDate - Select file until this date | |
141 | ext - Extension of the file to read |
|
142 | ext - Extension of the file to read | |
142 |
|
143 | |||
143 | ''' |
|
144 | ''' | |
144 |
|
145 | |||
145 | print 'Searching file in %s ' % (path) |
|
146 | print 'Searching file in %s ' % (path) | |
146 | foldercounter = 0 |
|
147 | foldercounter = 0 | |
147 | fileList0 = glob.glob1(path, "*%s" % ext) |
|
148 | fileList0 = glob.glob1(path, "*%s" % ext) | |
148 | fileList0.sort() |
|
149 | fileList0.sort() | |
149 |
|
150 | |||
150 | self.fileList = [] |
|
151 | self.fileList = [] | |
151 | self.dateFileList = [] |
|
152 | self.dateFileList = [] | |
152 |
|
153 | |||
153 | for thisFile in fileList0: |
|
154 | for thisFile in fileList0: | |
154 | year = thisFile[-14:-10] |
|
155 | year = thisFile[-14:-10] | |
155 | if not isNumber(year): |
|
156 | if not isNumber(year): | |
156 | continue |
|
157 | continue | |
157 |
|
158 | |||
158 | month = thisFile[-10:-8] |
|
159 | month = thisFile[-10:-8] | |
159 | if not isNumber(month): |
|
160 | if not isNumber(month): | |
160 | continue |
|
161 | continue | |
161 |
|
162 | |||
162 | day = thisFile[-8:-6] |
|
163 | day = thisFile[-8:-6] | |
163 | if not isNumber(day): |
|
164 | if not isNumber(day): | |
164 | continue |
|
165 | continue | |
165 |
|
166 | |||
166 | year, month, day = int(year), int(month), int(day) |
|
167 | year, month, day = int(year), int(month), int(day) | |
167 | dateFile = datetime.date(year, month, day) |
|
168 | dateFile = datetime.date(year, month, day) | |
168 |
|
169 | |||
169 | if (startDate > dateFile) or (endDate < dateFile): |
|
170 | if (startDate > dateFile) or (endDate < dateFile): | |
170 | continue |
|
171 | continue | |
171 |
|
172 | |||
172 | self.fileList.append(thisFile) |
|
173 | self.fileList.append(thisFile) | |
173 | self.dateFileList.append(dateFile) |
|
174 | self.dateFileList.append(dateFile) | |
174 |
|
175 | |||
175 | return |
|
176 | return | |
176 |
|
177 | |||
177 | def setNextFile(self): |
|
178 | def setNextFile(self): | |
178 |
|
179 | |||
179 | file_id = self.fileIndex |
|
180 | file_id = self.fileIndex | |
180 |
|
181 | |||
181 | if file_id == len(self.fileList): |
|
182 | if file_id == len(self.fileList): | |
182 | print '\nNo more files in the folder' |
|
183 | print '\nNo more files in the folder' | |
183 | print 'Total number of file(s) read : {}'.format(self.fileIndex + 1) |
|
184 | print 'Total number of file(s) read : {}'.format(self.fileIndex + 1) | |
184 | self.flagNoMoreFiles = 1 |
|
185 | self.flagNoMoreFiles = 1 | |
185 | return 0 |
|
186 | return 0 | |
186 |
|
187 | |||
187 | print '\n[Setting file] (%s) ...' % self.fileList[file_id] |
|
188 | print '\n[Setting file] (%s) ...' % self.fileList[file_id] | |
188 | filename = os.path.join(self.path, self.fileList[file_id]) |
|
189 | filename = os.path.join(self.path, self.fileList[file_id]) | |
189 |
|
190 | |||
190 | dirname, name = os.path.split(filename) |
|
191 | dirname, name = os.path.split(filename) | |
191 | self.siteFile = name.split('.')[0] # 'peru2' ---> Piura - 'peru1' ---> Huancayo or Porcuya |
|
192 | self.siteFile = name.split('.')[0] # 'peru2' ---> Piura - 'peru1' ---> Huancayo or Porcuya | |
192 | if self.filename is not None: |
|
193 | if self.filename is not None: | |
193 | self.fp.close() |
|
194 | self.fp.close() | |
194 | self.filename = filename |
|
195 | self.filename = filename | |
195 | self.fp = open(self.filename, 'rb') |
|
196 | self.fp = open(self.filename, 'rb') | |
196 | self.header_file = numpy.fromfile(self.fp, FILE_HEADER_STRUCTURE, 1) |
|
197 | self.header_file = numpy.fromfile(self.fp, FILE_HEADER_STRUCTURE, 1) | |
197 | self.nrecords = self.header_file['nrec'][0] |
|
198 | self.nrecords = self.header_file['nrec'][0] | |
198 | self.sizeOfFile = os.path.getsize(self.filename) |
|
199 | self.sizeOfFile = os.path.getsize(self.filename) | |
199 | self.counter_records = 0 |
|
200 | self.counter_records = 0 | |
200 | self.flagIsNewFile = 0 |
|
201 | self.flagIsNewFile = 0 | |
201 | self.fileIndex += 1 |
|
202 | self.fileIndex += 1 | |
202 |
|
203 | |||
203 | return 1 |
|
204 | return 1 | |
204 |
|
205 | |||
205 | def readNextBlock(self): |
|
206 | def readNextBlock(self): | |
206 |
|
207 | |||
207 | while True: |
|
208 | while True: | |
208 | if self.counter_records == self.nrecords: |
|
209 | if self.counter_records == self.nrecords: | |
209 | self.flagIsNewFile = 1 |
|
210 | self.flagIsNewFile = 1 | |
210 | if not self.setNextFile(): |
|
211 | if not self.setNextFile(): | |
211 | return 0 |
|
212 | return 0 | |
212 |
|
213 | |||
213 | self.readBlock() |
|
214 | self.readBlock() | |
214 |
|
215 | |||
215 | if (self.datatime.time() < self.startTime) or (self.datatime.time() > self.endTime): |
|
216 | if (self.datatime.time() < self.startTime) or (self.datatime.time() > self.endTime): | |
216 | print "[Reading] Record No. %d/%d -> %s [Skipping]" %( |
|
217 | print "[Reading] Record No. %d/%d -> %s [Skipping]" %( | |
217 | self.counter_records, |
|
218 | self.counter_records, | |
218 | self.nrecords, |
|
219 | self.nrecords, | |
219 | self.datatime.ctime()) |
|
220 | self.datatime.ctime()) | |
220 | continue |
|
221 | continue | |
221 | break |
|
222 | break | |
222 |
|
223 | |||
223 | print "[Reading] Record No. %d/%d -> %s" %( |
|
224 | print "[Reading] Record No. %d/%d -> %s" %( | |
224 | self.counter_records, |
|
225 | self.counter_records, | |
225 | self.nrecords, |
|
226 | self.nrecords, | |
226 | self.datatime.ctime()) |
|
227 | self.datatime.ctime()) | |
227 |
|
228 | |||
228 | return 1 |
|
229 | return 1 | |
229 |
|
230 | |||
230 | def readBlock(self): |
|
231 | def readBlock(self): | |
231 |
|
232 | |||
232 | pointer = self.fp.tell() |
|
233 | pointer = self.fp.tell() | |
233 | header_rec = numpy.fromfile(self.fp, REC_HEADER_STRUCTURE, 1) |
|
234 | header_rec = numpy.fromfile(self.fp, REC_HEADER_STRUCTURE, 1) | |
234 | self.nchannels = header_rec['nchan'][0]/2 |
|
235 | self.nchannels = header_rec['nchan'][0]/2 | |
235 | self.kchan = header_rec['nrxs'][0] |
|
236 | self.kchan = header_rec['nrxs'][0] | |
236 | self.nmodes = header_rec['nmodes'][0] |
|
237 | self.nmodes = header_rec['nmodes'][0] | |
237 | self.nranges = header_rec['nranges'][0] |
|
238 | self.nranges = header_rec['nranges'][0] | |
238 | self.fp.seek(pointer) |
|
239 | self.fp.seek(pointer) | |
239 | self.height = numpy.empty((self.nmodes, self.nranges)) |
|
240 | self.height = numpy.empty((self.nmodes, self.nranges)) | |
240 | self.snr = numpy.empty((self.nmodes, self.nchannels, self.nranges)) |
|
241 | self.snr = numpy.empty((self.nmodes, self.nchannels, self.nranges)) | |
241 | self.buffer = numpy.empty((self.nmodes, 3, self.nranges)) |
|
242 | self.buffer = numpy.empty((self.nmodes, 3, self.nranges)) | |
242 |
|
243 | |||
243 | for mode in range(self.nmodes): |
|
244 | for mode in range(self.nmodes): | |
244 | self.readHeader() |
|
245 | self.readHeader() | |
245 | data = self.readData() |
|
246 | data = self.readData() | |
246 | self.height[mode] = (data[0] - self.correction) / 1000. |
|
247 | self.height[mode] = (data[0] - self.correction) / 1000. | |
247 | self.buffer[mode] = data[1] |
|
248 | self.buffer[mode] = data[1] | |
248 | self.snr[mode] = data[2] |
|
249 | self.snr[mode] = data[2] | |
249 |
|
250 | |||
250 | self.counter_records = self.counter_records + self.nmodes |
|
251 | self.counter_records = self.counter_records + self.nmodes | |
251 |
|
252 | |||
252 | return |
|
253 | return | |
253 |
|
254 | |||
254 | def readHeader(self): |
|
255 | def readHeader(self): | |
255 | ''' |
|
256 | ''' | |
256 | RecordHeader of BLTR rawdata file |
|
257 | RecordHeader of BLTR rawdata file | |
257 | ''' |
|
258 | ''' | |
258 |
|
259 | |||
259 | header_structure = numpy.dtype( |
|
260 | header_structure = numpy.dtype( | |
260 | REC_HEADER_STRUCTURE.descr + [ |
|
261 | REC_HEADER_STRUCTURE.descr + [ | |
261 | ('antenna_coord', 'f4', (2, self.nchannels)), |
|
262 | ('antenna_coord', 'f4', (2, self.nchannels)), | |
262 | ('rx_gains', 'u4', (self.nchannels,)), |
|
263 | ('rx_gains', 'u4', (self.nchannels,)), | |
263 | ('rx_analysis', 'u4', (self.nchannels,)) |
|
264 | ('rx_analysis', 'u4', (self.nchannels,)) | |
264 | ] |
|
265 | ] | |
265 | ) |
|
266 | ) | |
266 |
|
267 | |||
267 | self.header_rec = numpy.fromfile(self.fp, header_structure, 1) |
|
268 | self.header_rec = numpy.fromfile(self.fp, header_structure, 1) | |
268 | self.lat = self.header_rec['lat'][0] |
|
269 | self.lat = self.header_rec['lat'][0] | |
269 | self.lon = self.header_rec['lon'][0] |
|
270 | self.lon = self.header_rec['lon'][0] | |
270 | self.delta = self.header_rec['delta_r'][0] |
|
271 | self.delta = self.header_rec['delta_r'][0] | |
271 | self.correction = self.header_rec['dmode_rngcorr'][0] |
|
272 | self.correction = self.header_rec['dmode_rngcorr'][0] | |
272 | self.imode = self.header_rec['dmode_index'][0] |
|
273 | self.imode = self.header_rec['dmode_index'][0] | |
273 | self.antenna = self.header_rec['antenna_coord'] |
|
274 | self.antenna = self.header_rec['antenna_coord'] | |
274 | self.rx_gains = self.header_rec['rx_gains'] |
|
275 | self.rx_gains = self.header_rec['rx_gains'] | |
275 |
self.time |
|
276 | self.time = self.header_rec['time'][0] | |
276 | tseconds = self.header_rec['time'][0] |
|
277 | tseconds = self.header_rec['time'][0] | |
277 | local_t1 = time.localtime(tseconds) |
|
278 | local_t1 = time.localtime(tseconds) | |
278 | self.year = local_t1.tm_year |
|
279 | self.year = local_t1.tm_year | |
279 | self.month = local_t1.tm_mon |
|
280 | self.month = local_t1.tm_mon | |
280 | self.day = local_t1.tm_mday |
|
281 | self.day = local_t1.tm_mday | |
281 | self.t = datetime.datetime(self.year, self.month, self.day) |
|
282 | self.t = datetime.datetime(self.year, self.month, self.day) | |
282 |
self.datatime = datetime.datetime.utcfromtimestamp(self.time |
|
283 | self.datatime = datetime.datetime.utcfromtimestamp(self.time) | |
283 |
|
284 | |||
284 | def readData(self): |
|
285 | def readData(self): | |
285 | ''' |
|
286 | ''' | |
286 | Reading and filtering data block record of BLTR rawdata file, filtering is according to status_value. |
|
287 | Reading and filtering data block record of BLTR rawdata file, filtering is according to status_value. | |
287 |
|
288 | |||
288 | Input: |
|
289 | Input: | |
289 | status_value - Array data is set to NAN for values that are not equal to status_value |
|
290 | status_value - Array data is set to NAN for values that are not equal to status_value | |
290 |
|
291 | |||
291 | ''' |
|
292 | ''' | |
292 |
|
293 | |||
293 | data_structure = numpy.dtype( |
|
294 | data_structure = numpy.dtype( | |
294 | DATA_STRUCTURE.descr + [ |
|
295 | DATA_STRUCTURE.descr + [ | |
295 | ('rx_saturation', 'u4', (self.nchannels,)), |
|
296 | ('rx_saturation', 'u4', (self.nchannels,)), | |
296 | ('chan_offset', 'u4', (2 * self.nchannels,)), |
|
297 | ('chan_offset', 'u4', (2 * self.nchannels,)), | |
297 | ('rx_amp', 'u4', (self.nchannels,)), |
|
298 | ('rx_amp', 'u4', (self.nchannels,)), | |
298 | ('rx_snr', 'f4', (self.nchannels,)), |
|
299 | ('rx_snr', 'f4', (self.nchannels,)), | |
299 | ('cross_snr', 'f4', (self.kchan,)), |
|
300 | ('cross_snr', 'f4', (self.kchan,)), | |
300 | ('sea_power_relative', 'f4', (self.kchan,))] |
|
301 | ('sea_power_relative', 'f4', (self.kchan,))] | |
301 | ) |
|
302 | ) | |
302 |
|
303 | |||
303 | data = numpy.fromfile(self.fp, data_structure, self.nranges) |
|
304 | data = numpy.fromfile(self.fp, data_structure, self.nranges) | |
304 |
|
305 | |||
305 | height = data['range'] |
|
306 | height = data['range'] | |
306 | winds = numpy.array((data['zonal'], data['meridional'], data['vertical'])) |
|
307 | winds = numpy.array((data['zonal'], data['meridional'], data['vertical'])) | |
307 | snr = data['rx_snr'].T |
|
308 | snr = data['rx_snr'].T | |
308 |
|
309 | |||
309 |
winds[numpy.where(winds == -9999.)] = numpy.nan |
|
310 | winds[numpy.where(winds == -9999.)] = numpy.nan | |
310 | winds[:, numpy.where(data['status'] != self.status_value)] = numpy.nan |
|
311 | winds[:, numpy.where(data['status'] != self.status_value)] = numpy.nan | |
311 | snr[numpy.where(snr == -9999.)] = numpy.nan |
|
312 | snr[numpy.where(snr == -9999.)] = numpy.nan | |
312 | snr[:, numpy.where(data['status'] != self.status_value)] = numpy.nan |
|
313 | snr[:, numpy.where(data['status'] != self.status_value)] = numpy.nan | |
313 | snr = numpy.power(10, snr / 10) |
|
314 | snr = numpy.power(10, snr / 10) | |
314 |
|
315 | |||
315 | return height, winds, snr |
|
316 | return height, winds, snr | |
316 |
|
317 | |||
317 | def set_output(self): |
|
318 | def set_output(self): | |
318 | ''' |
|
319 | ''' | |
319 | Storing data from databuffer to dataOut object |
|
320 | Storing data from databuffer to dataOut object | |
320 | ''' |
|
321 | ''' | |
321 |
|
322 | |||
322 | self.dataOut.time1 = self.time1 |
|
|||
323 | self.dataOut.data_SNR = self.snr |
|
323 | self.dataOut.data_SNR = self.snr | |
324 | self.dataOut.height= self.height |
|
324 | self.dataOut.height = self.height | |
325 | self.dataOut.data_output = self.buffer |
|
325 | self.dataOut.data_output = self.buffer | |
326 |
self.dataOut.utctimeInit = self.time |
|
326 | self.dataOut.utctimeInit = self.time | |
327 | self.dataOut.utctime = self.dataOut.utctimeInit |
|
327 | self.dataOut.utctime = self.dataOut.utctimeInit | |
328 | self.dataOut.counter_records = self.counter_records |
|
328 | self.dataOut.counter_records = self.counter_records | |
329 | self.dataOut.nrecords = self.nrecords |
|
329 | self.dataOut.nrecords = self.nrecords | |
330 | self.dataOut.useLocalTime = False |
|
330 | self.dataOut.useLocalTime = False | |
331 | self.dataOut.paramInterval = 157 |
|
331 | self.dataOut.paramInterval = 157 | |
332 | self.dataOut.timezone = self.timezone |
|
332 | self.dataOut.timezone = self.timezone | |
333 | self.dataOut.site = self.siteFile |
|
333 | self.dataOut.site = self.siteFile | |
334 | self.dataOut.nrecords = self.nrecords |
|
334 | self.dataOut.nrecords = self.nrecords | |
335 | self.dataOut.sizeOfFile = self.sizeOfFile |
|
335 | self.dataOut.sizeOfFile = self.sizeOfFile | |
336 | self.dataOut.lat = self.lat |
|
336 | self.dataOut.lat = self.lat | |
337 |
self.dataOut.lon = self.lon |
|
337 | self.dataOut.lon = self.lon | |
338 | self.dataOut.channelList = range(self.nchannels) |
|
338 | self.dataOut.channelList = range(self.nchannels) | |
339 | self.dataOut.kchan = self.kchan |
|
339 | self.dataOut.kchan = self.kchan | |
340 | # self.dataOut.nHeights = self.nranges |
|
340 | # self.dataOut.nHeights = self.nranges | |
341 | self.dataOut.delta = self.delta |
|
341 | self.dataOut.delta = self.delta | |
342 | self.dataOut.correction = self.correction |
|
342 | self.dataOut.correction = self.correction | |
343 | self.dataOut.nmodes = self.nmodes |
|
343 | self.dataOut.nmodes = self.nmodes | |
344 | self.dataOut.imode = self.imode |
|
344 | self.dataOut.imode = self.imode | |
345 | self.dataOut.antenna = self.antenna |
|
345 | self.dataOut.antenna = self.antenna | |
346 | self.dataOut.rx_gains = self.rx_gains |
|
346 | self.dataOut.rx_gains = self.rx_gains | |
347 | self.dataOut.flagNoData = False |
|
347 | self.dataOut.flagNoData = False | |
348 |
|
348 | |||
349 | def getData(self): |
|
349 | def getData(self): | |
350 | ''' |
|
350 | ''' | |
351 | Storing data from databuffer to dataOut object |
|
351 | Storing data from databuffer to dataOut object | |
352 | ''' |
|
352 | ''' | |
353 | if self.flagNoMoreFiles: |
|
353 | if self.flagNoMoreFiles: | |
354 | self.dataOut.flagNoData = True |
|
354 | self.dataOut.flagNoData = True | |
355 | print 'No file left to process' |
|
355 | print 'No file left to process' | |
356 | return 0 |
|
356 | return 0 | |
357 |
|
357 | |||
358 |
if not |
|
358 | if not self.readNextBlock(): | |
359 | self.dataOut.flagNoData = True |
|
359 | self.dataOut.flagNoData = True | |
360 | return 0 |
|
360 | return 0 | |
361 |
|
361 | |||
362 | self.set_output() |
|
362 | self.set_output() | |
363 |
|
363 | |||
364 | return 1 |
|
364 | return 1 |
@@ -1,16 +1,15 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author: murco $ |
|
3 | $Author: murco $ | |
4 | $Id: Processor.py 1 2012-11-12 18:56:07Z murco $ |
|
4 | $Id: Processor.py 1 2012-11-12 18:56:07Z murco $ | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | from jroproc_voltage import * |
|
7 | from jroproc_voltage import * | |
8 | from jroproc_spectra import * |
|
8 | from jroproc_spectra import * | |
9 | from jroproc_heispectra import * |
|
9 | from jroproc_heispectra import * | |
10 | from jroproc_amisr import * |
|
10 | from jroproc_amisr import * | |
11 | from jroproc_correlation import * |
|
11 | from jroproc_correlation import * | |
12 | from jroproc_parameters import * |
|
12 | from jroproc_parameters import * | |
13 | from jroproc_spectra_lags import * |
|
13 | from jroproc_spectra_lags import * | |
14 | from jroproc_spectra_acf import * |
|
14 | from jroproc_spectra_acf import * | |
15 |
from |
|
15 | from bltrproc_parameters import * | |
16 |
|
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
@@ -1,564 +1,393 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Oct 24, 2016 |
|
2 | Created on Oct 24, 2016 | |
3 |
|
3 | |||
4 | @author: roj- LouVD |
|
4 | @author: roj- LouVD | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import numpy |
|
7 | import numpy | |
8 | import copy |
|
8 | import copy | |
9 | import datetime |
|
9 | import datetime | |
10 | import time |
|
10 | import time | |
11 | from time import gmtime |
|
11 | from time import gmtime | |
12 |
|
12 | |||
13 | from jroproc_base import ProcessingUnit |
|
|||
14 | from schainpy.model.data.jrodata import Parameters |
|
|||
15 | from numpy import transpose |
|
13 | from numpy import transpose | |
16 |
|
14 | |||
17 | from matplotlib import cm |
|
15 | from jroproc_base import ProcessingUnit, Operation | |
18 | import matplotlib.pyplot as plt |
|
16 | from schainpy.model.data.jrodata import Parameters | |
19 | from matplotlib.mlab import griddata |
|
|||
20 |
|
17 | |||
21 |
|
18 | |||
22 | class BLTRParametersProc(ProcessingUnit): |
|
19 | class BLTRParametersProc(ProcessingUnit): | |
23 | ''' |
|
20 | ''' | |
24 | Processing unit for BLTR parameters data (winds) |
|
21 | Processing unit for BLTR parameters data (winds) | |
25 |
|
22 | |||
26 | Inputs: |
|
23 | Inputs: | |
27 | self.dataOut.nmodes - Number of operation modes |
|
24 | self.dataOut.nmodes - Number of operation modes | |
28 | self.dataOut.nchannels - Number of channels |
|
25 | self.dataOut.nchannels - Number of channels | |
29 | self.dataOut.nranges - Number of ranges |
|
26 | self.dataOut.nranges - Number of ranges | |
30 |
|
27 | |||
31 | self.dataOut.data_SNR - SNR array |
|
28 | self.dataOut.data_SNR - SNR array | |
32 | self.dataOut.data_output - Zonal, Vertical and Meridional velocity array |
|
29 | self.dataOut.data_output - Zonal, Vertical and Meridional velocity array | |
33 | self.dataOut.height - Height array (km) |
|
30 | self.dataOut.height - Height array (km) | |
34 | self.dataOut.time - Time array (seconds) |
|
31 | self.dataOut.time - Time array (seconds) | |
35 |
|
32 | |||
36 | self.dataOut.fileIndex -Index of the file currently read |
|
33 | self.dataOut.fileIndex -Index of the file currently read | |
37 | self.dataOut.lat - Latitude coordinate of BLTR location |
|
34 | self.dataOut.lat - Latitude coordinate of BLTR location | |
38 |
|
35 | |||
39 | self.dataOut.doy - Experiment doy (number of the day in the current year) |
|
36 | self.dataOut.doy - Experiment doy (number of the day in the current year) | |
40 | self.dataOut.month - Experiment month |
|
37 | self.dataOut.month - Experiment month | |
41 | self.dataOut.day - Experiment day |
|
38 | self.dataOut.day - Experiment day | |
42 | self.dataOut.year - Experiment year |
|
39 | self.dataOut.year - Experiment year | |
43 | ''' |
|
40 | ''' | |
44 |
|
41 | |||
45 | def __init__(self, **kwargs): |
|
42 | def __init__(self, **kwargs): | |
46 | ''' |
|
43 | ''' | |
47 | Inputs: None |
|
44 | Inputs: None | |
48 | ''' |
|
45 | ''' | |
49 | ProcessingUnit.__init__(self, **kwargs) |
|
46 | ProcessingUnit.__init__(self, **kwargs) | |
50 | self.dataOut = Parameters() |
|
47 | self.dataOut = Parameters() | |
51 |
|
48 | |||
52 |
def run |
|
49 | def run(self, mode, snr_threshold=None): | |
53 | ''' |
|
50 | ''' | |
|
51 | ||||
|
52 | Inputs: | |||
|
53 | mode = High resolution (0) or Low resolution (1) data | |||
|
54 | snr_threshold = snr filter value | |||
54 | ''' |
|
55 | ''' | |
55 |
if self.dataIn.type == |
|
56 | if self.dataIn.type == 'Parameters': | |
56 | self.dataOut.copy(self.dataIn) |
|
57 | self.dataOut.copy(self.dataIn) | |
57 |
|
58 | |||
58 | self.dataOut.data_output = self.dataOut.data_output[mode] |
|
59 | self.dataOut.data_output = self.dataOut.data_output[mode] | |
59 |
self.dataOut.heightList = self.dataOut.height[ |
|
60 | self.dataOut.heightList = self.dataOut.height[0] | |
|
61 | self.dataOut.data_SNR = self.dataOut.data_SNR[mode] | |||
60 |
|
62 | |||
61 | def TimeSelect(self): |
|
63 | if snr_threshold is not None: | |
62 | ''' |
|
64 | SNRavg = numpy.average(self.dataOut.data_SNR, axis=0) | |
63 | Selecting the time array according to the day of the experiment with a duration of 24 hours |
|
65 | SNRavgdB = 10*numpy.log10(SNRavg) | |
64 | ''' |
|
66 | for i in range(3): | |
65 |
|
67 | self.dataOut.data_output[i][SNRavgdB <= snr_threshold] = numpy.nan | ||
66 | k1 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) - datetime.timedelta(hours=5) |
|
68 | ||
67 | k2 = datetime.datetime(self.dataOut.year, self.dataOut.month, self.dataOut.day) + datetime.timedelta(hours=25) - datetime.timedelta(hours=5) |
|
69 | # TODO | |
68 | limit_sec1 = time.mktime(k1.timetuple()) |
|
70 | class OutliersFilter(Operation): | |
69 | limit_sec2 = time.mktime(k2.timetuple()) |
|
71 | ||
70 | valid_data = 0 |
|
72 | def __init__(self, **kwargs): | |
71 |
|
||||
72 | doy = self.dataOut.doy |
|
|||
73 | t1 = numpy.where(self.dataOut.time[0, :] >= limit_sec1) |
|
|||
74 | t2 = numpy.where(self.dataOut.time[0, :] < limit_sec2) |
|
|||
75 | time_select = [] |
|
|||
76 | for val_sec in t1[0]: |
|
|||
77 | if val_sec in t2[0]: |
|
|||
78 | time_select.append(val_sec) |
|
|||
79 |
|
||||
80 | time_select = numpy.array(time_select, dtype='int') |
|
|||
81 | valid_data = valid_data + len(time_select) |
|
|||
82 |
|
||||
83 |
|
||||
84 | if len(time_select) > 0: |
|
|||
85 | self.f_timesec = self.dataOut.time[:, time_select] |
|
|||
86 | snr = self.dataOut.data_SNR[time_select, :, :, :] |
|
|||
87 | zon = self.dataOut.data_output[0][time_select, :, :] |
|
|||
88 | mer = self.dataOut.data_output[1][time_select, :, :] |
|
|||
89 | ver = self.dataOut.data_output[2][time_select, :, :] |
|
|||
90 |
|
||||
91 | if valid_data > 0: |
|
|||
92 | self.timesec1 = self.f_timesec[0, :] |
|
|||
93 | self.f_height = self.dataOut.height |
|
|||
94 | self.f_zon = zon |
|
|||
95 | self.f_mer = mer |
|
|||
96 | self.f_ver = ver |
|
|||
97 | self.f_snr = snr |
|
|||
98 | self.f_timedate = [] |
|
|||
99 | self.f_time = [] |
|
|||
100 |
|
||||
101 | for valuet in self.timesec1: |
|
|||
102 | time_t = time.gmtime(valuet) |
|
|||
103 | year = time_t.tm_year |
|
|||
104 | month = time_t.tm_mon |
|
|||
105 | day = time_t.tm_mday |
|
|||
106 | hour = time_t.tm_hour |
|
|||
107 | minute = time_t.tm_min |
|
|||
108 | second = time_t.tm_sec |
|
|||
109 | f_timedate_0 = datetime.datetime(year, month, day, hour, minute, second) |
|
|||
110 | self.f_timedate.append(f_timedate_0) |
|
|||
111 |
|
||||
112 | return self.f_timedate, self.f_timesec, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr |
|
|||
113 |
|
||||
114 | else: |
|
|||
115 | self.f_timesec = None |
|
|||
116 | self.f_timedate = None |
|
|||
117 | self.f_height = None |
|
|||
118 | self.f_zon = None |
|
|||
119 | self.f_mer = None |
|
|||
120 | self.f_ver = None |
|
|||
121 | self.f_snr = None |
|
|||
122 | print 'Invalid time' |
|
|||
123 |
|
||||
124 | return self.f_timedate, self.f_height, self.f_zon, self.f_mer, self.f_ver, self.f_snr |
|
|||
125 |
|
||||
126 | def SnrFilter(self, snr_val,modetofilter): |
|
|||
127 | ''' |
|
73 | ''' | |
128 | Inputs: snr_val - Threshold value |
|
|||
129 |
|
||||
130 | ''' |
|
74 | ''' | |
131 | if modetofilter!=2 and modetofilter!=1 : |
|
75 | Operation.__init__(self, **kwargs) | |
132 | raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter) |
|
|||
133 | m = modetofilter-1 |
|
|||
134 |
|
||||
135 | print ' SNR filter [mode {}]: SNR <= {}: data_output = NA'.format(modetofilter,snr_val) |
|
|||
136 | for k in range(self.dataOut.nchannels): |
|
|||
137 | for r in range(self.dataOut.nranges): |
|
|||
138 | if self.dataOut.data_SNR[r,k,m] <= snr_val: |
|
|||
139 | self.dataOut.data_output[2][r,m] = numpy.nan |
|
|||
140 | self.dataOut.data_output[1][r,m] = numpy.nan |
|
|||
141 | self.dataOut.data_output[0][r,m] = numpy.nan |
|
|||
142 |
|
||||
143 |
|
76 | |||
144 |
|
77 | def run(self, svalue2, method, factor, filter, npoints=9): | ||
145 | def OutliersFilter(self,modetofilter,svalue,svalue2,method,factor,filter,npoints): |
|
|||
146 | ''' |
|
78 | ''' | |
147 | Inputs: |
|
79 | Inputs: | |
148 | svalue - string to select array velocity |
|
80 | svalue - string to select array velocity | |
149 | svalue2 - string to choose axis filtering |
|
81 | svalue2 - string to choose axis filtering | |
150 | method - 0 for SMOOTH or 1 for MEDIAN |
|
82 | method - 0 for SMOOTH or 1 for MEDIAN | |
151 |
factor - number used to set threshold |
|
83 | factor - number used to set threshold | |
152 | filter - 1 for data filtering using the standard deviation criteria else 0 |
|
84 | filter - 1 for data filtering using the standard deviation criteria else 0 | |
153 | npoints - number of points for mask filter |
|
85 | npoints - number of points for mask filter | |
154 |
|
|
86 | ''' | |
155 | ''' |
|
87 | ||
156 | if modetofilter!=2 and modetofilter!=1 : |
|
88 | print ' Outliers Filter {} {} / threshold = {}'.format(svalue, svalue, factor) | |
157 | raise ValueError,'Mode to filter should be "1" or "2". {} is not valid, check "Modetofilter" value.'.format(modetofilter) |
|
89 | ||
158 |
|
||||
159 | m = modetofilter-1 |
|
|||
160 |
|
||||
161 | print ' Outliers Filter [mode {}]: {} {} / threshold = {}'.format(modetofilter,svalue,svalue,factor) |
|
|||
162 |
|
||||
163 | npoints = 9 |
|
|||
164 | novalid = 0.1 |
|
|||
165 | if svalue == 'zonal': |
|
|||
166 | value = self.dataOut.data_output[0] |
|
|||
167 |
|
||||
168 | elif svalue == 'meridional': |
|
|||
169 | value = self.dataOut.data_output[1] |
|
|||
170 |
|
||||
171 | elif svalue == 'vertical': |
|
|||
172 | value = self.dataOut.data_output[2] |
|
|||
173 |
|
||||
174 | else: |
|
|||
175 | print 'value is not defined' |
|
|||
176 | return |
|
|||
177 |
|
90 | |||
178 | if svalue2 == 'inTime': |
|
91 | yaxis = self.dataOut.heightList | |
179 | yaxis = self.dataOut.height |
|
92 | xaxis = numpy.array([[self.dataOut.utctime]]) | |
180 | xaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]]) |
|
|||
181 |
|
||||
182 | elif svalue2 == 'inHeight': |
|
|||
183 | yaxis = numpy.array([[self.dataOut.time1],[self.dataOut.time1]]) |
|
|||
184 | xaxis = self.dataOut.height |
|
|||
185 |
|
||||
186 | else: |
|
|||
187 | print 'svalue2 is required, either inHeight or inTime' |
|
|||
188 | return |
|
|||
189 |
|
93 | |||
190 | output_array = value |
|
94 | # Zonal | |
|
95 | value_temp = self.dataOut.data_output[0] | |||
191 |
|
96 | |||
192 | value_temp = value[:,m] |
|
97 | # Zonal | |
193 | error = numpy.zeros(len(self.dataOut.time[m,:])) |
|
98 | value_temp = self.dataOut.data_output[1] | |
194 | if svalue2 == 'inHeight': |
|
|||
195 | value_temp = numpy.transpose(value_temp) |
|
|||
196 | error = numpy.zeros(len(self.dataOut.height)) |
|
|||
197 |
|
99 | |||
198 | htemp = yaxis[m,:] |
|
100 | # Vertical | |
|
101 | value_temp = numpy.transpose(self.dataOut.data_output[2]) | |||
|
102 | ||||
|
103 | htemp = yaxis | |||
199 | std = value_temp |
|
104 | std = value_temp | |
200 | for h in range(len(htemp)): |
|
105 | for h in range(len(htemp)): | |
201 | if filter: #standard deviation filtering |
|
|||
202 | std[h] = numpy.std(value_temp[h],ddof = npoints) |
|
|||
203 | value_temp[numpy.where(std[h] > 5),h] = numpy.nan |
|
|||
204 | error[numpy.where(std[h] > 5)] = error[numpy.where(std[h] > 5)] + 1 |
|
|||
205 |
|
||||
206 |
|
||||
207 | nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0]) |
|
106 | nvalues_valid = len(numpy.where(numpy.isfinite(value_temp[h]))[0]) | |
208 |
minvalid = n |
|
107 | minvalid = npoints | |
209 | if minvalid <= npoints: |
|
|||
210 | minvalid = npoints |
|
|||
211 |
|
108 | |||
212 | #only if valid values greater than the minimum required (10%) |
|
109 | #only if valid values greater than the minimum required (10%) | |
213 | if nvalues_valid > minvalid: |
|
110 | if nvalues_valid > minvalid: | |
214 |
|
111 | |||
215 | if method == 0: |
|
112 | if method == 0: | |
216 | #SMOOTH |
|
113 | #SMOOTH | |
217 | w = value_temp[h] - self.Smooth(input=value_temp[h], width=npoints, edge_truncate=1) |
|
114 | w = value_temp[h] - self.Smooth(input=value_temp[h], width=npoints, edge_truncate=1) | |
218 |
|
115 | |||
219 |
|
116 | |||
220 | if method == 1: |
|
117 | if method == 1: | |
221 | #MEDIAN |
|
118 | #MEDIAN | |
222 | w = value_temp[h] - self.Median(input=value_temp[h], width = npoints) |
|
119 | w = value_temp[h] - self.Median(input=value_temp[h], width = npoints) | |
223 |
|
120 | |||
224 | dw = numpy.std(w[numpy.where(numpy.isfinite(w))],ddof = 1) |
|
121 | dw = numpy.std(w[numpy.where(numpy.isfinite(w))],ddof = 1) | |
225 |
|
122 | |||
226 | threshold = dw*factor |
|
123 | threshold = dw*factor | |
227 | value_temp[numpy.where(w > threshold),h] = numpy.nan |
|
124 | value_temp[numpy.where(w > threshold),h] = numpy.nan | |
228 | value_temp[numpy.where(w < -1*threshold),h] = numpy.nan |
|
125 | value_temp[numpy.where(w < -1*threshold),h] = numpy.nan | |
229 |
|
126 | |||
230 |
|
127 | |||
231 | #At the end |
|
128 | #At the end | |
232 | if svalue2 == 'inHeight': |
|
129 | if svalue2 == 'inHeight': | |
233 | value_temp = numpy.transpose(value_temp) |
|
130 | value_temp = numpy.transpose(value_temp) | |
234 | output_array[:,m] = value_temp |
|
131 | output_array[:,m] = value_temp | |
235 |
|
132 | |||
236 | if svalue == 'zonal': |
|
133 | if svalue == 'zonal': | |
237 | self.dataOut.data_output[0] = output_array |
|
134 | self.dataOut.data_output[0] = output_array | |
238 |
|
135 | |||
239 | elif svalue == 'meridional': |
|
136 | elif svalue == 'meridional': | |
240 | self.dataOut.data_output[1] = output_array |
|
137 | self.dataOut.data_output[1] = output_array | |
241 |
|
138 | |||
242 | elif svalue == 'vertical': |
|
139 | elif svalue == 'vertical': | |
243 | self.dataOut.data_output[2] = output_array |
|
140 | self.dataOut.data_output[2] = output_array | |
244 |
|
141 | |||
245 | return self.dataOut.data_output |
|
142 | return self.dataOut.data_output | |
246 |
|
143 | |||
247 |
|
144 | |||
248 | def Median(self,input,width): |
|
145 | def Median(self,input,width): | |
249 | ''' |
|
146 | ''' | |
250 | Inputs: |
|
147 | Inputs: | |
251 | input - Velocity array |
|
148 | input - Velocity array | |
252 | width - Number of points for mask filter |
|
149 | width - Number of points for mask filter | |
253 |
|
150 | |||
254 | ''' |
|
151 | ''' | |
255 |
|
152 | |||
256 | if numpy.mod(width,2) == 1: |
|
153 | if numpy.mod(width,2) == 1: | |
257 | pc = int((width - 1) / 2) |
|
154 | pc = int((width - 1) / 2) | |
258 | cont = 0 |
|
155 | cont = 0 | |
259 | output = [] |
|
156 | output = [] | |
260 |
|
157 | |||
261 | for i in range(len(input)): |
|
158 | for i in range(len(input)): | |
262 | if i >= pc and i < len(input) - pc: |
|
159 | if i >= pc and i < len(input) - pc: | |
263 | new2 = input[i-pc:i+pc+1] |
|
160 | new2 = input[i-pc:i+pc+1] | |
264 | temp = numpy.where(numpy.isfinite(new2)) |
|
161 | temp = numpy.where(numpy.isfinite(new2)) | |
265 | new = new2[temp] |
|
162 | new = new2[temp] | |
266 | value = numpy.median(new) |
|
163 | value = numpy.median(new) | |
267 | output.append(value) |
|
164 | output.append(value) | |
268 |
|
165 | |||
269 | output = numpy.array(output) |
|
166 | output = numpy.array(output) | |
270 | output = numpy.hstack((input[0:pc],output)) |
|
167 | output = numpy.hstack((input[0:pc],output)) | |
271 | output = numpy.hstack((output,input[-pc:len(input)])) |
|
168 | output = numpy.hstack((output,input[-pc:len(input)])) | |
272 |
|
169 | |||
273 | return output |
|
170 | return output | |
274 |
|
171 | |||
275 | def Smooth(self,input,width,edge_truncate = None): |
|
172 | def Smooth(self,input,width,edge_truncate = None): | |
276 | ''' |
|
173 | ''' | |
277 | Inputs: |
|
174 | Inputs: | |
278 | input - Velocity array |
|
175 | input - Velocity array | |
279 | width - Number of points for mask filter |
|
176 | width - Number of points for mask filter | |
280 | edge_truncate - 1 for truncate the convolution product else |
|
177 | edge_truncate - 1 for truncate the convolution product else | |
281 |
|
178 | |||
282 | ''' |
|
179 | ''' | |
283 |
|
180 | |||
284 | if numpy.mod(width,2) == 0: |
|
181 | if numpy.mod(width,2) == 0: | |
285 | real_width = width + 1 |
|
182 | real_width = width + 1 | |
286 | nzeros = width / 2 |
|
183 | nzeros = width / 2 | |
287 | else: |
|
184 | else: | |
288 | real_width = width |
|
185 | real_width = width | |
289 | nzeros = (width - 1) / 2 |
|
186 | nzeros = (width - 1) / 2 | |
290 |
|
187 | |||
291 | half_width = int(real_width)/2 |
|
188 | half_width = int(real_width)/2 | |
292 | length = len(input) |
|
189 | length = len(input) | |
293 |
|
190 | |||
294 | gate = numpy.ones(real_width,dtype='float') |
|
191 | gate = numpy.ones(real_width,dtype='float') | |
295 | norm_of_gate = numpy.sum(gate) |
|
192 | norm_of_gate = numpy.sum(gate) | |
296 |
|
193 | |||
297 | nan_process = 0 |
|
194 | nan_process = 0 | |
298 | nan_id = numpy.where(numpy.isnan(input)) |
|
195 | nan_id = numpy.where(numpy.isnan(input)) | |
299 | if len(nan_id[0]) > 0: |
|
196 | if len(nan_id[0]) > 0: | |
300 | nan_process = 1 |
|
197 | nan_process = 1 | |
301 | pb = numpy.zeros(len(input)) |
|
198 | pb = numpy.zeros(len(input)) | |
302 | pb[nan_id] = 1. |
|
199 | pb[nan_id] = 1. | |
303 | input[nan_id] = 0. |
|
200 | input[nan_id] = 0. | |
304 |
|
201 | |||
305 | if edge_truncate == True: |
|
202 | if edge_truncate == True: | |
306 | output = numpy.convolve(input/norm_of_gate,gate,mode='same') |
|
203 | output = numpy.convolve(input/norm_of_gate,gate,mode='same') | |
307 | elif edge_truncate == False or edge_truncate == None: |
|
204 | elif edge_truncate == False or edge_truncate == None: | |
308 | output = numpy.convolve(input/norm_of_gate,gate,mode='valid') |
|
205 | output = numpy.convolve(input/norm_of_gate,gate,mode='valid') | |
309 | output = numpy.hstack((input[0:half_width],output)) |
|
206 | output = numpy.hstack((input[0:half_width],output)) | |
310 | output = numpy.hstack((output,input[len(input)-half_width:len(input)])) |
|
207 | output = numpy.hstack((output,input[len(input)-half_width:len(input)])) | |
311 |
|
208 | |||
312 | if nan_process: |
|
209 | if nan_process: | |
313 | pb = numpy.convolve(pb/norm_of_gate,gate,mode='valid') |
|
210 | pb = numpy.convolve(pb/norm_of_gate,gate,mode='valid') | |
314 | pb = numpy.hstack((numpy.zeros(half_width),pb)) |
|
211 | pb = numpy.hstack((numpy.zeros(half_width),pb)) | |
315 | pb = numpy.hstack((pb,numpy.zeros(half_width))) |
|
212 | pb = numpy.hstack((pb,numpy.zeros(half_width))) | |
316 | output[numpy.where(pb > 0.9999)] = numpy.nan |
|
213 | output[numpy.where(pb > 0.9999)] = numpy.nan | |
317 | input[nan_id] = numpy.nan |
|
214 | input[nan_id] = numpy.nan | |
318 | return output |
|
215 | return output | |
319 |
|
216 | |||
320 | def Average(self,aver=0,nhaver=1): |
|
217 | def Average(self,aver=0,nhaver=1): | |
321 | ''' |
|
218 | ''' | |
322 | Inputs: |
|
219 | Inputs: | |
323 | aver - Indicates the time period over which is averaged or consensus data |
|
220 | aver - Indicates the time period over which is averaged or consensus data | |
324 | nhaver - Indicates the decimation factor in heights |
|
221 | nhaver - Indicates the decimation factor in heights | |
325 |
|
222 | |||
326 | ''' |
|
223 | ''' | |
327 | nhpoints = 48 |
|
224 | nhpoints = 48 | |
328 |
|
225 | |||
329 | lat_piura = -5.17 |
|
226 | lat_piura = -5.17 | |
330 | lat_huancayo = -12.04 |
|
227 | lat_huancayo = -12.04 | |
331 | lat_porcuya = -5.8 |
|
228 | lat_porcuya = -5.8 | |
332 |
|
229 | |||
333 | if '%2.2f'%self.dataOut.lat == '%2.2f'%lat_piura: |
|
230 | if '%2.2f'%self.dataOut.lat == '%2.2f'%lat_piura: | |
334 | hcm = 3. |
|
231 | hcm = 3. | |
335 | if self.dataOut.year == 2003 : |
|
232 | if self.dataOut.year == 2003 : | |
336 | if self.dataOut.doy >= 25 and self.dataOut.doy < 64: |
|
233 | if self.dataOut.doy >= 25 and self.dataOut.doy < 64: | |
337 | nhpoints = 12 |
|
234 | nhpoints = 12 | |
338 |
|
235 | |||
339 | elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_huancayo: |
|
236 | elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_huancayo: | |
340 | hcm = 3. |
|
237 | hcm = 3. | |
341 | if self.dataOut.year == 2003 : |
|
238 | if self.dataOut.year == 2003 : | |
342 | if self.dataOut.doy >= 25 and self.dataOut.doy < 64: |
|
239 | if self.dataOut.doy >= 25 and self.dataOut.doy < 64: | |
343 | nhpoints = 12 |
|
240 | nhpoints = 12 | |
344 |
|
241 | |||
345 |
|
242 | |||
346 | elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_porcuya: |
|
243 | elif '%2.2f'%self.dataOut.lat == '%2.2f'%lat_porcuya: | |
347 | hcm = 5.#2 |
|
244 | hcm = 5.#2 | |
348 |
|
245 | |||
349 | pdata = 0.2 |
|
246 | pdata = 0.2 | |
350 | taver = [1,2,3,4,6,8,12,24] |
|
247 | taver = [1,2,3,4,6,8,12,24] | |
351 | t0 = 0 |
|
248 | t0 = 0 | |
352 | tf = 24 |
|
249 | tf = 24 | |
353 | ntime =(tf-t0)/taver[aver] |
|
250 | ntime =(tf-t0)/taver[aver] | |
354 | ti = numpy.arange(ntime) |
|
251 | ti = numpy.arange(ntime) | |
355 | tf = numpy.arange(ntime) + taver[aver] |
|
252 | tf = numpy.arange(ntime) + taver[aver] | |
356 |
|
253 | |||
357 |
|
254 | |||
358 | old_height = self.dataOut.heightList |
|
255 | old_height = self.dataOut.heightList | |
359 |
|
256 | |||
360 | if nhaver > 1: |
|
257 | if nhaver > 1: | |
361 | num_hei = len(self.dataOut.heightList)/nhaver/self.dataOut.nmodes |
|
258 | num_hei = len(self.dataOut.heightList)/nhaver/self.dataOut.nmodes | |
362 | deltha = 0.05*nhaver |
|
259 | deltha = 0.05*nhaver | |
363 | minhvalid = pdata*nhaver |
|
260 | minhvalid = pdata*nhaver | |
364 | for im in range(self.dataOut.nmodes): |
|
261 | for im in range(self.dataOut.nmodes): | |
365 | new_height = numpy.arange(num_hei)*deltha + self.dataOut.height[im,0] + deltha/2. |
|
262 | new_height = numpy.arange(num_hei)*deltha + self.dataOut.height[im,0] + deltha/2. | |
366 |
|
263 | |||
367 |
|
264 | |||
368 | data_fHeigths_List = [] |
|
265 | data_fHeigths_List = [] | |
369 | data_fZonal_List = [] |
|
266 | data_fZonal_List = [] | |
370 | data_fMeridional_List = [] |
|
267 | data_fMeridional_List = [] | |
371 | data_fVertical_List = [] |
|
268 | data_fVertical_List = [] | |
372 | startDTList = [] |
|
269 | startDTList = [] | |
373 |
|
270 | |||
374 |
|
271 | |||
375 | for i in range(ntime): |
|
272 | for i in range(ntime): | |
376 | height = old_height |
|
273 | height = old_height | |
377 |
|
274 | |||
378 | start = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(ti[i])) - datetime.timedelta(hours = 5) |
|
275 | start = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(ti[i])) - datetime.timedelta(hours = 5) | |
379 | stop = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(tf[i])) - datetime.timedelta(hours = 5) |
|
276 | stop = datetime.datetime(self.dataOut.year,self.dataOut.month,self.dataOut.day) + datetime.timedelta(hours = int(tf[i])) - datetime.timedelta(hours = 5) | |
380 |
|
277 | |||
381 |
|
278 | |||
382 | limit_sec1 = time.mktime(start.timetuple()) |
|
279 | limit_sec1 = time.mktime(start.timetuple()) | |
383 | limit_sec2 = time.mktime(stop.timetuple()) |
|
280 | limit_sec2 = time.mktime(stop.timetuple()) | |
384 |
|
281 | |||
385 | t1 = numpy.where(self.f_timesec >= limit_sec1) |
|
282 | t1 = numpy.where(self.f_timesec >= limit_sec1) | |
386 | t2 = numpy.where(self.f_timesec < limit_sec2) |
|
283 | t2 = numpy.where(self.f_timesec < limit_sec2) | |
387 | time_select = [] |
|
284 | time_select = [] | |
388 | for val_sec in t1[0]: |
|
285 | for val_sec in t1[0]: | |
389 | if val_sec in t2[0]: |
|
286 | if val_sec in t2[0]: | |
390 | time_select.append(val_sec) |
|
287 | time_select.append(val_sec) | |
391 |
|
288 | |||
392 |
|
289 | |||
393 | time_select = numpy.array(time_select,dtype = 'int') |
|
290 | time_select = numpy.array(time_select,dtype = 'int') | |
394 | minvalid = numpy.ceil(pdata*nhpoints) |
|
291 | minvalid = numpy.ceil(pdata*nhpoints) | |
395 |
|
292 | |||
396 | zon_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan |
|
293 | zon_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan | |
397 | mer_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan |
|
294 | mer_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan | |
398 | ver_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan |
|
295 | ver_aver = numpy.zeros([self.dataOut.nranges,self.dataOut.nmodes],dtype='f4') + numpy.nan | |
399 |
|
296 | |||
400 | if nhaver > 1: |
|
297 | if nhaver > 1: | |
401 | new_zon_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan |
|
298 | new_zon_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan | |
402 | new_mer_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan |
|
299 | new_mer_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan | |
403 | new_ver_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan |
|
300 | new_ver_aver = numpy.zeros([num_hei,self.dataOut.nmodes],dtype='f4') + numpy.nan | |
404 |
|
301 | |||
405 | if len(time_select) > minvalid: |
|
302 | if len(time_select) > minvalid: | |
406 | time_average = self.f_timesec[time_select] |
|
303 | time_average = self.f_timesec[time_select] | |
407 |
|
304 | |||
408 | for im in range(self.dataOut.nmodes): |
|
305 | for im in range(self.dataOut.nmodes): | |
409 |
|
306 | |||
410 | for ih in range(self.dataOut.nranges): |
|
307 | for ih in range(self.dataOut.nranges): | |
411 | if numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im])) >= minvalid: |
|
308 | if numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im])) >= minvalid: | |
412 | zon_aver[ih,im] = numpy.nansum(self.f_zon[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im])) |
|
309 | zon_aver[ih,im] = numpy.nansum(self.f_zon[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_zon[time_select,ih,im])) | |
413 |
|
310 | |||
414 | if numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im])) >= minvalid: |
|
311 | if numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im])) >= minvalid: | |
415 | mer_aver[ih,im] = numpy.nansum(self.f_mer[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im])) |
|
312 | mer_aver[ih,im] = numpy.nansum(self.f_mer[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_mer[time_select,ih,im])) | |
416 |
|
313 | |||
417 | if numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im])) >= minvalid: |
|
314 | if numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im])) >= minvalid: | |
418 | ver_aver[ih,im] = numpy.nansum(self.f_ver[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im])) |
|
315 | ver_aver[ih,im] = numpy.nansum(self.f_ver[time_select,ih,im]) / numpy.sum(numpy.isfinite(self.f_ver[time_select,ih,im])) | |
419 |
|
316 | |||
420 | if nhaver > 1: |
|
317 | if nhaver > 1: | |
421 | for ih in range(num_hei): |
|
318 | for ih in range(num_hei): | |
422 | hvalid = numpy.arange(nhaver) + nhaver*ih |
|
319 | hvalid = numpy.arange(nhaver) + nhaver*ih | |
423 |
|
320 | |||
424 | if numpy.sum(numpy.isfinite(zon_aver[hvalid,im])) >= minvalid: |
|
321 | if numpy.sum(numpy.isfinite(zon_aver[hvalid,im])) >= minvalid: | |
425 | new_zon_aver[ih,im] = numpy.nansum(zon_aver[hvalid,im]) / numpy.sum(numpy.isfinite(zon_aver[hvalid,im])) |
|
322 | new_zon_aver[ih,im] = numpy.nansum(zon_aver[hvalid,im]) / numpy.sum(numpy.isfinite(zon_aver[hvalid,im])) | |
426 |
|
323 | |||
427 | if numpy.sum(numpy.isfinite(mer_aver[hvalid,im])) >= minvalid: |
|
324 | if numpy.sum(numpy.isfinite(mer_aver[hvalid,im])) >= minvalid: | |
428 | new_mer_aver[ih,im] = numpy.nansum(mer_aver[hvalid,im]) / numpy.sum(numpy.isfinite(mer_aver[hvalid,im])) |
|
325 | new_mer_aver[ih,im] = numpy.nansum(mer_aver[hvalid,im]) / numpy.sum(numpy.isfinite(mer_aver[hvalid,im])) | |
429 |
|
326 | |||
430 | if numpy.sum(numpy.isfinite(ver_aver[hvalid,im])) >= minvalid: |
|
327 | if numpy.sum(numpy.isfinite(ver_aver[hvalid,im])) >= minvalid: | |
431 | new_ver_aver[ih,im] = numpy.nansum(ver_aver[hvalid,im]) / numpy.sum(numpy.isfinite(ver_aver[hvalid,im])) |
|
328 | new_ver_aver[ih,im] = numpy.nansum(ver_aver[hvalid,im]) / numpy.sum(numpy.isfinite(ver_aver[hvalid,im])) | |
432 | if nhaver > 1: |
|
329 | if nhaver > 1: | |
433 | zon_aver = new_zon_aver |
|
330 | zon_aver = new_zon_aver | |
434 | mer_aver = new_mer_aver |
|
331 | mer_aver = new_mer_aver | |
435 | ver_aver = new_ver_aver |
|
332 | ver_aver = new_ver_aver | |
436 | height = new_height |
|
333 | height = new_height | |
437 |
|
334 | |||
438 |
|
335 | |||
439 | tstart = time_average[0] |
|
336 | tstart = time_average[0] | |
440 | tend = time_average[-1] |
|
337 | tend = time_average[-1] | |
441 | startTime = time.gmtime(tstart) |
|
338 | startTime = time.gmtime(tstart) | |
442 |
|
339 | |||
443 | year = startTime.tm_year |
|
340 | year = startTime.tm_year | |
444 | month = startTime.tm_mon |
|
341 | month = startTime.tm_mon | |
445 | day = startTime.tm_mday |
|
342 | day = startTime.tm_mday | |
446 | hour = startTime.tm_hour |
|
343 | hour = startTime.tm_hour | |
447 | minute = startTime.tm_min |
|
344 | minute = startTime.tm_min | |
448 | second = startTime.tm_sec |
|
345 | second = startTime.tm_sec | |
449 |
|
346 | |||
450 | startDTList.append(datetime.datetime(year,month,day,hour,minute,second)) |
|
347 | startDTList.append(datetime.datetime(year,month,day,hour,minute,second)) | |
451 |
|
348 | |||
452 |
|
349 | |||
453 | o_height = numpy.array([]) |
|
350 | o_height = numpy.array([]) | |
454 | o_zon_aver = numpy.array([]) |
|
351 | o_zon_aver = numpy.array([]) | |
455 | o_mer_aver = numpy.array([]) |
|
352 | o_mer_aver = numpy.array([]) | |
456 | o_ver_aver = numpy.array([]) |
|
353 | o_ver_aver = numpy.array([]) | |
457 | if self.dataOut.nmodes > 1: |
|
354 | if self.dataOut.nmodes > 1: | |
458 | for im in range(self.dataOut.nmodes): |
|
355 | for im in range(self.dataOut.nmodes): | |
459 |
|
356 | |||
460 | if im == 0: |
|
357 | if im == 0: | |
461 | h_select = numpy.where(numpy.bitwise_and(height[0,:] >=0,height[0,:] <= hcm,numpy.isfinite(height[0,:]))) |
|
358 | h_select = numpy.where(numpy.bitwise_and(height[0,:] >=0,height[0,:] <= hcm,numpy.isfinite(height[0,:]))) | |
462 | else: |
|
359 | else: | |
463 | h_select = numpy.where(numpy.bitwise_and(height[1,:] > hcm,height[1,:] < 20,numpy.isfinite(height[1,:]))) |
|
360 | h_select = numpy.where(numpy.bitwise_and(height[1,:] > hcm,height[1,:] < 20,numpy.isfinite(height[1,:]))) | |
464 |
|
361 | |||
465 |
|
362 | |||
466 | ht = h_select[0] |
|
363 | ht = h_select[0] | |
467 |
|
364 | |||
468 | o_height = numpy.hstack((o_height,height[im,ht])) |
|
365 | o_height = numpy.hstack((o_height,height[im,ht])) | |
469 | o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im])) |
|
366 | o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im])) | |
470 | o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im])) |
|
367 | o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im])) | |
471 | o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im])) |
|
368 | o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im])) | |
472 |
|
369 | |||
473 | data_fHeigths_List.append(o_height) |
|
370 | data_fHeigths_List.append(o_height) | |
474 | data_fZonal_List.append(o_zon_aver) |
|
371 | data_fZonal_List.append(o_zon_aver) | |
475 | data_fMeridional_List.append(o_mer_aver) |
|
372 | data_fMeridional_List.append(o_mer_aver) | |
476 | data_fVertical_List.append(o_ver_aver) |
|
373 | data_fVertical_List.append(o_ver_aver) | |
477 |
|
374 | |||
478 |
|
375 | |||
479 | else: |
|
376 | else: | |
480 | h_select = numpy.where(numpy.bitwise_and(height[0,:] <= hcm,numpy.isfinite(height[0,:]))) |
|
377 | h_select = numpy.where(numpy.bitwise_and(height[0,:] <= hcm,numpy.isfinite(height[0,:]))) | |
481 | ht = h_select[0] |
|
378 | ht = h_select[0] | |
482 | o_height = numpy.hstack((o_height,height[im,ht])) |
|
379 | o_height = numpy.hstack((o_height,height[im,ht])) | |
483 | o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im])) |
|
380 | o_zon_aver = numpy.hstack((o_zon_aver,zon_aver[ht,im])) | |
484 | o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im])) |
|
381 | o_mer_aver = numpy.hstack((o_mer_aver,mer_aver[ht,im])) | |
485 | o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im])) |
|
382 | o_ver_aver = numpy.hstack((o_ver_aver,ver_aver[ht,im])) | |
486 |
|
383 | |||
487 | data_fHeigths_List.append(o_height) |
|
384 | data_fHeigths_List.append(o_height) | |
488 | data_fZonal_List.append(o_zon_aver) |
|
385 | data_fZonal_List.append(o_zon_aver) | |
489 | data_fMeridional_List.append(o_mer_aver) |
|
386 | data_fMeridional_List.append(o_mer_aver) | |
490 | data_fVertical_List.append(o_ver_aver) |
|
387 | data_fVertical_List.append(o_ver_aver) | |
491 |
|
388 | |||
492 |
|
389 | |||
493 | return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List |
|
390 | return startDTList, data_fHeigths_List, data_fZonal_List, data_fMeridional_List, data_fVertical_List | |
494 |
|
||||
495 |
|
||||
496 | def prePlot(self,modeselect=None): |
|
|||
497 |
|
391 | |||
498 | ''' |
|
|||
499 | Inputs: |
|
|||
500 |
|
||||
501 | self.dataOut.data_output - Zonal, Meridional and Vertical velocity array |
|
|||
502 | self.dataOut.height - height array |
|
|||
503 | self.dataOut.time - Time array (seconds) |
|
|||
504 | self.dataOut.data_SNR - SNR array |
|
|||
505 |
|
||||
506 | ''' |
|
|||
507 |
|
||||
508 | m = modeselect -1 |
|
|||
509 |
|
||||
510 | print ' [Plotting mode {}]'.format(modeselect) |
|
|||
511 | if not (m ==1 or m==0): |
|
|||
512 | raise IndexError("'Mode' must be egual to : 1 or 2") |
|
|||
513 | # |
|
|||
514 | if self.flagfirstmode==0: |
|
|||
515 | #copy of the data |
|
|||
516 | self.data_output_copy = self.dataOut.data_output.copy() |
|
|||
517 | self.data_height_copy = self.dataOut.height.copy() |
|
|||
518 | self.data_time_copy = self.dataOut.time.copy() |
|
|||
519 | self.data_SNR_copy = self.dataOut.data_SNR.copy() |
|
|||
520 | self.flagfirstmode = 1 |
|
|||
521 |
|
||||
522 | else: |
|
|||
523 | self.dataOut.data_output = self.data_output_copy |
|
|||
524 | self.dataOut.height = self.data_height_copy |
|
|||
525 | self.dataOut.time = self.data_time_copy |
|
|||
526 | self.dataOut.data_SNR = self.data_SNR_copy |
|
|||
527 | self.flagfirstmode = 0 |
|
|||
528 |
|
||||
529 |
|
||||
530 | #select data for mode m |
|
|||
531 | #self.dataOut.data_output = self.dataOut.data_output[:,:,m] |
|
|||
532 | self.dataOut.heightList = self.dataOut.height[0,:] |
|
|||
533 |
|
||||
534 | data_SNR = self.dataOut.data_SNR[:,:,m] |
|
|||
535 | self.dataOut.data_SNR= transpose(data_SNR) |
|
|||
536 |
|
||||
537 | if m==1 and self.dataOut.counter_records%2==0: |
|
|||
538 | print '*********' |
|
|||
539 | print 'MODO 2' |
|
|||
540 | #print 'Zonal', self.dataOut.data_output[0] |
|
|||
541 | #print 'Meridional', self.dataOut.data_output[1] |
|
|||
542 | #print 'Vertical', self.dataOut.data_output[2] |
|
|||
543 |
|
||||
544 | print '*********' |
|
|||
545 |
|
||||
546 | Vx=self.dataOut.data_output[0,:,m] |
|
|||
547 | Vy=self.dataOut.data_output[1,:,m] |
|
|||
548 |
|
||||
549 | Vmag=numpy.sqrt(Vx**2+Vy**2) |
|
|||
550 | Vang=numpy.arctan2(Vy,Vx) |
|
|||
551 | #print 'Vmag', Vmag |
|
|||
552 | #print 'Vang', Vang |
|
|||
553 |
|
||||
554 | self.dataOut.data_output[0,:,m]=Vmag |
|
|||
555 | self.dataOut.data_output[1,:,m]=Vang |
|
|||
556 |
|
||||
557 | prin= self.dataOut.data_output[0,:,m][~numpy.isnan(self.dataOut.data_output[0,:,m])] |
|
|||
558 | print ' ' |
|
|||
559 | print 'VmagAverage',numpy.mean(prin) |
|
|||
560 | print ' ' |
|
|||
561 | self.dataOut.data_output = self.dataOut.data_output[:,:,m] |
|
|||
562 |
|
||||
563 |
|
392 | |||
564 | No newline at end of file |
|
393 |
1 | NO CONTENT: modified file, binary diff hidden |
|
NO CONTENT: modified file, binary diff hidden |
1 | NO CONTENT: file was removed, binary diff hidden |
|
NO CONTENT: file was removed, binary diff hidden |
1 | NO CONTENT: file was removed, binary diff hidden |
|
NO CONTENT: file was removed, binary diff hidden |
General Comments 0
You need to be logged in to leave comments.
Login now