@@ -220,6 +220,158 class SpectraPlot(Figure): | |||
|
220 | 220 | wr_period=wr_period, |
|
221 | 221 | thisDatetime=thisDatetime) |
|
222 | 222 | |
|
223 | class ACFPlot(Figure): | |
|
224 | ||
|
225 | isConfig = None | |
|
226 | __nsubplots = None | |
|
227 | ||
|
228 | WIDTHPROF = None | |
|
229 | HEIGHTPROF = None | |
|
230 | PREFIX = 'acf' | |
|
231 | ||
|
232 | def __init__(self, **kwargs): | |
|
233 | Figure.__init__(self, **kwargs) | |
|
234 | self.isConfig = False | |
|
235 | self.__nsubplots = 1 | |
|
236 | ||
|
237 | self.PLOT_CODE = POWER_CODE | |
|
238 | ||
|
239 | self.WIDTH = 700 | |
|
240 | self.HEIGHT = 500 | |
|
241 | self.counter_imagwr = 0 | |
|
242 | ||
|
243 | def getSubplots(self): | |
|
244 | ncol = 1 | |
|
245 | nrow = 1 | |
|
246 | ||
|
247 | return nrow, ncol | |
|
248 | ||
|
249 | def setup(self, id, nplots, wintitle, show): | |
|
250 | ||
|
251 | self.nplots = nplots | |
|
252 | ||
|
253 | ncolspan = 1 | |
|
254 | colspan = 1 | |
|
255 | ||
|
256 | self.createFigure(id = id, | |
|
257 | wintitle = wintitle, | |
|
258 | widthplot = self.WIDTH, | |
|
259 | heightplot = self.HEIGHT, | |
|
260 | show=show) | |
|
261 | ||
|
262 | nrow, ncol = self.getSubplots() | |
|
263 | ||
|
264 | counter = 0 | |
|
265 | for y in range(nrow): | |
|
266 | for x in range(ncol): | |
|
267 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
|
268 | ||
|
269 | def run(self, dataOut, id, wintitle="", channelList=None, | |
|
270 | xmin=None, xmax=None, ymin=None, ymax=None, | |
|
271 | save=False, figpath='./', figfile=None, show=True, | |
|
272 | ftp=False, wr_period=1, server=None, | |
|
273 | folder=None, username=None, password=None, | |
|
274 | xaxis="frequency"): | |
|
275 | ||
|
276 | ||
|
277 | if channelList == None: | |
|
278 | channelIndexList = dataOut.channelIndexList | |
|
279 | channelList = dataOut.channelList | |
|
280 | else: | |
|
281 | channelIndexList = [] | |
|
282 | for channel in channelList: | |
|
283 | if channel not in dataOut.channelList: | |
|
284 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
|
285 | channelIndexList.append(dataOut.channelList.index(channel)) | |
|
286 | ||
|
287 | factor = dataOut.normFactor | |
|
288 | ||
|
289 | y = dataOut.getHeiRange() | |
|
290 | ||
|
291 | #z = dataOut.data_spc/factor | |
|
292 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
|
293 | print deltaHeight | |
|
294 | z = dataOut.data_spc | |
|
295 | ||
|
296 | #z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
|
297 | shape = dataOut.data_spc.shape | |
|
298 | for i in range(shape[0]): | |
|
299 | for j in range(shape[2]): | |
|
300 | z[i,:,j]= (z[i,:,j]+1.0)*deltaHeight*5/2.0 + j*deltaHeight | |
|
301 | #z[i,:,j]= (z[i,:,j]+1.0)*deltaHeight*dataOut.step/2.0 + j*deltaHeight*dataOut.step | |
|
302 | ||
|
303 | hei_index = numpy.arange(shape[2]) | |
|
304 | #print hei_index.shape | |
|
305 | #b = [] | |
|
306 | #for i in range(hei_index.shape[0]): | |
|
307 | # if hei_index[i]%30 == 0: | |
|
308 | # b.append(hei_index[i]) | |
|
309 | ||
|
310 | #hei_index= numpy.array(b) | |
|
311 | hei_index = hei_index[300:320] | |
|
312 | #hei_index = numpy.arange(20)*30+80 | |
|
313 | hei_index= numpy.arange(20)*5 | |
|
314 | if xaxis == "frequency": | |
|
315 | x = dataOut.getFreqRange()/1000. | |
|
316 | zdB = 10*numpy.log10(z[0,:,hei_index]) | |
|
317 | xlabel = "Frequency (kHz)" | |
|
318 | ylabel = "Power (dB)" | |
|
319 | ||
|
320 | elif xaxis == "time": | |
|
321 | x = dataOut.getAcfRange() | |
|
322 | zdB = z[0,:,hei_index] | |
|
323 | xlabel = "Time (ms)" | |
|
324 | ylabel = "ACF" | |
|
325 | ||
|
326 | else: | |
|
327 | x = dataOut.getVelRange() | |
|
328 | zdB = 10*numpy.log10(z[0,:,hei_index]) | |
|
329 | xlabel = "Velocity (m/s)" | |
|
330 | ylabel = "Power (dB)" | |
|
331 | ||
|
332 | thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0]) | |
|
333 | title = wintitle + " ACF Plot %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
|
334 | ||
|
335 | if not self.isConfig: | |
|
336 | ||
|
337 | nplots = 1 | |
|
338 | ||
|
339 | self.setup(id=id, | |
|
340 | nplots=nplots, | |
|
341 | wintitle=wintitle, | |
|
342 | show=show) | |
|
343 | ||
|
344 | if xmin == None: xmin = numpy.nanmin(x)*0.9 | |
|
345 | if xmax == None: xmax = numpy.nanmax(x)*1.1 | |
|
346 | if ymin == None: ymin = numpy.nanmin(zdB) | |
|
347 | if ymax == None: ymax = numpy.nanmax(zdB) | |
|
348 | ||
|
349 | self.isConfig = True | |
|
350 | ||
|
351 | self.setWinTitle(title) | |
|
352 | ||
|
353 | title = "Spectra Cuts: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
|
354 | axes = self.axesList[0] | |
|
355 | ||
|
356 | legendlabels = ["Range = %dKm" %y[i] for i in hei_index] | |
|
357 | ||
|
358 | axes.pmultilineyaxis( x, zdB, | |
|
359 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
|
360 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
|
361 | ytick_visible=True, nxticks=5, | |
|
362 | grid='x') | |
|
363 | ||
|
364 | self.draw() | |
|
365 | ||
|
366 | self.save(figpath=figpath, | |
|
367 | figfile=figfile, | |
|
368 | save=save, | |
|
369 | ftp=ftp, | |
|
370 | wr_period=wr_period, | |
|
371 | thisDatetime=thisDatetime) | |
|
372 | ||
|
373 | ||
|
374 | ||
|
223 | 375 | class CrossSpectraPlot(Figure): |
|
224 | 376 | |
|
225 | 377 | isConfig = None |
@@ -12,6 +12,7 TOTAL_CODE = 6 #Total Power. | |||
|
12 | 12 | DRIFT_CODE = 7 #Drifts graphics. |
|
13 | 13 | HEIGHT_CODE = 8 #Height profile. |
|
14 | 14 | PHASE_CODE = 9 #Signal Phase. |
|
15 | AFC_CODE = 10 #Autocorrelation function. | |
|
15 | 16 | |
|
16 | 17 | POWER_CODE = 16 |
|
17 | 18 | NOISE_CODE = 17 |
@@ -65,6 +65,8 class SpectraProc(ProcessingUnit): | |||
|
65 | 65 | self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList |
|
66 | 66 | self.dataOut.beam.zenithList = self.dataIn.beam.zenithList |
|
67 | 67 | |
|
68 | self.dataOut.step = self.dataIn.step | |
|
69 | ||
|
68 | 70 | def __getFft(self): |
|
69 | 71 | """ |
|
70 | 72 | Convierte valores de Voltaje a Spectra |
@@ -149,11 +149,18 class SpectraAFCProc(ProcessingUnit): | |||
|
149 | 149 | data = numpy.fft.ifft(spc, axis=1) |
|
150 | 150 | data = numpy.fft.fftshift(data, axes=(1,)) |
|
151 | 151 | spc = data.real |
|
152 | spc = spc[0,:,0] / numpy.max(numpy.abs(spc[0,:,0])) | |
|
153 | print spc | |
|
154 | import matplotlib.pyplot as plt | |
|
155 | #plt.plot(spc[10:]) | |
|
156 | plt.show() | |
|
152 | shape = spc.shape #nchannels, nprofiles, nsamples | |
|
153 | ||
|
154 | #print spc.shape | |
|
155 | for i in range(shape[0]): | |
|
156 | for j in range(shape[2]): | |
|
157 | spc[i,:,j]= spc[i,:,j] / numpy.max(numpy.abs(spc[i,:,j])) | |
|
158 | #spc = spc[0,:,250] / numpy.max(numpy.abs(spc[0,:,250])) | |
|
159 | #print spc.shape | |
|
160 | #import matplotlib.pyplot as plt | |
|
161 | #print spc[0:10] | |
|
162 | #plt.plot(spc[0,:,350]) | |
|
163 | #plt.show() | |
|
157 | 164 | |
|
158 | 165 | |
|
159 | 166 | self.dataOut.data_spc = spc |
@@ -1209,7 +1209,7 class SSheightProfiles(Operation): | |||
|
1209 | 1209 | self.__nProfiles = dataOut.nProfiles |
|
1210 | 1210 | self.__nHeis = dataOut.nHeights |
|
1211 | 1211 | shape = dataOut.data.shape #nchannels, nprofiles, nsamples |
|
1212 | print "shape",shape | |
|
1212 | #print "shape",shape | |
|
1213 | 1213 | #last test |
|
1214 | 1214 | residue = (shape[1] - self.nsamples) % self.step |
|
1215 | 1215 | if residue != 0: |
@@ -1248,6 +1248,8 class SSheightProfiles(Operation): | |||
|
1248 | 1248 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1249 | 1249 | ippSeconds = (deltaHeight*1.0e-6)/(0.15) |
|
1250 | 1250 | |
|
1251 | ||
|
1252 | ||
|
1251 | 1253 | dataOut.data = self.sshProfiles |
|
1252 | 1254 | dataOut.flagNoData = False |
|
1253 | 1255 | dataOut.heightList = numpy.arange(self.buffer.shape[1]) *self.step*deltaHeight + dataOut.heightList[0] |
@@ -1255,7 +1257,7 class SSheightProfiles(Operation): | |||
|
1255 | 1257 | dataOut.profileIndex = profileIndex |
|
1256 | 1258 | dataOut.flagDataAsBlock = True |
|
1257 | 1259 | dataOut.ippSeconds = ippSeconds |
|
1258 | ||
|
1260 | dataOut.step = self.step | |
|
1259 | 1261 | |
|
1260 | 1262 | |
|
1261 | 1263 | # import collections |
General Comments 0
You need to be logged in to leave comments.
Login now