@@ -11,62 +11,62 from figure import Figure | |||
|
11 | 11 | from plotting_codes import * |
|
12 | 12 | |
|
13 | 13 | class Scope(Figure): |
|
14 | ||
|
14 | ||
|
15 | 15 | isConfig = None |
|
16 | ||
|
16 | ||
|
17 | 17 | def __init__(self, **kwargs): |
|
18 | 18 | Figure.__init__(self, **kwargs) |
|
19 | 19 | self.isConfig = False |
|
20 | 20 | self.WIDTH = 300 |
|
21 | 21 | self.HEIGHT = 200 |
|
22 | 22 | self.counter_imagwr = 0 |
|
23 | ||
|
23 | ||
|
24 | 24 | def getSubplots(self): |
|
25 | ||
|
25 | ||
|
26 | 26 | nrow = self.nplots |
|
27 | 27 | ncol = 3 |
|
28 | 28 | return nrow, ncol |
|
29 | ||
|
29 | ||
|
30 | 30 | def setup(self, id, nplots, wintitle, show): |
|
31 | ||
|
31 | ||
|
32 | 32 | self.nplots = nplots |
|
33 | ||
|
34 |
self.createFigure(id=id, |
|
|
35 |
wintitle=wintitle, |
|
|
33 | ||
|
34 | self.createFigure(id=id, | |
|
35 | wintitle=wintitle, | |
|
36 | 36 | show=show) |
|
37 | ||
|
37 | ||
|
38 | 38 | nrow,ncol = self.getSubplots() |
|
39 | 39 | colspan = 3 |
|
40 | 40 | rowspan = 1 |
|
41 | ||
|
41 | ||
|
42 | 42 | for i in range(nplots): |
|
43 | 43 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
44 | ||
|
44 | ||
|
45 | 45 | def plot_iq(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax): |
|
46 | 46 | yreal = y[channelIndexList,:].real |
|
47 | 47 | yimag = y[channelIndexList,:].imag |
|
48 | ||
|
48 | ||
|
49 | 49 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
50 | 50 | xlabel = "Range (Km)" |
|
51 | 51 | ylabel = "Intensity - IQ" |
|
52 | ||
|
52 | ||
|
53 | 53 | if not self.isConfig: |
|
54 | 54 | nplots = len(channelIndexList) |
|
55 | ||
|
55 | ||
|
56 | 56 | self.setup(id=id, |
|
57 | 57 | nplots=nplots, |
|
58 | 58 | wintitle='', |
|
59 | 59 | show=show) |
|
60 | ||
|
60 | ||
|
61 | 61 | if xmin == None: xmin = numpy.nanmin(x) |
|
62 | 62 | if xmax == None: xmax = numpy.nanmax(x) |
|
63 | 63 | if ymin == None: ymin = min(numpy.nanmin(yreal),numpy.nanmin(yimag)) |
|
64 | 64 | if ymax == None: ymax = max(numpy.nanmax(yreal),numpy.nanmax(yimag)) |
|
65 | ||
|
65 | ||
|
66 | 66 | self.isConfig = True |
|
67 | ||
|
67 | ||
|
68 | 68 | self.setWinTitle(title) |
|
69 | ||
|
69 | ||
|
70 | 70 | for i in range(len(self.axesList)): |
|
71 | 71 | title = "Channel %d" %(i) |
|
72 | 72 | axes = self.axesList[i] |
@@ -76,32 +76,32 class Scope(Figure): | |||
|
76 | 76 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
77 | 77 | |
|
78 | 78 | axes.addpline(x, yimag[i,:], idline=1, color="red", linestyle="solid", lw=2) |
|
79 | ||
|
79 | ||
|
80 | 80 | def plot_power(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax): |
|
81 | 81 | y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:]) |
|
82 | 82 | yreal = y.real |
|
83 | ||
|
83 | ||
|
84 | 84 | title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
85 | 85 | xlabel = "Range (Km)" |
|
86 | 86 | ylabel = "Intensity" |
|
87 | ||
|
87 | ||
|
88 | 88 | if not self.isConfig: |
|
89 | 89 | nplots = len(channelIndexList) |
|
90 | ||
|
90 | ||
|
91 | 91 | self.setup(id=id, |
|
92 | 92 | nplots=nplots, |
|
93 | 93 | wintitle='', |
|
94 | 94 | show=show) |
|
95 | ||
|
95 | ||
|
96 | 96 | if xmin == None: xmin = numpy.nanmin(x) |
|
97 | 97 | if xmax == None: xmax = numpy.nanmax(x) |
|
98 | 98 | if ymin == None: ymin = numpy.nanmin(yreal) |
|
99 | 99 | if ymax == None: ymax = numpy.nanmax(yreal) |
|
100 | ||
|
100 | ||
|
101 | 101 | self.isConfig = True |
|
102 | ||
|
102 | ||
|
103 | 103 | self.setWinTitle(title) |
|
104 | ||
|
104 | ||
|
105 | 105 | for i in range(len(self.axesList)): |
|
106 | 106 | title = "Channel %d" %(i) |
|
107 | 107 | axes = self.axesList[i] |
@@ -110,14 +110,14 class Scope(Figure): | |||
|
110 | 110 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
111 | 111 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
112 | 112 | |
|
113 | ||
|
113 | ||
|
114 | 114 | def run(self, dataOut, id, wintitle="", channelList=None, |
|
115 | 115 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
116 | 116 | figpath='./', figfile=None, show=True, wr_period=1, |
|
117 | 117 | ftp=False, server=None, folder=None, username=None, password=None, type='power', **kwargs): |
|
118 | ||
|
118 | ||
|
119 | 119 | """ |
|
120 | ||
|
120 | ||
|
121 | 121 | Input: |
|
122 | 122 | dataOut : |
|
123 | 123 | id : |
@@ -128,7 +128,7 class Scope(Figure): | |||
|
128 | 128 | ymin : None, |
|
129 | 129 | ymax : None, |
|
130 | 130 | """ |
|
131 | ||
|
131 | ||
|
132 | 132 | if channelList == None: |
|
133 | 133 | channelIndexList = dataOut.channelIndexList |
|
134 | 134 | else: |
@@ -137,20 +137,20 class Scope(Figure): | |||
|
137 | 137 | if channel not in dataOut.channelList: |
|
138 | 138 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
139 | 139 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
140 | ||
|
140 | ||
|
141 | 141 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) |
|
142 | ||
|
142 | ||
|
143 | 143 | if dataOut.flagDataAsBlock: |
|
144 | ||
|
144 | ||
|
145 | 145 | for i in range(dataOut.nProfiles): |
|
146 | ||
|
146 | ||
|
147 | 147 | wintitle1 = wintitle + " [Profile = %d] " %i |
|
148 | ||
|
148 | ||
|
149 | 149 | if type == "power": |
|
150 |
self.plot_power(dataOut.heightList, |
|
|
150 | self.plot_power(dataOut.heightList, | |
|
151 | 151 | dataOut.data[:,i,:], |
|
152 |
id, |
|
|
153 |
channelIndexList, |
|
|
152 | id, | |
|
153 | channelIndexList, | |
|
154 | 154 | thisDatetime, |
|
155 | 155 | wintitle1, |
|
156 | 156 | show, |
@@ -158,12 +158,12 class Scope(Figure): | |||
|
158 | 158 | xmax, |
|
159 | 159 | ymin, |
|
160 | 160 | ymax) |
|
161 | ||
|
161 | ||
|
162 | 162 | if type == "iq": |
|
163 |
self.plot_iq(dataOut.heightList, |
|
|
163 | self.plot_iq(dataOut.heightList, | |
|
164 | 164 | dataOut.data[:,i,:], |
|
165 |
id, |
|
|
166 |
channelIndexList, |
|
|
165 | id, | |
|
166 | channelIndexList, | |
|
167 | 167 | thisDatetime, |
|
168 | 168 | wintitle1, |
|
169 | 169 | show, |
@@ -171,27 +171,27 class Scope(Figure): | |||
|
171 | 171 | xmax, |
|
172 | 172 | ymin, |
|
173 | 173 | ymax) |
|
174 | ||
|
174 | ||
|
175 | 175 | self.draw() |
|
176 | ||
|
176 | ||
|
177 | 177 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
178 | 178 | figfile = self.getFilename(name = str_datetime) + "_" + str(i) |
|
179 | ||
|
179 | ||
|
180 | 180 | self.save(figpath=figpath, |
|
181 | 181 | figfile=figfile, |
|
182 | 182 | save=save, |
|
183 | 183 | ftp=ftp, |
|
184 | 184 | wr_period=wr_period, |
|
185 | 185 | thisDatetime=thisDatetime) |
|
186 | ||
|
186 | ||
|
187 | 187 | else: |
|
188 | 188 | wintitle += " [Profile = %d] " %dataOut.profileIndex |
|
189 | ||
|
189 | ||
|
190 | 190 | if type == "power": |
|
191 |
self.plot_power(dataOut.heightList, |
|
|
191 | self.plot_power(dataOut.heightList, | |
|
192 | 192 | dataOut.data, |
|
193 |
id, |
|
|
194 |
channelIndexList, |
|
|
193 | id, | |
|
194 | channelIndexList, | |
|
195 | 195 | thisDatetime, |
|
196 | 196 | wintitle, |
|
197 | 197 | show, |
@@ -199,12 +199,12 class Scope(Figure): | |||
|
199 | 199 | xmax, |
|
200 | 200 | ymin, |
|
201 | 201 | ymax) |
|
202 | ||
|
202 | ||
|
203 | 203 | if type == "iq": |
|
204 |
self.plot_iq(dataOut.heightList, |
|
|
204 | self.plot_iq(dataOut.heightList, | |
|
205 | 205 | dataOut.data, |
|
206 |
id, |
|
|
207 |
channelIndexList, |
|
|
206 | id, | |
|
207 | channelIndexList, | |
|
208 | 208 | thisDatetime, |
|
209 | 209 | wintitle, |
|
210 | 210 | show, |
@@ -212,12 +212,12 class Scope(Figure): | |||
|
212 | 212 | xmax, |
|
213 | 213 | ymin, |
|
214 | 214 | ymax) |
|
215 | ||
|
215 | ||
|
216 | 216 | self.draw() |
|
217 | ||
|
217 | ||
|
218 | 218 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") + "_" + str(dataOut.profileIndex) |
|
219 |
figfile = self.getFilename(name = str_datetime) |
|
|
220 | ||
|
219 | figfile = self.getFilename(name = str_datetime) | |
|
220 | ||
|
221 | 221 | self.save(figpath=figpath, |
|
222 | 222 | figfile=figfile, |
|
223 | 223 | save=save, |
@@ -233,89 +233,91 class VoltACFPLot(Figure): | |||
|
233 | 233 | PREFIX = 'voltacf' |
|
234 | 234 | |
|
235 | 235 | def __init__(self, **kwargs): |
|
236 |
|
|
|
237 | self.isConfig = False | |
|
238 | self.__nsubplots = 1 | |
|
239 | self.PLOT_CODE = VOLT_ACF_CODE | |
|
240 | self.WIDTH = 900 | |
|
241 | self.HEIGHT = 700 | |
|
242 | self.counter_imagwr= 0 | |
|
243 | self.FTP_WEI = None | |
|
244 | self.EXP_CODE = None | |
|
245 | self.SUB_EXP_CODE = None | |
|
246 | self.PLOT_POS = None | |
|
236 | Figure.__init__(self,**kwargs) | |
|
237 | self.isConfig = False | |
|
238 | self.__nsubplots = 1 | |
|
239 | self.PLOT_CODE = VOLT_ACF_CODE | |
|
240 | self.WIDTH = 900 | |
|
241 | self.HEIGHT = 700 | |
|
242 | self.counter_imagwr= 0 | |
|
243 | self.FTP_WEI = None | |
|
244 | self.EXP_CODE = None | |
|
245 | self.SUB_EXP_CODE = None | |
|
246 | self.PLOT_POS = None | |
|
247 | 247 | |
|
248 | 248 | def getSubplots(self) : |
|
249 | ncol = 1 | |
|
250 | nrow = 1 | |
|
251 | return nrow, ncol | |
|
249 | ncol = 1 | |
|
250 | nrow = 1 | |
|
251 | return nrow, ncol | |
|
252 | 252 | |
|
253 | 253 | def setup(self,id, nplots,wintitle,show): |
|
254 | self.nplots = nplots | |
|
255 | ncolspan = 1 | |
|
256 | colspan = 1 | |
|
257 | self.createFigure(id=id, | |
|
258 | wintitle = wintitle, | |
|
259 | widthplot = self.WIDTH, | |
|
260 | heightplot = self.HEIGHT, | |
|
261 | show = show) | |
|
262 | nrow, ncol = self.getSubplots() | |
|
263 | counter = 0 | |
|
264 | for y in range(nrow): | |
|
265 | for x in range(ncol): | |
|
266 | self.addAxes(nrow, ncol*ncolspan,y, x*ncolspan, colspan, 1) | |
|
254 | self.nplots = nplots | |
|
255 | ncolspan = 1 | |
|
256 | colspan = 1 | |
|
257 | self.createFigure(id=id, | |
|
258 | wintitle = wintitle, | |
|
259 | widthplot = self.WIDTH, | |
|
260 | heightplot = self.HEIGHT, | |
|
261 | show = show) | |
|
262 | ||
|
263 | nrow, ncol = self.getSubplots() | |
|
264 | counter = 0 | |
|
265 | ||
|
266 | for y in range(nrow): | |
|
267 | for x in range(ncol): | |
|
268 | self.addAxes(nrow, ncol*ncolspan,y, x*ncolspan, colspan, 1) | |
|
267 | 269 | |
|
268 | 270 | def run(self,dataOut, id, wintitle="",channelList = None , channel =None, nSamples = None, |
|
269 | 271 | nSampleList= None, resolutionFactor=None, xmin= None, xmax = None, ymin=None, ymax=None, |
|
270 | 272 | save= False, figpath='./', figfile= None,show= True, ftp= False, wr_period=1, server= None, |
|
271 | 273 | folder= None, username =None, password= None, ftp_wei=0 , exp_code=0,sub_exp_code=0,plot_pos=0, |
|
272 | 274 | xaxis="time"): |
|
273 | ||
|
274 | channel0 = channel | |
|
275 | nSamples = nSamples | |
|
276 | resFactor = resolutionFactor | |
|
277 | ||
|
278 | if nSamples == None: | |
|
279 | nSamples = 20 | |
|
280 | ||
|
281 | if resFactor == None: | |
|
282 | resFactor = 5 | |
|
283 | ||
|
284 | if channel0 == None: | |
|
285 | channel0 = 0 | |
|
286 | else: | |
|
287 | if channel0 not in dataOut.channelList: | |
|
288 | raise ValueError, "Channel %d is not in %s dataOut.channelList"%(channel0, dataOut.channelList) | |
|
289 | ||
|
290 |
if channelList == None: |
|
|
291 | channelIndexList = dataOut.channelIndexList | |
|
292 | channelList = dataOut.channelList | |
|
293 | ||
|
294 | else: | |
|
275 | ||
|
276 | channel0 = channel | |
|
277 | nSamples = nSamples | |
|
278 | resFactor = resolutionFactor | |
|
279 | ||
|
280 | if nSamples == None: | |
|
281 | nSamples = 20 | |
|
282 | ||
|
283 | if resFactor == None: | |
|
284 | resFactor = 5 | |
|
285 | ||
|
286 | if channel0 == None: | |
|
287 | channel0 = 0 | |
|
288 | else: | |
|
289 | if channel0 not in dataOut.channelList: | |
|
290 | raise ValueError, "Channel %d is not in %s dataOut.channelList"%(channel0, dataOut.channelList) | |
|
291 | ||
|
292 | if channelList == None: | |
|
293 | channelIndexList = dataOut.channelIndexList | |
|
294 | channelList = dataOut.channelList | |
|
295 | ||
|
296 | else: | |
|
295 | 297 | channelIndexList = [] |
|
296 | 298 | for channel in channelList: |
|
297 | 299 | if channel not in dataOut.channelList: |
|
298 | 300 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
299 | 301 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
300 | 302 | |
|
301 | ||
|
302 | 303 | #factor = dataOut.normFactor |
|
303 | 304 | y = dataOut.getHeiRange() |
|
304 | #print y, dataOut.heightList[0] | |
|
305 | #print "pause" | |
|
306 | #import time | |
|
307 | #time.sleep(10) | |
|
305 | #print y, dataOut.heightList[0] | |
|
306 | #print "pause" | |
|
307 | #import time | |
|
308 | #time.sleep(10) | |
|
308 | 309 | deltaHeight = dataOut.heightList[1]-dataOut.heightList[0] |
|
309 | z = dataOut.data | |
|
310 | z = dataOut.data_acfLag | |
|
310 | 311 | |
|
311 | shape = dataOut.data.shape | |
|
312 | hei_index = numpy.arange(shape[2]) | |
|
313 |
|
|
|
312 | shape = dataOut.data_acfLag.shape | |
|
313 | ||
|
314 | hei_index = numpy.arange(shape[2]) | |
|
315 | hei_plot = numpy.arange(nSamples)*resFactor | |
|
314 | 316 | |
|
315 | 317 | if nSampleList is not None: |
|
316 | 318 | for nsample in nSampleList: |
|
317 | 319 | if nsample not in dataOut.heightList/deltaHeight: |
|
318 |
|
|
|
320 | print "Lista available : %s "%(dataOut.heightList/deltaHeight) | |
|
319 | 321 | raise ValueError, "nsample %d is not in %s dataOut.heightList"%(nsample,dataOut.heightList) |
|
320 | 322 | |
|
321 | 323 | if nSampleList is not None: |
@@ -325,102 +327,74 class VoltACFPLot(Figure): | |||
|
325 | 327 | print ("La cantidad de puntos en altura es %d y la resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) |
|
326 | 328 | raise ValueError, "resFactor %d multiplicado por el valor de %d nSamples es mayor a %d cantidad total de puntos"%(resFactor,nSamples,hei_index[-1]) |
|
327 | 329 | |
|
328 | #escalamiento -1 a 1 a resolucion (factor de resolucion en altura)* deltaHeight | |
|
330 | #escalamiento -1 a 1 a resolucion (factor de resolucion en altura)* deltaHeight | |
|
329 | 331 | #min = numpy.min(z[0,:,0]) |
|
330 | 332 | #max =numpy.max(z[0,:,0]) |
|
333 | #print shape[0] | |
|
331 | 334 | for i in range(shape[0]): |
|
335 | #print "amigo i",i | |
|
332 | 336 | for j in range(shape[2]): |
|
333 |
|
|
|
334 |
|
|
|
337 | min = numpy.min(z[i,:,j]) | |
|
338 | max = numpy.max(z[i,:,j]) | |
|
335 | 339 | z[i,:,j]= (((z[i,:,j]-min)/(max-min))*deltaHeight*resFactor + j*deltaHeight+dataOut.heightList[0]) |
|
336 | ||
|
337 | ||
|
338 | if xaxis == "time": | |
|
339 | x = dataOut.getAcfRange()*1000 | |
|
340 | zdB = z[channel0,:,hei_plot] | |
|
341 | xlabel = "Time (ms)" | |
|
342 | ylabel = "VOLT_ACF" | |
|
343 | ||
|
344 | ||
|
345 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
|
346 | title = wintitle + "VOLT ACF Plot Ch %s %s" %(channel0,thisDatetime.strftime("%d-%b-%Y")) | |
|
347 | ||
|
348 | if not self.isConfig: | |
|
349 | ||
|
350 | nplots = 1 | |
|
351 | ||
|
352 | self.setup(id=id, | |
|
353 | nplots=nplots, | |
|
354 | wintitle=wintitle, | |
|
355 | show=show) | |
|
356 | ||
|
357 | if xmin == None: xmin = numpy.nanmin(x)#*0.9 | |
|
358 | if xmax == None: xmax = numpy.nanmax(x)#*1.1 | |
|
359 | if ymin == None: ymin = numpy.nanmin(zdB) | |
|
360 | if ymax == None: ymax = numpy.nanmax(zdB) | |
|
361 | ||
|
362 | print ("El parametro resFactor es %d y la resolucion en altura es %f"%(resFactor,deltaHeight )) | |
|
363 | print ("La cantidad de puntos en altura es %d y la nueva resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) | |
|
364 | print ("La altura maxima es %d Km"%(hei_plot[-1]*deltaHeight )) | |
|
365 | ||
|
366 | self.FTP_WEI = ftp_wei | |
|
367 | self.EXP_CODE = exp_code | |
|
368 | self.SUB_EXP_CODE = sub_exp_code | |
|
369 | self.PLOT_POS = plot_pos | |
|
370 | ||
|
371 | self.isConfig = True | |
|
372 | ||
|
373 | self.setWinTitle(title) | |
|
374 | ||
|
375 | title = "VOLT ACF Plot: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
|
376 | axes = self.axesList[0] | |
|
377 | ||
|
378 | legendlabels = ["Range = %dKm" %y[i] for i in hei_plot] | |
|
379 | ||
|
380 | axes.pmultilineyaxis( x, zdB, | |
|
381 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
|
382 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
|
383 | ytick_visible=True, nxticks=5, | |
|
384 | grid='x') | |
|
385 | ||
|
386 | self.draw() | |
|
387 | ||
|
388 | if figfile == None: | |
|
389 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
|
390 | name = str_datetime | |
|
391 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
|
392 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | |
|
393 | figfile = self.getFilename(name) | |
|
394 | ||
|
395 | self.save(figpath=figpath, | |
|
396 | figfile=figfile, | |
|
397 | save=save, | |
|
398 | ftp=ftp, | |
|
399 | wr_period=wr_period, | |
|
400 | thisDatetime=thisDatetime) | |
|
401 | ||
|
402 | ||
|
403 | ||
|
404 | ||
|
405 | ||
|
406 | ||
|
407 | ||
|
408 | ||
|
409 | ||
|
410 | ||
|
411 | ||
|
412 | ||
|
413 | ||
|
414 | 340 | |
|
341 | if xaxis == "time": | |
|
342 | x = dataOut.getAcfRange()*1000 | |
|
343 | zdB = z[channel0,:,hei_plot] | |
|
344 | xlabel = "Time (ms)" | |
|
345 | ylabel = "VOLT_ACF" | |
|
346 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
|
347 | title = wintitle + "VOLT ACF Plot Ch %s %s" %(channel0,thisDatetime.strftime("%d-%b-%Y")) | |
|
415 | 348 | |
|
349 | if not self.isConfig: | |
|
416 | 350 | |
|
351 | nplots = 1 | |
|
417 | 352 | |
|
353 | self.setup(id=id, | |
|
354 | nplots=nplots, | |
|
355 | wintitle=wintitle, | |
|
356 | show=show) | |
|
418 | 357 | |
|
358 | if xmin == None: xmin = numpy.nanmin(x)#*0.9 | |
|
359 | if xmax == None: xmax = numpy.nanmax(x)#*1.1 | |
|
360 | if ymin == None: ymin = numpy.nanmin(zdB) | |
|
361 | if ymax == None: ymax = numpy.nanmax(zdB) | |
|
419 | 362 | |
|
363 | print ("El parametro resFactor es %d y la resolucion en altura es %f"%(resFactor,deltaHeight )) | |
|
364 | print ("La cantidad de puntos en altura es %d y la nueva resolucion es %f Km"%(hei_plot.shape[0],deltaHeight*resFactor )) | |
|
365 | print ("La altura maxima es %d Km"%(hei_plot[-1]*deltaHeight )) | |
|
420 | 366 | |
|
367 | self.FTP_WEI = ftp_wei | |
|
368 | self.EXP_CODE = exp_code | |
|
369 | self.SUB_EXP_CODE = sub_exp_code | |
|
370 | self.PLOT_POS = plot_pos | |
|
421 | 371 | |
|
372 | self.isConfig = True | |
|
422 | 373 | |
|
374 | self.setWinTitle(title) | |
|
375 | title = "VOLT ACF Plot: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
|
376 | axes = self.axesList[0] | |
|
423 | 377 | |
|
378 | legendlabels = ["Range = %dKm" %y[i] for i in hei_plot] | |
|
424 | 379 | |
|
380 | axes.pmultilineyaxis( x, zdB, | |
|
381 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
|
382 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
|
383 | ytick_visible=True, nxticks=5, | |
|
384 | grid='x') | |
|
425 | 385 | |
|
386 | self.draw() | |
|
426 | 387 | |
|
388 | if figfile == None: | |
|
389 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
|
390 | name = str_datetime | |
|
391 | if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)): | |
|
392 | name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith) | |
|
393 | figfile = self.getFilename(name) | |
|
394 | ||
|
395 | self.save(figpath=figpath, | |
|
396 | figfile=figfile, | |
|
397 | save=save, | |
|
398 | ftp=ftp, | |
|
399 | wr_period=wr_period, | |
|
400 | thisDatetime=thisDatetime) |
@@ -933,7 +933,7 class ProfileSelector(Operation): | |||
|
933 | 933 | rangeList : List of profile ranges. Example: rangeList = ((4, 30), (32, 64), (128, 256)) |
|
934 | 934 | |
|
935 | 935 | """ |
|
936 | print "HOLA MUNDO CRUEL" | |
|
936 | #print "HOLA MUNDO CRUEL" | |
|
937 | 937 | if rangeList is not None: |
|
938 | 938 | if type(rangeList[0]) not in (tuple, list): |
|
939 | 939 | rangeList = [rangeList] |
@@ -1355,6 +1355,7 class voltACFLags(Operation): | |||
|
1355 | 1355 | self.isConfig = False |
|
1356 | 1356 | self.profIndex = 0 |
|
1357 | 1357 | self.buffer = None |
|
1358 | self.channelList = [] | |
|
1358 | 1359 | |
|
1359 | 1360 | |
|
1360 | 1361 | def setup(self,dataOut ,lags = None,mode =None, fullBuffer= None ,pairsList = None,nAvg = 1): |
@@ -1364,7 +1365,7 class voltACFLags(Operation): | |||
|
1364 | 1365 | self.mode = mode |
|
1365 | 1366 | self.fullBuffer= fullBuffer |
|
1366 | 1367 | self.nAvg = nAvg |
|
1367 | self.pairsList = pairsList | |
|
1368 | self.pairsList = [pairsList] | |
|
1368 | 1369 | nChannels = dataOut.nChannels |
|
1369 | 1370 | nProfiles = dataOut.nProfiles |
|
1370 | 1371 | nHeights = dataOut.nHeights |
@@ -1381,7 +1382,10 class voltACFLags(Operation): | |||
|
1381 | 1382 | pairsList = [(0,1)] |
|
1382 | 1383 | self.pairsList= pairsList |
|
1383 | 1384 | |
|
1384 | self.selectChannels(self.pairsList) | |
|
1385 | ||
|
1386 | for i in range(len(self.pairsList)): | |
|
1387 | self.channelList.append(self.pairsList[i][0]) | |
|
1388 | self.channelList.append(self.pairsList[i][1]) | |
|
1385 | 1389 | |
|
1386 | 1390 | if lags == None: |
|
1387 | 1391 | if mode=='time': |
@@ -1392,20 +1396,22 class voltACFLags(Operation): | |||
|
1392 | 1396 | |
|
1393 | 1397 | # buffer de canalaes, perfiles, alturas |
|
1394 | 1398 | if self.buffer is None: |
|
1395 |
self.buffer = numpy.zeros(( |
|
|
1399 | self.buffer = numpy.zeros((nChannels,nProfiles,nHeights),dtype='complex') | |
|
1396 | 1400 | |
|
1397 | 1401 | if fullBuffer: |
|
1398 | self.tmp = numpy.zeros((len(pairsList), len(self.lags), nProfiles, nHeights), dtype = 'complex')*numpy.nan | |
|
1402 | self.tmp = numpy.zeros((len(self.pairsList), len(self.lags), nProfiles, nHeights), dtype = 'complex')*numpy.nan | |
|
1399 | 1403 | elif mode =='time': |
|
1400 | self.tmp = numpy.zeros((len(pairsList), len(self.lags), nHeights),dtype='complex') | |
|
1404 | self.tmp = numpy.zeros((len(self.pairsList), len(self.lags), nHeights),dtype='complex') | |
|
1401 | 1405 | elif mode =='height': |
|
1402 |
self.tmp = numpy.zeros(len(pairsList), |
|
|
1406 | self.tmp = numpy.zeros((len(self.pairsList), len(self.lags), nProfiles),dtype='complex') | |
|
1403 | 1407 | |
|
1404 | 1408 | print "lags", len(self.lags),self.lags |
|
1405 | 1409 | print "mode",self.mode |
|
1406 | 1410 | print "nChannels", nChannels |
|
1407 | 1411 | print "nProfiles", nProfiles |
|
1408 | 1412 | print "nHeights" , nHeights |
|
1413 | print "acf_channels",len(self.pairsList) | |
|
1414 | print "channelList",self.channelList | |
|
1409 | 1415 | print "pairsList", pairsList,len(self.pairsList) |
|
1410 | 1416 | print "fullBuffer", fullBuffer |
|
1411 | 1417 | #print "type(pairsList)",type(pairsList) |
@@ -1419,21 +1425,18 class voltACFLags(Operation): | |||
|
1419 | 1425 | if not self.isConfig: |
|
1420 | 1426 | self.setup(dataOut, lags = lags,mode = mode, fullBuffer= fullBuffer ,pairsList = pairsList,nAvg=nAvg) |
|
1421 | 1427 | self.isConfig = True |
|
1422 | print "pairsList Ale", self.pairsList | |
|
1423 | print dataOut.data[pairsList,:].shape | |
|
1428 | ||
|
1424 | 1429 | if dataOut.type == "Voltage": |
|
1425 | 1430 | if dataOut.flagDataAsBlock: |
|
1426 | 1431 | print "Not implemented yet" |
|
1427 | 1432 | return 0 |
|
1428 | 1433 | else: |
|
1429 | print "shapebuffer",self.buffer[:,0,:].shape | |
|
1430 | self.buffer[:, self.profIndex, :] = dataOut.data#error | |
|
1434 | self.buffer[:, self.profIndex, :] = dataOut.data | |
|
1431 | 1435 | self.profIndex += 1 |
|
1432 | 1436 | |
|
1433 | 1437 | if self.profIndex == self.__nProfiles : |
|
1438 | ||
|
1434 | 1439 | data_pre = self.buffer #data |
|
1435 | print "size",data_pre.shape | |
|
1436 | # Here is the loop :D | |
|
1437 | 1440 | for l in range(len(self.pairsList)): |
|
1438 | 1441 | ch0 = self.pairsList[l][0] |
|
1439 | 1442 | ch1 = self.pairsList[l][1] |
@@ -1451,17 +1454,16 class voltACFLags(Operation): | |||
|
1451 | 1454 | if self.fullBuffer: |
|
1452 | 1455 | self.tmp = numpy.sum(numpy.reshape(self.tmp,(self.tmp.shape[0],self.tmp.shape[1],self.tmp.shape[2]/self.nAvg,self.nAvg,self.tmp.shape[3])),axis=3) |
|
1453 | 1456 | dataOut.nAvg = self.nAvg |
|
1454 | ||
|
1455 | if self.mode == 'time': | |
|
1456 |
|
|
|
1457 |
|
|
|
1457 | if self.mode == 'time': | |
|
1458 | #print "entre" | |
|
1459 | delta = dataOut.ippSeconds*dataOut.nCohInt | |
|
1460 | else: | |
|
1458 | 1461 | delta = dataOut.heightList[1] - dataOut.heightList[0] |
|
1459 | 1462 | |
|
1460 |
shape= self.tmp.shape |
|
|
1461 | # Normalizando | |
|
1462 | for i in range(len(pairsList)): | |
|
1463 | shape= self.tmp.shape | |
|
1464 | for i in range(len(self.pairsList)): | |
|
1463 | 1465 | for j in range(shape[2]): |
|
1464 |
self.tmp[i,:,j]= self.tmp[i,:,j].real |
|
|
1466 | self.tmp[i,:,j]= self.tmp[i,:,j].real/numpy.max(numpy.abs(self.tmp[i,:,j])) | |
|
1465 | 1467 | |
|
1466 | 1468 | #import matplotlib.pyplot as plt |
|
1467 | 1469 | #print "test",self.tmp.shape |
@@ -1473,7 +1475,8 class voltACFLags(Operation): | |||
|
1473 | 1475 | #plt.show() |
|
1474 | 1476 | #import time |
|
1475 | 1477 | #time.sleep(20) |
|
1476 |
dataOut.data |
|
|
1478 | dataOut.data = self.buffer | |
|
1479 | dataOut.data_acfLag = self.tmp | |
|
1477 | 1480 | dataOut.mode = self.mode |
|
1478 | 1481 | dataOut.nLags = len(self.lags) |
|
1479 | 1482 | dataOut.nProfiles = len(self.lags) |
@@ -1482,6 +1485,7 class voltACFLags(Operation): | |||
|
1482 | 1485 | dataOut.lagRange = numpy.array(self.lags)*delta |
|
1483 | 1486 | dataOut.flagDataAsBlock = True |
|
1484 | 1487 | dataOut.flagNoData = False |
|
1488 | self.profIndex = 0 | |
|
1485 | 1489 | |
|
1486 | 1490 | |
|
1487 | 1491 | import time |
General Comments 0
You need to be logged in to leave comments.
Login now