@@ -1,1169 +1,1183 | |||||
1 | ''' |
|
1 | ''' | |
2 |
|
2 | |||
3 | $Author: murco $ |
|
3 | $Author: murco $ | |
4 | $Id: JROData.py 173 2012-11-20 15:06:21Z murco $ |
|
4 | $Id: JROData.py 173 2012-11-20 15:06:21Z murco $ | |
5 | ''' |
|
5 | ''' | |
6 |
|
6 | |||
7 | import copy |
|
7 | import copy | |
8 | import numpy |
|
8 | import numpy | |
9 | import datetime |
|
9 | import datetime | |
10 |
|
10 | |||
11 | from jroheaderIO import SystemHeader, RadarControllerHeader |
|
11 | from jroheaderIO import SystemHeader, RadarControllerHeader | |
12 |
|
12 | |||
13 | def getNumpyDtype(dataTypeCode): |
|
13 | def getNumpyDtype(dataTypeCode): | |
14 |
|
14 | |||
15 | if dataTypeCode == 0: |
|
15 | if dataTypeCode == 0: | |
16 | numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')]) |
|
16 | numpyDtype = numpy.dtype([('real','<i1'),('imag','<i1')]) | |
17 | elif dataTypeCode == 1: |
|
17 | elif dataTypeCode == 1: | |
18 | numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')]) |
|
18 | numpyDtype = numpy.dtype([('real','<i2'),('imag','<i2')]) | |
19 | elif dataTypeCode == 2: |
|
19 | elif dataTypeCode == 2: | |
20 | numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')]) |
|
20 | numpyDtype = numpy.dtype([('real','<i4'),('imag','<i4')]) | |
21 | elif dataTypeCode == 3: |
|
21 | elif dataTypeCode == 3: | |
22 | numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')]) |
|
22 | numpyDtype = numpy.dtype([('real','<i8'),('imag','<i8')]) | |
23 | elif dataTypeCode == 4: |
|
23 | elif dataTypeCode == 4: | |
24 | numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
24 | numpyDtype = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
25 | elif dataTypeCode == 5: |
|
25 | elif dataTypeCode == 5: | |
26 | numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')]) |
|
26 | numpyDtype = numpy.dtype([('real','<f8'),('imag','<f8')]) | |
27 | else: |
|
27 | else: | |
28 | raise ValueError, 'dataTypeCode was not defined' |
|
28 | raise ValueError, 'dataTypeCode was not defined' | |
29 |
|
29 | |||
30 | return numpyDtype |
|
30 | return numpyDtype | |
31 |
|
31 | |||
32 | def getDataTypeCode(numpyDtype): |
|
32 | def getDataTypeCode(numpyDtype): | |
33 |
|
33 | |||
34 | if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]): |
|
34 | if numpyDtype == numpy.dtype([('real','<i1'),('imag','<i1')]): | |
35 | datatype = 0 |
|
35 | datatype = 0 | |
36 | elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]): |
|
36 | elif numpyDtype == numpy.dtype([('real','<i2'),('imag','<i2')]): | |
37 | datatype = 1 |
|
37 | datatype = 1 | |
38 | elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]): |
|
38 | elif numpyDtype == numpy.dtype([('real','<i4'),('imag','<i4')]): | |
39 | datatype = 2 |
|
39 | datatype = 2 | |
40 | elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]): |
|
40 | elif numpyDtype == numpy.dtype([('real','<i8'),('imag','<i8')]): | |
41 | datatype = 3 |
|
41 | datatype = 3 | |
42 | elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]): |
|
42 | elif numpyDtype == numpy.dtype([('real','<f4'),('imag','<f4')]): | |
43 | datatype = 4 |
|
43 | datatype = 4 | |
44 | elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]): |
|
44 | elif numpyDtype == numpy.dtype([('real','<f8'),('imag','<f8')]): | |
45 | datatype = 5 |
|
45 | datatype = 5 | |
46 | else: |
|
46 | else: | |
47 | datatype = None |
|
47 | datatype = None | |
48 |
|
48 | |||
49 | return datatype |
|
49 | return datatype | |
50 |
|
50 | |||
51 | def hildebrand_sekhon(data, navg): |
|
51 | def hildebrand_sekhon(data, navg): | |
52 | """ |
|
52 | """ | |
53 | This method is for the objective determination of the noise level in Doppler spectra. This |
|
53 | This method is for the objective determination of the noise level in Doppler spectra. This | |
54 | implementation technique is based on the fact that the standard deviation of the spectral |
|
54 | implementation technique is based on the fact that the standard deviation of the spectral | |
55 | densities is equal to the mean spectral density for white Gaussian noise |
|
55 | densities is equal to the mean spectral density for white Gaussian noise | |
56 |
|
56 | |||
57 | Inputs: |
|
57 | Inputs: | |
58 | Data : heights |
|
58 | Data : heights | |
59 | navg : numbers of averages |
|
59 | navg : numbers of averages | |
60 |
|
60 | |||
61 | Return: |
|
61 | Return: | |
62 | -1 : any error |
|
62 | -1 : any error | |
63 | anoise : noise's level |
|
63 | anoise : noise's level | |
64 | """ |
|
64 | """ | |
65 |
|
65 | |||
66 | sortdata = numpy.sort(data,axis=None) |
|
66 | sortdata = numpy.sort(data,axis=None) | |
67 | lenOfData = len(sortdata) |
|
67 | lenOfData = len(sortdata) | |
68 | nums_min = lenOfData*0.2 |
|
68 | nums_min = lenOfData*0.2 | |
69 |
|
69 | |||
70 | if nums_min <= 5: |
|
70 | if nums_min <= 5: | |
71 | nums_min = 5 |
|
71 | nums_min = 5 | |
72 |
|
72 | |||
73 | sump = 0. |
|
73 | sump = 0. | |
74 |
|
74 | |||
75 | sumq = 0. |
|
75 | sumq = 0. | |
76 |
|
76 | |||
77 | j = 0 |
|
77 | j = 0 | |
78 |
|
78 | |||
79 | cont = 1 |
|
79 | cont = 1 | |
80 |
|
80 | |||
81 | while((cont==1)and(j<lenOfData)): |
|
81 | while((cont==1)and(j<lenOfData)): | |
82 |
|
82 | |||
83 | sump += sortdata[j] |
|
83 | sump += sortdata[j] | |
84 |
|
84 | |||
85 | sumq += sortdata[j]**2 |
|
85 | sumq += sortdata[j]**2 | |
86 |
|
86 | |||
87 | if j > nums_min: |
|
87 | if j > nums_min: | |
88 | rtest = float(j)/(j-1) + 1.0/navg |
|
88 | rtest = float(j)/(j-1) + 1.0/navg | |
89 | if ((sumq*j) > (rtest*sump**2)): |
|
89 | if ((sumq*j) > (rtest*sump**2)): | |
90 | j = j - 1 |
|
90 | j = j - 1 | |
91 | sump = sump - sortdata[j] |
|
91 | sump = sump - sortdata[j] | |
92 | sumq = sumq - sortdata[j]**2 |
|
92 | sumq = sumq - sortdata[j]**2 | |
93 | cont = 0 |
|
93 | cont = 0 | |
94 |
|
94 | |||
95 | j += 1 |
|
95 | j += 1 | |
96 |
|
96 | |||
97 | lnoise = sump /j |
|
97 | lnoise = sump /j | |
98 | # stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1)) |
|
98 | # stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1)) | |
99 | return lnoise |
|
99 | return lnoise | |
100 |
|
100 | |||
101 | class Beam: |
|
101 | class Beam: | |
102 | def __init__(self): |
|
102 | def __init__(self): | |
103 | self.codeList = [] |
|
103 | self.codeList = [] | |
104 | self.azimuthList = [] |
|
104 | self.azimuthList = [] | |
105 | self.zenithList = [] |
|
105 | self.zenithList = [] | |
106 |
|
106 | |||
107 | class GenericData(object): |
|
107 | class GenericData(object): | |
108 |
|
108 | |||
109 | flagNoData = True |
|
109 | flagNoData = True | |
110 |
|
110 | |||
111 | def __init__(self): |
|
111 | def __init__(self): | |
112 |
|
112 | |||
113 | raise NotImplementedError |
|
113 | raise NotImplementedError | |
114 |
|
114 | |||
115 | def copy(self, inputObj=None): |
|
115 | def copy(self, inputObj=None): | |
116 |
|
116 | |||
117 | if inputObj == None: |
|
117 | if inputObj == None: | |
118 | return copy.deepcopy(self) |
|
118 | return copy.deepcopy(self) | |
119 |
|
119 | |||
120 | for key in inputObj.__dict__.keys(): |
|
120 | for key in inputObj.__dict__.keys(): | |
121 |
|
121 | |||
122 | attribute = inputObj.__dict__[key] |
|
122 | attribute = inputObj.__dict__[key] | |
123 |
|
123 | |||
124 | #If this attribute is a tuple or list |
|
124 | #If this attribute is a tuple or list | |
125 | if type(inputObj.__dict__[key]) in (tuple, list): |
|
125 | if type(inputObj.__dict__[key]) in (tuple, list): | |
126 | self.__dict__[key] = attribute[:] |
|
126 | self.__dict__[key] = attribute[:] | |
127 | continue |
|
127 | continue | |
128 |
|
128 | |||
129 | #If this attribute is another object or instance |
|
129 | #If this attribute is another object or instance | |
130 | if hasattr(attribute, '__dict__'): |
|
130 | if hasattr(attribute, '__dict__'): | |
131 | self.__dict__[key] = attribute.copy() |
|
131 | self.__dict__[key] = attribute.copy() | |
132 | continue |
|
132 | continue | |
133 |
|
133 | |||
134 | self.__dict__[key] = inputObj.__dict__[key] |
|
134 | self.__dict__[key] = inputObj.__dict__[key] | |
135 |
|
135 | |||
136 | def deepcopy(self): |
|
136 | def deepcopy(self): | |
137 |
|
137 | |||
138 | return copy.deepcopy(self) |
|
138 | return copy.deepcopy(self) | |
139 |
|
139 | |||
140 | def isEmpty(self): |
|
140 | def isEmpty(self): | |
141 |
|
141 | |||
142 | return self.flagNoData |
|
142 | return self.flagNoData | |
143 |
|
143 | |||
144 | class JROData(GenericData): |
|
144 | class JROData(GenericData): | |
145 |
|
145 | |||
146 | # m_BasicHeader = BasicHeader() |
|
146 | # m_BasicHeader = BasicHeader() | |
147 | # m_ProcessingHeader = ProcessingHeader() |
|
147 | # m_ProcessingHeader = ProcessingHeader() | |
148 |
|
148 | |||
149 | systemHeaderObj = SystemHeader() |
|
149 | systemHeaderObj = SystemHeader() | |
150 |
|
150 | |||
151 | radarControllerHeaderObj = RadarControllerHeader() |
|
151 | radarControllerHeaderObj = RadarControllerHeader() | |
152 |
|
152 | |||
153 | # data = None |
|
153 | # data = None | |
154 |
|
154 | |||
155 | type = None |
|
155 | type = None | |
156 |
|
156 | |||
157 | datatype = None #dtype but in string |
|
157 | datatype = None #dtype but in string | |
158 |
|
158 | |||
159 | # dtype = None |
|
159 | # dtype = None | |
160 |
|
160 | |||
161 | # nChannels = None |
|
161 | # nChannels = None | |
162 |
|
162 | |||
163 | # nHeights = None |
|
163 | # nHeights = None | |
164 |
|
164 | |||
165 | nProfiles = None |
|
165 | nProfiles = None | |
166 |
|
166 | |||
167 | heightList = None |
|
167 | heightList = None | |
168 |
|
168 | |||
169 | channelList = None |
|
169 | channelList = None | |
170 |
|
170 | |||
171 | flagDiscontinuousBlock = False |
|
171 | flagDiscontinuousBlock = False | |
172 |
|
172 | |||
173 | useLocalTime = False |
|
173 | useLocalTime = False | |
174 |
|
174 | |||
175 | utctime = None |
|
175 | utctime = None | |
176 |
|
176 | |||
177 | timeZone = None |
|
177 | timeZone = None | |
178 |
|
178 | |||
179 | dstFlag = None |
|
179 | dstFlag = None | |
180 |
|
180 | |||
181 | errorCount = None |
|
181 | errorCount = None | |
182 |
|
182 | |||
183 | blocksize = None |
|
183 | blocksize = None | |
184 |
|
184 | |||
185 | # nCode = None |
|
185 | # nCode = None | |
186 | # |
|
186 | # | |
187 | # nBaud = None |
|
187 | # nBaud = None | |
188 | # |
|
188 | # | |
189 | # code = None |
|
189 | # code = None | |
190 |
|
190 | |||
191 | flagDecodeData = False #asumo q la data no esta decodificada |
|
191 | flagDecodeData = False #asumo q la data no esta decodificada | |
192 |
|
192 | |||
193 | flagDeflipData = False #asumo q la data no esta sin flip |
|
193 | flagDeflipData = False #asumo q la data no esta sin flip | |
194 |
|
194 | |||
195 | flagShiftFFT = False |
|
195 | flagShiftFFT = False | |
196 |
|
196 | |||
197 | # ippSeconds = None |
|
197 | # ippSeconds = None | |
198 |
|
198 | |||
199 | # timeInterval = None |
|
199 | # timeInterval = None | |
200 |
|
200 | |||
201 | nCohInt = None |
|
201 | nCohInt = None | |
202 |
|
202 | |||
203 | # noise = None |
|
203 | # noise = None | |
204 |
|
204 | |||
205 | windowOfFilter = 1 |
|
205 | windowOfFilter = 1 | |
206 |
|
206 | |||
207 | #Speed of ligth |
|
207 | #Speed of ligth | |
208 | C = 3e8 |
|
208 | C = 3e8 | |
209 |
|
209 | |||
210 | frequency = 49.92e6 |
|
210 | frequency = 49.92e6 | |
211 |
|
211 | |||
212 | realtime = False |
|
212 | realtime = False | |
213 |
|
213 | |||
214 | beacon_heiIndexList = None |
|
214 | beacon_heiIndexList = None | |
215 |
|
215 | |||
216 | last_block = None |
|
216 | last_block = None | |
217 |
|
217 | |||
218 | blocknow = None |
|
218 | blocknow = None | |
219 |
|
219 | |||
220 | azimuth = None |
|
220 | azimuth = None | |
221 |
|
221 | |||
222 | zenith = None |
|
222 | zenith = None | |
223 |
|
223 | |||
224 | beam = Beam() |
|
224 | beam = Beam() | |
225 |
|
225 | |||
226 | profileIndex = None |
|
226 | profileIndex = None | |
227 |
|
227 | |||
228 | def __init__(self): |
|
228 | def __init__(self): | |
229 |
|
229 | |||
230 | raise NotImplementedError |
|
230 | raise NotImplementedError | |
231 |
|
231 | |||
232 | def getNoise(self): |
|
232 | def getNoise(self): | |
233 |
|
233 | |||
234 | raise NotImplementedError |
|
234 | raise NotImplementedError | |
235 |
|
235 | |||
236 | def getNChannels(self): |
|
236 | def getNChannels(self): | |
237 |
|
237 | |||
238 | return len(self.channelList) |
|
238 | return len(self.channelList) | |
239 |
|
239 | |||
240 | def getChannelIndexList(self): |
|
240 | def getChannelIndexList(self): | |
241 |
|
241 | |||
242 | return range(self.nChannels) |
|
242 | return range(self.nChannels) | |
243 |
|
243 | |||
244 | def getNHeights(self): |
|
244 | def getNHeights(self): | |
245 |
|
245 | |||
246 | return len(self.heightList) |
|
246 | return len(self.heightList) | |
247 |
|
247 | |||
248 | def getHeiRange(self, extrapoints=0): |
|
248 | def getHeiRange(self, extrapoints=0): | |
249 |
|
249 | |||
250 | heis = self.heightList |
|
250 | heis = self.heightList | |
251 | # deltah = self.heightList[1] - self.heightList[0] |
|
251 | # deltah = self.heightList[1] - self.heightList[0] | |
252 | # |
|
252 | # | |
253 | # heis.append(self.heightList[-1]) |
|
253 | # heis.append(self.heightList[-1]) | |
254 |
|
254 | |||
255 | return heis |
|
255 | return heis | |
256 |
|
256 | |||
257 | def getDeltaH(self): |
|
257 | def getDeltaH(self): | |
258 |
|
258 | |||
259 | delta = self.heightList[1] - self.heightList[0] |
|
259 | delta = self.heightList[1] - self.heightList[0] | |
260 |
|
260 | |||
261 | return delta |
|
261 | return delta | |
262 |
|
262 | |||
263 | def getltctime(self): |
|
263 | def getltctime(self): | |
264 |
|
264 | |||
265 | if self.useLocalTime: |
|
265 | if self.useLocalTime: | |
266 | return self.utctime - self.timeZone*60 |
|
266 | return self.utctime - self.timeZone*60 | |
267 |
|
267 | |||
268 | return self.utctime |
|
268 | return self.utctime | |
269 |
|
269 | |||
270 | def getDatatime(self): |
|
270 | def getDatatime(self): | |
271 |
|
271 | |||
272 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
272 | datatimeValue = datetime.datetime.utcfromtimestamp(self.ltctime) | |
273 | return datatimeValue |
|
273 | return datatimeValue | |
274 |
|
274 | |||
275 | def getTimeRange(self): |
|
275 | def getTimeRange(self): | |
276 |
|
276 | |||
277 | datatime = [] |
|
277 | datatime = [] | |
278 |
|
278 | |||
279 | datatime.append(self.ltctime) |
|
279 | datatime.append(self.ltctime) | |
280 | datatime.append(self.ltctime + self.timeInterval+1) |
|
280 | datatime.append(self.ltctime + self.timeInterval+1) | |
281 |
|
281 | |||
282 | datatime = numpy.array(datatime) |
|
282 | datatime = numpy.array(datatime) | |
283 |
|
283 | |||
284 | return datatime |
|
284 | return datatime | |
285 |
|
285 | |||
286 | def getFmaxTimeResponse(self): |
|
286 | def getFmaxTimeResponse(self): | |
287 |
|
287 | |||
288 | period = (10**-6)*self.getDeltaH()/(0.15) |
|
288 | period = (10**-6)*self.getDeltaH()/(0.15) | |
289 |
|
289 | |||
290 | PRF = 1./(period * self.nCohInt) |
|
290 | PRF = 1./(period * self.nCohInt) | |
291 |
|
291 | |||
292 | fmax = PRF |
|
292 | fmax = PRF | |
293 |
|
293 | |||
294 | return fmax |
|
294 | return fmax | |
295 |
|
295 | |||
296 | def getFmax(self): |
|
296 | def getFmax(self): | |
297 |
|
297 | |||
298 | PRF = 1./(self.ippSeconds * self.nCohInt) |
|
298 | PRF = 1./(self.ippSeconds * self.nCohInt) | |
299 |
|
299 | |||
300 | fmax = PRF |
|
300 | fmax = PRF | |
301 |
|
301 | |||
302 | return fmax |
|
302 | return fmax | |
303 |
|
303 | |||
304 | def getVmax(self): |
|
304 | def getVmax(self): | |
305 |
|
305 | |||
306 | _lambda = self.C/self.frequency |
|
306 | _lambda = self.C/self.frequency | |
307 |
|
307 | |||
308 | vmax = self.getFmax() * _lambda |
|
308 | vmax = self.getFmax() * _lambda | |
309 |
|
309 | |||
310 | return vmax |
|
310 | return vmax | |
311 |
|
311 | |||
312 | def get_ippSeconds(self): |
|
312 | def get_ippSeconds(self): | |
313 | ''' |
|
313 | ''' | |
314 | ''' |
|
314 | ''' | |
315 | return self.radarControllerHeaderObj.ippSeconds |
|
315 | return self.radarControllerHeaderObj.ippSeconds | |
316 |
|
316 | |||
317 | def set_ippSeconds(self, ippSeconds): |
|
317 | def set_ippSeconds(self, ippSeconds): | |
318 | ''' |
|
318 | ''' | |
319 | ''' |
|
319 | ''' | |
320 |
|
320 | |||
321 | self.radarControllerHeaderObj.ippSeconds = ippSeconds |
|
321 | self.radarControllerHeaderObj.ippSeconds = ippSeconds | |
322 |
|
322 | |||
323 | return |
|
323 | return | |
324 |
|
324 | |||
325 | def get_dtype(self): |
|
325 | def get_dtype(self): | |
326 | ''' |
|
326 | ''' | |
327 | ''' |
|
327 | ''' | |
328 | return getNumpyDtype(self.datatype) |
|
328 | return getNumpyDtype(self.datatype) | |
329 |
|
329 | |||
330 | def set_dtype(self, numpyDtype): |
|
330 | def set_dtype(self, numpyDtype): | |
331 | ''' |
|
331 | ''' | |
332 | ''' |
|
332 | ''' | |
333 |
|
333 | |||
334 | self.datatype = getDataTypeCode(numpyDtype) |
|
334 | self.datatype = getDataTypeCode(numpyDtype) | |
335 |
|
335 | |||
336 | def get_code(self): |
|
336 | def get_code(self): | |
337 | ''' |
|
337 | ''' | |
338 | ''' |
|
338 | ''' | |
339 | return self.radarControllerHeaderObj.code |
|
339 | return self.radarControllerHeaderObj.code | |
340 |
|
340 | |||
341 | def set_code(self, code): |
|
341 | def set_code(self, code): | |
342 | ''' |
|
342 | ''' | |
343 | ''' |
|
343 | ''' | |
344 | self.radarControllerHeaderObj.code = code |
|
344 | self.radarControllerHeaderObj.code = code | |
345 |
|
345 | |||
346 | return |
|
346 | return | |
347 |
|
347 | |||
348 | def get_ncode(self): |
|
348 | def get_ncode(self): | |
349 | ''' |
|
349 | ''' | |
350 | ''' |
|
350 | ''' | |
351 | return self.radarControllerHeaderObj.nCode |
|
351 | return self.radarControllerHeaderObj.nCode | |
352 |
|
352 | |||
353 | def set_ncode(self, nCode): |
|
353 | def set_ncode(self, nCode): | |
354 | ''' |
|
354 | ''' | |
355 | ''' |
|
355 | ''' | |
356 | self.radarControllerHeaderObj.nCode = nCode |
|
356 | self.radarControllerHeaderObj.nCode = nCode | |
357 |
|
357 | |||
358 | return |
|
358 | return | |
359 |
|
359 | |||
360 | def get_nbaud(self): |
|
360 | def get_nbaud(self): | |
361 | ''' |
|
361 | ''' | |
362 | ''' |
|
362 | ''' | |
363 | return self.radarControllerHeaderObj.nBaud |
|
363 | return self.radarControllerHeaderObj.nBaud | |
364 |
|
364 | |||
365 | def set_nbaud(self, nBaud): |
|
365 | def set_nbaud(self, nBaud): | |
366 | ''' |
|
366 | ''' | |
367 | ''' |
|
367 | ''' | |
368 | self.radarControllerHeaderObj.nBaud = nBaud |
|
368 | self.radarControllerHeaderObj.nBaud = nBaud | |
369 |
|
369 | |||
370 | return |
|
370 | return | |
371 |
|
371 | |||
372 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
372 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
373 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
373 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
374 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
374 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
375 | #noise = property(getNoise, "I'm the 'nHeights' property.") |
|
375 | #noise = property(getNoise, "I'm the 'nHeights' property.") | |
376 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
376 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
377 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
377 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
378 | ippSeconds = property(get_ippSeconds, set_ippSeconds) |
|
378 | ippSeconds = property(get_ippSeconds, set_ippSeconds) | |
379 | dtype = property(get_dtype, set_dtype) |
|
379 | dtype = property(get_dtype, set_dtype) | |
380 | # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
380 | # timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
381 | code = property(get_code, set_code) |
|
381 | code = property(get_code, set_code) | |
382 | nCode = property(get_ncode, set_ncode) |
|
382 | nCode = property(get_ncode, set_ncode) | |
383 | nBaud = property(get_nbaud, set_nbaud) |
|
383 | nBaud = property(get_nbaud, set_nbaud) | |
384 |
|
384 | |||
385 | class Voltage(JROData): |
|
385 | class Voltage(JROData): | |
386 |
|
386 | |||
387 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
387 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
388 | data = None |
|
388 | data = None | |
389 |
|
389 | |||
390 | def __init__(self): |
|
390 | def __init__(self): | |
391 | ''' |
|
391 | ''' | |
392 | Constructor |
|
392 | Constructor | |
393 | ''' |
|
393 | ''' | |
394 |
|
394 | |||
395 | self.useLocalTime = True |
|
395 | self.useLocalTime = True | |
396 |
|
396 | |||
397 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
397 | self.radarControllerHeaderObj = RadarControllerHeader() | |
398 |
|
398 | |||
399 | self.systemHeaderObj = SystemHeader() |
|
399 | self.systemHeaderObj = SystemHeader() | |
400 |
|
400 | |||
401 | self.type = "Voltage" |
|
401 | self.type = "Voltage" | |
402 |
|
402 | |||
403 | self.data = None |
|
403 | self.data = None | |
404 |
|
404 | |||
405 | # self.dtype = None |
|
405 | # self.dtype = None | |
406 |
|
406 | |||
407 | # self.nChannels = 0 |
|
407 | # self.nChannels = 0 | |
408 |
|
408 | |||
409 | # self.nHeights = 0 |
|
409 | # self.nHeights = 0 | |
410 |
|
410 | |||
411 | self.nProfiles = None |
|
411 | self.nProfiles = None | |
412 |
|
412 | |||
413 | self.heightList = None |
|
413 | self.heightList = None | |
414 |
|
414 | |||
415 | self.channelList = None |
|
415 | self.channelList = None | |
416 |
|
416 | |||
417 | # self.channelIndexList = None |
|
417 | # self.channelIndexList = None | |
418 |
|
418 | |||
419 | self.flagNoData = True |
|
419 | self.flagNoData = True | |
420 |
|
420 | |||
421 | self.flagDiscontinuousBlock = False |
|
421 | self.flagDiscontinuousBlock = False | |
422 |
|
422 | |||
423 | self.utctime = None |
|
423 | self.utctime = None | |
424 |
|
424 | |||
425 | self.timeZone = None |
|
425 | self.timeZone = None | |
426 |
|
426 | |||
427 | self.dstFlag = None |
|
427 | self.dstFlag = None | |
428 |
|
428 | |||
429 | self.errorCount = None |
|
429 | self.errorCount = None | |
430 |
|
430 | |||
431 | self.nCohInt = None |
|
431 | self.nCohInt = None | |
432 |
|
432 | |||
433 | self.blocksize = None |
|
433 | self.blocksize = None | |
434 |
|
434 | |||
435 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
435 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
436 |
|
436 | |||
437 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
437 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
438 |
|
438 | |||
439 | self.flagShiftFFT = False |
|
439 | self.flagShiftFFT = False | |
440 |
|
440 | |||
441 | self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil |
|
441 | self.flagDataAsBlock = False #Asumo que la data es leida perfil a perfil | |
442 |
|
442 | |||
443 | self.profileIndex = 0 |
|
443 | self.profileIndex = 0 | |
444 |
|
444 | |||
445 | def getNoisebyHildebrand(self, channel = None): |
|
445 | def getNoisebyHildebrand(self, channel = None): | |
446 | """ |
|
446 | """ | |
447 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
447 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
448 |
|
448 | |||
449 | Return: |
|
449 | Return: | |
450 | noiselevel |
|
450 | noiselevel | |
451 | """ |
|
451 | """ | |
452 |
|
452 | |||
453 | if channel != None: |
|
453 | if channel != None: | |
454 | data = self.data[channel] |
|
454 | data = self.data[channel] | |
455 | nChannels = 1 |
|
455 | nChannels = 1 | |
456 | else: |
|
456 | else: | |
457 | data = self.data |
|
457 | data = self.data | |
458 | nChannels = self.nChannels |
|
458 | nChannels = self.nChannels | |
459 |
|
459 | |||
460 | noise = numpy.zeros(nChannels) |
|
460 | noise = numpy.zeros(nChannels) | |
461 | power = data * numpy.conjugate(data) |
|
461 | power = data * numpy.conjugate(data) | |
462 |
|
462 | |||
463 | for thisChannel in range(nChannels): |
|
463 | for thisChannel in range(nChannels): | |
464 | if nChannels == 1: |
|
464 | if nChannels == 1: | |
465 | daux = power[:].real |
|
465 | daux = power[:].real | |
466 | else: |
|
466 | else: | |
467 | daux = power[thisChannel,:].real |
|
467 | daux = power[thisChannel,:].real | |
468 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) |
|
468 | noise[thisChannel] = hildebrand_sekhon(daux, self.nCohInt) | |
469 |
|
469 | |||
470 | return noise |
|
470 | return noise | |
471 |
|
471 | |||
472 | def getNoise(self, type = 1, channel = None): |
|
472 | def getNoise(self, type = 1, channel = None): | |
473 |
|
473 | |||
474 | if type == 1: |
|
474 | if type == 1: | |
475 | noise = self.getNoisebyHildebrand(channel) |
|
475 | noise = self.getNoisebyHildebrand(channel) | |
476 |
|
476 | |||
477 | return noise |
|
477 | return noise | |
478 |
|
478 | |||
479 | def getPower(self, channel = None): |
|
479 | def getPower(self, channel = None): | |
480 |
|
480 | |||
481 | if channel != None: |
|
481 | if channel != None: | |
482 | data = self.data[channel] |
|
482 | data = self.data[channel] | |
483 | else: |
|
483 | else: | |
484 | data = self.data |
|
484 | data = self.data | |
485 |
|
485 | |||
486 | power = data * numpy.conjugate(data) |
|
486 | power = data * numpy.conjugate(data) | |
487 |
|
487 | |||
488 | return 10*numpy.log10(power.real) |
|
488 | return 10*numpy.log10(power.real) | |
489 |
|
489 | |||
490 | def getTimeInterval(self): |
|
490 | def getTimeInterval(self): | |
491 |
|
491 | |||
492 | timeInterval = self.ippSeconds * self.nCohInt |
|
492 | timeInterval = self.ippSeconds * self.nCohInt | |
493 |
|
493 | |||
494 | return timeInterval |
|
494 | return timeInterval | |
495 |
|
495 | |||
496 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
496 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
497 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
497 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
498 |
|
498 | |||
499 | class Spectra(JROData): |
|
499 | class Spectra(JROData): | |
500 |
|
500 | |||
501 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) |
|
501 | #data spc es un numpy array de 2 dmensiones (canales, perfiles, alturas) | |
502 | data_spc = None |
|
502 | data_spc = None | |
503 |
|
503 | |||
504 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) |
|
504 | #data cspc es un numpy array de 2 dmensiones (canales, pares, alturas) | |
505 | data_cspc = None |
|
505 | data_cspc = None | |
506 |
|
506 | |||
507 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
507 | #data dc es un numpy array de 2 dmensiones (canales, alturas) | |
508 | data_dc = None |
|
508 | data_dc = None | |
509 |
|
509 | |||
|
510 | #data power | |||
|
511 | data_pwr = None | |||
|
512 | ||||
510 | nFFTPoints = None |
|
513 | nFFTPoints = None | |
511 |
|
514 | |||
512 | # nPairs = None |
|
515 | # nPairs = None | |
513 |
|
516 | |||
514 | pairsList = None |
|
517 | pairsList = None | |
515 |
|
518 | |||
516 | nIncohInt = None |
|
519 | nIncohInt = None | |
517 |
|
520 | |||
518 | 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 | |
519 |
|
522 | |||
520 | nCohInt = None #se requiere para determinar el valor de timeInterval |
|
523 | nCohInt = None #se requiere para determinar el valor de timeInterval | |
521 |
|
524 | |||
522 | ippFactor = None |
|
525 | ippFactor = None | |
523 |
|
526 | |||
524 | profileIndex = 0 |
|
527 | profileIndex = 0 | |
525 |
|
528 | |||
526 | plotting = "spectra" |
|
529 | plotting = "spectra" | |
527 |
|
530 | |||
528 | def __init__(self): |
|
531 | def __init__(self): | |
529 | ''' |
|
532 | ''' | |
530 | Constructor |
|
533 | Constructor | |
531 | ''' |
|
534 | ''' | |
532 |
|
535 | |||
533 | self.useLocalTime = True |
|
536 | self.useLocalTime = True | |
534 |
|
537 | |||
535 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
538 | self.radarControllerHeaderObj = RadarControllerHeader() | |
536 |
|
539 | |||
537 | self.systemHeaderObj = SystemHeader() |
|
540 | self.systemHeaderObj = SystemHeader() | |
538 |
|
541 | |||
539 | self.type = "Spectra" |
|
542 | self.type = "Spectra" | |
540 |
|
543 | |||
541 | # self.data = None |
|
544 | # self.data = None | |
542 |
|
545 | |||
543 | # self.dtype = None |
|
546 | # self.dtype = None | |
544 |
|
547 | |||
545 | # self.nChannels = 0 |
|
548 | # self.nChannels = 0 | |
546 |
|
549 | |||
547 | # self.nHeights = 0 |
|
550 | # self.nHeights = 0 | |
548 |
|
551 | |||
549 | self.nProfiles = None |
|
552 | self.nProfiles = None | |
550 |
|
553 | |||
551 | self.heightList = None |
|
554 | self.heightList = None | |
552 |
|
555 | |||
553 | self.channelList = None |
|
556 | self.channelList = None | |
554 |
|
557 | |||
555 | # self.channelIndexList = None |
|
558 | # self.channelIndexList = None | |
556 |
|
559 | |||
557 | self.pairsList = None |
|
560 | self.pairsList = None | |
558 |
|
561 | |||
559 | self.flagNoData = True |
|
562 | self.flagNoData = True | |
560 |
|
563 | |||
561 | self.flagDiscontinuousBlock = False |
|
564 | self.flagDiscontinuousBlock = False | |
562 |
|
565 | |||
563 | self.utctime = None |
|
566 | self.utctime = None | |
564 |
|
567 | |||
565 | self.nCohInt = None |
|
568 | self.nCohInt = None | |
566 |
|
569 | |||
567 | self.nIncohInt = None |
|
570 | self.nIncohInt = None | |
568 |
|
571 | |||
569 | self.blocksize = None |
|
572 | self.blocksize = None | |
570 |
|
573 | |||
571 | self.nFFTPoints = None |
|
574 | self.nFFTPoints = None | |
572 |
|
575 | |||
573 | self.wavelength = None |
|
576 | self.wavelength = None | |
574 |
|
577 | |||
575 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
578 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
576 |
|
579 | |||
577 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
580 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
578 |
|
581 | |||
579 | self.flagShiftFFT = False |
|
582 | self.flagShiftFFT = False | |
580 |
|
583 | |||
581 | self.ippFactor = 1 |
|
584 | self.ippFactor = 1 | |
582 |
|
585 | |||
583 | #self.noise = None |
|
586 | #self.noise = None | |
584 |
|
587 | |||
585 | self.beacon_heiIndexList = [] |
|
588 | self.beacon_heiIndexList = [] | |
586 |
|
589 | |||
587 | self.noise_estimation = None |
|
590 | self.noise_estimation = None | |
588 |
|
591 | |||
589 |
|
592 | |||
590 | 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): | |
591 | """ |
|
594 | """ | |
592 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
595 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
593 |
|
596 | |||
594 | Return: |
|
597 | Return: | |
595 | noiselevel |
|
598 | noiselevel | |
596 | """ |
|
599 | """ | |
597 |
|
600 | |||
598 | noise = numpy.zeros(self.nChannels) |
|
601 | noise = numpy.zeros(self.nChannels) | |
599 |
|
602 | |||
600 | for channel in range(self.nChannels): |
|
603 | for channel in range(self.nChannels): | |
601 | 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] | |
602 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) |
|
605 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) | |
603 |
|
606 | |||
604 | return noise |
|
607 | return noise | |
605 |
|
608 | |||
606 | 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): | |
607 |
|
610 | |||
608 | if self.noise_estimation is not None: |
|
611 | if self.noise_estimation is not None: | |
609 | 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 | |
610 | else: |
|
613 | else: | |
611 | noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index) |
|
614 | noise = self.getNoisebyHildebrand(xmin_index, xmax_index, ymin_index, ymax_index) | |
612 | return noise |
|
615 | return noise | |
613 |
|
616 | |||
614 | def getFreqRangeTimeResponse(self, extrapoints=0): |
|
617 | def getFreqRangeTimeResponse(self, extrapoints=0): | |
615 |
|
618 | |||
616 | deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints*self.ippFactor) |
|
619 | deltafreq = self.getFmaxTimeResponse() / (self.nFFTPoints*self.ippFactor) | |
617 | 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 | |
618 |
|
621 | |||
619 | return freqrange |
|
622 | return freqrange | |
620 |
|
623 | |||
621 | def getAcfRange(self, extrapoints=0): |
|
624 | def getAcfRange(self, extrapoints=0): | |
622 |
|
625 | |||
623 | deltafreq = 10./(self.getFmax() / (self.nFFTPoints*self.ippFactor)) |
|
626 | deltafreq = 10./(self.getFmax() / (self.nFFTPoints*self.ippFactor)) | |
624 | 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 | |
625 |
|
628 | |||
626 | return freqrange |
|
629 | return freqrange | |
627 |
|
630 | |||
628 | def getFreqRange(self, extrapoints=0): |
|
631 | def getFreqRange(self, extrapoints=0): | |
629 |
|
632 | |||
630 | deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor) |
|
633 | deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor) | |
631 | 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 | |
632 |
|
635 | |||
633 | return freqrange |
|
636 | return freqrange | |
634 |
|
637 | |||
635 | def getVelRange(self, extrapoints=0): |
|
638 | def getVelRange(self, extrapoints=0): | |
636 |
|
639 | |||
637 | deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor) |
|
640 | deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor) | |
638 | 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 | |
639 |
|
642 | |||
640 | return velrange |
|
643 | return velrange | |
641 |
|
644 | |||
642 | def getNPairs(self): |
|
645 | def getNPairs(self): | |
643 |
|
646 | |||
644 | return len(self.pairsList) |
|
647 | return len(self.pairsList) | |
645 |
|
648 | |||
646 | def getPairsIndexList(self): |
|
649 | def getPairsIndexList(self): | |
647 |
|
650 | |||
648 | return range(self.nPairs) |
|
651 | return range(self.nPairs) | |
649 |
|
652 | |||
650 | def getNormFactor(self): |
|
653 | def getNormFactor(self): | |
651 |
|
654 | |||
652 | pwcode = 1 |
|
655 | pwcode = 1 | |
653 |
|
656 | |||
654 | if self.flagDecodeData: |
|
657 | if self.flagDecodeData: | |
655 | pwcode = numpy.sum(self.code[0]**2) |
|
658 | pwcode = numpy.sum(self.code[0]**2) | |
656 | #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 | |
657 | normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
660 | normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
658 |
|
661 | |||
659 | return normFactor |
|
662 | return normFactor | |
660 |
|
663 | |||
661 | def getFlagCspc(self): |
|
664 | def getFlagCspc(self): | |
662 |
|
665 | |||
663 | if self.data_cspc is None: |
|
666 | if self.data_cspc is None: | |
664 | return True |
|
667 | return True | |
665 |
|
668 | |||
666 | return False |
|
669 | return False | |
667 |
|
670 | |||
668 | def getFlagDc(self): |
|
671 | def getFlagDc(self): | |
669 |
|
672 | |||
670 | if self.data_dc is None: |
|
673 | if self.data_dc is None: | |
671 | return True |
|
674 | return True | |
672 |
|
675 | |||
673 | return False |
|
676 | return False | |
674 |
|
677 | |||
675 | def getTimeInterval(self): |
|
678 | def getTimeInterval(self): | |
676 |
|
679 | |||
677 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles |
|
680 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt * self.nProfiles | |
678 |
|
681 | |||
679 | return timeInterval |
|
682 | return timeInterval | |
680 |
|
683 | |||
|
684 | def getPower(self): | |||
|
685 | ||||
|
686 | factor = self.normFactor | |||
|
687 | z = self.data_spc/factor | |||
|
688 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |||
|
689 | avg = numpy.average(z, axis=1) | |||
|
690 | ||||
|
691 | return 10*numpy.log10(avg) | |||
|
692 | ||||
681 | def setValue(self, value): |
|
693 | def setValue(self, value): | |
682 |
|
694 | |||
683 | print "This property should not be initialized" |
|
695 | print "This property should not be initialized" | |
684 |
|
696 | |||
685 | return |
|
697 | return | |
686 |
|
698 | |||
687 | nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.") |
|
699 | nPairs = property(getNPairs, setValue, "I'm the 'nPairs' property.") | |
688 | pairsIndexList = property(getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.") |
|
700 | pairsIndexList = property(getPairsIndexList, setValue, "I'm the 'pairsIndexList' property.") | |
689 | normFactor = property(getNormFactor, setValue, "I'm the 'getNormFactor' property.") |
|
701 | normFactor = property(getNormFactor, setValue, "I'm the 'getNormFactor' property.") | |
690 | flag_cspc = property(getFlagCspc, setValue) |
|
702 | flag_cspc = property(getFlagCspc, setValue) | |
691 | flag_dc = property(getFlagDc, setValue) |
|
703 | flag_dc = property(getFlagDc, setValue) | |
692 | noise = property(getNoise, setValue, "I'm the 'nHeights' property.") |
|
704 | noise = property(getNoise, setValue, "I'm the 'nHeights' property.") | |
693 | timeInterval = property(getTimeInterval, setValue, "I'm the 'timeInterval' property") |
|
705 | timeInterval = property(getTimeInterval, setValue, "I'm the 'timeInterval' property") | |
694 |
|
706 | |||
695 | class SpectraHeis(Spectra): |
|
707 | class SpectraHeis(Spectra): | |
696 |
|
708 | |||
697 | data_spc = None |
|
709 | data_spc = None | |
698 |
|
710 | |||
699 | data_cspc = None |
|
711 | data_cspc = None | |
700 |
|
712 | |||
701 | data_dc = None |
|
713 | data_dc = None | |
702 |
|
714 | |||
703 | nFFTPoints = None |
|
715 | nFFTPoints = None | |
704 |
|
716 | |||
705 | # nPairs = None |
|
717 | # nPairs = None | |
706 |
|
718 | |||
707 | pairsList = None |
|
719 | pairsList = None | |
708 |
|
720 | |||
709 | nCohInt = None |
|
721 | nCohInt = None | |
710 |
|
722 | |||
711 | nIncohInt = None |
|
723 | nIncohInt = None | |
712 |
|
724 | |||
713 | def __init__(self): |
|
725 | def __init__(self): | |
714 |
|
726 | |||
715 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
727 | self.radarControllerHeaderObj = RadarControllerHeader() | |
716 |
|
728 | |||
717 | self.systemHeaderObj = SystemHeader() |
|
729 | self.systemHeaderObj = SystemHeader() | |
718 |
|
730 | |||
719 | self.type = "SpectraHeis" |
|
731 | self.type = "SpectraHeis" | |
720 |
|
732 | |||
721 | # self.dtype = None |
|
733 | # self.dtype = None | |
722 |
|
734 | |||
723 | # self.nChannels = 0 |
|
735 | # self.nChannels = 0 | |
724 |
|
736 | |||
725 | # self.nHeights = 0 |
|
737 | # self.nHeights = 0 | |
726 |
|
738 | |||
727 | self.nProfiles = None |
|
739 | self.nProfiles = None | |
728 |
|
740 | |||
729 | self.heightList = None |
|
741 | self.heightList = None | |
730 |
|
742 | |||
731 | self.channelList = None |
|
743 | self.channelList = None | |
732 |
|
744 | |||
733 | # self.channelIndexList = None |
|
745 | # self.channelIndexList = None | |
734 |
|
746 | |||
735 | self.flagNoData = True |
|
747 | self.flagNoData = True | |
736 |
|
748 | |||
737 | self.flagDiscontinuousBlock = False |
|
749 | self.flagDiscontinuousBlock = False | |
738 |
|
750 | |||
739 | # self.nPairs = 0 |
|
751 | # self.nPairs = 0 | |
740 |
|
752 | |||
741 | self.utctime = None |
|
753 | self.utctime = None | |
742 |
|
754 | |||
743 | self.blocksize = None |
|
755 | self.blocksize = None | |
744 |
|
756 | |||
745 | self.profileIndex = 0 |
|
757 | self.profileIndex = 0 | |
746 |
|
758 | |||
747 | self.nCohInt = 1 |
|
759 | self.nCohInt = 1 | |
748 |
|
760 | |||
749 | self.nIncohInt = 1 |
|
761 | self.nIncohInt = 1 | |
750 |
|
762 | |||
751 | def getNormFactor(self): |
|
763 | def getNormFactor(self): | |
752 | pwcode = 1 |
|
764 | pwcode = 1 | |
753 | if self.flagDecodeData: |
|
765 | if self.flagDecodeData: | |
754 | pwcode = numpy.sum(self.code[0]**2) |
|
766 | pwcode = numpy.sum(self.code[0]**2) | |
755 |
|
767 | |||
756 | normFactor = self.nIncohInt*self.nCohInt*pwcode |
|
768 | normFactor = self.nIncohInt*self.nCohInt*pwcode | |
757 |
|
769 | |||
758 | return normFactor |
|
770 | return normFactor | |
759 |
|
771 | |||
760 | def getTimeInterval(self): |
|
772 | def getTimeInterval(self): | |
761 |
|
773 | |||
762 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
774 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
763 |
|
775 | |||
764 | return timeInterval |
|
776 | return timeInterval | |
765 |
|
777 | |||
766 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") |
|
778 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") | |
767 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
779 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
768 |
|
780 | |||
769 | class Fits(JROData): |
|
781 | class Fits(JROData): | |
770 |
|
782 | |||
771 | heightList = None |
|
783 | heightList = None | |
772 |
|
784 | |||
773 | channelList = None |
|
785 | channelList = None | |
774 |
|
786 | |||
775 | flagNoData = True |
|
787 | flagNoData = True | |
776 |
|
788 | |||
777 | flagDiscontinuousBlock = False |
|
789 | flagDiscontinuousBlock = False | |
778 |
|
790 | |||
779 | useLocalTime = False |
|
791 | useLocalTime = False | |
780 |
|
792 | |||
781 | utctime = None |
|
793 | utctime = None | |
782 |
|
794 | |||
783 | timeZone = None |
|
795 | timeZone = None | |
784 |
|
796 | |||
785 | # ippSeconds = None |
|
797 | # ippSeconds = None | |
786 |
|
798 | |||
787 | # timeInterval = None |
|
799 | # timeInterval = None | |
788 |
|
800 | |||
789 | nCohInt = None |
|
801 | nCohInt = None | |
790 |
|
802 | |||
791 | nIncohInt = None |
|
803 | nIncohInt = None | |
792 |
|
804 | |||
793 | noise = None |
|
805 | noise = None | |
794 |
|
806 | |||
795 | windowOfFilter = 1 |
|
807 | windowOfFilter = 1 | |
796 |
|
808 | |||
797 | #Speed of ligth |
|
809 | #Speed of ligth | |
798 | C = 3e8 |
|
810 | C = 3e8 | |
799 |
|
811 | |||
800 | frequency = 49.92e6 |
|
812 | frequency = 49.92e6 | |
801 |
|
813 | |||
802 | realtime = False |
|
814 | realtime = False | |
803 |
|
815 | |||
804 |
|
816 | |||
805 | def __init__(self): |
|
817 | def __init__(self): | |
806 |
|
818 | |||
807 | self.type = "Fits" |
|
819 | self.type = "Fits" | |
808 |
|
820 | |||
809 | self.nProfiles = None |
|
821 | self.nProfiles = None | |
810 |
|
822 | |||
811 | self.heightList = None |
|
823 | self.heightList = None | |
812 |
|
824 | |||
813 | self.channelList = None |
|
825 | self.channelList = None | |
814 |
|
826 | |||
815 | # self.channelIndexList = None |
|
827 | # self.channelIndexList = None | |
816 |
|
828 | |||
817 | self.flagNoData = True |
|
829 | self.flagNoData = True | |
818 |
|
830 | |||
819 | self.utctime = None |
|
831 | self.utctime = None | |
820 |
|
832 | |||
821 | self.nCohInt = 1 |
|
833 | self.nCohInt = 1 | |
822 |
|
834 | |||
823 | self.nIncohInt = 1 |
|
835 | self.nIncohInt = 1 | |
824 |
|
836 | |||
825 | self.useLocalTime = True |
|
837 | self.useLocalTime = True | |
826 |
|
838 | |||
827 | self.profileIndex = 0 |
|
839 | self.profileIndex = 0 | |
828 |
|
840 | |||
829 | # self.utctime = None |
|
841 | # self.utctime = None | |
830 | # self.timeZone = None |
|
842 | # self.timeZone = None | |
831 | # self.ltctime = None |
|
843 | # self.ltctime = None | |
832 | # self.timeInterval = None |
|
844 | # self.timeInterval = None | |
833 | # self.header = None |
|
845 | # self.header = None | |
834 | # self.data_header = None |
|
846 | # self.data_header = None | |
835 | # self.data = None |
|
847 | # self.data = None | |
836 | # self.datatime = None |
|
848 | # self.datatime = None | |
837 | # self.flagNoData = False |
|
849 | # self.flagNoData = False | |
838 | # self.expName = '' |
|
850 | # self.expName = '' | |
839 | # self.nChannels = None |
|
851 | # self.nChannels = None | |
840 | # self.nSamples = None |
|
852 | # self.nSamples = None | |
841 | # self.dataBlocksPerFile = None |
|
853 | # self.dataBlocksPerFile = None | |
842 | # self.comments = '' |
|
854 | # self.comments = '' | |
843 | # |
|
855 | # | |
844 |
|
856 | |||
845 |
|
857 | |||
846 | def getltctime(self): |
|
858 | def getltctime(self): | |
847 |
|
859 | |||
848 | if self.useLocalTime: |
|
860 | if self.useLocalTime: | |
849 | return self.utctime - self.timeZone*60 |
|
861 | return self.utctime - self.timeZone*60 | |
850 |
|
862 | |||
851 | return self.utctime |
|
863 | return self.utctime | |
852 |
|
864 | |||
853 | def getDatatime(self): |
|
865 | def getDatatime(self): | |
854 |
|
866 | |||
855 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
867 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) | |
856 | return datatime |
|
868 | return datatime | |
857 |
|
869 | |||
858 | def getTimeRange(self): |
|
870 | def getTimeRange(self): | |
859 |
|
871 | |||
860 | datatime = [] |
|
872 | datatime = [] | |
861 |
|
873 | |||
862 | datatime.append(self.ltctime) |
|
874 | datatime.append(self.ltctime) | |
863 | datatime.append(self.ltctime + self.timeInterval) |
|
875 | datatime.append(self.ltctime + self.timeInterval) | |
864 |
|
876 | |||
865 | datatime = numpy.array(datatime) |
|
877 | datatime = numpy.array(datatime) | |
866 |
|
878 | |||
867 | return datatime |
|
879 | return datatime | |
868 |
|
880 | |||
869 | def getHeiRange(self): |
|
881 | def getHeiRange(self): | |
870 |
|
882 | |||
871 | heis = self.heightList |
|
883 | heis = self.heightList | |
872 |
|
884 | |||
873 | return heis |
|
885 | return heis | |
874 |
|
886 | |||
875 | def getNHeights(self): |
|
887 | def getNHeights(self): | |
876 |
|
888 | |||
877 | return len(self.heightList) |
|
889 | return len(self.heightList) | |
878 |
|
890 | |||
879 | def getNChannels(self): |
|
891 | def getNChannels(self): | |
880 |
|
892 | |||
881 | return len(self.channelList) |
|
893 | return len(self.channelList) | |
882 |
|
894 | |||
883 | def getChannelIndexList(self): |
|
895 | def getChannelIndexList(self): | |
884 |
|
896 | |||
885 | return range(self.nChannels) |
|
897 | return range(self.nChannels) | |
886 |
|
898 | |||
887 | def getNoise(self, type = 1): |
|
899 | def getNoise(self, type = 1): | |
888 |
|
900 | |||
889 | #noise = numpy.zeros(self.nChannels) |
|
901 | #noise = numpy.zeros(self.nChannels) | |
890 |
|
902 | |||
891 | if type == 1: |
|
903 | if type == 1: | |
892 | noise = self.getNoisebyHildebrand() |
|
904 | noise = self.getNoisebyHildebrand() | |
893 |
|
905 | |||
894 | if type == 2: |
|
906 | if type == 2: | |
895 | noise = self.getNoisebySort() |
|
907 | noise = self.getNoisebySort() | |
896 |
|
908 | |||
897 | if type == 3: |
|
909 | if type == 3: | |
898 | noise = self.getNoisebyWindow() |
|
910 | noise = self.getNoisebyWindow() | |
899 |
|
911 | |||
900 | return noise |
|
912 | return noise | |
901 |
|
913 | |||
902 | def getTimeInterval(self): |
|
914 | def getTimeInterval(self): | |
903 |
|
915 | |||
904 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt |
|
916 | timeInterval = self.ippSeconds * self.nCohInt * self.nIncohInt | |
905 |
|
917 | |||
906 | return timeInterval |
|
918 | return timeInterval | |
907 |
|
919 | |||
908 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
920 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
909 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
921 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
910 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
922 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
911 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
923 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
912 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
924 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
913 |
|
925 | |||
914 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
926 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
915 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
927 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
916 |
|
928 | |||
917 | class Correlation(JROData): |
|
929 | class Correlation(JROData): | |
918 |
|
930 | |||
919 | noise = None |
|
931 | noise = None | |
920 |
|
932 | |||
921 | SNR = None |
|
933 | SNR = None | |
922 |
|
934 | |||
923 | pairsAutoCorr = None #Pairs of Autocorrelation |
|
935 | pairsAutoCorr = None #Pairs of Autocorrelation | |
924 |
|
936 | |||
925 | #-------------------------------------------------- |
|
937 | #-------------------------------------------------- | |
926 |
|
938 | |||
927 | data_corr = None |
|
939 | data_corr = None | |
928 |
|
940 | |||
929 | data_volt = None |
|
941 | data_volt = None | |
930 |
|
942 | |||
931 | lagT = None # each element value is a profileIndex |
|
943 | lagT = None # each element value is a profileIndex | |
932 |
|
944 | |||
933 | lagR = None # each element value is in km |
|
945 | lagR = None # each element value is in km | |
934 |
|
946 | |||
935 | pairsList = None |
|
947 | pairsList = None | |
936 |
|
948 | |||
937 | calculateVelocity = None |
|
949 | calculateVelocity = None | |
938 |
|
950 | |||
939 | nPoints = None |
|
951 | nPoints = None | |
940 |
|
952 | |||
941 | nAvg = None |
|
953 | nAvg = None | |
942 |
|
954 | |||
943 | bufferSize = None |
|
955 | bufferSize = None | |
944 |
|
956 | |||
945 | def __init__(self): |
|
957 | def __init__(self): | |
946 | ''' |
|
958 | ''' | |
947 | Constructor |
|
959 | Constructor | |
948 | ''' |
|
960 | ''' | |
949 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
961 | self.radarControllerHeaderObj = RadarControllerHeader() | |
950 |
|
962 | |||
951 | self.systemHeaderObj = SystemHeader() |
|
963 | self.systemHeaderObj = SystemHeader() | |
952 |
|
964 | |||
953 | self.type = "Correlation" |
|
965 | self.type = "Correlation" | |
954 |
|
966 | |||
955 | self.data = None |
|
967 | self.data = None | |
956 |
|
968 | |||
957 | self.dtype = None |
|
969 | self.dtype = None | |
958 |
|
970 | |||
959 | self.nProfiles = None |
|
971 | self.nProfiles = None | |
960 |
|
972 | |||
961 | self.heightList = None |
|
973 | self.heightList = None | |
962 |
|
974 | |||
963 | self.channelList = None |
|
975 | self.channelList = None | |
964 |
|
976 | |||
965 | self.flagNoData = True |
|
977 | self.flagNoData = True | |
966 |
|
978 | |||
967 | self.flagDiscontinuousBlock = False |
|
979 | self.flagDiscontinuousBlock = False | |
968 |
|
980 | |||
969 | self.utctime = None |
|
981 | self.utctime = None | |
970 |
|
982 | |||
971 | self.timeZone = None |
|
983 | self.timeZone = None | |
972 |
|
984 | |||
973 | self.dstFlag = None |
|
985 | self.dstFlag = None | |
974 |
|
986 | |||
975 | self.errorCount = None |
|
987 | self.errorCount = None | |
976 |
|
988 | |||
977 | self.blocksize = None |
|
989 | self.blocksize = None | |
978 |
|
990 | |||
979 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
991 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
980 |
|
992 | |||
981 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
993 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
982 |
|
994 | |||
983 | self.pairsList = None |
|
995 | self.pairsList = None | |
984 |
|
996 | |||
985 | self.nPoints = None |
|
997 | self.nPoints = None | |
986 |
|
998 | |||
987 | def getLagTRange(self, extrapoints=0): |
|
999 | def getLagTRange(self, extrapoints=0): | |
988 |
|
1000 | |||
989 | lagTRange = self.lagT |
|
1001 | lagTRange = self.lagT | |
990 | diff = lagTRange[1] - lagTRange[0] |
|
1002 | diff = lagTRange[1] - lagTRange[0] | |
991 | extra = numpy.arange(1,extrapoints + 1)*diff + lagTRange[-1] |
|
1003 | extra = numpy.arange(1,extrapoints + 1)*diff + lagTRange[-1] | |
992 | lagTRange = numpy.hstack((lagTRange, extra)) |
|
1004 | lagTRange = numpy.hstack((lagTRange, extra)) | |
993 |
|
1005 | |||
994 | return lagTRange |
|
1006 | return lagTRange | |
995 |
|
1007 | |||
996 | def getLagRRange(self, extrapoints=0): |
|
1008 | def getLagRRange(self, extrapoints=0): | |
997 |
|
1009 | |||
998 | return self.lagR |
|
1010 | return self.lagR | |
999 |
|
1011 | |||
1000 | def getPairsList(self): |
|
1012 | def getPairsList(self): | |
1001 |
|
1013 | |||
1002 | return self.pairsList |
|
1014 | return self.pairsList | |
1003 |
|
1015 | |||
1004 | def getCalculateVelocity(self): |
|
1016 | def getCalculateVelocity(self): | |
1005 |
|
1017 | |||
1006 | return self.calculateVelocity |
|
1018 | return self.calculateVelocity | |
1007 |
|
1019 | |||
1008 | def getNPoints(self): |
|
1020 | def getNPoints(self): | |
1009 |
|
1021 | |||
1010 | return self.nPoints |
|
1022 | return self.nPoints | |
1011 |
|
1023 | |||
1012 | def getNAvg(self): |
|
1024 | def getNAvg(self): | |
1013 |
|
1025 | |||
1014 | return self.nAvg |
|
1026 | return self.nAvg | |
1015 |
|
1027 | |||
1016 | def getBufferSize(self): |
|
1028 | def getBufferSize(self): | |
1017 |
|
1029 | |||
1018 | return self.bufferSize |
|
1030 | return self.bufferSize | |
1019 |
|
1031 | |||
1020 | def getPairsAutoCorr(self): |
|
1032 | def getPairsAutoCorr(self): | |
1021 | pairsList = self.pairsList |
|
1033 | pairsList = self.pairsList | |
1022 | pairsAutoCorr = numpy.zeros(self.nChannels, dtype = 'int')*numpy.nan |
|
1034 | pairsAutoCorr = numpy.zeros(self.nChannels, dtype = 'int')*numpy.nan | |
1023 |
|
1035 | |||
1024 | for l in range(len(pairsList)): |
|
1036 | for l in range(len(pairsList)): | |
1025 | firstChannel = pairsList[l][0] |
|
1037 | firstChannel = pairsList[l][0] | |
1026 | secondChannel = pairsList[l][1] |
|
1038 | secondChannel = pairsList[l][1] | |
1027 |
|
1039 | |||
1028 | #Obteniendo pares de Autocorrelacion |
|
1040 | #Obteniendo pares de Autocorrelacion | |
1029 | if firstChannel == secondChannel: |
|
1041 | if firstChannel == secondChannel: | |
1030 | pairsAutoCorr[firstChannel] = int(l) |
|
1042 | pairsAutoCorr[firstChannel] = int(l) | |
1031 |
|
1043 | |||
1032 | pairsAutoCorr = pairsAutoCorr.astype(int) |
|
1044 | pairsAutoCorr = pairsAutoCorr.astype(int) | |
1033 |
|
1045 | |||
1034 | return pairsAutoCorr |
|
1046 | return pairsAutoCorr | |
1035 |
|
1047 | |||
1036 | def getNoise(self, mode = 2): |
|
1048 | def getNoise(self, mode = 2): | |
1037 |
|
1049 | |||
1038 | indR = numpy.where(self.lagR == 0)[0][0] |
|
1050 | indR = numpy.where(self.lagR == 0)[0][0] | |
1039 | indT = numpy.where(self.lagT == 0)[0][0] |
|
1051 | indT = numpy.where(self.lagT == 0)[0][0] | |
1040 |
|
1052 | |||
1041 | jspectra0 = self.data_corr[:,:,indR,:] |
|
1053 | jspectra0 = self.data_corr[:,:,indR,:] | |
1042 | jspectra = copy.copy(jspectra0) |
|
1054 | jspectra = copy.copy(jspectra0) | |
1043 |
|
1055 | |||
1044 | num_chan = jspectra.shape[0] |
|
1056 | num_chan = jspectra.shape[0] | |
1045 | num_hei = jspectra.shape[2] |
|
1057 | num_hei = jspectra.shape[2] | |
1046 |
|
1058 | |||
1047 | freq_dc = jspectra.shape[1]/2 |
|
1059 | freq_dc = jspectra.shape[1]/2 | |
1048 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc |
|
1060 | ind_vel = numpy.array([-2,-1,1,2]) + freq_dc | |
1049 |
|
1061 | |||
1050 | if ind_vel[0]<0: |
|
1062 | if ind_vel[0]<0: | |
1051 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof |
|
1063 | ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof | |
1052 |
|
1064 | |||
1053 | if mode == 1: |
|
1065 | if mode == 1: | |
1054 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION |
|
1066 | jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION | |
1055 |
|
1067 | |||
1056 | if mode == 2: |
|
1068 | if mode == 2: | |
1057 |
|
1069 | |||
1058 | vel = numpy.array([-2,-1,1,2]) |
|
1070 | vel = numpy.array([-2,-1,1,2]) | |
1059 | xx = numpy.zeros([4,4]) |
|
1071 | xx = numpy.zeros([4,4]) | |
1060 |
|
1072 | |||
1061 | for fil in range(4): |
|
1073 | for fil in range(4): | |
1062 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) |
|
1074 | xx[fil,:] = vel[fil]**numpy.asarray(range(4)) | |
1063 |
|
1075 | |||
1064 | xx_inv = numpy.linalg.inv(xx) |
|
1076 | xx_inv = numpy.linalg.inv(xx) | |
1065 | xx_aux = xx_inv[0,:] |
|
1077 | xx_aux = xx_inv[0,:] | |
1066 |
|
1078 | |||
1067 | for ich in range(num_chan): |
|
1079 | for ich in range(num_chan): | |
1068 | yy = jspectra[ich,ind_vel,:] |
|
1080 | yy = jspectra[ich,ind_vel,:] | |
1069 | jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy) |
|
1081 | jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy) | |
1070 |
|
1082 | |||
1071 | junkid = jspectra[ich,freq_dc,:]<=0 |
|
1083 | junkid = jspectra[ich,freq_dc,:]<=0 | |
1072 | cjunkid = sum(junkid) |
|
1084 | cjunkid = sum(junkid) | |
1073 |
|
1085 | |||
1074 | if cjunkid.any(): |
|
1086 | if cjunkid.any(): | |
1075 | jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2 |
|
1087 | jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2 | |
1076 |
|
1088 | |||
1077 | noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:] |
|
1089 | noise = jspectra0[:,freq_dc,:] - jspectra[:,freq_dc,:] | |
1078 |
|
1090 | |||
1079 | return noise |
|
1091 | return noise | |
1080 |
|
1092 | |||
1081 | def getTimeInterval(self): |
|
1093 | def getTimeInterval(self): | |
1082 |
|
1094 | |||
1083 | timeInterval = self.ippSeconds * self.nCohInt * self.nPoints |
|
1095 | timeInterval = self.ippSeconds * self.nCohInt * self.nPoints | |
1084 |
|
1096 | |||
1085 | return timeInterval |
|
1097 | return timeInterval | |
1086 |
|
1098 | |||
1087 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") |
|
1099 | timeInterval = property(getTimeInterval, "I'm the 'timeInterval' property") | |
1088 | # pairsList = property(getPairsList, "I'm the 'pairsList' property.") |
|
1100 | # pairsList = property(getPairsList, "I'm the 'pairsList' property.") | |
1089 | # nPoints = property(getNPoints, "I'm the 'nPoints' property.") |
|
1101 | # nPoints = property(getNPoints, "I'm the 'nPoints' property.") | |
1090 | calculateVelocity = property(getCalculateVelocity, "I'm the 'calculateVelocity' property.") |
|
1102 | calculateVelocity = property(getCalculateVelocity, "I'm the 'calculateVelocity' property.") | |
1091 | nAvg = property(getNAvg, "I'm the 'nAvg' property.") |
|
1103 | nAvg = property(getNAvg, "I'm the 'nAvg' property.") | |
1092 | bufferSize = property(getBufferSize, "I'm the 'bufferSize' property.") |
|
1104 | bufferSize = property(getBufferSize, "I'm the 'bufferSize' property.") | |
1093 |
|
1105 | |||
1094 |
|
1106 | |||
1095 | class Parameters(JROData): |
|
1107 | class Parameters(JROData): | |
1096 |
|
1108 | |||
|
1109 | experimentInfo = None #Information about the experiment | |||
|
1110 | ||||
1097 | #Information from previous data |
|
1111 | #Information from previous data | |
1098 |
|
1112 | |||
1099 | inputUnit = None #Type of data to be processed |
|
1113 | inputUnit = None #Type of data to be processed | |
1100 |
|
1114 | |||
1101 | operation = None #Type of operation to parametrize |
|
1115 | operation = None #Type of operation to parametrize | |
1102 |
|
1116 | |||
1103 | normFactor = None #Normalization Factor |
|
1117 | normFactor = None #Normalization Factor | |
1104 |
|
1118 | |||
1105 | groupList = None #List of Pairs, Groups, etc |
|
1119 | groupList = None #List of Pairs, Groups, etc | |
1106 |
|
1120 | |||
1107 | #Parameters |
|
1121 | #Parameters | |
1108 |
|
1122 | |||
1109 | data_param = None #Parameters obtained |
|
1123 | data_param = None #Parameters obtained | |
1110 |
|
1124 | |||
1111 | data_pre = None #Data Pre Parametrization |
|
1125 | data_pre = None #Data Pre Parametrization | |
1112 |
|
1126 | |||
1113 | data_SNR = None #Signal to Noise Ratio |
|
1127 | data_SNR = None #Signal to Noise Ratio | |
1114 |
|
1128 | |||
1115 | # heightRange = None #Heights |
|
1129 | # heightRange = None #Heights | |
1116 |
|
1130 | |||
1117 | abscissaList = None #Abscissa, can be velocities, lags or time |
|
1131 | abscissaList = None #Abscissa, can be velocities, lags or time | |
1118 |
|
1132 | |||
1119 | noise = None #Noise Potency |
|
1133 | noise = None #Noise Potency | |
1120 |
|
1134 | |||
1121 | utctimeInit = None #Initial UTC time |
|
1135 | utctimeInit = None #Initial UTC time | |
1122 |
|
1136 | |||
1123 | paramInterval = None #Time interval to calculate Parameters in seconds |
|
1137 | paramInterval = None #Time interval to calculate Parameters in seconds | |
1124 |
|
1138 | |||
1125 | useLocalTime = True |
|
1139 | useLocalTime = True | |
1126 |
|
1140 | |||
1127 | #Fitting |
|
1141 | #Fitting | |
1128 |
|
1142 | |||
1129 | data_error = None #Error of the estimation |
|
1143 | data_error = None #Error of the estimation | |
1130 |
|
1144 | |||
1131 | constants = None |
|
1145 | constants = None | |
1132 |
|
1146 | |||
1133 | library = None |
|
1147 | library = None | |
1134 |
|
1148 | |||
1135 | #Output signal |
|
1149 | #Output signal | |
1136 |
|
1150 | |||
1137 | outputInterval = None #Time interval to calculate output signal in seconds |
|
1151 | outputInterval = None #Time interval to calculate output signal in seconds | |
1138 |
|
1152 | |||
1139 | data_output = None #Out signal |
|
1153 | data_output = None #Out signal | |
1140 |
|
1154 | |||
1141 |
|
1155 | |||
1142 |
|
1156 | |||
1143 | def __init__(self): |
|
1157 | def __init__(self): | |
1144 | ''' |
|
1158 | ''' | |
1145 | Constructor |
|
1159 | Constructor | |
1146 | ''' |
|
1160 | ''' | |
1147 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
1161 | self.radarControllerHeaderObj = RadarControllerHeader() | |
1148 |
|
1162 | |||
1149 | self.systemHeaderObj = SystemHeader() |
|
1163 | self.systemHeaderObj = SystemHeader() | |
1150 |
|
1164 | |||
1151 | self.type = "Parameters" |
|
1165 | self.type = "Parameters" | |
1152 |
|
1166 | |||
1153 | def getTimeRange1(self, interval): |
|
1167 | def getTimeRange1(self, interval): | |
1154 |
|
1168 | |||
1155 | datatime = [] |
|
1169 | datatime = [] | |
1156 |
|
1170 | |||
1157 | if self.useLocalTime: |
|
1171 | if self.useLocalTime: | |
1158 | time1 = self.utctimeInit - self.timeZone*60 |
|
1172 | time1 = self.utctimeInit - self.timeZone*60 | |
1159 | else: |
|
1173 | else: | |
1160 | time1 = self.utctimeInit |
|
1174 | time1 = self.utctimeInit | |
1161 |
|
1175 | |||
1162 | # datatime.append(self.utctimeInit) |
|
1176 | # datatime.append(self.utctimeInit) | |
1163 | # datatime.append(self.utctimeInit + self.outputInterval) |
|
1177 | # datatime.append(self.utctimeInit + self.outputInterval) | |
1164 | datatime.append(time1) |
|
1178 | datatime.append(time1) | |
1165 | datatime.append(time1 + interval) |
|
1179 | datatime.append(time1 + interval) | |
1166 |
|
1180 | |||
1167 | datatime = numpy.array(datatime) |
|
1181 | datatime = numpy.array(datatime) | |
1168 |
|
1182 | |||
1169 | return datatime |
|
1183 | return datatime |
@@ -1,1364 +1,1569 | |||||
1 | import os |
|
1 | import os | |
2 | import datetime |
|
2 | import datetime | |
3 | import numpy |
|
3 | import numpy | |
4 |
|
4 | |||
5 | from figure import Figure, isRealtime |
|
5 | from figure import Figure, isRealtime, isTimeInHourRange | |
6 | from plotting_codes import * |
|
6 | from plotting_codes import * | |
7 |
|
7 | |||
8 | class MomentsPlot(Figure): |
|
8 | class MomentsPlot(Figure): | |
9 |
|
9 | |||
10 | isConfig = None |
|
10 | isConfig = None | |
11 | __nsubplots = None |
|
11 | __nsubplots = None | |
12 |
|
12 | |||
13 | WIDTHPROF = None |
|
13 | WIDTHPROF = None | |
14 | HEIGHTPROF = None |
|
14 | HEIGHTPROF = None | |
15 | PREFIX = 'prm' |
|
15 | PREFIX = 'prm' | |
16 |
|
16 | |||
17 | def __init__(self): |
|
17 | def __init__(self): | |
18 |
|
18 | |||
19 | self.isConfig = False |
|
19 | self.isConfig = False | |
20 | self.__nsubplots = 1 |
|
20 | self.__nsubplots = 1 | |
21 |
|
21 | |||
22 | self.WIDTH = 280 |
|
22 | self.WIDTH = 280 | |
23 | self.HEIGHT = 250 |
|
23 | self.HEIGHT = 250 | |
24 | self.WIDTHPROF = 120 |
|
24 | self.WIDTHPROF = 120 | |
25 | self.HEIGHTPROF = 0 |
|
25 | self.HEIGHTPROF = 0 | |
26 | self.counter_imagwr = 0 |
|
26 | self.counter_imagwr = 0 | |
27 |
|
27 | |||
28 | self.PLOT_CODE = MOMENTS_CODE |
|
28 | self.PLOT_CODE = MOMENTS_CODE | |
29 |
|
29 | |||
30 | self.FTP_WEI = None |
|
30 | self.FTP_WEI = None | |
31 | self.EXP_CODE = None |
|
31 | self.EXP_CODE = None | |
32 | self.SUB_EXP_CODE = None |
|
32 | self.SUB_EXP_CODE = None | |
33 | self.PLOT_POS = None |
|
33 | self.PLOT_POS = None | |
34 |
|
34 | |||
35 | def getSubplots(self): |
|
35 | def getSubplots(self): | |
36 |
|
36 | |||
37 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
37 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
38 | nrow = int(self.nplots*1./ncol + 0.9) |
|
38 | nrow = int(self.nplots*1./ncol + 0.9) | |
39 |
|
39 | |||
40 | return nrow, ncol |
|
40 | return nrow, ncol | |
41 |
|
41 | |||
42 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
42 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
43 |
|
43 | |||
44 | self.__showprofile = showprofile |
|
44 | self.__showprofile = showprofile | |
45 | self.nplots = nplots |
|
45 | self.nplots = nplots | |
46 |
|
46 | |||
47 | ncolspan = 1 |
|
47 | ncolspan = 1 | |
48 | colspan = 1 |
|
48 | colspan = 1 | |
49 | if showprofile: |
|
49 | if showprofile: | |
50 | ncolspan = 3 |
|
50 | ncolspan = 3 | |
51 | colspan = 2 |
|
51 | colspan = 2 | |
52 | self.__nsubplots = 2 |
|
52 | self.__nsubplots = 2 | |
53 |
|
53 | |||
54 | self.createFigure(id = id, |
|
54 | self.createFigure(id = id, | |
55 | wintitle = wintitle, |
|
55 | wintitle = wintitle, | |
56 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
56 | widthplot = self.WIDTH + self.WIDTHPROF, | |
57 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
57 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
58 | show=show) |
|
58 | show=show) | |
59 |
|
59 | |||
60 | nrow, ncol = self.getSubplots() |
|
60 | nrow, ncol = self.getSubplots() | |
61 |
|
61 | |||
62 | counter = 0 |
|
62 | counter = 0 | |
63 | for y in range(nrow): |
|
63 | for y in range(nrow): | |
64 | for x in range(ncol): |
|
64 | for x in range(ncol): | |
65 |
|
65 | |||
66 | if counter >= self.nplots: |
|
66 | if counter >= self.nplots: | |
67 | break |
|
67 | break | |
68 |
|
68 | |||
69 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
69 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
70 |
|
70 | |||
71 | if showprofile: |
|
71 | if showprofile: | |
72 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
72 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
73 |
|
73 | |||
74 | counter += 1 |
|
74 | counter += 1 | |
75 |
|
75 | |||
76 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
76 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
77 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
77 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
78 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
78 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
79 | server=None, folder=None, username=None, password=None, |
|
79 | server=None, folder=None, username=None, password=None, | |
80 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): |
|
80 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | |
81 |
|
81 | |||
82 | """ |
|
82 | """ | |
83 |
|
83 | |||
84 | Input: |
|
84 | Input: | |
85 | dataOut : |
|
85 | dataOut : | |
86 | id : |
|
86 | id : | |
87 | wintitle : |
|
87 | wintitle : | |
88 | channelList : |
|
88 | channelList : | |
89 | showProfile : |
|
89 | showProfile : | |
90 | xmin : None, |
|
90 | xmin : None, | |
91 | xmax : None, |
|
91 | xmax : None, | |
92 | ymin : None, |
|
92 | ymin : None, | |
93 | ymax : None, |
|
93 | ymax : None, | |
94 | zmin : None, |
|
94 | zmin : None, | |
95 | zmax : None |
|
95 | zmax : None | |
96 | """ |
|
96 | """ | |
97 |
|
97 | |||
98 | if dataOut.flagNoData: |
|
98 | if dataOut.flagNoData: | |
99 | return None |
|
99 | return None | |
100 |
|
100 | |||
101 | if realtime: |
|
101 | if realtime: | |
102 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
102 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
103 | print 'Skipping this plot function' |
|
103 | print 'Skipping this plot function' | |
104 | return |
|
104 | return | |
105 |
|
105 | |||
106 | if channelList == None: |
|
106 | if channelList == None: | |
107 | channelIndexList = dataOut.channelIndexList |
|
107 | channelIndexList = dataOut.channelIndexList | |
108 | else: |
|
108 | else: | |
109 | channelIndexList = [] |
|
109 | channelIndexList = [] | |
110 | for channel in channelList: |
|
110 | for channel in channelList: | |
111 | if channel not in dataOut.channelList: |
|
111 | if channel not in dataOut.channelList: | |
112 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
112 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
113 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
113 | channelIndexList.append(dataOut.channelList.index(channel)) | |
114 |
|
114 | |||
115 | factor = dataOut.normFactor |
|
115 | factor = dataOut.normFactor | |
116 | x = dataOut.abscissaList |
|
116 | x = dataOut.abscissaList | |
117 | y = dataOut.heightList |
|
117 | y = dataOut.heightList | |
118 |
|
118 | |||
119 | z = dataOut.data_pre[channelIndexList,:,:]/factor |
|
119 | z = dataOut.data_pre[channelIndexList,:,:]/factor | |
120 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
120 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
121 | avg = numpy.average(z, axis=1) |
|
121 | avg = numpy.average(z, axis=1) | |
122 | noise = dataOut.noise/factor |
|
122 | noise = dataOut.noise/factor | |
123 |
|
123 | |||
124 | zdB = 10*numpy.log10(z) |
|
124 | zdB = 10*numpy.log10(z) | |
125 | avgdB = 10*numpy.log10(avg) |
|
125 | avgdB = 10*numpy.log10(avg) | |
126 | noisedB = 10*numpy.log10(noise) |
|
126 | noisedB = 10*numpy.log10(noise) | |
127 |
|
127 | |||
128 | #thisDatetime = dataOut.datatime |
|
128 | #thisDatetime = dataOut.datatime | |
129 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
129 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
130 | title = wintitle + " Parameters" |
|
130 | title = wintitle + " Parameters" | |
131 | xlabel = "Velocity (m/s)" |
|
131 | xlabel = "Velocity (m/s)" | |
132 | ylabel = "Range (Km)" |
|
132 | ylabel = "Range (Km)" | |
133 |
|
133 | |||
134 | update_figfile = False |
|
134 | update_figfile = False | |
135 |
|
135 | |||
136 | if not self.isConfig: |
|
136 | if not self.isConfig: | |
137 |
|
137 | |||
138 | nplots = len(channelIndexList) |
|
138 | nplots = len(channelIndexList) | |
139 |
|
139 | |||
140 | self.setup(id=id, |
|
140 | self.setup(id=id, | |
141 | nplots=nplots, |
|
141 | nplots=nplots, | |
142 | wintitle=wintitle, |
|
142 | wintitle=wintitle, | |
143 | showprofile=showprofile, |
|
143 | showprofile=showprofile, | |
144 | show=show) |
|
144 | show=show) | |
145 |
|
145 | |||
146 | if xmin == None: xmin = numpy.nanmin(x) |
|
146 | if xmin == None: xmin = numpy.nanmin(x) | |
147 | if xmax == None: xmax = numpy.nanmax(x) |
|
147 | if xmax == None: xmax = numpy.nanmax(x) | |
148 | if ymin == None: ymin = numpy.nanmin(y) |
|
148 | if ymin == None: ymin = numpy.nanmin(y) | |
149 | if ymax == None: ymax = numpy.nanmax(y) |
|
149 | if ymax == None: ymax = numpy.nanmax(y) | |
150 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
150 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
151 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
151 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
152 |
|
152 | |||
153 | self.FTP_WEI = ftp_wei |
|
153 | self.FTP_WEI = ftp_wei | |
154 | self.EXP_CODE = exp_code |
|
154 | self.EXP_CODE = exp_code | |
155 | self.SUB_EXP_CODE = sub_exp_code |
|
155 | self.SUB_EXP_CODE = sub_exp_code | |
156 | self.PLOT_POS = plot_pos |
|
156 | self.PLOT_POS = plot_pos | |
157 |
|
157 | |||
158 | self.isConfig = True |
|
158 | self.isConfig = True | |
159 | update_figfile = True |
|
159 | update_figfile = True | |
160 |
|
160 | |||
161 | self.setWinTitle(title) |
|
161 | self.setWinTitle(title) | |
162 |
|
162 | |||
163 | for i in range(self.nplots): |
|
163 | for i in range(self.nplots): | |
164 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
164 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
165 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime) |
|
165 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime) | |
166 | axes = self.axesList[i*self.__nsubplots] |
|
166 | axes = self.axesList[i*self.__nsubplots] | |
167 | axes.pcolor(x, y, zdB[i,:,:], |
|
167 | axes.pcolor(x, y, zdB[i,:,:], | |
168 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
168 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
169 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
169 | xlabel=xlabel, ylabel=ylabel, title=title, | |
170 | ticksize=9, cblabel='') |
|
170 | ticksize=9, cblabel='') | |
171 | #Mean Line |
|
171 | #Mean Line | |
172 | mean = dataOut.data_param[i, 1, :] |
|
172 | mean = dataOut.data_param[i, 1, :] | |
173 | axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1) |
|
173 | axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1) | |
174 |
|
174 | |||
175 | if self.__showprofile: |
|
175 | if self.__showprofile: | |
176 | axes = self.axesList[i*self.__nsubplots +1] |
|
176 | axes = self.axesList[i*self.__nsubplots +1] | |
177 | axes.pline(avgdB[i], y, |
|
177 | axes.pline(avgdB[i], y, | |
178 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
178 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
179 | xlabel='dB', ylabel='', title='', |
|
179 | xlabel='dB', ylabel='', title='', | |
180 | ytick_visible=False, |
|
180 | ytick_visible=False, | |
181 | grid='x') |
|
181 | grid='x') | |
182 |
|
182 | |||
183 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
183 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
184 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
184 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
185 |
|
185 | |||
186 | self.draw() |
|
186 | self.draw() | |
187 |
|
187 | |||
188 | self.save(figpath=figpath, |
|
188 | self.save(figpath=figpath, | |
189 | figfile=figfile, |
|
189 | figfile=figfile, | |
190 | save=save, |
|
190 | save=save, | |
191 | ftp=ftp, |
|
191 | ftp=ftp, | |
192 | wr_period=wr_period, |
|
192 | wr_period=wr_period, | |
193 | thisDatetime=thisDatetime) |
|
193 | thisDatetime=thisDatetime) | |
194 |
|
194 | |||
195 |
|
195 | |||
196 |
|
196 | |||
197 | class SkyMapPlot(Figure): |
|
197 | class SkyMapPlot(Figure): | |
198 |
|
198 | |||
199 | __isConfig = None |
|
199 | __isConfig = None | |
200 | __nsubplots = None |
|
200 | __nsubplots = None | |
201 |
|
201 | |||
202 | WIDTHPROF = None |
|
202 | WIDTHPROF = None | |
203 | HEIGHTPROF = None |
|
203 | HEIGHTPROF = None | |
204 | PREFIX = 'mmap' |
|
204 | PREFIX = 'mmap' | |
205 |
|
205 | |||
206 | def __init__(self): |
|
206 | def __init__(self): | |
207 |
|
207 | |||
208 | self.isConfig = False |
|
208 | self.isConfig = False | |
209 | self.__nsubplots = 1 |
|
209 | self.__nsubplots = 1 | |
210 |
|
210 | |||
211 | # self.WIDTH = 280 |
|
211 | # self.WIDTH = 280 | |
212 | # self.HEIGHT = 250 |
|
212 | # self.HEIGHT = 250 | |
213 | self.WIDTH = 600 |
|
213 | self.WIDTH = 600 | |
214 | self.HEIGHT = 600 |
|
214 | self.HEIGHT = 600 | |
215 | self.WIDTHPROF = 120 |
|
215 | self.WIDTHPROF = 120 | |
216 | self.HEIGHTPROF = 0 |
|
216 | self.HEIGHTPROF = 0 | |
217 | self.counter_imagwr = 0 |
|
217 | self.counter_imagwr = 0 | |
218 |
|
218 | |||
219 | self.PLOT_CODE = MSKYMAP_CODE |
|
219 | self.PLOT_CODE = MSKYMAP_CODE | |
220 |
|
220 | |||
221 | self.FTP_WEI = None |
|
221 | self.FTP_WEI = None | |
222 | self.EXP_CODE = None |
|
222 | self.EXP_CODE = None | |
223 | self.SUB_EXP_CODE = None |
|
223 | self.SUB_EXP_CODE = None | |
224 | self.PLOT_POS = None |
|
224 | self.PLOT_POS = None | |
225 |
|
225 | |||
226 | def getSubplots(self): |
|
226 | def getSubplots(self): | |
227 |
|
227 | |||
228 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
228 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
229 | nrow = int(self.nplots*1./ncol + 0.9) |
|
229 | nrow = int(self.nplots*1./ncol + 0.9) | |
230 |
|
230 | |||
231 | return nrow, ncol |
|
231 | return nrow, ncol | |
232 |
|
232 | |||
233 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): |
|
233 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): | |
234 |
|
234 | |||
235 | self.__showprofile = showprofile |
|
235 | self.__showprofile = showprofile | |
236 | self.nplots = nplots |
|
236 | self.nplots = nplots | |
237 |
|
237 | |||
238 | ncolspan = 1 |
|
238 | ncolspan = 1 | |
239 | colspan = 1 |
|
239 | colspan = 1 | |
240 |
|
240 | |||
241 | self.createFigure(id = id, |
|
241 | self.createFigure(id = id, | |
242 | wintitle = wintitle, |
|
242 | wintitle = wintitle, | |
243 | widthplot = self.WIDTH, #+ self.WIDTHPROF, |
|
243 | widthplot = self.WIDTH, #+ self.WIDTHPROF, | |
244 | heightplot = self.HEIGHT,# + self.HEIGHTPROF, |
|
244 | heightplot = self.HEIGHT,# + self.HEIGHTPROF, | |
245 | show=show) |
|
245 | show=show) | |
246 |
|
246 | |||
247 | nrow, ncol = 1,1 |
|
247 | nrow, ncol = 1,1 | |
248 | counter = 0 |
|
248 | counter = 0 | |
249 | x = 0 |
|
249 | x = 0 | |
250 | y = 0 |
|
250 | y = 0 | |
251 | self.addAxes(1, 1, 0, 0, 1, 1, True) |
|
251 | self.addAxes(1, 1, 0, 0, 1, 1, True) | |
252 |
|
252 | |||
253 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, |
|
253 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | |
254 | tmin=0, tmax=24, timerange=None, |
|
254 | tmin=0, tmax=24, timerange=None, | |
255 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
255 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
256 | server=None, folder=None, username=None, password=None, |
|
256 | server=None, folder=None, username=None, password=None, | |
257 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): |
|
257 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | |
258 |
|
258 | |||
259 | """ |
|
259 | """ | |
260 |
|
260 | |||
261 | Input: |
|
261 | Input: | |
262 | dataOut : |
|
262 | dataOut : | |
263 | id : |
|
263 | id : | |
264 | wintitle : |
|
264 | wintitle : | |
265 | channelList : |
|
265 | channelList : | |
266 | showProfile : |
|
266 | showProfile : | |
267 | xmin : None, |
|
267 | xmin : None, | |
268 | xmax : None, |
|
268 | xmax : None, | |
269 | ymin : None, |
|
269 | ymin : None, | |
270 | ymax : None, |
|
270 | ymax : None, | |
271 | zmin : None, |
|
271 | zmin : None, | |
272 | zmax : None |
|
272 | zmax : None | |
273 | """ |
|
273 | """ | |
274 |
|
274 | |||
275 | arrayParameters = dataOut.data_param |
|
275 | arrayParameters = dataOut.data_param | |
276 | error = arrayParameters[:,-1] |
|
276 | error = arrayParameters[:,-1] | |
277 | indValid = numpy.where(error == 0)[0] |
|
277 | indValid = numpy.where(error == 0)[0] | |
278 | finalMeteor = arrayParameters[indValid,:] |
|
278 | finalMeteor = arrayParameters[indValid,:] | |
279 | finalAzimuth = finalMeteor[:,3] |
|
279 | finalAzimuth = finalMeteor[:,3] | |
280 | finalZenith = finalMeteor[:,4] |
|
280 | finalZenith = finalMeteor[:,4] | |
281 |
|
281 | |||
282 | x = finalAzimuth*numpy.pi/180 |
|
282 | x = finalAzimuth*numpy.pi/180 | |
283 | y = finalZenith |
|
283 | y = finalZenith | |
284 | x1 = [dataOut.ltctime, dataOut.ltctime] |
|
284 | x1 = [dataOut.ltctime, dataOut.ltctime] | |
285 |
|
285 | |||
286 | #thisDatetime = dataOut.datatime |
|
286 | #thisDatetime = dataOut.datatime | |
287 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) |
|
287 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | |
288 | title = wintitle + " Parameters" |
|
288 | title = wintitle + " Parameters" | |
289 | xlabel = "Zonal Zenith Angle (deg) " |
|
289 | xlabel = "Zonal Zenith Angle (deg) " | |
290 | ylabel = "Meridional Zenith Angle (deg)" |
|
290 | ylabel = "Meridional Zenith Angle (deg)" | |
291 | update_figfile = False |
|
291 | update_figfile = False | |
292 |
|
292 | |||
293 | if not self.isConfig: |
|
293 | if not self.isConfig: | |
294 |
|
294 | |||
295 | nplots = 1 |
|
295 | nplots = 1 | |
296 |
|
296 | |||
297 | self.setup(id=id, |
|
297 | self.setup(id=id, | |
298 | nplots=nplots, |
|
298 | nplots=nplots, | |
299 | wintitle=wintitle, |
|
299 | wintitle=wintitle, | |
300 | showprofile=showprofile, |
|
300 | showprofile=showprofile, | |
301 | show=show) |
|
301 | show=show) | |
302 |
|
302 | |||
303 | if self.xmin is None and self.xmax is None: |
|
303 | if self.xmin is None and self.xmax is None: | |
304 | self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange) |
|
304 | self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange) | |
305 |
|
305 | |||
306 | if timerange != None: |
|
306 | if timerange != None: | |
307 | self.timerange = timerange |
|
307 | self.timerange = timerange | |
308 | else: |
|
308 | else: | |
309 | self.timerange = self.xmax - self.xmin |
|
309 | self.timerange = self.xmax - self.xmin | |
310 |
|
310 | |||
311 | self.FTP_WEI = ftp_wei |
|
311 | self.FTP_WEI = ftp_wei | |
312 | self.EXP_CODE = exp_code |
|
312 | self.EXP_CODE = exp_code | |
313 | self.SUB_EXP_CODE = sub_exp_code |
|
313 | self.SUB_EXP_CODE = sub_exp_code | |
314 | self.PLOT_POS = plot_pos |
|
314 | self.PLOT_POS = plot_pos | |
315 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
315 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
316 | self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
316 | self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
317 | self.isConfig = True |
|
317 | self.isConfig = True | |
318 | update_figfile = True |
|
318 | update_figfile = True | |
319 |
|
319 | |||
320 | self.setWinTitle(title) |
|
320 | self.setWinTitle(title) | |
321 |
|
321 | |||
322 | i = 0 |
|
322 | i = 0 | |
323 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
323 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
324 |
|
324 | |||
325 | axes = self.axesList[i*self.__nsubplots] |
|
325 | axes = self.axesList[i*self.__nsubplots] | |
326 | nevents = axes.x_buffer.shape[0] + x.shape[0] |
|
326 | nevents = axes.x_buffer.shape[0] + x.shape[0] | |
327 | title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents) |
|
327 | title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents) | |
328 | axes.polar(x, y, |
|
328 | axes.polar(x, y, | |
329 | title=title, xlabel=xlabel, ylabel=ylabel, |
|
329 | title=title, xlabel=xlabel, ylabel=ylabel, | |
330 | ticksize=9, cblabel='') |
|
330 | ticksize=9, cblabel='') | |
331 |
|
331 | |||
332 | self.draw() |
|
332 | self.draw() | |
333 |
|
333 | |||
334 | self.save(figpath=figpath, |
|
334 | self.save(figpath=figpath, | |
335 | figfile=figfile, |
|
335 | figfile=figfile, | |
336 | save=save, |
|
336 | save=save, | |
337 | ftp=ftp, |
|
337 | ftp=ftp, | |
338 | wr_period=wr_period, |
|
338 | wr_period=wr_period, | |
339 | thisDatetime=thisDatetime, |
|
339 | thisDatetime=thisDatetime, | |
340 | update_figfile=update_figfile) |
|
340 | update_figfile=update_figfile) | |
341 |
|
341 | |||
342 | if dataOut.ltctime >= self.xmax: |
|
342 | if dataOut.ltctime >= self.xmax: | |
343 | self.isConfigmagwr = wr_period |
|
343 | self.isConfigmagwr = wr_period | |
344 | self.isConfig = False |
|
344 | self.isConfig = False | |
345 | update_figfile = True |
|
345 | update_figfile = True | |
346 | axes.__firsttime = True |
|
346 | axes.__firsttime = True | |
347 | self.xmin += self.timerange |
|
347 | self.xmin += self.timerange | |
348 | self.xmax += self.timerange |
|
348 | self.xmax += self.timerange | |
349 |
|
349 | |||
350 |
|
350 | |||
351 |
|
351 | |||
352 |
|
352 | |||
353 | class WindProfilerPlot(Figure): |
|
353 | class WindProfilerPlot(Figure): | |
354 |
|
354 | |||
355 | __isConfig = None |
|
355 | __isConfig = None | |
356 | __nsubplots = None |
|
356 | __nsubplots = None | |
357 |
|
357 | |||
358 | WIDTHPROF = None |
|
358 | WIDTHPROF = None | |
359 | HEIGHTPROF = None |
|
359 | HEIGHTPROF = None | |
360 | PREFIX = 'wind' |
|
360 | PREFIX = 'wind' | |
361 |
|
361 | |||
362 | def __init__(self): |
|
362 | def __init__(self): | |
363 |
|
363 | |||
364 | self.timerange = None |
|
364 | self.timerange = None | |
365 | self.isConfig = False |
|
365 | self.isConfig = False | |
366 | self.__nsubplots = 1 |
|
366 | self.__nsubplots = 1 | |
367 |
|
367 | |||
368 | self.WIDTH = 800 |
|
368 | self.WIDTH = 800 | |
369 | self.HEIGHT = 150 |
|
369 | self.HEIGHT = 150 | |
370 | self.WIDTHPROF = 120 |
|
370 | self.WIDTHPROF = 120 | |
371 | self.HEIGHTPROF = 0 |
|
371 | self.HEIGHTPROF = 0 | |
372 | self.counter_imagwr = 0 |
|
372 | self.counter_imagwr = 0 | |
373 |
|
373 | |||
374 | self.PLOT_CODE = WIND_CODE |
|
374 | self.PLOT_CODE = WIND_CODE | |
375 |
|
375 | |||
376 | self.FTP_WEI = None |
|
376 | self.FTP_WEI = None | |
377 | self.EXP_CODE = None |
|
377 | self.EXP_CODE = None | |
378 | self.SUB_EXP_CODE = None |
|
378 | self.SUB_EXP_CODE = None | |
379 | self.PLOT_POS = None |
|
379 | self.PLOT_POS = None | |
380 | self.tmin = None |
|
380 | self.tmin = None | |
381 | self.tmax = None |
|
381 | self.tmax = None | |
382 |
|
382 | |||
383 | self.xmin = None |
|
383 | self.xmin = None | |
384 | self.xmax = None |
|
384 | self.xmax = None | |
385 |
|
385 | |||
386 | self.figfile = None |
|
386 | self.figfile = None | |
387 |
|
387 | |||
388 | def getSubplots(self): |
|
388 | def getSubplots(self): | |
389 |
|
389 | |||
390 | ncol = 1 |
|
390 | ncol = 1 | |
391 | nrow = self.nplots |
|
391 | nrow = self.nplots | |
392 |
|
392 | |||
393 | return nrow, ncol |
|
393 | return nrow, ncol | |
394 |
|
394 | |||
395 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
395 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
396 |
|
396 | |||
397 | self.__showprofile = showprofile |
|
397 | self.__showprofile = showprofile | |
398 | self.nplots = nplots |
|
398 | self.nplots = nplots | |
399 |
|
399 | |||
400 | ncolspan = 1 |
|
400 | ncolspan = 1 | |
401 | colspan = 1 |
|
401 | colspan = 1 | |
402 |
|
402 | |||
403 | self.createFigure(id = id, |
|
403 | self.createFigure(id = id, | |
404 | wintitle = wintitle, |
|
404 | wintitle = wintitle, | |
405 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
405 | widthplot = self.WIDTH + self.WIDTHPROF, | |
406 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
406 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
407 | show=show) |
|
407 | show=show) | |
408 |
|
408 | |||
409 | nrow, ncol = self.getSubplots() |
|
409 | nrow, ncol = self.getSubplots() | |
410 |
|
410 | |||
411 | counter = 0 |
|
411 | counter = 0 | |
412 | for y in range(nrow): |
|
412 | for y in range(nrow): | |
413 | if counter >= self.nplots: |
|
413 | if counter >= self.nplots: | |
414 | break |
|
414 | break | |
415 |
|
415 | |||
416 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) |
|
416 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) | |
417 | counter += 1 |
|
417 | counter += 1 | |
418 |
|
418 | |||
419 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False', |
|
419 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False', | |
420 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
420 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
421 | zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None, |
|
421 | zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None, | |
422 | timerange=None, SNRthresh = None, |
|
422 | timerange=None, SNRthresh = None, | |
423 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
423 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
424 | server=None, folder=None, username=None, password=None, |
|
424 | server=None, folder=None, username=None, password=None, | |
425 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
425 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
426 | """ |
|
426 | """ | |
427 |
|
427 | |||
428 | Input: |
|
428 | Input: | |
429 | dataOut : |
|
429 | dataOut : | |
430 | id : |
|
430 | id : | |
431 | wintitle : |
|
431 | wintitle : | |
432 | channelList : |
|
432 | channelList : | |
433 | showProfile : |
|
433 | showProfile : | |
434 | xmin : None, |
|
434 | xmin : None, | |
435 | xmax : None, |
|
435 | xmax : None, | |
436 | ymin : None, |
|
436 | ymin : None, | |
437 | ymax : None, |
|
437 | ymax : None, | |
438 | zmin : None, |
|
438 | zmin : None, | |
439 | zmax : None |
|
439 | zmax : None | |
440 | """ |
|
440 | """ | |
441 |
|
441 | |||
442 | # if timerange is not None: |
|
442 | # if timerange is not None: | |
443 | # self.timerange = timerange |
|
443 | # self.timerange = timerange | |
444 | # |
|
444 | # | |
445 | # tmin = None |
|
445 | # tmin = None | |
446 | # tmax = None |
|
446 | # tmax = None | |
447 |
|
447 | |||
448 | x = dataOut.getTimeRange1(dataOut.outputInterval) |
|
448 | x = dataOut.getTimeRange1(dataOut.outputInterval) | |
449 | # y = dataOut.heightList |
|
449 | # y = dataOut.heightList | |
450 | y = dataOut.heightList |
|
450 | y = dataOut.heightList | |
451 |
|
451 | |||
452 | z = dataOut.data_output.copy() |
|
452 | z = dataOut.data_output.copy() | |
453 | nplots = z.shape[0] #Number of wind dimensions estimated |
|
453 | nplots = z.shape[0] #Number of wind dimensions estimated | |
454 | nplotsw = nplots |
|
454 | nplotsw = nplots | |
455 |
|
455 | |||
456 | #If there is a SNR function defined |
|
456 | #If there is a SNR function defined | |
457 | if dataOut.data_SNR is not None: |
|
457 | if dataOut.data_SNR is not None: | |
458 | nplots += 1 |
|
458 | nplots += 1 | |
459 | SNR = dataOut.data_SNR |
|
459 | SNR = dataOut.data_SNR | |
460 | SNRavg = numpy.average(SNR, axis=0) |
|
460 | SNRavg = numpy.average(SNR, axis=0) | |
461 |
|
461 | |||
462 | SNRdB = 10*numpy.log10(SNR) |
|
462 | SNRdB = 10*numpy.log10(SNR) | |
463 | SNRavgdB = 10*numpy.log10(SNRavg) |
|
463 | SNRavgdB = 10*numpy.log10(SNRavg) | |
464 |
|
464 | |||
465 | if SNRthresh == None: SNRthresh = -5.0 |
|
465 | if SNRthresh == None: SNRthresh = -5.0 | |
466 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] |
|
466 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] | |
467 |
|
467 | |||
468 | for i in range(nplotsw): |
|
468 | for i in range(nplotsw): | |
469 | z[i,ind] = numpy.nan |
|
469 | z[i,ind] = numpy.nan | |
470 |
|
470 | |||
471 |
|
471 | |||
472 | # showprofile = False |
|
472 | # showprofile = False | |
473 | # thisDatetime = dataOut.datatime |
|
473 | # thisDatetime = dataOut.datatime | |
474 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) |
|
474 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime) | |
475 | title = wintitle + "Wind" |
|
475 | title = wintitle + "Wind" | |
476 | xlabel = "" |
|
476 | xlabel = "" | |
477 | ylabel = "Range (Km)" |
|
477 | ylabel = "Range (Km)" | |
478 | update_figfile = False |
|
478 | update_figfile = False | |
479 |
|
479 | |||
480 | if not self.isConfig: |
|
480 | if not self.isConfig: | |
481 |
|
481 | |||
482 | self.setup(id=id, |
|
482 | self.setup(id=id, | |
483 | nplots=nplots, |
|
483 | nplots=nplots, | |
484 | wintitle=wintitle, |
|
484 | wintitle=wintitle, | |
485 | showprofile=showprofile, |
|
485 | showprofile=showprofile, | |
486 | show=show) |
|
486 | show=show) | |
487 |
|
487 | |||
488 | if timerange is not None: |
|
488 | if timerange is not None: | |
489 | self.timerange = timerange |
|
489 | self.timerange = timerange | |
490 |
|
490 | |||
491 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
491 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
492 |
|
492 | |||
493 | if ymin == None: ymin = numpy.nanmin(y) |
|
493 | if ymin == None: ymin = numpy.nanmin(y) | |
494 | if ymax == None: ymax = numpy.nanmax(y) |
|
494 | if ymax == None: ymax = numpy.nanmax(y) | |
495 |
|
495 | |||
496 | if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:])) |
|
496 | if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:])) | |
497 | #if numpy.isnan(zmax): zmax = 50 |
|
497 | #if numpy.isnan(zmax): zmax = 50 | |
498 | if zmin == None: zmin = -zmax |
|
498 | if zmin == None: zmin = -zmax | |
499 |
|
499 | |||
500 | if nplotsw == 3: |
|
500 | if nplotsw == 3: | |
501 | if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:])) |
|
501 | if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:])) | |
502 | if zmin_ver == None: zmin_ver = -zmax_ver |
|
502 | if zmin_ver == None: zmin_ver = -zmax_ver | |
503 |
|
503 | |||
504 | if dataOut.data_SNR is not None: |
|
504 | if dataOut.data_SNR is not None: | |
505 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) |
|
505 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | |
506 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) |
|
506 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | |
507 |
|
507 | |||
508 |
|
508 | |||
509 | self.FTP_WEI = ftp_wei |
|
509 | self.FTP_WEI = ftp_wei | |
510 | self.EXP_CODE = exp_code |
|
510 | self.EXP_CODE = exp_code | |
511 | self.SUB_EXP_CODE = sub_exp_code |
|
511 | self.SUB_EXP_CODE = sub_exp_code | |
512 | self.PLOT_POS = plot_pos |
|
512 | self.PLOT_POS = plot_pos | |
513 |
|
513 | |||
514 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
514 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
515 | self.isConfig = True |
|
515 | self.isConfig = True | |
516 | self.figfile = figfile |
|
516 | self.figfile = figfile | |
517 | update_figfile = True |
|
517 | update_figfile = True | |
518 |
|
518 | |||
519 | self.setWinTitle(title) |
|
519 | self.setWinTitle(title) | |
520 |
|
520 | |||
521 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
521 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
522 | x[1] = self.xmax |
|
522 | x[1] = self.xmax | |
523 |
|
523 | |||
524 | strWind = ['Zonal', 'Meridional', 'Vertical'] |
|
524 | strWind = ['Zonal', 'Meridional', 'Vertical'] | |
525 | strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] |
|
525 | strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)'] | |
526 | zmaxVector = [zmax, zmax, zmax_ver] |
|
526 | zmaxVector = [zmax, zmax, zmax_ver] | |
527 | zminVector = [zmin, zmin, zmin_ver] |
|
527 | zminVector = [zmin, zmin, zmin_ver] | |
528 | windFactor = [1,1,100] |
|
528 | windFactor = [1,1,100] | |
529 |
|
529 | |||
530 | for i in range(nplotsw): |
|
530 | for i in range(nplotsw): | |
531 |
|
531 | |||
532 | title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
532 | title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
533 | axes = self.axesList[i*self.__nsubplots] |
|
533 | axes = self.axesList[i*self.__nsubplots] | |
534 |
|
534 | |||
535 | z1 = z[i,:].reshape((1,-1))*windFactor[i] |
|
535 | z1 = z[i,:].reshape((1,-1))*windFactor[i] | |
536 |
|
536 | |||
537 | axes.pcolorbuffer(x, y, z1, |
|
537 | axes.pcolorbuffer(x, y, z1, | |
538 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], |
|
538 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], | |
539 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
539 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
540 | ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" ) |
|
540 | ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="RdBu_r" ) | |
541 |
|
541 | |||
542 | if dataOut.data_SNR is not None: |
|
542 | if dataOut.data_SNR is not None: | |
543 | i += 1 |
|
543 | i += 1 | |
544 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
544 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
545 | axes = self.axesList[i*self.__nsubplots] |
|
545 | axes = self.axesList[i*self.__nsubplots] | |
546 |
|
546 | |||
547 | SNRavgdB = SNRavgdB.reshape((1,-1)) |
|
547 | SNRavgdB = SNRavgdB.reshape((1,-1)) | |
548 |
|
548 | |||
549 | axes.pcolorbuffer(x, y, SNRavgdB, |
|
549 | axes.pcolorbuffer(x, y, SNRavgdB, | |
550 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
550 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
551 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
551 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
552 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") |
|
552 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") | |
553 |
|
553 | |||
554 | self.draw() |
|
554 | self.draw() | |
555 |
|
555 | |||
556 | if dataOut.ltctime >= self.xmax: |
|
556 | if dataOut.ltctime >= self.xmax: | |
557 | self.counter_imagwr = wr_period |
|
557 | self.counter_imagwr = wr_period | |
558 | self.isConfig = False |
|
558 | self.isConfig = False | |
559 | update_figfile = True |
|
559 | update_figfile = True | |
560 |
|
560 | |||
561 | self.save(figpath=figpath, |
|
561 | self.save(figpath=figpath, | |
562 | figfile=figfile, |
|
562 | figfile=figfile, | |
563 | save=save, |
|
563 | save=save, | |
564 | ftp=ftp, |
|
564 | ftp=ftp, | |
565 | wr_period=wr_period, |
|
565 | wr_period=wr_period, | |
566 | thisDatetime=thisDatetime, |
|
566 | thisDatetime=thisDatetime, | |
567 | update_figfile=update_figfile) |
|
567 | update_figfile=update_figfile) | |
568 |
|
568 | |||
|
569 | class ParametersPlot(Figure): | |||
|
570 | ||||
|
571 | __isConfig = None | |||
|
572 | __nsubplots = None | |||
|
573 | ||||
|
574 | WIDTHPROF = None | |||
|
575 | HEIGHTPROF = None | |||
|
576 | PREFIX = 'param' | |||
|
577 | ||||
|
578 | nplots = None | |||
|
579 | nchan = None | |||
|
580 | ||||
|
581 | def __init__(self): | |||
|
582 | ||||
|
583 | self.timerange = None | |||
|
584 | self.isConfig = False | |||
|
585 | self.__nsubplots = 1 | |||
|
586 | ||||
|
587 | self.WIDTH = 800 | |||
|
588 | self.HEIGHT = 180 | |||
|
589 | self.WIDTHPROF = 120 | |||
|
590 | self.HEIGHTPROF = 0 | |||
|
591 | self.counter_imagwr = 0 | |||
|
592 | ||||
|
593 | self.PLOT_CODE = RTI_CODE | |||
|
594 | ||||
|
595 | self.FTP_WEI = None | |||
|
596 | self.EXP_CODE = None | |||
|
597 | self.SUB_EXP_CODE = None | |||
|
598 | self.PLOT_POS = None | |||
|
599 | self.tmin = None | |||
|
600 | self.tmax = None | |||
|
601 | ||||
|
602 | self.xmin = None | |||
|
603 | self.xmax = None | |||
|
604 | ||||
|
605 | self.figfile = None | |||
|
606 | ||||
|
607 | def getSubplots(self): | |||
|
608 | ||||
|
609 | ncol = 1 | |||
|
610 | nrow = self.nplots | |||
|
611 | ||||
|
612 | return nrow, ncol | |||
|
613 | ||||
|
614 | def setup(self, id, nplots, wintitle, show=True): | |||
|
615 | ||||
|
616 | self.nplots = nplots | |||
|
617 | ||||
|
618 | ncolspan = 1 | |||
|
619 | colspan = 1 | |||
|
620 | ||||
|
621 | self.createFigure(id = id, | |||
|
622 | wintitle = wintitle, | |||
|
623 | widthplot = self.WIDTH + self.WIDTHPROF, | |||
|
624 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |||
|
625 | show=show) | |||
|
626 | ||||
|
627 | nrow, ncol = self.getSubplots() | |||
|
628 | ||||
|
629 | counter = 0 | |||
|
630 | for y in range(nrow): | |||
|
631 | for x in range(ncol): | |||
|
632 | ||||
|
633 | if counter >= self.nplots: | |||
|
634 | break | |||
|
635 | ||||
|
636 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |||
|
637 | ||||
|
638 | counter += 1 | |||
|
639 | ||||
|
640 | def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap=True, | |||
|
641 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None, | |||
|
642 | showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None, | |||
|
643 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |||
|
644 | server=None, folder=None, username=None, password=None, | |||
|
645 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |||
|
646 | ||||
|
647 | """ | |||
|
648 | ||||
|
649 | Input: | |||
|
650 | dataOut : | |||
|
651 | id : | |||
|
652 | wintitle : | |||
|
653 | channelList : | |||
|
654 | showProfile : | |||
|
655 | xmin : None, | |||
|
656 | xmax : None, | |||
|
657 | ymin : None, | |||
|
658 | ymax : None, | |||
|
659 | zmin : None, | |||
|
660 | zmax : None | |||
|
661 | """ | |||
|
662 | ||||
|
663 | if colormap: | |||
|
664 | colormap="jet" | |||
|
665 | else: | |||
|
666 | colormap="RdBu_r" | |||
|
667 | ||||
|
668 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |||
|
669 | return | |||
|
670 | ||||
|
671 | if channelList == None: | |||
|
672 | channelIndexList = dataOut.channelIndexList | |||
|
673 | else: | |||
|
674 | channelIndexList = [] | |||
|
675 | for channel in channelList: | |||
|
676 | if channel not in dataOut.channelList: | |||
|
677 | raise ValueError, "Channel %d is not in dataOut.channelList" | |||
|
678 | channelIndexList.append(dataOut.channelList.index(channel)) | |||
|
679 | ||||
|
680 | x = dataOut.getTimeRange1(dataOut.paramInterval) | |||
|
681 | y = dataOut.getHeiRange() | |||
|
682 | z = dataOut.data_param[channelIndexList,paramIndex,:] | |||
|
683 | ||||
|
684 | if showSNR: | |||
|
685 | #SNR data | |||
|
686 | SNRarray = dataOut.data_SNR[channelIndexList,:] | |||
|
687 | SNRdB = 10*numpy.log10(SNRarray) | |||
|
688 | ind = numpy.where(SNRdB < SNRthresh) | |||
|
689 | z[ind] = numpy.nan | |||
|
690 | ||||
|
691 | thisDatetime = dataOut.datatime | |||
|
692 | # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |||
|
693 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |||
|
694 | xlabel = "" | |||
|
695 | ylabel = "Range (Km)" | |||
|
696 | ||||
|
697 | update_figfile = False | |||
|
698 | ||||
|
699 | if not self.isConfig: | |||
569 |
|
700 | |||
|
701 | nchan = len(channelIndexList) | |||
|
702 | self.nchan = nchan | |||
|
703 | self.plotFact = 1 | |||
|
704 | nplots = nchan | |||
570 |
|
705 | |||
571 | class ParametersPlot(Figure): |
|
706 | if showSNR: | |
|
707 | nplots = nchan*2 | |||
|
708 | self.plotFact = 2 | |||
|
709 | if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) | |||
|
710 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) | |||
|
711 | ||||
|
712 | self.setup(id=id, | |||
|
713 | nplots=nplots, | |||
|
714 | wintitle=wintitle, | |||
|
715 | show=show) | |||
|
716 | ||||
|
717 | if timerange != None: | |||
|
718 | self.timerange = timerange | |||
|
719 | ||||
|
720 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |||
|
721 | ||||
|
722 | if ymin == None: ymin = numpy.nanmin(y) | |||
|
723 | if ymax == None: ymax = numpy.nanmax(y) | |||
|
724 | if zmin == None: zmin = dataOut.abscissaList[0] | |||
|
725 | if zmax == None: zmax = dataOut.abscissaList[-1] | |||
|
726 | ||||
|
727 | self.FTP_WEI = ftp_wei | |||
|
728 | self.EXP_CODE = exp_code | |||
|
729 | self.SUB_EXP_CODE = sub_exp_code | |||
|
730 | self.PLOT_POS = plot_pos | |||
|
731 | ||||
|
732 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |||
|
733 | self.isConfig = True | |||
|
734 | self.figfile = figfile | |||
|
735 | update_figfile = True | |||
|
736 | ||||
|
737 | self.setWinTitle(title) | |||
|
738 | ||||
|
739 | for i in range(self.nchan): | |||
|
740 | index = channelIndexList[i] | |||
|
741 | title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |||
|
742 | axes = self.axesList[i*self.plotFact] | |||
|
743 | z1 = z[i,:].reshape((1,-1)) | |||
|
744 | axes.pcolorbuffer(x, y, z1, | |||
|
745 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |||
|
746 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |||
|
747 | ticksize=9, cblabel='', cbsize="1%",colormap=colormap) | |||
|
748 | ||||
|
749 | if showSNR: | |||
|
750 | title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |||
|
751 | axes = self.axesList[i*self.plotFact + 1] | |||
|
752 | SNRdB1 = SNRdB[i,:].reshape((1,-1)) | |||
|
753 | axes.pcolorbuffer(x, y, SNRdB1, | |||
|
754 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |||
|
755 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |||
|
756 | ticksize=9, cblabel='', cbsize="1%",colormap='jet') | |||
|
757 | ||||
|
758 | ||||
|
759 | self.draw() | |||
|
760 | ||||
|
761 | if dataOut.ltctime >= self.xmax: | |||
|
762 | self.counter_imagwr = wr_period | |||
|
763 | self.isConfig = False | |||
|
764 | update_figfile = True | |||
|
765 | ||||
|
766 | self.save(figpath=figpath, | |||
|
767 | figfile=figfile, | |||
|
768 | save=save, | |||
|
769 | ftp=ftp, | |||
|
770 | wr_period=wr_period, | |||
|
771 | thisDatetime=thisDatetime, | |||
|
772 | update_figfile=update_figfile) | |||
|
773 | ||||
|
774 | ||||
|
775 | ||||
|
776 | class Parameters1Plot(Figure): | |||
572 |
|
777 | |||
573 | __isConfig = None |
|
778 | __isConfig = None | |
574 | __nsubplots = None |
|
779 | __nsubplots = None | |
575 |
|
780 | |||
576 | WIDTHPROF = None |
|
781 | WIDTHPROF = None | |
577 | HEIGHTPROF = None |
|
782 | HEIGHTPROF = None | |
578 | PREFIX = 'prm' |
|
783 | PREFIX = 'prm' | |
579 |
|
784 | |||
580 | def __init__(self): |
|
785 | def __init__(self): | |
581 |
|
786 | |||
582 | self.timerange = 2*60*60 |
|
787 | self.timerange = 2*60*60 | |
583 | self.isConfig = False |
|
788 | self.isConfig = False | |
584 | self.__nsubplots = 1 |
|
789 | self.__nsubplots = 1 | |
585 |
|
790 | |||
586 | self.WIDTH = 800 |
|
791 | self.WIDTH = 800 | |
587 | self.HEIGHT = 150 |
|
792 | self.HEIGHT = 150 | |
588 | self.WIDTHPROF = 120 |
|
793 | self.WIDTHPROF = 120 | |
589 | self.HEIGHTPROF = 0 |
|
794 | self.HEIGHTPROF = 0 | |
590 | self.counter_imagwr = 0 |
|
795 | self.counter_imagwr = 0 | |
591 |
|
796 | |||
592 | self.PLOT_CODE = PARMS_CODE |
|
797 | self.PLOT_CODE = PARMS_CODE | |
593 |
|
798 | |||
594 | self.FTP_WEI = None |
|
799 | self.FTP_WEI = None | |
595 | self.EXP_CODE = None |
|
800 | self.EXP_CODE = None | |
596 | self.SUB_EXP_CODE = None |
|
801 | self.SUB_EXP_CODE = None | |
597 | self.PLOT_POS = None |
|
802 | self.PLOT_POS = None | |
598 | self.tmin = None |
|
803 | self.tmin = None | |
599 | self.tmax = None |
|
804 | self.tmax = None | |
600 |
|
805 | |||
601 | self.xmin = None |
|
806 | self.xmin = None | |
602 | self.xmax = None |
|
807 | self.xmax = None | |
603 |
|
808 | |||
604 | self.figfile = None |
|
809 | self.figfile = None | |
605 |
|
810 | |||
606 | def getSubplots(self): |
|
811 | def getSubplots(self): | |
607 |
|
812 | |||
608 | ncol = 1 |
|
813 | ncol = 1 | |
609 | nrow = self.nplots |
|
814 | nrow = self.nplots | |
610 |
|
815 | |||
611 | return nrow, ncol |
|
816 | return nrow, ncol | |
612 |
|
817 | |||
613 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
818 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
614 |
|
819 | |||
615 | self.__showprofile = showprofile |
|
820 | self.__showprofile = showprofile | |
616 | self.nplots = nplots |
|
821 | self.nplots = nplots | |
617 |
|
822 | |||
618 | ncolspan = 1 |
|
823 | ncolspan = 1 | |
619 | colspan = 1 |
|
824 | colspan = 1 | |
620 |
|
825 | |||
621 | self.createFigure(id = id, |
|
826 | self.createFigure(id = id, | |
622 | wintitle = wintitle, |
|
827 | wintitle = wintitle, | |
623 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
828 | widthplot = self.WIDTH + self.WIDTHPROF, | |
624 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
829 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
625 | show=show) |
|
830 | show=show) | |
626 |
|
831 | |||
627 | nrow, ncol = self.getSubplots() |
|
832 | nrow, ncol = self.getSubplots() | |
628 |
|
833 | |||
629 | counter = 0 |
|
834 | counter = 0 | |
630 | for y in range(nrow): |
|
835 | for y in range(nrow): | |
631 | for x in range(ncol): |
|
836 | for x in range(ncol): | |
632 |
|
837 | |||
633 | if counter >= self.nplots: |
|
838 | if counter >= self.nplots: | |
634 | break |
|
839 | break | |
635 |
|
840 | |||
636 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
841 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
637 |
|
842 | |||
638 | if showprofile: |
|
843 | if showprofile: | |
639 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
844 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
640 |
|
845 | |||
641 | counter += 1 |
|
846 | counter += 1 | |
642 |
|
847 | |||
643 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, |
|
848 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | |
644 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None, |
|
849 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None, | |
645 | parameterIndex = None, onlyPositive = False, |
|
850 | parameterIndex = None, onlyPositive = False, | |
646 | SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False, |
|
851 | SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False, | |
647 | DOP = True, |
|
852 | DOP = True, | |
648 | zlabel = "", parameterName = "", parameterObject = "data_param", |
|
853 | zlabel = "", parameterName = "", parameterObject = "data_param", | |
649 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
854 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
650 | server=None, folder=None, username=None, password=None, |
|
855 | server=None, folder=None, username=None, password=None, | |
651 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
856 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
652 |
|
857 | |||
653 | """ |
|
858 | """ | |
654 |
|
859 | |||
655 | Input: |
|
860 | Input: | |
656 | dataOut : |
|
861 | dataOut : | |
657 | id : |
|
862 | id : | |
658 | wintitle : |
|
863 | wintitle : | |
659 | channelList : |
|
864 | channelList : | |
660 | showProfile : |
|
865 | showProfile : | |
661 | xmin : None, |
|
866 | xmin : None, | |
662 | xmax : None, |
|
867 | xmax : None, | |
663 | ymin : None, |
|
868 | ymin : None, | |
664 | ymax : None, |
|
869 | ymax : None, | |
665 | zmin : None, |
|
870 | zmin : None, | |
666 | zmax : None |
|
871 | zmax : None | |
667 | """ |
|
872 | """ | |
668 |
|
873 | |||
669 | data_param = getattr(dataOut, parameterObject) |
|
874 | data_param = getattr(dataOut, parameterObject) | |
670 |
|
875 | |||
671 | if channelList == None: |
|
876 | if channelList == None: | |
672 | channelIndexList = numpy.arange(data_param.shape[0]) |
|
877 | channelIndexList = numpy.arange(data_param.shape[0]) | |
673 | else: |
|
878 | else: | |
674 | channelIndexList = numpy.array(channelList) |
|
879 | channelIndexList = numpy.array(channelList) | |
675 |
|
880 | |||
676 | nchan = len(channelIndexList) #Number of channels being plotted |
|
881 | nchan = len(channelIndexList) #Number of channels being plotted | |
677 |
|
882 | |||
678 | if nchan < 1: |
|
883 | if nchan < 1: | |
679 | return |
|
884 | return | |
680 |
|
885 | |||
681 | nGraphsByChannel = 0 |
|
886 | nGraphsByChannel = 0 | |
682 |
|
887 | |||
683 | if SNR: |
|
888 | if SNR: | |
684 | nGraphsByChannel += 1 |
|
889 | nGraphsByChannel += 1 | |
685 | if DOP: |
|
890 | if DOP: | |
686 | nGraphsByChannel += 1 |
|
891 | nGraphsByChannel += 1 | |
687 |
|
892 | |||
688 | if nGraphsByChannel < 1: |
|
893 | if nGraphsByChannel < 1: | |
689 | return |
|
894 | return | |
690 |
|
895 | |||
691 | nplots = nGraphsByChannel*nchan |
|
896 | nplots = nGraphsByChannel*nchan | |
692 |
|
897 | |||
693 | if timerange is not None: |
|
898 | if timerange is not None: | |
694 | self.timerange = timerange |
|
899 | self.timerange = timerange | |
695 |
|
900 | |||
696 | #tmin = None |
|
901 | #tmin = None | |
697 | #tmax = None |
|
902 | #tmax = None | |
698 | if parameterIndex == None: |
|
903 | if parameterIndex == None: | |
699 | parameterIndex = 1 |
|
904 | parameterIndex = 1 | |
700 |
|
905 | |||
701 | x = dataOut.getTimeRange1(dataOut.paramInterval) |
|
906 | x = dataOut.getTimeRange1(dataOut.paramInterval) | |
702 | y = dataOut.heightList |
|
907 | y = dataOut.heightList | |
703 | z = data_param[channelIndexList,parameterIndex,:].copy() |
|
908 | z = data_param[channelIndexList,parameterIndex,:].copy() | |
704 |
|
909 | |||
705 | zRange = dataOut.abscissaList |
|
910 | zRange = dataOut.abscissaList | |
706 | # nChannels = z.shape[0] #Number of wind dimensions estimated |
|
911 | # nChannels = z.shape[0] #Number of wind dimensions estimated | |
707 | # thisDatetime = dataOut.datatime |
|
912 | # thisDatetime = dataOut.datatime | |
708 |
|
913 | |||
709 | if dataOut.data_SNR is not None: |
|
914 | if dataOut.data_SNR is not None: | |
710 | SNRarray = dataOut.data_SNR[channelIndexList,:] |
|
915 | SNRarray = dataOut.data_SNR[channelIndexList,:] | |
711 | SNRdB = 10*numpy.log10(SNRarray) |
|
916 | SNRdB = 10*numpy.log10(SNRarray) | |
712 | # SNRavgdB = 10*numpy.log10(SNRavg) |
|
917 | # SNRavgdB = 10*numpy.log10(SNRavg) | |
713 | ind = numpy.where(SNRdB < 10**(SNRthresh/10)) |
|
918 | ind = numpy.where(SNRdB < 10**(SNRthresh/10)) | |
714 | z[ind] = numpy.nan |
|
919 | z[ind] = numpy.nan | |
715 |
|
920 | |||
716 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
921 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
717 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
922 | title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
718 | xlabel = "" |
|
923 | xlabel = "" | |
719 | ylabel = "Range (Km)" |
|
924 | ylabel = "Range (Km)" | |
720 |
|
925 | |||
721 | if (SNR and not onlySNR): nplots = 2*nplots |
|
926 | if (SNR and not onlySNR): nplots = 2*nplots | |
722 |
|
927 | |||
723 | if onlyPositive: |
|
928 | if onlyPositive: | |
724 | colormap = "jet" |
|
929 | colormap = "jet" | |
725 | zmin = 0 |
|
930 | zmin = 0 | |
726 | else: colormap = "RdBu_r" |
|
931 | else: colormap = "RdBu_r" | |
727 |
|
932 | |||
728 | if not self.isConfig: |
|
933 | if not self.isConfig: | |
729 |
|
934 | |||
730 | self.setup(id=id, |
|
935 | self.setup(id=id, | |
731 | nplots=nplots, |
|
936 | nplots=nplots, | |
732 | wintitle=wintitle, |
|
937 | wintitle=wintitle, | |
733 | showprofile=showprofile, |
|
938 | showprofile=showprofile, | |
734 | show=show) |
|
939 | show=show) | |
735 |
|
940 | |||
736 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
941 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
737 |
|
942 | |||
738 | if ymin == None: ymin = numpy.nanmin(y) |
|
943 | if ymin == None: ymin = numpy.nanmin(y) | |
739 | if ymax == None: ymax = numpy.nanmax(y) |
|
944 | if ymax == None: ymax = numpy.nanmax(y) | |
740 | if zmin == None: zmin = numpy.nanmin(zRange) |
|
945 | if zmin == None: zmin = numpy.nanmin(zRange) | |
741 | if zmax == None: zmax = numpy.nanmax(zRange) |
|
946 | if zmax == None: zmax = numpy.nanmax(zRange) | |
742 |
|
947 | |||
743 | if SNR: |
|
948 | if SNR: | |
744 | if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) |
|
949 | if SNRmin == None: SNRmin = numpy.nanmin(SNRdB) | |
745 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) |
|
950 | if SNRmax == None: SNRmax = numpy.nanmax(SNRdB) | |
746 |
|
951 | |||
747 | self.FTP_WEI = ftp_wei |
|
952 | self.FTP_WEI = ftp_wei | |
748 | self.EXP_CODE = exp_code |
|
953 | self.EXP_CODE = exp_code | |
749 | self.SUB_EXP_CODE = sub_exp_code |
|
954 | self.SUB_EXP_CODE = sub_exp_code | |
750 | self.PLOT_POS = plot_pos |
|
955 | self.PLOT_POS = plot_pos | |
751 |
|
956 | |||
752 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
957 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
753 | self.isConfig = True |
|
958 | self.isConfig = True | |
754 | self.figfile = figfile |
|
959 | self.figfile = figfile | |
755 |
|
960 | |||
756 | self.setWinTitle(title) |
|
961 | self.setWinTitle(title) | |
757 |
|
962 | |||
758 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
963 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
759 | x[1] = self.xmax |
|
964 | x[1] = self.xmax | |
760 |
|
965 | |||
761 | for i in range(nchan): |
|
966 | for i in range(nchan): | |
762 |
|
967 | |||
763 | if (SNR and not onlySNR): j = 2*i |
|
968 | if (SNR and not onlySNR): j = 2*i | |
764 | else: j = i |
|
969 | else: j = i | |
765 |
|
970 | |||
766 | j = nGraphsByChannel*i |
|
971 | j = nGraphsByChannel*i | |
767 |
|
972 | |||
768 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
973 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
769 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
974 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
770 |
|
975 | |||
771 | if not onlySNR: |
|
976 | if not onlySNR: | |
772 | axes = self.axesList[j*self.__nsubplots] |
|
977 | axes = self.axesList[j*self.__nsubplots] | |
773 | z1 = z[i,:].reshape((1,-1)) |
|
978 | z1 = z[i,:].reshape((1,-1)) | |
774 | axes.pcolorbuffer(x, y, z1, |
|
979 | axes.pcolorbuffer(x, y, z1, | |
775 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
980 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
776 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, |
|
981 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, | |
777 | ticksize=9, cblabel=zlabel, cbsize="1%") |
|
982 | ticksize=9, cblabel=zlabel, cbsize="1%") | |
778 |
|
983 | |||
779 | if DOP: |
|
984 | if DOP: | |
780 | title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
985 | title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
781 |
|
986 | |||
782 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
987 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
783 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
988 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
784 | axes = self.axesList[j] |
|
989 | axes = self.axesList[j] | |
785 | z1 = z[i,:].reshape((1,-1)) |
|
990 | z1 = z[i,:].reshape((1,-1)) | |
786 | axes.pcolorbuffer(x, y, z1, |
|
991 | axes.pcolorbuffer(x, y, z1, | |
787 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
992 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
788 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, |
|
993 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap, | |
789 | ticksize=9, cblabel=zlabel, cbsize="1%") |
|
994 | ticksize=9, cblabel=zlabel, cbsize="1%") | |
790 |
|
995 | |||
791 | if SNR: |
|
996 | if SNR: | |
792 | title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
997 | title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
793 | axes = self.axesList[(j)*self.__nsubplots] |
|
998 | axes = self.axesList[(j)*self.__nsubplots] | |
794 | if not onlySNR: |
|
999 | if not onlySNR: | |
795 | axes = self.axesList[(j + 1)*self.__nsubplots] |
|
1000 | axes = self.axesList[(j + 1)*self.__nsubplots] | |
796 |
|
1001 | |||
797 | axes = self.axesList[(j + nGraphsByChannel-1)] |
|
1002 | axes = self.axesList[(j + nGraphsByChannel-1)] | |
798 |
|
1003 | |||
799 | z1 = SNRdB[i,:].reshape((1,-1)) |
|
1004 | z1 = SNRdB[i,:].reshape((1,-1)) | |
800 | axes.pcolorbuffer(x, y, z1, |
|
1005 | axes.pcolorbuffer(x, y, z1, | |
801 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
1006 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
802 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet", |
|
1007 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet", | |
803 | ticksize=9, cblabel=zlabel, cbsize="1%") |
|
1008 | ticksize=9, cblabel=zlabel, cbsize="1%") | |
804 |
|
1009 | |||
805 |
|
1010 | |||
806 |
|
1011 | |||
807 | self.draw() |
|
1012 | self.draw() | |
808 |
|
1013 | |||
809 | if x[1] >= self.axesList[0].xmax: |
|
1014 | if x[1] >= self.axesList[0].xmax: | |
810 | self.counter_imagwr = wr_period |
|
1015 | self.counter_imagwr = wr_period | |
811 | self.isConfig = False |
|
1016 | self.isConfig = False | |
812 | self.figfile = None |
|
1017 | self.figfile = None | |
813 |
|
1018 | |||
814 | self.save(figpath=figpath, |
|
1019 | self.save(figpath=figpath, | |
815 | figfile=figfile, |
|
1020 | figfile=figfile, | |
816 | save=save, |
|
1021 | save=save, | |
817 | ftp=ftp, |
|
1022 | ftp=ftp, | |
818 | wr_period=wr_period, |
|
1023 | wr_period=wr_period, | |
819 | thisDatetime=thisDatetime, |
|
1024 | thisDatetime=thisDatetime, | |
820 | update_figfile=False) |
|
1025 | update_figfile=False) | |
821 |
|
1026 | |||
822 | class SpectralFittingPlot(Figure): |
|
1027 | class SpectralFittingPlot(Figure): | |
823 |
|
1028 | |||
824 | __isConfig = None |
|
1029 | __isConfig = None | |
825 | __nsubplots = None |
|
1030 | __nsubplots = None | |
826 |
|
1031 | |||
827 | WIDTHPROF = None |
|
1032 | WIDTHPROF = None | |
828 | HEIGHTPROF = None |
|
1033 | HEIGHTPROF = None | |
829 | PREFIX = 'prm' |
|
1034 | PREFIX = 'prm' | |
830 |
|
1035 | |||
831 |
|
1036 | |||
832 | N = None |
|
1037 | N = None | |
833 | ippSeconds = None |
|
1038 | ippSeconds = None | |
834 |
|
1039 | |||
835 | def __init__(self): |
|
1040 | def __init__(self): | |
836 | self.isConfig = False |
|
1041 | self.isConfig = False | |
837 | self.__nsubplots = 1 |
|
1042 | self.__nsubplots = 1 | |
838 |
|
1043 | |||
839 | self.PLOT_CODE = SPECFIT_CODE |
|
1044 | self.PLOT_CODE = SPECFIT_CODE | |
840 |
|
1045 | |||
841 | self.WIDTH = 450 |
|
1046 | self.WIDTH = 450 | |
842 | self.HEIGHT = 250 |
|
1047 | self.HEIGHT = 250 | |
843 | self.WIDTHPROF = 0 |
|
1048 | self.WIDTHPROF = 0 | |
844 | self.HEIGHTPROF = 0 |
|
1049 | self.HEIGHTPROF = 0 | |
845 |
|
1050 | |||
846 | def getSubplots(self): |
|
1051 | def getSubplots(self): | |
847 |
|
1052 | |||
848 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
1053 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
849 | nrow = int(self.nplots*1./ncol + 0.9) |
|
1054 | nrow = int(self.nplots*1./ncol + 0.9) | |
850 |
|
1055 | |||
851 | return nrow, ncol |
|
1056 | return nrow, ncol | |
852 |
|
1057 | |||
853 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): |
|
1058 | def setup(self, id, nplots, wintitle, showprofile=False, show=True): | |
854 |
|
1059 | |||
855 | showprofile = False |
|
1060 | showprofile = False | |
856 | self.__showprofile = showprofile |
|
1061 | self.__showprofile = showprofile | |
857 | self.nplots = nplots |
|
1062 | self.nplots = nplots | |
858 |
|
1063 | |||
859 | ncolspan = 5 |
|
1064 | ncolspan = 5 | |
860 | colspan = 4 |
|
1065 | colspan = 4 | |
861 | if showprofile: |
|
1066 | if showprofile: | |
862 | ncolspan = 5 |
|
1067 | ncolspan = 5 | |
863 | colspan = 4 |
|
1068 | colspan = 4 | |
864 | self.__nsubplots = 2 |
|
1069 | self.__nsubplots = 2 | |
865 |
|
1070 | |||
866 | self.createFigure(id = id, |
|
1071 | self.createFigure(id = id, | |
867 | wintitle = wintitle, |
|
1072 | wintitle = wintitle, | |
868 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1073 | widthplot = self.WIDTH + self.WIDTHPROF, | |
869 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1074 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
870 | show=show) |
|
1075 | show=show) | |
871 |
|
1076 | |||
872 | nrow, ncol = self.getSubplots() |
|
1077 | nrow, ncol = self.getSubplots() | |
873 |
|
1078 | |||
874 | counter = 0 |
|
1079 | counter = 0 | |
875 | for y in range(nrow): |
|
1080 | for y in range(nrow): | |
876 | for x in range(ncol): |
|
1081 | for x in range(ncol): | |
877 |
|
1082 | |||
878 | if counter >= self.nplots: |
|
1083 | if counter >= self.nplots: | |
879 | break |
|
1084 | break | |
880 |
|
1085 | |||
881 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1086 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
882 |
|
1087 | |||
883 | if showprofile: |
|
1088 | if showprofile: | |
884 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
1089 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
885 |
|
1090 | |||
886 | counter += 1 |
|
1091 | counter += 1 | |
887 |
|
1092 | |||
888 | def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True, |
|
1093 | def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True, | |
889 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1094 | xmin=None, xmax=None, ymin=None, ymax=None, | |
890 | save=False, figpath='./', figfile=None, show=True): |
|
1095 | save=False, figpath='./', figfile=None, show=True): | |
891 |
|
1096 | |||
892 | """ |
|
1097 | """ | |
893 |
|
1098 | |||
894 | Input: |
|
1099 | Input: | |
895 | dataOut : |
|
1100 | dataOut : | |
896 | id : |
|
1101 | id : | |
897 | wintitle : |
|
1102 | wintitle : | |
898 | channelList : |
|
1103 | channelList : | |
899 | showProfile : |
|
1104 | showProfile : | |
900 | xmin : None, |
|
1105 | xmin : None, | |
901 | xmax : None, |
|
1106 | xmax : None, | |
902 | zmin : None, |
|
1107 | zmin : None, | |
903 | zmax : None |
|
1108 | zmax : None | |
904 | """ |
|
1109 | """ | |
905 |
|
1110 | |||
906 | if cutHeight==None: |
|
1111 | if cutHeight==None: | |
907 | h=270 |
|
1112 | h=270 | |
908 | heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin() |
|
1113 | heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin() | |
909 | cutHeight = dataOut.heightList[heightindex] |
|
1114 | cutHeight = dataOut.heightList[heightindex] | |
910 |
|
1115 | |||
911 | factor = dataOut.normFactor |
|
1116 | factor = dataOut.normFactor | |
912 | x = dataOut.abscissaList[:-1] |
|
1117 | x = dataOut.abscissaList[:-1] | |
913 | #y = dataOut.getHeiRange() |
|
1118 | #y = dataOut.getHeiRange() | |
914 |
|
1119 | |||
915 | z = dataOut.data_pre[:,:,heightindex]/factor |
|
1120 | z = dataOut.data_pre[:,:,heightindex]/factor | |
916 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
1121 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
917 | avg = numpy.average(z, axis=1) |
|
1122 | avg = numpy.average(z, axis=1) | |
918 | listChannels = z.shape[0] |
|
1123 | listChannels = z.shape[0] | |
919 |
|
1124 | |||
920 | #Reconstruct Function |
|
1125 | #Reconstruct Function | |
921 | if fit==True: |
|
1126 | if fit==True: | |
922 | groupArray = dataOut.groupList |
|
1127 | groupArray = dataOut.groupList | |
923 | listChannels = groupArray.reshape((groupArray.size)) |
|
1128 | listChannels = groupArray.reshape((groupArray.size)) | |
924 | listChannels.sort() |
|
1129 | listChannels.sort() | |
925 | spcFitLine = numpy.zeros(z.shape) |
|
1130 | spcFitLine = numpy.zeros(z.shape) | |
926 | constants = dataOut.constants |
|
1131 | constants = dataOut.constants | |
927 |
|
1132 | |||
928 | nGroups = groupArray.shape[0] |
|
1133 | nGroups = groupArray.shape[0] | |
929 | nChannels = groupArray.shape[1] |
|
1134 | nChannels = groupArray.shape[1] | |
930 | nProfiles = z.shape[1] |
|
1135 | nProfiles = z.shape[1] | |
931 |
|
1136 | |||
932 | for f in range(nGroups): |
|
1137 | for f in range(nGroups): | |
933 | groupChann = groupArray[f,:] |
|
1138 | groupChann = groupArray[f,:] | |
934 | p = dataOut.data_param[f,:,heightindex] |
|
1139 | p = dataOut.data_param[f,:,heightindex] | |
935 | # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167]) |
|
1140 | # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167]) | |
936 | fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles |
|
1141 | fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles | |
937 | fitLineAux = fitLineAux.reshape((nChannels,nProfiles)) |
|
1142 | fitLineAux = fitLineAux.reshape((nChannels,nProfiles)) | |
938 | spcFitLine[groupChann,:] = fitLineAux |
|
1143 | spcFitLine[groupChann,:] = fitLineAux | |
939 | # spcFitLine = spcFitLine/factor |
|
1144 | # spcFitLine = spcFitLine/factor | |
940 |
|
1145 | |||
941 | z = z[listChannels,:] |
|
1146 | z = z[listChannels,:] | |
942 | spcFitLine = spcFitLine[listChannels,:] |
|
1147 | spcFitLine = spcFitLine[listChannels,:] | |
943 | spcFitLinedB = 10*numpy.log10(spcFitLine) |
|
1148 | spcFitLinedB = 10*numpy.log10(spcFitLine) | |
944 |
|
1149 | |||
945 | zdB = 10*numpy.log10(z) |
|
1150 | zdB = 10*numpy.log10(z) | |
946 | #thisDatetime = dataOut.datatime |
|
1151 | #thisDatetime = dataOut.datatime | |
947 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
1152 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
948 | title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1153 | title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
949 | xlabel = "Velocity (m/s)" |
|
1154 | xlabel = "Velocity (m/s)" | |
950 | ylabel = "Spectrum" |
|
1155 | ylabel = "Spectrum" | |
951 |
|
1156 | |||
952 | if not self.isConfig: |
|
1157 | if not self.isConfig: | |
953 |
|
1158 | |||
954 | nplots = listChannels.size |
|
1159 | nplots = listChannels.size | |
955 |
|
1160 | |||
956 | self.setup(id=id, |
|
1161 | self.setup(id=id, | |
957 | nplots=nplots, |
|
1162 | nplots=nplots, | |
958 | wintitle=wintitle, |
|
1163 | wintitle=wintitle, | |
959 | showprofile=showprofile, |
|
1164 | showprofile=showprofile, | |
960 | show=show) |
|
1165 | show=show) | |
961 |
|
1166 | |||
962 | if xmin == None: xmin = numpy.nanmin(x) |
|
1167 | if xmin == None: xmin = numpy.nanmin(x) | |
963 | if xmax == None: xmax = numpy.nanmax(x) |
|
1168 | if xmax == None: xmax = numpy.nanmax(x) | |
964 | if ymin == None: ymin = numpy.nanmin(zdB) |
|
1169 | if ymin == None: ymin = numpy.nanmin(zdB) | |
965 | if ymax == None: ymax = numpy.nanmax(zdB)+2 |
|
1170 | if ymax == None: ymax = numpy.nanmax(zdB)+2 | |
966 |
|
1171 | |||
967 | self.isConfig = True |
|
1172 | self.isConfig = True | |
968 |
|
1173 | |||
969 | self.setWinTitle(title) |
|
1174 | self.setWinTitle(title) | |
970 | for i in range(self.nplots): |
|
1175 | for i in range(self.nplots): | |
971 | # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i]) |
|
1176 | # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i]) | |
972 | title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]) |
|
1177 | title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i]) | |
973 | axes = self.axesList[i*self.__nsubplots] |
|
1178 | axes = self.axesList[i*self.__nsubplots] | |
974 | if fit == False: |
|
1179 | if fit == False: | |
975 | axes.pline(x, zdB[i,:], |
|
1180 | axes.pline(x, zdB[i,:], | |
976 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1181 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
977 | xlabel=xlabel, ylabel=ylabel, title=title |
|
1182 | xlabel=xlabel, ylabel=ylabel, title=title | |
978 | ) |
|
1183 | ) | |
979 | if fit == True: |
|
1184 | if fit == True: | |
980 | fitline=spcFitLinedB[i,:] |
|
1185 | fitline=spcFitLinedB[i,:] | |
981 | y=numpy.vstack([zdB[i,:],fitline] ) |
|
1186 | y=numpy.vstack([zdB[i,:],fitline] ) | |
982 | legendlabels=['Data','Fitting'] |
|
1187 | legendlabels=['Data','Fitting'] | |
983 | axes.pmultilineyaxis(x, y, |
|
1188 | axes.pmultilineyaxis(x, y, | |
984 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1189 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
985 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
1190 | xlabel=xlabel, ylabel=ylabel, title=title, | |
986 | legendlabels=legendlabels, marker=None, |
|
1191 | legendlabels=legendlabels, marker=None, | |
987 | linestyle='solid', grid='both') |
|
1192 | linestyle='solid', grid='both') | |
988 |
|
1193 | |||
989 | self.draw() |
|
1194 | self.draw() | |
990 |
|
1195 | |||
991 | self.save(figpath=figpath, |
|
1196 | self.save(figpath=figpath, | |
992 | figfile=figfile, |
|
1197 | figfile=figfile, | |
993 | save=save, |
|
1198 | save=save, | |
994 | ftp=ftp, |
|
1199 | ftp=ftp, | |
995 | wr_period=wr_period, |
|
1200 | wr_period=wr_period, | |
996 | thisDatetime=thisDatetime) |
|
1201 | thisDatetime=thisDatetime) | |
997 |
|
1202 | |||
998 |
|
1203 | |||
999 | class EWDriftsPlot(Figure): |
|
1204 | class EWDriftsPlot(Figure): | |
1000 |
|
1205 | |||
1001 | __isConfig = None |
|
1206 | __isConfig = None | |
1002 | __nsubplots = None |
|
1207 | __nsubplots = None | |
1003 |
|
1208 | |||
1004 | WIDTHPROF = None |
|
1209 | WIDTHPROF = None | |
1005 | HEIGHTPROF = None |
|
1210 | HEIGHTPROF = None | |
1006 | PREFIX = 'drift' |
|
1211 | PREFIX = 'drift' | |
1007 |
|
1212 | |||
1008 | def __init__(self): |
|
1213 | def __init__(self): | |
1009 |
|
1214 | |||
1010 | self.timerange = 2*60*60 |
|
1215 | self.timerange = 2*60*60 | |
1011 | self.isConfig = False |
|
1216 | self.isConfig = False | |
1012 | self.__nsubplots = 1 |
|
1217 | self.__nsubplots = 1 | |
1013 |
|
1218 | |||
1014 | self.WIDTH = 800 |
|
1219 | self.WIDTH = 800 | |
1015 | self.HEIGHT = 150 |
|
1220 | self.HEIGHT = 150 | |
1016 | self.WIDTHPROF = 120 |
|
1221 | self.WIDTHPROF = 120 | |
1017 | self.HEIGHTPROF = 0 |
|
1222 | self.HEIGHTPROF = 0 | |
1018 | self.counter_imagwr = 0 |
|
1223 | self.counter_imagwr = 0 | |
1019 |
|
1224 | |||
1020 | self.PLOT_CODE = EWDRIFT_CODE |
|
1225 | self.PLOT_CODE = EWDRIFT_CODE | |
1021 |
|
1226 | |||
1022 | self.FTP_WEI = None |
|
1227 | self.FTP_WEI = None | |
1023 | self.EXP_CODE = None |
|
1228 | self.EXP_CODE = None | |
1024 | self.SUB_EXP_CODE = None |
|
1229 | self.SUB_EXP_CODE = None | |
1025 | self.PLOT_POS = None |
|
1230 | self.PLOT_POS = None | |
1026 | self.tmin = None |
|
1231 | self.tmin = None | |
1027 | self.tmax = None |
|
1232 | self.tmax = None | |
1028 |
|
1233 | |||
1029 | self.xmin = None |
|
1234 | self.xmin = None | |
1030 | self.xmax = None |
|
1235 | self.xmax = None | |
1031 |
|
1236 | |||
1032 | self.figfile = None |
|
1237 | self.figfile = None | |
1033 |
|
1238 | |||
1034 | def getSubplots(self): |
|
1239 | def getSubplots(self): | |
1035 |
|
1240 | |||
1036 | ncol = 1 |
|
1241 | ncol = 1 | |
1037 | nrow = self.nplots |
|
1242 | nrow = self.nplots | |
1038 |
|
1243 | |||
1039 | return nrow, ncol |
|
1244 | return nrow, ncol | |
1040 |
|
1245 | |||
1041 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1246 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1042 |
|
1247 | |||
1043 | self.__showprofile = showprofile |
|
1248 | self.__showprofile = showprofile | |
1044 | self.nplots = nplots |
|
1249 | self.nplots = nplots | |
1045 |
|
1250 | |||
1046 | ncolspan = 1 |
|
1251 | ncolspan = 1 | |
1047 | colspan = 1 |
|
1252 | colspan = 1 | |
1048 |
|
1253 | |||
1049 | self.createFigure(id = id, |
|
1254 | self.createFigure(id = id, | |
1050 | wintitle = wintitle, |
|
1255 | wintitle = wintitle, | |
1051 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1256 | widthplot = self.WIDTH + self.WIDTHPROF, | |
1052 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1257 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
1053 | show=show) |
|
1258 | show=show) | |
1054 |
|
1259 | |||
1055 | nrow, ncol = self.getSubplots() |
|
1260 | nrow, ncol = self.getSubplots() | |
1056 |
|
1261 | |||
1057 | counter = 0 |
|
1262 | counter = 0 | |
1058 | for y in range(nrow): |
|
1263 | for y in range(nrow): | |
1059 | if counter >= self.nplots: |
|
1264 | if counter >= self.nplots: | |
1060 | break |
|
1265 | break | |
1061 |
|
1266 | |||
1062 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) |
|
1267 | self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1) | |
1063 | counter += 1 |
|
1268 | counter += 1 | |
1064 |
|
1269 | |||
1065 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
1270 | def run(self, dataOut, id, wintitle="", channelList=None, | |
1066 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
1271 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
1067 | zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None, |
|
1272 | zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None, | |
1068 | timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False, |
|
1273 | timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False, | |
1069 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
1274 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
1070 | server=None, folder=None, username=None, password=None, |
|
1275 | server=None, folder=None, username=None, password=None, | |
1071 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1276 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1072 | """ |
|
1277 | """ | |
1073 |
|
1278 | |||
1074 | Input: |
|
1279 | Input: | |
1075 | dataOut : |
|
1280 | dataOut : | |
1076 | id : |
|
1281 | id : | |
1077 | wintitle : |
|
1282 | wintitle : | |
1078 | channelList : |
|
1283 | channelList : | |
1079 | showProfile : |
|
1284 | showProfile : | |
1080 | xmin : None, |
|
1285 | xmin : None, | |
1081 | xmax : None, |
|
1286 | xmax : None, | |
1082 | ymin : None, |
|
1287 | ymin : None, | |
1083 | ymax : None, |
|
1288 | ymax : None, | |
1084 | zmin : None, |
|
1289 | zmin : None, | |
1085 | zmax : None |
|
1290 | zmax : None | |
1086 | """ |
|
1291 | """ | |
1087 |
|
1292 | |||
1088 | if timerange is not None: |
|
1293 | if timerange is not None: | |
1089 | self.timerange = timerange |
|
1294 | self.timerange = timerange | |
1090 |
|
1295 | |||
1091 | tmin = None |
|
1296 | tmin = None | |
1092 | tmax = None |
|
1297 | tmax = None | |
1093 |
|
1298 | |||
1094 | x = dataOut.getTimeRange1(dataOut.outputInterval) |
|
1299 | x = dataOut.getTimeRange1(dataOut.outputInterval) | |
1095 | # y = dataOut.heightList |
|
1300 | # y = dataOut.heightList | |
1096 | y = dataOut.heightList |
|
1301 | y = dataOut.heightList | |
1097 |
|
1302 | |||
1098 | z = dataOut.data_output |
|
1303 | z = dataOut.data_output | |
1099 | nplots = z.shape[0] #Number of wind dimensions estimated |
|
1304 | nplots = z.shape[0] #Number of wind dimensions estimated | |
1100 | nplotsw = nplots |
|
1305 | nplotsw = nplots | |
1101 |
|
1306 | |||
1102 | #If there is a SNR function defined |
|
1307 | #If there is a SNR function defined | |
1103 | if dataOut.data_SNR is not None: |
|
1308 | if dataOut.data_SNR is not None: | |
1104 | nplots += 1 |
|
1309 | nplots += 1 | |
1105 | SNR = dataOut.data_SNR |
|
1310 | SNR = dataOut.data_SNR | |
1106 |
|
1311 | |||
1107 | if SNR_1: |
|
1312 | if SNR_1: | |
1108 | SNR += 1 |
|
1313 | SNR += 1 | |
1109 |
|
1314 | |||
1110 | SNRavg = numpy.average(SNR, axis=0) |
|
1315 | SNRavg = numpy.average(SNR, axis=0) | |
1111 |
|
1316 | |||
1112 | SNRdB = 10*numpy.log10(SNR) |
|
1317 | SNRdB = 10*numpy.log10(SNR) | |
1113 | SNRavgdB = 10*numpy.log10(SNRavg) |
|
1318 | SNRavgdB = 10*numpy.log10(SNRavg) | |
1114 |
|
1319 | |||
1115 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] |
|
1320 | ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0] | |
1116 |
|
1321 | |||
1117 | for i in range(nplotsw): |
|
1322 | for i in range(nplotsw): | |
1118 | z[i,ind] = numpy.nan |
|
1323 | z[i,ind] = numpy.nan | |
1119 |
|
1324 | |||
1120 |
|
1325 | |||
1121 | showprofile = False |
|
1326 | showprofile = False | |
1122 | # thisDatetime = dataOut.datatime |
|
1327 | # thisDatetime = dataOut.datatime | |
1123 | thisDatetime = datetime.datetime.utcfromtimestamp(x[1]) |
|
1328 | thisDatetime = datetime.datetime.utcfromtimestamp(x[1]) | |
1124 | title = wintitle + " EW Drifts" |
|
1329 | title = wintitle + " EW Drifts" | |
1125 | xlabel = "" |
|
1330 | xlabel = "" | |
1126 | ylabel = "Height (Km)" |
|
1331 | ylabel = "Height (Km)" | |
1127 |
|
1332 | |||
1128 | if not self.isConfig: |
|
1333 | if not self.isConfig: | |
1129 |
|
1334 | |||
1130 | self.setup(id=id, |
|
1335 | self.setup(id=id, | |
1131 | nplots=nplots, |
|
1336 | nplots=nplots, | |
1132 | wintitle=wintitle, |
|
1337 | wintitle=wintitle, | |
1133 | showprofile=showprofile, |
|
1338 | showprofile=showprofile, | |
1134 | show=show) |
|
1339 | show=show) | |
1135 |
|
1340 | |||
1136 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1341 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1137 |
|
1342 | |||
1138 | if ymin == None: ymin = numpy.nanmin(y) |
|
1343 | if ymin == None: ymin = numpy.nanmin(y) | |
1139 | if ymax == None: ymax = numpy.nanmax(y) |
|
1344 | if ymax == None: ymax = numpy.nanmax(y) | |
1140 |
|
1345 | |||
1141 | if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:])) |
|
1346 | if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:])) | |
1142 | if zminZonal == None: zminZonal = -zmaxZonal |
|
1347 | if zminZonal == None: zminZonal = -zmaxZonal | |
1143 | if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:])) |
|
1348 | if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:])) | |
1144 | if zminVertical == None: zminVertical = -zmaxVertical |
|
1349 | if zminVertical == None: zminVertical = -zmaxVertical | |
1145 |
|
1350 | |||
1146 | if dataOut.data_SNR is not None: |
|
1351 | if dataOut.data_SNR is not None: | |
1147 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) |
|
1352 | if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB) | |
1148 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) |
|
1353 | if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB) | |
1149 |
|
1354 | |||
1150 | self.FTP_WEI = ftp_wei |
|
1355 | self.FTP_WEI = ftp_wei | |
1151 | self.EXP_CODE = exp_code |
|
1356 | self.EXP_CODE = exp_code | |
1152 | self.SUB_EXP_CODE = sub_exp_code |
|
1357 | self.SUB_EXP_CODE = sub_exp_code | |
1153 | self.PLOT_POS = plot_pos |
|
1358 | self.PLOT_POS = plot_pos | |
1154 |
|
1359 | |||
1155 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1360 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1156 | self.isConfig = True |
|
1361 | self.isConfig = True | |
1157 |
|
1362 | |||
1158 |
|
1363 | |||
1159 | self.setWinTitle(title) |
|
1364 | self.setWinTitle(title) | |
1160 |
|
1365 | |||
1161 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
1366 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
1162 | x[1] = self.xmax |
|
1367 | x[1] = self.xmax | |
1163 |
|
1368 | |||
1164 | strWind = ['Zonal','Vertical'] |
|
1369 | strWind = ['Zonal','Vertical'] | |
1165 | strCb = 'Velocity (m/s)' |
|
1370 | strCb = 'Velocity (m/s)' | |
1166 | zmaxVector = [zmaxZonal, zmaxVertical] |
|
1371 | zmaxVector = [zmaxZonal, zmaxVertical] | |
1167 | zminVector = [zminZonal, zminVertical] |
|
1372 | zminVector = [zminZonal, zminVertical] | |
1168 |
|
1373 | |||
1169 | for i in range(nplotsw): |
|
1374 | for i in range(nplotsw): | |
1170 |
|
1375 | |||
1171 | title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1376 | title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1172 | axes = self.axesList[i*self.__nsubplots] |
|
1377 | axes = self.axesList[i*self.__nsubplots] | |
1173 |
|
1378 | |||
1174 | z1 = z[i,:].reshape((1,-1)) |
|
1379 | z1 = z[i,:].reshape((1,-1)) | |
1175 |
|
1380 | |||
1176 | axes.pcolorbuffer(x, y, z1, |
|
1381 | axes.pcolorbuffer(x, y, z1, | |
1177 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], |
|
1382 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i], | |
1178 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1383 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1179 | ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r") |
|
1384 | ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r") | |
1180 |
|
1385 | |||
1181 | if dataOut.data_SNR is not None: |
|
1386 | if dataOut.data_SNR is not None: | |
1182 | i += 1 |
|
1387 | i += 1 | |
1183 | if SNR_1: |
|
1388 | if SNR_1: | |
1184 | title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1389 | title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1185 | else: |
|
1390 | else: | |
1186 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1391 | title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1187 | axes = self.axesList[i*self.__nsubplots] |
|
1392 | axes = self.axesList[i*self.__nsubplots] | |
1188 | SNRavgdB = SNRavgdB.reshape((1,-1)) |
|
1393 | SNRavgdB = SNRavgdB.reshape((1,-1)) | |
1189 |
|
1394 | |||
1190 | axes.pcolorbuffer(x, y, SNRavgdB, |
|
1395 | axes.pcolorbuffer(x, y, SNRavgdB, | |
1191 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, |
|
1396 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax, | |
1192 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1397 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1193 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") |
|
1398 | ticksize=9, cblabel='', cbsize="1%", colormap="jet") | |
1194 |
|
1399 | |||
1195 | self.draw() |
|
1400 | self.draw() | |
1196 |
|
1401 | |||
1197 | if x[1] >= self.axesList[0].xmax: |
|
1402 | if x[1] >= self.axesList[0].xmax: | |
1198 | self.counter_imagwr = wr_period |
|
1403 | self.counter_imagwr = wr_period | |
1199 | self.isConfig = False |
|
1404 | self.isConfig = False | |
1200 | self.figfile = None |
|
1405 | self.figfile = None | |
1201 |
|
1406 | |||
1202 |
|
1407 | |||
1203 |
|
1408 | |||
1204 |
|
1409 | |||
1205 | class PhasePlot(Figure): |
|
1410 | class PhasePlot(Figure): | |
1206 |
|
1411 | |||
1207 | __isConfig = None |
|
1412 | __isConfig = None | |
1208 | __nsubplots = None |
|
1413 | __nsubplots = None | |
1209 |
|
1414 | |||
1210 | PREFIX = 'mphase' |
|
1415 | PREFIX = 'mphase' | |
1211 |
|
1416 | |||
1212 | def __init__(self): |
|
1417 | def __init__(self): | |
1213 |
|
1418 | |||
1214 | self.timerange = 24*60*60 |
|
1419 | self.timerange = 24*60*60 | |
1215 | self.isConfig = False |
|
1420 | self.isConfig = False | |
1216 | self.__nsubplots = 1 |
|
1421 | self.__nsubplots = 1 | |
1217 | self.counter_imagwr = 0 |
|
1422 | self.counter_imagwr = 0 | |
1218 | self.WIDTH = 600 |
|
1423 | self.WIDTH = 600 | |
1219 | self.HEIGHT = 300 |
|
1424 | self.HEIGHT = 300 | |
1220 | self.WIDTHPROF = 120 |
|
1425 | self.WIDTHPROF = 120 | |
1221 | self.HEIGHTPROF = 0 |
|
1426 | self.HEIGHTPROF = 0 | |
1222 | self.xdata = None |
|
1427 | self.xdata = None | |
1223 | self.ydata = None |
|
1428 | self.ydata = None | |
1224 |
|
1429 | |||
1225 | self.PLOT_CODE = MPHASE_CODE |
|
1430 | self.PLOT_CODE = MPHASE_CODE | |
1226 |
|
1431 | |||
1227 | self.FTP_WEI = None |
|
1432 | self.FTP_WEI = None | |
1228 | self.EXP_CODE = None |
|
1433 | self.EXP_CODE = None | |
1229 | self.SUB_EXP_CODE = None |
|
1434 | self.SUB_EXP_CODE = None | |
1230 | self.PLOT_POS = None |
|
1435 | self.PLOT_POS = None | |
1231 |
|
1436 | |||
1232 |
|
1437 | |||
1233 | self.filename_phase = None |
|
1438 | self.filename_phase = None | |
1234 |
|
1439 | |||
1235 | self.figfile = None |
|
1440 | self.figfile = None | |
1236 |
|
1441 | |||
1237 | def getSubplots(self): |
|
1442 | def getSubplots(self): | |
1238 |
|
1443 | |||
1239 | ncol = 1 |
|
1444 | ncol = 1 | |
1240 | nrow = 1 |
|
1445 | nrow = 1 | |
1241 |
|
1446 | |||
1242 | return nrow, ncol |
|
1447 | return nrow, ncol | |
1243 |
|
1448 | |||
1244 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1449 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1245 |
|
1450 | |||
1246 | self.__showprofile = showprofile |
|
1451 | self.__showprofile = showprofile | |
1247 | self.nplots = nplots |
|
1452 | self.nplots = nplots | |
1248 |
|
1453 | |||
1249 | ncolspan = 7 |
|
1454 | ncolspan = 7 | |
1250 | colspan = 6 |
|
1455 | colspan = 6 | |
1251 | self.__nsubplots = 2 |
|
1456 | self.__nsubplots = 2 | |
1252 |
|
1457 | |||
1253 | self.createFigure(id = id, |
|
1458 | self.createFigure(id = id, | |
1254 | wintitle = wintitle, |
|
1459 | wintitle = wintitle, | |
1255 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1460 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1256 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1461 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1257 | show=show) |
|
1462 | show=show) | |
1258 |
|
1463 | |||
1259 | nrow, ncol = self.getSubplots() |
|
1464 | nrow, ncol = self.getSubplots() | |
1260 |
|
1465 | |||
1261 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1466 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1262 |
|
1467 | |||
1263 |
|
1468 | |||
1264 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1469 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
1265 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1470 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1266 | timerange=None, |
|
1471 | timerange=None, | |
1267 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1472 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1268 | server=None, folder=None, username=None, password=None, |
|
1473 | server=None, folder=None, username=None, password=None, | |
1269 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1474 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1270 |
|
1475 | |||
1271 |
|
1476 | |||
1272 | tmin = None |
|
1477 | tmin = None | |
1273 | tmax = None |
|
1478 | tmax = None | |
1274 | x = dataOut.getTimeRange1(dataOut.outputInterval) |
|
1479 | x = dataOut.getTimeRange1(dataOut.outputInterval) | |
1275 | y = dataOut.getHeiRange() |
|
1480 | y = dataOut.getHeiRange() | |
1276 |
|
1481 | |||
1277 |
|
1482 | |||
1278 | #thisDatetime = dataOut.datatime |
|
1483 | #thisDatetime = dataOut.datatime | |
1279 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1484 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
1280 | title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1485 | title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1281 | xlabel = "Local Time" |
|
1486 | xlabel = "Local Time" | |
1282 | ylabel = "Phase" |
|
1487 | ylabel = "Phase" | |
1283 |
|
1488 | |||
1284 |
|
1489 | |||
1285 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) |
|
1490 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) | |
1286 | phase_beacon = dataOut.data_output |
|
1491 | phase_beacon = dataOut.data_output | |
1287 | update_figfile = False |
|
1492 | update_figfile = False | |
1288 |
|
1493 | |||
1289 | if not self.isConfig: |
|
1494 | if not self.isConfig: | |
1290 |
|
1495 | |||
1291 | self.nplots = phase_beacon.size |
|
1496 | self.nplots = phase_beacon.size | |
1292 |
|
1497 | |||
1293 | self.setup(id=id, |
|
1498 | self.setup(id=id, | |
1294 | nplots=self.nplots, |
|
1499 | nplots=self.nplots, | |
1295 | wintitle=wintitle, |
|
1500 | wintitle=wintitle, | |
1296 | showprofile=showprofile, |
|
1501 | showprofile=showprofile, | |
1297 | show=show) |
|
1502 | show=show) | |
1298 |
|
1503 | |||
1299 | if timerange is not None: |
|
1504 | if timerange is not None: | |
1300 | self.timerange = timerange |
|
1505 | self.timerange = timerange | |
1301 |
|
1506 | |||
1302 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1507 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1303 |
|
1508 | |||
1304 | if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0 |
|
1509 | if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0 | |
1305 | if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0 |
|
1510 | if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0 | |
1306 |
|
1511 | |||
1307 | self.FTP_WEI = ftp_wei |
|
1512 | self.FTP_WEI = ftp_wei | |
1308 | self.EXP_CODE = exp_code |
|
1513 | self.EXP_CODE = exp_code | |
1309 | self.SUB_EXP_CODE = sub_exp_code |
|
1514 | self.SUB_EXP_CODE = sub_exp_code | |
1310 | self.PLOT_POS = plot_pos |
|
1515 | self.PLOT_POS = plot_pos | |
1311 |
|
1516 | |||
1312 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1517 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1313 | self.isConfig = True |
|
1518 | self.isConfig = True | |
1314 | self.figfile = figfile |
|
1519 | self.figfile = figfile | |
1315 | self.xdata = numpy.array([]) |
|
1520 | self.xdata = numpy.array([]) | |
1316 | self.ydata = numpy.array([]) |
|
1521 | self.ydata = numpy.array([]) | |
1317 |
|
1522 | |||
1318 | #open file beacon phase |
|
1523 | #open file beacon phase | |
1319 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1524 | path = '%s%03d' %(self.PREFIX, self.id) | |
1320 | beacon_file = os.path.join(path,'%s.txt'%self.name) |
|
1525 | beacon_file = os.path.join(path,'%s.txt'%self.name) | |
1321 | self.filename_phase = os.path.join(figpath,beacon_file) |
|
1526 | self.filename_phase = os.path.join(figpath,beacon_file) | |
1322 | update_figfile = True |
|
1527 | update_figfile = True | |
1323 |
|
1528 | |||
1324 |
|
1529 | |||
1325 | #store data beacon phase |
|
1530 | #store data beacon phase | |
1326 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) |
|
1531 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) | |
1327 |
|
1532 | |||
1328 | self.setWinTitle(title) |
|
1533 | self.setWinTitle(title) | |
1329 |
|
1534 | |||
1330 |
|
1535 | |||
1331 | title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1536 | title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1332 |
|
1537 | |||
1333 | legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)] |
|
1538 | legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)] | |
1334 |
|
1539 | |||
1335 | axes = self.axesList[0] |
|
1540 | axes = self.axesList[0] | |
1336 |
|
1541 | |||
1337 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1542 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1338 |
|
1543 | |||
1339 | if len(self.ydata)==0: |
|
1544 | if len(self.ydata)==0: | |
1340 | self.ydata = phase_beacon.reshape(-1,1) |
|
1545 | self.ydata = phase_beacon.reshape(-1,1) | |
1341 | else: |
|
1546 | else: | |
1342 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) |
|
1547 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) | |
1343 |
|
1548 | |||
1344 |
|
1549 | |||
1345 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1550 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1346 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1551 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, | |
1347 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1552 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1348 | XAxisAsTime=True, grid='both' |
|
1553 | XAxisAsTime=True, grid='both' | |
1349 | ) |
|
1554 | ) | |
1350 |
|
1555 | |||
1351 | self.draw() |
|
1556 | self.draw() | |
1352 |
|
1557 | |||
1353 | if dataOut.ltctime >= self.xmax: |
|
1558 | if dataOut.ltctime >= self.xmax: | |
1354 | self.counter_imagwr = wr_period |
|
1559 | self.counter_imagwr = wr_period | |
1355 | self.isConfig = False |
|
1560 | self.isConfig = False | |
1356 | update_figfile = True |
|
1561 | update_figfile = True | |
1357 |
|
1562 | |||
1358 | self.save(figpath=figpath, |
|
1563 | self.save(figpath=figpath, | |
1359 | figfile=figfile, |
|
1564 | figfile=figfile, | |
1360 | save=save, |
|
1565 | save=save, | |
1361 | ftp=ftp, |
|
1566 | ftp=ftp, | |
1362 | wr_period=wr_period, |
|
1567 | wr_period=wr_period, | |
1363 | thisDatetime=thisDatetime, |
|
1568 | thisDatetime=thisDatetime, | |
1364 | update_figfile=update_figfile) |
|
1569 | update_figfile=update_figfile) |
@@ -1,1522 +1,1527 | |||||
1 | ''' |
|
1 | ''' | |
2 | Created on Jul 9, 2014 |
|
2 | Created on Jul 9, 2014 | |
3 |
|
3 | |||
4 | @author: roj-idl71 |
|
4 | @author: roj-idl71 | |
5 | ''' |
|
5 | ''' | |
6 | import os |
|
6 | import os | |
7 | import datetime |
|
7 | import datetime | |
8 | import numpy |
|
8 | import numpy | |
9 |
|
9 | |||
10 | from figure import Figure, isRealtime, isTimeInHourRange |
|
10 | from figure import Figure, isRealtime, isTimeInHourRange | |
11 | from plotting_codes import * |
|
11 | from plotting_codes import * | |
12 |
|
12 | |||
13 | class SpectraPlot(Figure): |
|
13 | class SpectraPlot(Figure): | |
14 |
|
14 | |||
15 | isConfig = None |
|
15 | isConfig = None | |
16 | __nsubplots = None |
|
16 | __nsubplots = None | |
17 |
|
17 | |||
18 | WIDTHPROF = None |
|
18 | WIDTHPROF = None | |
19 | HEIGHTPROF = None |
|
19 | HEIGHTPROF = None | |
20 | PREFIX = 'spc' |
|
20 | PREFIX = 'spc' | |
21 |
|
21 | |||
22 | def __init__(self): |
|
22 | def __init__(self): | |
23 |
|
23 | |||
24 | self.isConfig = False |
|
24 | self.isConfig = False | |
25 | self.__nsubplots = 1 |
|
25 | self.__nsubplots = 1 | |
26 |
|
26 | |||
27 | self.WIDTH = 250 |
|
27 | self.WIDTH = 250 | |
28 | self.HEIGHT = 250 |
|
28 | self.HEIGHT = 250 | |
29 | self.WIDTHPROF = 120 |
|
29 | self.WIDTHPROF = 120 | |
30 | self.HEIGHTPROF = 0 |
|
30 | self.HEIGHTPROF = 0 | |
31 | self.counter_imagwr = 0 |
|
31 | self.counter_imagwr = 0 | |
32 |
|
32 | |||
33 | self.PLOT_CODE = SPEC_CODE |
|
33 | self.PLOT_CODE = SPEC_CODE | |
34 |
|
34 | |||
35 | self.FTP_WEI = None |
|
35 | self.FTP_WEI = None | |
36 | self.EXP_CODE = None |
|
36 | self.EXP_CODE = None | |
37 | self.SUB_EXP_CODE = None |
|
37 | self.SUB_EXP_CODE = None | |
38 | self.PLOT_POS = None |
|
38 | self.PLOT_POS = None | |
39 |
|
39 | |||
40 | self.__xfilter_ena = False |
|
40 | self.__xfilter_ena = False | |
41 | self.__yfilter_ena = False |
|
41 | self.__yfilter_ena = False | |
42 |
|
42 | |||
43 | def getSubplots(self): |
|
43 | def getSubplots(self): | |
44 |
|
44 | |||
45 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
45 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
46 | nrow = int(self.nplots*1./ncol + 0.9) |
|
46 | nrow = int(self.nplots*1./ncol + 0.9) | |
47 |
|
47 | |||
48 | return nrow, ncol |
|
48 | return nrow, ncol | |
49 |
|
49 | |||
50 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
50 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
51 |
|
51 | |||
52 | self.__showprofile = showprofile |
|
52 | self.__showprofile = showprofile | |
53 | self.nplots = nplots |
|
53 | self.nplots = nplots | |
54 |
|
54 | |||
55 | ncolspan = 1 |
|
55 | ncolspan = 1 | |
56 | colspan = 1 |
|
56 | colspan = 1 | |
57 | if showprofile: |
|
57 | if showprofile: | |
58 | ncolspan = 3 |
|
58 | ncolspan = 3 | |
59 | colspan = 2 |
|
59 | colspan = 2 | |
60 | self.__nsubplots = 2 |
|
60 | self.__nsubplots = 2 | |
61 |
|
61 | |||
62 | self.createFigure(id = id, |
|
62 | self.createFigure(id = id, | |
63 | wintitle = wintitle, |
|
63 | wintitle = wintitle, | |
64 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
64 | widthplot = self.WIDTH + self.WIDTHPROF, | |
65 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
65 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
66 | show=show) |
|
66 | show=show) | |
67 |
|
67 | |||
68 | nrow, ncol = self.getSubplots() |
|
68 | nrow, ncol = self.getSubplots() | |
69 |
|
69 | |||
70 | counter = 0 |
|
70 | counter = 0 | |
71 | for y in range(nrow): |
|
71 | for y in range(nrow): | |
72 | for x in range(ncol): |
|
72 | for x in range(ncol): | |
73 |
|
73 | |||
74 | if counter >= self.nplots: |
|
74 | if counter >= self.nplots: | |
75 | break |
|
75 | break | |
76 |
|
76 | |||
77 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
77 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
78 |
|
78 | |||
79 | if showprofile: |
|
79 | if showprofile: | |
80 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
80 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
81 |
|
81 | |||
82 | counter += 1 |
|
82 | counter += 1 | |
83 |
|
83 | |||
84 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
84 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
85 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
85 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
86 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
86 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
87 | server=None, folder=None, username=None, password=None, |
|
87 | server=None, folder=None, username=None, password=None, | |
88 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False, |
|
88 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False, | |
89 | xaxis="frequency"): |
|
89 | xaxis="frequency"): | |
90 |
|
90 | |||
91 | """ |
|
91 | """ | |
92 |
|
92 | |||
93 | Input: |
|
93 | Input: | |
94 | dataOut : |
|
94 | dataOut : | |
95 | id : |
|
95 | id : | |
96 | wintitle : |
|
96 | wintitle : | |
97 | channelList : |
|
97 | channelList : | |
98 | showProfile : |
|
98 | showProfile : | |
99 | xmin : None, |
|
99 | xmin : None, | |
100 | xmax : None, |
|
100 | xmax : None, | |
101 | ymin : None, |
|
101 | ymin : None, | |
102 | ymax : None, |
|
102 | ymax : None, | |
103 | zmin : None, |
|
103 | zmin : None, | |
104 | zmax : None |
|
104 | zmax : None | |
105 | """ |
|
105 | """ | |
106 |
|
106 | |||
107 | if realtime: |
|
107 | if realtime: | |
108 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
108 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
109 | print 'Skipping this plot function' |
|
109 | print 'Skipping this plot function' | |
110 | return |
|
110 | return | |
111 |
|
111 | |||
112 | if channelList == None: |
|
112 | if channelList == None: | |
113 | channelIndexList = dataOut.channelIndexList |
|
113 | channelIndexList = dataOut.channelIndexList | |
114 | else: |
|
114 | else: | |
115 | channelIndexList = [] |
|
115 | channelIndexList = [] | |
116 | for channel in channelList: |
|
116 | for channel in channelList: | |
117 | if channel not in dataOut.channelList: |
|
117 | if channel not in dataOut.channelList: | |
118 | raise ValueError, "Channel %d is not in dataOut.channelList" %channel |
|
118 | raise ValueError, "Channel %d is not in dataOut.channelList" %channel | |
119 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
119 | channelIndexList.append(dataOut.channelList.index(channel)) | |
120 |
|
120 | |||
121 | factor = dataOut.normFactor |
|
121 | factor = dataOut.normFactor | |
122 |
|
122 | |||
123 | if xaxis == "frequency": |
|
123 | if xaxis == "frequency": | |
124 | x = dataOut.getFreqRange(1)/1000. |
|
124 | x = dataOut.getFreqRange(1)/1000. | |
125 | xlabel = "Frequency (kHz)" |
|
125 | xlabel = "Frequency (kHz)" | |
126 |
|
126 | |||
127 | elif xaxis == "time": |
|
127 | elif xaxis == "time": | |
128 | x = dataOut.getAcfRange(1) |
|
128 | x = dataOut.getAcfRange(1) | |
129 | xlabel = "Time (ms)" |
|
129 | xlabel = "Time (ms)" | |
130 |
|
130 | |||
131 | else: |
|
131 | else: | |
132 | x = dataOut.getVelRange(1) |
|
132 | x = dataOut.getVelRange(1) | |
133 | xlabel = "Velocity (m/s)" |
|
133 | xlabel = "Velocity (m/s)" | |
134 |
|
134 | |||
135 | ylabel = "Range (Km)" |
|
135 | ylabel = "Range (Km)" | |
136 |
|
136 | |||
137 | y = dataOut.getHeiRange() |
|
137 | y = dataOut.getHeiRange() | |
138 |
|
138 | |||
139 | z = dataOut.data_spc/factor |
|
139 | z = dataOut.data_spc/factor | |
140 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
140 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
141 | zdB = 10*numpy.log10(z) |
|
141 | zdB = 10*numpy.log10(z) | |
142 |
|
142 | |||
143 | avg = numpy.average(z, axis=1) |
|
143 | avg = numpy.average(z, axis=1) | |
144 | avgdB = 10*numpy.log10(avg) |
|
144 | avgdB = 10*numpy.log10(avg) | |
145 |
|
145 | |||
146 | noise = dataOut.getNoise()/factor |
|
146 | noise = dataOut.getNoise()/factor | |
147 | noisedB = 10*numpy.log10(noise) |
|
147 | noisedB = 10*numpy.log10(noise) | |
148 |
|
148 | |||
149 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
149 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
150 | title = wintitle + " Spectra" |
|
150 | title = wintitle + " Spectra" | |
151 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
151 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
152 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
152 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
153 |
|
153 | |||
154 | if not self.isConfig: |
|
154 | if not self.isConfig: | |
155 |
|
155 | |||
156 | nplots = len(channelIndexList) |
|
156 | nplots = len(channelIndexList) | |
157 |
|
157 | |||
158 | self.setup(id=id, |
|
158 | self.setup(id=id, | |
159 | nplots=nplots, |
|
159 | nplots=nplots, | |
160 | wintitle=wintitle, |
|
160 | wintitle=wintitle, | |
161 | showprofile=showprofile, |
|
161 | showprofile=showprofile, | |
162 | show=show) |
|
162 | show=show) | |
163 |
|
163 | |||
164 | if xmin == None: xmin = numpy.nanmin(x) |
|
164 | if xmin == None: xmin = numpy.nanmin(x) | |
165 | if xmax == None: xmax = numpy.nanmax(x) |
|
165 | if xmax == None: xmax = numpy.nanmax(x) | |
166 | if ymin == None: ymin = numpy.nanmin(y) |
|
166 | if ymin == None: ymin = numpy.nanmin(y) | |
167 | if ymax == None: ymax = numpy.nanmax(y) |
|
167 | if ymax == None: ymax = numpy.nanmax(y) | |
168 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 |
|
168 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 | |
169 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 |
|
169 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 | |
170 |
|
170 | |||
171 | self.FTP_WEI = ftp_wei |
|
171 | self.FTP_WEI = ftp_wei | |
172 | self.EXP_CODE = exp_code |
|
172 | self.EXP_CODE = exp_code | |
173 | self.SUB_EXP_CODE = sub_exp_code |
|
173 | self.SUB_EXP_CODE = sub_exp_code | |
174 | self.PLOT_POS = plot_pos |
|
174 | self.PLOT_POS = plot_pos | |
175 |
|
175 | |||
176 | self.isConfig = True |
|
176 | self.isConfig = True | |
177 |
|
177 | |||
178 | self.setWinTitle(title) |
|
178 | self.setWinTitle(title) | |
179 |
|
179 | |||
180 | for i in range(self.nplots): |
|
180 | for i in range(self.nplots): | |
181 | index = channelIndexList[i] |
|
181 | index = channelIndexList[i] | |
182 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
182 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
183 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime) |
|
183 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime) | |
184 | if len(dataOut.beam.codeList) != 0: |
|
184 | if len(dataOut.beam.codeList) != 0: | |
185 | 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) |
|
185 | 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) | |
186 |
|
186 | |||
187 | axes = self.axesList[i*self.__nsubplots] |
|
187 | axes = self.axesList[i*self.__nsubplots] | |
188 | axes.pcolor(x, y, zdB[index,:,:], |
|
188 | axes.pcolor(x, y, zdB[index,:,:], | |
189 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
189 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
190 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
190 | xlabel=xlabel, ylabel=ylabel, title=title, | |
191 | ticksize=9, cblabel='') |
|
191 | ticksize=9, cblabel='') | |
192 |
|
192 | |||
193 | if self.__showprofile: |
|
193 | if self.__showprofile: | |
194 | axes = self.axesList[i*self.__nsubplots +1] |
|
194 | axes = self.axesList[i*self.__nsubplots +1] | |
195 | axes.pline(avgdB[index,:], y, |
|
195 | axes.pline(avgdB[index,:], y, | |
196 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
196 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
197 | xlabel='dB', ylabel='', title='', |
|
197 | xlabel='dB', ylabel='', title='', | |
198 | ytick_visible=False, |
|
198 | ytick_visible=False, | |
199 | grid='x') |
|
199 | grid='x') | |
200 |
|
200 | |||
201 | noiseline = numpy.repeat(noisedB[index], len(y)) |
|
201 | noiseline = numpy.repeat(noisedB[index], len(y)) | |
202 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
202 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
203 |
|
203 | |||
204 | self.draw() |
|
204 | self.draw() | |
205 |
|
205 | |||
206 | if figfile == None: |
|
206 | if figfile == None: | |
207 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
207 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
208 | name = str_datetime |
|
208 | name = str_datetime | |
209 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
209 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
210 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) |
|
210 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | |
211 | figfile = self.getFilename(name) |
|
211 | figfile = self.getFilename(name) | |
212 |
|
212 | |||
213 | self.save(figpath=figpath, |
|
213 | self.save(figpath=figpath, | |
214 | figfile=figfile, |
|
214 | figfile=figfile, | |
215 | save=save, |
|
215 | save=save, | |
216 | ftp=ftp, |
|
216 | ftp=ftp, | |
217 | wr_period=wr_period, |
|
217 | wr_period=wr_period, | |
218 | thisDatetime=thisDatetime) |
|
218 | thisDatetime=thisDatetime) | |
219 |
|
219 | |||
220 | class CrossSpectraPlot(Figure): |
|
220 | class CrossSpectraPlot(Figure): | |
221 |
|
221 | |||
222 | isConfig = None |
|
222 | isConfig = None | |
223 | __nsubplots = None |
|
223 | __nsubplots = None | |
224 |
|
224 | |||
225 | WIDTH = None |
|
225 | WIDTH = None | |
226 | HEIGHT = None |
|
226 | HEIGHT = None | |
227 | WIDTHPROF = None |
|
227 | WIDTHPROF = None | |
228 | HEIGHTPROF = None |
|
228 | HEIGHTPROF = None | |
229 | PREFIX = 'cspc' |
|
229 | PREFIX = 'cspc' | |
230 |
|
230 | |||
231 | def __init__(self): |
|
231 | def __init__(self): | |
232 |
|
232 | |||
233 | self.isConfig = False |
|
233 | self.isConfig = False | |
234 | self.__nsubplots = 4 |
|
234 | self.__nsubplots = 4 | |
235 | self.counter_imagwr = 0 |
|
235 | self.counter_imagwr = 0 | |
236 | self.WIDTH = 250 |
|
236 | self.WIDTH = 250 | |
237 | self.HEIGHT = 250 |
|
237 | self.HEIGHT = 250 | |
238 | self.WIDTHPROF = 0 |
|
238 | self.WIDTHPROF = 0 | |
239 | self.HEIGHTPROF = 0 |
|
239 | self.HEIGHTPROF = 0 | |
240 |
|
240 | |||
241 | self.PLOT_CODE = CROSS_CODE |
|
241 | self.PLOT_CODE = CROSS_CODE | |
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 = 4 |
|
249 | ncol = 4 | |
250 | nrow = self.nplots |
|
250 | nrow = self.nplots | |
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 |
|
261 | |||
262 | self.createFigure(id = id, |
|
262 | self.createFigure(id = id, | |
263 | wintitle = wintitle, |
|
263 | wintitle = wintitle, | |
264 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
264 | widthplot = self.WIDTH + self.WIDTHPROF, | |
265 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
265 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
266 | show=True) |
|
266 | show=True) | |
267 |
|
267 | |||
268 | nrow, ncol = self.getSubplots() |
|
268 | nrow, ncol = self.getSubplots() | |
269 |
|
269 | |||
270 | counter = 0 |
|
270 | counter = 0 | |
271 | for y in range(nrow): |
|
271 | for y in range(nrow): | |
272 | for x in range(ncol): |
|
272 | for x in range(ncol): | |
273 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
273 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
274 |
|
274 | |||
275 | counter += 1 |
|
275 | counter += 1 | |
276 |
|
276 | |||
277 | def run(self, dataOut, id, wintitle="", pairsList=None, |
|
277 | def run(self, dataOut, id, wintitle="", pairsList=None, | |
278 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
278 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
279 | coh_min=None, coh_max=None, phase_min=None, phase_max=None, |
|
279 | coh_min=None, coh_max=None, phase_min=None, phase_max=None, | |
280 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, |
|
280 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, | |
281 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True, |
|
281 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True, | |
282 | server=None, folder=None, username=None, password=None, |
|
282 | server=None, folder=None, username=None, password=None, | |
283 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, |
|
283 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, | |
284 | xaxis='frequency'): |
|
284 | xaxis='frequency'): | |
285 |
|
285 | |||
286 | """ |
|
286 | """ | |
287 |
|
287 | |||
288 | Input: |
|
288 | Input: | |
289 | dataOut : |
|
289 | dataOut : | |
290 | id : |
|
290 | id : | |
291 | wintitle : |
|
291 | wintitle : | |
292 | channelList : |
|
292 | channelList : | |
293 | showProfile : |
|
293 | showProfile : | |
294 | xmin : None, |
|
294 | xmin : None, | |
295 | xmax : None, |
|
295 | xmax : None, | |
296 | ymin : None, |
|
296 | ymin : None, | |
297 | ymax : None, |
|
297 | ymax : None, | |
298 | zmin : None, |
|
298 | zmin : None, | |
299 | zmax : None |
|
299 | zmax : None | |
300 | """ |
|
300 | """ | |
301 |
|
301 | |||
302 | if pairsList == None: |
|
302 | if pairsList == None: | |
303 | pairsIndexList = dataOut.pairsIndexList |
|
303 | pairsIndexList = dataOut.pairsIndexList | |
304 | else: |
|
304 | else: | |
305 | pairsIndexList = [] |
|
305 | pairsIndexList = [] | |
306 | for pair in pairsList: |
|
306 | for pair in pairsList: | |
307 | if pair not in dataOut.pairsList: |
|
307 | if pair not in dataOut.pairsList: | |
308 | raise ValueError, "Pair %s is not in dataOut.pairsList" %str(pair) |
|
308 | raise ValueError, "Pair %s is not in dataOut.pairsList" %str(pair) | |
309 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
309 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
310 |
|
310 | |||
311 | if not pairsIndexList: |
|
311 | if not pairsIndexList: | |
312 | return |
|
312 | return | |
313 |
|
313 | |||
314 | if len(pairsIndexList) > 4: |
|
314 | if len(pairsIndexList) > 4: | |
315 | pairsIndexList = pairsIndexList[0:4] |
|
315 | pairsIndexList = pairsIndexList[0:4] | |
316 |
|
316 | |||
317 | factor = dataOut.normFactor |
|
317 | factor = dataOut.normFactor | |
318 | x = dataOut.getVelRange(1) |
|
318 | x = dataOut.getVelRange(1) | |
319 | y = dataOut.getHeiRange() |
|
319 | y = dataOut.getHeiRange() | |
320 | z = dataOut.data_spc[:,:,:]/factor |
|
320 | z = dataOut.data_spc[:,:,:]/factor | |
321 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
321 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
322 |
|
322 | |||
323 | noise = dataOut.noise/factor |
|
323 | noise = dataOut.noise/factor | |
324 |
|
324 | |||
325 | zdB = 10*numpy.log10(z) |
|
325 | zdB = 10*numpy.log10(z) | |
326 | noisedB = 10*numpy.log10(noise) |
|
326 | noisedB = 10*numpy.log10(noise) | |
327 |
|
327 | |||
328 | if coh_min == None: |
|
328 | if coh_min == None: | |
329 | coh_min = 0.0 |
|
329 | coh_min = 0.0 | |
330 | if coh_max == None: |
|
330 | if coh_max == None: | |
331 | coh_max = 1.0 |
|
331 | coh_max = 1.0 | |
332 |
|
332 | |||
333 | if phase_min == None: |
|
333 | if phase_min == None: | |
334 | phase_min = -180 |
|
334 | phase_min = -180 | |
335 | if phase_max == None: |
|
335 | if phase_max == None: | |
336 | phase_max = 180 |
|
336 | phase_max = 180 | |
337 |
|
337 | |||
338 | #thisDatetime = dataOut.datatime |
|
338 | #thisDatetime = dataOut.datatime | |
339 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
339 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
340 | title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
340 | title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
341 | # xlabel = "Velocity (m/s)" |
|
341 | # xlabel = "Velocity (m/s)" | |
342 | ylabel = "Range (Km)" |
|
342 | ylabel = "Range (Km)" | |
343 |
|
343 | |||
344 | if xaxis == "frequency": |
|
344 | if xaxis == "frequency": | |
345 | x = dataOut.getFreqRange(1)/1000. |
|
345 | x = dataOut.getFreqRange(1)/1000. | |
346 | xlabel = "Frequency (kHz)" |
|
346 | xlabel = "Frequency (kHz)" | |
347 |
|
347 | |||
348 | elif xaxis == "time": |
|
348 | elif xaxis == "time": | |
349 | x = dataOut.getAcfRange(1) |
|
349 | x = dataOut.getAcfRange(1) | |
350 | xlabel = "Time (ms)" |
|
350 | xlabel = "Time (ms)" | |
351 |
|
351 | |||
352 | else: |
|
352 | else: | |
353 | x = dataOut.getVelRange(1) |
|
353 | x = dataOut.getVelRange(1) | |
354 | xlabel = "Velocity (m/s)" |
|
354 | xlabel = "Velocity (m/s)" | |
355 |
|
355 | |||
356 | if not self.isConfig: |
|
356 | if not self.isConfig: | |
357 |
|
357 | |||
358 | nplots = len(pairsIndexList) |
|
358 | nplots = len(pairsIndexList) | |
359 |
|
359 | |||
360 | self.setup(id=id, |
|
360 | self.setup(id=id, | |
361 | nplots=nplots, |
|
361 | nplots=nplots, | |
362 | wintitle=wintitle, |
|
362 | wintitle=wintitle, | |
363 | showprofile=False, |
|
363 | showprofile=False, | |
364 | show=show) |
|
364 | show=show) | |
365 |
|
365 | |||
366 | avg = numpy.abs(numpy.average(z, axis=1)) |
|
366 | avg = numpy.abs(numpy.average(z, axis=1)) | |
367 | avgdB = 10*numpy.log10(avg) |
|
367 | avgdB = 10*numpy.log10(avg) | |
368 |
|
368 | |||
369 | if xmin == None: xmin = numpy.nanmin(x) |
|
369 | if xmin == None: xmin = numpy.nanmin(x) | |
370 | if xmax == None: xmax = numpy.nanmax(x) |
|
370 | if xmax == None: xmax = numpy.nanmax(x) | |
371 | if ymin == None: ymin = numpy.nanmin(y) |
|
371 | if ymin == None: ymin = numpy.nanmin(y) | |
372 | if ymax == None: ymax = numpy.nanmax(y) |
|
372 | if ymax == None: ymax = numpy.nanmax(y) | |
373 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 |
|
373 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 | |
374 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 |
|
374 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 | |
375 |
|
375 | |||
376 | self.FTP_WEI = ftp_wei |
|
376 | self.FTP_WEI = ftp_wei | |
377 | self.EXP_CODE = exp_code |
|
377 | self.EXP_CODE = exp_code | |
378 | self.SUB_EXP_CODE = sub_exp_code |
|
378 | self.SUB_EXP_CODE = sub_exp_code | |
379 | self.PLOT_POS = plot_pos |
|
379 | self.PLOT_POS = plot_pos | |
380 |
|
380 | |||
381 | self.isConfig = True |
|
381 | self.isConfig = True | |
382 |
|
382 | |||
383 | self.setWinTitle(title) |
|
383 | self.setWinTitle(title) | |
384 |
|
384 | |||
385 | for i in range(self.nplots): |
|
385 | for i in range(self.nplots): | |
386 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
386 | pair = dataOut.pairsList[pairsIndexList[i]] | |
387 |
|
387 | |||
388 | chan_index0 = dataOut.channelList.index(pair[0]) |
|
388 | chan_index0 = dataOut.channelList.index(pair[0]) | |
389 | chan_index1 = dataOut.channelList.index(pair[1]) |
|
389 | chan_index1 = dataOut.channelList.index(pair[1]) | |
390 |
|
390 | |||
391 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
391 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
392 | title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[chan_index0], str_datetime) |
|
392 | title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[chan_index0], str_datetime) | |
393 | zdB = 10.*numpy.log10(dataOut.data_spc[chan_index0,:,:]/factor) |
|
393 | zdB = 10.*numpy.log10(dataOut.data_spc[chan_index0,:,:]/factor) | |
394 | axes0 = self.axesList[i*self.__nsubplots] |
|
394 | axes0 = self.axesList[i*self.__nsubplots] | |
395 | axes0.pcolor(x, y, zdB, |
|
395 | axes0.pcolor(x, y, zdB, | |
396 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
396 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
397 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
397 | xlabel=xlabel, ylabel=ylabel, title=title, | |
398 | ticksize=9, colormap=power_cmap, cblabel='') |
|
398 | ticksize=9, colormap=power_cmap, cblabel='') | |
399 |
|
399 | |||
400 | title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[chan_index1], str_datetime) |
|
400 | title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[chan_index1], str_datetime) | |
401 | zdB = 10.*numpy.log10(dataOut.data_spc[chan_index1,:,:]/factor) |
|
401 | zdB = 10.*numpy.log10(dataOut.data_spc[chan_index1,:,:]/factor) | |
402 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
402 | axes0 = self.axesList[i*self.__nsubplots+1] | |
403 | axes0.pcolor(x, y, zdB, |
|
403 | axes0.pcolor(x, y, zdB, | |
404 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
404 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
405 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
405 | xlabel=xlabel, ylabel=ylabel, title=title, | |
406 | ticksize=9, colormap=power_cmap, cblabel='') |
|
406 | ticksize=9, colormap=power_cmap, cblabel='') | |
407 |
|
407 | |||
408 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[chan_index0,:,:]*dataOut.data_spc[chan_index1,:,:]) |
|
408 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[chan_index0,:,:]*dataOut.data_spc[chan_index1,:,:]) | |
409 | coherence = numpy.abs(coherenceComplex) |
|
409 | coherence = numpy.abs(coherenceComplex) | |
410 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
410 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
411 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi |
|
411 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi | |
412 |
|
412 | |||
413 | title = "Coherence Ch%d * Ch%d" %(pair[0], pair[1]) |
|
413 | title = "Coherence Ch%d * Ch%d" %(pair[0], pair[1]) | |
414 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
414 | axes0 = self.axesList[i*self.__nsubplots+2] | |
415 | axes0.pcolor(x, y, coherence, |
|
415 | axes0.pcolor(x, y, coherence, | |
416 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=coh_min, zmax=coh_max, |
|
416 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=coh_min, zmax=coh_max, | |
417 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
417 | xlabel=xlabel, ylabel=ylabel, title=title, | |
418 | ticksize=9, colormap=coherence_cmap, cblabel='') |
|
418 | ticksize=9, colormap=coherence_cmap, cblabel='') | |
419 |
|
419 | |||
420 | title = "Phase Ch%d * Ch%d" %(pair[0], pair[1]) |
|
420 | title = "Phase Ch%d * Ch%d" %(pair[0], pair[1]) | |
421 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
421 | axes0 = self.axesList[i*self.__nsubplots+3] | |
422 | axes0.pcolor(x, y, phase, |
|
422 | axes0.pcolor(x, y, phase, | |
423 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max, |
|
423 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max, | |
424 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
424 | xlabel=xlabel, ylabel=ylabel, title=title, | |
425 | ticksize=9, colormap=phase_cmap, cblabel='') |
|
425 | ticksize=9, colormap=phase_cmap, cblabel='') | |
426 |
|
426 | |||
427 |
|
427 | |||
428 |
|
428 | |||
429 | self.draw() |
|
429 | self.draw() | |
430 |
|
430 | |||
431 | self.save(figpath=figpath, |
|
431 | self.save(figpath=figpath, | |
432 | figfile=figfile, |
|
432 | figfile=figfile, | |
433 | save=save, |
|
433 | save=save, | |
434 | ftp=ftp, |
|
434 | ftp=ftp, | |
435 | wr_period=wr_period, |
|
435 | wr_period=wr_period, | |
436 | thisDatetime=thisDatetime) |
|
436 | thisDatetime=thisDatetime) | |
437 |
|
437 | |||
438 |
|
438 | |||
439 | class RTIPlot(Figure): |
|
439 | class RTIPlot(Figure): | |
440 |
|
440 | |||
441 | __isConfig = None |
|
441 | __isConfig = None | |
442 | __nsubplots = None |
|
442 | __nsubplots = None | |
443 |
|
443 | |||
444 | WIDTHPROF = None |
|
444 | WIDTHPROF = None | |
445 | HEIGHTPROF = None |
|
445 | HEIGHTPROF = None | |
446 | PREFIX = 'rti' |
|
446 | PREFIX = 'rti' | |
447 |
|
447 | |||
448 | def __init__(self): |
|
448 | def __init__(self): | |
449 |
|
449 | |||
450 | self.timerange = None |
|
450 | self.timerange = None | |
451 | self.isConfig = False |
|
451 | self.isConfig = False | |
452 | self.__nsubplots = 1 |
|
452 | self.__nsubplots = 1 | |
453 |
|
453 | |||
454 | self.WIDTH = 800 |
|
454 | self.WIDTH = 800 | |
455 | self.HEIGHT = 180 |
|
455 | self.HEIGHT = 180 | |
456 | self.WIDTHPROF = 120 |
|
456 | self.WIDTHPROF = 120 | |
457 | self.HEIGHTPROF = 0 |
|
457 | self.HEIGHTPROF = 0 | |
458 | self.counter_imagwr = 0 |
|
458 | self.counter_imagwr = 0 | |
459 |
|
459 | |||
460 | self.PLOT_CODE = RTI_CODE |
|
460 | self.PLOT_CODE = RTI_CODE | |
461 |
|
461 | |||
462 | self.FTP_WEI = None |
|
462 | self.FTP_WEI = None | |
463 | self.EXP_CODE = None |
|
463 | self.EXP_CODE = None | |
464 | self.SUB_EXP_CODE = None |
|
464 | self.SUB_EXP_CODE = None | |
465 | self.PLOT_POS = None |
|
465 | self.PLOT_POS = None | |
466 | self.tmin = None |
|
466 | self.tmin = None | |
467 | self.tmax = None |
|
467 | self.tmax = None | |
468 |
|
468 | |||
469 | self.xmin = None |
|
469 | self.xmin = None | |
470 | self.xmax = None |
|
470 | self.xmax = None | |
471 |
|
471 | |||
472 | self.figfile = None |
|
472 | self.figfile = None | |
473 |
|
473 | |||
474 | def getSubplots(self): |
|
474 | def getSubplots(self): | |
475 |
|
475 | |||
476 | ncol = 1 |
|
476 | ncol = 1 | |
477 | nrow = self.nplots |
|
477 | nrow = self.nplots | |
478 |
|
478 | |||
479 | return nrow, ncol |
|
479 | return nrow, ncol | |
480 |
|
480 | |||
481 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
481 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
482 |
|
482 | |||
483 | self.__showprofile = showprofile |
|
483 | self.__showprofile = showprofile | |
484 | self.nplots = nplots |
|
484 | self.nplots = nplots | |
485 |
|
485 | |||
486 | ncolspan = 1 |
|
486 | ncolspan = 1 | |
487 | colspan = 1 |
|
487 | colspan = 1 | |
488 | if showprofile: |
|
488 | if showprofile: | |
489 | ncolspan = 7 |
|
489 | ncolspan = 7 | |
490 | colspan = 6 |
|
490 | colspan = 6 | |
491 | self.__nsubplots = 2 |
|
491 | self.__nsubplots = 2 | |
492 |
|
492 | |||
493 | self.createFigure(id = id, |
|
493 | self.createFigure(id = id, | |
494 | wintitle = wintitle, |
|
494 | wintitle = wintitle, | |
495 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
495 | widthplot = self.WIDTH + self.WIDTHPROF, | |
496 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
496 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
497 | show=show) |
|
497 | show=show) | |
498 |
|
498 | |||
499 | nrow, ncol = self.getSubplots() |
|
499 | nrow, ncol = self.getSubplots() | |
500 |
|
500 | |||
501 | counter = 0 |
|
501 | counter = 0 | |
502 | for y in range(nrow): |
|
502 | for y in range(nrow): | |
503 | for x in range(ncol): |
|
503 | for x in range(ncol): | |
504 |
|
504 | |||
505 | if counter >= self.nplots: |
|
505 | if counter >= self.nplots: | |
506 | break |
|
506 | break | |
507 |
|
507 | |||
508 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
508 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
509 |
|
509 | |||
510 | if showprofile: |
|
510 | if showprofile: | |
511 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
511 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
512 |
|
512 | |||
513 | counter += 1 |
|
513 | counter += 1 | |
514 |
|
514 | |||
515 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', |
|
515 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
516 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
516 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
517 | timerange=None, |
|
517 | timerange=None, | |
518 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
518 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
519 | server=None, folder=None, username=None, password=None, |
|
519 | server=None, folder=None, username=None, password=None, | |
520 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
520 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
521 |
|
521 | |||
522 | """ |
|
522 | """ | |
523 |
|
523 | |||
524 | Input: |
|
524 | Input: | |
525 | dataOut : |
|
525 | dataOut : | |
526 | id : |
|
526 | id : | |
527 | wintitle : |
|
527 | wintitle : | |
528 | channelList : |
|
528 | channelList : | |
529 | showProfile : |
|
529 | showProfile : | |
530 | xmin : None, |
|
530 | xmin : None, | |
531 | xmax : None, |
|
531 | xmax : None, | |
532 | ymin : None, |
|
532 | ymin : None, | |
533 | ymax : None, |
|
533 | ymax : None, | |
534 | zmin : None, |
|
534 | zmin : None, | |
535 | zmax : None |
|
535 | zmax : None | |
536 | """ |
|
536 | """ | |
537 |
|
537 | |||
538 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
538 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
539 | return |
|
539 | return | |
540 |
|
540 | |||
541 | if channelList == None: |
|
541 | if channelList == None: | |
542 | channelIndexList = dataOut.channelIndexList |
|
542 | channelIndexList = dataOut.channelIndexList | |
543 | else: |
|
543 | else: | |
544 | channelIndexList = [] |
|
544 | channelIndexList = [] | |
545 | for channel in channelList: |
|
545 | for channel in channelList: | |
546 | if channel not in dataOut.channelList: |
|
546 | if channel not in dataOut.channelList: | |
547 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
547 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
548 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
548 | channelIndexList.append(dataOut.channelList.index(channel)) | |
549 |
|
549 | |||
550 |
f |
|
550 | if hasattr(dataOut, 'normFactor'): | |
|
551 | factor = dataOut.normFactor | |||
|
552 | else: | |||
|
553 | factor = 1 | |||
|
554 | ||||
|
555 | # factor = dataOut.normFactor | |||
551 | x = dataOut.getTimeRange() |
|
556 | x = dataOut.getTimeRange() | |
552 | y = dataOut.getHeiRange() |
|
557 | y = dataOut.getHeiRange() | |
553 |
|
558 | |||
554 | z = dataOut.data_spc/factor |
|
559 | # z = dataOut.data_spc/factor | |
555 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
560 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
556 | avg = numpy.average(z, axis=1) |
|
561 | # avg = numpy.average(z, axis=1) | |
557 |
|
562 | # avgdB = 10.*numpy.log10(avg) | ||
558 | avgdB = 10.*numpy.log10(avg) |
|
563 | avgdB = dataOut.getPower() | |
559 |
|
564 | |||
560 | thisDatetime = dataOut.datatime |
|
565 | thisDatetime = dataOut.datatime | |
561 | # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
566 | # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
562 | title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
567 | title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
563 | xlabel = "" |
|
568 | xlabel = "" | |
564 | ylabel = "Range (Km)" |
|
569 | ylabel = "Range (Km)" | |
565 |
|
570 | |||
566 | update_figfile = False |
|
571 | update_figfile = False | |
567 |
|
572 | |||
568 | if dataOut.ltctime >= self.xmax: |
|
573 | if dataOut.ltctime >= self.xmax: | |
569 | self.counter_imagwr = wr_period |
|
574 | self.counter_imagwr = wr_period | |
570 | self.isConfig = False |
|
575 | self.isConfig = False | |
571 | update_figfile = True |
|
576 | update_figfile = True | |
572 |
|
577 | |||
573 | if not self.isConfig: |
|
578 | if not self.isConfig: | |
574 |
|
579 | |||
575 | nplots = len(channelIndexList) |
|
580 | nplots = len(channelIndexList) | |
576 |
|
581 | |||
577 | self.setup(id=id, |
|
582 | self.setup(id=id, | |
578 | nplots=nplots, |
|
583 | nplots=nplots, | |
579 | wintitle=wintitle, |
|
584 | wintitle=wintitle, | |
580 | showprofile=showprofile, |
|
585 | showprofile=showprofile, | |
581 | show=show) |
|
586 | show=show) | |
582 |
|
587 | |||
583 | if timerange != None: |
|
588 | if timerange != None: | |
584 | self.timerange = timerange |
|
589 | self.timerange = timerange | |
585 |
|
590 | |||
586 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
591 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
587 |
|
592 | |||
588 | noise = dataOut.noise/factor |
|
593 | noise = dataOut.noise/factor | |
589 | noisedB = 10*numpy.log10(noise) |
|
594 | noisedB = 10*numpy.log10(noise) | |
590 |
|
595 | |||
591 | if ymin == None: ymin = numpy.nanmin(y) |
|
596 | if ymin == None: ymin = numpy.nanmin(y) | |
592 | if ymax == None: ymax = numpy.nanmax(y) |
|
597 | if ymax == None: ymax = numpy.nanmax(y) | |
593 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 |
|
598 | if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3 | |
594 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 |
|
599 | if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3 | |
595 |
|
600 | |||
596 | self.FTP_WEI = ftp_wei |
|
601 | self.FTP_WEI = ftp_wei | |
597 | self.EXP_CODE = exp_code |
|
602 | self.EXP_CODE = exp_code | |
598 | self.SUB_EXP_CODE = sub_exp_code |
|
603 | self.SUB_EXP_CODE = sub_exp_code | |
599 | self.PLOT_POS = plot_pos |
|
604 | self.PLOT_POS = plot_pos | |
600 |
|
605 | |||
601 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
606 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
602 | self.isConfig = True |
|
607 | self.isConfig = True | |
603 | self.figfile = figfile |
|
608 | self.figfile = figfile | |
604 | update_figfile = True |
|
609 | update_figfile = True | |
605 |
|
610 | |||
606 | self.setWinTitle(title) |
|
611 | self.setWinTitle(title) | |
607 |
|
612 | |||
608 | for i in range(self.nplots): |
|
613 | for i in range(self.nplots): | |
609 | index = channelIndexList[i] |
|
614 | index = channelIndexList[i] | |
610 | title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
615 | title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
611 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): |
|
616 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
612 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) |
|
617 | title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith) | |
613 | axes = self.axesList[i*self.__nsubplots] |
|
618 | axes = self.axesList[i*self.__nsubplots] | |
614 | zdB = avgdB[index].reshape((1,-1)) |
|
619 | zdB = avgdB[index].reshape((1,-1)) | |
615 | axes.pcolorbuffer(x, y, zdB, |
|
620 | axes.pcolorbuffer(x, y, zdB, | |
616 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
621 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
617 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
622 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
618 | ticksize=9, cblabel='', cbsize="1%") |
|
623 | ticksize=9, cblabel='', cbsize="1%") | |
619 |
|
624 | |||
620 | if self.__showprofile: |
|
625 | if self.__showprofile: | |
621 | axes = self.axesList[i*self.__nsubplots +1] |
|
626 | axes = self.axesList[i*self.__nsubplots +1] | |
622 | axes.pline(avgdB[index], y, |
|
627 | axes.pline(avgdB[index], y, | |
623 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
628 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
624 | xlabel='dB', ylabel='', title='', |
|
629 | xlabel='dB', ylabel='', title='', | |
625 | ytick_visible=False, |
|
630 | ytick_visible=False, | |
626 | grid='x') |
|
631 | grid='x') | |
627 |
|
632 | |||
628 | self.draw() |
|
633 | self.draw() | |
629 |
|
634 | |||
630 | self.save(figpath=figpath, |
|
635 | self.save(figpath=figpath, | |
631 | figfile=figfile, |
|
636 | figfile=figfile, | |
632 | save=save, |
|
637 | save=save, | |
633 | ftp=ftp, |
|
638 | ftp=ftp, | |
634 | wr_period=wr_period, |
|
639 | wr_period=wr_period, | |
635 | thisDatetime=thisDatetime, |
|
640 | thisDatetime=thisDatetime, | |
636 | update_figfile=update_figfile) |
|
641 | update_figfile=update_figfile) | |
637 |
|
642 | |||
638 | class CoherenceMap(Figure): |
|
643 | class CoherenceMap(Figure): | |
639 | isConfig = None |
|
644 | isConfig = None | |
640 | __nsubplots = None |
|
645 | __nsubplots = None | |
641 |
|
646 | |||
642 | WIDTHPROF = None |
|
647 | WIDTHPROF = None | |
643 | HEIGHTPROF = None |
|
648 | HEIGHTPROF = None | |
644 | PREFIX = 'cmap' |
|
649 | PREFIX = 'cmap' | |
645 |
|
650 | |||
646 | def __init__(self): |
|
651 | def __init__(self): | |
647 | self.timerange = 2*60*60 |
|
652 | self.timerange = 2*60*60 | |
648 | self.isConfig = False |
|
653 | self.isConfig = False | |
649 | self.__nsubplots = 1 |
|
654 | self.__nsubplots = 1 | |
650 |
|
655 | |||
651 | self.WIDTH = 800 |
|
656 | self.WIDTH = 800 | |
652 | self.HEIGHT = 180 |
|
657 | self.HEIGHT = 180 | |
653 | self.WIDTHPROF = 120 |
|
658 | self.WIDTHPROF = 120 | |
654 | self.HEIGHTPROF = 0 |
|
659 | self.HEIGHTPROF = 0 | |
655 | self.counter_imagwr = 0 |
|
660 | self.counter_imagwr = 0 | |
656 |
|
661 | |||
657 | self.PLOT_CODE = COH_CODE |
|
662 | self.PLOT_CODE = COH_CODE | |
658 |
|
663 | |||
659 | self.FTP_WEI = None |
|
664 | self.FTP_WEI = None | |
660 | self.EXP_CODE = None |
|
665 | self.EXP_CODE = None | |
661 | self.SUB_EXP_CODE = None |
|
666 | self.SUB_EXP_CODE = None | |
662 | self.PLOT_POS = None |
|
667 | self.PLOT_POS = None | |
663 | self.counter_imagwr = 0 |
|
668 | self.counter_imagwr = 0 | |
664 |
|
669 | |||
665 | self.xmin = None |
|
670 | self.xmin = None | |
666 | self.xmax = None |
|
671 | self.xmax = None | |
667 |
|
672 | |||
668 | def getSubplots(self): |
|
673 | def getSubplots(self): | |
669 | ncol = 1 |
|
674 | ncol = 1 | |
670 | nrow = self.nplots*2 |
|
675 | nrow = self.nplots*2 | |
671 |
|
676 | |||
672 | return nrow, ncol |
|
677 | return nrow, ncol | |
673 |
|
678 | |||
674 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
679 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
675 | self.__showprofile = showprofile |
|
680 | self.__showprofile = showprofile | |
676 | self.nplots = nplots |
|
681 | self.nplots = nplots | |
677 |
|
682 | |||
678 | ncolspan = 1 |
|
683 | ncolspan = 1 | |
679 | colspan = 1 |
|
684 | colspan = 1 | |
680 | if showprofile: |
|
685 | if showprofile: | |
681 | ncolspan = 7 |
|
686 | ncolspan = 7 | |
682 | colspan = 6 |
|
687 | colspan = 6 | |
683 | self.__nsubplots = 2 |
|
688 | self.__nsubplots = 2 | |
684 |
|
689 | |||
685 | self.createFigure(id = id, |
|
690 | self.createFigure(id = id, | |
686 | wintitle = wintitle, |
|
691 | wintitle = wintitle, | |
687 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
692 | widthplot = self.WIDTH + self.WIDTHPROF, | |
688 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
693 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
689 | show=True) |
|
694 | show=True) | |
690 |
|
695 | |||
691 | nrow, ncol = self.getSubplots() |
|
696 | nrow, ncol = self.getSubplots() | |
692 |
|
697 | |||
693 | for y in range(nrow): |
|
698 | for y in range(nrow): | |
694 | for x in range(ncol): |
|
699 | for x in range(ncol): | |
695 |
|
700 | |||
696 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
701 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
697 |
|
702 | |||
698 | if showprofile: |
|
703 | if showprofile: | |
699 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
704 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
700 |
|
705 | |||
701 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
706 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
702 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
707 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
703 | timerange=None, phase_min=None, phase_max=None, |
|
708 | timerange=None, phase_min=None, phase_max=None, | |
704 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, |
|
709 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, | |
705 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True, |
|
710 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True, | |
706 | server=None, folder=None, username=None, password=None, |
|
711 | server=None, folder=None, username=None, password=None, | |
707 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
712 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
708 |
|
713 | |||
709 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
714 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
710 | return |
|
715 | return | |
711 |
|
716 | |||
712 | if pairsList == None: |
|
717 | if pairsList == None: | |
713 | pairsIndexList = dataOut.pairsIndexList |
|
718 | pairsIndexList = dataOut.pairsIndexList | |
714 | else: |
|
719 | else: | |
715 | pairsIndexList = [] |
|
720 | pairsIndexList = [] | |
716 | for pair in pairsList: |
|
721 | for pair in pairsList: | |
717 | if pair not in dataOut.pairsList: |
|
722 | if pair not in dataOut.pairsList: | |
718 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
723 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
719 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
724 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
720 |
|
725 | |||
721 | if pairsIndexList == []: |
|
726 | if pairsIndexList == []: | |
722 | return |
|
727 | return | |
723 |
|
728 | |||
724 | if len(pairsIndexList) > 4: |
|
729 | if len(pairsIndexList) > 4: | |
725 | pairsIndexList = pairsIndexList[0:4] |
|
730 | pairsIndexList = pairsIndexList[0:4] | |
726 |
|
731 | |||
727 | if phase_min == None: |
|
732 | if phase_min == None: | |
728 | phase_min = -180 |
|
733 | phase_min = -180 | |
729 | if phase_max == None: |
|
734 | if phase_max == None: | |
730 | phase_max = 180 |
|
735 | phase_max = 180 | |
731 |
|
736 | |||
732 | x = dataOut.getTimeRange() |
|
737 | x = dataOut.getTimeRange() | |
733 | y = dataOut.getHeiRange() |
|
738 | y = dataOut.getHeiRange() | |
734 |
|
739 | |||
735 | thisDatetime = dataOut.datatime |
|
740 | thisDatetime = dataOut.datatime | |
736 |
|
741 | |||
737 | title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
742 | title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
738 | xlabel = "" |
|
743 | xlabel = "" | |
739 | ylabel = "Range (Km)" |
|
744 | ylabel = "Range (Km)" | |
740 | update_figfile = False |
|
745 | update_figfile = False | |
741 |
|
746 | |||
742 | if not self.isConfig: |
|
747 | if not self.isConfig: | |
743 | nplots = len(pairsIndexList) |
|
748 | nplots = len(pairsIndexList) | |
744 | self.setup(id=id, |
|
749 | self.setup(id=id, | |
745 | nplots=nplots, |
|
750 | nplots=nplots, | |
746 | wintitle=wintitle, |
|
751 | wintitle=wintitle, | |
747 | showprofile=showprofile, |
|
752 | showprofile=showprofile, | |
748 | show=show) |
|
753 | show=show) | |
749 |
|
754 | |||
750 | if timerange != None: |
|
755 | if timerange != None: | |
751 | self.timerange = timerange |
|
756 | self.timerange = timerange | |
752 |
|
757 | |||
753 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
758 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
754 |
|
759 | |||
755 | if ymin == None: ymin = numpy.nanmin(y) |
|
760 | if ymin == None: ymin = numpy.nanmin(y) | |
756 | if ymax == None: ymax = numpy.nanmax(y) |
|
761 | if ymax == None: ymax = numpy.nanmax(y) | |
757 | if zmin == None: zmin = 0. |
|
762 | if zmin == None: zmin = 0. | |
758 | if zmax == None: zmax = 1. |
|
763 | if zmax == None: zmax = 1. | |
759 |
|
764 | |||
760 | self.FTP_WEI = ftp_wei |
|
765 | self.FTP_WEI = ftp_wei | |
761 | self.EXP_CODE = exp_code |
|
766 | self.EXP_CODE = exp_code | |
762 | self.SUB_EXP_CODE = sub_exp_code |
|
767 | self.SUB_EXP_CODE = sub_exp_code | |
763 | self.PLOT_POS = plot_pos |
|
768 | self.PLOT_POS = plot_pos | |
764 |
|
769 | |||
765 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
770 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
766 |
|
771 | |||
767 | self.isConfig = True |
|
772 | self.isConfig = True | |
768 | update_figfile = True |
|
773 | update_figfile = True | |
769 |
|
774 | |||
770 | self.setWinTitle(title) |
|
775 | self.setWinTitle(title) | |
771 |
|
776 | |||
772 | for i in range(self.nplots): |
|
777 | for i in range(self.nplots): | |
773 |
|
778 | |||
774 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
779 | pair = dataOut.pairsList[pairsIndexList[i]] | |
775 |
|
780 | |||
776 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) |
|
781 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) | |
777 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) |
|
782 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) | |
778 | powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0) |
|
783 | powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0) | |
779 |
|
784 | |||
780 |
|
785 | |||
781 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
786 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
782 | coherence = numpy.abs(avgcoherenceComplex) |
|
787 | coherence = numpy.abs(avgcoherenceComplex) | |
783 |
|
788 | |||
784 | z = coherence.reshape((1,-1)) |
|
789 | z = coherence.reshape((1,-1)) | |
785 |
|
790 | |||
786 | counter = 0 |
|
791 | counter = 0 | |
787 |
|
792 | |||
788 | title = "Coherence Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
793 | title = "Coherence Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
789 | axes = self.axesList[i*self.__nsubplots*2] |
|
794 | axes = self.axesList[i*self.__nsubplots*2] | |
790 | axes.pcolorbuffer(x, y, z, |
|
795 | axes.pcolorbuffer(x, y, z, | |
791 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
796 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
792 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
797 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
793 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") |
|
798 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") | |
794 |
|
799 | |||
795 | if self.__showprofile: |
|
800 | if self.__showprofile: | |
796 | counter += 1 |
|
801 | counter += 1 | |
797 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
802 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
798 | axes.pline(coherence, y, |
|
803 | axes.pline(coherence, y, | |
799 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
804 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
800 | xlabel='', ylabel='', title='', ticksize=7, |
|
805 | xlabel='', ylabel='', title='', ticksize=7, | |
801 | ytick_visible=False, nxticks=5, |
|
806 | ytick_visible=False, nxticks=5, | |
802 | grid='x') |
|
807 | grid='x') | |
803 |
|
808 | |||
804 | counter += 1 |
|
809 | counter += 1 | |
805 |
|
810 | |||
806 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
811 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
807 |
|
812 | |||
808 | z = phase.reshape((1,-1)) |
|
813 | z = phase.reshape((1,-1)) | |
809 |
|
814 | |||
810 | title = "Phase Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
815 | title = "Phase Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
811 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
816 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
812 | axes.pcolorbuffer(x, y, z, |
|
817 | axes.pcolorbuffer(x, y, z, | |
813 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max, |
|
818 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max, | |
814 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
819 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
815 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") |
|
820 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") | |
816 |
|
821 | |||
817 | if self.__showprofile: |
|
822 | if self.__showprofile: | |
818 | counter += 1 |
|
823 | counter += 1 | |
819 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
824 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
820 | axes.pline(phase, y, |
|
825 | axes.pline(phase, y, | |
821 | xmin=phase_min, xmax=phase_max, ymin=ymin, ymax=ymax, |
|
826 | xmin=phase_min, xmax=phase_max, ymin=ymin, ymax=ymax, | |
822 | xlabel='', ylabel='', title='', ticksize=7, |
|
827 | xlabel='', ylabel='', title='', ticksize=7, | |
823 | ytick_visible=False, nxticks=4, |
|
828 | ytick_visible=False, nxticks=4, | |
824 | grid='x') |
|
829 | grid='x') | |
825 |
|
830 | |||
826 | self.draw() |
|
831 | self.draw() | |
827 |
|
832 | |||
828 | if dataOut.ltctime >= self.xmax: |
|
833 | if dataOut.ltctime >= self.xmax: | |
829 | self.counter_imagwr = wr_period |
|
834 | self.counter_imagwr = wr_period | |
830 | self.isConfig = False |
|
835 | self.isConfig = False | |
831 | update_figfile = True |
|
836 | update_figfile = True | |
832 |
|
837 | |||
833 | self.save(figpath=figpath, |
|
838 | self.save(figpath=figpath, | |
834 | figfile=figfile, |
|
839 | figfile=figfile, | |
835 | save=save, |
|
840 | save=save, | |
836 | ftp=ftp, |
|
841 | ftp=ftp, | |
837 | wr_period=wr_period, |
|
842 | wr_period=wr_period, | |
838 | thisDatetime=thisDatetime, |
|
843 | thisDatetime=thisDatetime, | |
839 | update_figfile=update_figfile) |
|
844 | update_figfile=update_figfile) | |
840 |
|
845 | |||
841 | class PowerProfilePlot(Figure): |
|
846 | class PowerProfilePlot(Figure): | |
842 |
|
847 | |||
843 | isConfig = None |
|
848 | isConfig = None | |
844 | __nsubplots = None |
|
849 | __nsubplots = None | |
845 |
|
850 | |||
846 | WIDTHPROF = None |
|
851 | WIDTHPROF = None | |
847 | HEIGHTPROF = None |
|
852 | HEIGHTPROF = None | |
848 | PREFIX = 'spcprofile' |
|
853 | PREFIX = 'spcprofile' | |
849 |
|
854 | |||
850 | def __init__(self): |
|
855 | def __init__(self): | |
851 | self.isConfig = False |
|
856 | self.isConfig = False | |
852 | self.__nsubplots = 1 |
|
857 | self.__nsubplots = 1 | |
853 |
|
858 | |||
854 | self.PLOT_CODE = POWER_CODE |
|
859 | self.PLOT_CODE = POWER_CODE | |
855 |
|
860 | |||
856 | self.WIDTH = 300 |
|
861 | self.WIDTH = 300 | |
857 | self.HEIGHT = 500 |
|
862 | self.HEIGHT = 500 | |
858 | self.counter_imagwr = 0 |
|
863 | self.counter_imagwr = 0 | |
859 |
|
864 | |||
860 | def getSubplots(self): |
|
865 | def getSubplots(self): | |
861 | ncol = 1 |
|
866 | ncol = 1 | |
862 | nrow = 1 |
|
867 | nrow = 1 | |
863 |
|
868 | |||
864 | return nrow, ncol |
|
869 | return nrow, ncol | |
865 |
|
870 | |||
866 | def setup(self, id, nplots, wintitle, show): |
|
871 | def setup(self, id, nplots, wintitle, show): | |
867 |
|
872 | |||
868 | self.nplots = nplots |
|
873 | self.nplots = nplots | |
869 |
|
874 | |||
870 | ncolspan = 1 |
|
875 | ncolspan = 1 | |
871 | colspan = 1 |
|
876 | colspan = 1 | |
872 |
|
877 | |||
873 | self.createFigure(id = id, |
|
878 | self.createFigure(id = id, | |
874 | wintitle = wintitle, |
|
879 | wintitle = wintitle, | |
875 | widthplot = self.WIDTH, |
|
880 | widthplot = self.WIDTH, | |
876 | heightplot = self.HEIGHT, |
|
881 | heightplot = self.HEIGHT, | |
877 | show=show) |
|
882 | show=show) | |
878 |
|
883 | |||
879 | nrow, ncol = self.getSubplots() |
|
884 | nrow, ncol = self.getSubplots() | |
880 |
|
885 | |||
881 | counter = 0 |
|
886 | counter = 0 | |
882 | for y in range(nrow): |
|
887 | for y in range(nrow): | |
883 | for x in range(ncol): |
|
888 | for x in range(ncol): | |
884 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
889 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
885 |
|
890 | |||
886 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
891 | def run(self, dataOut, id, wintitle="", channelList=None, | |
887 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
892 | xmin=None, xmax=None, ymin=None, ymax=None, | |
888 | save=False, figpath='./', figfile=None, show=True, |
|
893 | save=False, figpath='./', figfile=None, show=True, | |
889 | ftp=False, wr_period=1, server=None, |
|
894 | ftp=False, wr_period=1, server=None, | |
890 | folder=None, username=None, password=None): |
|
895 | folder=None, username=None, password=None): | |
891 |
|
896 | |||
892 |
|
897 | |||
893 | if channelList == None: |
|
898 | if channelList == None: | |
894 | channelIndexList = dataOut.channelIndexList |
|
899 | channelIndexList = dataOut.channelIndexList | |
895 | channelList = dataOut.channelList |
|
900 | channelList = dataOut.channelList | |
896 | else: |
|
901 | else: | |
897 | channelIndexList = [] |
|
902 | channelIndexList = [] | |
898 | for channel in channelList: |
|
903 | for channel in channelList: | |
899 | if channel not in dataOut.channelList: |
|
904 | if channel not in dataOut.channelList: | |
900 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
905 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
901 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
906 | channelIndexList.append(dataOut.channelList.index(channel)) | |
902 |
|
907 | |||
903 | factor = dataOut.normFactor |
|
908 | factor = dataOut.normFactor | |
904 |
|
909 | |||
905 | y = dataOut.getHeiRange() |
|
910 | y = dataOut.getHeiRange() | |
906 |
|
911 | |||
907 | #for voltage |
|
912 | #for voltage | |
908 | if dataOut.type == 'Voltage': |
|
913 | if dataOut.type == 'Voltage': | |
909 | x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
914 | x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
910 | x = x.real |
|
915 | x = x.real | |
911 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
916 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
912 |
|
917 | |||
913 | #for spectra |
|
918 | #for spectra | |
914 | if dataOut.type == 'Spectra': |
|
919 | if dataOut.type == 'Spectra': | |
915 | x = dataOut.data_spc[channelIndexList,:,:]/factor |
|
920 | x = dataOut.data_spc[channelIndexList,:,:]/factor | |
916 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
921 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
917 | x = numpy.average(x, axis=1) |
|
922 | x = numpy.average(x, axis=1) | |
918 |
|
923 | |||
919 |
|
924 | |||
920 | xdB = 10*numpy.log10(x) |
|
925 | xdB = 10*numpy.log10(x) | |
921 |
|
926 | |||
922 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
927 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
923 | title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
928 | title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
924 | xlabel = "dB" |
|
929 | xlabel = "dB" | |
925 | ylabel = "Range (Km)" |
|
930 | ylabel = "Range (Km)" | |
926 |
|
931 | |||
927 | if not self.isConfig: |
|
932 | if not self.isConfig: | |
928 |
|
933 | |||
929 | nplots = 1 |
|
934 | nplots = 1 | |
930 |
|
935 | |||
931 | self.setup(id=id, |
|
936 | self.setup(id=id, | |
932 | nplots=nplots, |
|
937 | nplots=nplots, | |
933 | wintitle=wintitle, |
|
938 | wintitle=wintitle, | |
934 | show=show) |
|
939 | show=show) | |
935 |
|
940 | |||
936 | if ymin == None: ymin = numpy.nanmin(y) |
|
941 | if ymin == None: ymin = numpy.nanmin(y) | |
937 | if ymax == None: ymax = numpy.nanmax(y) |
|
942 | if ymax == None: ymax = numpy.nanmax(y) | |
938 | if xmin == None: xmin = numpy.nanmin(xdB)*0.9 |
|
943 | if xmin == None: xmin = numpy.nanmin(xdB)*0.9 | |
939 | if xmax == None: xmax = numpy.nanmax(xdB)*1.1 |
|
944 | if xmax == None: xmax = numpy.nanmax(xdB)*1.1 | |
940 |
|
945 | |||
941 | self.isConfig = True |
|
946 | self.isConfig = True | |
942 |
|
947 | |||
943 | self.setWinTitle(title) |
|
948 | self.setWinTitle(title) | |
944 |
|
949 | |||
945 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
950 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
946 | axes = self.axesList[0] |
|
951 | axes = self.axesList[0] | |
947 |
|
952 | |||
948 | legendlabels = ["channel %d"%x for x in channelList] |
|
953 | legendlabels = ["channel %d"%x for x in channelList] | |
949 | axes.pmultiline(xdB, y, |
|
954 | axes.pmultiline(xdB, y, | |
950 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
955 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
951 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
956 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
952 | ytick_visible=True, nxticks=5, |
|
957 | ytick_visible=True, nxticks=5, | |
953 | grid='x') |
|
958 | grid='x') | |
954 |
|
959 | |||
955 | self.draw() |
|
960 | self.draw() | |
956 |
|
961 | |||
957 | self.save(figpath=figpath, |
|
962 | self.save(figpath=figpath, | |
958 | figfile=figfile, |
|
963 | figfile=figfile, | |
959 | save=save, |
|
964 | save=save, | |
960 | ftp=ftp, |
|
965 | ftp=ftp, | |
961 | wr_period=wr_period, |
|
966 | wr_period=wr_period, | |
962 | thisDatetime=thisDatetime) |
|
967 | thisDatetime=thisDatetime) | |
963 |
|
968 | |||
964 | class SpectraCutPlot(Figure): |
|
969 | class SpectraCutPlot(Figure): | |
965 |
|
970 | |||
966 | isConfig = None |
|
971 | isConfig = None | |
967 | __nsubplots = None |
|
972 | __nsubplots = None | |
968 |
|
973 | |||
969 | WIDTHPROF = None |
|
974 | WIDTHPROF = None | |
970 | HEIGHTPROF = None |
|
975 | HEIGHTPROF = None | |
971 | PREFIX = 'spc_cut' |
|
976 | PREFIX = 'spc_cut' | |
972 |
|
977 | |||
973 | def __init__(self): |
|
978 | def __init__(self): | |
974 | self.isConfig = False |
|
979 | self.isConfig = False | |
975 | self.__nsubplots = 1 |
|
980 | self.__nsubplots = 1 | |
976 |
|
981 | |||
977 | self.PLOT_CODE = POWER_CODE |
|
982 | self.PLOT_CODE = POWER_CODE | |
978 |
|
983 | |||
979 | self.WIDTH = 700 |
|
984 | self.WIDTH = 700 | |
980 | self.HEIGHT = 500 |
|
985 | self.HEIGHT = 500 | |
981 | self.counter_imagwr = 0 |
|
986 | self.counter_imagwr = 0 | |
982 |
|
987 | |||
983 | def getSubplots(self): |
|
988 | def getSubplots(self): | |
984 | ncol = 1 |
|
989 | ncol = 1 | |
985 | nrow = 1 |
|
990 | nrow = 1 | |
986 |
|
991 | |||
987 | return nrow, ncol |
|
992 | return nrow, ncol | |
988 |
|
993 | |||
989 | def setup(self, id, nplots, wintitle, show): |
|
994 | def setup(self, id, nplots, wintitle, show): | |
990 |
|
995 | |||
991 | self.nplots = nplots |
|
996 | self.nplots = nplots | |
992 |
|
997 | |||
993 | ncolspan = 1 |
|
998 | ncolspan = 1 | |
994 | colspan = 1 |
|
999 | colspan = 1 | |
995 |
|
1000 | |||
996 | self.createFigure(id = id, |
|
1001 | self.createFigure(id = id, | |
997 | wintitle = wintitle, |
|
1002 | wintitle = wintitle, | |
998 | widthplot = self.WIDTH, |
|
1003 | widthplot = self.WIDTH, | |
999 | heightplot = self.HEIGHT, |
|
1004 | heightplot = self.HEIGHT, | |
1000 | show=show) |
|
1005 | show=show) | |
1001 |
|
1006 | |||
1002 | nrow, ncol = self.getSubplots() |
|
1007 | nrow, ncol = self.getSubplots() | |
1003 |
|
1008 | |||
1004 | counter = 0 |
|
1009 | counter = 0 | |
1005 | for y in range(nrow): |
|
1010 | for y in range(nrow): | |
1006 | for x in range(ncol): |
|
1011 | for x in range(ncol): | |
1007 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1012 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
1008 |
|
1013 | |||
1009 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
1014 | def run(self, dataOut, id, wintitle="", channelList=None, | |
1010 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1015 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1011 | save=False, figpath='./', figfile=None, show=True, |
|
1016 | save=False, figpath='./', figfile=None, show=True, | |
1012 | ftp=False, wr_period=1, server=None, |
|
1017 | ftp=False, wr_period=1, server=None, | |
1013 | folder=None, username=None, password=None, |
|
1018 | folder=None, username=None, password=None, | |
1014 | xaxis="frequency"): |
|
1019 | xaxis="frequency"): | |
1015 |
|
1020 | |||
1016 |
|
1021 | |||
1017 | if channelList == None: |
|
1022 | if channelList == None: | |
1018 | channelIndexList = dataOut.channelIndexList |
|
1023 | channelIndexList = dataOut.channelIndexList | |
1019 | channelList = dataOut.channelList |
|
1024 | channelList = dataOut.channelList | |
1020 | else: |
|
1025 | else: | |
1021 | channelIndexList = [] |
|
1026 | channelIndexList = [] | |
1022 | for channel in channelList: |
|
1027 | for channel in channelList: | |
1023 | if channel not in dataOut.channelList: |
|
1028 | if channel not in dataOut.channelList: | |
1024 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1029 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1025 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1030 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1026 |
|
1031 | |||
1027 | factor = dataOut.normFactor |
|
1032 | factor = dataOut.normFactor | |
1028 |
|
1033 | |||
1029 | y = dataOut.getHeiRange() |
|
1034 | y = dataOut.getHeiRange() | |
1030 |
|
1035 | |||
1031 | z = dataOut.data_spc/factor |
|
1036 | z = dataOut.data_spc/factor | |
1032 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
1037 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
1033 |
|
1038 | |||
1034 | hei_index = numpy.arange(25)*3 + 20 |
|
1039 | hei_index = numpy.arange(25)*3 + 20 | |
1035 |
|
1040 | |||
1036 | if xaxis == "frequency": |
|
1041 | if xaxis == "frequency": | |
1037 | x = dataOut.getFreqRange()/1000. |
|
1042 | x = dataOut.getFreqRange()/1000. | |
1038 | zdB = 10*numpy.log10(z[0,:,hei_index]) |
|
1043 | zdB = 10*numpy.log10(z[0,:,hei_index]) | |
1039 | xlabel = "Frequency (kHz)" |
|
1044 | xlabel = "Frequency (kHz)" | |
1040 | ylabel = "Power (dB)" |
|
1045 | ylabel = "Power (dB)" | |
1041 |
|
1046 | |||
1042 | elif xaxis == "time": |
|
1047 | elif xaxis == "time": | |
1043 | x = dataOut.getAcfRange() |
|
1048 | x = dataOut.getAcfRange() | |
1044 | zdB = z[0,:,hei_index] |
|
1049 | zdB = z[0,:,hei_index] | |
1045 | xlabel = "Time (ms)" |
|
1050 | xlabel = "Time (ms)" | |
1046 | ylabel = "ACF" |
|
1051 | ylabel = "ACF" | |
1047 |
|
1052 | |||
1048 | else: |
|
1053 | else: | |
1049 | x = dataOut.getVelRange() |
|
1054 | x = dataOut.getVelRange() | |
1050 | zdB = 10*numpy.log10(z[0,:,hei_index]) |
|
1055 | zdB = 10*numpy.log10(z[0,:,hei_index]) | |
1051 | xlabel = "Velocity (m/s)" |
|
1056 | xlabel = "Velocity (m/s)" | |
1052 | ylabel = "Power (dB)" |
|
1057 | ylabel = "Power (dB)" | |
1053 |
|
1058 | |||
1054 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
1059 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
1055 | title = wintitle + " Range Cuts %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1060 | title = wintitle + " Range Cuts %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1056 |
|
1061 | |||
1057 | if not self.isConfig: |
|
1062 | if not self.isConfig: | |
1058 |
|
1063 | |||
1059 | nplots = 1 |
|
1064 | nplots = 1 | |
1060 |
|
1065 | |||
1061 | self.setup(id=id, |
|
1066 | self.setup(id=id, | |
1062 | nplots=nplots, |
|
1067 | nplots=nplots, | |
1063 | wintitle=wintitle, |
|
1068 | wintitle=wintitle, | |
1064 | show=show) |
|
1069 | show=show) | |
1065 |
|
1070 | |||
1066 | if xmin == None: xmin = numpy.nanmin(x)*0.9 |
|
1071 | if xmin == None: xmin = numpy.nanmin(x)*0.9 | |
1067 | if xmax == None: xmax = numpy.nanmax(x)*1.1 |
|
1072 | if xmax == None: xmax = numpy.nanmax(x)*1.1 | |
1068 | if ymin == None: ymin = numpy.nanmin(zdB) |
|
1073 | if ymin == None: ymin = numpy.nanmin(zdB) | |
1069 | if ymax == None: ymax = numpy.nanmax(zdB) |
|
1074 | if ymax == None: ymax = numpy.nanmax(zdB) | |
1070 |
|
1075 | |||
1071 | self.isConfig = True |
|
1076 | self.isConfig = True | |
1072 |
|
1077 | |||
1073 | self.setWinTitle(title) |
|
1078 | self.setWinTitle(title) | |
1074 |
|
1079 | |||
1075 | title = "Spectra Cuts: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1080 | title = "Spectra Cuts: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1076 | axes = self.axesList[0] |
|
1081 | axes = self.axesList[0] | |
1077 |
|
1082 | |||
1078 | legendlabels = ["Range = %dKm" %y[i] for i in hei_index] |
|
1083 | legendlabels = ["Range = %dKm" %y[i] for i in hei_index] | |
1079 |
|
1084 | |||
1080 | axes.pmultilineyaxis( x, zdB, |
|
1085 | axes.pmultilineyaxis( x, zdB, | |
1081 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1086 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
1082 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
1087 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
1083 | ytick_visible=True, nxticks=5, |
|
1088 | ytick_visible=True, nxticks=5, | |
1084 | grid='x') |
|
1089 | grid='x') | |
1085 |
|
1090 | |||
1086 | self.draw() |
|
1091 | self.draw() | |
1087 |
|
1092 | |||
1088 | self.save(figpath=figpath, |
|
1093 | self.save(figpath=figpath, | |
1089 | figfile=figfile, |
|
1094 | figfile=figfile, | |
1090 | save=save, |
|
1095 | save=save, | |
1091 | ftp=ftp, |
|
1096 | ftp=ftp, | |
1092 | wr_period=wr_period, |
|
1097 | wr_period=wr_period, | |
1093 | thisDatetime=thisDatetime) |
|
1098 | thisDatetime=thisDatetime) | |
1094 |
|
1099 | |||
1095 | class Noise(Figure): |
|
1100 | class Noise(Figure): | |
1096 |
|
1101 | |||
1097 | isConfig = None |
|
1102 | isConfig = None | |
1098 | __nsubplots = None |
|
1103 | __nsubplots = None | |
1099 |
|
1104 | |||
1100 | PREFIX = 'noise' |
|
1105 | PREFIX = 'noise' | |
1101 |
|
1106 | |||
1102 | def __init__(self): |
|
1107 | def __init__(self): | |
1103 |
|
1108 | |||
1104 | self.timerange = 24*60*60 |
|
1109 | self.timerange = 24*60*60 | |
1105 | self.isConfig = False |
|
1110 | self.isConfig = False | |
1106 | self.__nsubplots = 1 |
|
1111 | self.__nsubplots = 1 | |
1107 | self.counter_imagwr = 0 |
|
1112 | self.counter_imagwr = 0 | |
1108 | self.WIDTH = 800 |
|
1113 | self.WIDTH = 800 | |
1109 | self.HEIGHT = 400 |
|
1114 | self.HEIGHT = 400 | |
1110 | self.WIDTHPROF = 120 |
|
1115 | self.WIDTHPROF = 120 | |
1111 | self.HEIGHTPROF = 0 |
|
1116 | self.HEIGHTPROF = 0 | |
1112 | self.xdata = None |
|
1117 | self.xdata = None | |
1113 | self.ydata = None |
|
1118 | self.ydata = None | |
1114 |
|
1119 | |||
1115 | self.PLOT_CODE = NOISE_CODE |
|
1120 | self.PLOT_CODE = NOISE_CODE | |
1116 |
|
1121 | |||
1117 | self.FTP_WEI = None |
|
1122 | self.FTP_WEI = None | |
1118 | self.EXP_CODE = None |
|
1123 | self.EXP_CODE = None | |
1119 | self.SUB_EXP_CODE = None |
|
1124 | self.SUB_EXP_CODE = None | |
1120 | self.PLOT_POS = None |
|
1125 | self.PLOT_POS = None | |
1121 | self.figfile = None |
|
1126 | self.figfile = None | |
1122 |
|
1127 | |||
1123 | self.xmin = None |
|
1128 | self.xmin = None | |
1124 | self.xmax = None |
|
1129 | self.xmax = None | |
1125 |
|
1130 | |||
1126 | def getSubplots(self): |
|
1131 | def getSubplots(self): | |
1127 |
|
1132 | |||
1128 | ncol = 1 |
|
1133 | ncol = 1 | |
1129 | nrow = 1 |
|
1134 | nrow = 1 | |
1130 |
|
1135 | |||
1131 | return nrow, ncol |
|
1136 | return nrow, ncol | |
1132 |
|
1137 | |||
1133 | def openfile(self, filename): |
|
1138 | def openfile(self, filename): | |
1134 | dirname = os.path.dirname(filename) |
|
1139 | dirname = os.path.dirname(filename) | |
1135 |
|
1140 | |||
1136 | if not os.path.exists(dirname): |
|
1141 | if not os.path.exists(dirname): | |
1137 | os.mkdir(dirname) |
|
1142 | os.mkdir(dirname) | |
1138 |
|
1143 | |||
1139 | f = open(filename,'w+') |
|
1144 | f = open(filename,'w+') | |
1140 | f.write('\n\n') |
|
1145 | f.write('\n\n') | |
1141 | f.write('JICAMARCA RADIO OBSERVATORY - Noise \n') |
|
1146 | f.write('JICAMARCA RADIO OBSERVATORY - Noise \n') | |
1142 | f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' ) |
|
1147 | f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' ) | |
1143 | f.close() |
|
1148 | f.close() | |
1144 |
|
1149 | |||
1145 | def save_data(self, filename_phase, data, data_datetime): |
|
1150 | def save_data(self, filename_phase, data, data_datetime): | |
1146 |
|
1151 | |||
1147 | f=open(filename_phase,'a') |
|
1152 | f=open(filename_phase,'a') | |
1148 |
|
1153 | |||
1149 | timetuple_data = data_datetime.timetuple() |
|
1154 | timetuple_data = data_datetime.timetuple() | |
1150 | day = str(timetuple_data.tm_mday) |
|
1155 | day = str(timetuple_data.tm_mday) | |
1151 | month = str(timetuple_data.tm_mon) |
|
1156 | month = str(timetuple_data.tm_mon) | |
1152 | year = str(timetuple_data.tm_year) |
|
1157 | year = str(timetuple_data.tm_year) | |
1153 | hour = str(timetuple_data.tm_hour) |
|
1158 | hour = str(timetuple_data.tm_hour) | |
1154 | minute = str(timetuple_data.tm_min) |
|
1159 | minute = str(timetuple_data.tm_min) | |
1155 | second = str(timetuple_data.tm_sec) |
|
1160 | second = str(timetuple_data.tm_sec) | |
1156 |
|
1161 | |||
1157 | data_msg = '' |
|
1162 | data_msg = '' | |
1158 | for i in range(len(data)): |
|
1163 | for i in range(len(data)): | |
1159 | data_msg += str(data[i]) + ' ' |
|
1164 | data_msg += str(data[i]) + ' ' | |
1160 |
|
1165 | |||
1161 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' ' + data_msg + '\n') |
|
1166 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' ' + data_msg + '\n') | |
1162 | f.close() |
|
1167 | f.close() | |
1163 |
|
1168 | |||
1164 |
|
1169 | |||
1165 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1170 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1166 |
|
1171 | |||
1167 | self.__showprofile = showprofile |
|
1172 | self.__showprofile = showprofile | |
1168 | self.nplots = nplots |
|
1173 | self.nplots = nplots | |
1169 |
|
1174 | |||
1170 | ncolspan = 7 |
|
1175 | ncolspan = 7 | |
1171 | colspan = 6 |
|
1176 | colspan = 6 | |
1172 | self.__nsubplots = 2 |
|
1177 | self.__nsubplots = 2 | |
1173 |
|
1178 | |||
1174 | self.createFigure(id = id, |
|
1179 | self.createFigure(id = id, | |
1175 | wintitle = wintitle, |
|
1180 | wintitle = wintitle, | |
1176 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1181 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1177 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1182 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1178 | show=show) |
|
1183 | show=show) | |
1179 |
|
1184 | |||
1180 | nrow, ncol = self.getSubplots() |
|
1185 | nrow, ncol = self.getSubplots() | |
1181 |
|
1186 | |||
1182 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1187 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1183 |
|
1188 | |||
1184 |
|
1189 | |||
1185 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', |
|
1190 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
1186 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1191 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1187 | timerange=None, |
|
1192 | timerange=None, | |
1188 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1193 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1189 | server=None, folder=None, username=None, password=None, |
|
1194 | server=None, folder=None, username=None, password=None, | |
1190 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1195 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1191 |
|
1196 | |||
1192 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
1197 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
1193 | return |
|
1198 | return | |
1194 |
|
1199 | |||
1195 | if channelList == None: |
|
1200 | if channelList == None: | |
1196 | channelIndexList = dataOut.channelIndexList |
|
1201 | channelIndexList = dataOut.channelIndexList | |
1197 | channelList = dataOut.channelList |
|
1202 | channelList = dataOut.channelList | |
1198 | else: |
|
1203 | else: | |
1199 | channelIndexList = [] |
|
1204 | channelIndexList = [] | |
1200 | for channel in channelList: |
|
1205 | for channel in channelList: | |
1201 | if channel not in dataOut.channelList: |
|
1206 | if channel not in dataOut.channelList: | |
1202 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1207 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1203 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1208 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1204 |
|
1209 | |||
1205 | x = dataOut.getTimeRange() |
|
1210 | x = dataOut.getTimeRange() | |
1206 | #y = dataOut.getHeiRange() |
|
1211 | #y = dataOut.getHeiRange() | |
1207 | factor = dataOut.normFactor |
|
1212 | factor = dataOut.normFactor | |
1208 | noise = dataOut.noise[channelIndexList]/factor |
|
1213 | noise = dataOut.noise[channelIndexList]/factor | |
1209 | noisedB = 10*numpy.log10(noise) |
|
1214 | noisedB = 10*numpy.log10(noise) | |
1210 |
|
1215 | |||
1211 | thisDatetime = dataOut.datatime |
|
1216 | thisDatetime = dataOut.datatime | |
1212 |
|
1217 | |||
1213 | title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1218 | title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1214 | xlabel = "" |
|
1219 | xlabel = "" | |
1215 | ylabel = "Intensity (dB)" |
|
1220 | ylabel = "Intensity (dB)" | |
1216 | update_figfile = False |
|
1221 | update_figfile = False | |
1217 |
|
1222 | |||
1218 | if not self.isConfig: |
|
1223 | if not self.isConfig: | |
1219 |
|
1224 | |||
1220 | nplots = 1 |
|
1225 | nplots = 1 | |
1221 |
|
1226 | |||
1222 | self.setup(id=id, |
|
1227 | self.setup(id=id, | |
1223 | nplots=nplots, |
|
1228 | nplots=nplots, | |
1224 | wintitle=wintitle, |
|
1229 | wintitle=wintitle, | |
1225 | showprofile=showprofile, |
|
1230 | showprofile=showprofile, | |
1226 | show=show) |
|
1231 | show=show) | |
1227 |
|
1232 | |||
1228 | if timerange != None: |
|
1233 | if timerange != None: | |
1229 | self.timerange = timerange |
|
1234 | self.timerange = timerange | |
1230 |
|
1235 | |||
1231 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1236 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1232 |
|
1237 | |||
1233 | if ymin == None: ymin = numpy.floor(numpy.nanmin(noisedB)) - 10.0 |
|
1238 | if ymin == None: ymin = numpy.floor(numpy.nanmin(noisedB)) - 10.0 | |
1234 | if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0 |
|
1239 | if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0 | |
1235 |
|
1240 | |||
1236 | self.FTP_WEI = ftp_wei |
|
1241 | self.FTP_WEI = ftp_wei | |
1237 | self.EXP_CODE = exp_code |
|
1242 | self.EXP_CODE = exp_code | |
1238 | self.SUB_EXP_CODE = sub_exp_code |
|
1243 | self.SUB_EXP_CODE = sub_exp_code | |
1239 | self.PLOT_POS = plot_pos |
|
1244 | self.PLOT_POS = plot_pos | |
1240 |
|
1245 | |||
1241 |
|
1246 | |||
1242 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1247 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1243 | self.isConfig = True |
|
1248 | self.isConfig = True | |
1244 | self.figfile = figfile |
|
1249 | self.figfile = figfile | |
1245 | self.xdata = numpy.array([]) |
|
1250 | self.xdata = numpy.array([]) | |
1246 | self.ydata = numpy.array([]) |
|
1251 | self.ydata = numpy.array([]) | |
1247 |
|
1252 | |||
1248 | update_figfile = True |
|
1253 | update_figfile = True | |
1249 |
|
1254 | |||
1250 | #open file beacon phase |
|
1255 | #open file beacon phase | |
1251 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1256 | path = '%s%03d' %(self.PREFIX, self.id) | |
1252 | noise_file = os.path.join(path,'%s.txt'%self.name) |
|
1257 | noise_file = os.path.join(path,'%s.txt'%self.name) | |
1253 | self.filename_noise = os.path.join(figpath,noise_file) |
|
1258 | self.filename_noise = os.path.join(figpath,noise_file) | |
1254 |
|
1259 | |||
1255 | self.setWinTitle(title) |
|
1260 | self.setWinTitle(title) | |
1256 |
|
1261 | |||
1257 | title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1262 | title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1258 |
|
1263 | |||
1259 | legendlabels = ["channel %d"%(idchannel) for idchannel in channelList] |
|
1264 | legendlabels = ["channel %d"%(idchannel) for idchannel in channelList] | |
1260 | axes = self.axesList[0] |
|
1265 | axes = self.axesList[0] | |
1261 |
|
1266 | |||
1262 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1267 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1263 |
|
1268 | |||
1264 | if len(self.ydata)==0: |
|
1269 | if len(self.ydata)==0: | |
1265 | self.ydata = noisedB.reshape(-1,1) |
|
1270 | self.ydata = noisedB.reshape(-1,1) | |
1266 | else: |
|
1271 | else: | |
1267 | self.ydata = numpy.hstack((self.ydata, noisedB.reshape(-1,1))) |
|
1272 | self.ydata = numpy.hstack((self.ydata, noisedB.reshape(-1,1))) | |
1268 |
|
1273 | |||
1269 |
|
1274 | |||
1270 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1275 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1271 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1276 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, | |
1272 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1277 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1273 | XAxisAsTime=True, grid='both' |
|
1278 | XAxisAsTime=True, grid='both' | |
1274 | ) |
|
1279 | ) | |
1275 |
|
1280 | |||
1276 | self.draw() |
|
1281 | self.draw() | |
1277 |
|
1282 | |||
1278 | if dataOut.ltctime >= self.xmax: |
|
1283 | if dataOut.ltctime >= self.xmax: | |
1279 | self.counter_imagwr = wr_period |
|
1284 | self.counter_imagwr = wr_period | |
1280 | self.isConfig = False |
|
1285 | self.isConfig = False | |
1281 | update_figfile = True |
|
1286 | update_figfile = True | |
1282 |
|
1287 | |||
1283 | self.save(figpath=figpath, |
|
1288 | self.save(figpath=figpath, | |
1284 | figfile=figfile, |
|
1289 | figfile=figfile, | |
1285 | save=save, |
|
1290 | save=save, | |
1286 | ftp=ftp, |
|
1291 | ftp=ftp, | |
1287 | wr_period=wr_period, |
|
1292 | wr_period=wr_period, | |
1288 | thisDatetime=thisDatetime, |
|
1293 | thisDatetime=thisDatetime, | |
1289 | update_figfile=update_figfile) |
|
1294 | update_figfile=update_figfile) | |
1290 |
|
1295 | |||
1291 | #store data beacon phase |
|
1296 | #store data beacon phase | |
1292 | if save: |
|
1297 | if save: | |
1293 | self.save_data(self.filename_noise, noisedB, thisDatetime) |
|
1298 | self.save_data(self.filename_noise, noisedB, thisDatetime) | |
1294 |
|
1299 | |||
1295 | class BeaconPhase(Figure): |
|
1300 | class BeaconPhase(Figure): | |
1296 |
|
1301 | |||
1297 | __isConfig = None |
|
1302 | __isConfig = None | |
1298 | __nsubplots = None |
|
1303 | __nsubplots = None | |
1299 |
|
1304 | |||
1300 | PREFIX = 'beacon_phase' |
|
1305 | PREFIX = 'beacon_phase' | |
1301 |
|
1306 | |||
1302 | def __init__(self): |
|
1307 | def __init__(self): | |
1303 |
|
1308 | |||
1304 | self.timerange = 24*60*60 |
|
1309 | self.timerange = 24*60*60 | |
1305 | self.isConfig = False |
|
1310 | self.isConfig = False | |
1306 | self.__nsubplots = 1 |
|
1311 | self.__nsubplots = 1 | |
1307 | self.counter_imagwr = 0 |
|
1312 | self.counter_imagwr = 0 | |
1308 | self.WIDTH = 800 |
|
1313 | self.WIDTH = 800 | |
1309 | self.HEIGHT = 400 |
|
1314 | self.HEIGHT = 400 | |
1310 | self.WIDTHPROF = 120 |
|
1315 | self.WIDTHPROF = 120 | |
1311 | self.HEIGHTPROF = 0 |
|
1316 | self.HEIGHTPROF = 0 | |
1312 | self.xdata = None |
|
1317 | self.xdata = None | |
1313 | self.ydata = None |
|
1318 | self.ydata = None | |
1314 |
|
1319 | |||
1315 | self.PLOT_CODE = BEACON_CODE |
|
1320 | self.PLOT_CODE = BEACON_CODE | |
1316 |
|
1321 | |||
1317 | self.FTP_WEI = None |
|
1322 | self.FTP_WEI = None | |
1318 | self.EXP_CODE = None |
|
1323 | self.EXP_CODE = None | |
1319 | self.SUB_EXP_CODE = None |
|
1324 | self.SUB_EXP_CODE = None | |
1320 | self.PLOT_POS = None |
|
1325 | self.PLOT_POS = None | |
1321 |
|
1326 | |||
1322 | self.filename_phase = None |
|
1327 | self.filename_phase = None | |
1323 |
|
1328 | |||
1324 | self.figfile = None |
|
1329 | self.figfile = None | |
1325 |
|
1330 | |||
1326 | self.xmin = None |
|
1331 | self.xmin = None | |
1327 | self.xmax = None |
|
1332 | self.xmax = None | |
1328 |
|
1333 | |||
1329 | def getSubplots(self): |
|
1334 | def getSubplots(self): | |
1330 |
|
1335 | |||
1331 | ncol = 1 |
|
1336 | ncol = 1 | |
1332 | nrow = 1 |
|
1337 | nrow = 1 | |
1333 |
|
1338 | |||
1334 | return nrow, ncol |
|
1339 | return nrow, ncol | |
1335 |
|
1340 | |||
1336 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1341 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1337 |
|
1342 | |||
1338 | self.__showprofile = showprofile |
|
1343 | self.__showprofile = showprofile | |
1339 | self.nplots = nplots |
|
1344 | self.nplots = nplots | |
1340 |
|
1345 | |||
1341 | ncolspan = 7 |
|
1346 | ncolspan = 7 | |
1342 | colspan = 6 |
|
1347 | colspan = 6 | |
1343 | self.__nsubplots = 2 |
|
1348 | self.__nsubplots = 2 | |
1344 |
|
1349 | |||
1345 | self.createFigure(id = id, |
|
1350 | self.createFigure(id = id, | |
1346 | wintitle = wintitle, |
|
1351 | wintitle = wintitle, | |
1347 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1352 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1348 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1353 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1349 | show=show) |
|
1354 | show=show) | |
1350 |
|
1355 | |||
1351 | nrow, ncol = self.getSubplots() |
|
1356 | nrow, ncol = self.getSubplots() | |
1352 |
|
1357 | |||
1353 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1358 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1354 |
|
1359 | |||
1355 | def save_phase(self, filename_phase): |
|
1360 | def save_phase(self, filename_phase): | |
1356 | f = open(filename_phase,'w+') |
|
1361 | f = open(filename_phase,'w+') | |
1357 | f.write('\n\n') |
|
1362 | f.write('\n\n') | |
1358 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') |
|
1363 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') | |
1359 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) |
|
1364 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) | |
1360 | f.close() |
|
1365 | f.close() | |
1361 |
|
1366 | |||
1362 | def save_data(self, filename_phase, data, data_datetime): |
|
1367 | def save_data(self, filename_phase, data, data_datetime): | |
1363 | f=open(filename_phase,'a') |
|
1368 | f=open(filename_phase,'a') | |
1364 | timetuple_data = data_datetime.timetuple() |
|
1369 | timetuple_data = data_datetime.timetuple() | |
1365 | day = str(timetuple_data.tm_mday) |
|
1370 | day = str(timetuple_data.tm_mday) | |
1366 | month = str(timetuple_data.tm_mon) |
|
1371 | month = str(timetuple_data.tm_mon) | |
1367 | year = str(timetuple_data.tm_year) |
|
1372 | year = str(timetuple_data.tm_year) | |
1368 | hour = str(timetuple_data.tm_hour) |
|
1373 | hour = str(timetuple_data.tm_hour) | |
1369 | minute = str(timetuple_data.tm_min) |
|
1374 | minute = str(timetuple_data.tm_min) | |
1370 | second = str(timetuple_data.tm_sec) |
|
1375 | second = str(timetuple_data.tm_sec) | |
1371 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') |
|
1376 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') | |
1372 | f.close() |
|
1377 | f.close() | |
1373 |
|
1378 | |||
1374 |
|
1379 | |||
1375 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1380 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
1376 | xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None, |
|
1381 | xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None, | |
1377 | timerange=None, |
|
1382 | timerange=None, | |
1378 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1383 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1379 | server=None, folder=None, username=None, password=None, |
|
1384 | server=None, folder=None, username=None, password=None, | |
1380 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1385 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1381 |
|
1386 | |||
1382 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): |
|
1387 | if not isTimeInHourRange(dataOut.datatime, xmin, xmax): | |
1383 | return |
|
1388 | return | |
1384 |
|
1389 | |||
1385 | if pairsList == None: |
|
1390 | if pairsList == None: | |
1386 | pairsIndexList = dataOut.pairsIndexList[:10] |
|
1391 | pairsIndexList = dataOut.pairsIndexList[:10] | |
1387 | else: |
|
1392 | else: | |
1388 | pairsIndexList = [] |
|
1393 | pairsIndexList = [] | |
1389 | for pair in pairsList: |
|
1394 | for pair in pairsList: | |
1390 | if pair not in dataOut.pairsList: |
|
1395 | if pair not in dataOut.pairsList: | |
1391 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
1396 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
1392 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
1397 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
1393 |
|
1398 | |||
1394 | if pairsIndexList == []: |
|
1399 | if pairsIndexList == []: | |
1395 | return |
|
1400 | return | |
1396 |
|
1401 | |||
1397 | # if len(pairsIndexList) > 4: |
|
1402 | # if len(pairsIndexList) > 4: | |
1398 | # pairsIndexList = pairsIndexList[0:4] |
|
1403 | # pairsIndexList = pairsIndexList[0:4] | |
1399 |
|
1404 | |||
1400 | hmin_index = None |
|
1405 | hmin_index = None | |
1401 | hmax_index = None |
|
1406 | hmax_index = None | |
1402 |
|
1407 | |||
1403 | if hmin != None and hmax != None: |
|
1408 | if hmin != None and hmax != None: | |
1404 | indexes = numpy.arange(dataOut.nHeights) |
|
1409 | indexes = numpy.arange(dataOut.nHeights) | |
1405 | hmin_list = indexes[dataOut.heightList >= hmin] |
|
1410 | hmin_list = indexes[dataOut.heightList >= hmin] | |
1406 | hmax_list = indexes[dataOut.heightList <= hmax] |
|
1411 | hmax_list = indexes[dataOut.heightList <= hmax] | |
1407 |
|
1412 | |||
1408 | if hmin_list.any(): |
|
1413 | if hmin_list.any(): | |
1409 | hmin_index = hmin_list[0] |
|
1414 | hmin_index = hmin_list[0] | |
1410 |
|
1415 | |||
1411 | if hmax_list.any(): |
|
1416 | if hmax_list.any(): | |
1412 | hmax_index = hmax_list[-1]+1 |
|
1417 | hmax_index = hmax_list[-1]+1 | |
1413 |
|
1418 | |||
1414 | x = dataOut.getTimeRange() |
|
1419 | x = dataOut.getTimeRange() | |
1415 | #y = dataOut.getHeiRange() |
|
1420 | #y = dataOut.getHeiRange() | |
1416 |
|
1421 | |||
1417 |
|
1422 | |||
1418 | thisDatetime = dataOut.datatime |
|
1423 | thisDatetime = dataOut.datatime | |
1419 |
|
1424 | |||
1420 | title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1425 | title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1421 | xlabel = "Local Time" |
|
1426 | xlabel = "Local Time" | |
1422 | ylabel = "Phase (degrees)" |
|
1427 | ylabel = "Phase (degrees)" | |
1423 |
|
1428 | |||
1424 | update_figfile = False |
|
1429 | update_figfile = False | |
1425 |
|
1430 | |||
1426 | nplots = len(pairsIndexList) |
|
1431 | nplots = len(pairsIndexList) | |
1427 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) |
|
1432 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) | |
1428 | phase_beacon = numpy.zeros(len(pairsIndexList)) |
|
1433 | phase_beacon = numpy.zeros(len(pairsIndexList)) | |
1429 | for i in range(nplots): |
|
1434 | for i in range(nplots): | |
1430 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
1435 | pair = dataOut.pairsList[pairsIndexList[i]] | |
1431 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0) |
|
1436 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0) | |
1432 | powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0) |
|
1437 | powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0) | |
1433 | powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0) |
|
1438 | powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0) | |
1434 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
1439 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
1435 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
1440 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
1436 |
|
1441 | |||
1437 | #print "Phase %d%d" %(pair[0], pair[1]) |
|
1442 | #print "Phase %d%d" %(pair[0], pair[1]) | |
1438 | #print phase[dataOut.beacon_heiIndexList] |
|
1443 | #print phase[dataOut.beacon_heiIndexList] | |
1439 |
|
1444 | |||
1440 | if dataOut.beacon_heiIndexList: |
|
1445 | if dataOut.beacon_heiIndexList: | |
1441 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) |
|
1446 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) | |
1442 | else: |
|
1447 | else: | |
1443 | phase_beacon[i] = numpy.average(phase) |
|
1448 | phase_beacon[i] = numpy.average(phase) | |
1444 |
|
1449 | |||
1445 | if not self.isConfig: |
|
1450 | if not self.isConfig: | |
1446 |
|
1451 | |||
1447 | nplots = len(pairsIndexList) |
|
1452 | nplots = len(pairsIndexList) | |
1448 |
|
1453 | |||
1449 | self.setup(id=id, |
|
1454 | self.setup(id=id, | |
1450 | nplots=nplots, |
|
1455 | nplots=nplots, | |
1451 | wintitle=wintitle, |
|
1456 | wintitle=wintitle, | |
1452 | showprofile=showprofile, |
|
1457 | showprofile=showprofile, | |
1453 | show=show) |
|
1458 | show=show) | |
1454 |
|
1459 | |||
1455 | if timerange != None: |
|
1460 | if timerange != None: | |
1456 | self.timerange = timerange |
|
1461 | self.timerange = timerange | |
1457 |
|
1462 | |||
1458 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1463 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1459 |
|
1464 | |||
1460 | if ymin == None: ymin = 0 |
|
1465 | if ymin == None: ymin = 0 | |
1461 | if ymax == None: ymax = 360 |
|
1466 | if ymax == None: ymax = 360 | |
1462 |
|
1467 | |||
1463 | self.FTP_WEI = ftp_wei |
|
1468 | self.FTP_WEI = ftp_wei | |
1464 | self.EXP_CODE = exp_code |
|
1469 | self.EXP_CODE = exp_code | |
1465 | self.SUB_EXP_CODE = sub_exp_code |
|
1470 | self.SUB_EXP_CODE = sub_exp_code | |
1466 | self.PLOT_POS = plot_pos |
|
1471 | self.PLOT_POS = plot_pos | |
1467 |
|
1472 | |||
1468 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1473 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1469 | self.isConfig = True |
|
1474 | self.isConfig = True | |
1470 | self.figfile = figfile |
|
1475 | self.figfile = figfile | |
1471 | self.xdata = numpy.array([]) |
|
1476 | self.xdata = numpy.array([]) | |
1472 | self.ydata = numpy.array([]) |
|
1477 | self.ydata = numpy.array([]) | |
1473 |
|
1478 | |||
1474 | update_figfile = True |
|
1479 | update_figfile = True | |
1475 |
|
1480 | |||
1476 | #open file beacon phase |
|
1481 | #open file beacon phase | |
1477 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1482 | path = '%s%03d' %(self.PREFIX, self.id) | |
1478 | beacon_file = os.path.join(path,'%s.txt'%self.name) |
|
1483 | beacon_file = os.path.join(path,'%s.txt'%self.name) | |
1479 | self.filename_phase = os.path.join(figpath,beacon_file) |
|
1484 | self.filename_phase = os.path.join(figpath,beacon_file) | |
1480 | #self.save_phase(self.filename_phase) |
|
1485 | #self.save_phase(self.filename_phase) | |
1481 |
|
1486 | |||
1482 |
|
1487 | |||
1483 | #store data beacon phase |
|
1488 | #store data beacon phase | |
1484 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) |
|
1489 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) | |
1485 |
|
1490 | |||
1486 | self.setWinTitle(title) |
|
1491 | self.setWinTitle(title) | |
1487 |
|
1492 | |||
1488 |
|
1493 | |||
1489 | title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1494 | title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1490 |
|
1495 | |||
1491 | legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList] |
|
1496 | legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList] | |
1492 |
|
1497 | |||
1493 | axes = self.axesList[0] |
|
1498 | axes = self.axesList[0] | |
1494 |
|
1499 | |||
1495 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1500 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1496 |
|
1501 | |||
1497 | if len(self.ydata)==0: |
|
1502 | if len(self.ydata)==0: | |
1498 | self.ydata = phase_beacon.reshape(-1,1) |
|
1503 | self.ydata = phase_beacon.reshape(-1,1) | |
1499 | else: |
|
1504 | else: | |
1500 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) |
|
1505 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) | |
1501 |
|
1506 | |||
1502 |
|
1507 | |||
1503 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1508 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1504 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, |
|
1509 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, | |
1505 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1510 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1506 | XAxisAsTime=True, grid='both' |
|
1511 | XAxisAsTime=True, grid='both' | |
1507 | ) |
|
1512 | ) | |
1508 |
|
1513 | |||
1509 | self.draw() |
|
1514 | self.draw() | |
1510 |
|
1515 | |||
1511 | if dataOut.ltctime >= self.xmax: |
|
1516 | if dataOut.ltctime >= self.xmax: | |
1512 | self.counter_imagwr = wr_period |
|
1517 | self.counter_imagwr = wr_period | |
1513 | self.isConfig = False |
|
1518 | self.isConfig = False | |
1514 | update_figfile = True |
|
1519 | update_figfile = True | |
1515 |
|
1520 | |||
1516 | self.save(figpath=figpath, |
|
1521 | self.save(figpath=figpath, | |
1517 | figfile=figfile, |
|
1522 | figfile=figfile, | |
1518 | save=save, |
|
1523 | save=save, | |
1519 | ftp=ftp, |
|
1524 | ftp=ftp, | |
1520 | wr_period=wr_period, |
|
1525 | wr_period=wr_period, | |
1521 | thisDatetime=thisDatetime, |
|
1526 | thisDatetime=thisDatetime, | |
1522 | update_figfile=update_figfile) |
|
1527 | update_figfile=update_figfile) |
General Comments 0
You need to be logged in to leave comments.
Login now