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