@@ -1,690 +1,690 | |||||
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 os, sys |
|
7 | import os, sys | |
8 | import copy |
|
8 | import copy | |
9 | import numpy |
|
9 | import numpy | |
10 | import datetime |
|
10 | import datetime | |
11 |
|
11 | import time | ||
12 | from jroheaderIO import SystemHeader, RadarControllerHeader |
|
12 | from jroheaderIO import SystemHeader, RadarControllerHeader | |
13 |
|
13 | |||
14 |
|
14 | |||
15 | def hildebrand_sekhon(data, navg): |
|
15 | def hildebrand_sekhon(data, navg): | |
16 |
|
16 | |||
17 | data = data.copy() |
|
17 | data = data.copy() | |
18 |
|
18 | |||
19 | sortdata = numpy.sort(data,axis=None) |
|
19 | sortdata = numpy.sort(data,axis=None) | |
20 | lenOfData = len(sortdata) |
|
20 | lenOfData = len(sortdata) | |
21 | nums_min = lenOfData/10 |
|
21 | nums_min = lenOfData/10 | |
22 |
|
22 | |||
23 | if (lenOfData/10) > 2: |
|
23 | if (lenOfData/10) > 2: | |
24 | nums_min = lenOfData/10 |
|
24 | nums_min = lenOfData/10 | |
25 | else: |
|
25 | else: | |
26 | nums_min = 2 |
|
26 | nums_min = 2 | |
27 |
|
27 | |||
28 | sump = 0. |
|
28 | sump = 0. | |
29 |
|
29 | |||
30 | sumq = 0. |
|
30 | sumq = 0. | |
31 |
|
31 | |||
32 | j = 0 |
|
32 | j = 0 | |
33 |
|
33 | |||
34 | cont = 1 |
|
34 | cont = 1 | |
35 |
|
35 | |||
36 | while((cont==1)and(j<lenOfData)): |
|
36 | while((cont==1)and(j<lenOfData)): | |
37 |
|
37 | |||
38 | sump += sortdata[j] |
|
38 | sump += sortdata[j] | |
39 |
|
39 | |||
40 | sumq += sortdata[j]**2 |
|
40 | sumq += sortdata[j]**2 | |
41 |
|
41 | |||
42 | j += 1 |
|
42 | j += 1 | |
43 |
|
43 | |||
44 | if j > nums_min: |
|
44 | if j > nums_min: | |
45 | rtest = float(j)/(j-1) + 1.0/navg |
|
45 | rtest = float(j)/(j-1) + 1.0/navg | |
46 | if ((sumq*j) > (rtest*sump**2)): |
|
46 | if ((sumq*j) > (rtest*sump**2)): | |
47 | j = j - 1 |
|
47 | j = j - 1 | |
48 | sump = sump - sortdata[j] |
|
48 | sump = sump - sortdata[j] | |
49 | sumq = sumq - sortdata[j]**2 |
|
49 | sumq = sumq - sortdata[j]**2 | |
50 | cont = 0 |
|
50 | cont = 0 | |
51 |
|
51 | |||
52 | lnoise = sump /j |
|
52 | lnoise = sump /j | |
53 | stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1)) |
|
53 | stdv = numpy.sqrt((sumq - lnoise**2)/(j - 1)) | |
54 | return lnoise |
|
54 | return lnoise | |
55 |
|
55 | |||
56 | class JROData: |
|
56 | class JROData: | |
57 |
|
57 | |||
58 | # m_BasicHeader = BasicHeader() |
|
58 | # m_BasicHeader = BasicHeader() | |
59 | # m_ProcessingHeader = ProcessingHeader() |
|
59 | # m_ProcessingHeader = ProcessingHeader() | |
60 |
|
60 | |||
61 | systemHeaderObj = SystemHeader() |
|
61 | systemHeaderObj = SystemHeader() | |
62 |
|
62 | |||
63 | radarControllerHeaderObj = RadarControllerHeader() |
|
63 | radarControllerHeaderObj = RadarControllerHeader() | |
64 |
|
64 | |||
65 | # data = None |
|
65 | # data = None | |
66 |
|
66 | |||
67 | type = None |
|
67 | type = None | |
68 |
|
68 | |||
69 | dtype = None |
|
69 | dtype = None | |
70 |
|
70 | |||
71 | # nChannels = None |
|
71 | # nChannels = None | |
72 |
|
72 | |||
73 | # nHeights = None |
|
73 | # nHeights = None | |
74 |
|
74 | |||
75 | nProfiles = None |
|
75 | nProfiles = None | |
76 |
|
76 | |||
77 | heightList = None |
|
77 | heightList = None | |
78 |
|
78 | |||
79 | channelList = None |
|
79 | channelList = None | |
80 |
|
80 | |||
81 | flagNoData = True |
|
81 | flagNoData = True | |
82 |
|
82 | |||
83 | flagTimeBlock = False |
|
83 | flagTimeBlock = False | |
84 |
|
84 | |||
85 | useLocalTime = False |
|
85 | useLocalTime = False | |
86 |
|
86 | |||
87 | utctime = None |
|
87 | utctime = None | |
88 |
|
88 | |||
89 | timeZone = None |
|
89 | timeZone = None | |
90 |
|
90 | |||
91 | dstFlag = None |
|
91 | dstFlag = None | |
92 |
|
92 | |||
93 | errorCount = None |
|
93 | errorCount = None | |
94 |
|
94 | |||
95 | blocksize = None |
|
95 | blocksize = None | |
96 |
|
96 | |||
97 | nCode = None |
|
97 | nCode = None | |
98 |
|
98 | |||
99 | nBaud = None |
|
99 | nBaud = None | |
100 |
|
100 | |||
101 | code = None |
|
101 | code = None | |
102 |
|
102 | |||
103 | flagDecodeData = False #asumo q la data no esta decodificada |
|
103 | flagDecodeData = False #asumo q la data no esta decodificada | |
104 |
|
104 | |||
105 | flagDeflipData = False #asumo q la data no esta sin flip |
|
105 | flagDeflipData = False #asumo q la data no esta sin flip | |
106 |
|
106 | |||
107 | flagShiftFFT = False |
|
107 | flagShiftFFT = False | |
108 |
|
108 | |||
109 | ippSeconds = None |
|
109 | ippSeconds = None | |
110 |
|
110 | |||
111 | timeInterval = None |
|
111 | timeInterval = None | |
112 |
|
112 | |||
113 | nCohInt = None |
|
113 | nCohInt = None | |
114 |
|
114 | |||
115 | noise = None |
|
115 | noise = None | |
116 |
|
116 | |||
117 | windowOfFilter = 1 |
|
117 | windowOfFilter = 1 | |
118 |
|
118 | |||
119 | #Speed of ligth |
|
119 | #Speed of ligth | |
120 | C = 3e8 |
|
120 | C = 3e8 | |
121 |
|
121 | |||
122 | frequency = 49.92e6 |
|
122 | frequency = 49.92e6 | |
123 |
|
123 | |||
124 | realtime = False |
|
124 | realtime = False | |
125 |
|
125 | |||
126 | beacon_heiIndexList = None |
|
126 | beacon_heiIndexList = None | |
127 |
|
127 | |||
128 | last_block = None |
|
128 | last_block = None | |
129 |
|
129 | |||
130 | blocknow = None |
|
130 | blocknow = None | |
131 |
|
131 | |||
132 | def __init__(self): |
|
132 | def __init__(self): | |
133 |
|
133 | |||
134 | raise ValueError, "This class has not been implemented" |
|
134 | raise ValueError, "This class has not been implemented" | |
135 |
|
135 | |||
136 | def copy(self, inputObj=None): |
|
136 | def copy(self, inputObj=None): | |
137 |
|
137 | |||
138 | if inputObj == None: |
|
138 | if inputObj == None: | |
139 | return copy.deepcopy(self) |
|
139 | return copy.deepcopy(self) | |
140 |
|
140 | |||
141 | for key in inputObj.__dict__.keys(): |
|
141 | for key in inputObj.__dict__.keys(): | |
142 | self.__dict__[key] = inputObj.__dict__[key] |
|
142 | self.__dict__[key] = inputObj.__dict__[key] | |
143 |
|
143 | |||
144 | def deepcopy(self): |
|
144 | def deepcopy(self): | |
145 |
|
145 | |||
146 | return copy.deepcopy(self) |
|
146 | return copy.deepcopy(self) | |
147 |
|
147 | |||
148 | def isEmpty(self): |
|
148 | def isEmpty(self): | |
149 |
|
149 | |||
150 | return self.flagNoData |
|
150 | return self.flagNoData | |
151 |
|
151 | |||
152 | def getNoise(self): |
|
152 | def getNoise(self): | |
153 |
|
153 | |||
154 | raise ValueError, "Not implemented" |
|
154 | raise ValueError, "Not implemented" | |
155 |
|
155 | |||
156 | def getNChannels(self): |
|
156 | def getNChannels(self): | |
157 |
|
157 | |||
158 | return len(self.channelList) |
|
158 | return len(self.channelList) | |
159 |
|
159 | |||
160 | def getChannelIndexList(self): |
|
160 | def getChannelIndexList(self): | |
161 |
|
161 | |||
162 | return range(self.nChannels) |
|
162 | return range(self.nChannels) | |
163 |
|
163 | |||
164 | def getNHeights(self): |
|
164 | def getNHeights(self): | |
165 |
|
165 | |||
166 | return len(self.heightList) |
|
166 | return len(self.heightList) | |
167 |
|
167 | |||
168 | def getHeiRange(self, extrapoints=0): |
|
168 | def getHeiRange(self, extrapoints=0): | |
169 |
|
169 | |||
170 | heis = self.heightList |
|
170 | heis = self.heightList | |
171 | # deltah = self.heightList[1] - self.heightList[0] |
|
171 | # deltah = self.heightList[1] - self.heightList[0] | |
172 | # |
|
172 | # | |
173 | # heis.append(self.heightList[-1]) |
|
173 | # heis.append(self.heightList[-1]) | |
174 |
|
174 | |||
175 | return heis |
|
175 | return heis | |
176 |
|
176 | |||
177 | def getltctime(self): |
|
177 | def getltctime(self): | |
178 |
|
178 | |||
179 | if self.useLocalTime: |
|
179 | if self.useLocalTime: | |
180 | return self.utctime - self.timeZone*60 |
|
180 | return self.utctime - self.timeZone*60 | |
181 |
|
181 | |||
182 | return self.utctime |
|
182 | return self.utctime | |
183 |
|
183 | |||
184 | def getDatatime(self): |
|
184 | def getDatatime(self): | |
185 |
|
185 | |||
186 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
186 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) | |
187 | return datatime |
|
187 | return datatime | |
188 |
|
188 | |||
189 | def getTimeRange(self): |
|
189 | def getTimeRange(self): | |
190 |
|
190 | |||
191 | datatime = [] |
|
191 | datatime = [] | |
192 |
|
192 | |||
193 | datatime.append(self.ltctime) |
|
193 | datatime.append(self.ltctime) | |
194 | datatime.append(self.ltctime + self.timeInterval) |
|
194 | datatime.append(self.ltctime + self.timeInterval) | |
195 |
|
195 | |||
196 | datatime = numpy.array(datatime) |
|
196 | datatime = numpy.array(datatime) | |
197 |
|
197 | |||
198 | return datatime |
|
198 | return datatime | |
199 |
|
199 | |||
200 | def getFmax(self): |
|
200 | def getFmax(self): | |
201 |
|
201 | |||
202 | PRF = 1./(self.ippSeconds * self.nCohInt) |
|
202 | PRF = 1./(self.ippSeconds * self.nCohInt) | |
203 |
|
203 | |||
204 | fmax = PRF/2. |
|
204 | fmax = PRF/2. | |
205 |
|
205 | |||
206 | return fmax |
|
206 | return fmax | |
207 |
|
207 | |||
208 | def getVmax(self): |
|
208 | def getVmax(self): | |
209 |
|
209 | |||
210 | _lambda = self.C/self.frequency |
|
210 | _lambda = self.C/self.frequency | |
211 |
|
211 | |||
212 | vmax = self.getFmax() * _lambda |
|
212 | vmax = self.getFmax() * _lambda | |
213 |
|
213 | |||
214 | return vmax |
|
214 | return vmax | |
215 |
|
215 | |||
216 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
216 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
217 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
217 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
218 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
218 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
219 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
219 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
220 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
220 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
221 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
221 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
222 |
|
222 | |||
223 | class Voltage(JROData): |
|
223 | class Voltage(JROData): | |
224 |
|
224 | |||
225 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
225 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
226 | data = None |
|
226 | data = None | |
227 |
|
227 | |||
228 | def __init__(self): |
|
228 | def __init__(self): | |
229 | ''' |
|
229 | ''' | |
230 | Constructor |
|
230 | Constructor | |
231 | ''' |
|
231 | ''' | |
232 |
|
232 | |||
233 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
233 | self.radarControllerHeaderObj = RadarControllerHeader() | |
234 |
|
234 | |||
235 | self.systemHeaderObj = SystemHeader() |
|
235 | self.systemHeaderObj = SystemHeader() | |
236 |
|
236 | |||
237 | self.type = "Voltage" |
|
237 | self.type = "Voltage" | |
238 |
|
238 | |||
239 | self.data = None |
|
239 | self.data = None | |
240 |
|
240 | |||
241 | self.dtype = None |
|
241 | self.dtype = None | |
242 |
|
242 | |||
243 | # self.nChannels = 0 |
|
243 | # self.nChannels = 0 | |
244 |
|
244 | |||
245 | # self.nHeights = 0 |
|
245 | # self.nHeights = 0 | |
246 |
|
246 | |||
247 | self.nProfiles = None |
|
247 | self.nProfiles = None | |
248 |
|
248 | |||
249 | self.heightList = None |
|
249 | self.heightList = None | |
250 |
|
250 | |||
251 | self.channelList = None |
|
251 | self.channelList = None | |
252 |
|
252 | |||
253 | # self.channelIndexList = None |
|
253 | # self.channelIndexList = None | |
254 |
|
254 | |||
255 | self.flagNoData = True |
|
255 | self.flagNoData = True | |
256 |
|
256 | |||
257 | self.flagTimeBlock = False |
|
257 | self.flagTimeBlock = False | |
258 |
|
258 | |||
259 | self.utctime = None |
|
259 | self.utctime = None | |
260 |
|
260 | |||
261 | self.timeZone = None |
|
261 | self.timeZone = None | |
262 |
|
262 | |||
263 | self.dstFlag = None |
|
263 | self.dstFlag = None | |
264 |
|
264 | |||
265 | self.errorCount = None |
|
265 | self.errorCount = None | |
266 |
|
266 | |||
267 | self.nCohInt = None |
|
267 | self.nCohInt = None | |
268 |
|
268 | |||
269 | self.blocksize = None |
|
269 | self.blocksize = None | |
270 |
|
270 | |||
271 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
271 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
272 |
|
272 | |||
273 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
273 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
274 |
|
274 | |||
275 | self.flagShiftFFT = False |
|
275 | self.flagShiftFFT = False | |
276 |
|
276 | |||
277 |
|
277 | |||
278 | def getNoisebyHildebrand(self): |
|
278 | def getNoisebyHildebrand(self): | |
279 | """ |
|
279 | """ | |
280 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
280 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
281 |
|
281 | |||
282 | Return: |
|
282 | Return: | |
283 | noiselevel |
|
283 | noiselevel | |
284 | """ |
|
284 | """ | |
285 |
|
285 | |||
286 | for channel in range(self.nChannels): |
|
286 | for channel in range(self.nChannels): | |
287 | daux = self.data_spc[channel,:,:] |
|
287 | daux = self.data_spc[channel,:,:] | |
288 | self.noise[channel] = hildebrand_sekhon(daux, self.nCohInt) |
|
288 | self.noise[channel] = hildebrand_sekhon(daux, self.nCohInt) | |
289 |
|
289 | |||
290 | return self.noise |
|
290 | return self.noise | |
291 |
|
291 | |||
292 | def getNoise(self, type = 1): |
|
292 | def getNoise(self, type = 1): | |
293 |
|
293 | |||
294 | self.noise = numpy.zeros(self.nChannels) |
|
294 | self.noise = numpy.zeros(self.nChannels) | |
295 |
|
295 | |||
296 | if type == 1: |
|
296 | if type == 1: | |
297 | noise = self.getNoisebyHildebrand() |
|
297 | noise = self.getNoisebyHildebrand() | |
298 |
|
298 | |||
299 | return 10*numpy.log10(noise) |
|
299 | return 10*numpy.log10(noise) | |
300 |
|
300 | |||
301 | class Spectra(JROData): |
|
301 | class Spectra(JROData): | |
302 |
|
302 | |||
303 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) |
|
303 | #data es un numpy array de 2 dmensiones (canales, perfiles, alturas) | |
304 | data_spc = None |
|
304 | data_spc = None | |
305 |
|
305 | |||
306 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) |
|
306 | #data es un numpy array de 2 dmensiones (canales, pares, alturas) | |
307 | data_cspc = None |
|
307 | data_cspc = None | |
308 |
|
308 | |||
309 | #data es un numpy array de 2 dmensiones (canales, alturas) |
|
309 | #data es un numpy array de 2 dmensiones (canales, alturas) | |
310 | data_dc = None |
|
310 | data_dc = None | |
311 |
|
311 | |||
312 | nFFTPoints = None |
|
312 | nFFTPoints = None | |
313 |
|
313 | |||
314 | nPairs = None |
|
314 | nPairs = None | |
315 |
|
315 | |||
316 | pairsList = None |
|
316 | pairsList = None | |
317 |
|
317 | |||
318 | nIncohInt = None |
|
318 | nIncohInt = None | |
319 |
|
319 | |||
320 | wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia |
|
320 | wavelength = None #Necesario para cacular el rango de velocidad desde la frecuencia | |
321 |
|
321 | |||
322 | nCohInt = None #se requiere para determinar el valor de timeInterval |
|
322 | nCohInt = None #se requiere para determinar el valor de timeInterval | |
323 |
|
323 | |||
324 | ippFactor = None |
|
324 | ippFactor = None | |
325 |
|
325 | |||
326 | def __init__(self): |
|
326 | def __init__(self): | |
327 | ''' |
|
327 | ''' | |
328 | Constructor |
|
328 | Constructor | |
329 | ''' |
|
329 | ''' | |
330 |
|
330 | |||
331 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
331 | self.radarControllerHeaderObj = RadarControllerHeader() | |
332 |
|
332 | |||
333 | self.systemHeaderObj = SystemHeader() |
|
333 | self.systemHeaderObj = SystemHeader() | |
334 |
|
334 | |||
335 | self.type = "Spectra" |
|
335 | self.type = "Spectra" | |
336 |
|
336 | |||
337 | # self.data = None |
|
337 | # self.data = None | |
338 |
|
338 | |||
339 | self.dtype = None |
|
339 | self.dtype = None | |
340 |
|
340 | |||
341 | # self.nChannels = 0 |
|
341 | # self.nChannels = 0 | |
342 |
|
342 | |||
343 | # self.nHeights = 0 |
|
343 | # self.nHeights = 0 | |
344 |
|
344 | |||
345 | self.nProfiles = None |
|
345 | self.nProfiles = None | |
346 |
|
346 | |||
347 | self.heightList = None |
|
347 | self.heightList = None | |
348 |
|
348 | |||
349 | self.channelList = None |
|
349 | self.channelList = None | |
350 |
|
350 | |||
351 | # self.channelIndexList = None |
|
351 | # self.channelIndexList = None | |
352 |
|
352 | |||
353 | self.flagNoData = True |
|
353 | self.flagNoData = True | |
354 |
|
354 | |||
355 | self.flagTimeBlock = False |
|
355 | self.flagTimeBlock = False | |
356 |
|
356 | |||
357 | self.utctime = None |
|
357 | self.utctime = None | |
358 |
|
358 | |||
359 | self.nCohInt = None |
|
359 | self.nCohInt = None | |
360 |
|
360 | |||
361 | self.nIncohInt = None |
|
361 | self.nIncohInt = None | |
362 |
|
362 | |||
363 | self.blocksize = None |
|
363 | self.blocksize = None | |
364 |
|
364 | |||
365 | self.nFFTPoints = None |
|
365 | self.nFFTPoints = None | |
366 |
|
366 | |||
367 | self.wavelength = None |
|
367 | self.wavelength = None | |
368 |
|
368 | |||
369 | self.flagDecodeData = False #asumo q la data no esta decodificada |
|
369 | self.flagDecodeData = False #asumo q la data no esta decodificada | |
370 |
|
370 | |||
371 | self.flagDeflipData = False #asumo q la data no esta sin flip |
|
371 | self.flagDeflipData = False #asumo q la data no esta sin flip | |
372 |
|
372 | |||
373 | self.flagShiftFFT = False |
|
373 | self.flagShiftFFT = False | |
374 |
|
374 | |||
375 | self.ippFactor = 1 |
|
375 | self.ippFactor = 1 | |
376 |
|
376 | |||
377 | self.noise = None |
|
377 | self.noise = None | |
378 |
|
378 | |||
379 | self.beacon_heiIndexList = [] |
|
379 | self.beacon_heiIndexList = [] | |
380 |
|
380 | |||
381 |
|
381 | |||
382 | def getNoisebyHildebrand(self): |
|
382 | def getNoisebyHildebrand(self): | |
383 | """ |
|
383 | """ | |
384 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon |
|
384 | Determino el nivel de ruido usando el metodo Hildebrand-Sekhon | |
385 |
|
385 | |||
386 | Return: |
|
386 | Return: | |
387 | noiselevel |
|
387 | noiselevel | |
388 | """ |
|
388 | """ | |
389 | noise = numpy.zeros(self.nChannels) |
|
389 | noise = numpy.zeros(self.nChannels) | |
390 | for channel in range(self.nChannels): |
|
390 | for channel in range(self.nChannels): | |
391 | daux = self.data_spc[channel,:,:] |
|
391 | daux = self.data_spc[channel,:,:] | |
392 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) |
|
392 | noise[channel] = hildebrand_sekhon(daux, self.nIncohInt) | |
393 |
|
393 | |||
394 | return noise |
|
394 | return noise | |
395 |
|
395 | |||
396 | def getNoise(self): |
|
396 | def getNoise(self): | |
397 | if self.noise != None: |
|
397 | if self.noise != None: | |
398 | return self.noise |
|
398 | return self.noise | |
399 | else: |
|
399 | else: | |
400 | noise = self.getNoisebyHildebrand() |
|
400 | noise = self.getNoisebyHildebrand() | |
401 | return noise |
|
401 | return noise | |
402 |
|
402 | |||
403 |
|
403 | |||
404 | def getFreqRange(self, extrapoints=0): |
|
404 | def getFreqRange(self, extrapoints=0): | |
405 |
|
405 | |||
406 | deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor) |
|
406 | deltafreq = self.getFmax() / (self.nFFTPoints*self.ippFactor) | |
407 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 |
|
407 | freqrange = deltafreq*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltafreq/2 | |
408 |
|
408 | |||
409 | return freqrange |
|
409 | return freqrange | |
410 |
|
410 | |||
411 | def getVelRange(self, extrapoints=0): |
|
411 | def getVelRange(self, extrapoints=0): | |
412 |
|
412 | |||
413 | deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor) |
|
413 | deltav = self.getVmax() / (self.nFFTPoints*self.ippFactor) | |
414 | velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2 |
|
414 | velrange = deltav*(numpy.arange(self.nFFTPoints+extrapoints)-self.nFFTPoints/2.) - deltav/2 | |
415 |
|
415 | |||
416 | return velrange |
|
416 | return velrange | |
417 |
|
417 | |||
418 | def getNPairs(self): |
|
418 | def getNPairs(self): | |
419 |
|
419 | |||
420 | return len(self.pairsList) |
|
420 | return len(self.pairsList) | |
421 |
|
421 | |||
422 | def getPairsIndexList(self): |
|
422 | def getPairsIndexList(self): | |
423 |
|
423 | |||
424 | return range(self.nPairs) |
|
424 | return range(self.nPairs) | |
425 |
|
425 | |||
426 | def getNormFactor(self): |
|
426 | def getNormFactor(self): | |
427 | pwcode = 1 |
|
427 | pwcode = 1 | |
428 | if self.flagDecodeData: |
|
428 | if self.flagDecodeData: | |
429 | pwcode = numpy.sum(self.code[0]**2) |
|
429 | pwcode = numpy.sum(self.code[0]**2) | |
430 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
430 | #normFactor = min(self.nFFTPoints,self.nProfiles)*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
431 | normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter |
|
431 | normFactor = self.nProfiles*self.nIncohInt*self.nCohInt*pwcode*self.windowOfFilter | |
432 |
|
432 | |||
433 | return normFactor |
|
433 | return normFactor | |
434 |
|
434 | |||
435 | def getFlagCspc(self): |
|
435 | def getFlagCspc(self): | |
436 |
|
436 | |||
437 | if self.data_cspc == None: |
|
437 | if self.data_cspc == None: | |
438 | return True |
|
438 | return True | |
439 |
|
439 | |||
440 | return False |
|
440 | return False | |
441 |
|
441 | |||
442 | def getFlagDc(self): |
|
442 | def getFlagDc(self): | |
443 |
|
443 | |||
444 | if self.data_dc == None: |
|
444 | if self.data_dc == None: | |
445 | return True |
|
445 | return True | |
446 |
|
446 | |||
447 | return False |
|
447 | return False | |
448 |
|
448 | |||
449 | nPairs = property(getNPairs, "I'm the 'nPairs' property.") |
|
449 | nPairs = property(getNPairs, "I'm the 'nPairs' property.") | |
450 | pairsIndexList = property(getPairsIndexList, "I'm the 'pairsIndexList' property.") |
|
450 | pairsIndexList = property(getPairsIndexList, "I'm the 'pairsIndexList' property.") | |
451 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") |
|
451 | normFactor = property(getNormFactor, "I'm the 'getNormFactor' property.") | |
452 | flag_cspc = property(getFlagCspc) |
|
452 | flag_cspc = property(getFlagCspc) | |
453 | flag_dc = property(getFlagDc) |
|
453 | flag_dc = property(getFlagDc) | |
454 |
|
454 | |||
455 | class SpectraHeis(JROData): |
|
455 | class SpectraHeis(JROData): | |
456 |
|
456 | |||
457 | data_spc = None |
|
457 | data_spc = None | |
458 |
|
458 | |||
459 | data_cspc = None |
|
459 | data_cspc = None | |
460 |
|
460 | |||
461 | data_dc = None |
|
461 | data_dc = None | |
462 |
|
462 | |||
463 | nFFTPoints = None |
|
463 | nFFTPoints = None | |
464 |
|
464 | |||
465 | nPairs = None |
|
465 | nPairs = None | |
466 |
|
466 | |||
467 | pairsList = None |
|
467 | pairsList = None | |
468 |
|
468 | |||
469 | nIncohInt = None |
|
469 | nIncohInt = None | |
470 |
|
470 | |||
471 | def __init__(self): |
|
471 | def __init__(self): | |
472 |
|
472 | |||
473 | self.radarControllerHeaderObj = RadarControllerHeader() |
|
473 | self.radarControllerHeaderObj = RadarControllerHeader() | |
474 |
|
474 | |||
475 | self.systemHeaderObj = SystemHeader() |
|
475 | self.systemHeaderObj = SystemHeader() | |
476 |
|
476 | |||
477 | self.type = "SpectraHeis" |
|
477 | self.type = "SpectraHeis" | |
478 |
|
478 | |||
479 | self.dtype = None |
|
479 | self.dtype = None | |
480 |
|
480 | |||
481 | # self.nChannels = 0 |
|
481 | # self.nChannels = 0 | |
482 |
|
482 | |||
483 | # self.nHeights = 0 |
|
483 | # self.nHeights = 0 | |
484 |
|
484 | |||
485 | self.nProfiles = None |
|
485 | self.nProfiles = None | |
486 |
|
486 | |||
487 | self.heightList = None |
|
487 | self.heightList = None | |
488 |
|
488 | |||
489 | self.channelList = None |
|
489 | self.channelList = None | |
490 |
|
490 | |||
491 | # self.channelIndexList = None |
|
491 | # self.channelIndexList = None | |
492 |
|
492 | |||
493 | self.flagNoData = True |
|
493 | self.flagNoData = True | |
494 |
|
494 | |||
495 | self.flagTimeBlock = False |
|
495 | self.flagTimeBlock = False | |
496 |
|
496 | |||
497 | self.nPairs = 0 |
|
497 | self.nPairs = 0 | |
498 |
|
498 | |||
499 | self.utctime = None |
|
499 | self.utctime = None | |
500 |
|
500 | |||
501 | self.blocksize = None |
|
501 | self.blocksize = None | |
502 |
|
502 | |||
503 | class Fits: |
|
503 | class Fits: | |
504 |
|
504 | |||
505 | heightList = None |
|
505 | heightList = None | |
506 |
|
506 | |||
507 | channelList = None |
|
507 | channelList = None | |
508 |
|
508 | |||
509 | flagNoData = True |
|
509 | flagNoData = True | |
510 |
|
510 | |||
511 | flagTimeBlock = False |
|
511 | flagTimeBlock = False | |
512 |
|
512 | |||
513 | useLocalTime = False |
|
513 | useLocalTime = False | |
514 |
|
514 | |||
515 | utctime = None |
|
515 | utctime = None | |
516 |
|
516 | |||
517 | timeZone = None |
|
517 | timeZone = None | |
518 |
|
518 | |||
519 | ippSeconds = None |
|
519 | ippSeconds = None | |
520 |
|
520 | |||
521 | timeInterval = None |
|
521 | timeInterval = None | |
522 |
|
522 | |||
523 | nCohInt = None |
|
523 | nCohInt = None | |
524 |
|
524 | |||
525 | nIncohInt = None |
|
525 | nIncohInt = None | |
526 |
|
526 | |||
527 | noise = None |
|
527 | noise = None | |
528 |
|
528 | |||
529 | windowOfFilter = 1 |
|
529 | windowOfFilter = 1 | |
530 |
|
530 | |||
531 | #Speed of ligth |
|
531 | #Speed of ligth | |
532 | C = 3e8 |
|
532 | C = 3e8 | |
533 |
|
533 | |||
534 | frequency = 49.92e6 |
|
534 | frequency = 49.92e6 | |
535 |
|
535 | |||
536 | realtime = False |
|
536 | realtime = False | |
537 |
|
537 | |||
538 |
|
538 | |||
539 | def __init__(self): |
|
539 | def __init__(self): | |
540 |
|
540 | |||
541 | self.type = "Fits" |
|
541 | self.type = "Fits" | |
542 |
|
542 | |||
543 | self.nProfiles = None |
|
543 | self.nProfiles = None | |
544 |
|
544 | |||
545 | self.heightList = None |
|
545 | self.heightList = None | |
546 |
|
546 | |||
547 | self.channelList = None |
|
547 | self.channelList = None | |
548 |
|
548 | |||
549 | # self.channelIndexList = None |
|
549 | # self.channelIndexList = None | |
550 |
|
550 | |||
551 | self.flagNoData = True |
|
551 | self.flagNoData = True | |
552 |
|
552 | |||
553 | self.utctime = None |
|
553 | self.utctime = None | |
554 |
|
554 | |||
555 | self.nCohInt = None |
|
555 | self.nCohInt = None | |
556 |
|
556 | |||
557 | self.nIncohInt = None |
|
557 | self.nIncohInt = None | |
558 |
|
558 | |||
559 | self.useLocalTime = True |
|
559 | self.useLocalTime = True | |
560 |
|
560 | |||
561 | # self.utctime = None |
|
561 | # self.utctime = None | |
562 | # self.timeZone = None |
|
562 | # self.timeZone = None | |
563 | # self.ltctime = None |
|
563 | # self.ltctime = None | |
564 | # self.timeInterval = None |
|
564 | # self.timeInterval = None | |
565 | # self.header = None |
|
565 | # self.header = None | |
566 | # self.data_header = None |
|
566 | # self.data_header = None | |
567 | # self.data = None |
|
567 | # self.data = None | |
568 | # self.datatime = None |
|
568 | # self.datatime = None | |
569 | # self.flagNoData = False |
|
569 | # self.flagNoData = False | |
570 | # self.expName = '' |
|
570 | # self.expName = '' | |
571 | # self.nChannels = None |
|
571 | # self.nChannels = None | |
572 | # self.nSamples = None |
|
572 | # self.nSamples = None | |
573 | # self.dataBlocksPerFile = None |
|
573 | # self.dataBlocksPerFile = None | |
574 | # self.comments = '' |
|
574 | # self.comments = '' | |
575 | # |
|
575 | # | |
576 |
|
576 | |||
577 |
|
577 | |||
578 | def getltctime(self): |
|
578 | def getltctime(self): | |
579 |
|
579 | |||
580 | if self.useLocalTime: |
|
580 | if self.useLocalTime: | |
581 | return self.utctime - self.timeZone*60 |
|
581 | return self.utctime - self.timeZone*60 | |
582 |
|
582 | |||
583 | return self.utctime |
|
583 | return self.utctime | |
584 |
|
584 | |||
585 | def getDatatime(self): |
|
585 | def getDatatime(self): | |
586 |
|
586 | |||
587 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) |
|
587 | datatime = datetime.datetime.utcfromtimestamp(self.ltctime) | |
588 | return datatime |
|
588 | return datatime | |
589 |
|
589 | |||
590 | def getTimeRange(self): |
|
590 | def getTimeRange(self): | |
591 |
|
591 | |||
592 | datatime = [] |
|
592 | datatime = [] | |
593 |
|
593 | |||
594 | datatime.append(self.ltctime) |
|
594 | datatime.append(self.ltctime) | |
595 | datatime.append(self.ltctime + self.timeInterval) |
|
595 | datatime.append(self.ltctime + self.timeInterval) | |
596 |
|
596 | |||
597 | datatime = numpy.array(datatime) |
|
597 | datatime = numpy.array(datatime) | |
598 |
|
598 | |||
599 | return datatime |
|
599 | return datatime | |
600 |
|
600 | |||
601 | def getHeiRange(self): |
|
601 | def getHeiRange(self): | |
602 |
|
602 | |||
603 | heis = self.heightList |
|
603 | heis = self.heightList | |
604 |
|
604 | |||
605 | return heis |
|
605 | return heis | |
606 |
|
606 | |||
607 | def isEmpty(self): |
|
607 | def isEmpty(self): | |
608 |
|
608 | |||
609 | return self.flagNoData |
|
609 | return self.flagNoData | |
610 |
|
610 | |||
611 | def getNHeights(self): |
|
611 | def getNHeights(self): | |
612 |
|
612 | |||
613 | return len(self.heightList) |
|
613 | return len(self.heightList) | |
614 |
|
614 | |||
615 | def getNChannels(self): |
|
615 | def getNChannels(self): | |
616 |
|
616 | |||
617 | return len(self.channelList) |
|
617 | return len(self.channelList) | |
618 |
|
618 | |||
619 | def getChannelIndexList(self): |
|
619 | def getChannelIndexList(self): | |
620 |
|
620 | |||
621 | return range(self.nChannels) |
|
621 | return range(self.nChannels) | |
622 |
|
622 | |||
623 | def getNoise(self, type = 1): |
|
623 | def getNoise(self, type = 1): | |
624 |
|
624 | |||
625 | self.noise = numpy.zeros(self.nChannels) |
|
625 | self.noise = numpy.zeros(self.nChannels) | |
626 |
|
626 | |||
627 | if type == 1: |
|
627 | if type == 1: | |
628 | noise = self.getNoisebyHildebrand() |
|
628 | noise = self.getNoisebyHildebrand() | |
629 |
|
629 | |||
630 | if type == 2: |
|
630 | if type == 2: | |
631 | noise = self.getNoisebySort() |
|
631 | noise = self.getNoisebySort() | |
632 |
|
632 | |||
633 | if type == 3: |
|
633 | if type == 3: | |
634 | noise = self.getNoisebyWindow() |
|
634 | noise = self.getNoisebyWindow() | |
635 |
|
635 | |||
636 | return noise |
|
636 | return noise | |
637 |
|
637 | |||
638 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
638 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
639 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") |
|
639 | nHeights = property(getNHeights, "I'm the 'nHeights' property.") | |
640 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") |
|
640 | nChannels = property(getNChannels, "I'm the 'nChannel' property.") | |
641 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") |
|
641 | channelIndexList = property(getChannelIndexList, "I'm the 'channelIndexList' property.") | |
642 | noise = property(getNoise, "I'm the 'nHeights' property.") |
|
642 | noise = property(getNoise, "I'm the 'nHeights' property.") | |
643 | datatime = property(getDatatime, "I'm the 'datatime' property") |
|
643 | datatime = property(getDatatime, "I'm the 'datatime' property") | |
644 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
644 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
645 |
|
645 | |||
646 | ltctime = property(getltctime, "I'm the 'ltctime' property") |
|
646 | ltctime = property(getltctime, "I'm the 'ltctime' property") | |
647 |
|
647 | |||
648 | class AMISR: |
|
648 | class AMISR: | |
649 | def __init__(self): |
|
649 | def __init__(self): | |
650 | self.flagNoData = True |
|
650 | self.flagNoData = True | |
651 | self.data = None |
|
651 | self.data = None | |
652 | self.utctime = None |
|
652 | self.utctime = None | |
653 | self.type = "AMISR" |
|
653 | self.type = "AMISR" | |
654 |
|
654 | |||
655 | #propiedades para compatibilidad con Voltages |
|
655 | #propiedades para compatibilidad con Voltages | |
656 | self.timeZone = 0#self.dataIn.timeZone |
|
656 | self.timeZone = 300#timezone like jroheader, difference in minutes between UTC and localtime | |
657 | self.dstFlag = 0#self.dataIn.dstFlag |
|
657 | self.dstFlag = 0#self.dataIn.dstFlag | |
658 | self.errorCount = 0#self.dataIn.errorCount |
|
658 | self.errorCount = 0#self.dataIn.errorCount | |
659 | self.useLocalTime = True#self.dataIn.useLocalTime |
|
659 | self.useLocalTime = True#self.dataIn.useLocalTime | |
660 |
|
660 | |||
661 | self.radarControllerHeaderObj = None#self.dataIn.radarControllerHeaderObj.copy() |
|
661 | self.radarControllerHeaderObj = None#self.dataIn.radarControllerHeaderObj.copy() | |
662 | self.systemHeaderObj = None#self.dataIn.systemHeaderObj.copy() |
|
662 | self.systemHeaderObj = None#self.dataIn.systemHeaderObj.copy() | |
663 |
self.channelList = [ |
|
663 | self.channelList = [0]#self.dataIn.channelList esto solo aplica para el caso de AMISR | |
664 | self.dtype = numpy.dtype([('real','<f4'),('imag','<f4')]) |
|
664 | self.dtype = numpy.dtype([('real','<f4'),('imag','<f4')]) | |
665 |
|
665 | |||
666 | self.flagTimeBlock = None#self.dataIn.flagTimeBlock |
|
666 | self.flagTimeBlock = None#self.dataIn.flagTimeBlock | |
667 | #self.utctime = #self.firstdatatime |
|
667 | #self.utctime = #self.firstdatatime | |
668 | self.flagDecodeData = None#self.dataIn.flagDecodeData #asumo q la data esta decodificada |
|
668 | self.flagDecodeData = None#self.dataIn.flagDecodeData #asumo q la data esta decodificada | |
669 | self.flagDeflipData = None#self.dataIn.flagDeflipData #asumo q la data esta sin flip |
|
669 | self.flagDeflipData = None#self.dataIn.flagDeflipData #asumo q la data esta sin flip | |
670 |
|
670 | |||
671 | self.nCohInt = 1#self.dataIn.nCohInt |
|
671 | self.nCohInt = 1#self.dataIn.nCohInt | |
672 | self.nIncohInt = 1 |
|
672 | self.nIncohInt = 1 | |
673 | self.ippSeconds = 0.004#self.dataIn.ippSeconds, segun el filename/Setup/Tufile |
|
673 | self.ippSeconds = 0.004#self.dataIn.ippSeconds, segun el filename/Setup/Tufile | |
674 | self.windowOfFilter = None#self.dataIn.windowOfFilter |
|
674 | self.windowOfFilter = None#self.dataIn.windowOfFilter | |
675 |
|
675 | |||
676 | self.timeInterval = None#self.dataIn.timeInterval*self.dataOut.nFFTPoints*self.dataOut.nIncohInt |
|
676 | self.timeInterval = None#self.dataIn.timeInterval*self.dataOut.nFFTPoints*self.dataOut.nIncohInt | |
677 | self.frequency = 20000000#self.dataIn.frequency |
|
677 | self.frequency = 20000000#self.dataIn.frequency | |
678 | self.realtime = 0#self.dataIn.realtime |
|
678 | self.realtime = 0#self.dataIn.realtime | |
679 |
|
679 | |||
680 | #actualizar en la lectura de datos |
|
680 | #actualizar en la lectura de datos | |
681 | self.heightList = None#self.dataIn.heightList |
|
681 | self.heightList = None#self.dataIn.heightList | |
682 | self.nProfiles = None#self.dataOut.nFFTPoints |
|
682 | self.nProfiles = None#self.dataOut.nFFTPoints | |
683 | self.nBaud = None#self.dataIn.nBaud |
|
683 | self.nBaud = None#self.dataIn.nBaud | |
684 | self.nCode = None#self.dataIn.nCode |
|
684 | self.nCode = None#self.dataIn.nCode | |
685 | self.code = None#self.dataIn.code |
|
685 | self.code = None#self.dataIn.code | |
686 |
|
686 | |||
687 |
|
687 | |||
688 | def isEmpty(self): |
|
688 | def isEmpty(self): | |
689 |
|
689 | |||
690 | return self.flagNoData No newline at end of file |
|
690 | return self.flagNoData |
@@ -1,2118 +1,2119 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import time, datetime, os |
|
2 | import time, datetime, os | |
3 | from graphics.figure import * |
|
3 | from graphics.figure import * | |
4 | def isRealtime(utcdatatime): |
|
4 | def isRealtime(utcdatatime): | |
5 | utcnow = time.mktime(time.localtime()) |
|
5 | utcnow = time.mktime(time.localtime()) | |
6 | delta = abs(utcnow - utcdatatime) # abs |
|
6 | delta = abs(utcnow - utcdatatime) # abs | |
7 | if delta >= 30.: |
|
7 | if delta >= 30.: | |
8 | return False |
|
8 | return False | |
9 | return True |
|
9 | return True | |
10 |
|
10 | |||
11 | class CrossSpectraPlot(Figure): |
|
11 | class CrossSpectraPlot(Figure): | |
12 |
|
12 | |||
13 | __isConfig = None |
|
13 | __isConfig = None | |
14 | __nsubplots = None |
|
14 | __nsubplots = None | |
15 |
|
15 | |||
16 | WIDTH = None |
|
16 | WIDTH = None | |
17 | HEIGHT = None |
|
17 | HEIGHT = None | |
18 | WIDTHPROF = None |
|
18 | WIDTHPROF = None | |
19 | HEIGHTPROF = None |
|
19 | HEIGHTPROF = None | |
20 | PREFIX = 'cspc' |
|
20 | PREFIX = 'cspc' | |
21 |
|
21 | |||
22 | def __init__(self): |
|
22 | def __init__(self): | |
23 |
|
23 | |||
24 | self.__isConfig = False |
|
24 | self.__isConfig = False | |
25 | self.__nsubplots = 4 |
|
25 | self.__nsubplots = 4 | |
26 | self.counter_imagwr = 0 |
|
26 | self.counter_imagwr = 0 | |
27 | self.WIDTH = 250 |
|
27 | self.WIDTH = 250 | |
28 | self.HEIGHT = 250 |
|
28 | self.HEIGHT = 250 | |
29 | self.WIDTHPROF = 0 |
|
29 | self.WIDTHPROF = 0 | |
30 | self.HEIGHTPROF = 0 |
|
30 | self.HEIGHTPROF = 0 | |
31 |
|
31 | |||
32 | self.PLOT_CODE = 1 |
|
32 | self.PLOT_CODE = 1 | |
33 | self.FTP_WEI = None |
|
33 | self.FTP_WEI = None | |
34 | self.EXP_CODE = None |
|
34 | self.EXP_CODE = None | |
35 | self.SUB_EXP_CODE = None |
|
35 | self.SUB_EXP_CODE = None | |
36 | self.PLOT_POS = None |
|
36 | self.PLOT_POS = None | |
37 |
|
37 | |||
38 | def getSubplots(self): |
|
38 | def getSubplots(self): | |
39 |
|
39 | |||
40 | ncol = 4 |
|
40 | ncol = 4 | |
41 | nrow = self.nplots |
|
41 | nrow = self.nplots | |
42 |
|
42 | |||
43 | return nrow, ncol |
|
43 | return nrow, ncol | |
44 |
|
44 | |||
45 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
45 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
46 |
|
46 | |||
47 | self.__showprofile = showprofile |
|
47 | self.__showprofile = showprofile | |
48 | self.nplots = nplots |
|
48 | self.nplots = nplots | |
49 |
|
49 | |||
50 | ncolspan = 1 |
|
50 | ncolspan = 1 | |
51 | colspan = 1 |
|
51 | colspan = 1 | |
52 |
|
52 | |||
53 | self.createFigure(id = id, |
|
53 | self.createFigure(id = id, | |
54 | wintitle = wintitle, |
|
54 | wintitle = wintitle, | |
55 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
55 | widthplot = self.WIDTH + self.WIDTHPROF, | |
56 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
56 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
57 | show=True) |
|
57 | show=True) | |
58 |
|
58 | |||
59 | nrow, ncol = self.getSubplots() |
|
59 | nrow, ncol = self.getSubplots() | |
60 |
|
60 | |||
61 | counter = 0 |
|
61 | counter = 0 | |
62 | for y in range(nrow): |
|
62 | for y in range(nrow): | |
63 | for x in range(ncol): |
|
63 | for x in range(ncol): | |
64 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
64 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
65 |
|
65 | |||
66 | counter += 1 |
|
66 | counter += 1 | |
67 |
|
67 | |||
68 | def run(self, dataOut, id, wintitle="", pairsList=None, |
|
68 | def run(self, dataOut, id, wintitle="", pairsList=None, | |
69 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
69 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
70 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, |
|
70 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, | |
71 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True, |
|
71 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True, | |
72 | server=None, folder=None, username=None, password=None, |
|
72 | server=None, folder=None, username=None, password=None, | |
73 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
73 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
74 |
|
74 | |||
75 | """ |
|
75 | """ | |
76 |
|
76 | |||
77 | Input: |
|
77 | Input: | |
78 | dataOut : |
|
78 | dataOut : | |
79 | id : |
|
79 | id : | |
80 | wintitle : |
|
80 | wintitle : | |
81 | channelList : |
|
81 | channelList : | |
82 | showProfile : |
|
82 | showProfile : | |
83 | xmin : None, |
|
83 | xmin : None, | |
84 | xmax : None, |
|
84 | xmax : None, | |
85 | ymin : None, |
|
85 | ymin : None, | |
86 | ymax : None, |
|
86 | ymax : None, | |
87 | zmin : None, |
|
87 | zmin : None, | |
88 | zmax : None |
|
88 | zmax : None | |
89 | """ |
|
89 | """ | |
90 |
|
90 | |||
91 | if pairsList == None: |
|
91 | if pairsList == None: | |
92 | pairsIndexList = dataOut.pairsIndexList |
|
92 | pairsIndexList = dataOut.pairsIndexList | |
93 | else: |
|
93 | else: | |
94 | pairsIndexList = [] |
|
94 | pairsIndexList = [] | |
95 | for pair in pairsList: |
|
95 | for pair in pairsList: | |
96 | if pair not in dataOut.pairsList: |
|
96 | if pair not in dataOut.pairsList: | |
97 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
97 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
98 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
98 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
99 |
|
99 | |||
100 | if pairsIndexList == []: |
|
100 | if pairsIndexList == []: | |
101 | return |
|
101 | return | |
102 |
|
102 | |||
103 | if len(pairsIndexList) > 4: |
|
103 | if len(pairsIndexList) > 4: | |
104 | pairsIndexList = pairsIndexList[0:4] |
|
104 | pairsIndexList = pairsIndexList[0:4] | |
105 | factor = dataOut.normFactor |
|
105 | factor = dataOut.normFactor | |
106 | x = dataOut.getVelRange(1) |
|
106 | x = dataOut.getVelRange(1) | |
107 | y = dataOut.getHeiRange() |
|
107 | y = dataOut.getHeiRange() | |
108 | z = dataOut.data_spc[:,:,:]/factor |
|
108 | z = dataOut.data_spc[:,:,:]/factor | |
109 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
109 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
110 | avg = numpy.abs(numpy.average(z, axis=1)) |
|
110 | avg = numpy.abs(numpy.average(z, axis=1)) | |
111 | noise = dataOut.getNoise()/factor |
|
111 | noise = dataOut.getNoise()/factor | |
112 |
|
112 | |||
113 | zdB = 10*numpy.log10(z) |
|
113 | zdB = 10*numpy.log10(z) | |
114 | avgdB = 10*numpy.log10(avg) |
|
114 | avgdB = 10*numpy.log10(avg) | |
115 | noisedB = 10*numpy.log10(noise) |
|
115 | noisedB = 10*numpy.log10(noise) | |
116 |
|
116 | |||
117 |
|
117 | |||
118 | #thisDatetime = dataOut.datatime |
|
118 | #thisDatetime = dataOut.datatime | |
119 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
119 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
120 | title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
120 | title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
121 | xlabel = "Velocity (m/s)" |
|
121 | xlabel = "Velocity (m/s)" | |
122 | ylabel = "Range (Km)" |
|
122 | ylabel = "Range (Km)" | |
123 |
|
123 | |||
124 | if not self.__isConfig: |
|
124 | if not self.__isConfig: | |
125 |
|
125 | |||
126 | nplots = len(pairsIndexList) |
|
126 | nplots = len(pairsIndexList) | |
127 |
|
127 | |||
128 | self.setup(id=id, |
|
128 | self.setup(id=id, | |
129 | nplots=nplots, |
|
129 | nplots=nplots, | |
130 | wintitle=wintitle, |
|
130 | wintitle=wintitle, | |
131 | showprofile=False, |
|
131 | showprofile=False, | |
132 | show=show) |
|
132 | show=show) | |
133 |
|
133 | |||
134 | if xmin == None: xmin = numpy.nanmin(x) |
|
134 | if xmin == None: xmin = numpy.nanmin(x) | |
135 | if xmax == None: xmax = numpy.nanmax(x) |
|
135 | if xmax == None: xmax = numpy.nanmax(x) | |
136 | if ymin == None: ymin = numpy.nanmin(y) |
|
136 | if ymin == None: ymin = numpy.nanmin(y) | |
137 | if ymax == None: ymax = numpy.nanmax(y) |
|
137 | if ymax == None: ymax = numpy.nanmax(y) | |
138 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
138 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
139 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
139 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
140 |
|
140 | |||
141 | self.FTP_WEI = ftp_wei |
|
141 | self.FTP_WEI = ftp_wei | |
142 | self.EXP_CODE = exp_code |
|
142 | self.EXP_CODE = exp_code | |
143 | self.SUB_EXP_CODE = sub_exp_code |
|
143 | self.SUB_EXP_CODE = sub_exp_code | |
144 | self.PLOT_POS = plot_pos |
|
144 | self.PLOT_POS = plot_pos | |
145 |
|
145 | |||
146 | self.__isConfig = True |
|
146 | self.__isConfig = True | |
147 |
|
147 | |||
148 | self.setWinTitle(title) |
|
148 | self.setWinTitle(title) | |
149 |
|
149 | |||
150 | for i in range(self.nplots): |
|
150 | for i in range(self.nplots): | |
151 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
151 | pair = dataOut.pairsList[pairsIndexList[i]] | |
152 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
152 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
153 | title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[pair[0]], str_datetime) |
|
153 | title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[pair[0]], str_datetime) | |
154 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]) |
|
154 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]) | |
155 | axes0 = self.axesList[i*self.__nsubplots] |
|
155 | axes0 = self.axesList[i*self.__nsubplots] | |
156 | axes0.pcolor(x, y, zdB, |
|
156 | axes0.pcolor(x, y, zdB, | |
157 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
157 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
158 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
158 | xlabel=xlabel, ylabel=ylabel, title=title, | |
159 | ticksize=9, colormap=power_cmap, cblabel='') |
|
159 | ticksize=9, colormap=power_cmap, cblabel='') | |
160 |
|
160 | |||
161 | title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[pair[1]], str_datetime) |
|
161 | title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[pair[1]], str_datetime) | |
162 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]) |
|
162 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]) | |
163 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
163 | axes0 = self.axesList[i*self.__nsubplots+1] | |
164 | axes0.pcolor(x, y, zdB, |
|
164 | axes0.pcolor(x, y, zdB, | |
165 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
165 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
166 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
166 | xlabel=xlabel, ylabel=ylabel, title=title, | |
167 | ticksize=9, colormap=power_cmap, cblabel='') |
|
167 | ticksize=9, colormap=power_cmap, cblabel='') | |
168 |
|
168 | |||
169 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
169 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
170 | coherence = numpy.abs(coherenceComplex) |
|
170 | coherence = numpy.abs(coherenceComplex) | |
171 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
171 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
172 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi |
|
172 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi | |
173 |
|
173 | |||
174 | title = "Coherence %d%d" %(pair[0], pair[1]) |
|
174 | title = "Coherence %d%d" %(pair[0], pair[1]) | |
175 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
175 | axes0 = self.axesList[i*self.__nsubplots+2] | |
176 | axes0.pcolor(x, y, coherence, |
|
176 | axes0.pcolor(x, y, coherence, | |
177 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
177 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
178 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
178 | xlabel=xlabel, ylabel=ylabel, title=title, | |
179 | ticksize=9, colormap=coherence_cmap, cblabel='') |
|
179 | ticksize=9, colormap=coherence_cmap, cblabel='') | |
180 |
|
180 | |||
181 | title = "Phase %d%d" %(pair[0], pair[1]) |
|
181 | title = "Phase %d%d" %(pair[0], pair[1]) | |
182 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
182 | axes0 = self.axesList[i*self.__nsubplots+3] | |
183 | axes0.pcolor(x, y, phase, |
|
183 | axes0.pcolor(x, y, phase, | |
184 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
184 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
185 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
185 | xlabel=xlabel, ylabel=ylabel, title=title, | |
186 | ticksize=9, colormap=phase_cmap, cblabel='') |
|
186 | ticksize=9, colormap=phase_cmap, cblabel='') | |
187 |
|
187 | |||
188 |
|
188 | |||
189 |
|
189 | |||
190 | self.draw() |
|
190 | self.draw() | |
191 |
|
191 | |||
192 | if save: |
|
192 | if save: | |
193 |
|
193 | |||
194 | self.counter_imagwr += 1 |
|
194 | self.counter_imagwr += 1 | |
195 | if (self.counter_imagwr==wr_period): |
|
195 | if (self.counter_imagwr==wr_period): | |
196 | if figfile == None: |
|
196 | if figfile == None: | |
197 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
197 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
198 | figfile = self.getFilename(name = str_datetime) |
|
198 | figfile = self.getFilename(name = str_datetime) | |
199 |
|
199 | |||
200 | self.saveFigure(figpath, figfile) |
|
200 | self.saveFigure(figpath, figfile) | |
201 |
|
201 | |||
202 | if ftp: |
|
202 | if ftp: | |
203 | #provisionalmente envia archivos en el formato de la web en tiempo real |
|
203 | #provisionalmente envia archivos en el formato de la web en tiempo real | |
204 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
204 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
205 | path = '%s%03d' %(self.PREFIX, self.id) |
|
205 | path = '%s%03d' %(self.PREFIX, self.id) | |
206 | ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
206 | ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
207 | self.saveFigure(figpath, ftp_file) |
|
207 | self.saveFigure(figpath, ftp_file) | |
208 | ftp_filename = os.path.join(figpath,ftp_file) |
|
208 | ftp_filename = os.path.join(figpath,ftp_file) | |
209 |
|
209 | |||
210 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
210 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
211 | self.counter_imagwr = 0 |
|
211 | self.counter_imagwr = 0 | |
212 |
|
212 | |||
213 | self.counter_imagwr = 0 |
|
213 | self.counter_imagwr = 0 | |
214 |
|
214 | |||
215 | class SNRPlot(Figure): |
|
215 | class SNRPlot(Figure): | |
216 |
|
216 | |||
217 | __isConfig = None |
|
217 | __isConfig = None | |
218 | __nsubplots = None |
|
218 | __nsubplots = None | |
219 |
|
219 | |||
220 | WIDTHPROF = None |
|
220 | WIDTHPROF = None | |
221 | HEIGHTPROF = None |
|
221 | HEIGHTPROF = None | |
222 | PREFIX = 'snr' |
|
222 | PREFIX = 'snr' | |
223 |
|
223 | |||
224 | def __init__(self): |
|
224 | def __init__(self): | |
225 |
|
225 | |||
226 | self.timerange = 2*60*60 |
|
226 | self.timerange = 2*60*60 | |
227 | self.__isConfig = False |
|
227 | self.__isConfig = False | |
228 | self.__nsubplots = 1 |
|
228 | self.__nsubplots = 1 | |
229 |
|
229 | |||
230 | self.WIDTH = 800 |
|
230 | self.WIDTH = 800 | |
231 | self.HEIGHT = 150 |
|
231 | self.HEIGHT = 150 | |
232 | self.WIDTHPROF = 120 |
|
232 | self.WIDTHPROF = 120 | |
233 | self.HEIGHTPROF = 0 |
|
233 | self.HEIGHTPROF = 0 | |
234 | self.counter_imagwr = 0 |
|
234 | self.counter_imagwr = 0 | |
235 |
|
235 | |||
236 | self.PLOT_CODE = 0 |
|
236 | self.PLOT_CODE = 0 | |
237 | self.FTP_WEI = None |
|
237 | self.FTP_WEI = None | |
238 | self.EXP_CODE = None |
|
238 | self.EXP_CODE = None | |
239 | self.SUB_EXP_CODE = None |
|
239 | self.SUB_EXP_CODE = None | |
240 | self.PLOT_POS = None |
|
240 | self.PLOT_POS = None | |
241 |
|
241 | |||
242 | def getSubplots(self): |
|
242 | def getSubplots(self): | |
243 |
|
243 | |||
244 | ncol = 1 |
|
244 | ncol = 1 | |
245 | nrow = self.nplots |
|
245 | nrow = self.nplots | |
246 |
|
246 | |||
247 | return nrow, ncol |
|
247 | return nrow, ncol | |
248 |
|
248 | |||
249 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
249 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
250 |
|
250 | |||
251 | self.__showprofile = showprofile |
|
251 | self.__showprofile = showprofile | |
252 | self.nplots = nplots |
|
252 | self.nplots = nplots | |
253 |
|
253 | |||
254 | ncolspan = 1 |
|
254 | ncolspan = 1 | |
255 | colspan = 1 |
|
255 | colspan = 1 | |
256 | if showprofile: |
|
256 | if showprofile: | |
257 | ncolspan = 7 |
|
257 | ncolspan = 7 | |
258 | colspan = 6 |
|
258 | colspan = 6 | |
259 | self.__nsubplots = 2 |
|
259 | self.__nsubplots = 2 | |
260 |
|
260 | |||
261 | self.createFigure(id = id, |
|
261 | self.createFigure(id = id, | |
262 | wintitle = wintitle, |
|
262 | wintitle = wintitle, | |
263 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
263 | widthplot = self.WIDTH + self.WIDTHPROF, | |
264 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
264 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
265 | show=show) |
|
265 | show=show) | |
266 |
|
266 | |||
267 | nrow, ncol = self.getSubplots() |
|
267 | nrow, ncol = self.getSubplots() | |
268 |
|
268 | |||
269 | counter = 0 |
|
269 | counter = 0 | |
270 | for y in range(nrow): |
|
270 | for y in range(nrow): | |
271 | for x in range(ncol): |
|
271 | for x in range(ncol): | |
272 |
|
272 | |||
273 | if counter >= self.nplots: |
|
273 | if counter >= self.nplots: | |
274 | break |
|
274 | break | |
275 |
|
275 | |||
276 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
276 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
277 |
|
277 | |||
278 | if showprofile: |
|
278 | if showprofile: | |
279 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
279 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
280 |
|
280 | |||
281 | counter += 1 |
|
281 | counter += 1 | |
282 |
|
282 | |||
283 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, |
|
283 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False, | |
284 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
284 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
285 | timerange=None, |
|
285 | timerange=None, | |
286 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
286 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
287 | server=None, folder=None, username=None, password=None, |
|
287 | server=None, folder=None, username=None, password=None, | |
288 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
288 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
289 |
|
289 | |||
290 | """ |
|
290 | """ | |
291 |
|
291 | |||
292 | Input: |
|
292 | Input: | |
293 | dataOut : |
|
293 | dataOut : | |
294 | id : |
|
294 | id : | |
295 | wintitle : |
|
295 | wintitle : | |
296 | channelList : |
|
296 | channelList : | |
297 | showProfile : |
|
297 | showProfile : | |
298 | xmin : None, |
|
298 | xmin : None, | |
299 | xmax : None, |
|
299 | xmax : None, | |
300 | ymin : None, |
|
300 | ymin : None, | |
301 | ymax : None, |
|
301 | ymax : None, | |
302 | zmin : None, |
|
302 | zmin : None, | |
303 | zmax : None |
|
303 | zmax : None | |
304 | """ |
|
304 | """ | |
305 |
|
305 | |||
306 | if channelList == None: |
|
306 | if channelList == None: | |
307 | channelIndexList = dataOut.channelIndexList |
|
307 | channelIndexList = dataOut.channelIndexList | |
308 | else: |
|
308 | else: | |
309 | channelIndexList = [] |
|
309 | channelIndexList = [] | |
310 | for channel in channelList: |
|
310 | for channel in channelList: | |
311 | if channel not in dataOut.channelList: |
|
311 | if channel not in dataOut.channelList: | |
312 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
312 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
313 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
313 | channelIndexList.append(dataOut.channelList.index(channel)) | |
314 |
|
314 | |||
315 | if timerange != None: |
|
315 | if timerange != None: | |
316 | self.timerange = timerange |
|
316 | self.timerange = timerange | |
317 |
|
317 | |||
318 | tmin = None |
|
318 | tmin = None | |
319 | tmax = None |
|
319 | tmax = None | |
320 | factor = dataOut.normFactor |
|
320 | factor = dataOut.normFactor | |
321 | x = dataOut.getTimeRange() |
|
321 | x = dataOut.getTimeRange() | |
322 | y = dataOut.getHeiRange() |
|
322 | y = dataOut.getHeiRange() | |
323 |
|
323 | |||
324 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
324 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
325 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
325 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
326 | avg = numpy.average(z, axis=1) |
|
326 | avg = numpy.average(z, axis=1) | |
327 |
|
327 | |||
328 | avgdB = 10.*numpy.log10(avg) |
|
328 | avgdB = 10.*numpy.log10(avg) | |
329 |
|
329 | |||
330 | noise = dataOut.getNoise()/factor |
|
330 | noise = dataOut.getNoise()/factor | |
331 | noisedB = 10.*numpy.log10(noise) |
|
331 | noisedB = 10.*numpy.log10(noise) | |
332 |
|
332 | |||
333 | SNR = numpy.transpose(numpy.divide(avg.T,noise)) |
|
333 | SNR = numpy.transpose(numpy.divide(avg.T,noise)) | |
334 |
|
334 | |||
335 | SNR_dB = 10.*numpy.log10(SNR) |
|
335 | SNR_dB = 10.*numpy.log10(SNR) | |
336 |
|
336 | |||
337 | #SNR_dB = numpy.transpose(numpy.subtract(avgdB.T, noisedB)) |
|
337 | #SNR_dB = numpy.transpose(numpy.subtract(avgdB.T, noisedB)) | |
338 |
|
338 | |||
339 | # thisDatetime = dataOut.datatime |
|
339 | # thisDatetime = dataOut.datatime | |
340 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
340 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
341 | title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
341 | title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
342 | xlabel = "" |
|
342 | xlabel = "" | |
343 | ylabel = "Range (Km)" |
|
343 | ylabel = "Range (Km)" | |
344 |
|
344 | |||
345 | if not self.__isConfig: |
|
345 | if not self.__isConfig: | |
346 |
|
346 | |||
347 | nplots = len(channelIndexList) |
|
347 | nplots = len(channelIndexList) | |
348 |
|
348 | |||
349 | self.setup(id=id, |
|
349 | self.setup(id=id, | |
350 | nplots=nplots, |
|
350 | nplots=nplots, | |
351 | wintitle=wintitle, |
|
351 | wintitle=wintitle, | |
352 | showprofile=showprofile, |
|
352 | showprofile=showprofile, | |
353 | show=show) |
|
353 | show=show) | |
354 |
|
354 | |||
355 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
355 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
356 | if ymin == None: ymin = numpy.nanmin(y) |
|
356 | if ymin == None: ymin = numpy.nanmin(y) | |
357 | if ymax == None: ymax = numpy.nanmax(y) |
|
357 | if ymax == None: ymax = numpy.nanmax(y) | |
358 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
358 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
359 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
359 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
360 |
|
360 | |||
361 | self.FTP_WEI = ftp_wei |
|
361 | self.FTP_WEI = ftp_wei | |
362 | self.EXP_CODE = exp_code |
|
362 | self.EXP_CODE = exp_code | |
363 | self.SUB_EXP_CODE = sub_exp_code |
|
363 | self.SUB_EXP_CODE = sub_exp_code | |
364 | self.PLOT_POS = plot_pos |
|
364 | self.PLOT_POS = plot_pos | |
365 |
|
365 | |||
366 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
366 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
367 | self.__isConfig = True |
|
367 | self.__isConfig = True | |
368 |
|
368 | |||
369 |
|
369 | |||
370 | self.setWinTitle(title) |
|
370 | self.setWinTitle(title) | |
371 |
|
371 | |||
372 | for i in range(self.nplots): |
|
372 | for i in range(self.nplots): | |
373 | title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
373 | title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
374 | axes = self.axesList[i*self.__nsubplots] |
|
374 | axes = self.axesList[i*self.__nsubplots] | |
375 | zdB = SNR_dB[i].reshape((1,-1)) |
|
375 | zdB = SNR_dB[i].reshape((1,-1)) | |
376 | axes.pcolorbuffer(x, y, zdB, |
|
376 | axes.pcolorbuffer(x, y, zdB, | |
377 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
377 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
378 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
378 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
379 | ticksize=9, cblabel='', cbsize="1%") |
|
379 | ticksize=9, cblabel='', cbsize="1%") | |
380 |
|
380 | |||
381 | # if self.__showprofile: |
|
381 | # if self.__showprofile: | |
382 | # axes = self.axesList[i*self.__nsubplots +1] |
|
382 | # axes = self.axesList[i*self.__nsubplots +1] | |
383 | # axes.pline(avgdB[i], y, |
|
383 | # axes.pline(avgdB[i], y, | |
384 | # xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
384 | # xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
385 | # xlabel='dB', ylabel='', title='', |
|
385 | # xlabel='dB', ylabel='', title='', | |
386 | # ytick_visible=False, |
|
386 | # ytick_visible=False, | |
387 | # grid='x') |
|
387 | # grid='x') | |
388 | # |
|
388 | # | |
389 | self.draw() |
|
389 | self.draw() | |
390 |
|
390 | |||
391 | if lastone: |
|
391 | if lastone: | |
392 | if dataOut.blocknow >= dataOut.last_block: |
|
392 | if dataOut.blocknow >= dataOut.last_block: | |
393 | if figfile == None: |
|
393 | if figfile == None: | |
394 | figfile = self.getFilename(name = self.name) |
|
394 | figfile = self.getFilename(name = self.name) | |
395 | self.saveFigure(figpath, figfile) |
|
395 | self.saveFigure(figpath, figfile) | |
396 |
|
396 | |||
397 | if (save and not(lastone)): |
|
397 | if (save and not(lastone)): | |
398 |
|
398 | |||
399 | self.counter_imagwr += 1 |
|
399 | self.counter_imagwr += 1 | |
400 | if (self.counter_imagwr==wr_period): |
|
400 | if (self.counter_imagwr==wr_period): | |
401 | if figfile == None: |
|
401 | if figfile == None: | |
402 | figfile = self.getFilename(name = self.name) |
|
402 | figfile = self.getFilename(name = self.name) | |
403 | self.saveFigure(figpath, figfile) |
|
403 | self.saveFigure(figpath, figfile) | |
404 |
|
404 | |||
405 | if ftp: |
|
405 | if ftp: | |
406 | #provisionalmente envia archivos en el formato de la web en tiempo real |
|
406 | #provisionalmente envia archivos en el formato de la web en tiempo real | |
407 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
407 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
408 | path = '%s%03d' %(self.PREFIX, self.id) |
|
408 | path = '%s%03d' %(self.PREFIX, self.id) | |
409 | ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
409 | ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
410 | self.saveFigure(figpath, ftp_file) |
|
410 | self.saveFigure(figpath, ftp_file) | |
411 | ftp_filename = os.path.join(figpath,ftp_file) |
|
411 | ftp_filename = os.path.join(figpath,ftp_file) | |
412 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
412 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
413 | self.counter_imagwr = 0 |
|
413 | self.counter_imagwr = 0 | |
414 |
|
414 | |||
415 | self.counter_imagwr = 0 |
|
415 | self.counter_imagwr = 0 | |
416 |
|
416 | |||
417 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
417 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
418 |
|
418 | |||
419 | self.__isConfig = False |
|
419 | self.__isConfig = False | |
420 |
|
420 | |||
421 | if lastone: |
|
421 | if lastone: | |
422 | if figfile == None: |
|
422 | if figfile == None: | |
423 | figfile = self.getFilename(name = self.name) |
|
423 | figfile = self.getFilename(name = self.name) | |
424 | self.saveFigure(figpath, figfile) |
|
424 | self.saveFigure(figpath, figfile) | |
425 |
|
425 | |||
426 | if ftp: |
|
426 | if ftp: | |
427 | #provisionalmente envia archivos en el formato de la web en tiempo real |
|
427 | #provisionalmente envia archivos en el formato de la web en tiempo real | |
428 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
428 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
429 | path = '%s%03d' %(self.PREFIX, self.id) |
|
429 | path = '%s%03d' %(self.PREFIX, self.id) | |
430 | ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
430 | ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
431 | self.saveFigure(figpath, ftp_file) |
|
431 | self.saveFigure(figpath, ftp_file) | |
432 | ftp_filename = os.path.join(figpath,ftp_file) |
|
432 | ftp_filename = os.path.join(figpath,ftp_file) | |
433 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
433 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
434 |
|
434 | |||
435 |
|
435 | |||
436 | class RTIPlot(Figure): |
|
436 | class RTIPlot(Figure): | |
437 |
|
437 | |||
438 | __isConfig = None |
|
438 | __isConfig = None | |
439 | __nsubplots = None |
|
439 | __nsubplots = None | |
440 |
|
440 | |||
441 | WIDTHPROF = None |
|
441 | WIDTHPROF = None | |
442 | HEIGHTPROF = None |
|
442 | HEIGHTPROF = None | |
443 | PREFIX = 'rti' |
|
443 | PREFIX = 'rti' | |
444 |
|
444 | |||
445 | def __init__(self): |
|
445 | def __init__(self): | |
446 |
|
446 | |||
447 | self.timerange = 2*60*60 |
|
447 | self.timerange = 2*60*60 | |
448 | self.__isConfig = False |
|
448 | self.__isConfig = False | |
449 | self.__nsubplots = 1 |
|
449 | self.__nsubplots = 1 | |
450 |
|
450 | |||
451 | self.WIDTH = 800 |
|
451 | self.WIDTH = 800 | |
452 | self.HEIGHT = 150 |
|
452 | self.HEIGHT = 150 | |
453 | self.WIDTHPROF = 120 |
|
453 | self.WIDTHPROF = 120 | |
454 | self.HEIGHTPROF = 0 |
|
454 | self.HEIGHTPROF = 0 | |
455 | self.counter_imagwr = 0 |
|
455 | self.counter_imagwr = 0 | |
456 |
|
456 | |||
457 | self.PLOT_CODE = 0 |
|
457 | self.PLOT_CODE = 0 | |
458 | self.FTP_WEI = None |
|
458 | self.FTP_WEI = None | |
459 | self.EXP_CODE = None |
|
459 | self.EXP_CODE = None | |
460 | self.SUB_EXP_CODE = None |
|
460 | self.SUB_EXP_CODE = None | |
461 | self.PLOT_POS = None |
|
461 | self.PLOT_POS = None | |
462 | self.tmin = None |
|
462 | self.tmin = None | |
463 | self.tmax = None |
|
463 | self.tmax = None | |
464 |
|
464 | |||
465 | self.xmin = None |
|
465 | self.xmin = None | |
466 | self.xmax = None |
|
466 | self.xmax = None | |
467 |
|
467 | |||
468 | def getSubplots(self): |
|
468 | def getSubplots(self): | |
469 |
|
469 | |||
470 | ncol = 1 |
|
470 | ncol = 1 | |
471 | nrow = self.nplots |
|
471 | nrow = self.nplots | |
472 |
|
472 | |||
473 | return nrow, ncol |
|
473 | return nrow, ncol | |
474 |
|
474 | |||
475 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
475 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
476 |
|
476 | |||
477 | self.__showprofile = showprofile |
|
477 | self.__showprofile = showprofile | |
478 | self.nplots = nplots |
|
478 | self.nplots = nplots | |
479 |
|
479 | |||
480 | ncolspan = 1 |
|
480 | ncolspan = 1 | |
481 | colspan = 1 |
|
481 | colspan = 1 | |
482 | if showprofile: |
|
482 | if showprofile: | |
483 | ncolspan = 7 |
|
483 | ncolspan = 7 | |
484 | colspan = 6 |
|
484 | colspan = 6 | |
485 | self.__nsubplots = 2 |
|
485 | self.__nsubplots = 2 | |
486 |
|
486 | |||
487 | self.createFigure(id = id, |
|
487 | self.createFigure(id = id, | |
488 | wintitle = wintitle, |
|
488 | wintitle = wintitle, | |
489 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
489 | widthplot = self.WIDTH + self.WIDTHPROF, | |
490 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
490 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
491 | show=show) |
|
491 | show=show) | |
492 |
|
492 | |||
493 | nrow, ncol = self.getSubplots() |
|
493 | nrow, ncol = self.getSubplots() | |
494 |
|
494 | |||
495 | counter = 0 |
|
495 | counter = 0 | |
496 | for y in range(nrow): |
|
496 | for y in range(nrow): | |
497 | for x in range(ncol): |
|
497 | for x in range(ncol): | |
498 |
|
498 | |||
499 | if counter >= self.nplots: |
|
499 | if counter >= self.nplots: | |
500 | break |
|
500 | break | |
501 |
|
501 | |||
502 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
502 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
503 |
|
503 | |||
504 | if showprofile: |
|
504 | if showprofile: | |
505 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
505 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
506 |
|
506 | |||
507 | counter += 1 |
|
507 | counter += 1 | |
508 |
|
508 | |||
509 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', |
|
509 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
510 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
510 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
511 | timerange=None, |
|
511 | timerange=None, | |
512 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, |
|
512 | save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True, | |
513 | server=None, folder=None, username=None, password=None, |
|
513 | server=None, folder=None, username=None, password=None, | |
514 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
514 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
515 |
|
515 | |||
516 | """ |
|
516 | """ | |
517 |
|
517 | |||
518 | Input: |
|
518 | Input: | |
519 | dataOut : |
|
519 | dataOut : | |
520 | id : |
|
520 | id : | |
521 | wintitle : |
|
521 | wintitle : | |
522 | channelList : |
|
522 | channelList : | |
523 | showProfile : |
|
523 | showProfile : | |
524 | xmin : None, |
|
524 | xmin : None, | |
525 | xmax : None, |
|
525 | xmax : None, | |
526 | ymin : None, |
|
526 | ymin : None, | |
527 | ymax : None, |
|
527 | ymax : None, | |
528 | zmin : None, |
|
528 | zmin : None, | |
529 | zmax : None |
|
529 | zmax : None | |
530 | """ |
|
530 | """ | |
531 |
|
531 | |||
532 | if channelList == None: |
|
532 | if channelList == None: | |
533 | channelIndexList = dataOut.channelIndexList |
|
533 | channelIndexList = dataOut.channelIndexList | |
534 | else: |
|
534 | else: | |
535 | channelIndexList = [] |
|
535 | channelIndexList = [] | |
536 | for channel in channelList: |
|
536 | for channel in channelList: | |
537 | if channel not in dataOut.channelList: |
|
537 | if channel not in dataOut.channelList: | |
538 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
538 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
539 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
539 | channelIndexList.append(dataOut.channelList.index(channel)) | |
540 |
|
540 | |||
541 | if timerange != None: |
|
541 | if timerange != None: | |
542 | self.timerange = timerange |
|
542 | self.timerange = timerange | |
543 |
|
543 | |||
544 | #tmin = None |
|
544 | #tmin = None | |
545 | #tmax = None |
|
545 | #tmax = None | |
546 | factor = dataOut.normFactor |
|
546 | factor = dataOut.normFactor | |
547 | x = dataOut.getTimeRange() |
|
547 | x = dataOut.getTimeRange() | |
548 | y = dataOut.getHeiRange() |
|
548 | y = dataOut.getHeiRange() | |
549 |
|
549 | |||
550 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
550 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
551 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
551 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
552 | avg = numpy.average(z, axis=1) |
|
552 | avg = numpy.average(z, axis=1) | |
553 |
|
553 | |||
554 | avgdB = 10.*numpy.log10(avg) |
|
554 | avgdB = 10.*numpy.log10(avg) | |
555 |
|
555 | |||
556 |
|
556 | |||
557 | # thisDatetime = dataOut.datatime |
|
557 | # thisDatetime = dataOut.datatime | |
558 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
558 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
559 | title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
559 | title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
560 | xlabel = "" |
|
560 | xlabel = "" | |
561 | ylabel = "Range (Km)" |
|
561 | ylabel = "Range (Km)" | |
562 |
|
562 | |||
563 | if not self.__isConfig: |
|
563 | if not self.__isConfig: | |
564 |
|
564 | |||
565 | nplots = len(channelIndexList) |
|
565 | nplots = len(channelIndexList) | |
566 |
|
566 | |||
567 | self.setup(id=id, |
|
567 | self.setup(id=id, | |
568 | nplots=nplots, |
|
568 | nplots=nplots, | |
569 | wintitle=wintitle, |
|
569 | wintitle=wintitle, | |
570 | showprofile=showprofile, |
|
570 | showprofile=showprofile, | |
571 | show=show) |
|
571 | show=show) | |
572 |
|
572 | |||
573 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
573 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
574 |
|
574 | |||
575 | # if timerange != None: |
|
575 | # if timerange != None: | |
576 | # self.timerange = timerange |
|
576 | # self.timerange = timerange | |
577 | # self.xmin, self.tmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
577 | # self.xmin, self.tmax = self.getTimeLim(x, xmin, xmax, timerange) | |
578 |
|
578 | |||
579 |
|
579 | |||
580 |
|
580 | |||
581 | if ymin == None: ymin = numpy.nanmin(y) |
|
581 | if ymin == None: ymin = numpy.nanmin(y) | |
582 | if ymax == None: ymax = numpy.nanmax(y) |
|
582 | if ymax == None: ymax = numpy.nanmax(y) | |
583 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
583 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
584 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
584 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
585 |
|
585 | |||
586 | self.FTP_WEI = ftp_wei |
|
586 | self.FTP_WEI = ftp_wei | |
587 | self.EXP_CODE = exp_code |
|
587 | self.EXP_CODE = exp_code | |
588 | self.SUB_EXP_CODE = sub_exp_code |
|
588 | self.SUB_EXP_CODE = sub_exp_code | |
589 | self.PLOT_POS = plot_pos |
|
589 | self.PLOT_POS = plot_pos | |
590 |
|
590 | |||
591 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
591 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
592 | self.__isConfig = True |
|
592 | self.__isConfig = True | |
593 |
|
593 | |||
594 |
|
594 | |||
595 | self.setWinTitle(title) |
|
595 | self.setWinTitle(title) | |
596 |
|
596 | |||
597 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
597 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
598 | x[1] = self.xmax |
|
598 | x[1] = self.xmax | |
599 |
|
599 | |||
600 | for i in range(self.nplots): |
|
600 | for i in range(self.nplots): | |
601 | title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
601 | title = "Channel %d: %s" %(dataOut.channelList[i]+1, thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
602 | axes = self.axesList[i*self.__nsubplots] |
|
602 | axes = self.axesList[i*self.__nsubplots] | |
603 | zdB = avgdB[i].reshape((1,-1)) |
|
603 | zdB = avgdB[i].reshape((1,-1)) | |
604 | axes.pcolorbuffer(x, y, zdB, |
|
604 | axes.pcolorbuffer(x, y, zdB, | |
605 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
605 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
606 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
606 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
607 | ticksize=9, cblabel='', cbsize="1%") |
|
607 | ticksize=9, cblabel='', cbsize="1%") | |
608 |
|
608 | |||
609 | if self.__showprofile: |
|
609 | if self.__showprofile: | |
610 | axes = self.axesList[i*self.__nsubplots +1] |
|
610 | axes = self.axesList[i*self.__nsubplots +1] | |
611 | axes.pline(avgdB[i], y, |
|
611 | axes.pline(avgdB[i], y, | |
612 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
612 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
613 | xlabel='dB', ylabel='', title='', |
|
613 | xlabel='dB', ylabel='', title='', | |
614 | ytick_visible=False, |
|
614 | ytick_visible=False, | |
615 | grid='x') |
|
615 | grid='x') | |
616 |
|
616 | |||
617 | self.draw() |
|
617 | self.draw() | |
618 |
|
618 | |||
619 | # if lastone: |
|
619 | # if lastone: | |
620 | # if dataOut.blocknow >= dataOut.last_block: |
|
620 | # if dataOut.blocknow >= dataOut.last_block: | |
621 | # if figfile == None: |
|
621 | # if figfile == None: | |
622 | # figfile = self.getFilename(name = self.name) |
|
622 | # figfile = self.getFilename(name = self.name) | |
623 | # self.saveFigure(figpath, figfile) |
|
623 | # self.saveFigure(figpath, figfile) | |
624 | # |
|
624 | # | |
625 | # if (save and not(lastone)): |
|
625 | # if (save and not(lastone)): | |
626 | # |
|
626 | # | |
627 | # self.counter_imagwr += 1 |
|
627 | # self.counter_imagwr += 1 | |
628 | # if (self.counter_imagwr==wr_period): |
|
628 | # if (self.counter_imagwr==wr_period): | |
629 | # if figfile == None: |
|
629 | # if figfile == None: | |
630 | # figfile = self.getFilename(name = self.name) |
|
630 | # figfile = self.getFilename(name = self.name) | |
631 | # self.saveFigure(figpath, figfile) |
|
631 | # self.saveFigure(figpath, figfile) | |
632 | # |
|
632 | # | |
633 | # if ftp: |
|
633 | # if ftp: | |
634 | # #provisionalmente envia archivos en el formato de la web en tiempo real |
|
634 | # #provisionalmente envia archivos en el formato de la web en tiempo real | |
635 | # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
635 | # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
636 | # path = '%s%03d' %(self.PREFIX, self.id) |
|
636 | # path = '%s%03d' %(self.PREFIX, self.id) | |
637 | # ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
637 | # ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
638 | # self.saveFigure(figpath, ftp_file) |
|
638 | # self.saveFigure(figpath, ftp_file) | |
639 | # ftp_filename = os.path.join(figpath,ftp_file) |
|
639 | # ftp_filename = os.path.join(figpath,ftp_file) | |
640 | # self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
640 | # self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
641 | # self.counter_imagwr = 0 |
|
641 | # self.counter_imagwr = 0 | |
642 | # |
|
642 | # | |
643 | # self.counter_imagwr = 0 |
|
643 | # self.counter_imagwr = 0 | |
644 |
|
644 | |||
645 | #if ((dataOut.utctime-time.timezone) >= self.axesList[0].xmax): |
|
645 | #if ((dataOut.utctime-time.timezone) >= self.axesList[0].xmax): | |
|
646 | self.saveFigure(figpath, figfile) | |||
646 | if x[1] >= self.axesList[0].xmax: |
|
647 | if x[1] >= self.axesList[0].xmax: | |
647 |
|
|
648 | self.saveFigure(figpath, figfile) | |
648 | self.__isConfig = False |
|
649 | self.__isConfig = False | |
649 |
|
650 | |||
650 | # if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
651 | # if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
651 | # |
|
652 | # | |
652 | # self.__isConfig = False |
|
653 | # self.__isConfig = False | |
653 |
|
654 | |||
654 | # if lastone: |
|
655 | # if lastone: | |
655 | # if figfile == None: |
|
656 | # if figfile == None: | |
656 | # figfile = self.getFilename(name = self.name) |
|
657 | # figfile = self.getFilename(name = self.name) | |
657 | # self.saveFigure(figpath, figfile) |
|
658 | # self.saveFigure(figpath, figfile) | |
658 | # |
|
659 | # | |
659 | # if ftp: |
|
660 | # if ftp: | |
660 | # #provisionalmente envia archivos en el formato de la web en tiempo real |
|
661 | # #provisionalmente envia archivos en el formato de la web en tiempo real | |
661 | # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
662 | # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
662 | # path = '%s%03d' %(self.PREFIX, self.id) |
|
663 | # path = '%s%03d' %(self.PREFIX, self.id) | |
663 | # ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
664 | # ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
664 | # self.saveFigure(figpath, ftp_file) |
|
665 | # self.saveFigure(figpath, ftp_file) | |
665 | # ftp_filename = os.path.join(figpath,ftp_file) |
|
666 | # ftp_filename = os.path.join(figpath,ftp_file) | |
666 | # self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
667 | # self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
667 |
|
668 | |||
668 |
|
669 | |||
669 | class SpectraPlot(Figure): |
|
670 | class SpectraPlot(Figure): | |
670 |
|
671 | |||
671 | __isConfig = None |
|
672 | __isConfig = None | |
672 | __nsubplots = None |
|
673 | __nsubplots = None | |
673 |
|
674 | |||
674 | WIDTHPROF = None |
|
675 | WIDTHPROF = None | |
675 | HEIGHTPROF = None |
|
676 | HEIGHTPROF = None | |
676 | PREFIX = 'spc' |
|
677 | PREFIX = 'spc' | |
677 |
|
678 | |||
678 | def __init__(self): |
|
679 | def __init__(self): | |
679 |
|
680 | |||
680 | self.__isConfig = False |
|
681 | self.__isConfig = False | |
681 | self.__nsubplots = 1 |
|
682 | self.__nsubplots = 1 | |
682 |
|
683 | |||
683 | self.WIDTH = 280 |
|
684 | self.WIDTH = 280 | |
684 | self.HEIGHT = 250 |
|
685 | self.HEIGHT = 250 | |
685 | self.WIDTHPROF = 120 |
|
686 | self.WIDTHPROF = 120 | |
686 | self.HEIGHTPROF = 0 |
|
687 | self.HEIGHTPROF = 0 | |
687 | self.counter_imagwr = 0 |
|
688 | self.counter_imagwr = 0 | |
688 |
|
689 | |||
689 | self.PLOT_CODE = 1 |
|
690 | self.PLOT_CODE = 1 | |
690 | self.FTP_WEI = None |
|
691 | self.FTP_WEI = None | |
691 | self.EXP_CODE = None |
|
692 | self.EXP_CODE = None | |
692 | self.SUB_EXP_CODE = None |
|
693 | self.SUB_EXP_CODE = None | |
693 | self.PLOT_POS = None |
|
694 | self.PLOT_POS = None | |
694 |
|
695 | |||
695 | def getSubplots(self): |
|
696 | def getSubplots(self): | |
696 |
|
697 | |||
697 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
698 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
698 | nrow = int(self.nplots*1./ncol + 0.9) |
|
699 | nrow = int(self.nplots*1./ncol + 0.9) | |
699 |
|
700 | |||
700 | return nrow, ncol |
|
701 | return nrow, ncol | |
701 |
|
702 | |||
702 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
703 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
703 |
|
704 | |||
704 | self.__showprofile = showprofile |
|
705 | self.__showprofile = showprofile | |
705 | self.nplots = nplots |
|
706 | self.nplots = nplots | |
706 |
|
707 | |||
707 | ncolspan = 1 |
|
708 | ncolspan = 1 | |
708 | colspan = 1 |
|
709 | colspan = 1 | |
709 | if showprofile: |
|
710 | if showprofile: | |
710 | ncolspan = 3 |
|
711 | ncolspan = 3 | |
711 | colspan = 2 |
|
712 | colspan = 2 | |
712 | self.__nsubplots = 2 |
|
713 | self.__nsubplots = 2 | |
713 |
|
714 | |||
714 | self.createFigure(id = id, |
|
715 | self.createFigure(id = id, | |
715 | wintitle = wintitle, |
|
716 | wintitle = wintitle, | |
716 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
717 | widthplot = self.WIDTH + self.WIDTHPROF, | |
717 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
718 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
718 | show=show) |
|
719 | show=show) | |
719 |
|
720 | |||
720 | nrow, ncol = self.getSubplots() |
|
721 | nrow, ncol = self.getSubplots() | |
721 |
|
722 | |||
722 | counter = 0 |
|
723 | counter = 0 | |
723 | for y in range(nrow): |
|
724 | for y in range(nrow): | |
724 | for x in range(ncol): |
|
725 | for x in range(ncol): | |
725 |
|
726 | |||
726 | if counter >= self.nplots: |
|
727 | if counter >= self.nplots: | |
727 | break |
|
728 | break | |
728 |
|
729 | |||
729 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
730 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
730 |
|
731 | |||
731 | if showprofile: |
|
732 | if showprofile: | |
732 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
733 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
733 |
|
734 | |||
734 | counter += 1 |
|
735 | counter += 1 | |
735 |
|
736 | |||
736 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, |
|
737 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True, | |
737 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
738 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
738 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
739 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
739 | server=None, folder=None, username=None, password=None, |
|
740 | server=None, folder=None, username=None, password=None, | |
740 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): |
|
741 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False): | |
741 |
|
742 | |||
742 | """ |
|
743 | """ | |
743 |
|
744 | |||
744 | Input: |
|
745 | Input: | |
745 | dataOut : |
|
746 | dataOut : | |
746 | id : |
|
747 | id : | |
747 | wintitle : |
|
748 | wintitle : | |
748 | channelList : |
|
749 | channelList : | |
749 | showProfile : |
|
750 | showProfile : | |
750 | xmin : None, |
|
751 | xmin : None, | |
751 | xmax : None, |
|
752 | xmax : None, | |
752 | ymin : None, |
|
753 | ymin : None, | |
753 | ymax : None, |
|
754 | ymax : None, | |
754 | zmin : None, |
|
755 | zmin : None, | |
755 | zmax : None |
|
756 | zmax : None | |
756 | """ |
|
757 | """ | |
757 |
|
758 | |||
758 | if dataOut.flagNoData: |
|
759 | if dataOut.flagNoData: | |
759 | return None |
|
760 | return None | |
760 |
|
761 | |||
761 | if realtime: |
|
762 | if realtime: | |
762 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
763 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
763 | print 'Skipping this plot function' |
|
764 | print 'Skipping this plot function' | |
764 | return |
|
765 | return | |
765 |
|
766 | |||
766 | if channelList == None: |
|
767 | if channelList == None: | |
767 | channelIndexList = dataOut.channelIndexList |
|
768 | channelIndexList = dataOut.channelIndexList | |
768 | else: |
|
769 | else: | |
769 | channelIndexList = [] |
|
770 | channelIndexList = [] | |
770 | for channel in channelList: |
|
771 | for channel in channelList: | |
771 | if channel not in dataOut.channelList: |
|
772 | if channel not in dataOut.channelList: | |
772 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
773 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
773 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
774 | channelIndexList.append(dataOut.channelList.index(channel)) | |
774 | factor = dataOut.normFactor |
|
775 | factor = dataOut.normFactor | |
775 | x = dataOut.getVelRange(1) |
|
776 | x = dataOut.getVelRange(1) | |
776 | y = dataOut.getHeiRange() |
|
777 | y = dataOut.getHeiRange() | |
777 |
|
778 | |||
778 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
779 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
779 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
780 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
780 | avg = numpy.average(z, axis=1) |
|
781 | avg = numpy.average(z, axis=1) | |
781 | noise = dataOut.getNoise()/factor |
|
782 | noise = dataOut.getNoise()/factor | |
782 |
|
783 | |||
783 | zdB = 10*numpy.log10(z) |
|
784 | zdB = 10*numpy.log10(z) | |
784 | avgdB = 10*numpy.log10(avg) |
|
785 | avgdB = 10*numpy.log10(avg) | |
785 | noisedB = 10*numpy.log10(noise) |
|
786 | noisedB = 10*numpy.log10(noise) | |
786 |
|
787 | |||
787 | #thisDatetime = dataOut.datatime |
|
788 | #thisDatetime = dataOut.datatime | |
788 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
789 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
789 | title = wintitle + " Spectra" |
|
790 | title = wintitle + " Spectra" | |
790 | xlabel = "Velocity (m/s)" |
|
791 | xlabel = "Velocity (m/s)" | |
791 | ylabel = "Range (Km)" |
|
792 | ylabel = "Range (Km)" | |
792 |
|
793 | |||
793 | if not self.__isConfig: |
|
794 | if not self.__isConfig: | |
794 |
|
795 | |||
795 | nplots = len(channelIndexList) |
|
796 | nplots = len(channelIndexList) | |
796 |
|
797 | |||
797 | self.setup(id=id, |
|
798 | self.setup(id=id, | |
798 | nplots=nplots, |
|
799 | nplots=nplots, | |
799 | wintitle=wintitle, |
|
800 | wintitle=wintitle, | |
800 | showprofile=showprofile, |
|
801 | showprofile=showprofile, | |
801 | show=show) |
|
802 | show=show) | |
802 |
|
803 | |||
803 | if xmin == None: xmin = numpy.nanmin(x) |
|
804 | if xmin == None: xmin = numpy.nanmin(x) | |
804 | if xmax == None: xmax = numpy.nanmax(x) |
|
805 | if xmax == None: xmax = numpy.nanmax(x) | |
805 | if ymin == None: ymin = numpy.nanmin(y) |
|
806 | if ymin == None: ymin = numpy.nanmin(y) | |
806 | if ymax == None: ymax = numpy.nanmax(y) |
|
807 | if ymax == None: ymax = numpy.nanmax(y) | |
807 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
808 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
808 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
809 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
809 |
|
810 | |||
810 | self.FTP_WEI = ftp_wei |
|
811 | self.FTP_WEI = ftp_wei | |
811 | self.EXP_CODE = exp_code |
|
812 | self.EXP_CODE = exp_code | |
812 | self.SUB_EXP_CODE = sub_exp_code |
|
813 | self.SUB_EXP_CODE = sub_exp_code | |
813 | self.PLOT_POS = plot_pos |
|
814 | self.PLOT_POS = plot_pos | |
814 |
|
815 | |||
815 | self.__isConfig = True |
|
816 | self.__isConfig = True | |
816 |
|
817 | |||
817 | self.setWinTitle(title) |
|
818 | self.setWinTitle(title) | |
818 |
|
819 | |||
819 | for i in range(self.nplots): |
|
820 | for i in range(self.nplots): | |
820 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
821 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
821 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, noisedB[i], str_datetime) |
|
822 | title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i]+1, noisedB[i], str_datetime) | |
822 | axes = self.axesList[i*self.__nsubplots] |
|
823 | axes = self.axesList[i*self.__nsubplots] | |
823 | axes.pcolor(x, y, zdB[i,:,:], |
|
824 | axes.pcolor(x, y, zdB[i,:,:], | |
824 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
825 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
825 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
826 | xlabel=xlabel, ylabel=ylabel, title=title, | |
826 | ticksize=9, cblabel='') |
|
827 | ticksize=9, cblabel='') | |
827 |
|
828 | |||
828 | if self.__showprofile: |
|
829 | if self.__showprofile: | |
829 | axes = self.axesList[i*self.__nsubplots +1] |
|
830 | axes = self.axesList[i*self.__nsubplots +1] | |
830 | axes.pline(avgdB[i], y, |
|
831 | axes.pline(avgdB[i], y, | |
831 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
832 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
832 | xlabel='dB', ylabel='', title='', |
|
833 | xlabel='dB', ylabel='', title='', | |
833 | ytick_visible=False, |
|
834 | ytick_visible=False, | |
834 | grid='x') |
|
835 | grid='x') | |
835 |
|
836 | |||
836 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
837 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
837 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
838 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
838 |
|
839 | |||
839 | self.draw() |
|
840 | self.draw() | |
840 |
|
841 | |||
841 | if save: |
|
842 | if save: | |
842 |
|
843 | |||
843 | self.counter_imagwr += 1 |
|
844 | self.counter_imagwr += 1 | |
844 | if (self.counter_imagwr==wr_period): |
|
845 | if (self.counter_imagwr==wr_period): | |
845 | if figfile == None: |
|
846 | if figfile == None: | |
846 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
847 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
847 | figfile = self.getFilename(name = str_datetime) |
|
848 | figfile = self.getFilename(name = str_datetime) | |
848 |
|
849 | |||
849 | self.saveFigure(figpath, figfile) |
|
850 | self.saveFigure(figpath, figfile) | |
850 |
|
851 | |||
851 | if ftp: |
|
852 | if ftp: | |
852 | #provisionalmente envia archivos en el formato de la web en tiempo real |
|
853 | #provisionalmente envia archivos en el formato de la web en tiempo real | |
853 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
854 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
854 | path = '%s%03d' %(self.PREFIX, self.id) |
|
855 | path = '%s%03d' %(self.PREFIX, self.id) | |
855 | ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
856 | ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
856 | self.saveFigure(figpath, ftp_file) |
|
857 | self.saveFigure(figpath, ftp_file) | |
857 | ftp_filename = os.path.join(figpath,ftp_file) |
|
858 | ftp_filename = os.path.join(figpath,ftp_file) | |
858 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
859 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
859 | self.counter_imagwr = 0 |
|
860 | self.counter_imagwr = 0 | |
860 |
|
861 | |||
861 |
|
862 | |||
862 | self.counter_imagwr = 0 |
|
863 | self.counter_imagwr = 0 | |
863 |
|
864 | |||
864 |
|
865 | |||
865 | class Scope(Figure): |
|
866 | class Scope(Figure): | |
866 |
|
867 | |||
867 | __isConfig = None |
|
868 | __isConfig = None | |
868 |
|
869 | |||
869 | def __init__(self): |
|
870 | def __init__(self): | |
870 |
|
871 | |||
871 | self.__isConfig = False |
|
872 | self.__isConfig = False | |
872 | self.WIDTH = 300 |
|
873 | self.WIDTH = 300 | |
873 | self.HEIGHT = 200 |
|
874 | self.HEIGHT = 200 | |
874 | self.counter_imagwr = 0 |
|
875 | self.counter_imagwr = 0 | |
875 |
|
876 | |||
876 | def getSubplots(self): |
|
877 | def getSubplots(self): | |
877 |
|
878 | |||
878 | nrow = self.nplots |
|
879 | nrow = self.nplots | |
879 | ncol = 3 |
|
880 | ncol = 3 | |
880 | return nrow, ncol |
|
881 | return nrow, ncol | |
881 |
|
882 | |||
882 | def setup(self, id, nplots, wintitle, show): |
|
883 | def setup(self, id, nplots, wintitle, show): | |
883 |
|
884 | |||
884 | self.nplots = nplots |
|
885 | self.nplots = nplots | |
885 |
|
886 | |||
886 | self.createFigure(id=id, |
|
887 | self.createFigure(id=id, | |
887 | wintitle=wintitle, |
|
888 | wintitle=wintitle, | |
888 | show=show) |
|
889 | show=show) | |
889 |
|
890 | |||
890 | nrow,ncol = self.getSubplots() |
|
891 | nrow,ncol = self.getSubplots() | |
891 | colspan = 3 |
|
892 | colspan = 3 | |
892 | rowspan = 1 |
|
893 | rowspan = 1 | |
893 |
|
894 | |||
894 | for i in range(nplots): |
|
895 | for i in range(nplots): | |
895 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
896 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
896 |
|
897 | |||
897 | def plot_iq(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax): |
|
898 | def plot_iq(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax): | |
898 | yreal = y[channelIndexList,:].real |
|
899 | yreal = y[channelIndexList,:].real | |
899 | yimag = y[channelIndexList,:].imag |
|
900 | yimag = y[channelIndexList,:].imag | |
900 |
|
901 | |||
901 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
902 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
902 | xlabel = "Range (Km)" |
|
903 | xlabel = "Range (Km)" | |
903 | ylabel = "Intensity - IQ" |
|
904 | ylabel = "Intensity - IQ" | |
904 |
|
905 | |||
905 | if not self.__isConfig: |
|
906 | if not self.__isConfig: | |
906 | nplots = len(channelIndexList) |
|
907 | nplots = len(channelIndexList) | |
907 |
|
908 | |||
908 | self.setup(id=id, |
|
909 | self.setup(id=id, | |
909 | nplots=nplots, |
|
910 | nplots=nplots, | |
910 | wintitle='', |
|
911 | wintitle='', | |
911 | show=show) |
|
912 | show=show) | |
912 |
|
913 | |||
913 | if xmin == None: xmin = numpy.nanmin(x) |
|
914 | if xmin == None: xmin = numpy.nanmin(x) | |
914 | if xmax == None: xmax = numpy.nanmax(x) |
|
915 | if xmax == None: xmax = numpy.nanmax(x) | |
915 | if ymin == None: ymin = min(numpy.nanmin(yreal),numpy.nanmin(yimag)) |
|
916 | if ymin == None: ymin = min(numpy.nanmin(yreal),numpy.nanmin(yimag)) | |
916 | if ymax == None: ymax = max(numpy.nanmax(yreal),numpy.nanmax(yimag)) |
|
917 | if ymax == None: ymax = max(numpy.nanmax(yreal),numpy.nanmax(yimag)) | |
917 |
|
918 | |||
918 | self.__isConfig = True |
|
919 | self.__isConfig = True | |
919 |
|
920 | |||
920 | self.setWinTitle(title) |
|
921 | self.setWinTitle(title) | |
921 |
|
922 | |||
922 | for i in range(len(self.axesList)): |
|
923 | for i in range(len(self.axesList)): | |
923 | title = "Channel %d" %(i) |
|
924 | title = "Channel %d" %(i) | |
924 | axes = self.axesList[i] |
|
925 | axes = self.axesList[i] | |
925 |
|
926 | |||
926 | axes.pline(x, yreal[i,:], |
|
927 | axes.pline(x, yreal[i,:], | |
927 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
928 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
928 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
929 | xlabel=xlabel, ylabel=ylabel, title=title) | |
929 |
|
930 | |||
930 | axes.addpline(x, yimag[i,:], idline=1, color="red", linestyle="solid", lw=2) |
|
931 | axes.addpline(x, yimag[i,:], idline=1, color="red", linestyle="solid", lw=2) | |
931 |
|
932 | |||
932 | def plot_power(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax): |
|
933 | def plot_power(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax): | |
933 | y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:]) |
|
934 | y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:]) | |
934 | yreal = y.real |
|
935 | yreal = y.real | |
935 |
|
936 | |||
936 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
937 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
937 | xlabel = "Range (Km)" |
|
938 | xlabel = "Range (Km)" | |
938 | ylabel = "Intensity" |
|
939 | ylabel = "Intensity" | |
939 |
|
940 | |||
940 | if not self.__isConfig: |
|
941 | if not self.__isConfig: | |
941 | nplots = len(channelIndexList) |
|
942 | nplots = len(channelIndexList) | |
942 |
|
943 | |||
943 | self.setup(id=id, |
|
944 | self.setup(id=id, | |
944 | nplots=nplots, |
|
945 | nplots=nplots, | |
945 | wintitle='', |
|
946 | wintitle='', | |
946 | show=show) |
|
947 | show=show) | |
947 |
|
948 | |||
948 | if xmin == None: xmin = numpy.nanmin(x) |
|
949 | if xmin == None: xmin = numpy.nanmin(x) | |
949 | if xmax == None: xmax = numpy.nanmax(x) |
|
950 | if xmax == None: xmax = numpy.nanmax(x) | |
950 | if ymin == None: ymin = numpy.nanmin(yreal) |
|
951 | if ymin == None: ymin = numpy.nanmin(yreal) | |
951 | if ymax == None: ymax = numpy.nanmax(yreal) |
|
952 | if ymax == None: ymax = numpy.nanmax(yreal) | |
952 |
|
953 | |||
953 | self.__isConfig = True |
|
954 | self.__isConfig = True | |
954 |
|
955 | |||
955 | self.setWinTitle(title) |
|
956 | self.setWinTitle(title) | |
956 |
|
957 | |||
957 | for i in range(len(self.axesList)): |
|
958 | for i in range(len(self.axesList)): | |
958 | title = "Channel %d" %(i) |
|
959 | title = "Channel %d" %(i) | |
959 | axes = self.axesList[i] |
|
960 | axes = self.axesList[i] | |
960 | ychannel = yreal[i,:] |
|
961 | ychannel = yreal[i,:] | |
961 | axes.pline(x, ychannel, |
|
962 | axes.pline(x, ychannel, | |
962 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
963 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
963 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
964 | xlabel=xlabel, ylabel=ylabel, title=title) | |
964 |
|
965 | |||
965 |
|
966 | |||
966 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
967 | def run(self, dataOut, id, wintitle="", channelList=None, | |
967 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
968 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, | |
968 | figpath='./', figfile=None, show=True, wr_period=1, |
|
969 | figpath='./', figfile=None, show=True, wr_period=1, | |
969 | server=None, folder=None, username=None, password=None, type='power'): |
|
970 | server=None, folder=None, username=None, password=None, type='power'): | |
970 |
|
971 | |||
971 | """ |
|
972 | """ | |
972 |
|
973 | |||
973 | Input: |
|
974 | Input: | |
974 | dataOut : |
|
975 | dataOut : | |
975 | id : |
|
976 | id : | |
976 | wintitle : |
|
977 | wintitle : | |
977 | channelList : |
|
978 | channelList : | |
978 | xmin : None, |
|
979 | xmin : None, | |
979 | xmax : None, |
|
980 | xmax : None, | |
980 | ymin : None, |
|
981 | ymin : None, | |
981 | ymax : None, |
|
982 | ymax : None, | |
982 | """ |
|
983 | """ | |
983 | if dataOut.flagNoData: |
|
984 | if dataOut.flagNoData: | |
984 | return None |
|
985 | return None | |
985 |
|
986 | |||
986 | if channelList == None: |
|
987 | if channelList == None: | |
987 | channelIndexList = dataOut.channelIndexList |
|
988 | channelIndexList = dataOut.channelIndexList | |
988 | else: |
|
989 | else: | |
989 | channelIndexList = [] |
|
990 | channelIndexList = [] | |
990 | for channel in channelList: |
|
991 | for channel in channelList: | |
991 | if channel not in dataOut.channelList: |
|
992 | if channel not in dataOut.channelList: | |
992 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
993 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
993 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
994 | channelIndexList.append(dataOut.channelList.index(channel)) | |
994 |
|
995 | |||
995 | x = dataOut.heightList |
|
996 | x = dataOut.heightList | |
996 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
997 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
997 | y = y.real |
|
998 | y = y.real | |
998 |
|
999 | |||
999 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1000 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
1000 |
|
1001 | |||
1001 | if type == "power": |
|
1002 | if type == "power": | |
1002 | self.plot_power(dataOut.heightList, |
|
1003 | self.plot_power(dataOut.heightList, | |
1003 | dataOut.data, |
|
1004 | dataOut.data, | |
1004 | id, |
|
1005 | id, | |
1005 | channelIndexList, |
|
1006 | channelIndexList, | |
1006 | thisDatetime, |
|
1007 | thisDatetime, | |
1007 | wintitle, |
|
1008 | wintitle, | |
1008 | show, |
|
1009 | show, | |
1009 | xmin, |
|
1010 | xmin, | |
1010 | xmax, |
|
1011 | xmax, | |
1011 | ymin, |
|
1012 | ymin, | |
1012 | ymax) |
|
1013 | ymax) | |
1013 |
|
1014 | |||
1014 | if type == "iq": |
|
1015 | if type == "iq": | |
1015 | self.plot_iq(dataOut.heightList, |
|
1016 | self.plot_iq(dataOut.heightList, | |
1016 | dataOut.data, |
|
1017 | dataOut.data, | |
1017 | id, |
|
1018 | id, | |
1018 | channelIndexList, |
|
1019 | channelIndexList, | |
1019 | thisDatetime, |
|
1020 | thisDatetime, | |
1020 | wintitle, |
|
1021 | wintitle, | |
1021 | show, |
|
1022 | show, | |
1022 | xmin, |
|
1023 | xmin, | |
1023 | xmax, |
|
1024 | xmax, | |
1024 | ymin, |
|
1025 | ymin, | |
1025 | ymax) |
|
1026 | ymax) | |
1026 |
|
1027 | |||
1027 |
|
1028 | |||
1028 | self.draw() |
|
1029 | self.draw() | |
1029 |
|
1030 | |||
1030 | if save: |
|
1031 | if save: | |
1031 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1032 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1032 | if figfile == None: |
|
1033 | if figfile == None: | |
1033 | figfile = self.getFilename(name = date) |
|
1034 | figfile = self.getFilename(name = date) | |
1034 |
|
1035 | |||
1035 | self.saveFigure(figpath, figfile) |
|
1036 | self.saveFigure(figpath, figfile) | |
1036 |
|
1037 | |||
1037 | self.counter_imagwr += 1 |
|
1038 | self.counter_imagwr += 1 | |
1038 | if (ftp and (self.counter_imagwr==wr_period)): |
|
1039 | if (ftp and (self.counter_imagwr==wr_period)): | |
1039 | ftp_filename = os.path.join(figpath,figfile) |
|
1040 | ftp_filename = os.path.join(figpath,figfile) | |
1040 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
1041 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
1041 | self.counter_imagwr = 0 |
|
1042 | self.counter_imagwr = 0 | |
1042 |
|
1043 | |||
1043 | class PowerProfile(Figure): |
|
1044 | class PowerProfile(Figure): | |
1044 | __isConfig = None |
|
1045 | __isConfig = None | |
1045 | __nsubplots = None |
|
1046 | __nsubplots = None | |
1046 |
|
1047 | |||
1047 | WIDTHPROF = None |
|
1048 | WIDTHPROF = None | |
1048 | HEIGHTPROF = None |
|
1049 | HEIGHTPROF = None | |
1049 | PREFIX = 'spcprofile' |
|
1050 | PREFIX = 'spcprofile' | |
1050 |
|
1051 | |||
1051 | def __init__(self): |
|
1052 | def __init__(self): | |
1052 | self.__isConfig = False |
|
1053 | self.__isConfig = False | |
1053 | self.__nsubplots = 1 |
|
1054 | self.__nsubplots = 1 | |
1054 |
|
1055 | |||
1055 | self.WIDTH = 300 |
|
1056 | self.WIDTH = 300 | |
1056 | self.HEIGHT = 500 |
|
1057 | self.HEIGHT = 500 | |
1057 | self.counter_imagwr = 0 |
|
1058 | self.counter_imagwr = 0 | |
1058 |
|
1059 | |||
1059 | def getSubplots(self): |
|
1060 | def getSubplots(self): | |
1060 | ncol = 1 |
|
1061 | ncol = 1 | |
1061 | nrow = 1 |
|
1062 | nrow = 1 | |
1062 |
|
1063 | |||
1063 | return nrow, ncol |
|
1064 | return nrow, ncol | |
1064 |
|
1065 | |||
1065 | def setup(self, id, nplots, wintitle, show): |
|
1066 | def setup(self, id, nplots, wintitle, show): | |
1066 |
|
1067 | |||
1067 | self.nplots = nplots |
|
1068 | self.nplots = nplots | |
1068 |
|
1069 | |||
1069 | ncolspan = 1 |
|
1070 | ncolspan = 1 | |
1070 | colspan = 1 |
|
1071 | colspan = 1 | |
1071 |
|
1072 | |||
1072 | self.createFigure(id = id, |
|
1073 | self.createFigure(id = id, | |
1073 | wintitle = wintitle, |
|
1074 | wintitle = wintitle, | |
1074 | widthplot = self.WIDTH, |
|
1075 | widthplot = self.WIDTH, | |
1075 | heightplot = self.HEIGHT, |
|
1076 | heightplot = self.HEIGHT, | |
1076 | show=show) |
|
1077 | show=show) | |
1077 |
|
1078 | |||
1078 | nrow, ncol = self.getSubplots() |
|
1079 | nrow, ncol = self.getSubplots() | |
1079 |
|
1080 | |||
1080 | counter = 0 |
|
1081 | counter = 0 | |
1081 | for y in range(nrow): |
|
1082 | for y in range(nrow): | |
1082 | for x in range(ncol): |
|
1083 | for x in range(ncol): | |
1083 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1084 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
1084 |
|
1085 | |||
1085 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
1086 | def run(self, dataOut, id, wintitle="", channelList=None, | |
1086 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1087 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1087 | save=False, figpath='./', figfile=None, show=True, wr_period=1, |
|
1088 | save=False, figpath='./', figfile=None, show=True, wr_period=1, | |
1088 | server=None, folder=None, username=None, password=None,): |
|
1089 | server=None, folder=None, username=None, password=None,): | |
1089 |
|
1090 | |||
1090 | if dataOut.flagNoData: |
|
1091 | if dataOut.flagNoData: | |
1091 | return None |
|
1092 | return None | |
1092 |
|
1093 | |||
1093 | if channelList == None: |
|
1094 | if channelList == None: | |
1094 | channelIndexList = dataOut.channelIndexList |
|
1095 | channelIndexList = dataOut.channelIndexList | |
1095 | channelList = dataOut.channelList |
|
1096 | channelList = dataOut.channelList | |
1096 | else: |
|
1097 | else: | |
1097 | channelIndexList = [] |
|
1098 | channelIndexList = [] | |
1098 | for channel in channelList: |
|
1099 | for channel in channelList: | |
1099 | if channel not in dataOut.channelList: |
|
1100 | if channel not in dataOut.channelList: | |
1100 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1101 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1101 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1102 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1102 |
|
1103 | |||
1103 | try: |
|
1104 | try: | |
1104 | factor = dataOut.normFactor |
|
1105 | factor = dataOut.normFactor | |
1105 | except: |
|
1106 | except: | |
1106 | factor = 1 |
|
1107 | factor = 1 | |
1107 |
|
1108 | |||
1108 | y = dataOut.getHeiRange() |
|
1109 | y = dataOut.getHeiRange() | |
1109 |
|
1110 | |||
1110 | #for voltage |
|
1111 | #for voltage | |
1111 | if dataOut.type == 'Voltage': |
|
1112 | if dataOut.type == 'Voltage': | |
1112 | x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
1113 | x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
1113 | x = x.real |
|
1114 | x = x.real | |
1114 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
1115 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
1115 |
|
1116 | |||
1116 | #for spectra |
|
1117 | #for spectra | |
1117 | if dataOut.type == 'Spectra': |
|
1118 | if dataOut.type == 'Spectra': | |
1118 | x = dataOut.data_spc[channelIndexList,:,:]/factor |
|
1119 | x = dataOut.data_spc[channelIndexList,:,:]/factor | |
1119 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
1120 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
1120 | x = numpy.average(x, axis=1) |
|
1121 | x = numpy.average(x, axis=1) | |
1121 |
|
1122 | |||
1122 |
|
1123 | |||
1123 | xdB = 10*numpy.log10(x) |
|
1124 | xdB = 10*numpy.log10(x) | |
1124 |
|
1125 | |||
1125 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1126 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
1126 | title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1127 | title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1127 | xlabel = "dB" |
|
1128 | xlabel = "dB" | |
1128 | ylabel = "Range (Km)" |
|
1129 | ylabel = "Range (Km)" | |
1129 |
|
1130 | |||
1130 | if not self.__isConfig: |
|
1131 | if not self.__isConfig: | |
1131 |
|
1132 | |||
1132 | nplots = 1 |
|
1133 | nplots = 1 | |
1133 |
|
1134 | |||
1134 | self.setup(id=id, |
|
1135 | self.setup(id=id, | |
1135 | nplots=nplots, |
|
1136 | nplots=nplots, | |
1136 | wintitle=wintitle, |
|
1137 | wintitle=wintitle, | |
1137 | show=show) |
|
1138 | show=show) | |
1138 |
|
1139 | |||
1139 | if ymin == None: ymin = numpy.nanmin(y) |
|
1140 | if ymin == None: ymin = numpy.nanmin(y) | |
1140 | if ymax == None: ymax = numpy.nanmax(y) |
|
1141 | if ymax == None: ymax = numpy.nanmax(y) | |
1141 | if xmin == None: xmin = numpy.nanmin(xdB)*0.9 |
|
1142 | if xmin == None: xmin = numpy.nanmin(xdB)*0.9 | |
1142 | if xmax == None: xmax = numpy.nanmax(xdB)*0.9 |
|
1143 | if xmax == None: xmax = numpy.nanmax(xdB)*0.9 | |
1143 |
|
1144 | |||
1144 | self.__isConfig = True |
|
1145 | self.__isConfig = True | |
1145 |
|
1146 | |||
1146 | self.setWinTitle(title) |
|
1147 | self.setWinTitle(title) | |
1147 |
|
1148 | |||
1148 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1149 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1149 | axes = self.axesList[0] |
|
1150 | axes = self.axesList[0] | |
1150 |
|
1151 | |||
1151 | legendlabels = ["channel %d"%x for x in channelList] |
|
1152 | legendlabels = ["channel %d"%x for x in channelList] | |
1152 | axes.pmultiline(xdB, y, |
|
1153 | axes.pmultiline(xdB, y, | |
1153 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1154 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
1154 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
1155 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
1155 | ytick_visible=True, nxticks=5, |
|
1156 | ytick_visible=True, nxticks=5, | |
1156 | grid='x') |
|
1157 | grid='x') | |
1157 |
|
1158 | |||
1158 | self.draw() |
|
1159 | self.draw() | |
1159 |
|
1160 | |||
1160 | if save: |
|
1161 | if save: | |
1161 | date = thisDatetime.strftime("%Y%m%d") |
|
1162 | date = thisDatetime.strftime("%Y%m%d") | |
1162 | if figfile == None: |
|
1163 | if figfile == None: | |
1163 | figfile = self.getFilename(name = date) |
|
1164 | figfile = self.getFilename(name = date) | |
1164 |
|
1165 | |||
1165 | self.saveFigure(figpath, figfile) |
|
1166 | self.saveFigure(figpath, figfile) | |
1166 |
|
1167 | |||
1167 | self.counter_imagwr += 1 |
|
1168 | self.counter_imagwr += 1 | |
1168 | if (ftp and (self.counter_imagwr==wr_period)): |
|
1169 | if (ftp and (self.counter_imagwr==wr_period)): | |
1169 | ftp_filename = os.path.join(figpath,figfile) |
|
1170 | ftp_filename = os.path.join(figpath,figfile) | |
1170 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
1171 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
1171 | self.counter_imagwr = 0 |
|
1172 | self.counter_imagwr = 0 | |
1172 |
|
1173 | |||
1173 | class CoherenceMap(Figure): |
|
1174 | class CoherenceMap(Figure): | |
1174 | __isConfig = None |
|
1175 | __isConfig = None | |
1175 | __nsubplots = None |
|
1176 | __nsubplots = None | |
1176 |
|
1177 | |||
1177 | WIDTHPROF = None |
|
1178 | WIDTHPROF = None | |
1178 | HEIGHTPROF = None |
|
1179 | HEIGHTPROF = None | |
1179 | PREFIX = 'cmap' |
|
1180 | PREFIX = 'cmap' | |
1180 |
|
1181 | |||
1181 | def __init__(self): |
|
1182 | def __init__(self): | |
1182 | self.timerange = 2*60*60 |
|
1183 | self.timerange = 2*60*60 | |
1183 | self.__isConfig = False |
|
1184 | self.__isConfig = False | |
1184 | self.__nsubplots = 1 |
|
1185 | self.__nsubplots = 1 | |
1185 |
|
1186 | |||
1186 | self.WIDTH = 800 |
|
1187 | self.WIDTH = 800 | |
1187 | self.HEIGHT = 150 |
|
1188 | self.HEIGHT = 150 | |
1188 | self.WIDTHPROF = 120 |
|
1189 | self.WIDTHPROF = 120 | |
1189 | self.HEIGHTPROF = 0 |
|
1190 | self.HEIGHTPROF = 0 | |
1190 | self.counter_imagwr = 0 |
|
1191 | self.counter_imagwr = 0 | |
1191 |
|
1192 | |||
1192 | self.PLOT_CODE = 3 |
|
1193 | self.PLOT_CODE = 3 | |
1193 | self.FTP_WEI = None |
|
1194 | self.FTP_WEI = None | |
1194 | self.EXP_CODE = None |
|
1195 | self.EXP_CODE = None | |
1195 | self.SUB_EXP_CODE = None |
|
1196 | self.SUB_EXP_CODE = None | |
1196 | self.PLOT_POS = None |
|
1197 | self.PLOT_POS = None | |
1197 | self.counter_imagwr = 0 |
|
1198 | self.counter_imagwr = 0 | |
1198 |
|
1199 | |||
1199 | self.xmin = None |
|
1200 | self.xmin = None | |
1200 | self.xmax = None |
|
1201 | self.xmax = None | |
1201 |
|
1202 | |||
1202 | def getSubplots(self): |
|
1203 | def getSubplots(self): | |
1203 | ncol = 1 |
|
1204 | ncol = 1 | |
1204 | nrow = self.nplots*2 |
|
1205 | nrow = self.nplots*2 | |
1205 |
|
1206 | |||
1206 | return nrow, ncol |
|
1207 | return nrow, ncol | |
1207 |
|
1208 | |||
1208 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1209 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1209 | self.__showprofile = showprofile |
|
1210 | self.__showprofile = showprofile | |
1210 | self.nplots = nplots |
|
1211 | self.nplots = nplots | |
1211 |
|
1212 | |||
1212 | ncolspan = 1 |
|
1213 | ncolspan = 1 | |
1213 | colspan = 1 |
|
1214 | colspan = 1 | |
1214 | if showprofile: |
|
1215 | if showprofile: | |
1215 | ncolspan = 7 |
|
1216 | ncolspan = 7 | |
1216 | colspan = 6 |
|
1217 | colspan = 6 | |
1217 | self.__nsubplots = 2 |
|
1218 | self.__nsubplots = 2 | |
1218 |
|
1219 | |||
1219 | self.createFigure(id = id, |
|
1220 | self.createFigure(id = id, | |
1220 | wintitle = wintitle, |
|
1221 | wintitle = wintitle, | |
1221 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1222 | widthplot = self.WIDTH + self.WIDTHPROF, | |
1222 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1223 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
1223 | show=True) |
|
1224 | show=True) | |
1224 |
|
1225 | |||
1225 | nrow, ncol = self.getSubplots() |
|
1226 | nrow, ncol = self.getSubplots() | |
1226 |
|
1227 | |||
1227 | for y in range(nrow): |
|
1228 | for y in range(nrow): | |
1228 | for x in range(ncol): |
|
1229 | for x in range(ncol): | |
1229 |
|
1230 | |||
1230 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1231 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
1231 |
|
1232 | |||
1232 | if showprofile: |
|
1233 | if showprofile: | |
1233 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
1234 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
1234 |
|
1235 | |||
1235 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1236 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
1236 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
1237 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
1237 | timerange=None, |
|
1238 | timerange=None, | |
1238 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, |
|
1239 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, | |
1239 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True, |
|
1240 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True, | |
1240 | server=None, folder=None, username=None, password=None, |
|
1241 | server=None, folder=None, username=None, password=None, | |
1241 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1242 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1242 |
|
1243 | |||
1243 | if pairsList == None: |
|
1244 | if pairsList == None: | |
1244 | pairsIndexList = dataOut.pairsIndexList |
|
1245 | pairsIndexList = dataOut.pairsIndexList | |
1245 | else: |
|
1246 | else: | |
1246 | pairsIndexList = [] |
|
1247 | pairsIndexList = [] | |
1247 | for pair in pairsList: |
|
1248 | for pair in pairsList: | |
1248 | if pair not in dataOut.pairsList: |
|
1249 | if pair not in dataOut.pairsList: | |
1249 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
1250 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
1250 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
1251 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
1251 |
|
1252 | |||
1252 | if timerange != None: |
|
1253 | if timerange != None: | |
1253 | self.timerange = timerange |
|
1254 | self.timerange = timerange | |
1254 |
|
1255 | |||
1255 | if pairsIndexList == []: |
|
1256 | if pairsIndexList == []: | |
1256 | return |
|
1257 | return | |
1257 |
|
1258 | |||
1258 | if len(pairsIndexList) > 4: |
|
1259 | if len(pairsIndexList) > 4: | |
1259 | pairsIndexList = pairsIndexList[0:4] |
|
1260 | pairsIndexList = pairsIndexList[0:4] | |
1260 |
|
1261 | |||
1261 | # tmin = None |
|
1262 | # tmin = None | |
1262 | # tmax = None |
|
1263 | # tmax = None | |
1263 | x = dataOut.getTimeRange() |
|
1264 | x = dataOut.getTimeRange() | |
1264 | y = dataOut.getHeiRange() |
|
1265 | y = dataOut.getHeiRange() | |
1265 |
|
1266 | |||
1266 | #thisDatetime = dataOut.datatime |
|
1267 | #thisDatetime = dataOut.datatime | |
1267 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1268 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
1268 | title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1269 | title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1269 | xlabel = "" |
|
1270 | xlabel = "" | |
1270 | ylabel = "Range (Km)" |
|
1271 | ylabel = "Range (Km)" | |
1271 |
|
1272 | |||
1272 | if not self.__isConfig: |
|
1273 | if not self.__isConfig: | |
1273 | nplots = len(pairsIndexList) |
|
1274 | nplots = len(pairsIndexList) | |
1274 | self.setup(id=id, |
|
1275 | self.setup(id=id, | |
1275 | nplots=nplots, |
|
1276 | nplots=nplots, | |
1276 | wintitle=wintitle, |
|
1277 | wintitle=wintitle, | |
1277 | showprofile=showprofile, |
|
1278 | showprofile=showprofile, | |
1278 | show=show) |
|
1279 | show=show) | |
1279 |
|
1280 | |||
1280 | #tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
1281 | #tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
1281 |
|
1282 | |||
1282 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) |
|
1283 | self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange) | |
1283 |
|
1284 | |||
1284 | if ymin == None: ymin = numpy.nanmin(y) |
|
1285 | if ymin == None: ymin = numpy.nanmin(y) | |
1285 | if ymax == None: ymax = numpy.nanmax(y) |
|
1286 | if ymax == None: ymax = numpy.nanmax(y) | |
1286 | if zmin == None: zmin = 0. |
|
1287 | if zmin == None: zmin = 0. | |
1287 | if zmax == None: zmax = 1. |
|
1288 | if zmax == None: zmax = 1. | |
1288 |
|
1289 | |||
1289 | self.FTP_WEI = ftp_wei |
|
1290 | self.FTP_WEI = ftp_wei | |
1290 | self.EXP_CODE = exp_code |
|
1291 | self.EXP_CODE = exp_code | |
1291 | self.SUB_EXP_CODE = sub_exp_code |
|
1292 | self.SUB_EXP_CODE = sub_exp_code | |
1292 | self.PLOT_POS = plot_pos |
|
1293 | self.PLOT_POS = plot_pos | |
1293 |
|
1294 | |||
1294 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1295 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1295 |
|
1296 | |||
1296 | self.__isConfig = True |
|
1297 | self.__isConfig = True | |
1297 |
|
1298 | |||
1298 | self.setWinTitle(title) |
|
1299 | self.setWinTitle(title) | |
1299 |
|
1300 | |||
1300 | if ((self.xmax - x[1]) < (x[1]-x[0])): |
|
1301 | if ((self.xmax - x[1]) < (x[1]-x[0])): | |
1301 | x[1] = self.xmax |
|
1302 | x[1] = self.xmax | |
1302 |
|
1303 | |||
1303 | for i in range(self.nplots): |
|
1304 | for i in range(self.nplots): | |
1304 |
|
1305 | |||
1305 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
1306 | pair = dataOut.pairsList[pairsIndexList[i]] | |
1306 | # coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
1307 | # coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
1307 | # avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) |
|
1308 | # avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) | |
1308 | # coherence = numpy.abs(avgcoherenceComplex) |
|
1309 | # coherence = numpy.abs(avgcoherenceComplex) | |
1309 |
|
1310 | |||
1310 | ## coherence = numpy.abs(coherenceComplex) |
|
1311 | ## coherence = numpy.abs(coherenceComplex) | |
1311 | ## avg = numpy.average(coherence, axis=0) |
|
1312 | ## avg = numpy.average(coherence, axis=0) | |
1312 |
|
1313 | |||
1313 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) |
|
1314 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) | |
1314 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) |
|
1315 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) | |
1315 | powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0) |
|
1316 | powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0) | |
1316 |
|
1317 | |||
1317 |
|
1318 | |||
1318 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
1319 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
1319 | coherence = numpy.abs(avgcoherenceComplex) |
|
1320 | coherence = numpy.abs(avgcoherenceComplex) | |
1320 |
|
1321 | |||
1321 | z = coherence.reshape((1,-1)) |
|
1322 | z = coherence.reshape((1,-1)) | |
1322 |
|
1323 | |||
1323 | counter = 0 |
|
1324 | counter = 0 | |
1324 |
|
1325 | |||
1325 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1326 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1326 | axes = self.axesList[i*self.__nsubplots*2] |
|
1327 | axes = self.axesList[i*self.__nsubplots*2] | |
1327 | axes.pcolorbuffer(x, y, z, |
|
1328 | axes.pcolorbuffer(x, y, z, | |
1328 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
1329 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
1329 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1330 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1330 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") |
|
1331 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") | |
1331 |
|
1332 | |||
1332 | if self.__showprofile: |
|
1333 | if self.__showprofile: | |
1333 | counter += 1 |
|
1334 | counter += 1 | |
1334 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
1335 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
1335 | axes.pline(coherence, y, |
|
1336 | axes.pline(coherence, y, | |
1336 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
1337 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
1337 | xlabel='', ylabel='', title='', ticksize=7, |
|
1338 | xlabel='', ylabel='', title='', ticksize=7, | |
1338 | ytick_visible=False, nxticks=5, |
|
1339 | ytick_visible=False, nxticks=5, | |
1339 | grid='x') |
|
1340 | grid='x') | |
1340 |
|
1341 | |||
1341 | counter += 1 |
|
1342 | counter += 1 | |
1342 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
1343 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
1343 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
1344 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
1344 | # avg = numpy.average(phase, axis=0) |
|
1345 | # avg = numpy.average(phase, axis=0) | |
1345 | z = phase.reshape((1,-1)) |
|
1346 | z = phase.reshape((1,-1)) | |
1346 |
|
1347 | |||
1347 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1348 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1348 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
1349 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
1349 | axes.pcolorbuffer(x, y, z, |
|
1350 | axes.pcolorbuffer(x, y, z, | |
1350 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
1351 | xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
1351 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
1352 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
1352 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") |
|
1353 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") | |
1353 |
|
1354 | |||
1354 | if self.__showprofile: |
|
1355 | if self.__showprofile: | |
1355 | counter += 1 |
|
1356 | counter += 1 | |
1356 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
1357 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
1357 | axes.pline(phase, y, |
|
1358 | axes.pline(phase, y, | |
1358 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, |
|
1359 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, | |
1359 | xlabel='', ylabel='', title='', ticksize=7, |
|
1360 | xlabel='', ylabel='', title='', ticksize=7, | |
1360 | ytick_visible=False, nxticks=4, |
|
1361 | ytick_visible=False, nxticks=4, | |
1361 | grid='x') |
|
1362 | grid='x') | |
1362 |
|
1363 | |||
1363 | self.draw() |
|
1364 | self.draw() | |
1364 |
|
1365 | |||
1365 | if x[1] >= self.axesList[0].xmax: |
|
1366 | if x[1] >= self.axesList[0].xmax: | |
1366 | self.saveFigure(figpath, figfile) |
|
1367 | self.saveFigure(figpath, figfile) | |
1367 | self.__isConfig = False |
|
1368 | self.__isConfig = False | |
1368 |
|
1369 | |||
1369 | # if save: |
|
1370 | # if save: | |
1370 | # |
|
1371 | # | |
1371 | # self.counter_imagwr += 1 |
|
1372 | # self.counter_imagwr += 1 | |
1372 | # if (self.counter_imagwr==wr_period): |
|
1373 | # if (self.counter_imagwr==wr_period): | |
1373 | # if figfile == None: |
|
1374 | # if figfile == None: | |
1374 | # figfile = self.getFilename(name = self.name) |
|
1375 | # figfile = self.getFilename(name = self.name) | |
1375 | # self.saveFigure(figpath, figfile) |
|
1376 | # self.saveFigure(figpath, figfile) | |
1376 | # |
|
1377 | # | |
1377 | # if ftp: |
|
1378 | # if ftp: | |
1378 | # #provisionalmente envia archivos en el formato de la web en tiempo real |
|
1379 | # #provisionalmente envia archivos en el formato de la web en tiempo real | |
1379 | # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
1380 | # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
1380 | # path = '%s%03d' %(self.PREFIX, self.id) |
|
1381 | # path = '%s%03d' %(self.PREFIX, self.id) | |
1381 | # ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
1382 | # ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
1382 | # self.saveFigure(figpath, ftp_file) |
|
1383 | # self.saveFigure(figpath, ftp_file) | |
1383 | # ftp_filename = os.path.join(figpath,ftp_file) |
|
1384 | # ftp_filename = os.path.join(figpath,ftp_file) | |
1384 | # self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
1385 | # self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
1385 | # self.counter_imagwr = 0 |
|
1386 | # self.counter_imagwr = 0 | |
1386 | # |
|
1387 | # | |
1387 | # self.counter_imagwr = 0 |
|
1388 | # self.counter_imagwr = 0 | |
1388 | # |
|
1389 | # | |
1389 | # |
|
1390 | # | |
1390 | # if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1391 | # if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
1391 | # self.__isConfig = False |
|
1392 | # self.__isConfig = False | |
1392 |
|
1393 | |||
1393 | class BeaconPhase(Figure): |
|
1394 | class BeaconPhase(Figure): | |
1394 |
|
1395 | |||
1395 | __isConfig = None |
|
1396 | __isConfig = None | |
1396 | __nsubplots = None |
|
1397 | __nsubplots = None | |
1397 |
|
1398 | |||
1398 | PREFIX = 'beacon_phase' |
|
1399 | PREFIX = 'beacon_phase' | |
1399 |
|
1400 | |||
1400 | def __init__(self): |
|
1401 | def __init__(self): | |
1401 |
|
1402 | |||
1402 | self.timerange = 24*60*60 |
|
1403 | self.timerange = 24*60*60 | |
1403 | self.__isConfig = False |
|
1404 | self.__isConfig = False | |
1404 | self.__nsubplots = 1 |
|
1405 | self.__nsubplots = 1 | |
1405 | self.counter_imagwr = 0 |
|
1406 | self.counter_imagwr = 0 | |
1406 | self.WIDTH = 600 |
|
1407 | self.WIDTH = 600 | |
1407 | self.HEIGHT = 300 |
|
1408 | self.HEIGHT = 300 | |
1408 | self.WIDTHPROF = 120 |
|
1409 | self.WIDTHPROF = 120 | |
1409 | self.HEIGHTPROF = 0 |
|
1410 | self.HEIGHTPROF = 0 | |
1410 | self.xdata = None |
|
1411 | self.xdata = None | |
1411 | self.ydata = None |
|
1412 | self.ydata = None | |
1412 |
|
1413 | |||
1413 | self.PLOT_CODE = 18 |
|
1414 | self.PLOT_CODE = 18 | |
1414 | self.FTP_WEI = None |
|
1415 | self.FTP_WEI = None | |
1415 | self.EXP_CODE = None |
|
1416 | self.EXP_CODE = None | |
1416 | self.SUB_EXP_CODE = None |
|
1417 | self.SUB_EXP_CODE = None | |
1417 | self.PLOT_POS = None |
|
1418 | self.PLOT_POS = None | |
1418 |
|
1419 | |||
1419 | self.filename_phase = None |
|
1420 | self.filename_phase = None | |
1420 |
|
1421 | |||
1421 | def getSubplots(self): |
|
1422 | def getSubplots(self): | |
1422 |
|
1423 | |||
1423 | ncol = 1 |
|
1424 | ncol = 1 | |
1424 | nrow = 1 |
|
1425 | nrow = 1 | |
1425 |
|
1426 | |||
1426 | return nrow, ncol |
|
1427 | return nrow, ncol | |
1427 |
|
1428 | |||
1428 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1429 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1429 |
|
1430 | |||
1430 | self.__showprofile = showprofile |
|
1431 | self.__showprofile = showprofile | |
1431 | self.nplots = nplots |
|
1432 | self.nplots = nplots | |
1432 |
|
1433 | |||
1433 | ncolspan = 7 |
|
1434 | ncolspan = 7 | |
1434 | colspan = 6 |
|
1435 | colspan = 6 | |
1435 | self.__nsubplots = 2 |
|
1436 | self.__nsubplots = 2 | |
1436 |
|
1437 | |||
1437 | self.createFigure(id = id, |
|
1438 | self.createFigure(id = id, | |
1438 | wintitle = wintitle, |
|
1439 | wintitle = wintitle, | |
1439 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1440 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1440 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1441 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1441 | show=show) |
|
1442 | show=show) | |
1442 |
|
1443 | |||
1443 | nrow, ncol = self.getSubplots() |
|
1444 | nrow, ncol = self.getSubplots() | |
1444 |
|
1445 | |||
1445 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1446 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1446 |
|
1447 | |||
1447 | def save_phase(self, filename_phase): |
|
1448 | def save_phase(self, filename_phase): | |
1448 | f = open(filename_phase,'w+') |
|
1449 | f = open(filename_phase,'w+') | |
1449 | f.write('\n\n') |
|
1450 | f.write('\n\n') | |
1450 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') |
|
1451 | f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n') | |
1451 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) |
|
1452 | f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' ) | |
1452 | f.close() |
|
1453 | f.close() | |
1453 |
|
1454 | |||
1454 | def save_data(self, filename_phase, data, data_datetime): |
|
1455 | def save_data(self, filename_phase, data, data_datetime): | |
1455 | f=open(filename_phase,'a') |
|
1456 | f=open(filename_phase,'a') | |
1456 | timetuple_data = data_datetime.timetuple() |
|
1457 | timetuple_data = data_datetime.timetuple() | |
1457 | day = str(timetuple_data.tm_mday) |
|
1458 | day = str(timetuple_data.tm_mday) | |
1458 | month = str(timetuple_data.tm_mon) |
|
1459 | month = str(timetuple_data.tm_mon) | |
1459 | year = str(timetuple_data.tm_year) |
|
1460 | year = str(timetuple_data.tm_year) | |
1460 | hour = str(timetuple_data.tm_hour) |
|
1461 | hour = str(timetuple_data.tm_hour) | |
1461 | minute = str(timetuple_data.tm_min) |
|
1462 | minute = str(timetuple_data.tm_min) | |
1462 | second = str(timetuple_data.tm_sec) |
|
1463 | second = str(timetuple_data.tm_sec) | |
1463 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') |
|
1464 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') | |
1464 | f.close() |
|
1465 | f.close() | |
1465 |
|
1466 | |||
1466 |
|
1467 | |||
1467 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', |
|
1468 | def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True', | |
1468 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1469 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1469 | timerange=None, |
|
1470 | timerange=None, | |
1470 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1471 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1471 | server=None, folder=None, username=None, password=None, |
|
1472 | server=None, folder=None, username=None, password=None, | |
1472 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1473 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1473 |
|
1474 | |||
1474 | if pairsList == None: |
|
1475 | if pairsList == None: | |
1475 | pairsIndexList = dataOut.pairsIndexList |
|
1476 | pairsIndexList = dataOut.pairsIndexList | |
1476 | else: |
|
1477 | else: | |
1477 | pairsIndexList = [] |
|
1478 | pairsIndexList = [] | |
1478 | for pair in pairsList: |
|
1479 | for pair in pairsList: | |
1479 | if pair not in dataOut.pairsList: |
|
1480 | if pair not in dataOut.pairsList: | |
1480 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
1481 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
1481 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
1482 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
1482 |
|
1483 | |||
1483 | if pairsIndexList == []: |
|
1484 | if pairsIndexList == []: | |
1484 | return |
|
1485 | return | |
1485 |
|
1486 | |||
1486 | # if len(pairsIndexList) > 4: |
|
1487 | # if len(pairsIndexList) > 4: | |
1487 | # pairsIndexList = pairsIndexList[0:4] |
|
1488 | # pairsIndexList = pairsIndexList[0:4] | |
1488 |
|
1489 | |||
1489 | if timerange != None: |
|
1490 | if timerange != None: | |
1490 | self.timerange = timerange |
|
1491 | self.timerange = timerange | |
1491 |
|
1492 | |||
1492 | tmin = None |
|
1493 | tmin = None | |
1493 | tmax = None |
|
1494 | tmax = None | |
1494 | x = dataOut.getTimeRange() |
|
1495 | x = dataOut.getTimeRange() | |
1495 | y = dataOut.getHeiRange() |
|
1496 | y = dataOut.getHeiRange() | |
1496 |
|
1497 | |||
1497 |
|
1498 | |||
1498 | #thisDatetime = dataOut.datatime |
|
1499 | #thisDatetime = dataOut.datatime | |
1499 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1500 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
1500 | title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1501 | title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1501 | xlabel = "Local Time" |
|
1502 | xlabel = "Local Time" | |
1502 | ylabel = "Phase" |
|
1503 | ylabel = "Phase" | |
1503 |
|
1504 | |||
1504 | nplots = len(pairsIndexList) |
|
1505 | nplots = len(pairsIndexList) | |
1505 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) |
|
1506 | #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList))) | |
1506 | phase_beacon = numpy.zeros(len(pairsIndexList)) |
|
1507 | phase_beacon = numpy.zeros(len(pairsIndexList)) | |
1507 | for i in range(nplots): |
|
1508 | for i in range(nplots): | |
1508 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
1509 | pair = dataOut.pairsList[pairsIndexList[i]] | |
1509 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) |
|
1510 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) | |
1510 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) |
|
1511 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) | |
1511 | powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0) |
|
1512 | powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0) | |
1512 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) |
|
1513 | avgcoherenceComplex = ccf/numpy.sqrt(powa*powb) | |
1513 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
1514 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
1514 |
|
1515 | |||
1515 | #print "Phase %d%d" %(pair[0], pair[1]) |
|
1516 | #print "Phase %d%d" %(pair[0], pair[1]) | |
1516 | #print phase[dataOut.beacon_heiIndexList] |
|
1517 | #print phase[dataOut.beacon_heiIndexList] | |
1517 |
|
1518 | |||
1518 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) |
|
1519 | phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList]) | |
1519 |
|
1520 | |||
1520 | if not self.__isConfig: |
|
1521 | if not self.__isConfig: | |
1521 |
|
1522 | |||
1522 | nplots = len(pairsIndexList) |
|
1523 | nplots = len(pairsIndexList) | |
1523 |
|
1524 | |||
1524 | self.setup(id=id, |
|
1525 | self.setup(id=id, | |
1525 | nplots=nplots, |
|
1526 | nplots=nplots, | |
1526 | wintitle=wintitle, |
|
1527 | wintitle=wintitle, | |
1527 | showprofile=showprofile, |
|
1528 | showprofile=showprofile, | |
1528 | show=show) |
|
1529 | show=show) | |
1529 |
|
1530 | |||
1530 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
1531 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
1531 | if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0 |
|
1532 | if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0 | |
1532 | if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0 |
|
1533 | if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0 | |
1533 |
|
1534 | |||
1534 | self.FTP_WEI = ftp_wei |
|
1535 | self.FTP_WEI = ftp_wei | |
1535 | self.EXP_CODE = exp_code |
|
1536 | self.EXP_CODE = exp_code | |
1536 | self.SUB_EXP_CODE = sub_exp_code |
|
1537 | self.SUB_EXP_CODE = sub_exp_code | |
1537 | self.PLOT_POS = plot_pos |
|
1538 | self.PLOT_POS = plot_pos | |
1538 |
|
1539 | |||
1539 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1540 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1540 | self.__isConfig = True |
|
1541 | self.__isConfig = True | |
1541 |
|
1542 | |||
1542 | self.xdata = numpy.array([]) |
|
1543 | self.xdata = numpy.array([]) | |
1543 | self.ydata = numpy.array([]) |
|
1544 | self.ydata = numpy.array([]) | |
1544 |
|
1545 | |||
1545 | #open file beacon phase |
|
1546 | #open file beacon phase | |
1546 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1547 | path = '%s%03d' %(self.PREFIX, self.id) | |
1547 | beacon_file = os.path.join(path,'%s.txt'%self.name) |
|
1548 | beacon_file = os.path.join(path,'%s.txt'%self.name) | |
1548 | self.filename_phase = os.path.join(figpath,beacon_file) |
|
1549 | self.filename_phase = os.path.join(figpath,beacon_file) | |
1549 | #self.save_phase(self.filename_phase) |
|
1550 | #self.save_phase(self.filename_phase) | |
1550 |
|
1551 | |||
1551 |
|
1552 | |||
1552 | #store data beacon phase |
|
1553 | #store data beacon phase | |
1553 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) |
|
1554 | #self.save_data(self.filename_phase, phase_beacon, thisDatetime) | |
1554 |
|
1555 | |||
1555 | self.setWinTitle(title) |
|
1556 | self.setWinTitle(title) | |
1556 |
|
1557 | |||
1557 |
|
1558 | |||
1558 | title = "Beacon Signal %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1559 | title = "Beacon Signal %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1559 |
|
1560 | |||
1560 | legendlabels = ["pairs %d%d"%(pair[0], pair[1]) for pair in dataOut.pairsList] |
|
1561 | legendlabels = ["pairs %d%d"%(pair[0], pair[1]) for pair in dataOut.pairsList] | |
1561 |
|
1562 | |||
1562 | axes = self.axesList[0] |
|
1563 | axes = self.axesList[0] | |
1563 |
|
1564 | |||
1564 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1565 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1565 |
|
1566 | |||
1566 | if len(self.ydata)==0: |
|
1567 | if len(self.ydata)==0: | |
1567 | self.ydata = phase_beacon.reshape(-1,1) |
|
1568 | self.ydata = phase_beacon.reshape(-1,1) | |
1568 | else: |
|
1569 | else: | |
1569 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) |
|
1570 | self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1))) | |
1570 |
|
1571 | |||
1571 |
|
1572 | |||
1572 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1573 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1573 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
1574 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | |
1574 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1575 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1575 | XAxisAsTime=True, grid='both' |
|
1576 | XAxisAsTime=True, grid='both' | |
1576 | ) |
|
1577 | ) | |
1577 |
|
1578 | |||
1578 | self.draw() |
|
1579 | self.draw() | |
1579 |
|
1580 | |||
1580 | if save: |
|
1581 | if save: | |
1581 |
|
1582 | |||
1582 | self.counter_imagwr += 1 |
|
1583 | self.counter_imagwr += 1 | |
1583 | if (self.counter_imagwr==wr_period): |
|
1584 | if (self.counter_imagwr==wr_period): | |
1584 | if figfile == None: |
|
1585 | if figfile == None: | |
1585 | figfile = self.getFilename(name = self.name) |
|
1586 | figfile = self.getFilename(name = self.name) | |
1586 | self.saveFigure(figpath, figfile) |
|
1587 | self.saveFigure(figpath, figfile) | |
1587 |
|
1588 | |||
1588 | if ftp: |
|
1589 | if ftp: | |
1589 | #provisionalmente envia archivos en el formato de la web en tiempo real |
|
1590 | #provisionalmente envia archivos en el formato de la web en tiempo real | |
1590 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
1591 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
1591 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1592 | path = '%s%03d' %(self.PREFIX, self.id) | |
1592 | ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
1593 | ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
1593 | self.saveFigure(figpath, ftp_file) |
|
1594 | self.saveFigure(figpath, ftp_file) | |
1594 | ftp_filename = os.path.join(figpath,ftp_file) |
|
1595 | ftp_filename = os.path.join(figpath,ftp_file) | |
1595 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
1596 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
1596 |
|
1597 | |||
1597 | self.counter_imagwr = 0 |
|
1598 | self.counter_imagwr = 0 | |
1598 |
|
1599 | |||
1599 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1600 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
1600 | self.__isConfig = False |
|
1601 | self.__isConfig = False | |
1601 | del self.xdata |
|
1602 | del self.xdata | |
1602 | del self.ydata |
|
1603 | del self.ydata | |
1603 |
|
1604 | |||
1604 |
|
1605 | |||
1605 |
|
1606 | |||
1606 |
|
1607 | |||
1607 | class Noise(Figure): |
|
1608 | class Noise(Figure): | |
1608 |
|
1609 | |||
1609 | __isConfig = None |
|
1610 | __isConfig = None | |
1610 | __nsubplots = None |
|
1611 | __nsubplots = None | |
1611 |
|
1612 | |||
1612 | PREFIX = 'noise' |
|
1613 | PREFIX = 'noise' | |
1613 |
|
1614 | |||
1614 | def __init__(self): |
|
1615 | def __init__(self): | |
1615 |
|
1616 | |||
1616 | self.timerange = 24*60*60 |
|
1617 | self.timerange = 24*60*60 | |
1617 | self.__isConfig = False |
|
1618 | self.__isConfig = False | |
1618 | self.__nsubplots = 1 |
|
1619 | self.__nsubplots = 1 | |
1619 | self.counter_imagwr = 0 |
|
1620 | self.counter_imagwr = 0 | |
1620 | self.WIDTH = 600 |
|
1621 | self.WIDTH = 600 | |
1621 | self.HEIGHT = 300 |
|
1622 | self.HEIGHT = 300 | |
1622 | self.WIDTHPROF = 120 |
|
1623 | self.WIDTHPROF = 120 | |
1623 | self.HEIGHTPROF = 0 |
|
1624 | self.HEIGHTPROF = 0 | |
1624 | self.xdata = None |
|
1625 | self.xdata = None | |
1625 | self.ydata = None |
|
1626 | self.ydata = None | |
1626 |
|
1627 | |||
1627 | self.PLOT_CODE = 77 |
|
1628 | self.PLOT_CODE = 77 | |
1628 | self.FTP_WEI = None |
|
1629 | self.FTP_WEI = None | |
1629 | self.EXP_CODE = None |
|
1630 | self.EXP_CODE = None | |
1630 | self.SUB_EXP_CODE = None |
|
1631 | self.SUB_EXP_CODE = None | |
1631 | self.PLOT_POS = None |
|
1632 | self.PLOT_POS = None | |
1632 |
|
1633 | |||
1633 | def getSubplots(self): |
|
1634 | def getSubplots(self): | |
1634 |
|
1635 | |||
1635 | ncol = 1 |
|
1636 | ncol = 1 | |
1636 | nrow = 1 |
|
1637 | nrow = 1 | |
1637 |
|
1638 | |||
1638 | return nrow, ncol |
|
1639 | return nrow, ncol | |
1639 |
|
1640 | |||
1640 | def openfile(self, filename): |
|
1641 | def openfile(self, filename): | |
1641 | f = open(filename,'w+') |
|
1642 | f = open(filename,'w+') | |
1642 | f.write('\n\n') |
|
1643 | f.write('\n\n') | |
1643 | f.write('JICAMARCA RADIO OBSERVATORY - Noise \n') |
|
1644 | f.write('JICAMARCA RADIO OBSERVATORY - Noise \n') | |
1644 | f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' ) |
|
1645 | f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' ) | |
1645 | f.close() |
|
1646 | f.close() | |
1646 |
|
1647 | |||
1647 | def save_data(self, filename_phase, data, data_datetime): |
|
1648 | def save_data(self, filename_phase, data, data_datetime): | |
1648 | f=open(filename_phase,'a') |
|
1649 | f=open(filename_phase,'a') | |
1649 | timetuple_data = data_datetime.timetuple() |
|
1650 | timetuple_data = data_datetime.timetuple() | |
1650 | day = str(timetuple_data.tm_mday) |
|
1651 | day = str(timetuple_data.tm_mday) | |
1651 | month = str(timetuple_data.tm_mon) |
|
1652 | month = str(timetuple_data.tm_mon) | |
1652 | year = str(timetuple_data.tm_year) |
|
1653 | year = str(timetuple_data.tm_year) | |
1653 | hour = str(timetuple_data.tm_hour) |
|
1654 | hour = str(timetuple_data.tm_hour) | |
1654 | minute = str(timetuple_data.tm_min) |
|
1655 | minute = str(timetuple_data.tm_min) | |
1655 | second = str(timetuple_data.tm_sec) |
|
1656 | second = str(timetuple_data.tm_sec) | |
1656 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') |
|
1657 | f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n') | |
1657 | f.close() |
|
1658 | f.close() | |
1658 |
|
1659 | |||
1659 |
|
1660 | |||
1660 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1661 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1661 |
|
1662 | |||
1662 | self.__showprofile = showprofile |
|
1663 | self.__showprofile = showprofile | |
1663 | self.nplots = nplots |
|
1664 | self.nplots = nplots | |
1664 |
|
1665 | |||
1665 | ncolspan = 7 |
|
1666 | ncolspan = 7 | |
1666 | colspan = 6 |
|
1667 | colspan = 6 | |
1667 | self.__nsubplots = 2 |
|
1668 | self.__nsubplots = 2 | |
1668 |
|
1669 | |||
1669 | self.createFigure(id = id, |
|
1670 | self.createFigure(id = id, | |
1670 | wintitle = wintitle, |
|
1671 | wintitle = wintitle, | |
1671 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1672 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1672 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1673 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1673 | show=show) |
|
1674 | show=show) | |
1674 |
|
1675 | |||
1675 | nrow, ncol = self.getSubplots() |
|
1676 | nrow, ncol = self.getSubplots() | |
1676 |
|
1677 | |||
1677 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1678 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1678 |
|
1679 | |||
1679 |
|
1680 | |||
1680 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', |
|
1681 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
1681 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1682 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1682 | timerange=None, |
|
1683 | timerange=None, | |
1683 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, |
|
1684 | save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1, | |
1684 | server=None, folder=None, username=None, password=None, |
|
1685 | server=None, folder=None, username=None, password=None, | |
1685 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): |
|
1686 | ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0): | |
1686 |
|
1687 | |||
1687 | if channelList == None: |
|
1688 | if channelList == None: | |
1688 | channelIndexList = dataOut.channelIndexList |
|
1689 | channelIndexList = dataOut.channelIndexList | |
1689 | channelList = dataOut.channelList |
|
1690 | channelList = dataOut.channelList | |
1690 | else: |
|
1691 | else: | |
1691 | channelIndexList = [] |
|
1692 | channelIndexList = [] | |
1692 | for channel in channelList: |
|
1693 | for channel in channelList: | |
1693 | if channel not in dataOut.channelList: |
|
1694 | if channel not in dataOut.channelList: | |
1694 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1695 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1695 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1696 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1696 |
|
1697 | |||
1697 | if timerange != None: |
|
1698 | if timerange != None: | |
1698 | self.timerange = timerange |
|
1699 | self.timerange = timerange | |
1699 |
|
1700 | |||
1700 | tmin = None |
|
1701 | tmin = None | |
1701 | tmax = None |
|
1702 | tmax = None | |
1702 | x = dataOut.getTimeRange() |
|
1703 | x = dataOut.getTimeRange() | |
1703 | y = dataOut.getHeiRange() |
|
1704 | y = dataOut.getHeiRange() | |
1704 | factor = dataOut.normFactor |
|
1705 | factor = dataOut.normFactor | |
1705 | noise = dataOut.getNoise()/factor |
|
1706 | noise = dataOut.getNoise()/factor | |
1706 | noisedB = 10*numpy.log10(noise) |
|
1707 | noisedB = 10*numpy.log10(noise) | |
1707 |
|
1708 | |||
1708 | #thisDatetime = dataOut.datatime |
|
1709 | #thisDatetime = dataOut.datatime | |
1709 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1710 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
1710 | title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1711 | title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1711 | xlabel = "" |
|
1712 | xlabel = "" | |
1712 | ylabel = "Intensity (dB)" |
|
1713 | ylabel = "Intensity (dB)" | |
1713 |
|
1714 | |||
1714 | if not self.__isConfig: |
|
1715 | if not self.__isConfig: | |
1715 |
|
1716 | |||
1716 | nplots = 1 |
|
1717 | nplots = 1 | |
1717 |
|
1718 | |||
1718 | self.setup(id=id, |
|
1719 | self.setup(id=id, | |
1719 | nplots=nplots, |
|
1720 | nplots=nplots, | |
1720 | wintitle=wintitle, |
|
1721 | wintitle=wintitle, | |
1721 | showprofile=showprofile, |
|
1722 | showprofile=showprofile, | |
1722 | show=show) |
|
1723 | show=show) | |
1723 |
|
1724 | |||
1724 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
1725 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
1725 | if ymin == None: ymin = numpy.nanmin(noisedB) - 10.0 |
|
1726 | if ymin == None: ymin = numpy.nanmin(noisedB) - 10.0 | |
1726 | if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0 |
|
1727 | if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0 | |
1727 |
|
1728 | |||
1728 | self.FTP_WEI = ftp_wei |
|
1729 | self.FTP_WEI = ftp_wei | |
1729 | self.EXP_CODE = exp_code |
|
1730 | self.EXP_CODE = exp_code | |
1730 | self.SUB_EXP_CODE = sub_exp_code |
|
1731 | self.SUB_EXP_CODE = sub_exp_code | |
1731 | self.PLOT_POS = plot_pos |
|
1732 | self.PLOT_POS = plot_pos | |
1732 |
|
1733 | |||
1733 |
|
1734 | |||
1734 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1735 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1735 | self.__isConfig = True |
|
1736 | self.__isConfig = True | |
1736 |
|
1737 | |||
1737 | self.xdata = numpy.array([]) |
|
1738 | self.xdata = numpy.array([]) | |
1738 | self.ydata = numpy.array([]) |
|
1739 | self.ydata = numpy.array([]) | |
1739 |
|
1740 | |||
1740 | #open file beacon phase |
|
1741 | #open file beacon phase | |
1741 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1742 | path = '%s%03d' %(self.PREFIX, self.id) | |
1742 | noise_file = os.path.join(path,'%s.txt'%self.name) |
|
1743 | noise_file = os.path.join(path,'%s.txt'%self.name) | |
1743 | self.filename_noise = os.path.join(figpath,noise_file) |
|
1744 | self.filename_noise = os.path.join(figpath,noise_file) | |
1744 | self.openfile(self.filename_noise) |
|
1745 | self.openfile(self.filename_noise) | |
1745 |
|
1746 | |||
1746 |
|
1747 | |||
1747 | #store data beacon phase |
|
1748 | #store data beacon phase | |
1748 | self.save_data(self.filename_noise, noisedB, thisDatetime) |
|
1749 | self.save_data(self.filename_noise, noisedB, thisDatetime) | |
1749 |
|
1750 | |||
1750 |
|
1751 | |||
1751 | self.setWinTitle(title) |
|
1752 | self.setWinTitle(title) | |
1752 |
|
1753 | |||
1753 |
|
1754 | |||
1754 | title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) |
|
1755 | title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S")) | |
1755 |
|
1756 | |||
1756 | legendlabels = ["channel %d"%(idchannel+1) for idchannel in channelList] |
|
1757 | legendlabels = ["channel %d"%(idchannel+1) for idchannel in channelList] | |
1757 | axes = self.axesList[0] |
|
1758 | axes = self.axesList[0] | |
1758 |
|
1759 | |||
1759 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1760 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1760 |
|
1761 | |||
1761 | if len(self.ydata)==0: |
|
1762 | if len(self.ydata)==0: | |
1762 | self.ydata = noisedB[channelIndexList].reshape(-1,1) |
|
1763 | self.ydata = noisedB[channelIndexList].reshape(-1,1) | |
1763 | else: |
|
1764 | else: | |
1764 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) |
|
1765 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) | |
1765 |
|
1766 | |||
1766 |
|
1767 | |||
1767 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1768 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1768 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
1769 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | |
1769 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1770 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1770 | XAxisAsTime=True, grid='both' |
|
1771 | XAxisAsTime=True, grid='both' | |
1771 | ) |
|
1772 | ) | |
1772 |
|
1773 | |||
1773 | self.draw() |
|
1774 | self.draw() | |
1774 |
|
1775 | |||
1775 | # if save: |
|
1776 | # if save: | |
1776 | # |
|
1777 | # | |
1777 | # if figfile == None: |
|
1778 | # if figfile == None: | |
1778 | # figfile = self.getFilename(name = self.name) |
|
1779 | # figfile = self.getFilename(name = self.name) | |
1779 | # |
|
1780 | # | |
1780 | # self.saveFigure(figpath, figfile) |
|
1781 | # self.saveFigure(figpath, figfile) | |
1781 |
|
1782 | |||
1782 | if save: |
|
1783 | if save: | |
1783 |
|
1784 | |||
1784 | self.counter_imagwr += 1 |
|
1785 | self.counter_imagwr += 1 | |
1785 | if (self.counter_imagwr==wr_period): |
|
1786 | if (self.counter_imagwr==wr_period): | |
1786 | if figfile == None: |
|
1787 | if figfile == None: | |
1787 | figfile = self.getFilename(name = self.name) |
|
1788 | figfile = self.getFilename(name = self.name) | |
1788 | self.saveFigure(figpath, figfile) |
|
1789 | self.saveFigure(figpath, figfile) | |
1789 |
|
1790 | |||
1790 | if ftp: |
|
1791 | if ftp: | |
1791 | #provisionalmente envia archivos en el formato de la web en tiempo real |
|
1792 | #provisionalmente envia archivos en el formato de la web en tiempo real | |
1792 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) |
|
1793 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
1793 | path = '%s%03d' %(self.PREFIX, self.id) |
|
1794 | path = '%s%03d' %(self.PREFIX, self.id) | |
1794 | ftp_file = os.path.join(path,'ftp','%s.png'%name) |
|
1795 | ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
1795 | self.saveFigure(figpath, ftp_file) |
|
1796 | self.saveFigure(figpath, ftp_file) | |
1796 | ftp_filename = os.path.join(figpath,ftp_file) |
|
1797 | ftp_filename = os.path.join(figpath,ftp_file) | |
1797 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
1798 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
1798 | self.counter_imagwr = 0 |
|
1799 | self.counter_imagwr = 0 | |
1799 |
|
1800 | |||
1800 | self.counter_imagwr = 0 |
|
1801 | self.counter_imagwr = 0 | |
1801 |
|
1802 | |||
1802 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1803 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
1803 | self.__isConfig = False |
|
1804 | self.__isConfig = False | |
1804 | del self.xdata |
|
1805 | del self.xdata | |
1805 | del self.ydata |
|
1806 | del self.ydata | |
1806 |
|
1807 | |||
1807 |
|
1808 | |||
1808 | class SpectraHeisScope(Figure): |
|
1809 | class SpectraHeisScope(Figure): | |
1809 |
|
1810 | |||
1810 |
|
1811 | |||
1811 | __isConfig = None |
|
1812 | __isConfig = None | |
1812 | __nsubplots = None |
|
1813 | __nsubplots = None | |
1813 |
|
1814 | |||
1814 | WIDTHPROF = None |
|
1815 | WIDTHPROF = None | |
1815 | HEIGHTPROF = None |
|
1816 | HEIGHTPROF = None | |
1816 | PREFIX = 'spc' |
|
1817 | PREFIX = 'spc' | |
1817 |
|
1818 | |||
1818 | def __init__(self): |
|
1819 | def __init__(self): | |
1819 |
|
1820 | |||
1820 | self.__isConfig = False |
|
1821 | self.__isConfig = False | |
1821 | self.__nsubplots = 1 |
|
1822 | self.__nsubplots = 1 | |
1822 |
|
1823 | |||
1823 | self.WIDTH = 230 |
|
1824 | self.WIDTH = 230 | |
1824 | self.HEIGHT = 250 |
|
1825 | self.HEIGHT = 250 | |
1825 | self.WIDTHPROF = 120 |
|
1826 | self.WIDTHPROF = 120 | |
1826 | self.HEIGHTPROF = 0 |
|
1827 | self.HEIGHTPROF = 0 | |
1827 | self.counter_imagwr = 0 |
|
1828 | self.counter_imagwr = 0 | |
1828 |
|
1829 | |||
1829 | def getSubplots(self): |
|
1830 | def getSubplots(self): | |
1830 |
|
1831 | |||
1831 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
1832 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
1832 | nrow = int(self.nplots*1./ncol + 0.9) |
|
1833 | nrow = int(self.nplots*1./ncol + 0.9) | |
1833 |
|
1834 | |||
1834 | return nrow, ncol |
|
1835 | return nrow, ncol | |
1835 |
|
1836 | |||
1836 | def setup(self, id, nplots, wintitle, show): |
|
1837 | def setup(self, id, nplots, wintitle, show): | |
1837 |
|
1838 | |||
1838 | showprofile = False |
|
1839 | showprofile = False | |
1839 | self.__showprofile = showprofile |
|
1840 | self.__showprofile = showprofile | |
1840 | self.nplots = nplots |
|
1841 | self.nplots = nplots | |
1841 |
|
1842 | |||
1842 | ncolspan = 1 |
|
1843 | ncolspan = 1 | |
1843 | colspan = 1 |
|
1844 | colspan = 1 | |
1844 | if showprofile: |
|
1845 | if showprofile: | |
1845 | ncolspan = 3 |
|
1846 | ncolspan = 3 | |
1846 | colspan = 2 |
|
1847 | colspan = 2 | |
1847 | self.__nsubplots = 2 |
|
1848 | self.__nsubplots = 2 | |
1848 |
|
1849 | |||
1849 | self.createFigure(id = id, |
|
1850 | self.createFigure(id = id, | |
1850 | wintitle = wintitle, |
|
1851 | wintitle = wintitle, | |
1851 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1852 | widthplot = self.WIDTH + self.WIDTHPROF, | |
1852 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1853 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
1853 | show = show) |
|
1854 | show = show) | |
1854 |
|
1855 | |||
1855 | nrow, ncol = self.getSubplots() |
|
1856 | nrow, ncol = self.getSubplots() | |
1856 |
|
1857 | |||
1857 | counter = 0 |
|
1858 | counter = 0 | |
1858 | for y in range(nrow): |
|
1859 | for y in range(nrow): | |
1859 | for x in range(ncol): |
|
1860 | for x in range(ncol): | |
1860 |
|
1861 | |||
1861 | if counter >= self.nplots: |
|
1862 | if counter >= self.nplots: | |
1862 | break |
|
1863 | break | |
1863 |
|
1864 | |||
1864 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1865 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
1865 |
|
1866 | |||
1866 | if showprofile: |
|
1867 | if showprofile: | |
1867 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
1868 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
1868 |
|
1869 | |||
1869 | counter += 1 |
|
1870 | counter += 1 | |
1870 |
|
1871 | |||
1871 |
|
1872 | |||
1872 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
1873 | def run(self, dataOut, id, wintitle="", channelList=None, | |
1873 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
1874 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, | |
1874 | figpath='./', figfile=None, ftp=False, wr_period=1, show=True, |
|
1875 | figpath='./', figfile=None, ftp=False, wr_period=1, show=True, | |
1875 | server=None, folder=None, username=None, password=None): |
|
1876 | server=None, folder=None, username=None, password=None): | |
1876 |
|
1877 | |||
1877 | """ |
|
1878 | """ | |
1878 |
|
1879 | |||
1879 | Input: |
|
1880 | Input: | |
1880 | dataOut : |
|
1881 | dataOut : | |
1881 | id : |
|
1882 | id : | |
1882 | wintitle : |
|
1883 | wintitle : | |
1883 | channelList : |
|
1884 | channelList : | |
1884 | xmin : None, |
|
1885 | xmin : None, | |
1885 | xmax : None, |
|
1886 | xmax : None, | |
1886 | ymin : None, |
|
1887 | ymin : None, | |
1887 | ymax : None, |
|
1888 | ymax : None, | |
1888 | """ |
|
1889 | """ | |
1889 |
|
1890 | |||
1890 | if dataOut.realtime: |
|
1891 | if dataOut.realtime: | |
1891 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
1892 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
1892 | print 'Skipping this plot function' |
|
1893 | print 'Skipping this plot function' | |
1893 | return |
|
1894 | return | |
1894 |
|
1895 | |||
1895 | if channelList == None: |
|
1896 | if channelList == None: | |
1896 | channelIndexList = dataOut.channelIndexList |
|
1897 | channelIndexList = dataOut.channelIndexList | |
1897 | else: |
|
1898 | else: | |
1898 | channelIndexList = [] |
|
1899 | channelIndexList = [] | |
1899 | for channel in channelList: |
|
1900 | for channel in channelList: | |
1900 | if channel not in dataOut.channelList: |
|
1901 | if channel not in dataOut.channelList: | |
1901 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1902 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1902 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1903 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1903 |
|
1904 | |||
1904 | # x = dataOut.heightList |
|
1905 | # x = dataOut.heightList | |
1905 | c = 3E8 |
|
1906 | c = 3E8 | |
1906 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1907 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1907 | #deberia cambiar para el caso de 1Mhz y 100KHz |
|
1908 | #deberia cambiar para el caso de 1Mhz y 100KHz | |
1908 | x = numpy.arange(-1*dataOut.nHeights/2.,dataOut.nHeights/2.)*(c/(2*deltaHeight*dataOut.nHeights*1000)) |
|
1909 | x = numpy.arange(-1*dataOut.nHeights/2.,dataOut.nHeights/2.)*(c/(2*deltaHeight*dataOut.nHeights*1000)) | |
1909 | #para 1Mhz descomentar la siguiente linea |
|
1910 | #para 1Mhz descomentar la siguiente linea | |
1910 | #x= x/(10000.0) |
|
1911 | #x= x/(10000.0) | |
1911 | # y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
1912 | # y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
1912 | # y = y.real |
|
1913 | # y = y.real | |
1913 | datadB = 10.*numpy.log10(dataOut.data_spc) |
|
1914 | datadB = 10.*numpy.log10(dataOut.data_spc) | |
1914 | y = datadB |
|
1915 | y = datadB | |
1915 |
|
1916 | |||
1916 | #thisDatetime = dataOut.datatime |
|
1917 | #thisDatetime = dataOut.datatime | |
1917 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
1918 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
1918 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1919 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1919 | xlabel = "" |
|
1920 | xlabel = "" | |
1920 | #para 1Mhz descomentar la siguiente linea |
|
1921 | #para 1Mhz descomentar la siguiente linea | |
1921 | #xlabel = "Frequency x 10000" |
|
1922 | #xlabel = "Frequency x 10000" | |
1922 | ylabel = "Intensity (dB)" |
|
1923 | ylabel = "Intensity (dB)" | |
1923 |
|
1924 | |||
1924 | if not self.__isConfig: |
|
1925 | if not self.__isConfig: | |
1925 | nplots = len(channelIndexList) |
|
1926 | nplots = len(channelIndexList) | |
1926 |
|
1927 | |||
1927 | self.setup(id=id, |
|
1928 | self.setup(id=id, | |
1928 | nplots=nplots, |
|
1929 | nplots=nplots, | |
1929 | wintitle=wintitle, |
|
1930 | wintitle=wintitle, | |
1930 | show=show) |
|
1931 | show=show) | |
1931 |
|
1932 | |||
1932 | if xmin == None: xmin = numpy.nanmin(x) |
|
1933 | if xmin == None: xmin = numpy.nanmin(x) | |
1933 | if xmax == None: xmax = numpy.nanmax(x) |
|
1934 | if xmax == None: xmax = numpy.nanmax(x) | |
1934 | if ymin == None: ymin = numpy.nanmin(y) |
|
1935 | if ymin == None: ymin = numpy.nanmin(y) | |
1935 | if ymax == None: ymax = numpy.nanmax(y) |
|
1936 | if ymax == None: ymax = numpy.nanmax(y) | |
1936 |
|
1937 | |||
1937 | self.__isConfig = True |
|
1938 | self.__isConfig = True | |
1938 |
|
1939 | |||
1939 | self.setWinTitle(title) |
|
1940 | self.setWinTitle(title) | |
1940 |
|
1941 | |||
1941 | for i in range(len(self.axesList)): |
|
1942 | for i in range(len(self.axesList)): | |
1942 | ychannel = y[i,:] |
|
1943 | ychannel = y[i,:] | |
1943 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) |
|
1944 | str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S")) | |
1944 | title = "Channel %d: %4.2fdB: %s" %(i, numpy.max(ychannel), str_datetime) |
|
1945 | title = "Channel %d: %4.2fdB: %s" %(i, numpy.max(ychannel), str_datetime) | |
1945 | axes = self.axesList[i] |
|
1946 | axes = self.axesList[i] | |
1946 | axes.pline(x, ychannel, |
|
1947 | axes.pline(x, ychannel, | |
1947 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1948 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
1948 | xlabel=xlabel, ylabel=ylabel, title=title, grid='both') |
|
1949 | xlabel=xlabel, ylabel=ylabel, title=title, grid='both') | |
1949 |
|
1950 | |||
1950 |
|
1951 | |||
1951 | self.draw() |
|
1952 | self.draw() | |
1952 |
|
1953 | |||
1953 | if save: |
|
1954 | if save: | |
1954 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1955 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1955 | if figfile == None: |
|
1956 | if figfile == None: | |
1956 | figfile = self.getFilename(name = date) |
|
1957 | figfile = self.getFilename(name = date) | |
1957 |
|
1958 | |||
1958 | self.saveFigure(figpath, figfile) |
|
1959 | self.saveFigure(figpath, figfile) | |
1959 |
|
1960 | |||
1960 | self.counter_imagwr += 1 |
|
1961 | self.counter_imagwr += 1 | |
1961 | if (ftp and (self.counter_imagwr==wr_period)): |
|
1962 | if (ftp and (self.counter_imagwr==wr_period)): | |
1962 | ftp_filename = os.path.join(figpath,figfile) |
|
1963 | ftp_filename = os.path.join(figpath,figfile) | |
1963 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
1964 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
1964 | self.counter_imagwr = 0 |
|
1965 | self.counter_imagwr = 0 | |
1965 |
|
1966 | |||
1966 |
|
1967 | |||
1967 | class RTIfromSpectraHeis(Figure): |
|
1968 | class RTIfromSpectraHeis(Figure): | |
1968 |
|
1969 | |||
1969 | __isConfig = None |
|
1970 | __isConfig = None | |
1970 | __nsubplots = None |
|
1971 | __nsubplots = None | |
1971 |
|
1972 | |||
1972 | PREFIX = 'rtinoise' |
|
1973 | PREFIX = 'rtinoise' | |
1973 |
|
1974 | |||
1974 | def __init__(self): |
|
1975 | def __init__(self): | |
1975 |
|
1976 | |||
1976 | self.timerange = 24*60*60 |
|
1977 | self.timerange = 24*60*60 | |
1977 | self.__isConfig = False |
|
1978 | self.__isConfig = False | |
1978 | self.__nsubplots = 1 |
|
1979 | self.__nsubplots = 1 | |
1979 |
|
1980 | |||
1980 | self.WIDTH = 820 |
|
1981 | self.WIDTH = 820 | |
1981 | self.HEIGHT = 200 |
|
1982 | self.HEIGHT = 200 | |
1982 | self.WIDTHPROF = 120 |
|
1983 | self.WIDTHPROF = 120 | |
1983 | self.HEIGHTPROF = 0 |
|
1984 | self.HEIGHTPROF = 0 | |
1984 | self.counter_imagwr = 0 |
|
1985 | self.counter_imagwr = 0 | |
1985 | self.xdata = None |
|
1986 | self.xdata = None | |
1986 | self.ydata = None |
|
1987 | self.ydata = None | |
1987 |
|
1988 | |||
1988 | def getSubplots(self): |
|
1989 | def getSubplots(self): | |
1989 |
|
1990 | |||
1990 | ncol = 1 |
|
1991 | ncol = 1 | |
1991 | nrow = 1 |
|
1992 | nrow = 1 | |
1992 |
|
1993 | |||
1993 | return nrow, ncol |
|
1994 | return nrow, ncol | |
1994 |
|
1995 | |||
1995 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): |
|
1996 | def setup(self, id, nplots, wintitle, showprofile=True, show=True): | |
1996 |
|
1997 | |||
1997 | self.__showprofile = showprofile |
|
1998 | self.__showprofile = showprofile | |
1998 | self.nplots = nplots |
|
1999 | self.nplots = nplots | |
1999 |
|
2000 | |||
2000 | ncolspan = 7 |
|
2001 | ncolspan = 7 | |
2001 | colspan = 6 |
|
2002 | colspan = 6 | |
2002 | self.__nsubplots = 2 |
|
2003 | self.__nsubplots = 2 | |
2003 |
|
2004 | |||
2004 | self.createFigure(id = id, |
|
2005 | self.createFigure(id = id, | |
2005 | wintitle = wintitle, |
|
2006 | wintitle = wintitle, | |
2006 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
2007 | widthplot = self.WIDTH+self.WIDTHPROF, | |
2007 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
2008 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
2008 | show = show) |
|
2009 | show = show) | |
2009 |
|
2010 | |||
2010 | nrow, ncol = self.getSubplots() |
|
2011 | nrow, ncol = self.getSubplots() | |
2011 |
|
2012 | |||
2012 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
2013 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
2013 |
|
2014 | |||
2014 |
|
2015 | |||
2015 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', |
|
2016 | def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True', | |
2016 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
2017 | xmin=None, xmax=None, ymin=None, ymax=None, | |
2017 | timerange=None, |
|
2018 | timerange=None, | |
2018 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, show=True, |
|
2019 | save=False, figpath='./', figfile=None, ftp=False, wr_period=1, show=True, | |
2019 | server=None, folder=None, username=None, password=None): |
|
2020 | server=None, folder=None, username=None, password=None): | |
2020 |
|
2021 | |||
2021 | if channelList == None: |
|
2022 | if channelList == None: | |
2022 | channelIndexList = dataOut.channelIndexList |
|
2023 | channelIndexList = dataOut.channelIndexList | |
2023 | channelList = dataOut.channelList |
|
2024 | channelList = dataOut.channelList | |
2024 | else: |
|
2025 | else: | |
2025 | channelIndexList = [] |
|
2026 | channelIndexList = [] | |
2026 | for channel in channelList: |
|
2027 | for channel in channelList: | |
2027 | if channel not in dataOut.channelList: |
|
2028 | if channel not in dataOut.channelList: | |
2028 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
2029 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
2029 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
2030 | channelIndexList.append(dataOut.channelList.index(channel)) | |
2030 |
|
2031 | |||
2031 | if timerange != None: |
|
2032 | if timerange != None: | |
2032 | self.timerange = timerange |
|
2033 | self.timerange = timerange | |
2033 |
|
2034 | |||
2034 | tmin = None |
|
2035 | tmin = None | |
2035 | tmax = None |
|
2036 | tmax = None | |
2036 | x = dataOut.getTimeRange() |
|
2037 | x = dataOut.getTimeRange() | |
2037 | y = dataOut.getHeiRange() |
|
2038 | y = dataOut.getHeiRange() | |
2038 |
|
2039 | |||
2039 | #factor = 1 |
|
2040 | #factor = 1 | |
2040 | data = dataOut.data_spc#/factor |
|
2041 | data = dataOut.data_spc#/factor | |
2041 | data = numpy.average(data,axis=1) |
|
2042 | data = numpy.average(data,axis=1) | |
2042 | datadB = 10*numpy.log10(data) |
|
2043 | datadB = 10*numpy.log10(data) | |
2043 |
|
2044 | |||
2044 | # factor = dataOut.normFactor |
|
2045 | # factor = dataOut.normFactor | |
2045 | # noise = dataOut.getNoise()/factor |
|
2046 | # noise = dataOut.getNoise()/factor | |
2046 | # noisedB = 10*numpy.log10(noise) |
|
2047 | # noisedB = 10*numpy.log10(noise) | |
2047 |
|
2048 | |||
2048 | #thisDatetime = dataOut.datatime |
|
2049 | #thisDatetime = dataOut.datatime | |
2049 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) |
|
2050 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[1]) | |
2050 | title = wintitle + " RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
2051 | title = wintitle + " RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
2051 | xlabel = "Local Time" |
|
2052 | xlabel = "Local Time" | |
2052 | ylabel = "Intensity (dB)" |
|
2053 | ylabel = "Intensity (dB)" | |
2053 |
|
2054 | |||
2054 | if not self.__isConfig: |
|
2055 | if not self.__isConfig: | |
2055 |
|
2056 | |||
2056 | nplots = 1 |
|
2057 | nplots = 1 | |
2057 |
|
2058 | |||
2058 | self.setup(id=id, |
|
2059 | self.setup(id=id, | |
2059 | nplots=nplots, |
|
2060 | nplots=nplots, | |
2060 | wintitle=wintitle, |
|
2061 | wintitle=wintitle, | |
2061 | showprofile=showprofile, |
|
2062 | showprofile=showprofile, | |
2062 | show=show) |
|
2063 | show=show) | |
2063 |
|
2064 | |||
2064 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
2065 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
2065 | if ymin == None: ymin = numpy.nanmin(datadB) |
|
2066 | if ymin == None: ymin = numpy.nanmin(datadB) | |
2066 | if ymax == None: ymax = numpy.nanmax(datadB) |
|
2067 | if ymax == None: ymax = numpy.nanmax(datadB) | |
2067 |
|
2068 | |||
2068 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
2069 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
2069 | self.__isConfig = True |
|
2070 | self.__isConfig = True | |
2070 |
|
2071 | |||
2071 | self.xdata = numpy.array([]) |
|
2072 | self.xdata = numpy.array([]) | |
2072 | self.ydata = numpy.array([]) |
|
2073 | self.ydata = numpy.array([]) | |
2073 |
|
2074 | |||
2074 | self.setWinTitle(title) |
|
2075 | self.setWinTitle(title) | |
2075 |
|
2076 | |||
2076 |
|
2077 | |||
2077 | # title = "RTI %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
2078 | # title = "RTI %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
2078 | title = "RTI - %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
2079 | title = "RTI - %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
2079 |
|
2080 | |||
2080 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] |
|
2081 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] | |
2081 | axes = self.axesList[0] |
|
2082 | axes = self.axesList[0] | |
2082 |
|
2083 | |||
2083 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
2084 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
2084 |
|
2085 | |||
2085 | if len(self.ydata)==0: |
|
2086 | if len(self.ydata)==0: | |
2086 | self.ydata = datadB[channelIndexList].reshape(-1,1) |
|
2087 | self.ydata = datadB[channelIndexList].reshape(-1,1) | |
2087 | else: |
|
2088 | else: | |
2088 | self.ydata = numpy.hstack((self.ydata, datadB[channelIndexList].reshape(-1,1))) |
|
2089 | self.ydata = numpy.hstack((self.ydata, datadB[channelIndexList].reshape(-1,1))) | |
2089 |
|
2090 | |||
2090 |
|
2091 | |||
2091 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
2092 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
2092 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
2093 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | |
2093 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='.', markersize=8, linestyle="solid", grid='both', |
|
2094 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='.', markersize=8, linestyle="solid", grid='both', | |
2094 | XAxisAsTime=True |
|
2095 | XAxisAsTime=True | |
2095 | ) |
|
2096 | ) | |
2096 |
|
2097 | |||
2097 | self.draw() |
|
2098 | self.draw() | |
2098 |
|
2099 | |||
2099 | if save: |
|
2100 | if save: | |
2100 |
|
2101 | |||
2101 | if figfile == None: |
|
2102 | if figfile == None: | |
2102 | figfile = self.getFilename(name = self.name) |
|
2103 | figfile = self.getFilename(name = self.name) | |
2103 |
|
2104 | |||
2104 | self.saveFigure(figpath, figfile) |
|
2105 | self.saveFigure(figpath, figfile) | |
2105 |
|
2106 | |||
2106 | self.counter_imagwr += 1 |
|
2107 | self.counter_imagwr += 1 | |
2107 | if (ftp and (self.counter_imagwr==wr_period)): |
|
2108 | if (ftp and (self.counter_imagwr==wr_period)): | |
2108 | ftp_filename = os.path.join(figpath,figfile) |
|
2109 | ftp_filename = os.path.join(figpath,figfile) | |
2109 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) |
|
2110 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
2110 | self.counter_imagwr = 0 |
|
2111 | self.counter_imagwr = 0 | |
2111 |
|
2112 | |||
2112 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
2113 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
2113 | self.__isConfig = False |
|
2114 | self.__isConfig = False | |
2114 | del self.xdata |
|
2115 | del self.xdata | |
2115 | del self.ydata |
|
2116 | del self.ydata | |
2116 |
|
2117 | |||
2117 |
|
2118 | |||
2118 | No newline at end of file |
|
2119 |
@@ -1,93 +1,287 | |||||
1 | import os, sys |
|
1 | import os, sys | |
2 |
|
2 | |||
3 | path = os.path.split(os.getcwd())[0] |
|
3 | path = os.path.split(os.getcwd())[0] | |
4 | sys.path.append(path) |
|
4 | sys.path.append(path) | |
5 |
|
5 | |||
6 | from controller import * |
|
6 | from controller import * | |
7 |
|
7 | |||
8 | desc = "AMISR Experiment Test" |
|
8 | desc = "AMISR Experiment Test" | |
9 | filename = "amisr.xml" |
|
9 | filename = "amisr.xml" | |
10 |
|
10 | |||
11 | controllerObj = Project() |
|
11 | controllerObj = Project() | |
12 |
|
12 | |||
13 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
13 | controllerObj.setup(id = '191', name='test01', description=desc) | |
14 |
|
14 | |||
15 | path = '/home/administrator/Documents/amisr' |
|
15 | path = '/home/administrator/Documents/amisr' | |
|
16 | path = '/media/administrator/New Volume/amisr' | |||
|
17 | ||||
|
18 | figpath = '/home/administrator/Pictures/amisr' | |||
|
19 | ||||
|
20 | figfile0 = 'amisr_rti_beam0.png' | |||
|
21 | figfile1 = 'amisr_rti_beam1.png' | |||
|
22 | figfile2 = 'amisr_rti_beam2.png' | |||
|
23 | figfile3 = 'amisr_rti_beam3.png' | |||
|
24 | figfile4 = 'amisr_rti_beam4.png' | |||
|
25 | figfile5 = 'amisr_rti_beam5.png' | |||
|
26 | figfile6 = 'amisr_rti_beam6.png' | |||
|
27 | ||||
|
28 | title0 = 'RTI AMISR Beam 0' | |||
|
29 | title1 = 'RTI AMISR Beam 1' | |||
|
30 | title2 = 'RTI AMISR Beam 2' | |||
|
31 | title3 = 'RTI AMISR Beam 3' | |||
|
32 | title4 = 'RTI AMISR Beam 4' | |||
|
33 | title5 = 'RTI AMISR Beam 5' | |||
|
34 | title6 = 'RTI AMISR Beam 6' | |||
16 |
|
35 | |||
17 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISR', |
|
36 | readUnitConfObj = controllerObj.addReadUnit(datatype='AMISR', | |
18 | path=path, |
|
37 | path=path, | |
19 |
startDate='2014/08/1 |
|
38 | startDate='2014/08/19', | |
20 |
endDate='2014/08/1 |
|
39 | endDate='2014/08/19', | |
21 | startTime='00:00:00', |
|
40 | startTime='00:00:00', | |
22 | endTime='23:59:59', |
|
41 | endTime='23:59:59', | |
23 | walk=1) |
|
42 | walk=1) | |
24 |
|
43 | |||
25 | procUnitConfObjBeam0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
44 | procUnitConfObjBeam0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
26 | procUnitConfObjBeam1 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
45 | procUnitConfObjBeam1 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
27 | procUnitConfObjBeam2 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
46 | procUnitConfObjBeam2 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
28 | procUnitConfObjBeam3 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
47 | procUnitConfObjBeam3 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
29 | procUnitConfObjBeam4 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
48 | procUnitConfObjBeam4 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
30 | procUnitConfObjBeam5 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
49 | procUnitConfObjBeam5 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
31 | procUnitConfObjBeam6 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) |
|
50 | procUnitConfObjBeam6 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
32 |
|
51 | |||
33 | # Beam0 |
|
52 | ||
|
53 | ||||
|
54 | ||||
|
55 | ############################# Beam0 ############################# | |||
34 | opObj11 = procUnitConfObjBeam0.addOperation(name='ProfileSelector', optype='other') |
|
56 | opObj11 = procUnitConfObjBeam0.addOperation(name='ProfileSelector', optype='other') | |
35 | opObj11.addParameter(name='profileRangeList', value='0,81', format='intlist') |
|
57 | opObj11.addParameter(name='profileRangeList', value='0,81', format='intlist') | |
36 |
|
58 | |||
37 |
opObj11 = procUnitConfObjBeam0.addOperation(name=' |
|
59 | opObj11 = procUnitConfObjBeam0.addOperation(name='CohInt', optype='other') | |
38 |
opObj11.addParameter(name=' |
|
60 | opObj11.addParameter(name='n', value='82', format='int') | |
39 | opObj11.addParameter(name='wintitle', value='AMISR Beam0 - Power Profile', format='str') |
|
61 | ||
|
62 | procUnitConfObjSpectraBeam0 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam0.getId()) | |||
|
63 | procUnitConfObjSpectraBeam0.addParameter(name='nFFTPoints', value='32', format='int') | |||
|
64 | procUnitConfObjSpectraBeam0.addParameter(name='nProfiles', value='32', format='int') | |||
|
65 | ||||
|
66 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='getNoise') | |||
|
67 | opObj11.addParameter(name='minHei', value='100', format='float') | |||
|
68 | opObj11.addParameter(name='maxHei', value='450', format='float') | |||
|
69 | ||||
|
70 | opObj11 = procUnitConfObjSpectraBeam0.addOperation(name='RTIPlot', optype='other') | |||
|
71 | opObj11.addParameter(name='id', value='200', format='int') | |||
|
72 | opObj11.addParameter(name='wintitle', value=title0, format='str') | |||
|
73 | opObj11.addParameter(name='xmin', value='0', format='int') | |||
|
74 | opObj11.addParameter(name='xmax', value='18', format='int') | |||
|
75 | opObj11.addParameter(name='zmin', value='45', format='int') | |||
|
76 | opObj11.addParameter(name='zmax', value='70', format='int') | |||
|
77 | #opObj11.addParameter(name='timerange', value='7200', format='int') | |||
|
78 | opObj11.addParameter(name='showprofile', value='0', format='int') | |||
|
79 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |||
|
80 | opObj11.addParameter(name='figfile', value=figfile0, format='str') | |||
|
81 | ||||
|
82 | ||||
40 |
|
83 | |||
41 | # Beam1 |
|
84 | ||
|
85 | ||||
|
86 | # | |||
|
87 | ############################# Beam1 ############################# | |||
42 | opObj11 = procUnitConfObjBeam1.addOperation(name='ProfileSelector', optype='other') |
|
88 | opObj11 = procUnitConfObjBeam1.addOperation(name='ProfileSelector', optype='other') | |
43 | opObj11.addParameter(name='profileRangeList', value='82,209', format='intlist') |
|
89 | opObj11.addParameter(name='profileRangeList', value='82,209', format='intlist') | |
44 | opObj11 = procUnitConfObjBeam1.addOperation(name='PowerProfile', optype='other') |
|
|||
45 | opObj11.addParameter(name='id', value='11', format='int') |
|
|||
46 | opObj11.addParameter(name='wintitle', value='AMISR Beam1 - Power Profile', format='str') |
|
|||
47 |
|
90 | |||
48 | # # Beam2 |
|
91 | opObj11 = procUnitConfObjBeam1.addOperation(name='CohInt', optype='other') | |
|
92 | opObj11.addParameter(name='n', value='128', format='int') | |||
|
93 | ||||
|
94 | procUnitConfObjSpectraBeam1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam1.getId()) | |||
|
95 | procUnitConfObjSpectraBeam1.addParameter(name='nFFTPoints', value='32', format='int') | |||
|
96 | procUnitConfObjSpectraBeam1.addParameter(name='nProfiles', value='32', format='int') | |||
|
97 | ||||
|
98 | opObj11 = procUnitConfObjSpectraBeam1.addOperation(name='getNoise') | |||
|
99 | opObj11.addParameter(name='minHei', value='100', format='float') | |||
|
100 | opObj11.addParameter(name='maxHei', value='450', format='float') | |||
|
101 | ||||
|
102 | #opObj11 = procUnitConfObjSpectraBeam1.addOperation(name='SpectraPlot', optype='other') | |||
|
103 | #opObj11.addParameter(name='id', value='100', format='int') | |||
|
104 | #opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') | |||
|
105 | # opObj11.addParameter(name='zmin', value='45', format='int') | |||
|
106 | # opObj11.addParameter(name='zmax', value='70', format='int') | |||
|
107 | # opObj11.addParameter(name='save', value='1', format='bool') | |||
|
108 | # opObj11.addParameter(name='figpath', value='/Users/administrator/Pictures/amisr', format='str') | |||
|
109 | ||||
|
110 | opObj11 = procUnitConfObjSpectraBeam1.addOperation(name='RTIPlot', optype='other') | |||
|
111 | opObj11.addParameter(name='id', value='201', format='int') | |||
|
112 | opObj11.addParameter(name='wintitle', value=title1, format='str') | |||
|
113 | #opObj11.addParameter(name='timerange', value='36000', format='int') | |||
|
114 | opObj11.addParameter(name='xmin', value='0', format='int') | |||
|
115 | opObj11.addParameter(name='xmax', value='18', format='int') | |||
|
116 | opObj11.addParameter(name='zmin', value='45', format='int') | |||
|
117 | opObj11.addParameter(name='zmax', value='70', format='int') | |||
|
118 | opObj11.addParameter(name='showprofile', value='0', format='int') | |||
|
119 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |||
|
120 | opObj11.addParameter(name='figfile', value=figfile1, format='str') | |||
|
121 | # | |||
|
122 | # | |||
|
123 | # | |||
|
124 | # | |||
|
125 | # | |||
|
126 | ############################## Beam2 ############################# | |||
49 | opObj11 = procUnitConfObjBeam2.addOperation(name='ProfileSelector', optype='other') |
|
127 | opObj11 = procUnitConfObjBeam2.addOperation(name='ProfileSelector', optype='other') | |
50 | opObj11.addParameter(name='profileRangeList', value='210,337', format='intlist') |
|
128 | opObj11.addParameter(name='profileRangeList', value='210,337', format='intlist') | |
51 | opObj11 = procUnitConfObjBeam2.addOperation(name='PowerProfile', optype='other') |
|
129 | ||
52 | opObj11.addParameter(name='id', value='12', format='int') |
|
130 | opObj11 = procUnitConfObjBeam2.addOperation(name='CohInt', optype='other') | |
53 |
opObj11.addParameter(name=' |
|
131 | opObj11.addParameter(name='n', value='128', format='int') | |
54 | # |
|
132 | ||
55 | # # Beam3 |
|
133 | procUnitConfObjSpectraBeam2 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam2.getId()) | |
|
134 | procUnitConfObjSpectraBeam2.addParameter(name='nFFTPoints', value='32', format='int') | |||
|
135 | procUnitConfObjSpectraBeam2.addParameter(name='nProfiles', value='32', format='int') | |||
|
136 | ||||
|
137 | opObj11 = procUnitConfObjSpectraBeam2.addOperation(name='getNoise') | |||
|
138 | opObj11.addParameter(name='minHei', value='100', format='float') | |||
|
139 | opObj11.addParameter(name='maxHei', value='450', format='float') | |||
|
140 | ||||
|
141 | opObj11 = procUnitConfObjSpectraBeam2.addOperation(name='RTIPlot', optype='other') | |||
|
142 | opObj11.addParameter(name='id', value='202', format='int') | |||
|
143 | opObj11.addParameter(name='wintitle', value=title2, format='str') | |||
|
144 | #opObj11.addParameter(name='timerange', value='18000', format='int') | |||
|
145 | opObj11.addParameter(name='xmin', value='0', format='int') | |||
|
146 | opObj11.addParameter(name='xmax', value='18', format='int') | |||
|
147 | opObj11.addParameter(name='zmin', value='45', format='int') | |||
|
148 | opObj11.addParameter(name='zmax', value='70', format='int') | |||
|
149 | opObj11.addParameter(name='showprofile', value='0', format='int') | |||
|
150 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |||
|
151 | opObj11.addParameter(name='figfile', value=figfile2, format='str') | |||
|
152 | # # | |||
|
153 | # # | |||
|
154 | # # | |||
|
155 | # # | |||
|
156 | # # | |||
|
157 | # # | |||
|
158 | ############################## Beam3 ############################# | |||
56 | opObj11 = procUnitConfObjBeam3.addOperation(name='ProfileSelector', optype='other') |
|
159 | opObj11 = procUnitConfObjBeam3.addOperation(name='ProfileSelector', optype='other') | |
57 | opObj11.addParameter(name='profileRangeList', value='338,465', format='intlist') |
|
160 | opObj11.addParameter(name='profileRangeList', value='338,465', format='intlist') | |
58 | opObj11 = procUnitConfObjBeam3.addOperation(name='PowerProfile', optype='other') |
|
|||
59 | opObj11.addParameter(name='id', value='13', format='int') |
|
|||
60 | opObj11.addParameter(name='wintitle', value='AMISR Beam3 - Power Profile', format='str') |
|
|||
61 |
|
161 | |||
62 | # # Beam4 |
|
162 | opObj11 = procUnitConfObjBeam3.addOperation(name='CohInt', optype='other') | |
|
163 | opObj11.addParameter(name='n', value='128', format='int') | |||
|
164 | ||||
|
165 | procUnitConfObjSpectraBeam3 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam3.getId()) | |||
|
166 | procUnitConfObjSpectraBeam3.addParameter(name='nFFTPoints', value='32', format='int') | |||
|
167 | procUnitConfObjSpectraBeam3.addParameter(name='nProfiles', value='32', format='int') | |||
|
168 | ||||
|
169 | opObj11 = procUnitConfObjSpectraBeam3.addOperation(name='getNoise') | |||
|
170 | opObj11.addParameter(name='minHei', value='100', format='float') | |||
|
171 | opObj11.addParameter(name='maxHei', value='450', format='float') | |||
|
172 | ||||
|
173 | opObj11 = procUnitConfObjSpectraBeam3.addOperation(name='RTIPlot', optype='other') | |||
|
174 | opObj11.addParameter(name='id', value='203', format='int') | |||
|
175 | opObj11.addParameter(name='wintitle', value=title3, format='str') | |||
|
176 | #opObj11.addParameter(name='timerange', value='18000', format='int') | |||
|
177 | opObj11.addParameter(name='xmin', value='0', format='int') | |||
|
178 | opObj11.addParameter(name='xmax', value='18', format='int') | |||
|
179 | opObj11.addParameter(name='zmin', value='45', format='int') | |||
|
180 | opObj11.addParameter(name='zmax', value='70', format='int') | |||
|
181 | opObj11.addParameter(name='showprofile', value='0', format='int') | |||
|
182 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |||
|
183 | opObj11.addParameter(name='figfile', value=figfile3, format='str') | |||
|
184 | # # | |||
|
185 | # # | |||
|
186 | # # | |||
|
187 | # # | |||
|
188 | # # | |||
|
189 | # # | |||
|
190 | ############################## Beam4 ############################# | |||
63 | opObj11 = procUnitConfObjBeam4.addOperation(name='ProfileSelector', optype='other') |
|
191 | opObj11 = procUnitConfObjBeam4.addOperation(name='ProfileSelector', optype='other') | |
64 | opObj11.addParameter(name='profileRangeList', value='466,593', format='intlist') |
|
192 | opObj11.addParameter(name='profileRangeList', value='466,593', format='intlist') | |
65 | opObj11 = procUnitConfObjBeam4.addOperation(name='PowerProfile', optype='other') |
|
|||
66 | opObj11.addParameter(name='id', value='14', format='int') |
|
|||
67 | opObj11.addParameter(name='wintitle', value='AMISR Beam4 - Power Profile', format='str') |
|
|||
68 | # |
|
|||
69 | # # Beam5 |
|
|||
70 | # opObj11 = procUnitConfObjBeam5.addOperation(name='ProfileSelector', optype='other') |
|
|||
71 | # opObj11.addParameter(name='profileRangeList', value='594,721', format='intlist') |
|
|||
72 | # opObj11 = procUnitConfObjBeam5.addOperation(name='PowerProfile', optype='other') |
|
|||
73 | # opObj11.addParameter(name='id', value='15', format='int') |
|
|||
74 | # opObj11.addParameter(name='wintitle', value='AMISR Beam5 - Power Profile', format='str') |
|
|||
75 | # |
|
|||
76 | # # Beam6 |
|
|||
77 | # opObj11 = procUnitConfObjBeam6.addOperation(name='ProfileSelector', optype='other') |
|
|||
78 | # opObj11.addParameter(name='profileRangeList', value='722,849', format='intlist') |
|
|||
79 | # opObj11 = procUnitConfObjBeam6.addOperation(name='PowerProfile', optype='other') |
|
|||
80 | # opObj11.addParameter(name='id', value='16', format='int') |
|
|||
81 | # opObj11.addParameter(name='wintitle', value='AMISR Beam6 - Power Profile', format='str') |
|
|||
82 |
|
193 | |||
|
194 | opObj11 = procUnitConfObjBeam4.addOperation(name='CohInt', optype='other') | |||
|
195 | opObj11.addParameter(name='n', value='128', format='int') | |||
|
196 | ||||
|
197 | procUnitConfObjSpectraBeam4 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam4.getId()) | |||
|
198 | procUnitConfObjSpectraBeam4.addParameter(name='nFFTPoints', value='32', format='int') | |||
|
199 | procUnitConfObjSpectraBeam4.addParameter(name='nProfiles', value='32', format='int') | |||
|
200 | ||||
|
201 | opObj11 = procUnitConfObjSpectraBeam4.addOperation(name='getNoise') | |||
|
202 | opObj11.addParameter(name='minHei', value='100', format='float') | |||
|
203 | opObj11.addParameter(name='maxHei', value='450', format='float') | |||
|
204 | ||||
|
205 | opObj11 = procUnitConfObjSpectraBeam4.addOperation(name='RTIPlot', optype='other') | |||
|
206 | opObj11.addParameter(name='id', value='204', format='int') | |||
|
207 | opObj11.addParameter(name='wintitle', value=title4, format='str') | |||
|
208 | #opObj11.addParameter(name='timerange', value='18000', format='int') | |||
|
209 | opObj11.addParameter(name='xmin', value='0', format='int') | |||
|
210 | opObj11.addParameter(name='xmax', value='18', format='int') | |||
|
211 | opObj11.addParameter(name='zmin', value='45', format='int') | |||
|
212 | opObj11.addParameter(name='zmax', value='70', format='int') | |||
|
213 | opObj11.addParameter(name='showprofile', value='0', format='int') | |||
|
214 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |||
|
215 | opObj11.addParameter(name='figfile', value=figfile4, format='str') | |||
|
216 | # # | |||
|
217 | # # | |||
|
218 | # # | |||
|
219 | # # | |||
|
220 | # # | |||
|
221 | ############################## Beam5 ############################# | |||
|
222 | opObj11 = procUnitConfObjBeam5.addOperation(name='ProfileSelector', optype='other') | |||
|
223 | opObj11.addParameter(name='profileRangeList', value='594,721', format='intlist') | |||
|
224 | ||||
|
225 | opObj11 = procUnitConfObjBeam5.addOperation(name='CohInt', optype='other') | |||
|
226 | opObj11.addParameter(name='n', value='128', format='int') | |||
|
227 | ||||
|
228 | procUnitConfObjSpectraBeam5 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam5.getId()) | |||
|
229 | procUnitConfObjSpectraBeam5.addParameter(name='nFFTPoints', value='32', format='int') | |||
|
230 | procUnitConfObjSpectraBeam5.addParameter(name='nProfiles', value='32', format='int') | |||
|
231 | ||||
|
232 | opObj11 = procUnitConfObjSpectraBeam5.addOperation(name='getNoise') | |||
|
233 | opObj11.addParameter(name='minHei', value='100', format='float') | |||
|
234 | opObj11.addParameter(name='maxHei', value='450', format='float') | |||
|
235 | ||||
|
236 | opObj11 = procUnitConfObjSpectraBeam5.addOperation(name='RTIPlot', optype='other') | |||
|
237 | opObj11.addParameter(name='id', value='205', format='int') | |||
|
238 | opObj11.addParameter(name='wintitle', value=title5, format='str') | |||
|
239 | #opObj11.addParameter(name='timerange', value='18000', format='int') | |||
|
240 | opObj11.addParameter(name='xmin', value='0', format='int') | |||
|
241 | opObj11.addParameter(name='xmax', value='18', format='int') | |||
|
242 | opObj11.addParameter(name='zmin', value='45', format='int') | |||
|
243 | opObj11.addParameter(name='zmax', value='70', format='int') | |||
|
244 | opObj11.addParameter(name='showprofile', value='0', format='int') | |||
|
245 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |||
|
246 | opObj11.addParameter(name='figfile', value=figfile5, format='str') | |||
|
247 | # # | |||
|
248 | # # | |||
|
249 | # # | |||
|
250 | # # | |||
|
251 | # # | |||
|
252 | ############################## Beam6 ############################# | |||
|
253 | opObj11 = procUnitConfObjBeam6.addOperation(name='ProfileSelector', optype='other') | |||
|
254 | opObj11.addParameter(name='profileRangeList', value='722,849', format='intlist') | |||
|
255 | ||||
|
256 | opObj11 = procUnitConfObjBeam6.addOperation(name='CohInt', optype='other') | |||
|
257 | opObj11.addParameter(name='n', value='128', format='int') | |||
|
258 | ||||
|
259 | procUnitConfObjSpectraBeam6 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObjBeam6.getId()) | |||
|
260 | procUnitConfObjSpectraBeam6.addParameter(name='nFFTPoints', value='32', format='int') | |||
|
261 | procUnitConfObjSpectraBeam6.addParameter(name='nProfiles', value='32', format='int') | |||
|
262 | ||||
|
263 | opObj11 = procUnitConfObjSpectraBeam6.addOperation(name='getNoise') | |||
|
264 | opObj11.addParameter(name='minHei', value='100', format='float') | |||
|
265 | opObj11.addParameter(name='maxHei', value='450', format='float') | |||
83 |
|
266 | |||
|
267 | opObj11 = procUnitConfObjSpectraBeam6.addOperation(name='RTIPlot', optype='other') | |||
|
268 | opObj11.addParameter(name='id', value='206', format='int') | |||
|
269 | opObj11.addParameter(name='wintitle', value=title6, format='str') | |||
|
270 | #opObj11.addParameter(name='timerange', value='18000', format='int') | |||
|
271 | opObj11.addParameter(name='xmin', value='0', format='int') | |||
|
272 | opObj11.addParameter(name='xmax', value='18', format='int') | |||
|
273 | opObj11.addParameter(name='zmin', value='45', format='int') | |||
|
274 | opObj11.addParameter(name='zmax', value='70', format='int') | |||
|
275 | opObj11.addParameter(name='showprofile', value='0', format='int') | |||
|
276 | opObj11.addParameter(name='figpath', value=figpath, format='str') | |||
|
277 | opObj11.addParameter(name='figfile', value=figfile6, format='str') | |||
84 |
|
278 | |||
85 |
|
279 | |||
86 | print "Escribiendo el archivo XML" |
|
280 | print "Escribiendo el archivo XML" | |
87 | controllerObj.writeXml(filename) |
|
281 | controllerObj.writeXml(filename) | |
88 | print "Leyendo el archivo XML" |
|
282 | print "Leyendo el archivo XML" | |
89 | controllerObj.readXml(filename) |
|
283 | controllerObj.readXml(filename) | |
90 |
|
284 | |||
91 | controllerObj.createObjects() |
|
285 | controllerObj.createObjects() | |
92 | controllerObj.connectObjects() |
|
286 | controllerObj.connectObjects() | |
93 | controllerObj.run() |
|
287 | controllerObj.run() |
General Comments 0
You need to be logged in to leave comments.
Login now