##// END OF EJS Templates
Last Commit foreva!
ebocanegra -
r1157:823d4012bd34
parent child
Show More

The requested changes are too big and content was truncated. Show full diff

@@ -1,2161 +1,2393
1 import os
1 import os
2 import datetime
2 import datetime
3 import numpy
3 import numpy
4 import inspect
4 import inspect
5 from figure import Figure, isRealtime, isTimeInHourRange
5 from figure import Figure, isRealtime, isTimeInHourRange
6 from plotting_codes import *
6 from plotting_codes import *
7
7
8 class ParamLine(Figure):
9
10 isConfig = None
11
12 def __init__(self):
13
14 self.isConfig = False
15 self.WIDTH = 300
16 self.HEIGHT = 200
17 self.counter_imagwr = 0
18
19 def getSubplots(self):
20
21 nrow = self.nplots
22 ncol = 3
23 return nrow, ncol
24
25 def setup(self, id, nplots, wintitle, show):
26
27 self.nplots = nplots
28
29 self.createFigure(id=id,
30 wintitle=wintitle,
31 show=show)
32
33 nrow,ncol = self.getSubplots()
34 colspan = 3
35 rowspan = 1
36
37 for i in range(nplots):
38 self.addAxes(nrow, ncol, i, 0, colspan, rowspan)
39
40 def plot_iq(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
41 yreal = y[channelIndexList,:].real
42 yimag = y[channelIndexList,:].imag
43
44 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
45 xlabel = "Range (Km)"
46 ylabel = "Intensity - IQ"
47
48 if not self.isConfig:
49 nplots = len(channelIndexList)
50
51 self.setup(id=id,
52 nplots=nplots,
53 wintitle='',
54 show=show)
55
56 if xmin == None: xmin = numpy.nanmin(x)
57 if xmax == None: xmax = numpy.nanmax(x)
58 if ymin == None: ymin = min(numpy.nanmin(yreal),numpy.nanmin(yimag))
59 if ymax == None: ymax = max(numpy.nanmax(yreal),numpy.nanmax(yimag))
60
61 self.isConfig = True
62
63 self.setWinTitle(title)
64
65 for i in range(len(self.axesList)):
66 title = "Channel %d" %(i)
67 axes = self.axesList[i]
68
69 axes.pline(x, yreal[i,:],
70 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
71 xlabel=xlabel, ylabel=ylabel, title=title)
72
73 axes.addpline(x, yimag[i,:], idline=1, color="red", linestyle="solid", lw=2)
74
75 def plot_power(self, x, y, id, channelIndexList, thisDatetime, wintitle, show, xmin, xmax, ymin, ymax):
76 y = y[channelIndexList,:] * numpy.conjugate(y[channelIndexList,:])
77 yreal = y.real
78
79 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
80 xlabel = "Range (Km)"
81 ylabel = "Intensity"
82
83 if not self.isConfig:
84 nplots = len(channelIndexList)
85
86 self.setup(id=id,
87 nplots=nplots,
88 wintitle='',
89 show=show)
90
91 if xmin == None: xmin = numpy.nanmin(x)
92 if xmax == None: xmax = numpy.nanmax(x)
93 if ymin == None: ymin = numpy.nanmin(yreal)
94 if ymax == None: ymax = numpy.nanmax(yreal)
95
96 self.isConfig = True
97
98 self.setWinTitle(title)
99
100 for i in range(len(self.axesList)):
101 title = "Channel %d" %(i)
102 axes = self.axesList[i]
103 ychannel = yreal[i,:]
104 axes.pline(x, ychannel,
105 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
106 xlabel=xlabel, ylabel=ylabel, title=title)
107
108
109 def run(self, dataOut, id, wintitle="", channelList=None,
110 xmin=None, xmax=None, ymin=None, ymax=None, save=False,
111 figpath='./', figfile=None, show=True, wr_period=1,
112 ftp=False, server=None, folder=None, username=None, password=None):
113
114 """
115
116 Input:
117 dataOut :
118 id :
119 wintitle :
120 channelList :
121 xmin : None,
122 xmax : None,
123 ymin : None,
124 ymax : None,
125 """
126
127 if channelList == None:
128 channelIndexList = dataOut.channelIndexList
129 else:
130 channelIndexList = []
131 for channel in channelList:
132 if channel not in dataOut.channelList:
133 raise ValueError, "Channel %d is not in dataOut.channelList"
134 channelIndexList.append(dataOut.channelList.index(channel))
135
136 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
137
138 y = dataOut.RR
139
140 title = wintitle + " Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
141 xlabel = "Range (Km)"
142 ylabel = "Intensity"
143
144 if not self.isConfig:
145 nplots = len(channelIndexList)
146
147 self.setup(id=id,
148 nplots=nplots,
149 wintitle='',
150 show=show)
151
152 if xmin == None: xmin = numpy.nanmin(x)
153 if xmax == None: xmax = numpy.nanmax(x)
154 if ymin == None: ymin = numpy.nanmin(y)
155 if ymax == None: ymax = numpy.nanmax(y)
156
157 self.isConfig = True
158
159 self.setWinTitle(title)
160
161 for i in range(len(self.axesList)):
162 title = "Channel %d" %(i)
163 axes = self.axesList[i]
164 ychannel = y[i,:]
165 axes.pline(x, ychannel,
166 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
167 xlabel=xlabel, ylabel=ylabel, title=title)
168
169
170 self.draw()
171
172 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") + "_" + str(dataOut.profileIndex)
173 figfile = self.getFilename(name = str_datetime)
174
175 self.save(figpath=figpath,
176 figfile=figfile,
177 save=save,
178 ftp=ftp,
179 wr_period=wr_period,
180 thisDatetime=thisDatetime)
181
182
8
183
9 class SpcParamPlot(Figure):
184 class SpcParamPlot(Figure):
10
185
11 isConfig = None
186 isConfig = None
12 __nsubplots = None
187 __nsubplots = None
13
188
14 WIDTHPROF = None
189 WIDTHPROF = None
15 HEIGHTPROF = None
190 HEIGHTPROF = None
16 PREFIX = 'SpcParam'
191 PREFIX = 'SpcParam'
17
192
18 def __init__(self, **kwargs):
193 def __init__(self, **kwargs):
19 Figure.__init__(self, **kwargs)
194 Figure.__init__(self, **kwargs)
20 self.isConfig = False
195 self.isConfig = False
21 self.__nsubplots = 1
196 self.__nsubplots = 1
22
197
23 self.WIDTH = 250
198 self.WIDTH = 250
24 self.HEIGHT = 250
199 self.HEIGHT = 250
25 self.WIDTHPROF = 120
200 self.WIDTHPROF = 120
26 self.HEIGHTPROF = 0
201 self.HEIGHTPROF = 0
27 self.counter_imagwr = 0
202 self.counter_imagwr = 0
28
203
29 self.PLOT_CODE = SPEC_CODE
204 self.PLOT_CODE = SPEC_CODE
30
205
31 self.FTP_WEI = None
206 self.FTP_WEI = None
32 self.EXP_CODE = None
207 self.EXP_CODE = None
33 self.SUB_EXP_CODE = None
208 self.SUB_EXP_CODE = None
34 self.PLOT_POS = None
209 self.PLOT_POS = None
35
210
36 self.__xfilter_ena = False
211 self.__xfilter_ena = False
37 self.__yfilter_ena = False
212 self.__yfilter_ena = False
38
213
39 def getSubplots(self):
214 def getSubplots(self):
40
215
41 ncol = int(numpy.sqrt(self.nplots)+0.9)
216 ncol = int(numpy.sqrt(self.nplots)+0.9)
42 nrow = int(self.nplots*1./ncol + 0.9)
217 nrow = int(self.nplots*1./ncol + 0.9)
43
218
44 return nrow, ncol
219 return nrow, ncol
45
220
46 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
221 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
47
222
48 self.__showprofile = showprofile
223 self.__showprofile = showprofile
49 self.nplots = nplots
224 self.nplots = nplots
50
225
51 ncolspan = 1
226 ncolspan = 1
52 colspan = 1
227 colspan = 1
53 if showprofile:
228 if showprofile:
54 ncolspan = 3
229 ncolspan = 3
55 colspan = 2
230 colspan = 2
56 self.__nsubplots = 2
231 self.__nsubplots = 2
57
232
58 self.createFigure(id = id,
233 self.createFigure(id = id,
59 wintitle = wintitle,
234 wintitle = wintitle,
60 widthplot = self.WIDTH + self.WIDTHPROF,
235 widthplot = self.WIDTH + self.WIDTHPROF,
61 heightplot = self.HEIGHT + self.HEIGHTPROF,
236 heightplot = self.HEIGHT + self.HEIGHTPROF,
62 show=show)
237 show=show)
63
238
64 nrow, ncol = self.getSubplots()
239 nrow, ncol = self.getSubplots()
65
240
66 counter = 0
241 counter = 0
67 for y in range(nrow):
242 for y in range(nrow):
68 for x in range(ncol):
243 for x in range(ncol):
69
244
70 if counter >= self.nplots:
245 if counter >= self.nplots:
71 break
246 break
72
247
73 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
248 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
74
249
75 if showprofile:
250 if showprofile:
76 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
251 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
77
252
78 counter += 1
253 counter += 1
79
254
80 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
255 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
81 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
256 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
82 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
257 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
83 server=None, folder=None, username=None, password=None,
258 server=None, folder=None, username=None, password=None,
84 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
259 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
85 xaxis="frequency", colormap='jet', normFactor=None , Selector = 0):
260 xaxis="frequency", colormap='jet', normFactor=None , Selector = 0):
86
261
87 """
262 """
88
263
89 Input:
264 Input:
90 dataOut :
265 dataOut :
91 id :
266 id :
92 wintitle :
267 wintitle :
93 channelList :
268 channelList :
94 showProfile :
269 showProfile :
95 xmin : None,
270 xmin : None,
96 xmax : None,
271 xmax : None,
97 ymin : None,
272 ymin : None,
98 ymax : None,
273 ymax : None,
99 zmin : None,
274 zmin : None,
100 zmax : None
275 zmax : None
101 """
276 """
102 if realtime:
277 if realtime:
103 if not(isRealtime(utcdatatime = dataOut.utctime)):
278 if not(isRealtime(utcdatatime = dataOut.utctime)):
104 print 'Skipping this plot function'
279 print 'Skipping this plot function'
105 return
280 return
106
281
107 if channelList == None:
282 if channelList == None:
108 channelIndexList = dataOut.channelIndexList
283 channelIndexList = dataOut.channelIndexList
109 else:
284 else:
110 channelIndexList = []
285 channelIndexList = []
111 for channel in channelList:
286 for channel in channelList:
112 if channel not in dataOut.channelList:
287 if channel not in dataOut.channelList:
113 raise ValueError, "Channel %d is not in dataOut.channelList" %channel
288 raise ValueError, "Channel %d is not in dataOut.channelList" %channel
114 channelIndexList.append(dataOut.channelList.index(channel))
289 channelIndexList.append(dataOut.channelList.index(channel))
115
290
116 # if normFactor is None:
291 # if normFactor is None:
117 # factor = dataOut.normFactor
292 # factor = dataOut.normFactor
118 # else:
293 # else:
119 # factor = normFactor
294 # factor = normFactor
120 if xaxis == "frequency":
295 if xaxis == "frequency":
121 x = dataOut.spcparam_range[0]
296 x = dataOut.spcparam_range[0]
122 xlabel = "Frequency (kHz)"
297 xlabel = "Frequency (kHz)"
123
298
124 elif xaxis == "time":
299 elif xaxis == "time":
125 x = dataOut.spcparam_range[1]
300 x = dataOut.spcparam_range[1]
126 xlabel = "Time (ms)"
301 xlabel = "Time (ms)"
127
302
128 else:
303 else:
129 x = dataOut.spcparam_range[2]
304 x = dataOut.spcparam_range[2]
130 xlabel = "Velocity (m/s)"
305 xlabel = "Velocity (m/s)"
131 print "Vmax=",x[-1]
306 print "Vmax=",x[-1]
132
307
133 ylabel = "Range (km)"
308 ylabel = "Range (km)"
134
309
135 y = dataOut.getHeiRange()
310 y = dataOut.getHeiRange()
136
311
137 z = dataOut.SPCparam[Selector] /1966080.0#/ dataOut.normFactor#GauSelector] #dataOut.data_spc/factor
312 z = dataOut.SPCparam[Selector] /1966080.0#/ dataOut.normFactor#GauSelector] #dataOut.data_spc/factor
138 #print 'GausSPC', z[0,32,10:40]
313 #print 'GausSPC', z[0,32,10:40]
139 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
314 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
140 zdB = 10*numpy.log10(z)
315 zdB = 10*numpy.log10(z)
141
316
142 avg = numpy.average(z, axis=1)
317 avg = numpy.average(z, axis=1)
143 avgdB = 10*numpy.log10(avg)
318 avgdB = 10*numpy.log10(avg)
144
319
145 noise = dataOut.spc_noise
320 noise = dataOut.spc_noise
146 noisedB = 10*numpy.log10(noise)
321 noisedB = 10*numpy.log10(noise)
147
322
148 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
323 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
149 title = wintitle + " Spectra"
324 title = wintitle + " Spectra"
150 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
325 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
151 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
326 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
152
327
153 if not self.isConfig:
328 if not self.isConfig:
154
329
155 nplots = len(channelIndexList)
330 nplots = len(channelIndexList)
156
331
157 self.setup(id=id,
332 self.setup(id=id,
158 nplots=nplots,
333 nplots=nplots,
159 wintitle=wintitle,
334 wintitle=wintitle,
160 showprofile=showprofile,
335 showprofile=showprofile,
161 show=show)
336 show=show)
162
337
163 if xmin == None: xmin = numpy.nanmin(x)
338 if xmin == None: xmin = numpy.nanmin(x)
164 if xmax == None: xmax = numpy.nanmax(x)
339 if xmax == None: xmax = numpy.nanmax(x)
165 if ymin == None: ymin = numpy.nanmin(y)
340 if ymin == None: ymin = numpy.nanmin(y)
166 if ymax == None: ymax = numpy.nanmax(y)
341 if ymax == None: ymax = numpy.nanmax(y)
167 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
342 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
168 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
343 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
169
344
170 self.FTP_WEI = ftp_wei
345 self.FTP_WEI = ftp_wei
171 self.EXP_CODE = exp_code
346 self.EXP_CODE = exp_code
172 self.SUB_EXP_CODE = sub_exp_code
347 self.SUB_EXP_CODE = sub_exp_code
173 self.PLOT_POS = plot_pos
348 self.PLOT_POS = plot_pos
174
349
175 self.isConfig = True
350 self.isConfig = True
176
351
177 self.setWinTitle(title)
352 self.setWinTitle(title)
178
353
179 for i in range(self.nplots):
354 for i in range(self.nplots):
180 index = channelIndexList[i]
355 index = channelIndexList[i]
181 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
356 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
182 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime)
357 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime)
183 if len(dataOut.beam.codeList) != 0:
358 if len(dataOut.beam.codeList) != 0:
184 title = "Ch%d:%4.2fdB,%2.2f,%2.2f:%s" %(dataOut.channelList[index], noisedB[index], dataOut.beam.azimuthList[index], dataOut.beam.zenithList[index], str_datetime)
359 title = "Ch%d:%4.2fdB,%2.2f,%2.2f:%s" %(dataOut.channelList[index], noisedB[index], dataOut.beam.azimuthList[index], dataOut.beam.zenithList[index], str_datetime)
185
360
186 axes = self.axesList[i*self.__nsubplots]
361 axes = self.axesList[i*self.__nsubplots]
187 axes.pcolor(x, y, zdB[index,:,:],
362 axes.pcolor(x, y, zdB[index,:,:],
188 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
363 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
189 xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap,
364 xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap,
190 ticksize=9, cblabel='')
365 ticksize=9, cblabel='')
191
366
192 if self.__showprofile:
367 if self.__showprofile:
193 axes = self.axesList[i*self.__nsubplots +1]
368 axes = self.axesList[i*self.__nsubplots +1]
194 axes.pline(avgdB[index,:], y,
369 axes.pline(avgdB[index,:], y,
195 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
370 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
196 xlabel='dB', ylabel='', title='',
371 xlabel='dB', ylabel='', title='',
197 ytick_visible=False,
372 ytick_visible=False,
198 grid='x')
373 grid='x')
199
374
200 noiseline = numpy.repeat(noisedB[index], len(y))
375 noiseline = numpy.repeat(noisedB[index], len(y))
201 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
376 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
202
377
203 self.draw()
378 self.draw()
204
379
205 if figfile == None:
380 if figfile == None:
206 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
381 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
207 name = str_datetime
382 name = str_datetime
208 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
383 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
209 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
384 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
210 figfile = self.getFilename(name)
385 figfile = self.getFilename(name)
211
386
212 self.save(figpath=figpath,
387 self.save(figpath=figpath,
213 figfile=figfile,
388 figfile=figfile,
214 save=save,
389 save=save,
215 ftp=ftp,
390 ftp=ftp,
216 wr_period=wr_period,
391 wr_period=wr_period,
217 thisDatetime=thisDatetime)
392 thisDatetime=thisDatetime)
218
393
219
394
220
395
221 class MomentsPlot(Figure):
396 class MomentsPlot(Figure):
222
397
223 isConfig = None
398 isConfig = None
224 __nsubplots = None
399 __nsubplots = None
225
400
226 WIDTHPROF = None
401 WIDTHPROF = None
227 HEIGHTPROF = None
402 HEIGHTPROF = None
228 PREFIX = 'prm'
403 PREFIX = 'prm'
229
404
230 def __init__(self, **kwargs):
405 def __init__(self, **kwargs):
231 Figure.__init__(self, **kwargs)
406 Figure.__init__(self, **kwargs)
232 self.isConfig = False
407 self.isConfig = False
233 self.__nsubplots = 1
408 self.__nsubplots = 1
234
409
235 self.WIDTH = 280
410 self.WIDTH = 280
236 self.HEIGHT = 250
411 self.HEIGHT = 250
237 self.WIDTHPROF = 120
412 self.WIDTHPROF = 120
238 self.HEIGHTPROF = 0
413 self.HEIGHTPROF = 0
239 self.counter_imagwr = 0
414 self.counter_imagwr = 0
240
415
241 self.PLOT_CODE = MOMENTS_CODE
416 self.PLOT_CODE = MOMENTS_CODE
242
417
243 self.FTP_WEI = None
418 self.FTP_WEI = None
244 self.EXP_CODE = None
419 self.EXP_CODE = None
245 self.SUB_EXP_CODE = None
420 self.SUB_EXP_CODE = None
246 self.PLOT_POS = None
421 self.PLOT_POS = None
247
422
248 def getSubplots(self):
423 def getSubplots(self):
249
424
250 ncol = int(numpy.sqrt(self.nplots)+0.9)
425 ncol = int(numpy.sqrt(self.nplots)+0.9)
251 nrow = int(self.nplots*1./ncol + 0.9)
426 nrow = int(self.nplots*1./ncol + 0.9)
252
427
253 return nrow, ncol
428 return nrow, ncol
254
429
255 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
430 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
256
431
257 self.__showprofile = showprofile
432 self.__showprofile = showprofile
258 self.nplots = nplots
433 self.nplots = nplots
259
434
260 ncolspan = 1
435 ncolspan = 1
261 colspan = 1
436 colspan = 1
262 if showprofile:
437 if showprofile:
263 ncolspan = 3
438 ncolspan = 3
264 colspan = 2
439 colspan = 2
265 self.__nsubplots = 2
440 self.__nsubplots = 2
266
441
267 self.createFigure(id = id,
442 self.createFigure(id = id,
268 wintitle = wintitle,
443 wintitle = wintitle,
269 widthplot = self.WIDTH + self.WIDTHPROF,
444 widthplot = self.WIDTH + self.WIDTHPROF,
270 heightplot = self.HEIGHT + self.HEIGHTPROF,
445 heightplot = self.HEIGHT + self.HEIGHTPROF,
271 show=show)
446 show=show)
272
447
273 nrow, ncol = self.getSubplots()
448 nrow, ncol = self.getSubplots()
274
449
275 counter = 0
450 counter = 0
276 for y in range(nrow):
451 for y in range(nrow):
277 for x in range(ncol):
452 for x in range(ncol):
278
453
279 if counter >= self.nplots:
454 if counter >= self.nplots:
280 break
455 break
281
456
282 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
457 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
283
458
284 if showprofile:
459 if showprofile:
285 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
460 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
286
461
287 counter += 1
462 counter += 1
288
463
289 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
464 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
290 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
465 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
291 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
466 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
292 server=None, folder=None, username=None, password=None,
467 server=None, folder=None, username=None, password=None,
293 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
468 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
294
469
295 """
470 """
296
471
297 Input:
472 Input:
298 dataOut :
473 dataOut :
299 id :
474 id :
300 wintitle :
475 wintitle :
301 channelList :
476 channelList :
302 showProfile :
477 showProfile :
303 xmin : None,
478 xmin : None,
304 xmax : None,
479 xmax : None,
305 ymin : None,
480 ymin : None,
306 ymax : None,
481 ymax : None,
307 zmin : None,
482 zmin : None,
308 zmax : None
483 zmax : None
309 """
484 """
310
485
311 if dataOut.flagNoData:
486 if dataOut.flagNoData:
312 return None
487 return None
313
488
314 if realtime:
489 if realtime:
315 if not(isRealtime(utcdatatime = dataOut.utctime)):
490 if not(isRealtime(utcdatatime = dataOut.utctime)):
316 print 'Skipping this plot function'
491 print 'Skipping this plot function'
317 return
492 return
318
493
319 if channelList == None:
494 if channelList == None:
320 channelIndexList = dataOut.channelIndexList
495 channelIndexList = dataOut.channelIndexList
321 else:
496 else:
322 channelIndexList = []
497 channelIndexList = []
323 for channel in channelList:
498 for channel in channelList:
324 if channel not in dataOut.channelList:
499 if channel not in dataOut.channelList:
325 raise ValueError, "Channel %d is not in dataOut.channelList"
500 raise ValueError, "Channel %d is not in dataOut.channelList"
326 channelIndexList.append(dataOut.channelList.index(channel))
501 channelIndexList.append(dataOut.channelList.index(channel))
327
502
328 factor = dataOut.normFactor
503 factor = dataOut.normFactor
329 x = dataOut.abscissaList
504 x = dataOut.abscissaList
330 y = dataOut.heightList
505 y = dataOut.heightList
331
506
332 z = dataOut.data_pre[channelIndexList,:,:]/factor
507 z = dataOut.data_pre[channelIndexList,:,:]/factor
333 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
508 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
334 avg = numpy.average(z, axis=1)
509 avg = numpy.average(z, axis=1)
335 noise = dataOut.noise/factor
510 noise = dataOut.noise/factor
336
511
337 zdB = 10*numpy.log10(z)
512 zdB = 10*numpy.log10(z)
338 avgdB = 10*numpy.log10(avg)
513 avgdB = 10*numpy.log10(avg)
339 noisedB = 10*numpy.log10(noise)
514 noisedB = 10*numpy.log10(noise)
340
515
341 #thisDatetime = dataOut.datatime
516 #thisDatetime = dataOut.datatime
342 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
517 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
343 title = wintitle + " Parameters"
518 title = wintitle + " Parameters"
344 xlabel = "Velocity (m/s)"
519 xlabel = "Velocity (m/s)"
345 ylabel = "Range (Km)"
520 ylabel = "Range (Km)"
346
521
347 update_figfile = False
522 update_figfile = False
348
523
349 if not self.isConfig:
524 if not self.isConfig:
350
525
351 nplots = len(channelIndexList)
526 nplots = len(channelIndexList)
352
527
353 self.setup(id=id,
528 self.setup(id=id,
354 nplots=nplots,
529 nplots=nplots,
355 wintitle=wintitle,
530 wintitle=wintitle,
356 showprofile=showprofile,
531 showprofile=showprofile,
357 show=show)
532 show=show)
358
533
359 if xmin == None: xmin = numpy.nanmin(x)
534 if xmin == None: xmin = numpy.nanmin(x)
360 if xmax == None: xmax = numpy.nanmax(x)
535 if xmax == None: xmax = numpy.nanmax(x)
361 if ymin == None: ymin = numpy.nanmin(y)
536 if ymin == None: ymin = numpy.nanmin(y)
362 if ymax == None: ymax = numpy.nanmax(y)
537 if ymax == None: ymax = numpy.nanmax(y)
363 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
538 if zmin == None: zmin = numpy.nanmin(avgdB)*0.9
364 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
539 if zmax == None: zmax = numpy.nanmax(avgdB)*0.9
365
540
366 self.FTP_WEI = ftp_wei
541 self.FTP_WEI = ftp_wei
367 self.EXP_CODE = exp_code
542 self.EXP_CODE = exp_code
368 self.SUB_EXP_CODE = sub_exp_code
543 self.SUB_EXP_CODE = sub_exp_code
369 self.PLOT_POS = plot_pos
544 self.PLOT_POS = plot_pos
370
545
371 self.isConfig = True
546 self.isConfig = True
372 update_figfile = True
547 update_figfile = True
373
548
374 self.setWinTitle(title)
549 self.setWinTitle(title)
375
550
376 for i in range(self.nplots):
551 for i in range(self.nplots):
377 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
552 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
378 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime)
553 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[i], noisedB[i], str_datetime)
379 axes = self.axesList[i*self.__nsubplots]
554 axes = self.axesList[i*self.__nsubplots]
380 axes.pcolor(x, y, zdB[i,:,:],
555 axes.pcolor(x, y, zdB[i,:,:],
381 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
556 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
382 xlabel=xlabel, ylabel=ylabel, title=title,
557 xlabel=xlabel, ylabel=ylabel, title=title,
383 ticksize=9, cblabel='')
558 ticksize=9, cblabel='')
384 #Mean Line
559 #Mean Line
385 mean = dataOut.data_param[i, 1, :]
560 mean = dataOut.data_param[i, 1, :]
386 axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1)
561 axes.addpline(mean, y, idline=0, color="black", linestyle="solid", lw=1)
387
562
388 if self.__showprofile:
563 if self.__showprofile:
389 axes = self.axesList[i*self.__nsubplots +1]
564 axes = self.axesList[i*self.__nsubplots +1]
390 axes.pline(avgdB[i], y,
565 axes.pline(avgdB[i], y,
391 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
566 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
392 xlabel='dB', ylabel='', title='',
567 xlabel='dB', ylabel='', title='',
393 ytick_visible=False,
568 ytick_visible=False,
394 grid='x')
569 grid='x')
395
570
396 noiseline = numpy.repeat(noisedB[i], len(y))
571 noiseline = numpy.repeat(noisedB[i], len(y))
397 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
572 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
398
573
399 self.draw()
574 self.draw()
400
575
401 self.save(figpath=figpath,
576 self.save(figpath=figpath,
402 figfile=figfile,
577 figfile=figfile,
403 save=save,
578 save=save,
404 ftp=ftp,
579 ftp=ftp,
405 wr_period=wr_period,
580 wr_period=wr_period,
406 thisDatetime=thisDatetime)
581 thisDatetime=thisDatetime)
407
582
408
583
409
584
410 class SkyMapPlot(Figure):
585 class SkyMapPlot(Figure):
411
586
412 __isConfig = None
587 __isConfig = None
413 __nsubplots = None
588 __nsubplots = None
414
589
415 WIDTHPROF = None
590 WIDTHPROF = None
416 HEIGHTPROF = None
591 HEIGHTPROF = None
417 PREFIX = 'mmap'
592 PREFIX = 'mmap'
418
593
419 def __init__(self, **kwargs):
594 def __init__(self, **kwargs):
420 Figure.__init__(self, **kwargs)
595 Figure.__init__(self, **kwargs)
421 self.isConfig = False
596 self.isConfig = False
422 self.__nsubplots = 1
597 self.__nsubplots = 1
423
598
424 # self.WIDTH = 280
599 # self.WIDTH = 280
425 # self.HEIGHT = 250
600 # self.HEIGHT = 250
426 self.WIDTH = 600
601 self.WIDTH = 600
427 self.HEIGHT = 600
602 self.HEIGHT = 600
428 self.WIDTHPROF = 120
603 self.WIDTHPROF = 120
429 self.HEIGHTPROF = 0
604 self.HEIGHTPROF = 0
430 self.counter_imagwr = 0
605 self.counter_imagwr = 0
431
606
432 self.PLOT_CODE = MSKYMAP_CODE
607 self.PLOT_CODE = MSKYMAP_CODE
433
608
434 self.FTP_WEI = None
609 self.FTP_WEI = None
435 self.EXP_CODE = None
610 self.EXP_CODE = None
436 self.SUB_EXP_CODE = None
611 self.SUB_EXP_CODE = None
437 self.PLOT_POS = None
612 self.PLOT_POS = None
438
613
439 def getSubplots(self):
614 def getSubplots(self):
440
615
441 ncol = int(numpy.sqrt(self.nplots)+0.9)
616 ncol = int(numpy.sqrt(self.nplots)+0.9)
442 nrow = int(self.nplots*1./ncol + 0.9)
617 nrow = int(self.nplots*1./ncol + 0.9)
443
618
444 return nrow, ncol
619 return nrow, ncol
445
620
446 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
621 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
447
622
448 self.__showprofile = showprofile
623 self.__showprofile = showprofile
449 self.nplots = nplots
624 self.nplots = nplots
450
625
451 ncolspan = 1
626 ncolspan = 1
452 colspan = 1
627 colspan = 1
453
628
454 self.createFigure(id = id,
629 self.createFigure(id = id,
455 wintitle = wintitle,
630 wintitle = wintitle,
456 widthplot = self.WIDTH, #+ self.WIDTHPROF,
631 widthplot = self.WIDTH, #+ self.WIDTHPROF,
457 heightplot = self.HEIGHT,# + self.HEIGHTPROF,
632 heightplot = self.HEIGHT,# + self.HEIGHTPROF,
458 show=show)
633 show=show)
459
634
460 nrow, ncol = 1,1
635 nrow, ncol = 1,1
461 counter = 0
636 counter = 0
462 x = 0
637 x = 0
463 y = 0
638 y = 0
464 self.addAxes(1, 1, 0, 0, 1, 1, True)
639 self.addAxes(1, 1, 0, 0, 1, 1, True)
465
640
466 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
641 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
467 tmin=0, tmax=24, timerange=None,
642 tmin=0, tmax=24, timerange=None,
468 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
643 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
469 server=None, folder=None, username=None, password=None,
644 server=None, folder=None, username=None, password=None,
470 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
645 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False):
471
646
472 """
647 """
473
648
474 Input:
649 Input:
475 dataOut :
650 dataOut :
476 id :
651 id :
477 wintitle :
652 wintitle :
478 channelList :
653 channelList :
479 showProfile :
654 showProfile :
480 xmin : None,
655 xmin : None,
481 xmax : None,
656 xmax : None,
482 ymin : None,
657 ymin : None,
483 ymax : None,
658 ymax : None,
484 zmin : None,
659 zmin : None,
485 zmax : None
660 zmax : None
486 """
661 """
487
662
488 arrayParameters = dataOut.data_param
663 arrayParameters = dataOut.data_param
489 error = arrayParameters[:,-1]
664 error = arrayParameters[:,-1]
490 indValid = numpy.where(error == 0)[0]
665 indValid = numpy.where(error == 0)[0]
491 finalMeteor = arrayParameters[indValid,:]
666 finalMeteor = arrayParameters[indValid,:]
492 finalAzimuth = finalMeteor[:,3]
667 finalAzimuth = finalMeteor[:,3]
493 finalZenith = finalMeteor[:,4]
668 finalZenith = finalMeteor[:,4]
494
669
495 x = finalAzimuth*numpy.pi/180
670 x = finalAzimuth*numpy.pi/180
496 y = finalZenith
671 y = finalZenith
497 x1 = [dataOut.ltctime, dataOut.ltctime]
672 x1 = [dataOut.ltctime, dataOut.ltctime]
498
673
499 #thisDatetime = dataOut.datatime
674 #thisDatetime = dataOut.datatime
500 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
675 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
501 title = wintitle + " Parameters"
676 title = wintitle + " Parameters"
502 xlabel = "Zonal Zenith Angle (deg) "
677 xlabel = "Zonal Zenith Angle (deg) "
503 ylabel = "Meridional Zenith Angle (deg)"
678 ylabel = "Meridional Zenith Angle (deg)"
504 update_figfile = False
679 update_figfile = False
505
680
506 if not self.isConfig:
681 if not self.isConfig:
507
682
508 nplots = 1
683 nplots = 1
509
684
510 self.setup(id=id,
685 self.setup(id=id,
511 nplots=nplots,
686 nplots=nplots,
512 wintitle=wintitle,
687 wintitle=wintitle,
513 showprofile=showprofile,
688 showprofile=showprofile,
514 show=show)
689 show=show)
515
690
516 if self.xmin is None and self.xmax is None:
691 if self.xmin is None and self.xmax is None:
517 self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange)
692 self.xmin, self.xmax = self.getTimeLim(x1, tmin, tmax, timerange)
518
693
519 if timerange != None:
694 if timerange != None:
520 self.timerange = timerange
695 self.timerange = timerange
521 else:
696 else:
522 self.timerange = self.xmax - self.xmin
697 self.timerange = self.xmax - self.xmin
523
698
524 self.FTP_WEI = ftp_wei
699 self.FTP_WEI = ftp_wei
525 self.EXP_CODE = exp_code
700 self.EXP_CODE = exp_code
526 self.SUB_EXP_CODE = sub_exp_code
701 self.SUB_EXP_CODE = sub_exp_code
527 self.PLOT_POS = plot_pos
702 self.PLOT_POS = plot_pos
528 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
703 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
529 self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
704 self.firstdate = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
530 self.isConfig = True
705 self.isConfig = True
531 update_figfile = True
706 update_figfile = True
532
707
533 self.setWinTitle(title)
708 self.setWinTitle(title)
534
709
535 i = 0
710 i = 0
536 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
711 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
537
712
538 axes = self.axesList[i*self.__nsubplots]
713 axes = self.axesList[i*self.__nsubplots]
539 nevents = axes.x_buffer.shape[0] + x.shape[0]
714 nevents = axes.x_buffer.shape[0] + x.shape[0]
540 title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents)
715 title = "Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n" %(self.firstdate,str_datetime,nevents)
541 axes.polar(x, y,
716 axes.polar(x, y,
542 title=title, xlabel=xlabel, ylabel=ylabel,
717 title=title, xlabel=xlabel, ylabel=ylabel,
543 ticksize=9, cblabel='')
718 ticksize=9, cblabel='')
544
719
545 self.draw()
720 self.draw()
546
721
547 self.save(figpath=figpath,
722 self.save(figpath=figpath,
548 figfile=figfile,
723 figfile=figfile,
549 save=save,
724 save=save,
550 ftp=ftp,
725 ftp=ftp,
551 wr_period=wr_period,
726 wr_period=wr_period,
552 thisDatetime=thisDatetime,
727 thisDatetime=thisDatetime,
553 update_figfile=update_figfile)
728 update_figfile=update_figfile)
554
729
555 if dataOut.ltctime >= self.xmax:
730 if dataOut.ltctime >= self.xmax:
556 self.isConfigmagwr = wr_period
731 self.isConfigmagwr = wr_period
557 self.isConfig = False
732 self.isConfig = False
558 update_figfile = True
733 update_figfile = True
559 axes.__firsttime = True
734 axes.__firsttime = True
560 self.xmin += self.timerange
735 self.xmin += self.timerange
561 self.xmax += self.timerange
736 self.xmax += self.timerange
562
737
563
738
564
739
565
740
566 class WindProfilerPlot(Figure):
741 class WindProfilerPlot(Figure):
567
742
568 __isConfig = None
743 __isConfig = None
569 __nsubplots = None
744 __nsubplots = None
570
745
571 WIDTHPROF = None
746 WIDTHPROF = None
572 HEIGHTPROF = None
747 HEIGHTPROF = None
573 PREFIX = 'wind'
748 PREFIX = 'wind'
574
749
575 def __init__(self, **kwargs):
750 def __init__(self, **kwargs):
576 Figure.__init__(self, **kwargs)
751 Figure.__init__(self, **kwargs)
577 self.timerange = None
752 self.timerange = None
578 self.isConfig = False
753 self.isConfig = False
579 self.__nsubplots = 1
754 self.__nsubplots = 1
580
755
581 self.WIDTH = 800
756 self.WIDTH = 800
582 self.HEIGHT = 300
757 self.HEIGHT = 300
583 self.WIDTHPROF = 120
758 self.WIDTHPROF = 120
584 self.HEIGHTPROF = 0
759 self.HEIGHTPROF = 0
585 self.counter_imagwr = 0
760 self.counter_imagwr = 0
586
761
587 self.PLOT_CODE = WIND_CODE
762 self.PLOT_CODE = WIND_CODE
588
763
589 self.FTP_WEI = None
764 self.FTP_WEI = None
590 self.EXP_CODE = None
765 self.EXP_CODE = None
591 self.SUB_EXP_CODE = None
766 self.SUB_EXP_CODE = None
592 self.PLOT_POS = None
767 self.PLOT_POS = None
593 self.tmin = None
768 self.tmin = None
594 self.tmax = None
769 self.tmax = None
595
770
596 self.xmin = None
771 self.xmin = None
597 self.xmax = None
772 self.xmax = None
598
773
599 self.figfile = None
774 self.figfile = None
600
775
601 def getSubplots(self):
776 def getSubplots(self):
602
777
603 ncol = 1
778 ncol = 1
604 nrow = self.nplots
779 nrow = self.nplots
605
780
606 return nrow, ncol
781 return nrow, ncol
607
782
608 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
783 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
609
784
610 self.__showprofile = showprofile
785 self.__showprofile = showprofile
611 self.nplots = nplots
786 self.nplots = nplots
612
787
613 ncolspan = 1
788 ncolspan = 1
614 colspan = 1
789 colspan = 1
615
790
616 self.createFigure(id = id,
791 self.createFigure(id = id,
617 wintitle = wintitle,
792 wintitle = wintitle,
618 widthplot = self.WIDTH + self.WIDTHPROF,
793 widthplot = self.WIDTH + self.WIDTHPROF,
619 heightplot = self.HEIGHT + self.HEIGHTPROF,
794 heightplot = self.HEIGHT + self.HEIGHTPROF,
620 show=show)
795 show=show)
621
796
622 nrow, ncol = self.getSubplots()
797 nrow, ncol = self.getSubplots()
623
798
624 counter = 0
799 counter = 0
625 for y in range(nrow):
800 for y in range(nrow):
626 if counter >= self.nplots:
801 if counter >= self.nplots:
627 break
802 break
628
803
629 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
804 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
630 counter += 1
805 counter += 1
631
806
632 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False',
807 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='False',
633 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
808 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
634 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
809 zmax_ver = None, zmin_ver = None, SNRmin = None, SNRmax = None,
635 timerange=None, SNRthresh = None,
810 timerange=None, SNRthresh = None,
636 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
811 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
637 server=None, folder=None, username=None, password=None,
812 server=None, folder=None, username=None, password=None,
638 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
813 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
639 """
814 """
640
815
641 Input:
816 Input:
642 dataOut :
817 dataOut :
643 id :
818 id :
644 wintitle :
819 wintitle :
645 channelList :
820 channelList :
646 showProfile :
821 showProfile :
647 xmin : None,
822 xmin : None,
648 xmax : None,
823 xmax : None,
649 ymin : None,
824 ymin : None,
650 ymax : None,
825 ymax : None,
651 zmin : None,
826 zmin : None,
652 zmax : None
827 zmax : None
653 """
828 """
654
829
655 # if timerange is not None:
830 # if timerange is not None:
656 # self.timerange = timerange
831 # self.timerange = timerange
657 #
832 #
658 # tmin = None
833 # tmin = None
659 # tmax = None
834 # tmax = None
660
835
661 x = dataOut.getTimeRange1(dataOut.paramInterval)
836 x = dataOut.getTimeRange1(dataOut.paramInterval)
662 y = dataOut.heightList
837 y = dataOut.heightList
663 z = dataOut.data_output.copy()
838 z = dataOut.data_output.copy()
664 nplots = z.shape[0] #Number of wind dimensions estimated
839 nplots = z.shape[0] #Number of wind dimensions estimated
665 nplotsw = nplots
840 nplotsw = nplots
666
841
667
842
668 #If there is a SNR function defined
843 #If there is a SNR function defined
669 if dataOut.data_SNR is not None:
844 if dataOut.data_SNR is not None:
670 nplots += 1
845 nplots += 1
671 SNR = dataOut.data_SNR[0]
846 SNR = dataOut.data_SNR[0]
672 SNRavg = SNR#numpy.average(SNR, axis=0)
847 SNRavg = SNR#numpy.average(SNR, axis=0)
673
848
674 SNRdB = 10*numpy.log10(SNR)
849 SNRdB = 10*numpy.log10(SNR)
675 SNRavgdB = 10*numpy.log10(SNRavg)
850 SNRavgdB = 10*numpy.log10(SNRavg)
676
851
677 if SNRthresh == None:
852 if SNRthresh == None:
678 SNRthresh = -5.0
853 SNRthresh = -5.0
679 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
854 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
680
855
681 for i in range(nplotsw):
856 for i in range(nplotsw):
682 z[i,ind] = numpy.nan
857 z[i,ind] = numpy.nan
683
858
684 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
859 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
685 #thisDatetime = datetime.datetime.now()
860 #thisDatetime = datetime.datetime.now()
686 title = wintitle + "Wind"
861 title = wintitle + "Wind"
687 xlabel = ""
862 xlabel = ""
688 ylabel = "Height (km)"
863 ylabel = "Height (km)"
689 update_figfile = False
864 update_figfile = False
690
865
691 if not self.isConfig:
866 if not self.isConfig:
692
867
693 self.setup(id=id,
868 self.setup(id=id,
694 nplots=nplots,
869 nplots=nplots,
695 wintitle=wintitle,
870 wintitle=wintitle,
696 showprofile=showprofile,
871 showprofile=showprofile,
697 show=show)
872 show=show)
698
873
699 if timerange is not None:
874 if timerange is not None:
700 self.timerange = timerange
875 self.timerange = timerange
701
876
702 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
877 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
703
878
704 if ymin == None: ymin = numpy.nanmin(y)
879 if ymin == None: ymin = numpy.nanmin(y)
705 if ymax == None: ymax = numpy.nanmax(y)
880 if ymax == None: ymax = numpy.nanmax(y)
706
881
707 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
882 if zmax == None: zmax = numpy.nanmax(abs(z[range(2),:]))
708 #if numpy.isnan(zmax): zmax = 50
883 #if numpy.isnan(zmax): zmax = 50
709 if zmin == None: zmin = -zmax
884 if zmin == None: zmin = -zmax
710
885
711 if nplotsw == 3:
886 if nplotsw == 3:
712 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
887 if zmax_ver == None: zmax_ver = numpy.nanmax(abs(z[2,:]))
713 if zmin_ver == None: zmin_ver = -zmax_ver
888 if zmin_ver == None: zmin_ver = -zmax_ver
714
889
715 if dataOut.data_SNR is not None:
890 if dataOut.data_SNR is not None:
716 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
891 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
717 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
892 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
718
893
719
894
720 self.FTP_WEI = ftp_wei
895 self.FTP_WEI = ftp_wei
721 self.EXP_CODE = exp_code
896 self.EXP_CODE = exp_code
722 self.SUB_EXP_CODE = sub_exp_code
897 self.SUB_EXP_CODE = sub_exp_code
723 self.PLOT_POS = plot_pos
898 self.PLOT_POS = plot_pos
724
899
725 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
900 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
726 self.isConfig = True
901 self.isConfig = True
727 self.figfile = figfile
902 self.figfile = figfile
728 update_figfile = True
903 update_figfile = True
729
904
730 self.setWinTitle(title)
905 self.setWinTitle(title)
731
906
732 if ((self.xmax - x[1]) < (x[1]-x[0])):
907 if ((self.xmax - x[1]) < (x[1]-x[0])):
733 x[1] = self.xmax
908 x[1] = self.xmax
734
909
735 strWind = ['Zonal', 'Meridional', 'Vertical']
910 strWind = ['Zonal', 'Meridional', 'Vertical']
736 strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
911 strCb = ['Velocity (m/s)','Velocity (m/s)','Velocity (cm/s)']
737 zmaxVector = [zmax, zmax, zmax_ver]
912 zmaxVector = [zmax, zmax, zmax_ver]
738 zminVector = [zmin, zmin, zmin_ver]
913 zminVector = [zmin, zmin, zmin_ver]
739 windFactor = [1,1,100]
914 windFactor = [1,1,100]
740
915
741 for i in range(nplotsw):
916 for i in range(nplotsw):
742
917
743 title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
918 title = "%s Wind: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
744 axes = self.axesList[i*self.__nsubplots]
919 axes = self.axesList[i*self.__nsubplots]
745
920
746 z1 = z[i,:].reshape((1,-1))*windFactor[i]
921 z1 = z[i,:].reshape((1,-1))*windFactor[i]
747
922
748 print 'x', x
923 print 'x', x
749 print datetime.datetime.utcfromtimestamp(x[0])
924 print datetime.datetime.utcfromtimestamp(x[0])
750 print datetime.datetime.utcfromtimestamp(x[1])
925 print datetime.datetime.utcfromtimestamp(x[1])
751
926
752 #z1=numpy.ma.masked_where(z1==0.,z1)
927 #z1=numpy.ma.masked_where(z1==0.,z1)
753
928
754 axes.pcolorbuffer(x, y, z1,
929 axes.pcolorbuffer(x, y, z1,
755 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
930 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
756 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
931 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
757 ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="seismic" )
932 ticksize=9, cblabel=strCb[i], cbsize="1%", colormap="seismic" )
758
933
759 if dataOut.data_SNR is not None:
934 if dataOut.data_SNR is not None:
760 i += 1
935 i += 1
761 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
936 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
762 axes = self.axesList[i*self.__nsubplots]
937 axes = self.axesList[i*self.__nsubplots]
763 SNRavgdB = SNRavgdB.reshape((1,-1))
938 SNRavgdB = SNRavgdB.reshape((1,-1))
764 axes.pcolorbuffer(x, y, SNRavgdB,
939 axes.pcolorbuffer(x, y, SNRavgdB,
765 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
940 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
766 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
941 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
767 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
942 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
768
943
769 self.draw()
944 self.draw()
770
945
771 self.save(figpath=figpath,
946 self.save(figpath=figpath,
772 figfile=figfile,
947 figfile=figfile,
773 save=save,
948 save=save,
774 ftp=ftp,
949 ftp=ftp,
775 wr_period=wr_period,
950 wr_period=wr_period,
776 thisDatetime=thisDatetime,
951 thisDatetime=thisDatetime,
777 update_figfile=update_figfile)
952 update_figfile=update_figfile)
778
953
779 if dataOut.ltctime + dataOut.paramInterval >= self.xmax:
954 if dataOut.ltctime + dataOut.paramInterval >= self.xmax:
780 self.counter_imagwr = wr_period
955 self.counter_imagwr = wr_period
781 self.isConfig = False
956 self.isConfig = False
782 update_figfile = True
957 update_figfile = True
783
958
784
959
785 class ParametersPlot(Figure):
960 class ParametersPlot(Figure):
786
961
787 __isConfig = None
962 __isConfig = None
788 __nsubplots = None
963 __nsubplots = None
789
964
790 WIDTHPROF = None
965 WIDTHPROF = None
791 HEIGHTPROF = None
966 HEIGHTPROF = None
792 PREFIX = 'param'
967 PREFIX = 'param'
793
968
794 nplots = None
969 nplots = None
795 nchan = None
970 nchan = None
796
971
797 def __init__(self, **kwargs):
972 def __init__(self, **kwargs):
798 Figure.__init__(self, **kwargs)
973 Figure.__init__(self, **kwargs)
799 self.timerange = None
974 self.timerange = None
800 self.isConfig = False
975 self.isConfig = False
801 self.__nsubplots = 1
976 self.__nsubplots = 1
802
977
803 self.WIDTH = 800
978 self.WIDTH = 300
804 self.HEIGHT = 250
979 self.HEIGHT = 550
805 self.WIDTHPROF = 120
980 self.WIDTHPROF = 120
806 self.HEIGHTPROF = 0
981 self.HEIGHTPROF = 0
807 self.counter_imagwr = 0
982 self.counter_imagwr = 0
808
983
809 self.PLOT_CODE = RTI_CODE
984 self.PLOT_CODE = RTI_CODE
810
985
811 self.FTP_WEI = None
986 self.FTP_WEI = None
812 self.EXP_CODE = None
987 self.EXP_CODE = None
813 self.SUB_EXP_CODE = None
988 self.SUB_EXP_CODE = None
814 self.PLOT_POS = None
989 self.PLOT_POS = None
815 self.tmin = None
990 self.tmin = None
816 self.tmax = None
991 self.tmax = None
817
992
818 self.xmin = None
993 self.xmin = None
819 self.xmax = None
994 self.xmax = None
820
995
821 self.figfile = None
996 self.figfile = None
822
997
823 def getSubplots(self):
998 def getSubplots(self):
824
999
825 ncol = 1
1000 ncol = 1
826 nrow = self.nplots
1001 nrow = self.nplots
827
1002
828 return nrow, ncol
1003 return nrow, ncol
829
1004
830 def setup(self, id, nplots, wintitle, show=True):
1005 def setup(self, id, nplots, wintitle, show=True):
831
1006
832 self.nplots = nplots
1007 self.nplots = nplots
833
1008
834 ncolspan = 1
1009 ncolspan = 1
835 colspan = 1
1010 colspan = 1
836
1011
837 self.createFigure(id = id,
1012 self.createFigure(id = id,
838 wintitle = wintitle,
1013 wintitle = wintitle,
839 widthplot = self.WIDTH + self.WIDTHPROF,
1014 widthplot = self.WIDTH + self.WIDTHPROF,
840 heightplot = self.HEIGHT + self.HEIGHTPROF,
1015 heightplot = self.HEIGHT + self.HEIGHTPROF,
841 show=show)
1016 show=show)
842
1017
843 nrow, ncol = self.getSubplots()
1018 nrow, ncol = self.getSubplots()
844
1019
845 counter = 0
1020 counter = 0
846 for y in range(nrow):
1021 for y in range(nrow):
847 for x in range(ncol):
1022 for x in range(ncol):
848
1023
849 if counter >= self.nplots:
1024 if counter >= self.nplots:
850 break
1025 break
851
1026
852 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1027 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
853
1028
854 counter += 1
1029 counter += 1
855
1030
856 def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap="jet",
1031 def run(self, dataOut, id, wintitle="", channelList=None, paramIndex = 0, colormap="jet",
857 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None,
1032 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, timerange=None,
858 showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None,
1033 showSNR=False, SNRthresh = -numpy.inf, SNRmin=None, SNRmax=None,
859 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1034 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
860 server=None, folder=None, username=None, password=None,
1035 server=None, folder=None, username=None, password=None,
861 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, HEIGHT=None):
1036 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, HEIGHT=None):
862 """
1037 """
863
1038
864 Input:
1039 Input:
865 dataOut :
1040 dataOut :
866 id :
1041 id :
867 wintitle :
1042 wintitle :
868 channelList :
1043 channelList :
869 showProfile :
1044 showProfile :
870 xmin : None,
1045 xmin : None,
871 xmax : None,
1046 xmax : None,
872 ymin : None,
1047 ymin : None,
873 ymax : None,
1048 ymax : None,
874 zmin : None,
1049 zmin : None,
875 zmax : None
1050 zmax : None
876 """
1051 """
877
1052
878 if HEIGHT is not None:
1053 if HEIGHT is not None:
879 self.HEIGHT = HEIGHT
1054 self.HEIGHT = HEIGHT
880
1055
881
1056
882 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1057 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
883 return
1058 return
884
1059
885 if channelList == None:
1060 if channelList == None:
886 channelIndexList = range(dataOut.data_param.shape[0])
1061 channelIndexList = range(dataOut.data_param.shape[0])
887 else:
1062 else:
888 channelIndexList = []
1063 channelIndexList = []
889 for channel in channelList:
1064 for channel in channelList:
890 if channel not in dataOut.channelList:
1065 if channel not in dataOut.channelList:
891 raise ValueError, "Channel %d is not in dataOut.channelList"
1066 raise ValueError, "Channel %d is not in dataOut.channelList"
892 channelIndexList.append(dataOut.channelList.index(channel))
1067 channelIndexList.append(dataOut.channelList.index(channel))
893
1068
894 x = dataOut.getTimeRange1(dataOut.paramInterval)
1069 x = dataOut.getTimeRange1(dataOut.paramInterval)
895 y = dataOut.getHeiRange()
1070 y = dataOut.getHeiRange()
896
1071
897 if dataOut.data_param.ndim == 3:
1072 if dataOut.data_param.ndim == 3:
898 z = dataOut.data_param[channelIndexList,paramIndex,:]
1073 z = dataOut.data_param[channelIndexList,paramIndex,:]
899 else:
1074 else:
900 z = dataOut.data_param[channelIndexList,:]
1075 z = dataOut.data_param[channelIndexList,:]
901
1076
902 if showSNR:
1077 if showSNR:
903 #SNR data
1078 #SNR data
904 SNRarray = dataOut.data_SNR[channelIndexList,:]
1079 SNRarray = dataOut.data_SNR[channelIndexList,:]
905 SNRdB = 10*numpy.log10(SNRarray)
1080 SNRdB = 10*numpy.log10(SNRarray)
906 ind = numpy.where(SNRdB < SNRthresh)
1081 ind = numpy.where(SNRdB < SNRthresh)
907 z[ind] = numpy.nan
1082 z[ind] = numpy.nan
908
1083
909 thisDatetime = dataOut.datatime
1084 thisDatetime = dataOut.datatime
910 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1085 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
911 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
1086 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
912 xlabel = ""
1087 xlabel = ""
913 ylabel = "Range (Km)"
1088 ylabel = "Range (km)"
914
1089
915 update_figfile = False
1090 update_figfile = False
916
1091
917 if not self.isConfig:
1092 if not self.isConfig:
918
1093
919 nchan = len(channelIndexList)
1094 nchan = len(channelIndexList)
920 self.nchan = nchan
1095 self.nchan = nchan
921 self.plotFact = 1
1096 self.plotFact = 1
922 nplots = nchan
1097 nplots = nchan
923
1098
924 if showSNR:
1099 if showSNR:
925 nplots = nchan*2
1100 nplots = nchan*2
926 self.plotFact = 2
1101 self.plotFact = 2
927 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
1102 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
928 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
1103 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
929
1104
930 self.setup(id=id,
1105 self.setup(id=id,
931 nplots=nplots,
1106 nplots=nplots,
932 wintitle=wintitle,
1107 wintitle=wintitle,
933 show=show)
1108 show=show)
934
1109
935 if timerange != None:
1110 if timerange != None:
936 self.timerange = timerange
1111 self.timerange = timerange
937
1112
938 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1113 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
939
1114
940 if ymin == None: ymin = numpy.nanmin(y)
1115 if ymin == None: ymin = numpy.nanmin(y)
941 if ymax == None: ymax = numpy.nanmax(y)
1116 if ymax == None: ymax = numpy.nanmax(y)
942 if zmin == None: zmin = numpy.nanmin(z)
1117 if zmin == None: zmin = numpy.nanmin(z)
943 if zmax == None: zmax = numpy.nanmax(z)
1118 if zmax == None: zmax = numpy.nanmax(z)
944
1119
945 self.FTP_WEI = ftp_wei
1120 self.FTP_WEI = ftp_wei
946 self.EXP_CODE = exp_code
1121 self.EXP_CODE = exp_code
947 self.SUB_EXP_CODE = sub_exp_code
1122 self.SUB_EXP_CODE = sub_exp_code
948 self.PLOT_POS = plot_pos
1123 self.PLOT_POS = plot_pos
949
1124
950 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1125 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
951 self.isConfig = True
1126 self.isConfig = True
952 self.figfile = figfile
1127 self.figfile = figfile
953 update_figfile = True
1128 update_figfile = True
954
1129
955 self.setWinTitle(title)
1130 self.setWinTitle(title)
956
1131
957 for i in range(self.nchan):
1132 # for i in range(self.nchan):
958 index = channelIndexList[i]
1133 # index = channelIndexList[i]
959 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1134 # title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
960 axes = self.axesList[i*self.plotFact]
1135 # axes = self.axesList[i*self.plotFact]
961 z1 = z[i,:].reshape((1,-1))
1136 # z1 = z[i,:].reshape((1,-1))
962 axes.pcolorbuffer(x, y, z1,
1137 # axes.pcolorbuffer(x, y, z1,
963 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1138 # xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
964 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1139 # xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
965 ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
1140 # ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
966
1141 #
967 if showSNR:
1142 # if showSNR:
968 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1143 # title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
969 axes = self.axesList[i*self.plotFact + 1]
1144 # axes = self.axesList[i*self.plotFact + 1]
970 SNRdB1 = SNRdB[i,:].reshape((1,-1))
1145 # SNRdB1 = SNRdB[i,:].reshape((1,-1))
971 axes.pcolorbuffer(x, y, SNRdB1,
1146 # axes.pcolorbuffer(x, y, SNRdB1,
972 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1147 # xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
973 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1148 # xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
974 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
1149 # ticksize=9, cblabel='', cbsize="1%",colormap='jet')
1150
1151 i=0
1152 index = channelIndexList[i]
1153 title = "Factor de reflectividad Z [dBZ]"
1154 axes = self.axesList[i*self.plotFact]
1155 z1 = z[i,:].reshape((1,-1))
1156 axes.pcolorbuffer(x, y, z1,
1157 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1158 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1159 ticksize=9, cblabel='', cbsize="1%",colormap=colormap)
1160
1161 if showSNR:
1162 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1163 axes = self.axesList[i*self.plotFact + 1]
1164 SNRdB1 = SNRdB[i,:].reshape((1,-1))
1165 axes.pcolorbuffer(x, y, SNRdB1,
1166 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1167 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1168 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
1169
1170 i=1
1171 index = channelIndexList[i]
1172 title = "Velocidad vertical Doppler [m/s]"
1173 axes = self.axesList[i*self.plotFact]
1174 z1 = z[i,:].reshape((1,-1))
1175 axes.pcolorbuffer(x, y, z1,
1176 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=-10, zmax=10,
1177 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1178 ticksize=9, cblabel='', cbsize="1%",colormap='seismic_r')
1179
1180 if showSNR:
1181 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1182 axes = self.axesList[i*self.plotFact + 1]
1183 SNRdB1 = SNRdB[i,:].reshape((1,-1))
1184 axes.pcolorbuffer(x, y, SNRdB1,
1185 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1186 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1187 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
1188
1189 i=2
1190 index = channelIndexList[i]
1191 title = "Intensidad de lluvia [mm/h]"
1192 axes = self.axesList[i*self.plotFact]
1193 z1 = z[i,:].reshape((1,-1))
1194 axes.pcolorbuffer(x, y, z1,
1195 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=40,
1196 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1197 ticksize=9, cblabel='', cbsize="1%",colormap='ocean_r')
1198
1199 if showSNR:
1200 title = "Channel %d SNR: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1201 axes = self.axesList[i*self.plotFact + 1]
1202 SNRdB1 = SNRdB[i,:].reshape((1,-1))
1203 axes.pcolorbuffer(x, y, SNRdB1,
1204 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1205 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1206 ticksize=9, cblabel='', cbsize="1%",colormap='jet')
975
1207
976
1208
977 self.draw()
1209 self.draw()
978
1210
979 if dataOut.ltctime >= self.xmax:
1211 if dataOut.ltctime >= self.xmax:
980 self.counter_imagwr = wr_period
1212 self.counter_imagwr = wr_period
981 self.isConfig = False
1213 self.isConfig = False
982 update_figfile = True
1214 update_figfile = True
983
1215
984 self.save(figpath=figpath,
1216 self.save(figpath=figpath,
985 figfile=figfile,
1217 figfile=figfile,
986 save=save,
1218 save=save,
987 ftp=ftp,
1219 ftp=ftp,
988 wr_period=wr_period,
1220 wr_period=wr_period,
989 thisDatetime=thisDatetime,
1221 thisDatetime=thisDatetime,
990 update_figfile=update_figfile)
1222 update_figfile=update_figfile)
991
1223
992
1224
993
1225
994 class Parameters1Plot(Figure):
1226 class Parameters1Plot(Figure):
995
1227
996 __isConfig = None
1228 __isConfig = None
997 __nsubplots = None
1229 __nsubplots = None
998
1230
999 WIDTHPROF = None
1231 WIDTHPROF = None
1000 HEIGHTPROF = None
1232 HEIGHTPROF = None
1001 PREFIX = 'prm'
1233 PREFIX = 'prm'
1002
1234
1003 def __init__(self, **kwargs):
1235 def __init__(self, **kwargs):
1004 Figure.__init__(self, **kwargs)
1236 Figure.__init__(self, **kwargs)
1005 self.timerange = 2*60*60
1237 self.timerange = 2*60*60
1006 self.isConfig = False
1238 self.isConfig = False
1007 self.__nsubplots = 1
1239 self.__nsubplots = 1
1008
1240
1009 self.WIDTH = 800
1241 self.WIDTH = 800
1010 self.HEIGHT = 180
1242 self.HEIGHT = 180
1011 self.WIDTHPROF = 120
1243 self.WIDTHPROF = 120
1012 self.HEIGHTPROF = 0
1244 self.HEIGHTPROF = 0
1013 self.counter_imagwr = 0
1245 self.counter_imagwr = 0
1014
1246
1015 self.PLOT_CODE = PARMS_CODE
1247 self.PLOT_CODE = PARMS_CODE
1016
1248
1017 self.FTP_WEI = None
1249 self.FTP_WEI = None
1018 self.EXP_CODE = None
1250 self.EXP_CODE = None
1019 self.SUB_EXP_CODE = None
1251 self.SUB_EXP_CODE = None
1020 self.PLOT_POS = None
1252 self.PLOT_POS = None
1021 self.tmin = None
1253 self.tmin = None
1022 self.tmax = None
1254 self.tmax = None
1023
1255
1024 self.xmin = None
1256 self.xmin = None
1025 self.xmax = None
1257 self.xmax = None
1026
1258
1027 self.figfile = None
1259 self.figfile = None
1028
1260
1029 def getSubplots(self):
1261 def getSubplots(self):
1030
1262
1031 ncol = 1
1263 ncol = 1
1032 nrow = self.nplots
1264 nrow = self.nplots
1033
1265
1034 return nrow, ncol
1266 return nrow, ncol
1035
1267
1036 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1268 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1037
1269
1038 self.__showprofile = showprofile
1270 self.__showprofile = showprofile
1039 self.nplots = nplots
1271 self.nplots = nplots
1040
1272
1041 ncolspan = 1
1273 ncolspan = 1
1042 colspan = 1
1274 colspan = 1
1043
1275
1044 self.createFigure(id = id,
1276 self.createFigure(id = id,
1045 wintitle = wintitle,
1277 wintitle = wintitle,
1046 widthplot = self.WIDTH + self.WIDTHPROF,
1278 widthplot = self.WIDTH + self.WIDTHPROF,
1047 heightplot = self.HEIGHT + self.HEIGHTPROF,
1279 heightplot = self.HEIGHT + self.HEIGHTPROF,
1048 show=show)
1280 show=show)
1049
1281
1050 nrow, ncol = self.getSubplots()
1282 nrow, ncol = self.getSubplots()
1051
1283
1052 counter = 0
1284 counter = 0
1053 for y in range(nrow):
1285 for y in range(nrow):
1054 for x in range(ncol):
1286 for x in range(ncol):
1055
1287
1056 if counter >= self.nplots:
1288 if counter >= self.nplots:
1057 break
1289 break
1058
1290
1059 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1291 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1060
1292
1061 if showprofile:
1293 if showprofile:
1062 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1294 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1063
1295
1064 counter += 1
1296 counter += 1
1065
1297
1066 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
1298 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=False,
1067 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
1299 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,timerange=None,
1068 parameterIndex = None, onlyPositive = False,
1300 parameterIndex = None, onlyPositive = False,
1069 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
1301 SNRthresh = -numpy.inf, SNR = True, SNRmin = None, SNRmax = None, onlySNR = False,
1070 DOP = True,
1302 DOP = True,
1071 zlabel = "", parameterName = "", parameterObject = "data_param",
1303 zlabel = "", parameterName = "", parameterObject = "data_param",
1072 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1304 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1073 server=None, folder=None, username=None, password=None,
1305 server=None, folder=None, username=None, password=None,
1074 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1306 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1075 #print inspect.getargspec(self.run).args
1307 #print inspect.getargspec(self.run).args
1076 """
1308 """
1077
1309
1078 Input:
1310 Input:
1079 dataOut :
1311 dataOut :
1080 id :
1312 id :
1081 wintitle :
1313 wintitle :
1082 channelList :
1314 channelList :
1083 showProfile :
1315 showProfile :
1084 xmin : None,
1316 xmin : None,
1085 xmax : None,
1317 xmax : None,
1086 ymin : None,
1318 ymin : None,
1087 ymax : None,
1319 ymax : None,
1088 zmin : None,
1320 zmin : None,
1089 zmax : None
1321 zmax : None
1090 """
1322 """
1091
1323
1092 data_param = getattr(dataOut, parameterObject)
1324 data_param = getattr(dataOut, parameterObject)
1093
1325
1094 if channelList == None:
1326 if channelList == None:
1095 channelIndexList = numpy.arange(data_param.shape[0])
1327 channelIndexList = numpy.arange(data_param.shape[0])
1096 else:
1328 else:
1097 channelIndexList = numpy.array(channelList)
1329 channelIndexList = numpy.array(channelList)
1098
1330
1099 nchan = len(channelIndexList) #Number of channels being plotted
1331 nchan = len(channelIndexList) #Number of channels being plotted
1100
1332
1101 if nchan < 1:
1333 if nchan < 1:
1102 return
1334 return
1103
1335
1104 nGraphsByChannel = 0
1336 nGraphsByChannel = 0
1105
1337
1106 if SNR:
1338 if SNR:
1107 nGraphsByChannel += 1
1339 nGraphsByChannel += 1
1108 if DOP:
1340 if DOP:
1109 nGraphsByChannel += 1
1341 nGraphsByChannel += 1
1110
1342
1111 if nGraphsByChannel < 1:
1343 if nGraphsByChannel < 1:
1112 return
1344 return
1113
1345
1114 nplots = nGraphsByChannel*nchan
1346 nplots = nGraphsByChannel*nchan
1115
1347
1116 if timerange is not None:
1348 if timerange is not None:
1117 self.timerange = timerange
1349 self.timerange = timerange
1118
1350
1119 #tmin = None
1351 #tmin = None
1120 #tmax = None
1352 #tmax = None
1121 if parameterIndex == None:
1353 if parameterIndex == None:
1122 parameterIndex = 1
1354 parameterIndex = 1
1123
1355
1124 x = dataOut.getTimeRange1(dataOut.paramInterval)
1356 x = dataOut.getTimeRange1(dataOut.paramInterval)
1125 y = dataOut.heightList
1357 y = dataOut.heightList
1126 z = data_param[channelIndexList,parameterIndex,:].copy()
1358 z = data_param[channelIndexList,parameterIndex,:].copy()
1127
1359
1128 zRange = dataOut.abscissaList
1360 zRange = dataOut.abscissaList
1129 # nChannels = z.shape[0] #Number of wind dimensions estimated
1361 # nChannels = z.shape[0] #Number of wind dimensions estimated
1130 # thisDatetime = dataOut.datatime
1362 # thisDatetime = dataOut.datatime
1131
1363
1132 if dataOut.data_SNR is not None:
1364 if dataOut.data_SNR is not None:
1133 SNRarray = dataOut.data_SNR[channelIndexList,:]
1365 SNRarray = dataOut.data_SNR[channelIndexList,:]
1134 SNRdB = 10*numpy.log10(SNRarray)
1366 SNRdB = 10*numpy.log10(SNRarray)
1135 # SNRavgdB = 10*numpy.log10(SNRavg)
1367 # SNRavgdB = 10*numpy.log10(SNRavg)
1136 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
1368 ind = numpy.where(SNRdB < 10**(SNRthresh/10))
1137 z[ind] = numpy.nan
1369 z[ind] = numpy.nan
1138
1370
1139 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1371 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1140 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
1372 title = wintitle + " Parameters Plot" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
1141 xlabel = ""
1373 xlabel = ""
1142 ylabel = "Range (Km)"
1374 ylabel = "Range (Km)"
1143
1375
1144 if (SNR and not onlySNR): nplots = 2*nplots
1376 if (SNR and not onlySNR): nplots = 2*nplots
1145
1377
1146 if onlyPositive:
1378 if onlyPositive:
1147 colormap = "jet"
1379 colormap = "jet"
1148 zmin = 0
1380 zmin = 0
1149 else: colormap = "RdBu_r"
1381 else: colormap = "RdBu_r"
1150
1382
1151 if not self.isConfig:
1383 if not self.isConfig:
1152
1384
1153 self.setup(id=id,
1385 self.setup(id=id,
1154 nplots=nplots,
1386 nplots=nplots,
1155 wintitle=wintitle,
1387 wintitle=wintitle,
1156 showprofile=showprofile,
1388 showprofile=showprofile,
1157 show=show)
1389 show=show)
1158
1390
1159 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1391 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1160
1392
1161 if ymin == None: ymin = numpy.nanmin(y)
1393 if ymin == None: ymin = numpy.nanmin(y)
1162 if ymax == None: ymax = numpy.nanmax(y)
1394 if ymax == None: ymax = numpy.nanmax(y)
1163 if zmin == None: zmin = numpy.nanmin(zRange)
1395 if zmin == None: zmin = numpy.nanmin(zRange)
1164 if zmax == None: zmax = numpy.nanmax(zRange)
1396 if zmax == None: zmax = numpy.nanmax(zRange)
1165
1397
1166 if SNR:
1398 if SNR:
1167 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
1399 if SNRmin == None: SNRmin = numpy.nanmin(SNRdB)
1168 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
1400 if SNRmax == None: SNRmax = numpy.nanmax(SNRdB)
1169
1401
1170 self.FTP_WEI = ftp_wei
1402 self.FTP_WEI = ftp_wei
1171 self.EXP_CODE = exp_code
1403 self.EXP_CODE = exp_code
1172 self.SUB_EXP_CODE = sub_exp_code
1404 self.SUB_EXP_CODE = sub_exp_code
1173 self.PLOT_POS = plot_pos
1405 self.PLOT_POS = plot_pos
1174
1406
1175 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1407 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1176 self.isConfig = True
1408 self.isConfig = True
1177 self.figfile = figfile
1409 self.figfile = figfile
1178
1410
1179 self.setWinTitle(title)
1411 self.setWinTitle(title)
1180
1412
1181 if ((self.xmax - x[1]) < (x[1]-x[0])):
1413 if ((self.xmax - x[1]) < (x[1]-x[0])):
1182 x[1] = self.xmax
1414 x[1] = self.xmax
1183
1415
1184 for i in range(nchan):
1416 for i in range(nchan):
1185
1417
1186 if (SNR and not onlySNR): j = 2*i
1418 if (SNR and not onlySNR): j = 2*i
1187 else: j = i
1419 else: j = i
1188
1420
1189 j = nGraphsByChannel*i
1421 j = nGraphsByChannel*i
1190
1422
1191 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1423 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1192 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
1424 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
1193
1425
1194 if not onlySNR:
1426 if not onlySNR:
1195 axes = self.axesList[j*self.__nsubplots]
1427 axes = self.axesList[j*self.__nsubplots]
1196 z1 = z[i,:].reshape((1,-1))
1428 z1 = z[i,:].reshape((1,-1))
1197 axes.pcolorbuffer(x, y, z1,
1429 axes.pcolorbuffer(x, y, z1,
1198 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1430 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1199 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
1431 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
1200 ticksize=9, cblabel=zlabel, cbsize="1%")
1432 ticksize=9, cblabel=zlabel, cbsize="1%")
1201
1433
1202 if DOP:
1434 if DOP:
1203 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1435 title = "%s Channel %d: %s" %(parameterName, channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1204
1436
1205 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1437 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1206 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
1438 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
1207 axes = self.axesList[j]
1439 axes = self.axesList[j]
1208 z1 = z[i,:].reshape((1,-1))
1440 z1 = z[i,:].reshape((1,-1))
1209 axes.pcolorbuffer(x, y, z1,
1441 axes.pcolorbuffer(x, y, z1,
1210 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1442 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
1211 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
1443 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap=colormap,
1212 ticksize=9, cblabel=zlabel, cbsize="1%")
1444 ticksize=9, cblabel=zlabel, cbsize="1%")
1213
1445
1214 if SNR:
1446 if SNR:
1215 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1447 title = "Channel %d Signal Noise Ratio (SNR): %s" %(channelIndexList[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1216 axes = self.axesList[(j)*self.__nsubplots]
1448 axes = self.axesList[(j)*self.__nsubplots]
1217 if not onlySNR:
1449 if not onlySNR:
1218 axes = self.axesList[(j + 1)*self.__nsubplots]
1450 axes = self.axesList[(j + 1)*self.__nsubplots]
1219
1451
1220 axes = self.axesList[(j + nGraphsByChannel-1)]
1452 axes = self.axesList[(j + nGraphsByChannel-1)]
1221
1453
1222 z1 = SNRdB[i,:].reshape((1,-1))
1454 z1 = SNRdB[i,:].reshape((1,-1))
1223 axes.pcolorbuffer(x, y, z1,
1455 axes.pcolorbuffer(x, y, z1,
1224 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1456 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1225 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
1457 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,colormap="jet",
1226 ticksize=9, cblabel=zlabel, cbsize="1%")
1458 ticksize=9, cblabel=zlabel, cbsize="1%")
1227
1459
1228
1460
1229
1461
1230 self.draw()
1462 self.draw()
1231
1463
1232 if x[1] >= self.axesList[0].xmax:
1464 if x[1] >= self.axesList[0].xmax:
1233 self.counter_imagwr = wr_period
1465 self.counter_imagwr = wr_period
1234 self.isConfig = False
1466 self.isConfig = False
1235 self.figfile = None
1467 self.figfile = None
1236
1468
1237 self.save(figpath=figpath,
1469 self.save(figpath=figpath,
1238 figfile=figfile,
1470 figfile=figfile,
1239 save=save,
1471 save=save,
1240 ftp=ftp,
1472 ftp=ftp,
1241 wr_period=wr_period,
1473 wr_period=wr_period,
1242 thisDatetime=thisDatetime,
1474 thisDatetime=thisDatetime,
1243 update_figfile=False)
1475 update_figfile=False)
1244
1476
1245 class SpectralFittingPlot(Figure):
1477 class SpectralFittingPlot(Figure):
1246
1478
1247 __isConfig = None
1479 __isConfig = None
1248 __nsubplots = None
1480 __nsubplots = None
1249
1481
1250 WIDTHPROF = None
1482 WIDTHPROF = None
1251 HEIGHTPROF = None
1483 HEIGHTPROF = None
1252 PREFIX = 'prm'
1484 PREFIX = 'prm'
1253
1485
1254
1486
1255 N = None
1487 N = None
1256 ippSeconds = None
1488 ippSeconds = None
1257
1489
1258 def __init__(self, **kwargs):
1490 def __init__(self, **kwargs):
1259 Figure.__init__(self, **kwargs)
1491 Figure.__init__(self, **kwargs)
1260 self.isConfig = False
1492 self.isConfig = False
1261 self.__nsubplots = 1
1493 self.__nsubplots = 1
1262
1494
1263 self.PLOT_CODE = SPECFIT_CODE
1495 self.PLOT_CODE = SPECFIT_CODE
1264
1496
1265 self.WIDTH = 450
1497 self.WIDTH = 450
1266 self.HEIGHT = 250
1498 self.HEIGHT = 250
1267 self.WIDTHPROF = 0
1499 self.WIDTHPROF = 0
1268 self.HEIGHTPROF = 0
1500 self.HEIGHTPROF = 0
1269
1501
1270 def getSubplots(self):
1502 def getSubplots(self):
1271
1503
1272 ncol = int(numpy.sqrt(self.nplots)+0.9)
1504 ncol = int(numpy.sqrt(self.nplots)+0.9)
1273 nrow = int(self.nplots*1./ncol + 0.9)
1505 nrow = int(self.nplots*1./ncol + 0.9)
1274
1506
1275 return nrow, ncol
1507 return nrow, ncol
1276
1508
1277 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
1509 def setup(self, id, nplots, wintitle, showprofile=False, show=True):
1278
1510
1279 showprofile = False
1511 showprofile = False
1280 self.__showprofile = showprofile
1512 self.__showprofile = showprofile
1281 self.nplots = nplots
1513 self.nplots = nplots
1282
1514
1283 ncolspan = 5
1515 ncolspan = 5
1284 colspan = 4
1516 colspan = 4
1285 if showprofile:
1517 if showprofile:
1286 ncolspan = 5
1518 ncolspan = 5
1287 colspan = 4
1519 colspan = 4
1288 self.__nsubplots = 2
1520 self.__nsubplots = 2
1289
1521
1290 self.createFigure(id = id,
1522 self.createFigure(id = id,
1291 wintitle = wintitle,
1523 wintitle = wintitle,
1292 widthplot = self.WIDTH + self.WIDTHPROF,
1524 widthplot = self.WIDTH + self.WIDTHPROF,
1293 heightplot = self.HEIGHT + self.HEIGHTPROF,
1525 heightplot = self.HEIGHT + self.HEIGHTPROF,
1294 show=show)
1526 show=show)
1295
1527
1296 nrow, ncol = self.getSubplots()
1528 nrow, ncol = self.getSubplots()
1297
1529
1298 counter = 0
1530 counter = 0
1299 for y in range(nrow):
1531 for y in range(nrow):
1300 for x in range(ncol):
1532 for x in range(ncol):
1301
1533
1302 if counter >= self.nplots:
1534 if counter >= self.nplots:
1303 break
1535 break
1304
1536
1305 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1537 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1306
1538
1307 if showprofile:
1539 if showprofile:
1308 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1540 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
1309
1541
1310 counter += 1
1542 counter += 1
1311
1543
1312 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
1544 def run(self, dataOut, id, cutHeight=None, fit=False, wintitle="", channelList=None, showprofile=True,
1313 xmin=None, xmax=None, ymin=None, ymax=None,
1545 xmin=None, xmax=None, ymin=None, ymax=None,
1314 save=False, figpath='./', figfile=None, show=True):
1546 save=False, figpath='./', figfile=None, show=True):
1315
1547
1316 """
1548 """
1317
1549
1318 Input:
1550 Input:
1319 dataOut :
1551 dataOut :
1320 id :
1552 id :
1321 wintitle :
1553 wintitle :
1322 channelList :
1554 channelList :
1323 showProfile :
1555 showProfile :
1324 xmin : None,
1556 xmin : None,
1325 xmax : None,
1557 xmax : None,
1326 zmin : None,
1558 zmin : None,
1327 zmax : None
1559 zmax : None
1328 """
1560 """
1329
1561
1330 if cutHeight==None:
1562 if cutHeight==None:
1331 h=270
1563 h=270
1332 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
1564 heightindex = numpy.abs(cutHeight - dataOut.heightList).argmin()
1333 cutHeight = dataOut.heightList[heightindex]
1565 cutHeight = dataOut.heightList[heightindex]
1334
1566
1335 factor = dataOut.normFactor
1567 factor = dataOut.normFactor
1336 x = dataOut.abscissaList[:-1]
1568 x = dataOut.abscissaList[:-1]
1337 #y = dataOut.getHeiRange()
1569 #y = dataOut.getHeiRange()
1338
1570
1339 z = dataOut.data_pre[:,:,heightindex]/factor
1571 z = dataOut.data_pre[:,:,heightindex]/factor
1340 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1572 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1341 avg = numpy.average(z, axis=1)
1573 avg = numpy.average(z, axis=1)
1342 listChannels = z.shape[0]
1574 listChannels = z.shape[0]
1343
1575
1344 #Reconstruct Function
1576 #Reconstruct Function
1345 if fit==True:
1577 if fit==True:
1346 groupArray = dataOut.groupList
1578 groupArray = dataOut.groupList
1347 listChannels = groupArray.reshape((groupArray.size))
1579 listChannels = groupArray.reshape((groupArray.size))
1348 listChannels.sort()
1580 listChannels.sort()
1349 spcFitLine = numpy.zeros(z.shape)
1581 spcFitLine = numpy.zeros(z.shape)
1350 constants = dataOut.constants
1582 constants = dataOut.constants
1351
1583
1352 nGroups = groupArray.shape[0]
1584 nGroups = groupArray.shape[0]
1353 nChannels = groupArray.shape[1]
1585 nChannels = groupArray.shape[1]
1354 nProfiles = z.shape[1]
1586 nProfiles = z.shape[1]
1355
1587
1356 for f in range(nGroups):
1588 for f in range(nGroups):
1357 groupChann = groupArray[f,:]
1589 groupChann = groupArray[f,:]
1358 p = dataOut.data_param[f,:,heightindex]
1590 p = dataOut.data_param[f,:,heightindex]
1359 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
1591 # p = numpy.array([ 89.343967,0.14036615,0.17086219,18.89835291,1.58388365,1.55099167])
1360 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
1592 fitLineAux = dataOut.library.modelFunction(p, constants)*nProfiles
1361 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
1593 fitLineAux = fitLineAux.reshape((nChannels,nProfiles))
1362 spcFitLine[groupChann,:] = fitLineAux
1594 spcFitLine[groupChann,:] = fitLineAux
1363 # spcFitLine = spcFitLine/factor
1595 # spcFitLine = spcFitLine/factor
1364
1596
1365 z = z[listChannels,:]
1597 z = z[listChannels,:]
1366 spcFitLine = spcFitLine[listChannels,:]
1598 spcFitLine = spcFitLine[listChannels,:]
1367 spcFitLinedB = 10*numpy.log10(spcFitLine)
1599 spcFitLinedB = 10*numpy.log10(spcFitLine)
1368
1600
1369 zdB = 10*numpy.log10(z)
1601 zdB = 10*numpy.log10(z)
1370 #thisDatetime = dataOut.datatime
1602 #thisDatetime = dataOut.datatime
1371 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1603 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1372 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1604 title = wintitle + " Doppler Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1373 xlabel = "Velocity (m/s)"
1605 xlabel = "Velocity (m/s)"
1374 ylabel = "Spectrum"
1606 ylabel = "Spectrum"
1375
1607
1376 if not self.isConfig:
1608 if not self.isConfig:
1377
1609
1378 nplots = listChannels.size
1610 nplots = listChannels.size
1379
1611
1380 self.setup(id=id,
1612 self.setup(id=id,
1381 nplots=nplots,
1613 nplots=nplots,
1382 wintitle=wintitle,
1614 wintitle=wintitle,
1383 showprofile=showprofile,
1615 showprofile=showprofile,
1384 show=show)
1616 show=show)
1385
1617
1386 if xmin == None: xmin = numpy.nanmin(x)
1618 if xmin == None: xmin = numpy.nanmin(x)
1387 if xmax == None: xmax = numpy.nanmax(x)
1619 if xmax == None: xmax = numpy.nanmax(x)
1388 if ymin == None: ymin = numpy.nanmin(zdB)
1620 if ymin == None: ymin = numpy.nanmin(zdB)
1389 if ymax == None: ymax = numpy.nanmax(zdB)+2
1621 if ymax == None: ymax = numpy.nanmax(zdB)+2
1390
1622
1391 self.isConfig = True
1623 self.isConfig = True
1392
1624
1393 self.setWinTitle(title)
1625 self.setWinTitle(title)
1394 for i in range(self.nplots):
1626 for i in range(self.nplots):
1395 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
1627 # title = "Channel %d: %4.2fdB" %(dataOut.channelList[i]+1, noisedB[i])
1396 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
1628 title = "Height %4.1f km\nChannel %d:" %(cutHeight, listChannels[i])
1397 axes = self.axesList[i*self.__nsubplots]
1629 axes = self.axesList[i*self.__nsubplots]
1398 if fit == False:
1630 if fit == False:
1399 axes.pline(x, zdB[i,:],
1631 axes.pline(x, zdB[i,:],
1400 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1632 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1401 xlabel=xlabel, ylabel=ylabel, title=title
1633 xlabel=xlabel, ylabel=ylabel, title=title
1402 )
1634 )
1403 if fit == True:
1635 if fit == True:
1404 fitline=spcFitLinedB[i,:]
1636 fitline=spcFitLinedB[i,:]
1405 y=numpy.vstack([zdB[i,:],fitline] )
1637 y=numpy.vstack([zdB[i,:],fitline] )
1406 legendlabels=['Data','Fitting']
1638 legendlabels=['Data','Fitting']
1407 axes.pmultilineyaxis(x, y,
1639 axes.pmultilineyaxis(x, y,
1408 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1640 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1409 xlabel=xlabel, ylabel=ylabel, title=title,
1641 xlabel=xlabel, ylabel=ylabel, title=title,
1410 legendlabels=legendlabels, marker=None,
1642 legendlabels=legendlabels, marker=None,
1411 linestyle='solid', grid='both')
1643 linestyle='solid', grid='both')
1412
1644
1413 self.draw()
1645 self.draw()
1414
1646
1415 self.save(figpath=figpath,
1647 self.save(figpath=figpath,
1416 figfile=figfile,
1648 figfile=figfile,
1417 save=save,
1649 save=save,
1418 ftp=ftp,
1650 ftp=ftp,
1419 wr_period=wr_period,
1651 wr_period=wr_period,
1420 thisDatetime=thisDatetime)
1652 thisDatetime=thisDatetime)
1421
1653
1422
1654
1423 class EWDriftsPlot(Figure):
1655 class EWDriftsPlot(Figure):
1424
1656
1425 __isConfig = None
1657 __isConfig = None
1426 __nsubplots = None
1658 __nsubplots = None
1427
1659
1428 WIDTHPROF = None
1660 WIDTHPROF = None
1429 HEIGHTPROF = None
1661 HEIGHTPROF = None
1430 PREFIX = 'drift'
1662 PREFIX = 'drift'
1431
1663
1432 def __init__(self, **kwargs):
1664 def __init__(self, **kwargs):
1433 Figure.__init__(self, **kwargs)
1665 Figure.__init__(self, **kwargs)
1434 self.timerange = 2*60*60
1666 self.timerange = 2*60*60
1435 self.isConfig = False
1667 self.isConfig = False
1436 self.__nsubplots = 1
1668 self.__nsubplots = 1
1437
1669
1438 self.WIDTH = 800
1670 self.WIDTH = 800
1439 self.HEIGHT = 150
1671 self.HEIGHT = 150
1440 self.WIDTHPROF = 120
1672 self.WIDTHPROF = 120
1441 self.HEIGHTPROF = 0
1673 self.HEIGHTPROF = 0
1442 self.counter_imagwr = 0
1674 self.counter_imagwr = 0
1443
1675
1444 self.PLOT_CODE = EWDRIFT_CODE
1676 self.PLOT_CODE = EWDRIFT_CODE
1445
1677
1446 self.FTP_WEI = None
1678 self.FTP_WEI = None
1447 self.EXP_CODE = None
1679 self.EXP_CODE = None
1448 self.SUB_EXP_CODE = None
1680 self.SUB_EXP_CODE = None
1449 self.PLOT_POS = None
1681 self.PLOT_POS = None
1450 self.tmin = None
1682 self.tmin = None
1451 self.tmax = None
1683 self.tmax = None
1452
1684
1453 self.xmin = None
1685 self.xmin = None
1454 self.xmax = None
1686 self.xmax = None
1455
1687
1456 self.figfile = None
1688 self.figfile = None
1457
1689
1458 def getSubplots(self):
1690 def getSubplots(self):
1459
1691
1460 ncol = 1
1692 ncol = 1
1461 nrow = self.nplots
1693 nrow = self.nplots
1462
1694
1463 return nrow, ncol
1695 return nrow, ncol
1464
1696
1465 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1697 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1466
1698
1467 self.__showprofile = showprofile
1699 self.__showprofile = showprofile
1468 self.nplots = nplots
1700 self.nplots = nplots
1469
1701
1470 ncolspan = 1
1702 ncolspan = 1
1471 colspan = 1
1703 colspan = 1
1472
1704
1473 self.createFigure(id = id,
1705 self.createFigure(id = id,
1474 wintitle = wintitle,
1706 wintitle = wintitle,
1475 widthplot = self.WIDTH + self.WIDTHPROF,
1707 widthplot = self.WIDTH + self.WIDTHPROF,
1476 heightplot = self.HEIGHT + self.HEIGHTPROF,
1708 heightplot = self.HEIGHT + self.HEIGHTPROF,
1477 show=show)
1709 show=show)
1478
1710
1479 nrow, ncol = self.getSubplots()
1711 nrow, ncol = self.getSubplots()
1480
1712
1481 counter = 0
1713 counter = 0
1482 for y in range(nrow):
1714 for y in range(nrow):
1483 if counter >= self.nplots:
1715 if counter >= self.nplots:
1484 break
1716 break
1485
1717
1486 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1718 self.addAxes(nrow, ncol*ncolspan, y, 0, colspan, 1)
1487 counter += 1
1719 counter += 1
1488
1720
1489 def run(self, dataOut, id, wintitle="", channelList=None,
1721 def run(self, dataOut, id, wintitle="", channelList=None,
1490 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1722 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
1491 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1723 zmaxVertical = None, zminVertical = None, zmaxZonal = None, zminZonal = None,
1492 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1724 timerange=None, SNRthresh = -numpy.inf, SNRmin = None, SNRmax = None, SNR_1 = False,
1493 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1725 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
1494 server=None, folder=None, username=None, password=None,
1726 server=None, folder=None, username=None, password=None,
1495 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1727 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1496 """
1728 """
1497
1729
1498 Input:
1730 Input:
1499 dataOut :
1731 dataOut :
1500 id :
1732 id :
1501 wintitle :
1733 wintitle :
1502 channelList :
1734 channelList :
1503 showProfile :
1735 showProfile :
1504 xmin : None,
1736 xmin : None,
1505 xmax : None,
1737 xmax : None,
1506 ymin : None,
1738 ymin : None,
1507 ymax : None,
1739 ymax : None,
1508 zmin : None,
1740 zmin : None,
1509 zmax : None
1741 zmax : None
1510 """
1742 """
1511
1743
1512 if timerange is not None:
1744 if timerange is not None:
1513 self.timerange = timerange
1745 self.timerange = timerange
1514
1746
1515 tmin = None
1747 tmin = None
1516 tmax = None
1748 tmax = None
1517
1749
1518 x = dataOut.getTimeRange1(dataOut.outputInterval)
1750 x = dataOut.getTimeRange1(dataOut.outputInterval)
1519 # y = dataOut.heightList
1751 # y = dataOut.heightList
1520 y = dataOut.heightList
1752 y = dataOut.heightList
1521
1753
1522 z = dataOut.data_output
1754 z = dataOut.data_output
1523 nplots = z.shape[0] #Number of wind dimensions estimated
1755 nplots = z.shape[0] #Number of wind dimensions estimated
1524 nplotsw = nplots
1756 nplotsw = nplots
1525
1757
1526 #If there is a SNR function defined
1758 #If there is a SNR function defined
1527 if dataOut.data_SNR is not None:
1759 if dataOut.data_SNR is not None:
1528 nplots += 1
1760 nplots += 1
1529 SNR = dataOut.data_SNR
1761 SNR = dataOut.data_SNR
1530
1762
1531 if SNR_1:
1763 if SNR_1:
1532 SNR += 1
1764 SNR += 1
1533
1765
1534 SNRavg = numpy.average(SNR, axis=0)
1766 SNRavg = numpy.average(SNR, axis=0)
1535
1767
1536 SNRdB = 10*numpy.log10(SNR)
1768 SNRdB = 10*numpy.log10(SNR)
1537 SNRavgdB = 10*numpy.log10(SNRavg)
1769 SNRavgdB = 10*numpy.log10(SNRavg)
1538
1770
1539 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1771 ind = numpy.where(SNRavg < 10**(SNRthresh/10))[0]
1540
1772
1541 for i in range(nplotsw):
1773 for i in range(nplotsw):
1542 z[i,ind] = numpy.nan
1774 z[i,ind] = numpy.nan
1543
1775
1544
1776
1545 showprofile = False
1777 showprofile = False
1546 # thisDatetime = dataOut.datatime
1778 # thisDatetime = dataOut.datatime
1547 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1779 thisDatetime = datetime.datetime.utcfromtimestamp(x[1])
1548 title = wintitle + " EW Drifts"
1780 title = wintitle + " EW Drifts"
1549 xlabel = ""
1781 xlabel = ""
1550 ylabel = "Height (Km)"
1782 ylabel = "Height (Km)"
1551
1783
1552 if not self.isConfig:
1784 if not self.isConfig:
1553
1785
1554 self.setup(id=id,
1786 self.setup(id=id,
1555 nplots=nplots,
1787 nplots=nplots,
1556 wintitle=wintitle,
1788 wintitle=wintitle,
1557 showprofile=showprofile,
1789 showprofile=showprofile,
1558 show=show)
1790 show=show)
1559
1791
1560 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1792 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1561
1793
1562 if ymin == None: ymin = numpy.nanmin(y)
1794 if ymin == None: ymin = numpy.nanmin(y)
1563 if ymax == None: ymax = numpy.nanmax(y)
1795 if ymax == None: ymax = numpy.nanmax(y)
1564
1796
1565 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1797 if zmaxZonal == None: zmaxZonal = numpy.nanmax(abs(z[0,:]))
1566 if zminZonal == None: zminZonal = -zmaxZonal
1798 if zminZonal == None: zminZonal = -zmaxZonal
1567 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1799 if zmaxVertical == None: zmaxVertical = numpy.nanmax(abs(z[1,:]))
1568 if zminVertical == None: zminVertical = -zmaxVertical
1800 if zminVertical == None: zminVertical = -zmaxVertical
1569
1801
1570 if dataOut.data_SNR is not None:
1802 if dataOut.data_SNR is not None:
1571 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1803 if SNRmin == None: SNRmin = numpy.nanmin(SNRavgdB)
1572 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1804 if SNRmax == None: SNRmax = numpy.nanmax(SNRavgdB)
1573
1805
1574 self.FTP_WEI = ftp_wei
1806 self.FTP_WEI = ftp_wei
1575 self.EXP_CODE = exp_code
1807 self.EXP_CODE = exp_code
1576 self.SUB_EXP_CODE = sub_exp_code
1808 self.SUB_EXP_CODE = sub_exp_code
1577 self.PLOT_POS = plot_pos
1809 self.PLOT_POS = plot_pos
1578
1810
1579 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1811 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1580 self.isConfig = True
1812 self.isConfig = True
1581
1813
1582
1814
1583 self.setWinTitle(title)
1815 self.setWinTitle(title)
1584
1816
1585 if ((self.xmax - x[1]) < (x[1]-x[0])):
1817 if ((self.xmax - x[1]) < (x[1]-x[0])):
1586 x[1] = self.xmax
1818 x[1] = self.xmax
1587
1819
1588 strWind = ['Zonal','Vertical']
1820 strWind = ['Zonal','Vertical']
1589 strCb = 'Velocity (m/s)'
1821 strCb = 'Velocity (m/s)'
1590 zmaxVector = [zmaxZonal, zmaxVertical]
1822 zmaxVector = [zmaxZonal, zmaxVertical]
1591 zminVector = [zminZonal, zminVertical]
1823 zminVector = [zminZonal, zminVertical]
1592
1824
1593 for i in range(nplotsw):
1825 for i in range(nplotsw):
1594
1826
1595 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1827 title = "%s Drifts: %s" %(strWind[i], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1596 axes = self.axesList[i*self.__nsubplots]
1828 axes = self.axesList[i*self.__nsubplots]
1597
1829
1598 z1 = z[i,:].reshape((1,-1))
1830 z1 = z[i,:].reshape((1,-1))
1599
1831
1600 axes.pcolorbuffer(x, y, z1,
1832 axes.pcolorbuffer(x, y, z1,
1601 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1833 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zminVector[i], zmax=zmaxVector[i],
1602 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1834 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1603 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1835 ticksize=9, cblabel=strCb, cbsize="1%", colormap="RdBu_r")
1604
1836
1605 if dataOut.data_SNR is not None:
1837 if dataOut.data_SNR is not None:
1606 i += 1
1838 i += 1
1607 if SNR_1:
1839 if SNR_1:
1608 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1840 title = "Signal Noise Ratio + 1 (SNR+1): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1609 else:
1841 else:
1610 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1842 title = "Signal Noise Ratio (SNR): %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1611 axes = self.axesList[i*self.__nsubplots]
1843 axes = self.axesList[i*self.__nsubplots]
1612 SNRavgdB = SNRavgdB.reshape((1,-1))
1844 SNRavgdB = SNRavgdB.reshape((1,-1))
1613
1845
1614 axes.pcolorbuffer(x, y, SNRavgdB,
1846 axes.pcolorbuffer(x, y, SNRavgdB,
1615 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1847 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=SNRmin, zmax=SNRmax,
1616 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1848 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
1617 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1849 ticksize=9, cblabel='', cbsize="1%", colormap="jet")
1618
1850
1619 self.draw()
1851 self.draw()
1620
1852
1621 if x[1] >= self.axesList[0].xmax:
1853 if x[1] >= self.axesList[0].xmax:
1622 self.counter_imagwr = wr_period
1854 self.counter_imagwr = wr_period
1623 self.isConfig = False
1855 self.isConfig = False
1624 self.figfile = None
1856 self.figfile = None
1625
1857
1626
1858
1627
1859
1628
1860
1629 class PhasePlot(Figure):
1861 class PhasePlot(Figure):
1630
1862
1631 __isConfig = None
1863 __isConfig = None
1632 __nsubplots = None
1864 __nsubplots = None
1633
1865
1634 PREFIX = 'mphase'
1866 PREFIX = 'mphase'
1635
1867
1636 def __init__(self, **kwargs):
1868 def __init__(self, **kwargs):
1637 Figure.__init__(self, **kwargs)
1869 Figure.__init__(self, **kwargs)
1638 self.timerange = 24*60*60
1870 self.timerange = 24*60*60
1639 self.isConfig = False
1871 self.isConfig = False
1640 self.__nsubplots = 1
1872 self.__nsubplots = 1
1641 self.counter_imagwr = 0
1873 self.counter_imagwr = 0
1642 self.WIDTH = 600
1874 self.WIDTH = 600
1643 self.HEIGHT = 300
1875 self.HEIGHT = 300
1644 self.WIDTHPROF = 120
1876 self.WIDTHPROF = 120
1645 self.HEIGHTPROF = 0
1877 self.HEIGHTPROF = 0
1646 self.xdata = None
1878 self.xdata = None
1647 self.ydata = None
1879 self.ydata = None
1648
1880
1649 self.PLOT_CODE = MPHASE_CODE
1881 self.PLOT_CODE = MPHASE_CODE
1650
1882
1651 self.FTP_WEI = None
1883 self.FTP_WEI = None
1652 self.EXP_CODE = None
1884 self.EXP_CODE = None
1653 self.SUB_EXP_CODE = None
1885 self.SUB_EXP_CODE = None
1654 self.PLOT_POS = None
1886 self.PLOT_POS = None
1655
1887
1656
1888
1657 self.filename_phase = None
1889 self.filename_phase = None
1658
1890
1659 self.figfile = None
1891 self.figfile = None
1660
1892
1661 def getSubplots(self):
1893 def getSubplots(self):
1662
1894
1663 ncol = 1
1895 ncol = 1
1664 nrow = 1
1896 nrow = 1
1665
1897
1666 return nrow, ncol
1898 return nrow, ncol
1667
1899
1668 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1900 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1669
1901
1670 self.__showprofile = showprofile
1902 self.__showprofile = showprofile
1671 self.nplots = nplots
1903 self.nplots = nplots
1672
1904
1673 ncolspan = 7
1905 ncolspan = 7
1674 colspan = 6
1906 colspan = 6
1675 self.__nsubplots = 2
1907 self.__nsubplots = 2
1676
1908
1677 self.createFigure(id = id,
1909 self.createFigure(id = id,
1678 wintitle = wintitle,
1910 wintitle = wintitle,
1679 widthplot = self.WIDTH+self.WIDTHPROF,
1911 widthplot = self.WIDTH+self.WIDTHPROF,
1680 heightplot = self.HEIGHT+self.HEIGHTPROF,
1912 heightplot = self.HEIGHT+self.HEIGHTPROF,
1681 show=show)
1913 show=show)
1682
1914
1683 nrow, ncol = self.getSubplots()
1915 nrow, ncol = self.getSubplots()
1684
1916
1685 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1917 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1686
1918
1687
1919
1688 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1920 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1689 xmin=None, xmax=None, ymin=None, ymax=None,
1921 xmin=None, xmax=None, ymin=None, ymax=None,
1690 timerange=None,
1922 timerange=None,
1691 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1923 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1692 server=None, folder=None, username=None, password=None,
1924 server=None, folder=None, username=None, password=None,
1693 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1925 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1694
1926
1695
1927
1696 tmin = None
1928 tmin = None
1697 tmax = None
1929 tmax = None
1698 x = dataOut.getTimeRange1(dataOut.outputInterval)
1930 x = dataOut.getTimeRange1(dataOut.outputInterval)
1699 y = dataOut.getHeiRange()
1931 y = dataOut.getHeiRange()
1700
1932
1701
1933
1702 #thisDatetime = dataOut.datatime
1934 #thisDatetime = dataOut.datatime
1703 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1935 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1704 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1936 title = wintitle + " Phase of Beacon Signal" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1705 xlabel = "Local Time"
1937 xlabel = "Local Time"
1706 ylabel = "Phase"
1938 ylabel = "Phase"
1707
1939
1708
1940
1709 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1941 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1710 phase_beacon = dataOut.data_output
1942 phase_beacon = dataOut.data_output
1711 update_figfile = False
1943 update_figfile = False
1712
1944
1713 if not self.isConfig:
1945 if not self.isConfig:
1714
1946
1715 self.nplots = phase_beacon.size
1947 self.nplots = phase_beacon.size
1716
1948
1717 self.setup(id=id,
1949 self.setup(id=id,
1718 nplots=self.nplots,
1950 nplots=self.nplots,
1719 wintitle=wintitle,
1951 wintitle=wintitle,
1720 showprofile=showprofile,
1952 showprofile=showprofile,
1721 show=show)
1953 show=show)
1722
1954
1723 if timerange is not None:
1955 if timerange is not None:
1724 self.timerange = timerange
1956 self.timerange = timerange
1725
1957
1726 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1958 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1727
1959
1728 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1960 if ymin == None: ymin = numpy.nanmin(phase_beacon) - 10.0
1729 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1961 if ymax == None: ymax = numpy.nanmax(phase_beacon) + 10.0
1730
1962
1731 self.FTP_WEI = ftp_wei
1963 self.FTP_WEI = ftp_wei
1732 self.EXP_CODE = exp_code
1964 self.EXP_CODE = exp_code
1733 self.SUB_EXP_CODE = sub_exp_code
1965 self.SUB_EXP_CODE = sub_exp_code
1734 self.PLOT_POS = plot_pos
1966 self.PLOT_POS = plot_pos
1735
1967
1736 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1968 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1737 self.isConfig = True
1969 self.isConfig = True
1738 self.figfile = figfile
1970 self.figfile = figfile
1739 self.xdata = numpy.array([])
1971 self.xdata = numpy.array([])
1740 self.ydata = numpy.array([])
1972 self.ydata = numpy.array([])
1741
1973
1742 #open file beacon phase
1974 #open file beacon phase
1743 path = '%s%03d' %(self.PREFIX, self.id)
1975 path = '%s%03d' %(self.PREFIX, self.id)
1744 beacon_file = os.path.join(path,'%s.txt'%self.name)
1976 beacon_file = os.path.join(path,'%s.txt'%self.name)
1745 self.filename_phase = os.path.join(figpath,beacon_file)
1977 self.filename_phase = os.path.join(figpath,beacon_file)
1746 update_figfile = True
1978 update_figfile = True
1747
1979
1748
1980
1749 #store data beacon phase
1981 #store data beacon phase
1750 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1982 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1751
1983
1752 self.setWinTitle(title)
1984 self.setWinTitle(title)
1753
1985
1754
1986
1755 title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1987 title = "Phase Offset %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1756
1988
1757 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1989 legendlabels = ["phase %d"%(chan) for chan in numpy.arange(self.nplots)]
1758
1990
1759 axes = self.axesList[0]
1991 axes = self.axesList[0]
1760
1992
1761 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1993 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1762
1994
1763 if len(self.ydata)==0:
1995 if len(self.ydata)==0:
1764 self.ydata = phase_beacon.reshape(-1,1)
1996 self.ydata = phase_beacon.reshape(-1,1)
1765 else:
1997 else:
1766 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1998 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1767
1999
1768
2000
1769 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
2001 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1770 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
2002 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1771 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
2003 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1772 XAxisAsTime=True, grid='both'
2004 XAxisAsTime=True, grid='both'
1773 )
2005 )
1774
2006
1775 self.draw()
2007 self.draw()
1776
2008
1777 self.save(figpath=figpath,
2009 self.save(figpath=figpath,
1778 figfile=figfile,
2010 figfile=figfile,
1779 save=save,
2011 save=save,
1780 ftp=ftp,
2012 ftp=ftp,
1781 wr_period=wr_period,
2013 wr_period=wr_period,
1782 thisDatetime=thisDatetime,
2014 thisDatetime=thisDatetime,
1783 update_figfile=update_figfile)
2015 update_figfile=update_figfile)
1784
2016
1785 if dataOut.ltctime + dataOut.outputInterval >= self.xmax:
2017 if dataOut.ltctime + dataOut.outputInterval >= self.xmax:
1786 self.counter_imagwr = wr_period
2018 self.counter_imagwr = wr_period
1787 self.isConfig = False
2019 self.isConfig = False
1788 update_figfile = True
2020 update_figfile = True
1789
2021
1790
2022
1791
2023
1792 class NSMeteorDetection1Plot(Figure):
2024 class NSMeteorDetection1Plot(Figure):
1793
2025
1794 isConfig = None
2026 isConfig = None
1795 __nsubplots = None
2027 __nsubplots = None
1796
2028
1797 WIDTHPROF = None
2029 WIDTHPROF = None
1798 HEIGHTPROF = None
2030 HEIGHTPROF = None
1799 PREFIX = 'nsm'
2031 PREFIX = 'nsm'
1800
2032
1801 zminList = None
2033 zminList = None
1802 zmaxList = None
2034 zmaxList = None
1803 cmapList = None
2035 cmapList = None
1804 titleList = None
2036 titleList = None
1805 nPairs = None
2037 nPairs = None
1806 nChannels = None
2038 nChannels = None
1807 nParam = None
2039 nParam = None
1808
2040
1809 def __init__(self, **kwargs):
2041 def __init__(self, **kwargs):
1810 Figure.__init__(self, **kwargs)
2042 Figure.__init__(self, **kwargs)
1811 self.isConfig = False
2043 self.isConfig = False
1812 self.__nsubplots = 1
2044 self.__nsubplots = 1
1813
2045
1814 self.WIDTH = 750
2046 self.WIDTH = 750
1815 self.HEIGHT = 250
2047 self.HEIGHT = 250
1816 self.WIDTHPROF = 120
2048 self.WIDTHPROF = 120
1817 self.HEIGHTPROF = 0
2049 self.HEIGHTPROF = 0
1818 self.counter_imagwr = 0
2050 self.counter_imagwr = 0
1819
2051
1820 self.PLOT_CODE = SPEC_CODE
2052 self.PLOT_CODE = SPEC_CODE
1821
2053
1822 self.FTP_WEI = None
2054 self.FTP_WEI = None
1823 self.EXP_CODE = None
2055 self.EXP_CODE = None
1824 self.SUB_EXP_CODE = None
2056 self.SUB_EXP_CODE = None
1825 self.PLOT_POS = None
2057 self.PLOT_POS = None
1826
2058
1827 self.__xfilter_ena = False
2059 self.__xfilter_ena = False
1828 self.__yfilter_ena = False
2060 self.__yfilter_ena = False
1829
2061
1830 def getSubplots(self):
2062 def getSubplots(self):
1831
2063
1832 ncol = 3
2064 ncol = 3
1833 nrow = int(numpy.ceil(self.nplots/3.0))
2065 nrow = int(numpy.ceil(self.nplots/3.0))
1834
2066
1835 return nrow, ncol
2067 return nrow, ncol
1836
2068
1837 def setup(self, id, nplots, wintitle, show=True):
2069 def setup(self, id, nplots, wintitle, show=True):
1838
2070
1839 self.nplots = nplots
2071 self.nplots = nplots
1840
2072
1841 ncolspan = 1
2073 ncolspan = 1
1842 colspan = 1
2074 colspan = 1
1843
2075
1844 self.createFigure(id = id,
2076 self.createFigure(id = id,
1845 wintitle = wintitle,
2077 wintitle = wintitle,
1846 widthplot = self.WIDTH + self.WIDTHPROF,
2078 widthplot = self.WIDTH + self.WIDTHPROF,
1847 heightplot = self.HEIGHT + self.HEIGHTPROF,
2079 heightplot = self.HEIGHT + self.HEIGHTPROF,
1848 show=show)
2080 show=show)
1849
2081
1850 nrow, ncol = self.getSubplots()
2082 nrow, ncol = self.getSubplots()
1851
2083
1852 counter = 0
2084 counter = 0
1853 for y in range(nrow):
2085 for y in range(nrow):
1854 for x in range(ncol):
2086 for x in range(ncol):
1855
2087
1856 if counter >= self.nplots:
2088 if counter >= self.nplots:
1857 break
2089 break
1858
2090
1859 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
2091 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1860
2092
1861 counter += 1
2093 counter += 1
1862
2094
1863 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
2095 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
1864 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
2096 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
1865 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
2097 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
1866 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
2098 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1867 server=None, folder=None, username=None, password=None,
2099 server=None, folder=None, username=None, password=None,
1868 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
2100 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
1869 xaxis="frequency"):
2101 xaxis="frequency"):
1870
2102
1871 """
2103 """
1872
2104
1873 Input:
2105 Input:
1874 dataOut :
2106 dataOut :
1875 id :
2107 id :
1876 wintitle :
2108 wintitle :
1877 channelList :
2109 channelList :
1878 showProfile :
2110 showProfile :
1879 xmin : None,
2111 xmin : None,
1880 xmax : None,
2112 xmax : None,
1881 ymin : None,
2113 ymin : None,
1882 ymax : None,
2114 ymax : None,
1883 zmin : None,
2115 zmin : None,
1884 zmax : None
2116 zmax : None
1885 """
2117 """
1886 #SEPARAR EN DOS PLOTS
2118 #SEPARAR EN DOS PLOTS
1887 nParam = dataOut.data_param.shape[1] - 3
2119 nParam = dataOut.data_param.shape[1] - 3
1888
2120
1889 utctime = dataOut.data_param[0,0]
2121 utctime = dataOut.data_param[0,0]
1890 tmet = dataOut.data_param[:,1].astype(int)
2122 tmet = dataOut.data_param[:,1].astype(int)
1891 hmet = dataOut.data_param[:,2].astype(int)
2123 hmet = dataOut.data_param[:,2].astype(int)
1892
2124
1893 x = dataOut.abscissaList
2125 x = dataOut.abscissaList
1894 y = dataOut.heightList
2126 y = dataOut.heightList
1895
2127
1896 z = numpy.zeros((nParam, y.size, x.size - 1))
2128 z = numpy.zeros((nParam, y.size, x.size - 1))
1897 z[:,:] = numpy.nan
2129 z[:,:] = numpy.nan
1898 z[:,hmet,tmet] = dataOut.data_param[:,3:].T
2130 z[:,hmet,tmet] = dataOut.data_param[:,3:].T
1899 z[0,:,:] = 10*numpy.log10(z[0,:,:])
2131 z[0,:,:] = 10*numpy.log10(z[0,:,:])
1900
2132
1901 xlabel = "Time (s)"
2133 xlabel = "Time (s)"
1902 ylabel = "Range (km)"
2134 ylabel = "Range (km)"
1903
2135
1904 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
2136 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
1905
2137
1906 if not self.isConfig:
2138 if not self.isConfig:
1907
2139
1908 nplots = nParam
2140 nplots = nParam
1909
2141
1910 self.setup(id=id,
2142 self.setup(id=id,
1911 nplots=nplots,
2143 nplots=nplots,
1912 wintitle=wintitle,
2144 wintitle=wintitle,
1913 show=show)
2145 show=show)
1914
2146
1915 if xmin is None: xmin = numpy.nanmin(x)
2147 if xmin is None: xmin = numpy.nanmin(x)
1916 if xmax is None: xmax = numpy.nanmax(x)
2148 if xmax is None: xmax = numpy.nanmax(x)
1917 if ymin is None: ymin = numpy.nanmin(y)
2149 if ymin is None: ymin = numpy.nanmin(y)
1918 if ymax is None: ymax = numpy.nanmax(y)
2150 if ymax is None: ymax = numpy.nanmax(y)
1919 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
2151 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
1920 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
2152 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
1921 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
2153 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
1922 if vmin is None: vmin = -vmax
2154 if vmin is None: vmin = -vmax
1923 if wmin is None: wmin = 0
2155 if wmin is None: wmin = 0
1924 if wmax is None: wmax = 50
2156 if wmax is None: wmax = 50
1925
2157
1926 pairsList = dataOut.groupList
2158 pairsList = dataOut.groupList
1927 self.nPairs = len(dataOut.groupList)
2159 self.nPairs = len(dataOut.groupList)
1928
2160
1929 zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs
2161 zminList = [SNRmin, vmin, cmin] + [pmin]*self.nPairs
1930 zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs
2162 zmaxList = [SNRmax, vmax, cmax] + [pmax]*self.nPairs
1931 titleList = ["SNR","Radial Velocity","Coherence"]
2163 titleList = ["SNR","Radial Velocity","Coherence"]
1932 cmapList = ["jet","RdBu_r","jet"]
2164 cmapList = ["jet","RdBu_r","jet"]
1933
2165
1934 for i in range(self.nPairs):
2166 for i in range(self.nPairs):
1935 strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1])
2167 strAux1 = "Phase Difference "+ str(pairsList[i][0]) + str(pairsList[i][1])
1936 titleList = titleList + [strAux1]
2168 titleList = titleList + [strAux1]
1937 cmapList = cmapList + ["RdBu_r"]
2169 cmapList = cmapList + ["RdBu_r"]
1938
2170
1939 self.zminList = zminList
2171 self.zminList = zminList
1940 self.zmaxList = zmaxList
2172 self.zmaxList = zmaxList
1941 self.cmapList = cmapList
2173 self.cmapList = cmapList
1942 self.titleList = titleList
2174 self.titleList = titleList
1943
2175
1944 self.FTP_WEI = ftp_wei
2176 self.FTP_WEI = ftp_wei
1945 self.EXP_CODE = exp_code
2177 self.EXP_CODE = exp_code
1946 self.SUB_EXP_CODE = sub_exp_code
2178 self.SUB_EXP_CODE = sub_exp_code
1947 self.PLOT_POS = plot_pos
2179 self.PLOT_POS = plot_pos
1948
2180
1949 self.isConfig = True
2181 self.isConfig = True
1950
2182
1951 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
2183 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
1952
2184
1953 for i in range(nParam):
2185 for i in range(nParam):
1954 title = self.titleList[i] + ": " +str_datetime
2186 title = self.titleList[i] + ": " +str_datetime
1955 axes = self.axesList[i]
2187 axes = self.axesList[i]
1956 axes.pcolor(x, y, z[i,:].T,
2188 axes.pcolor(x, y, z[i,:].T,
1957 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
2189 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
1958 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
2190 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
1959 self.draw()
2191 self.draw()
1960
2192
1961 if figfile == None:
2193 if figfile == None:
1962 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
2194 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
1963 name = str_datetime
2195 name = str_datetime
1964 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
2196 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
1965 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
2197 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
1966 figfile = self.getFilename(name)
2198 figfile = self.getFilename(name)
1967
2199
1968 self.save(figpath=figpath,
2200 self.save(figpath=figpath,
1969 figfile=figfile,
2201 figfile=figfile,
1970 save=save,
2202 save=save,
1971 ftp=ftp,
2203 ftp=ftp,
1972 wr_period=wr_period,
2204 wr_period=wr_period,
1973 thisDatetime=thisDatetime)
2205 thisDatetime=thisDatetime)
1974
2206
1975
2207
1976 class NSMeteorDetection2Plot(Figure):
2208 class NSMeteorDetection2Plot(Figure):
1977
2209
1978 isConfig = None
2210 isConfig = None
1979 __nsubplots = None
2211 __nsubplots = None
1980
2212
1981 WIDTHPROF = None
2213 WIDTHPROF = None
1982 HEIGHTPROF = None
2214 HEIGHTPROF = None
1983 PREFIX = 'nsm'
2215 PREFIX = 'nsm'
1984
2216
1985 zminList = None
2217 zminList = None
1986 zmaxList = None
2218 zmaxList = None
1987 cmapList = None
2219 cmapList = None
1988 titleList = None
2220 titleList = None
1989 nPairs = None
2221 nPairs = None
1990 nChannels = None
2222 nChannels = None
1991 nParam = None
2223 nParam = None
1992
2224
1993 def __init__(self, **kwargs):
2225 def __init__(self, **kwargs):
1994 Figure.__init__(self, **kwargs)
2226 Figure.__init__(self, **kwargs)
1995 self.isConfig = False
2227 self.isConfig = False
1996 self.__nsubplots = 1
2228 self.__nsubplots = 1
1997
2229
1998 self.WIDTH = 750
2230 self.WIDTH = 750
1999 self.HEIGHT = 250
2231 self.HEIGHT = 250
2000 self.WIDTHPROF = 120
2232 self.WIDTHPROF = 120
2001 self.HEIGHTPROF = 0
2233 self.HEIGHTPROF = 0
2002 self.counter_imagwr = 0
2234 self.counter_imagwr = 0
2003
2235
2004 self.PLOT_CODE = SPEC_CODE
2236 self.PLOT_CODE = SPEC_CODE
2005
2237
2006 self.FTP_WEI = None
2238 self.FTP_WEI = None
2007 self.EXP_CODE = None
2239 self.EXP_CODE = None
2008 self.SUB_EXP_CODE = None
2240 self.SUB_EXP_CODE = None
2009 self.PLOT_POS = None
2241 self.PLOT_POS = None
2010
2242
2011 self.__xfilter_ena = False
2243 self.__xfilter_ena = False
2012 self.__yfilter_ena = False
2244 self.__yfilter_ena = False
2013
2245
2014 def getSubplots(self):
2246 def getSubplots(self):
2015
2247
2016 ncol = 3
2248 ncol = 3
2017 nrow = int(numpy.ceil(self.nplots/3.0))
2249 nrow = int(numpy.ceil(self.nplots/3.0))
2018
2250
2019 return nrow, ncol
2251 return nrow, ncol
2020
2252
2021 def setup(self, id, nplots, wintitle, show=True):
2253 def setup(self, id, nplots, wintitle, show=True):
2022
2254
2023 self.nplots = nplots
2255 self.nplots = nplots
2024
2256
2025 ncolspan = 1
2257 ncolspan = 1
2026 colspan = 1
2258 colspan = 1
2027
2259
2028 self.createFigure(id = id,
2260 self.createFigure(id = id,
2029 wintitle = wintitle,
2261 wintitle = wintitle,
2030 widthplot = self.WIDTH + self.WIDTHPROF,
2262 widthplot = self.WIDTH + self.WIDTHPROF,
2031 heightplot = self.HEIGHT + self.HEIGHTPROF,
2263 heightplot = self.HEIGHT + self.HEIGHTPROF,
2032 show=show)
2264 show=show)
2033
2265
2034 nrow, ncol = self.getSubplots()
2266 nrow, ncol = self.getSubplots()
2035
2267
2036 counter = 0
2268 counter = 0
2037 for y in range(nrow):
2269 for y in range(nrow):
2038 for x in range(ncol):
2270 for x in range(ncol):
2039
2271
2040 if counter >= self.nplots:
2272 if counter >= self.nplots:
2041 break
2273 break
2042
2274
2043 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
2275 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
2044
2276
2045 counter += 1
2277 counter += 1
2046
2278
2047 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
2279 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
2048 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
2280 xmin=None, xmax=None, ymin=None, ymax=None, SNRmin=None, SNRmax=None,
2049 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
2281 vmin=None, vmax=None, wmin=None, wmax=None, mode = 'SA',
2050 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
2282 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
2051 server=None, folder=None, username=None, password=None,
2283 server=None, folder=None, username=None, password=None,
2052 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
2284 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
2053 xaxis="frequency"):
2285 xaxis="frequency"):
2054
2286
2055 """
2287 """
2056
2288
2057 Input:
2289 Input:
2058 dataOut :
2290 dataOut :
2059 id :
2291 id :
2060 wintitle :
2292 wintitle :
2061 channelList :
2293 channelList :
2062 showProfile :
2294 showProfile :
2063 xmin : None,
2295 xmin : None,
2064 xmax : None,
2296 xmax : None,
2065 ymin : None,
2297 ymin : None,
2066 ymax : None,
2298 ymax : None,
2067 zmin : None,
2299 zmin : None,
2068 zmax : None
2300 zmax : None
2069 """
2301 """
2070 #Rebuild matrix
2302 #Rebuild matrix
2071 utctime = dataOut.data_param[0,0]
2303 utctime = dataOut.data_param[0,0]
2072 cmet = dataOut.data_param[:,1].astype(int)
2304 cmet = dataOut.data_param[:,1].astype(int)
2073 tmet = dataOut.data_param[:,2].astype(int)
2305 tmet = dataOut.data_param[:,2].astype(int)
2074 hmet = dataOut.data_param[:,3].astype(int)
2306 hmet = dataOut.data_param[:,3].astype(int)
2075
2307
2076 nParam = 3
2308 nParam = 3
2077 nChan = len(dataOut.groupList)
2309 nChan = len(dataOut.groupList)
2078 x = dataOut.abscissaList
2310 x = dataOut.abscissaList
2079 y = dataOut.heightList
2311 y = dataOut.heightList
2080
2312
2081 z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan)
2313 z = numpy.full((nChan, nParam, y.size, x.size - 1),numpy.nan)
2082 z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:]
2314 z[cmet,:,hmet,tmet] = dataOut.data_param[:,4:]
2083 z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale
2315 z[:,0,:,:] = 10*numpy.log10(z[:,0,:,:]) #logarithmic scale
2084 z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1))
2316 z = numpy.reshape(z, (nChan*nParam, y.size, x.size-1))
2085
2317
2086 xlabel = "Time (s)"
2318 xlabel = "Time (s)"
2087 ylabel = "Range (km)"
2319 ylabel = "Range (km)"
2088
2320
2089 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
2321 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.ltctime)
2090
2322
2091 if not self.isConfig:
2323 if not self.isConfig:
2092
2324
2093 nplots = nParam*nChan
2325 nplots = nParam*nChan
2094
2326
2095 self.setup(id=id,
2327 self.setup(id=id,
2096 nplots=nplots,
2328 nplots=nplots,
2097 wintitle=wintitle,
2329 wintitle=wintitle,
2098 show=show)
2330 show=show)
2099
2331
2100 if xmin is None: xmin = numpy.nanmin(x)
2332 if xmin is None: xmin = numpy.nanmin(x)
2101 if xmax is None: xmax = numpy.nanmax(x)
2333 if xmax is None: xmax = numpy.nanmax(x)
2102 if ymin is None: ymin = numpy.nanmin(y)
2334 if ymin is None: ymin = numpy.nanmin(y)
2103 if ymax is None: ymax = numpy.nanmax(y)
2335 if ymax is None: ymax = numpy.nanmax(y)
2104 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
2336 if SNRmin is None: SNRmin = numpy.nanmin(z[0,:])
2105 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
2337 if SNRmax is None: SNRmax = numpy.nanmax(z[0,:])
2106 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
2338 if vmax is None: vmax = numpy.nanmax(numpy.abs(z[1,:]))
2107 if vmin is None: vmin = -vmax
2339 if vmin is None: vmin = -vmax
2108 if wmin is None: wmin = 0
2340 if wmin is None: wmin = 0
2109 if wmax is None: wmax = 50
2341 if wmax is None: wmax = 50
2110
2342
2111 self.nChannels = nChan
2343 self.nChannels = nChan
2112
2344
2113 zminList = []
2345 zminList = []
2114 zmaxList = []
2346 zmaxList = []
2115 titleList = []
2347 titleList = []
2116 cmapList = []
2348 cmapList = []
2117 for i in range(self.nChannels):
2349 for i in range(self.nChannels):
2118 strAux1 = "SNR Channel "+ str(i)
2350 strAux1 = "SNR Channel "+ str(i)
2119 strAux2 = "Radial Velocity Channel "+ str(i)
2351 strAux2 = "Radial Velocity Channel "+ str(i)
2120 strAux3 = "Spectral Width Channel "+ str(i)
2352 strAux3 = "Spectral Width Channel "+ str(i)
2121
2353
2122 titleList = titleList + [strAux1,strAux2,strAux3]
2354 titleList = titleList + [strAux1,strAux2,strAux3]
2123 cmapList = cmapList + ["jet","RdBu_r","jet"]
2355 cmapList = cmapList + ["jet","RdBu_r","jet"]
2124 zminList = zminList + [SNRmin,vmin,wmin]
2356 zminList = zminList + [SNRmin,vmin,wmin]
2125 zmaxList = zmaxList + [SNRmax,vmax,wmax]
2357 zmaxList = zmaxList + [SNRmax,vmax,wmax]
2126
2358
2127 self.zminList = zminList
2359 self.zminList = zminList
2128 self.zmaxList = zmaxList
2360 self.zmaxList = zmaxList
2129 self.cmapList = cmapList
2361 self.cmapList = cmapList
2130 self.titleList = titleList
2362 self.titleList = titleList
2131
2363
2132 self.FTP_WEI = ftp_wei
2364 self.FTP_WEI = ftp_wei
2133 self.EXP_CODE = exp_code
2365 self.EXP_CODE = exp_code
2134 self.SUB_EXP_CODE = sub_exp_code
2366 self.SUB_EXP_CODE = sub_exp_code
2135 self.PLOT_POS = plot_pos
2367 self.PLOT_POS = plot_pos
2136
2368
2137 self.isConfig = True
2369 self.isConfig = True
2138
2370
2139 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
2371 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
2140
2372
2141 for i in range(self.nplots):
2373 for i in range(self.nplots):
2142 title = self.titleList[i] + ": " +str_datetime
2374 title = self.titleList[i] + ": " +str_datetime
2143 axes = self.axesList[i]
2375 axes = self.axesList[i]
2144 axes.pcolor(x, y, z[i,:].T,
2376 axes.pcolor(x, y, z[i,:].T,
2145 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
2377 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=self.zminList[i], zmax=self.zmaxList[i],
2146 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
2378 xlabel=xlabel, ylabel=ylabel, title=title, colormap=self.cmapList[i],ticksize=9, cblabel='')
2147 self.draw()
2379 self.draw()
2148
2380
2149 if figfile == None:
2381 if figfile == None:
2150 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
2382 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
2151 name = str_datetime
2383 name = str_datetime
2152 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
2384 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
2153 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
2385 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
2154 figfile = self.getFilename(name)
2386 figfile = self.getFilename(name)
2155
2387
2156 self.save(figpath=figpath,
2388 self.save(figpath=figpath,
2157 figfile=figfile,
2389 figfile=figfile,
2158 save=save,
2390 save=save,
2159 ftp=ftp,
2391 ftp=ftp,
2160 wr_period=wr_period,
2392 wr_period=wr_period,
2161 thisDatetime=thisDatetime)
2393 thisDatetime=thisDatetime)
@@ -1,1155 +1,795
1 import os, sys
1 import os, sys
2 import glob
2 import glob
3 import fnmatch
3 import fnmatch
4 import datetime
4 import datetime
5 import time
5 import time
6 import re
6 import re
7 import h5py
7 import h5py
8 import numpy
8 import numpy
9 import matplotlib.pyplot as plt
9 import matplotlib.pyplot as plt
10
10
11 import pylab as plb
11 import pylab as plb
12 from scipy.optimize import curve_fit
12 from scipy.optimize import curve_fit
13 from scipy import asarray as ar, exp
13 from scipy import asarray as ar, exp
14 from scipy import stats
14 from scipy import stats
15
15
16 from numpy.ma.core import getdata
16 from numpy.ma.core import getdata
17
17
18 SPEED_OF_LIGHT = 299792458
18 SPEED_OF_LIGHT = 299792458
19 SPEED_OF_LIGHT = 3e8
19 SPEED_OF_LIGHT = 3e8
20
20
21 try:
21 try:
22 from gevent import sleep
22 from gevent import sleep
23 except:
23 except:
24 from time import sleep
24 from time import sleep
25
25
26 from schainpy.model.data.jrodata import Spectra
26 from schainpy.model.data.jrodata import Spectra
27 #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
27 #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
28 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
28 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
29 #from schainpy.model.io.jroIO_bltr import BLTRReader
29 #from schainpy.model.io.jroIO_bltr import BLTRReader
30 from numpy import imag, shape, NaN
30 from numpy import imag, shape, NaN
31
31
32 from jroIO_base import JRODataReader
32 from jroIO_base import JRODataReader
33
33
34
34
35 class Header(object):
35 class Header(object):
36
36
37 def __init__(self):
37 def __init__(self):
38 raise NotImplementedError
38 raise NotImplementedError
39
39
40
40
41 def read(self):
41 def read(self):
42
42
43 raise NotImplementedError
43 raise NotImplementedError
44
44
45 def write(self):
45 def write(self):
46
46
47 raise NotImplementedError
47 raise NotImplementedError
48
48
49 def printInfo(self):
49 def printInfo(self):
50
50
51 message = "#"*50 + "\n"
51 message = "#"*50 + "\n"
52 message += self.__class__.__name__.upper() + "\n"
52 message += self.__class__.__name__.upper() + "\n"
53 message += "#"*50 + "\n"
53 message += "#"*50 + "\n"
54
54
55 keyList = self.__dict__.keys()
55 keyList = self.__dict__.keys()
56 keyList.sort()
56 keyList.sort()
57
57
58 for key in keyList:
58 for key in keyList:
59 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
59 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
60
60
61 if "size" not in keyList:
61 if "size" not in keyList:
62 attr = getattr(self, "size")
62 attr = getattr(self, "size")
63
63
64 if attr:
64 if attr:
65 message += "%s = %s" %("size", attr) + "\n"
65 message += "%s = %s" %("size", attr) + "\n"
66
66
67 #print message
67 #print message
68
68
69
69
70
70
71
71
72
72
73 FILE_STRUCTURE = numpy.dtype([ #HEADER 48bytes
73 FILE_STRUCTURE = numpy.dtype([ #HEADER 48bytes
74 ('FileMgcNumber','<u4'), #0x23020100
74 ('FileMgcNumber','<u4'), #0x23020100
75 ('nFDTdataRecors','<u4'), #No Of FDT data records in this file (0 or more)
75 ('nFDTdataRecors','<u4'), #No Of FDT data records in this file (0 or more)
76 ('OffsetStartHeader','<u4'),
76 ('OffsetStartHeader','<u4'),
77 ('RadarUnitId','<u4'),
77 ('RadarUnitId','<u4'),
78 ('SiteName',numpy.str_,32), #Null terminated
78 ('SiteName',numpy.str_,32), #Null terminated
79 ])
79 ])
80
80
81 class FileHeaderBLTR(Header):
81 class FileHeaderBLTR(Header):
82
82
83 def __init__(self):
83 def __init__(self):
84
84
85 self.FileMgcNumber= 0 #0x23020100
85 self.FileMgcNumber= 0 #0x23020100
86 self.nFDTdataRecors=0 #No Of FDT data records in this file (0 or more)
86 self.nFDTdataRecors=0 #No Of FDT data records in this file (0 or more)
87 self.RadarUnitId= 0
87 self.RadarUnitId= 0
88 self.OffsetStartHeader=0
88 self.OffsetStartHeader=0
89 self.SiteName= ""
89 self.SiteName= ""
90 self.size = 48
90 self.size = 48
91
91
92 def FHread(self, fp):
92 def FHread(self, fp):
93 #try:
93 #try:
94 startFp = open(fp,"rb")
94 startFp = open(fp,"rb")
95
95
96 header = numpy.fromfile(startFp, FILE_STRUCTURE,1)
96 header = numpy.fromfile(startFp, FILE_STRUCTURE,1)
97
97
98 print ' '
98 print ' '
99 print 'puntero file header', startFp.tell()
99 print 'puntero file header', startFp.tell()
100 print ' '
100 print ' '
101
101
102
102
103 ''' numpy.fromfile(file, dtype, count, sep='')
103 ''' numpy.fromfile(file, dtype, count, sep='')
104 file : file or str
104 file : file or str
105 Open file object or filename.
105 Open file object or filename.
106
106
107 dtype : data-type
107 dtype : data-type
108 Data type of the returned array. For binary files, it is used to determine
108 Data type of the returned array. For binary files, it is used to determine
109 the size and byte-order of the items in the file.
109 the size and byte-order of the items in the file.
110
110
111 count : int
111 count : int
112 Number of items to read. -1 means all items (i.e., the complete file).
112 Number of items to read. -1 means all items (i.e., the complete file).
113
113
114 sep : str
114 sep : str
115 Separator between items if file is a text file. Empty ("") separator means
115 Separator between items if file is a text file. Empty ("") separator means
116 the file should be treated as binary. Spaces (" ") in the separator match zero
116 the file should be treated as binary. Spaces (" ") in the separator match zero
117 or more whitespace characters. A separator consisting only of spaces must match
117 or more whitespace characters. A separator consisting only of spaces must match
118 at least one whitespace.
118 at least one whitespace.
119
119
120 '''
120 '''
121
121
122
122
123
123
124 self.FileMgcNumber= hex(header['FileMgcNumber'][0])
124 self.FileMgcNumber= hex(header['FileMgcNumber'][0])
125 self.nFDTdataRecors=int(header['nFDTdataRecors'][0]) #No Of FDT data records in this file (0 or more)
125 self.nFDTdataRecors=int(header['nFDTdataRecors'][0]) #No Of FDT data records in this file (0 or more)
126 self.RadarUnitId= int(header['RadarUnitId'][0])
126 self.RadarUnitId= int(header['RadarUnitId'][0])
127 self.OffsetStartHeader= int(header['OffsetStartHeader'][0])
127 self.OffsetStartHeader= int(header['OffsetStartHeader'][0])
128 self.SiteName= str(header['SiteName'][0])
128 self.SiteName= str(header['SiteName'][0])
129
129
130 #print 'Numero de bloques', self.nFDTdataRecors
130 #print 'Numero de bloques', self.nFDTdataRecors
131
131
132
132
133 if self.size <48:
133 if self.size <48:
134 return 0
134 return 0
135
135
136 return 1
136 return 1
137
137
138
138
139 def write(self, fp):
139 def write(self, fp):
140
140
141 headerTuple = (self.FileMgcNumber,
141 headerTuple = (self.FileMgcNumber,
142 self.nFDTdataRecors,
142 self.nFDTdataRecors,
143 self.RadarUnitId,
143 self.RadarUnitId,
144 self.SiteName,
144 self.SiteName,
145 self.size)
145 self.size)
146
146
147
147
148 header = numpy.array(headerTuple, FILE_STRUCTURE)
148 header = numpy.array(headerTuple, FILE_STRUCTURE)
149 # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)
149 # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)
150 header.tofile(fp)
150 header.tofile(fp)
151 ''' ndarray.tofile(fid, sep, format) Write array to a file as text or binary (default).
151 ''' ndarray.tofile(fid, sep, format) Write array to a file as text or binary (default).
152
152
153 fid : file or str
153 fid : file or str
154 An open file object, or a string containing a filename.
154 An open file object, or a string containing a filename.
155
155
156 sep : str
156 sep : str
157 Separator between array items for text output. If "" (empty), a binary file is written,
157 Separator between array items for text output. If "" (empty), a binary file is written,
158 equivalent to file.write(a.tobytes()).
158 equivalent to file.write(a.tobytes()).
159
159
160 format : str
160 format : str
161 Format string for text file output. Each entry in the array is formatted to text by
161 Format string for text file output. Each entry in the array is formatted to text by
162 first converting it to the closest Python type, and then using "format" % item.
162 first converting it to the closest Python type, and then using "format" % item.
163
163
164 '''
164 '''
165
165
166 return 1
166 return 1
167
167
168
168
169
169
170
170
171
171
172 RECORD_STRUCTURE = numpy.dtype([ #RECORD HEADER 180+20N bytes
172 RECORD_STRUCTURE = numpy.dtype([ #RECORD HEADER 180+20N bytes
173 ('RecMgcNumber','<u4'), #0x23030001
173 ('RecMgcNumber','<u4'), #0x23030001
174 ('RecCounter','<u4'), #Record counter(0,1, ...)
174 ('RecCounter','<u4'), #Record counter(0,1, ...)
175 ('Off2StartNxtRec','<u4'), #Offset to start of next record form start of this record
175 ('Off2StartNxtRec','<u4'), #Offset to start of next record form start of this record
176 ('Off2StartData','<u4'), #Offset to start of data from start of this record
176 ('Off2StartData','<u4'), #Offset to start of data from start of this record
177 ('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds)
177 ('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds)
178 ('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999)
178 ('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999)
179 ('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated)
179 ('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated)
180 ('ExpComment',numpy.str_,32), #Experiment comment (null terminated)
180 ('ExpComment',numpy.str_,32), #Experiment comment (null terminated)
181 ('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North)
181 ('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North)
182 ('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East)
182 ('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East)
183 ('RTCgpsStatus','<u4'), #RTC GPS engine status (0=SEEK, 1=LOCK, 2=NOT FITTED, 3=UNAVAILABLE)
183 ('RTCgpsStatus','<u4'), #RTC GPS engine status (0=SEEK, 1=LOCK, 2=NOT FITTED, 3=UNAVAILABLE)
184 ('TransmitFrec','<u4'), #Transmit frequency (Hz)
184 ('TransmitFrec','<u4'), #Transmit frequency (Hz)
185 ('ReceiveFrec','<u4'), #Receive frequency
185 ('ReceiveFrec','<u4'), #Receive frequency
186 ('FirstOsciFrec','<u4'), #First local oscillator frequency (Hz)
186 ('FirstOsciFrec','<u4'), #First local oscillator frequency (Hz)
187 ('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2")
187 ('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2")
188 ('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3)
188 ('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3)
189 ('nModesInUse','<u4'), #Number of modes in use (1 or 2)
189 ('nModesInUse','<u4'), #Number of modes in use (1 or 2)
190 ('DualModeIndex','<u4'), #Dual Mode index number for these data (0 or 1)
190 ('DualModeIndex','<u4'), #Dual Mode index number for these data (0 or 1)
191 ('DualModeRange','<u4'), #Dual Mode range correction for these data (m)
191 ('DualModeRange','<u4'), #Dual Mode range correction for these data (m)
192 ('nDigChannels','<u4'), #Number of digital channels acquired (2*N)
192 ('nDigChannels','<u4'), #Number of digital channels acquired (2*N)
193 ('SampResolution','<u4'), #Sampling resolution (meters)
193 ('SampResolution','<u4'), #Sampling resolution (meters)
194 ('nHeights','<u4'), #Number of range gates sampled
194 ('nHeights','<u4'), #Number of range gates sampled
195 ('StartRangeSamp','<u4'), #Start range of sampling (meters)
195 ('StartRangeSamp','<u4'), #Start range of sampling (meters)
196 ('PRFhz','<u4'), #PRF (Hz)
196 ('PRFhz','<u4'), #PRF (Hz)
197 ('nCohInt','<u4'), #Integrations
197 ('nCohInt','<u4'), #Integrations
198 ('nProfiles','<u4'), #Number of data points transformed
198 ('nProfiles','<u4'), #Number of data points transformed
199 ('nChannels','<u4'), #Number of receive beams stored in file (1 or N)
199 ('nChannels','<u4'), #Number of receive beams stored in file (1 or N)
200 ('nIncohInt','<u4'), #Number of spectral averages
200 ('nIncohInt','<u4'), #Number of spectral averages
201 ('FFTwindowingInd','<u4'), #FFT windowing index (0 = no window)
201 ('FFTwindowingInd','<u4'), #FFT windowing index (0 = no window)
202 ('BeamAngleAzim','<f4'), #Beam steer angle (azimuth) in degrees (clockwise from true North)
202 ('BeamAngleAzim','<f4'), #Beam steer angle (azimuth) in degrees (clockwise from true North)
203 ('BeamAngleZen','<f4'), #Beam steer angle (zenith) in degrees (0=> vertical)
203 ('BeamAngleZen','<f4'), #Beam steer angle (zenith) in degrees (0=> vertical)
204 ('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
204 ('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
205 ('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
205 ('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
206 ('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
206 ('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
207 ('AntennaAngl1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
207 ('AntennaAngl1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
208 ('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
208 ('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
209 ('AntennaAngl2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
209 ('AntennaAngl2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
210 ('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values
210 ('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values
211 ('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values
211 ('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values
212 ('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values
212 ('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values
213 ('RecAmpCalibr0','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
213 ('RecAmpCalibr0','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
214 ('RecAmpCalibr1','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
214 ('RecAmpCalibr1','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
215 ('RecAmpCalibr2','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
215 ('RecAmpCalibr2','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
216 ('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values
216 ('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values
217 ('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values
217 ('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values
218 ('ReceiverGaindB2','<i4'), #Receiver gains in dB - N values
218 ('ReceiverGaindB2','<i4'), #Receiver gains in dB - N values
219 ])
219 ])
220
220
221
221
222 class RecordHeaderBLTR(Header):
222 class RecordHeaderBLTR(Header):
223
223
224 def __init__(self, RecMgcNumber=None, RecCounter= 0, Off2StartNxtRec= 811248,
224 def __init__(self, RecMgcNumber=None, RecCounter= 0, Off2StartNxtRec= 811248,
225 nUtime= 0, nMilisec= 0, ExpTagName= None,
225 nUtime= 0, nMilisec= 0, ExpTagName= None,
226 ExpComment=None, SiteLatDegrees=0, SiteLongDegrees= 0,
226 ExpComment=None, SiteLatDegrees=0, SiteLongDegrees= 0,
227 RTCgpsStatus= 0, TransmitFrec= 0, ReceiveFrec= 0,
227 RTCgpsStatus= 0, TransmitFrec= 0, ReceiveFrec= 0,
228 FirstOsciFrec= 0, Polarisation= 0, ReceiverFiltSett= 0,
228 FirstOsciFrec= 0, Polarisation= 0, ReceiverFiltSett= 0,
229 nModesInUse= 0, DualModeIndex= 0, DualModeRange= 0,
229 nModesInUse= 0, DualModeIndex= 0, DualModeRange= 0,
230 nDigChannels= 0, SampResolution= 0, nHeights= 0,
230 nDigChannels= 0, SampResolution= 0, nHeights= 0,
231 StartRangeSamp= 0, PRFhz= 0, nCohInt= 0,
231 StartRangeSamp= 0, PRFhz= 0, nCohInt= 0,
232 nProfiles= 0, nChannels= 0, nIncohInt= 0,
232 nProfiles= 0, nChannels= 0, nIncohInt= 0,
233 FFTwindowingInd= 0, BeamAngleAzim= 0, BeamAngleZen= 0,
233 FFTwindowingInd= 0, BeamAngleAzim= 0, BeamAngleZen= 0,
234 AntennaCoord0= 0, AntennaCoord1= 0, AntennaCoord2= 0,
234 AntennaCoord0= 0, AntennaCoord1= 0, AntennaCoord2= 0,
235 RecPhaseCalibr0= 0, RecPhaseCalibr1= 0, RecPhaseCalibr2= 0,
235 RecPhaseCalibr0= 0, RecPhaseCalibr1= 0, RecPhaseCalibr2= 0,
236 RecAmpCalibr0= 0, RecAmpCalibr1= 0, RecAmpCalibr2= 0,
236 RecAmpCalibr0= 0, RecAmpCalibr1= 0, RecAmpCalibr2= 0,
237 AntennaAngl0=0, AntennaAngl1=0, AntennaAngl2=0,
237 AntennaAngl0=0, AntennaAngl1=0, AntennaAngl2=0,
238 ReceiverGaindB0= 0, ReceiverGaindB1= 0, ReceiverGaindB2= 0, Off2StartData=0, OffsetStartHeader=0):
238 ReceiverGaindB0= 0, ReceiverGaindB1= 0, ReceiverGaindB2= 0, Off2StartData=0, OffsetStartHeader=0):
239
239
240 self.RecMgcNumber = RecMgcNumber #0x23030001
240 self.RecMgcNumber = RecMgcNumber #0x23030001
241 self.RecCounter = RecCounter
241 self.RecCounter = RecCounter
242 self.Off2StartNxtRec = Off2StartNxtRec
242 self.Off2StartNxtRec = Off2StartNxtRec
243 self.Off2StartData = Off2StartData
243 self.Off2StartData = Off2StartData
244 self.nUtime = nUtime
244 self.nUtime = nUtime
245 self.nMilisec = nMilisec
245 self.nMilisec = nMilisec
246 self.ExpTagName = ExpTagName
246 self.ExpTagName = ExpTagName
247 self.ExpComment = ExpComment
247 self.ExpComment = ExpComment
248 self.SiteLatDegrees = SiteLatDegrees
248 self.SiteLatDegrees = SiteLatDegrees
249 self.SiteLongDegrees = SiteLongDegrees
249 self.SiteLongDegrees = SiteLongDegrees
250 self.RTCgpsStatus = RTCgpsStatus
250 self.RTCgpsStatus = RTCgpsStatus
251 self.TransmitFrec = TransmitFrec
251 self.TransmitFrec = TransmitFrec
252 self.ReceiveFrec = ReceiveFrec
252 self.ReceiveFrec = ReceiveFrec
253 self.FirstOsciFrec = FirstOsciFrec
253 self.FirstOsciFrec = FirstOsciFrec
254 self.Polarisation = Polarisation
254 self.Polarisation = Polarisation
255 self.ReceiverFiltSett = ReceiverFiltSett
255 self.ReceiverFiltSett = ReceiverFiltSett
256 self.nModesInUse = nModesInUse
256 self.nModesInUse = nModesInUse
257 self.DualModeIndex = DualModeIndex
257 self.DualModeIndex = DualModeIndex
258 self.DualModeRange = DualModeRange
258 self.DualModeRange = DualModeRange
259 self.nDigChannels = nDigChannels
259 self.nDigChannels = nDigChannels
260 self.SampResolution = SampResolution
260 self.SampResolution = SampResolution
261 self.nHeights = nHeights
261 self.nHeights = nHeights
262 self.StartRangeSamp = StartRangeSamp
262 self.StartRangeSamp = StartRangeSamp
263 self.PRFhz = PRFhz
263 self.PRFhz = PRFhz
264 self.nCohInt = nCohInt
264 self.nCohInt = nCohInt
265 self.nProfiles = nProfiles
265 self.nProfiles = nProfiles
266 self.nChannels = nChannels
266 self.nChannels = nChannels
267 self.nIncohInt = nIncohInt
267 self.nIncohInt = nIncohInt
268 self.FFTwindowingInd = FFTwindowingInd
268 self.FFTwindowingInd = FFTwindowingInd
269 self.BeamAngleAzim = BeamAngleAzim
269 self.BeamAngleAzim = BeamAngleAzim
270 self.BeamAngleZen = BeamAngleZen
270 self.BeamAngleZen = BeamAngleZen
271 self.AntennaCoord0 = AntennaCoord0
271 self.AntennaCoord0 = AntennaCoord0
272 self.AntennaAngl0 = AntennaAngl0
272 self.AntennaAngl0 = AntennaAngl0
273 self.AntennaAngl1 = AntennaAngl1
273 self.AntennaAngl1 = AntennaAngl1
274 self.AntennaAngl2 = AntennaAngl2
274 self.AntennaAngl2 = AntennaAngl2
275 self.AntennaCoord1 = AntennaCoord1
275 self.AntennaCoord1 = AntennaCoord1
276 self.AntennaCoord2 = AntennaCoord2
276 self.AntennaCoord2 = AntennaCoord2
277 self.RecPhaseCalibr0 = RecPhaseCalibr0
277 self.RecPhaseCalibr0 = RecPhaseCalibr0
278 self.RecPhaseCalibr1 = RecPhaseCalibr1
278 self.RecPhaseCalibr1 = RecPhaseCalibr1
279 self.RecPhaseCalibr2 = RecPhaseCalibr2
279 self.RecPhaseCalibr2 = RecPhaseCalibr2
280 self.RecAmpCalibr0 = RecAmpCalibr0
280 self.RecAmpCalibr0 = RecAmpCalibr0
281 self.RecAmpCalibr1 = RecAmpCalibr1
281 self.RecAmpCalibr1 = RecAmpCalibr1
282 self.RecAmpCalibr2 = RecAmpCalibr2
282 self.RecAmpCalibr2 = RecAmpCalibr2
283 self.ReceiverGaindB0 = ReceiverGaindB0
283 self.ReceiverGaindB0 = ReceiverGaindB0
284 self.ReceiverGaindB1 = ReceiverGaindB1
284 self.ReceiverGaindB1 = ReceiverGaindB1
285 self.ReceiverGaindB2 = ReceiverGaindB2
285 self.ReceiverGaindB2 = ReceiverGaindB2
286 self.OffsetStartHeader = 48
286 self.OffsetStartHeader = 48
287
287
288
288
289
289
290 def RHread(self, fp):
290 def RHread(self, fp):
291 #print fp
291 #print fp
292 #startFp = open('/home/erick/Documents/Data/huancayo.20161019.22.fdt',"rb") #The method tell() returns the current position of the file read/write pointer within the file.
292 #startFp = open('/home/erick/Documents/Data/huancayo.20161019.22.fdt',"rb") #The method tell() returns the current position of the file read/write pointer within the file.
293 startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file.
293 startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file.
294 #RecCounter=0
294 #RecCounter=0
295 #Off2StartNxtRec=811248
295 #Off2StartNxtRec=811248
296 OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
296 OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
297 print ' '
297 print ' '
298 print 'puntero Record Header', startFp.tell()
298 print 'puntero Record Header', startFp.tell()
299 print ' '
299 print ' '
300
300
301
301
302 startFp.seek(OffRHeader, os.SEEK_SET)
302 startFp.seek(OffRHeader, os.SEEK_SET)
303
303
304 print ' '
304 print ' '
305 print 'puntero Record Header con seek', startFp.tell()
305 print 'puntero Record Header con seek', startFp.tell()
306 print ' '
306 print ' '
307
307
308 #print 'Posicion del bloque: ',OffRHeader
308 #print 'Posicion del bloque: ',OffRHeader
309
309
310 header = numpy.fromfile(startFp,RECORD_STRUCTURE,1)
310 header = numpy.fromfile(startFp,RECORD_STRUCTURE,1)
311
311
312 print ' '
312 print ' '
313 print 'puntero Record Header con seek', startFp.tell()
313 print 'puntero Record Header con seek', startFp.tell()
314 print ' '
314 print ' '
315
315
316 print ' '
316 print ' '
317 #
317 #
318 #print 'puntero Record Header despues de seek', header.tell()
318 #print 'puntero Record Header despues de seek', header.tell()
319 print ' '
319 print ' '
320
320
321 self.RecMgcNumber = hex(header['RecMgcNumber'][0]) #0x23030001
321 self.RecMgcNumber = hex(header['RecMgcNumber'][0]) #0x23030001
322 self.RecCounter = int(header['RecCounter'][0])
322 self.RecCounter = int(header['RecCounter'][0])
323 self.Off2StartNxtRec = int(header['Off2StartNxtRec'][0])
323 self.Off2StartNxtRec = int(header['Off2StartNxtRec'][0])
324 self.Off2StartData = int(header['Off2StartData'][0])
324 self.Off2StartData = int(header['Off2StartData'][0])
325 self.nUtime = header['nUtime'][0]
325 self.nUtime = header['nUtime'][0]
326 self.nMilisec = header['nMilisec'][0]
326 self.nMilisec = header['nMilisec'][0]
327 self.ExpTagName = str(header['ExpTagName'][0])
327 self.ExpTagName = str(header['ExpTagName'][0])
328 self.ExpComment = str(header['ExpComment'][0])
328 self.ExpComment = str(header['ExpComment'][0])
329 self.SiteLatDegrees = header['SiteLatDegrees'][0]
329 self.SiteLatDegrees = header['SiteLatDegrees'][0]
330 self.SiteLongDegrees = header['SiteLongDegrees'][0]
330 self.SiteLongDegrees = header['SiteLongDegrees'][0]
331 self.RTCgpsStatus = header['RTCgpsStatus'][0]
331 self.RTCgpsStatus = header['RTCgpsStatus'][0]
332 self.TransmitFrec = header['TransmitFrec'][0]
332 self.TransmitFrec = header['TransmitFrec'][0]
333 self.ReceiveFrec = header['ReceiveFrec'][0]
333 self.ReceiveFrec = header['ReceiveFrec'][0]
334 self.FirstOsciFrec = header['FirstOsciFrec'][0]
334 self.FirstOsciFrec = header['FirstOsciFrec'][0]
335 self.Polarisation = header['Polarisation'][0]
335 self.Polarisation = header['Polarisation'][0]
336 self.ReceiverFiltSett = header['ReceiverFiltSett'][0]
336 self.ReceiverFiltSett = header['ReceiverFiltSett'][0]
337 self.nModesInUse = header['nModesInUse'][0]
337 self.nModesInUse = header['nModesInUse'][0]
338 self.DualModeIndex = header['DualModeIndex'][0]
338 self.DualModeIndex = header['DualModeIndex'][0]
339 self.DualModeRange = header['DualModeRange'][0]
339 self.DualModeRange = header['DualModeRange'][0]
340 self.nDigChannels = header['nDigChannels'][0]
340 self.nDigChannels = header['nDigChannels'][0]
341 self.SampResolution = header['SampResolution'][0]
341 self.SampResolution = header['SampResolution'][0]
342 self.nHeights = header['nHeights'][0]
342 self.nHeights = header['nHeights'][0]
343 self.StartRangeSamp = header['StartRangeSamp'][0]
343 self.StartRangeSamp = header['StartRangeSamp'][0]
344 self.PRFhz = header['PRFhz'][0]
344 self.PRFhz = header['PRFhz'][0]
345 self.nCohInt = header['nCohInt'][0]
345 self.nCohInt = header['nCohInt'][0]
346 self.nProfiles = header['nProfiles'][0]
346 self.nProfiles = header['nProfiles'][0]
347 self.nChannels = header['nChannels'][0]
347 self.nChannels = header['nChannels'][0]
348 self.nIncohInt = header['nIncohInt'][0]
348 self.nIncohInt = header['nIncohInt'][0]
349 self.FFTwindowingInd = header['FFTwindowingInd'][0]
349 self.FFTwindowingInd = header['FFTwindowingInd'][0]
350 self.BeamAngleAzim = header['BeamAngleAzim'][0]
350 self.BeamAngleAzim = header['BeamAngleAzim'][0]
351 self.BeamAngleZen = header['BeamAngleZen'][0]
351 self.BeamAngleZen = header['BeamAngleZen'][0]
352 self.AntennaCoord0 = header['AntennaCoord0'][0]
352 self.AntennaCoord0 = header['AntennaCoord0'][0]
353 self.AntennaAngl0 = header['AntennaAngl0'][0]
353 self.AntennaAngl0 = header['AntennaAngl0'][0]
354 self.AntennaCoord1 = header['AntennaCoord1'][0]
354 self.AntennaCoord1 = header['AntennaCoord1'][0]
355 self.AntennaAngl1 = header['AntennaAngl1'][0]
355 self.AntennaAngl1 = header['AntennaAngl1'][0]
356 self.AntennaCoord2 = header['AntennaCoord2'][0]
356 self.AntennaCoord2 = header['AntennaCoord2'][0]
357 self.AntennaAngl2 = header['AntennaAngl2'][0]
357 self.AntennaAngl2 = header['AntennaAngl2'][0]
358 self.RecPhaseCalibr0 = header['RecPhaseCalibr0'][0]
358 self.RecPhaseCalibr0 = header['RecPhaseCalibr0'][0]
359 self.RecPhaseCalibr1 = header['RecPhaseCalibr1'][0]
359 self.RecPhaseCalibr1 = header['RecPhaseCalibr1'][0]
360 self.RecPhaseCalibr2 = header['RecPhaseCalibr2'][0]
360 self.RecPhaseCalibr2 = header['RecPhaseCalibr2'][0]
361 self.RecAmpCalibr0 = header['RecAmpCalibr0'][0]
361 self.RecAmpCalibr0 = header['RecAmpCalibr0'][0]
362 self.RecAmpCalibr1 = header['RecAmpCalibr1'][0]
362 self.RecAmpCalibr1 = header['RecAmpCalibr1'][0]
363 self.RecAmpCalibr2 = header['RecAmpCalibr2'][0]
363 self.RecAmpCalibr2 = header['RecAmpCalibr2'][0]
364 self.ReceiverGaindB0 = header['ReceiverGaindB0'][0]
364 self.ReceiverGaindB0 = header['ReceiverGaindB0'][0]
365 self.ReceiverGaindB1 = header['ReceiverGaindB1'][0]
365 self.ReceiverGaindB1 = header['ReceiverGaindB1'][0]
366 self.ReceiverGaindB2 = header['ReceiverGaindB2'][0]
366 self.ReceiverGaindB2 = header['ReceiverGaindB2'][0]
367
367
368 self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
368 self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
369
369
370 self.RHsize = 180+20*self.nChannels
370 self.RHsize = 180+20*self.nChannels
371 self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
371 self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
372 #print 'Datasize',self.Datasize
372 #print 'Datasize',self.Datasize
373 endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
373 endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
374
374
375 print '=============================================='
375 print '=============================================='
376 print 'RecMgcNumber ',self.RecMgcNumber
376 print 'RecMgcNumber ',self.RecMgcNumber
377 print 'RecCounter ',self.RecCounter
377 print 'RecCounter ',self.RecCounter
378 print 'Off2StartNxtRec ',self.Off2StartNxtRec
378 print 'Off2StartNxtRec ',self.Off2StartNxtRec
379 print 'Off2StartData ',self.Off2StartData
379 print 'Off2StartData ',self.Off2StartData
380 print 'Range Resolution ',self.SampResolution
380 print 'Range Resolution ',self.SampResolution
381 print 'First Height ',self.StartRangeSamp
381 print 'First Height ',self.StartRangeSamp
382 print 'PRF (Hz) ',self.PRFhz
382 print 'PRF (Hz) ',self.PRFhz
383 print 'Heights (K) ',self.nHeights
383 print 'Heights (K) ',self.nHeights
384 print 'Channels (N) ',self.nChannels
384 print 'Channels (N) ',self.nChannels
385 print 'Profiles (J) ',self.nProfiles
385 print 'Profiles (J) ',self.nProfiles
386 print 'iCoh ',self.nCohInt
386 print 'iCoh ',self.nCohInt
387 print 'iInCoh ',self.nIncohInt
387 print 'iInCoh ',self.nIncohInt
388 print 'BeamAngleAzim ',self.BeamAngleAzim
388 print 'BeamAngleAzim ',self.BeamAngleAzim
389 print 'BeamAngleZen ',self.BeamAngleZen
389 print 'BeamAngleZen ',self.BeamAngleZen
390
390
391 #print 'ModoEnUso ',self.DualModeIndex
391 #print 'ModoEnUso ',self.DualModeIndex
392 #print 'UtcTime ',self.nUtime
392 #print 'UtcTime ',self.nUtime
393 #print 'MiliSec ',self.nMilisec
393 #print 'MiliSec ',self.nMilisec
394 #print 'Exp TagName ',self.ExpTagName
394 #print 'Exp TagName ',self.ExpTagName
395 #print 'Exp Comment ',self.ExpComment
395 #print 'Exp Comment ',self.ExpComment
396 #print 'FFT Window Index ',self.FFTwindowingInd
396 #print 'FFT Window Index ',self.FFTwindowingInd
397 #print 'N Dig. Channels ',self.nDigChannels
397 #print 'N Dig. Channels ',self.nDigChannels
398 print 'Size de bloque ',self.RHsize
398 print 'Size de bloque ',self.RHsize
399 print 'DataSize ',self.Datasize
399 print 'DataSize ',self.Datasize
400 print 'BeamAngleAzim ',self.BeamAngleAzim
400 print 'BeamAngleAzim ',self.BeamAngleAzim
401 #print 'AntennaCoord0 ',self.AntennaCoord0
401 #print 'AntennaCoord0 ',self.AntennaCoord0
402 #print 'AntennaAngl0 ',self.AntennaAngl0
402 #print 'AntennaAngl0 ',self.AntennaAngl0
403 #print 'AntennaCoord1 ',self.AntennaCoord1
403 #print 'AntennaCoord1 ',self.AntennaCoord1
404 #print 'AntennaAngl1 ',self.AntennaAngl1
404 #print 'AntennaAngl1 ',self.AntennaAngl1
405 #print 'AntennaCoord2 ',self.AntennaCoord2
405 #print 'AntennaCoord2 ',self.AntennaCoord2
406 #print 'AntennaAngl2 ',self.AntennaAngl2
406 #print 'AntennaAngl2 ',self.AntennaAngl2
407 print 'RecPhaseCalibr0 ',self.RecPhaseCalibr0
407 print 'RecPhaseCalibr0 ',self.RecPhaseCalibr0
408 print 'RecPhaseCalibr1 ',self.RecPhaseCalibr1
408 print 'RecPhaseCalibr1 ',self.RecPhaseCalibr1
409 print 'RecPhaseCalibr2 ',self.RecPhaseCalibr2
409 print 'RecPhaseCalibr2 ',self.RecPhaseCalibr2
410 print 'RecAmpCalibr0 ',self.RecAmpCalibr0
410 print 'RecAmpCalibr0 ',self.RecAmpCalibr0
411 print 'RecAmpCalibr1 ',self.RecAmpCalibr1
411 print 'RecAmpCalibr1 ',self.RecAmpCalibr1
412 print 'RecAmpCalibr2 ',self.RecAmpCalibr2
412 print 'RecAmpCalibr2 ',self.RecAmpCalibr2
413 print 'ReceiverGaindB0 ',self.ReceiverGaindB0
413 print 'ReceiverGaindB0 ',self.ReceiverGaindB0
414 print 'ReceiverGaindB1 ',self.ReceiverGaindB1
414 print 'ReceiverGaindB1 ',self.ReceiverGaindB1
415 print 'ReceiverGaindB2 ',self.ReceiverGaindB2
415 print 'ReceiverGaindB2 ',self.ReceiverGaindB2
416 print '=============================================='
416 print '=============================================='
417
417
418 if OffRHeader > endFp:
418 if OffRHeader > endFp:
419 sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp)
419 sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp)
420 return 0
420 return 0
421
421
422 if OffRHeader < endFp:
422 if OffRHeader < endFp:
423 sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp)
423 sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp)
424 return 0
424 return 0
425
425
426 return 1
426 return 1
427
427
428
428
429 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODataReader):
429 class BLTRSpectraReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODataReader):
430
430
431 path = None
431 path = None
432 startDate = None
432 startDate = None
433 endDate = None
433 endDate = None
434 startTime = None
434 startTime = None
435 endTime = None
435 endTime = None
436 walk = None
436 walk = None
437 isConfig = False
437 isConfig = False
438
438
439
439
440 fileList= None
440 fileList= None
441
441
442 #metadata
442 #metadata
443 TimeZone= None
443 TimeZone= None
444 Interval= None
444 Interval= None
445 heightList= None
445 heightList= None
446
446
447 #data
447 #data
448 data= None
448 data= None
449 utctime= None
449 utctime= None
450
450
451
451
452
452
453 def __init__(self, **kwargs):
453 def __init__(self, **kwargs):
454
454
455 #Eliminar de la base la herencia
455 #Eliminar de la base la herencia
456 ProcessingUnit.__init__(self, **kwargs)
456 ProcessingUnit.__init__(self, **kwargs)
457
457
458 #self.isConfig = False
458 #self.isConfig = False
459
459
460 #self.pts2read_SelfSpectra = 0
460 #self.pts2read_SelfSpectra = 0
461 #self.pts2read_CrossSpectra = 0
461 #self.pts2read_CrossSpectra = 0
462 #self.pts2read_DCchannels = 0
462 #self.pts2read_DCchannels = 0
463 #self.datablock = None
463 #self.datablock = None
464 self.utc = None
464 self.utc = None
465 self.ext = ".fdt"
465 self.ext = ".fdt"
466 self.optchar = "P"
466 self.optchar = "P"
467 self.fpFile=None
467 self.fpFile=None
468 self.fp = None
468 self.fp = None
469 self.BlockCounter=0
469 self.BlockCounter=0
470 self.dtype = None
470 self.dtype = None
471 self.fileSizeByHeader = None
471 self.fileSizeByHeader = None
472 self.filenameList = []
472 self.filenameList = []
473 self.fileSelector = 0
473 self.fileSelector = 0
474 self.Off2StartNxtRec=0
474 self.Off2StartNxtRec=0
475 self.RecCounter=0
475 self.RecCounter=0
476 self.flagNoMoreFiles = 0
476 self.flagNoMoreFiles = 0
477 self.data_spc=None
477 self.data_spc=None
478 self.data_cspc=None
478 self.data_cspc=None
479 self.data_output=None
479 self.data_output=None
480 self.path = None
480 self.path = None
481 self.OffsetStartHeader=0
481 self.OffsetStartHeader=0
482 self.Off2StartData=0
482 self.Off2StartData=0
483 self.ipp = 0
483 self.ipp = 0
484 self.nFDTdataRecors=0
484 self.nFDTdataRecors=0
485 self.blocksize = 0
485 self.blocksize = 0
486 self.dataOut = Spectra()
486 self.dataOut = Spectra()
487 self.profileIndex = 1 #Always
487 self.profileIndex = 1 #Always
488 self.dataOut.flagNoData=False
488 self.dataOut.flagNoData=False
489 self.dataOut.nRdPairs = 0
489 self.dataOut.nRdPairs = 0
490 self.dataOut.pairsList = []
490 self.dataOut.pairsList = []
491 self.dataOut.data_spc=None
491 self.dataOut.data_spc=None
492 self.dataOut.noise=[]
492 self.dataOut.noise=[]
493 self.dataOut.velocityX=[]
493 self.dataOut.velocityX=[]
494 self.dataOut.velocityY=[]
494 self.dataOut.velocityY=[]
495 self.dataOut.velocityV=[]
495 self.dataOut.velocityV=[]
496
496
497
497
498
498
499 def Files2Read(self, fp):
499 def Files2Read(self, fp):
500 '''
500 '''
501 Function that indicates the number of .fdt files that exist in the folder to be read.
501 Function that indicates the number of .fdt files that exist in the folder to be read.
502 It also creates an organized list with the names of the files to read.
502 It also creates an organized list with the names of the files to read.
503 '''
503 '''
504 #self.__checkPath()
504 #self.__checkPath()
505
505
506 ListaData=os.listdir(fp) #Gets the list of files within the fp address
506 ListaData=os.listdir(fp) #Gets the list of files within the fp address
507 ListaData=sorted(ListaData) #Sort the list of files from least to largest by names
507 ListaData=sorted(ListaData) #Sort the list of files from least to largest by names
508 nFiles=0 #File Counter
508 nFiles=0 #File Counter
509 FileList=[] #A list is created that will contain the .fdt files
509 FileList=[] #A list is created that will contain the .fdt files
510 for IndexFile in ListaData :
510 for IndexFile in ListaData :
511 if '.fdt' in IndexFile:
511 if '.fdt' in IndexFile:
512 FileList.append(IndexFile)
512 FileList.append(IndexFile)
513 nFiles+=1
513 nFiles+=1
514
514
515 #print 'Files2Read'
515 #print 'Files2Read'
516 #print 'Existen '+str(nFiles)+' archivos .fdt'
516 #print 'Existen '+str(nFiles)+' archivos .fdt'
517
517
518 self.filenameList=FileList #List of files from least to largest by names
518 self.filenameList=FileList #List of files from least to largest by names
519
519
520
520
521 def run(self, **kwargs):
521 def run(self, **kwargs):
522 '''
522 '''
523 This method will be the one that will initiate the data entry, will be called constantly.
523 This method will be the one that will initiate the data entry, will be called constantly.
524 You should first verify that your Setup () is set up and then continue to acquire
524 You should first verify that your Setup () is set up and then continue to acquire
525 the data to be processed with getData ().
525 the data to be processed with getData ().
526 '''
526 '''
527 if not self.isConfig:
527 if not self.isConfig:
528 self.setup(**kwargs)
528 self.setup(**kwargs)
529 self.isConfig = True
529 self.isConfig = True
530
530
531 self.getData()
531 self.getData()
532 #print 'running'
532 #print 'running'
533
533
534
534
535 def setup(self, path=None,
535 def setup(self, path=None,
536 startDate=None,
536 startDate=None,
537 endDate=None,
537 endDate=None,
538 startTime=None,
538 startTime=None,
539 endTime=None,
539 endTime=None,
540 walk=True,
540 walk=True,
541 timezone='utc',
541 timezone='utc',
542 code = None,
542 code = None,
543 online=False,
543 online=False,
544 ReadMode=None,
544 ReadMode=None,
545 **kwargs):
545 **kwargs):
546
546
547 self.isConfig = True
547 self.isConfig = True
548
548
549 self.path=path
549 self.path=path
550 self.startDate=startDate
550 self.startDate=startDate
551 self.endDate=endDate
551 self.endDate=endDate
552 self.startTime=startTime
552 self.startTime=startTime
553 self.endTime=endTime
553 self.endTime=endTime
554 self.walk=walk
554 self.walk=walk
555 self.ReadMode=int(ReadMode)
555 self.ReadMode=int(ReadMode)
556
556
557 pass
557 pass
558
558
559
559
560 def getData(self):
560 def getData(self):
561 '''
561 '''
562 Before starting this function, you should check that there is still an unread file,
562 Before starting this function, you should check that there is still an unread file,
563 If there are still blocks to read or if the data block is empty.
563 If there are still blocks to read or if the data block is empty.
564
564
565 You should call the file "read".
565 You should call the file "read".
566
566
567 '''
567 '''
568
568
569 if self.flagNoMoreFiles:
569 if self.flagNoMoreFiles:
570 self.dataOut.flagNoData = True
570 self.dataOut.flagNoData = True
571 print 'NoData se vuelve true'
571 #print 'NoData se vuelve true'
572 return 0
572 return 0
573
573
574 self.fp=self.path
574 self.fp=self.path
575 self.Files2Read(self.fp)
575 self.Files2Read(self.fp)
576 self.readFile(self.fp)
576 self.readFile(self.fp)
577 self.dataOut.data_spc = self.data_spc
577 self.dataOut.data_spc = self.data_spc
578 self.dataOut.data_cspc =self.data_cspc
578 self.dataOut.data_cspc =self.data_cspc
579 self.dataOut.data_output=self.data_output
579 self.dataOut.data_output=self.data_output
580
580
581 print 'self.dataOut.data_output', shape(self.dataOut.data_output)
581 #print 'self.dataOut.data_output', shape(self.dataOut.data_output)
582
582
583 #self.removeDC()
583 #self.removeDC()
584 return self.dataOut.data_spc
584 return self.dataOut.data_spc
585
585
586
586
587 def readFile(self,fp):
587 def readFile(self,fp):
588 '''
588 '''
589 You must indicate if you are reading in Online or Offline mode and load the
589 You must indicate if you are reading in Online or Offline mode and load the
590 The parameters for this file reading mode.
590 The parameters for this file reading mode.
591
591
592 Then you must do 2 actions:
592 Then you must do 2 actions:
593
593
594 1. Get the BLTR FileHeader.
594 1. Get the BLTR FileHeader.
595 2. Start reading the first block.
595 2. Start reading the first block.
596 '''
596 '''
597
597
598 #The address of the folder is generated the name of the .fdt file that will be read
598 #The address of the folder is generated the name of the .fdt file that will be read
599 print "File: ",self.fileSelector+1
599 #print "File: ",self.fileSelector+1
600
600
601 if self.fileSelector < len(self.filenameList):
601 if self.fileSelector < len(self.filenameList):
602
602
603 self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
603 self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
604 #print self.fpFile
604 #print self.fpFile
605 fheader = FileHeaderBLTR()
605 fheader = FileHeaderBLTR()
606 fheader.FHread(self.fpFile) #Bltr FileHeader Reading
606 fheader.FHread(self.fpFile) #Bltr FileHeader Reading
607 self.nFDTdataRecors=fheader.nFDTdataRecors
607 self.nFDTdataRecors=fheader.nFDTdataRecors
608
608
609 self.readBlock() #Block reading
609 self.readBlock() #Block reading
610 else:
610 else:
611 print 'readFile FlagNoData becomes true'
611 #print 'readFile FlagNoData becomes true'
612 self.flagNoMoreFiles=True
612 self.flagNoMoreFiles=True
613 self.dataOut.flagNoData = True
613 self.dataOut.flagNoData = True
614 return 0
614 return 0
615
615
616 def getVelRange(self, extrapoints=0):
616 def getVelRange(self, extrapoints=0):
617 Lambda= SPEED_OF_LIGHT/50000000
617 Lambda= SPEED_OF_LIGHT/50000000
618 PRF = self.dataOut.PRF#1./(self.dataOut.ippSeconds * self.dataOut.nCohInt)
618 PRF = self.dataOut.PRF#1./(self.dataOut.ippSeconds * self.dataOut.nCohInt)
619 Vmax=-Lambda/(4.*(1./PRF)*self.dataOut.nCohInt*2.)
619 Vmax=-Lambda/(4.*(1./PRF)*self.dataOut.nCohInt*2.)
620 deltafreq = PRF / (self.nProfiles)
620 deltafreq = PRF / (self.nProfiles)
621 deltavel = (Vmax*2) / (self.nProfiles)
621 deltavel = (Vmax*2) / (self.nProfiles)
622 freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2
622 freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2
623 velrange = deltavel*(numpy.arange(self.nProfiles)-self.nProfiles/2.)
623 velrange = deltavel*(numpy.arange(self.nProfiles)-self.nProfiles/2.)
624 return velrange
624 return velrange
625
625
626 def readBlock(self):
626 def readBlock(self):
627 '''
627 '''
628 It should be checked if the block has data, if it is not passed to the next file.
628 It should be checked if the block has data, if it is not passed to the next file.
629
629
630 Then the following is done:
630 Then the following is done:
631
631
632 1. Read the RecordHeader
632 1. Read the RecordHeader
633 2. Fill the buffer with the current block number.
633 2. Fill the buffer with the current block number.
634
634
635 '''
635 '''
636
636
637 if self.BlockCounter < self.nFDTdataRecors-2:
637 if self.BlockCounter < self.nFDTdataRecors-1:
638 print self.nFDTdataRecors, 'CONDICION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
638 #print self.nFDTdataRecors, 'CONDICION'
639 if self.ReadMode==1:
639 if self.ReadMode==1:
640 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter+1)
640 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter+1)
641 elif self.ReadMode==0:
641 elif self.ReadMode==0:
642 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter)
642 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter)
643
643
644 rheader.RHread(self.fpFile) #Bltr FileHeader Reading
644 rheader.RHread(self.fpFile) #Bltr FileHeader Reading
645
645
646 self.OffsetStartHeader=rheader.OffsetStartHeader
646 self.OffsetStartHeader=rheader.OffsetStartHeader
647 self.RecCounter=rheader.RecCounter
647 self.RecCounter=rheader.RecCounter
648 self.Off2StartNxtRec=rheader.Off2StartNxtRec
648 self.Off2StartNxtRec=rheader.Off2StartNxtRec
649 self.Off2StartData=rheader.Off2StartData
649 self.Off2StartData=rheader.Off2StartData
650 self.nProfiles=rheader.nProfiles
650 self.nProfiles=rheader.nProfiles
651 self.nChannels=rheader.nChannels
651 self.nChannels=rheader.nChannels
652 self.nHeights=rheader.nHeights
652 self.nHeights=rheader.nHeights
653 self.frequency=rheader.TransmitFrec
653 self.frequency=rheader.TransmitFrec
654 self.DualModeIndex=rheader.DualModeIndex
654 self.DualModeIndex=rheader.DualModeIndex
655
655
656 self.pairsList =[(0,1),(0,2),(1,2)]
656 self.pairsList =[(0,1),(0,2),(1,2)]
657 self.dataOut.pairsList = self.pairsList
657 self.dataOut.pairsList = self.pairsList
658
658
659 self.nRdPairs=len(self.dataOut.pairsList)
659 self.nRdPairs=len(self.dataOut.pairsList)
660 self.dataOut.nRdPairs = self.nRdPairs
660 self.dataOut.nRdPairs = self.nRdPairs
661
661
662 self.__firstHeigth=rheader.StartRangeSamp
662 self.__firstHeigth=rheader.StartRangeSamp
663 self.__deltaHeigth=rheader.SampResolution
663 self.__deltaHeigth=rheader.SampResolution
664 self.dataOut.heightList= self.__firstHeigth + numpy.array(range(self.nHeights))*self.__deltaHeigth
664 self.dataOut.heightList= self.__firstHeigth + numpy.array(range(self.nHeights))*self.__deltaHeigth
665 self.dataOut.channelList = range(self.nChannels)
665 self.dataOut.channelList = range(self.nChannels)
666 self.dataOut.nProfiles=rheader.nProfiles
666 self.dataOut.nProfiles=rheader.nProfiles
667 self.dataOut.nIncohInt=rheader.nIncohInt
667 self.dataOut.nIncohInt=rheader.nIncohInt
668 self.dataOut.nCohInt=rheader.nCohInt
668 self.dataOut.nCohInt=rheader.nCohInt
669 self.dataOut.ippSeconds= 1/float(rheader.PRFhz)
669 self.dataOut.ippSeconds= 1/float(rheader.PRFhz)
670 self.dataOut.PRF=rheader.PRFhz
670 self.dataOut.PRF=rheader.PRFhz
671 self.dataOut.nFFTPoints=rheader.nProfiles
671 self.dataOut.nFFTPoints=rheader.nProfiles
672 self.dataOut.utctime=rheader.nUtime
672 self.dataOut.utctime=rheader.nUtime
673 self.dataOut.timeZone=0
673 self.dataOut.timeZone=0
674 self.dataOut.normFactor= self.dataOut.nProfiles*self.dataOut.nIncohInt*self.dataOut.nCohInt
674 self.dataOut.normFactor= self.dataOut.nProfiles*self.dataOut.nIncohInt*self.dataOut.nCohInt
675 self.dataOut.outputInterval= self.dataOut.ippSeconds * self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles
675 self.dataOut.outputInterval= self.dataOut.ippSeconds * self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles
676
676
677 self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN
677 self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN
678 print 'self.data_output', shape(self.data_output)
678 #print 'self.data_output', shape(self.data_output)
679 self.dataOut.velocityX=[]
679 self.dataOut.velocityX=[]
680 self.dataOut.velocityY=[]
680 self.dataOut.velocityY=[]
681 self.dataOut.velocityV=[]
681 self.dataOut.velocityV=[]
682
682
683 '''Block Reading, the Block Data is received and Reshape is used to give it
683 '''Block Reading, the Block Data is received and Reshape is used to give it
684 shape.
684 shape.
685 '''
685 '''
686
686
687 #Procedure to take the pointer to where the date block starts
687 #Procedure to take the pointer to where the date block starts
688 startDATA = open(self.fpFile,"rb")
688 startDATA = open(self.fpFile,"rb")
689 OffDATA= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec+self.Off2StartData
689 OffDATA= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec+self.Off2StartData
690 startDATA.seek(OffDATA, os.SEEK_SET)
690 startDATA.seek(OffDATA, os.SEEK_SET)
691
691
692 def moving_average(x, N=2):
692 def moving_average(x, N=2):
693 return numpy.convolve(x, numpy.ones((N,))/N)[(N-1):]
693 return numpy.convolve(x, numpy.ones((N,))/N)[(N-1):]
694
694
695 def gaus(xSamples,a,x0,sigma):
695 def gaus(xSamples,a,x0,sigma):
696 return a*exp(-(xSamples-x0)**2/(2*sigma**2))
696 return a*exp(-(xSamples-x0)**2/(2*sigma**2))
697
697
698 def Find(x,value):
698 def Find(x,value):
699 for index in range(len(x)):
699 for index in range(len(x)):
700 if x[index]==value:
700 if x[index]==value:
701 return index
701 return index
702
702
703 def pol2cart(rho, phi):
703 def pol2cart(rho, phi):
704 x = rho * numpy.cos(phi)
704 x = rho * numpy.cos(phi)
705 y = rho * numpy.sin(phi)
705 y = rho * numpy.sin(phi)
706 return(x, y)
706 return(x, y)
707
707
708
708
709
709
710
710
711 if self.DualModeIndex==self.ReadMode:
711 if self.DualModeIndex==self.ReadMode:
712
712
713 self.data_fft = numpy.fromfile( startDATA, [('complex','<c8')],self.nProfiles*self.nChannels*self.nHeights )
713 self.data_fft = numpy.fromfile( startDATA, [('complex','<c8')],self.nProfiles*self.nChannels*self.nHeights )
714 #
715 # if len(self.data_fft) is not 101376:
716 #
717 # self.data_fft = numpy.empty(101376)
714
718
715 self.data_fft=self.data_fft.astype(numpy.dtype('complex'))
719 self.data_fft=self.data_fft.astype(numpy.dtype('complex'))
716
720
721
722
723
724
717 self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles ))
725 self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles ))
718
726
719 self.data_block = numpy.transpose(self.data_block, (1,2,0))
727 self.data_block = numpy.transpose(self.data_block, (1,2,0))
720
728
721 copy = self.data_block.copy()
729 copy = self.data_block.copy()
722 spc = copy * numpy.conjugate(copy)
730 spc = copy * numpy.conjugate(copy)
723
731
724 self.data_spc = numpy.absolute(spc) # valor absoluto o magnitud
732 self.data_spc = numpy.absolute(spc) # valor absoluto o magnitud
725
733
726 factor = self.dataOut.normFactor
734 factor = self.dataOut.normFactor
727
735
728
736
729 z = self.data_spc.copy()#/factor
737 z = self.data_spc.copy()#/factor
730 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
738 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
731 #zdB = 10*numpy.log10(z)
739 #zdB = 10*numpy.log10(z)
732 print ' '
740
733 print 'Z: '
734 print shape(z)
735 print ' '
736 print ' '
737
741
738 self.dataOut.data_spc=self.data_spc
742 self.dataOut.data_spc=self.data_spc
739
743
740 self.noise = self.dataOut.getNoise(ymin_index=80, ymax_index=132)#/factor
744 self.noise = self.dataOut.getNoise(ymin_index=80, ymax_index=132)#/factor
741 #noisedB = 10*numpy.log10(self.noise)
745 #noisedB = 10*numpy.log10(self.noise)
742
746
743
747
744 ySamples=numpy.ones([3,self.nProfiles])
748 ySamples=numpy.ones([3,self.nProfiles])
745 phase=numpy.ones([3,self.nProfiles])
749 phase=numpy.ones([3,self.nProfiles])
746 CSPCSamples=numpy.ones([3,self.nProfiles],dtype=numpy.complex_)
750 CSPCSamples=numpy.ones([3,self.nProfiles],dtype=numpy.complex_)
747 coherence=numpy.ones([3,self.nProfiles])
751 coherence=numpy.ones([3,self.nProfiles])
748 PhaseSlope=numpy.ones(3)
752 PhaseSlope=numpy.ones(3)
749 PhaseInter=numpy.ones(3)
753 PhaseInter=numpy.ones(3)
750
754
751 '''****** Getting CrossSpectra ******'''
755 '''****** Getting CrossSpectra ******'''
752 cspc=self.data_block.copy()
756 cspc=self.data_block.copy()
753 self.data_cspc=self.data_block.copy()
757 self.data_cspc=self.data_block.copy()
754
758
755 xFrec=self.getVelRange(1)
759 xFrec=self.getVelRange(1)
756 VelRange=self.getVelRange(1)
760 VelRange=self.getVelRange(1)
757 self.dataOut.VelRange=VelRange
761 self.dataOut.VelRange=VelRange
758 #print ' '
762 #print ' '
759 #print ' '
763 #print ' '
760 #print 'xFrec',xFrec
764 #print 'xFrec',xFrec
761 #print ' '
765 #print ' '
762 #print ' '
766 #print ' '
763 #Height=35
767 #Height=35
764
768
765 for i in range(self.nRdPairs):
769 for i in range(self.nRdPairs):
766
770
767 chan_index0 = self.dataOut.pairsList[i][0]
771 chan_index0 = self.dataOut.pairsList[i][0]
768 chan_index1 = self.dataOut.pairsList[i][1]
772 chan_index1 = self.dataOut.pairsList[i][1]
769
773
770 self.data_cspc[i,:,:]=cspc[chan_index0,:,:] * numpy.conjugate(cspc[chan_index1,:,:])
774 self.data_cspc[i,:,:]=cspc[chan_index0,:,:] * numpy.conjugate(cspc[chan_index1,:,:])
771
775
772
776
773 '''Getting Eij and Nij'''
777 '''Getting Eij and Nij'''
774 (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
778 (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
775 (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
779 (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
776 (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
780 (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
777
781
778 E01=AntennaX0-AntennaX1
782 E01=AntennaX0-AntennaX1
779 N01=AntennaY0-AntennaY1
783 N01=AntennaY0-AntennaY1
780
784
781 E02=AntennaX0-AntennaX2
785 E02=AntennaX0-AntennaX2
782 N02=AntennaY0-AntennaY2
786 N02=AntennaY0-AntennaY2
783
787
784 E12=AntennaX1-AntennaX2
788 E12=AntennaX1-AntennaX2
785 N12=AntennaY1-AntennaY2
789 N12=AntennaY1-AntennaY2
786
790
787 self.ChanDist= numpy.array([[E01, N01],[E02,N02],[E12,N12]])
791 self.ChanDist= numpy.array([[E01, N01],[E02,N02],[E12,N12]])
788
792
789 self.dataOut.ChanDist = self.ChanDist
793 self.dataOut.ChanDist = self.ChanDist
790
794
791
795
792 # for Height in range(self.nHeights):
793 #
794 # for i in range(self.nRdPairs):
795 #
796 # '''****** Line of Data SPC ******'''
797 # zline=z[i,:,Height]
798 #
799 # '''****** DC is removed ******'''
800 # DC=Find(zline,numpy.amax(zline))
801 # zline[DC]=(zline[DC-1]+zline[DC+1])/2
802 #
803 #
804 # '''****** SPC is normalized ******'''
805 # FactNorm= zline.copy() / numpy.sum(zline.copy())
806 # FactNorm= FactNorm/numpy.sum(FactNorm)
807 #
808 # SmoothSPC=moving_average(FactNorm,N=3)
809 #
810 # xSamples = ar(range(len(SmoothSPC)))
811 # ySamples[i] = SmoothSPC-self.noise[i]
812 #
813 # for i in range(self.nRdPairs):
814 #
815 # '''****** Line of Data CSPC ******'''
816 # cspcLine=self.data_cspc[i,:,Height].copy()
817 #
818 #
819 #
820 # '''****** CSPC is normalized ******'''
821 # chan_index0 = self.dataOut.pairsList[i][0]
822 # chan_index1 = self.dataOut.pairsList[i][1]
823 # CSPCFactor= numpy.sum(ySamples[chan_index0]) * numpy.sum(ySamples[chan_index1])
824 #
825 #
826 # CSPCNorm= cspcLine.copy() / numpy.sqrt(CSPCFactor)
827 #
828 #
829 # CSPCSamples[i] = CSPCNorm-self.noise[i]
830 # coherence[i] = numpy.abs(CSPCSamples[i]) / numpy.sqrt(CSPCFactor)
831 #
832 # '''****** DC is removed ******'''
833 # DC=Find(coherence[i],numpy.amax(coherence[i]))
834 # coherence[i][DC]=(coherence[i][DC-1]+coherence[i][DC+1])/2
835 # coherence[i]= moving_average(coherence[i],N=2)
836 #
837 # phase[i] = moving_average( numpy.arctan2(CSPCSamples[i].imag, CSPCSamples[i].real),N=1)#*180/numpy.pi
838 #
839 #
840 # '''****** Getting fij width ******'''
841 #
842 # yMean=[]
843 # yMean2=[]
844 #
845 # for j in range(len(ySamples[1])):
846 # yMean=numpy.append(yMean,numpy.average([ySamples[0,j],ySamples[1,j],ySamples[2,j]]))
847 #
848 # '''******* Getting fitting Gaussian ******'''
849 # meanGauss=sum(xSamples*yMean) / len(xSamples)
850 # sigma=sum(yMean*(xSamples-meanGauss)**2) / len(xSamples)
851 # #print 'Height',Height,'SNR', meanGauss/sigma**2
852 #
853 # if (abs(meanGauss/sigma**2) > 0.0001) :
854 #
855 # try:
856 # popt,pcov = curve_fit(gaus,xSamples,yMean,p0=[1,meanGauss,sigma])
857 #
858 # if numpy.amax(popt)>numpy.amax(yMean)*0.3:
859 # FitGauss=gaus(xSamples,*popt)
860 #
861 # else:
862 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
863 # print 'Verificador: Dentro', Height
864 # except RuntimeError:
865 #
866 # try:
867 # for j in range(len(ySamples[1])):
868 # yMean2=numpy.append(yMean2,numpy.average([ySamples[1,j],ySamples[2,j]]))
869 # popt,pcov = curve_fit(gaus,xSamples,yMean2,p0=[1,meanGauss,sigma])
870 # FitGauss=gaus(xSamples,*popt)
871 # print 'Verificador: Exepcion1', Height
872 # except RuntimeError:
873 #
874 # try:
875 # popt,pcov = curve_fit(gaus,xSamples,ySamples[1],p0=[1,meanGauss,sigma])
876 # FitGauss=gaus(xSamples,*popt)
877 # print 'Verificador: Exepcion2', Height
878 # except RuntimeError:
879 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
880 # print 'Verificador: Exepcion3', Height
881 # else:
882 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
883 # #print 'Verificador: Fuera', Height
884 #
885 #
886 #
887 # Maximun=numpy.amax(yMean)
888 # eMinus1=Maximun*numpy.exp(-1)
889 #
890 # HWpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-eMinus1)))
891 # HalfWidth= xFrec[HWpos]
892 # GCpos=Find(FitGauss, numpy.amax(FitGauss))
893 # Vpos=Find(FactNorm, numpy.amax(FactNorm))
894 # #Vpos=numpy.sum(FactNorm)/len(FactNorm)
895 # #Vpos=Find(FactNorm, min(FactNorm, key=lambda value:abs(value- numpy.mean(FactNorm) )))
896 # #print 'GCpos',GCpos, numpy.amax(FitGauss), 'HWpos',HWpos
897 # '''****** Getting Fij ******'''
898 #
899 # GaussCenter=xFrec[GCpos]
900 # if (GaussCenter<0 and HalfWidth>0) or (GaussCenter>0 and HalfWidth<0):
901 # Fij=abs(GaussCenter)+abs(HalfWidth)+0.0000001
902 # else:
903 # Fij=abs(GaussCenter-HalfWidth)+0.0000001
904 #
905 # '''****** Getting Frecuency range of significant data ******'''
906 #
907 # Rangpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.10)))
908 #
909 # if Rangpos<GCpos:
910 # Range=numpy.array([Rangpos,2*GCpos-Rangpos])
911 # else:
912 # Range=numpy.array([2*GCpos-Rangpos,Rangpos])
913 #
914 # FrecRange=xFrec[Range[0]:Range[1]]
915 #
916 # #print 'FrecRange', FrecRange
917 # '''****** Getting SCPC Slope ******'''
918 #
919 # for i in range(self.nRdPairs):
920 #
921 # if len(FrecRange)>5 and len(FrecRange)<self.nProfiles*0.5:
922 # PhaseRange=moving_average(phase[i,Range[0]:Range[1]],N=3)
923 #
924 # slope, intercept, r_value, p_value, std_err = stats.linregress(FrecRange,PhaseRange)
925 # PhaseSlope[i]=slope
926 # PhaseInter[i]=intercept
927 # else:
928 # PhaseSlope[i]=0
929 # PhaseInter[i]=0
930 #
931 # # plt.figure(i+15)
932 # # plt.title('FASE ( CH%s*CH%s )' %(self.dataOut.pairsList[i][0],self.dataOut.pairsList[i][1]))
933 # # plt.xlabel('Frecuencia (KHz)')
934 # # plt.ylabel('Magnitud')
935 # # #plt.subplot(311+i)
936 # # plt.plot(FrecRange,PhaseRange,'b')
937 # # plt.plot(FrecRange,FrecRange*PhaseSlope[i]+PhaseInter[i],'r')
938 #
939 # #plt.axis([-0.6, 0.2, -3.2, 3.2])
940 #
941 #
942 # '''Getting constant C'''
943 # cC=(Fij*numpy.pi)**2
944 #
945 # # '''Getting Eij and Nij'''
946 # # (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
947 # # (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
948 # # (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
949 # #
950 # # E01=AntennaX0-AntennaX1
951 # # N01=AntennaY0-AntennaY1
952 # #
953 # # E02=AntennaX0-AntennaX2
954 # # N02=AntennaY0-AntennaY2
955 # #
956 # # E12=AntennaX1-AntennaX2
957 # # N12=AntennaY1-AntennaY2
958 #
959 # '''****** Getting constants F and G ******'''
960 # MijEijNij=numpy.array([[E02,N02], [E12,N12]])
961 # MijResult0=(-PhaseSlope[1]*cC) / (2*numpy.pi)
962 # MijResult1=(-PhaseSlope[2]*cC) / (2*numpy.pi)
963 # MijResults=numpy.array([MijResult0,MijResult1])
964 # (cF,cG) = numpy.linalg.solve(MijEijNij, MijResults)
965 #
966 # '''****** Getting constants A, B and H ******'''
967 # W01=numpy.amax(coherence[0])
968 # W02=numpy.amax(coherence[1])
969 # W12=numpy.amax(coherence[2])
970 #
971 # WijResult0=((cF*E01+cG*N01)**2)/cC - numpy.log(W01 / numpy.sqrt(numpy.pi/cC))
972 # WijResult1=((cF*E02+cG*N02)**2)/cC - numpy.log(W02 / numpy.sqrt(numpy.pi/cC))
973 # WijResult2=((cF*E12+cG*N12)**2)/cC - numpy.log(W12 / numpy.sqrt(numpy.pi/cC))
974 #
975 # WijResults=numpy.array([WijResult0, WijResult1, WijResult2])
976 #
977 # WijEijNij=numpy.array([ [E01**2, N01**2, 2*E01*N01] , [E02**2, N02**2, 2*E02*N02] , [E12**2, N12**2, 2*E12*N12] ])
978 # (cA,cB,cH) = numpy.linalg.solve(WijEijNij, WijResults)
979 #
980 # VxVy=numpy.array([[cA,cH],[cH,cB]])
981 #
982 # VxVyResults=numpy.array([-cF,-cG])
983 # (Vx,Vy) = numpy.linalg.solve(VxVy, VxVyResults)
984 # Vzon = Vy
985 # Vmer = Vx
986 # Vmag=numpy.sqrt(Vzon**2+Vmer**2)
987 # Vang=numpy.arctan2(Vmer,Vzon)
988 #
989 # if abs(Vy)<100 and abs(Vy)> 0.:
990 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, Vzon) #Vmag
991 # #print 'Vmag',Vmag
992 # else:
993 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, NaN)
994 #
995 # if abs(Vx)<100 and abs(Vx) > 0.:
996 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, Vmer) #Vang
997 # #print 'Vang',Vang
998 # else:
999 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, NaN)
1000 #
1001 # if abs(GaussCenter)<2:
1002 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, xFrec[Vpos])
1003 #
1004 # else:
1005 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, NaN)
1006 #
1007 #
1008 # # print '********************************************'
1009 # # print 'HalfWidth ', HalfWidth
1010 # # print 'Maximun ', Maximun
1011 # # print 'eMinus1 ', eMinus1
1012 # # print 'Rangpos ', Rangpos
1013 # # print 'GaussCenter ',GaussCenter
1014 # # print 'E01 ',E01
1015 # # print 'N01 ',N01
1016 # # print 'E02 ',E02
1017 # # print 'N02 ',N02
1018 # # print 'E12 ',E12
1019 # # print 'N12 ',N12
1020 # #print 'self.dataOut.velocityX ', self.dataOut.velocityX
1021 # # print 'Fij ', Fij
1022 # # print 'cC ', cC
1023 # # print 'cF ', cF
1024 # # print 'cG ', cG
1025 # # print 'cA ', cA
1026 # # print 'cB ', cB
1027 # # print 'cH ', cH
1028 # # print 'Vx ', Vx
1029 # # print 'Vy ', Vy
1030 # # print 'Vmag ', Vmag
1031 # # print 'Vang ', Vang*180/numpy.pi
1032 # # print 'PhaseSlope ',PhaseSlope[0]
1033 # # print 'PhaseSlope ',PhaseSlope[1]
1034 # # print 'PhaseSlope ',PhaseSlope[2]
1035 # # print '********************************************'
1036 # #print 'data_output',shape(self.dataOut.velocityX), shape(self.dataOut.velocityY)
1037 #
1038 # #print 'self.dataOut.velocityX', len(self.dataOut.velocityX)
1039 # #print 'self.dataOut.velocityY', len(self.dataOut.velocityY)
1040 # #print 'self.dataOut.velocityV', self.dataOut.velocityV
1041 #
1042 # self.data_output[0]=numpy.array(self.dataOut.velocityX)
1043 # self.data_output[1]=numpy.array(self.dataOut.velocityY)
1044 # self.data_output[2]=numpy.array(self.dataOut.velocityV)
1045 #
1046 # prin= self.data_output[0][~numpy.isnan(self.data_output[0])]
1047 # print ' '
1048 # print 'VmagAverage',numpy.mean(prin)
1049 # print ' '
1050 # # plt.figure(5)
1051 # # plt.subplot(211)
1052 # # plt.plot(self.dataOut.velocityX,'yo:')
1053 # # plt.subplot(212)
1054 # # plt.plot(self.dataOut.velocityY,'yo:')
1055 #
1056 # # plt.figure(1)
1057 # # # plt.subplot(121)
1058 # # # plt.plot(xFrec,ySamples[0],'k',label='Ch0')
1059 # # # plt.plot(xFrec,ySamples[1],'g',label='Ch1')
1060 # # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1061 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1062 # # # plt.legend()
1063 # # plt.title('DATOS A ALTURA DE 2850 METROS')
1064 # #
1065 # # plt.xlabel('Frecuencia (KHz)')
1066 # # plt.ylabel('Magnitud')
1067 # # # plt.subplot(122)
1068 # # # plt.title('Fit for Time Constant')
1069 # # #plt.plot(xFrec,zline)
1070 # # #plt.plot(xFrec,SmoothSPC,'g')
1071 # # plt.plot(xFrec,FactNorm)
1072 # # plt.axis([-4, 4, 0, 0.15])
1073 # # # plt.xlabel('SelfSpectra KHz')
1074 # #
1075 # # plt.figure(10)
1076 # # # plt.subplot(121)
1077 # # plt.plot(xFrec,ySamples[0],'b',label='Ch0')
1078 # # plt.plot(xFrec,ySamples[1],'y',label='Ch1')
1079 # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1080 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1081 # # plt.legend()
1082 # # plt.title('SELFSPECTRA EN CANALES')
1083 # #
1084 # # plt.xlabel('Frecuencia (KHz)')
1085 # # plt.ylabel('Magnitud')
1086 # # # plt.subplot(122)
1087 # # # plt.title('Fit for Time Constant')
1088 # # #plt.plot(xFrec,zline)
1089 # # #plt.plot(xFrec,SmoothSPC,'g')
1090 # # # plt.plot(xFrec,FactNorm)
1091 # # # plt.axis([-4, 4, 0, 0.15])
1092 # # # plt.xlabel('SelfSpectra KHz')
1093 # #
1094 # # plt.figure(9)
1095 # #
1096 # #
1097 # # plt.title('DATOS SUAVIZADOS')
1098 # # plt.xlabel('Frecuencia (KHz)')
1099 # # plt.ylabel('Magnitud')
1100 # # plt.plot(xFrec,SmoothSPC,'g')
1101 # #
1102 # # #plt.plot(xFrec,FactNorm)
1103 # # plt.axis([-4, 4, 0, 0.15])
1104 # # # plt.xlabel('SelfSpectra KHz')
1105 # # #
1106 # # plt.figure(2)
1107 # # # #plt.subplot(121)
1108 # # plt.plot(xFrec,yMean,'r',label='Mean SelfSpectra')
1109 # # plt.plot(xFrec,FitGauss,'yo:',label='Ajuste Gaussiano')
1110 # # # plt.plot(xFrec[Rangpos],FitGauss[Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.1)))],'bo')
1111 # # # #plt.plot(xFrec,phase)
1112 # # # plt.xlabel('Suavizado, promediado KHz')
1113 # # plt.title('SELFSPECTRA PROMEDIADO')
1114 # # # #plt.subplot(122)
1115 # # # #plt.plot(xSamples,zline)
1116 # # plt.xlabel('Frecuencia (KHz)')
1117 # # plt.ylabel('Magnitud')
1118 # # plt.legend()
1119 # # #
1120 # # # plt.figure(3)
1121 # # # plt.subplot(311)
1122 # # # #plt.plot(xFrec,phase[0])
1123 # # # plt.plot(xFrec,phase[0],'g')
1124 # # # plt.subplot(312)
1125 # # # plt.plot(xFrec,phase[1],'g')
1126 # # # plt.subplot(313)
1127 # # # plt.plot(xFrec,phase[2],'g')
1128 # # # #plt.plot(xFrec,phase[2])
1129 # # #
1130 # # # plt.figure(4)
1131 # # #
1132 # # # plt.plot(xSamples,coherence[0],'b')
1133 # # # plt.plot(xSamples,coherence[1],'r')
1134 # # # plt.plot(xSamples,coherence[2],'g')
1135 # # plt.show()
1136 # # #
1137 # # # plt.clf()
1138 # # # plt.cla()
1139 # # # plt.close()
1140 #
1141 # print ' '
1142
1143
1144
1145 self.BlockCounter+=2
1146
1147 else:
1148 self.fileSelector+=1
1149 self.BlockCounter=0
1150 print "Next File"
1151
1152
1153
1154
1155
@@ -1,1091 +1,1095
1 import numpy
1 import numpy
2 import time
2 import time
3 import os
3 import os
4 import h5py
4 import h5py
5 import re
5 import re
6 import datetime
6 import datetime
7
7
8 from schainpy.model.data.jrodata import *
8 from schainpy.model.data.jrodata import *
9 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
9 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
10 # from jroIO_base import *
10 # from jroIO_base import *
11 from schainpy.model.io.jroIO_base import *
11 from schainpy.model.io.jroIO_base import *
12 import schainpy
12 import schainpy
13
13
14
14
15 class ParamReader(ProcessingUnit):
15 class ParamReader(ProcessingUnit):
16 '''
16 '''
17 Reads HDF5 format files
17 Reads HDF5 format files
18
18
19 path
19 path
20
20
21 startDate
21 startDate
22
22
23 endDate
23 endDate
24
24
25 startTime
25 startTime
26
26
27 endTime
27 endTime
28 '''
28 '''
29
29
30 ext = ".hdf5"
30 ext = ".hdf5"
31
31
32 optchar = "D"
32 optchar = "D"
33
33
34 timezone = None
34 timezone = None
35
35
36 startTime = None
36 startTime = None
37
37
38 endTime = None
38 endTime = None
39
39
40 fileIndex = None
40 fileIndex = None
41
41
42 utcList = None #To select data in the utctime list
42 utcList = None #To select data in the utctime list
43
43
44 blockList = None #List to blocks to be read from the file
44 blockList = None #List to blocks to be read from the file
45
45
46 blocksPerFile = None #Number of blocks to be read
46 blocksPerFile = None #Number of blocks to be read
47
47
48 blockIndex = None
48 blockIndex = None
49
49
50 path = None
50 path = None
51
51
52 #List of Files
52 #List of Files
53
53
54 filenameList = None
54 filenameList = None
55
55
56 datetimeList = None
56 datetimeList = None
57
57
58 #Hdf5 File
58 #Hdf5 File
59
59
60 listMetaname = None
60 listMetaname = None
61
61
62 listMeta = None
62 listMeta = None
63
63
64 listDataname = None
64 listDataname = None
65
65
66 listData = None
66 listData = None
67
67
68 listShapes = None
68 listShapes = None
69
69
70 fp = None
70 fp = None
71
71
72 #dataOut reconstruction
72 #dataOut reconstruction
73
73
74 dataOut = None
74 dataOut = None
75
75
76
76
77 def __init__(self, **kwargs):
77 def __init__(self, **kwargs):
78 ProcessingUnit.__init__(self, **kwargs)
78 ProcessingUnit.__init__(self, **kwargs)
79 self.dataOut = Parameters()
79 self.dataOut = Parameters()
80 return
80 return
81
81
82 def setup(self, **kwargs):
82 def setup(self, **kwargs):
83
83
84 path = kwargs['path']
84 path = kwargs['path']
85 startDate = kwargs['startDate']
85 startDate = kwargs['startDate']
86 endDate = kwargs['endDate']
86 endDate = kwargs['endDate']
87 startTime = kwargs['startTime']
87 startTime = kwargs['startTime']
88 endTime = kwargs['endTime']
88 endTime = kwargs['endTime']
89 walk = kwargs['walk']
89 walk = kwargs['walk']
90 if kwargs.has_key('ext'):
90 if kwargs.has_key('ext'):
91 ext = kwargs['ext']
91 ext = kwargs['ext']
92 else:
92 else:
93 ext = '.hdf5'
93 ext = '.hdf5'
94 if kwargs.has_key('timezone'):
94 if kwargs.has_key('timezone'):
95 self.timezone = kwargs['timezone']
95 self.timezone = kwargs['timezone']
96 else:
96 else:
97 self.timezone = 'lt'
97 self.timezone = 'lt'
98
98
99 print "[Reading] Searching files in offline mode ..."
99 print "[Reading] Searching files in offline mode ..."
100 pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate,
100 pathList, filenameList = self.__searchFilesOffLine(path, startDate=startDate, endDate=endDate,
101 startTime=startTime, endTime=endTime,
101 startTime=startTime, endTime=endTime,
102 ext=ext, walk=walk)
102 ext=ext, walk=walk)
103
103
104 if not(filenameList):
104 if not(filenameList):
105 print "There is no files into the folder: %s"%(path)
105 print "There is no files into the folder: %s"%(path)
106 sys.exit(-1)
106 sys.exit(-1)
107
107
108 self.fileIndex = -1
108 self.fileIndex = -1
109 self.startTime = startTime
109 self.startTime = startTime
110 self.endTime = endTime
110 self.endTime = endTime
111
111
112 self.__readMetadata()
112 self.__readMetadata()
113
113
114 self.__setNextFileOffline()
114 self.__setNextFileOffline()
115
115
116 return
116 return
117
117
118 def __searchFilesOffLine(self,
118 def __searchFilesOffLine(self,
119 path,
119 path,
120 startDate=None,
120 startDate=None,
121 endDate=None,
121 endDate=None,
122 startTime=datetime.time(0,0,0),
122 startTime=datetime.time(0,0,0),
123 endTime=datetime.time(23,59,59),
123 endTime=datetime.time(23,59,59),
124 ext='.hdf5',
124 ext='.hdf5',
125 walk=True):
125 walk=True):
126
126
127 expLabel = ''
127 expLabel = ''
128 self.filenameList = []
128 self.filenameList = []
129 self.datetimeList = []
129 self.datetimeList = []
130
130
131 pathList = []
131 pathList = []
132
132
133 JRODataObj = JRODataReader()
133 JRODataObj = JRODataReader()
134 dateList, pathList = JRODataObj.findDatafiles(path, startDate, endDate, expLabel, ext, walk, include_path=True)
134 dateList, pathList = JRODataObj.findDatafiles(path, startDate, endDate, expLabel, ext, walk, include_path=True)
135
135
136 if dateList == []:
136 if dateList == []:
137 print "[Reading] No *%s files in %s from %s to %s)"%(ext, path,
137 print "[Reading] No *%s files in %s from %s to %s)"%(ext, path,
138 datetime.datetime.combine(startDate,startTime).ctime(),
138 datetime.datetime.combine(startDate,startTime).ctime(),
139 datetime.datetime.combine(endDate,endTime).ctime())
139 datetime.datetime.combine(endDate,endTime).ctime())
140
140
141 return None, None
141 return None, None
142
142
143 if len(dateList) > 1:
143 if len(dateList) > 1:
144 print "[Reading] %d days were found in date range: %s - %s" %(len(dateList), startDate, endDate)
144 print "[Reading] %d days were found in date range: %s - %s" %(len(dateList), startDate, endDate)
145 else:
145 else:
146 print "[Reading] data was found for the date %s" %(dateList[0])
146 print "[Reading] data was found for the date %s" %(dateList[0])
147
147
148 filenameList = []
148 filenameList = []
149 datetimeList = []
149 datetimeList = []
150
150
151 #----------------------------------------------------------------------------------
151 #----------------------------------------------------------------------------------
152
152
153 for thisPath in pathList:
153 for thisPath in pathList:
154 # thisPath = pathList[pathDict[file]]
154 # thisPath = pathList[pathDict[file]]
155
155
156 fileList = glob.glob1(thisPath, "*%s" %ext)
156 fileList = glob.glob1(thisPath, "*%s" %ext)
157 fileList.sort()
157 fileList.sort()
158
158
159 for file in fileList:
159 for file in fileList:
160
160
161 filename = os.path.join(thisPath,file)
161 filename = os.path.join(thisPath,file)
162
162
163 if not isFileInDateRange(filename, startDate, endDate):
163 if not isFileInDateRange(filename, startDate, endDate):
164 continue
164 continue
165
165
166 thisDatetime = self.__isFileInTimeRange(filename, startDate, endDate, startTime, endTime)
166 thisDatetime = self.__isFileInTimeRange(filename, startDate, endDate, startTime, endTime)
167
167
168 if not(thisDatetime):
168 if not(thisDatetime):
169 continue
169 continue
170
170
171 filenameList.append(filename)
171 filenameList.append(filename)
172 datetimeList.append(thisDatetime)
172 datetimeList.append(thisDatetime)
173
173
174 if not(filenameList):
174 if not(filenameList):
175 print "[Reading] Any file was found int time range %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
175 print "[Reading] Any file was found int time range %s - %s" %(datetime.datetime.combine(startDate,startTime).ctime(), datetime.datetime.combine(endDate,endTime).ctime())
176 return None, None
176 return None, None
177
177
178 print "[Reading] %d file(s) was(were) found in time range: %s - %s" %(len(filenameList), startTime, endTime)
178 print "[Reading] %d file(s) was(were) found in time range: %s - %s" %(len(filenameList), startTime, endTime)
179 print
179 print
180
180
181 # for i in range(len(filenameList)):
181 # for i in range(len(filenameList)):
182 # print "[Reading] %s -> [%s]" %(filenameList[i], datetimeList[i].ctime())
182 # print "[Reading] %s -> [%s]" %(filenameList[i], datetimeList[i].ctime())
183
183
184 self.filenameList = filenameList
184 self.filenameList = filenameList
185 self.datetimeList = datetimeList
185 self.datetimeList = datetimeList
186
186
187 return pathList, filenameList
187 return pathList, filenameList
188
188
189 def __isFileInTimeRange(self,filename, startDate, endDate, startTime, endTime):
189 def __isFileInTimeRange(self,filename, startDate, endDate, startTime, endTime):
190
190
191 """
191 """
192 Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
192 Retorna 1 si el archivo de datos se encuentra dentro del rango de horas especificado.
193
193
194 Inputs:
194 Inputs:
195 filename : nombre completo del archivo de datos en formato Jicamarca (.r)
195 filename : nombre completo del archivo de datos en formato Jicamarca (.r)
196
196
197 startDate : fecha inicial del rango seleccionado en formato datetime.date
197 startDate : fecha inicial del rango seleccionado en formato datetime.date
198
198
199 endDate : fecha final del rango seleccionado en formato datetime.date
199 endDate : fecha final del rango seleccionado en formato datetime.date
200
200
201 startTime : tiempo inicial del rango seleccionado en formato datetime.time
201 startTime : tiempo inicial del rango seleccionado en formato datetime.time
202
202
203 endTime : tiempo final del rango seleccionado en formato datetime.time
203 endTime : tiempo final del rango seleccionado en formato datetime.time
204
204
205 Return:
205 Return:
206 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
206 Boolean : Retorna True si el archivo de datos contiene datos en el rango de
207 fecha especificado, de lo contrario retorna False.
207 fecha especificado, de lo contrario retorna False.
208
208
209 Excepciones:
209 Excepciones:
210 Si el archivo no existe o no puede ser abierto
210 Si el archivo no existe o no puede ser abierto
211 Si la cabecera no puede ser leida.
211 Si la cabecera no puede ser leida.
212
212
213 """
213 """
214
214
215 try:
215 try:
216 fp = h5py.File(filename,'r')
216 fp = h5py.File(filename,'r')
217 grp1 = fp['Data']
217 grp1 = fp['Data']
218
218
219 except IOError:
219 except IOError:
220 traceback.print_exc()
220 traceback.print_exc()
221 raise IOError, "The file %s can't be opened" %(filename)
221 raise IOError, "The file %s can't be opened" %(filename)
222 #chino rata
222 #chino rata
223 #In case has utctime attribute
223 #In case has utctime attribute
224 grp2 = grp1['utctime']
224 grp2 = grp1['utctime']
225 # thisUtcTime = grp2.value[0] - 5*3600 #To convert to local time
225 # thisUtcTime = grp2.value[0] - 5*3600 #To convert to local time
226 thisUtcTime = grp2.value[0]
226 thisUtcTime = grp2.value[0]
227
227
228 fp.close()
228 fp.close()
229
229
230 if self.timezone == 'lt':
230 if self.timezone == 'lt':
231 thisUtcTime -= 5*3600
231 thisUtcTime -= 5*3600
232
232
233 thisDatetime = datetime.datetime.fromtimestamp(thisUtcTime[0] + 5*3600)
233 thisDatetime = datetime.datetime.fromtimestamp(thisUtcTime[0] + 5*3600)
234 # thisDatetime = datetime.datetime.fromtimestamp(thisUtcTime[0])
234 # thisDatetime = datetime.datetime.fromtimestamp(thisUtcTime[0])
235 thisDate = thisDatetime.date()
235 thisDate = thisDatetime.date()
236 thisTime = thisDatetime.time()
236 thisTime = thisDatetime.time()
237
237
238 startUtcTime = (datetime.datetime.combine(thisDate,startTime)- datetime.datetime(1970, 1, 1)).total_seconds()
238 startUtcTime = (datetime.datetime.combine(thisDate,startTime)- datetime.datetime(1970, 1, 1)).total_seconds()
239 endUtcTime = (datetime.datetime.combine(thisDate,endTime)- datetime.datetime(1970, 1, 1)).total_seconds()
239 endUtcTime = (datetime.datetime.combine(thisDate,endTime)- datetime.datetime(1970, 1, 1)).total_seconds()
240
240
241 #General case
241 #General case
242 # o>>>>>>>>>>>>>><<<<<<<<<<<<<<o
242 # o>>>>>>>>>>>>>><<<<<<<<<<<<<<o
243 #-----------o----------------------------o-----------
243 #-----------o----------------------------o-----------
244 # startTime endTime
244 # startTime endTime
245
245
246 if endTime >= startTime:
246 if endTime >= startTime:
247 thisUtcLog = numpy.logical_and(thisUtcTime > startUtcTime, thisUtcTime < endUtcTime)
247 thisUtcLog = numpy.logical_and(thisUtcTime > startUtcTime, thisUtcTime < endUtcTime)
248 if numpy.any(thisUtcLog): #If there is one block between the hours mentioned
248 if numpy.any(thisUtcLog): #If there is one block between the hours mentioned
249 return thisDatetime
249 return thisDatetime
250 return None
250 return None
251
251
252 #If endTime < startTime then endTime belongs to the next day
252 #If endTime < startTime then endTime belongs to the next day
253 #<<<<<<<<<<<o o>>>>>>>>>>>
253 #<<<<<<<<<<<o o>>>>>>>>>>>
254 #-----------o----------------------------o-----------
254 #-----------o----------------------------o-----------
255 # endTime startTime
255 # endTime startTime
256
256
257 if (thisDate == startDate) and numpy.all(thisUtcTime < startUtcTime):
257 if (thisDate == startDate) and numpy.all(thisUtcTime < startUtcTime):
258 return None
258 return None
259
259
260 if (thisDate == endDate) and numpy.all(thisUtcTime > endUtcTime):
260 if (thisDate == endDate) and numpy.all(thisUtcTime > endUtcTime):
261 return None
261 return None
262
262
263 if numpy.all(thisUtcTime < startUtcTime) and numpy.all(thisUtcTime > endUtcTime):
263 if numpy.all(thisUtcTime < startUtcTime) and numpy.all(thisUtcTime > endUtcTime):
264 return None
264 return None
265
265
266 return thisDatetime
266 return thisDatetime
267
267
268 def __setNextFileOffline(self):
268 def __setNextFileOffline(self):
269
269
270 self.fileIndex += 1
270 self.fileIndex += 1
271 idFile = self.fileIndex
271 idFile = self.fileIndex
272
272
273 if not(idFile < len(self.filenameList)):
273 if not(idFile < len(self.filenameList)):
274 print "No more Files"
274 print "No more Files"
275 return 0
275 return 0
276
276
277 filename = self.filenameList[idFile]
277 filename = self.filenameList[idFile]
278
278
279 filePointer = h5py.File(filename,'r')
279 filePointer = h5py.File(filename,'r')
280
280
281 self.filename = filename
281 self.filename = filename
282
282
283 self.fp = filePointer
283 self.fp = filePointer
284
284
285 print "Setting the file: %s"%self.filename
285 print "Setting the file: %s"%self.filename
286
286
287 # self.__readMetadata()
287 # self.__readMetadata()
288 self.__setBlockList()
288 self.__setBlockList()
289 self.__readData()
289 self.__readData()
290 # self.nRecords = self.fp['Data'].attrs['blocksPerFile']
290 # self.nRecords = self.fp['Data'].attrs['blocksPerFile']
291 # self.nRecords = self.fp['Data'].attrs['nRecords']
291 # self.nRecords = self.fp['Data'].attrs['nRecords']
292 self.blockIndex = 0
292 self.blockIndex = 0
293 return 1
293 return 1
294
294
295 def __setBlockList(self):
295 def __setBlockList(self):
296 '''
296 '''
297 Selects the data within the times defined
297 Selects the data within the times defined
298
298
299 self.fp
299 self.fp
300 self.startTime
300 self.startTime
301 self.endTime
301 self.endTime
302
302
303 self.blockList
303 self.blockList
304 self.blocksPerFile
304 self.blocksPerFile
305
305
306 '''
306 '''
307 fp = self.fp
307 fp = self.fp
308 startTime = self.startTime
308 startTime = self.startTime
309 endTime = self.endTime
309 endTime = self.endTime
310
310
311 grp = fp['Data']
311 grp = fp['Data']
312 thisUtcTime = grp['utctime'].value.astype(numpy.float)[0]
312 thisUtcTime = grp['utctime'].value.astype(numpy.float)[0]
313
313
314 #ERROOOOR
314 #ERROOOOR
315 if self.timezone == 'lt':
315 if self.timezone == 'lt':
316 thisUtcTime -= 5*3600
316 thisUtcTime -= 5*3600
317
317
318 thisDatetime = datetime.datetime.fromtimestamp(thisUtcTime[0] + 5*3600)
318 thisDatetime = datetime.datetime.fromtimestamp(thisUtcTime[0] + 5*3600)
319
319
320 thisDate = thisDatetime.date()
320 thisDate = thisDatetime.date()
321 thisTime = thisDatetime.time()
321 thisTime = thisDatetime.time()
322
322
323 startUtcTime = (datetime.datetime.combine(thisDate,startTime) - datetime.datetime(1970, 1, 1)).total_seconds()
323 startUtcTime = (datetime.datetime.combine(thisDate,startTime) - datetime.datetime(1970, 1, 1)).total_seconds()
324 endUtcTime = (datetime.datetime.combine(thisDate,endTime) - datetime.datetime(1970, 1, 1)).total_seconds()
324 endUtcTime = (datetime.datetime.combine(thisDate,endTime) - datetime.datetime(1970, 1, 1)).total_seconds()
325
325
326 ind = numpy.where(numpy.logical_and(thisUtcTime >= startUtcTime, thisUtcTime < endUtcTime))[0]
326 ind = numpy.where(numpy.logical_and(thisUtcTime >= startUtcTime, thisUtcTime < endUtcTime))[0]
327
327
328 self.blockList = ind
328 self.blockList = ind
329 self.blocksPerFile = len(ind)
329 self.blocksPerFile = len(ind)
330
330
331 return
331 return
332
332
333 def __readMetadata(self):
333 def __readMetadata(self):
334 '''
334 '''
335 Reads Metadata
335 Reads Metadata
336
336
337 self.pathMeta
337 self.pathMeta
338
338
339 self.listShapes
339 self.listShapes
340 self.listMetaname
340 self.listMetaname
341 self.listMeta
341 self.listMeta
342
342
343 '''
343 '''
344
344
345 # grp = self.fp['Data']
345 # grp = self.fp['Data']
346 # pathMeta = os.path.join(self.path, grp.attrs['metadata'])
346 # pathMeta = os.path.join(self.path, grp.attrs['metadata'])
347 #
347 #
348 # if pathMeta == self.pathMeta:
348 # if pathMeta == self.pathMeta:
349 # return
349 # return
350 # else:
350 # else:
351 # self.pathMeta = pathMeta
351 # self.pathMeta = pathMeta
352 #
352 #
353 # filePointer = h5py.File(self.pathMeta,'r')
353 # filePointer = h5py.File(self.pathMeta,'r')
354 # groupPointer = filePointer['Metadata']
354 # groupPointer = filePointer['Metadata']
355
355
356 filename = self.filenameList[0]
356 filename = self.filenameList[0]
357
357
358 fp = h5py.File(filename,'r')
358 fp = h5py.File(filename,'r')
359
359
360 gp = fp['Metadata']
360 gp = fp['Metadata']
361
361
362 listMetaname = []
362 listMetaname = []
363 listMetadata = []
363 listMetadata = []
364 for item in gp.items():
364 for item in gp.items():
365 name = item[0]
365 name = item[0]
366
366
367 if name=='array dimensions':
367 if name=='array dimensions':
368 table = gp[name][:]
368 table = gp[name][:]
369 listShapes = {}
369 listShapes = {}
370 for shapes in table:
370 for shapes in table:
371 listShapes[shapes[0]] = numpy.array([shapes[1],shapes[2],shapes[3],shapes[4],shapes[5]])
371 listShapes[shapes[0]] = numpy.array([shapes[1],shapes[2],shapes[3],shapes[4],shapes[5]])
372 else:
372 else:
373 data = gp[name].value
373 data = gp[name].value
374 listMetaname.append(name)
374 listMetaname.append(name)
375 listMetadata.append(data)
375 listMetadata.append(data)
376
376
377 # if name=='type':
377 # if name=='type':
378 # self.__initDataOut(data)
378 # self.__initDataOut(data)
379
379
380 self.listShapes = listShapes
380 self.listShapes = listShapes
381 self.listMetaname = listMetaname
381 self.listMetaname = listMetaname
382 self.listMeta = listMetadata
382 self.listMeta = listMetadata
383
383
384 fp.close()
384 fp.close()
385 return
385 return
386
386
387 def __readData(self):
387 def __readData(self):
388 grp = self.fp['Data']
388 grp = self.fp['Data']
389 listdataname = []
389 listdataname = []
390 listdata = []
390 listdata = []
391
391
392 for item in grp.items():
392 for item in grp.items():
393 name = item[0]
393 name = item[0]
394 listdataname.append(name)
394 listdataname.append(name)
395
395
396 array = self.__setDataArray(grp[name],self.listShapes[name])
396 array = self.__setDataArray(grp[name],self.listShapes[name])
397 listdata.append(array)
397 listdata.append(array)
398
398
399 self.listDataname = listdataname
399 self.listDataname = listdataname
400 self.listData = listdata
400 self.listData = listdata
401 return
401 return
402
402
403 def __setDataArray(self, dataset, shapes):
403 def __setDataArray(self, dataset, shapes):
404
404
405 nDims = shapes[0]
405 nDims = shapes[0]
406
406
407 nDim2 = shapes[1] #Dimension 0
407 nDim2 = shapes[1] #Dimension 0
408
408
409 nDim1 = shapes[2] #Dimension 1, number of Points or Parameters
409 nDim1 = shapes[2] #Dimension 1, number of Points or Parameters
410
410
411 nDim0 = shapes[3] #Dimension 2, number of samples or ranges
411 nDim0 = shapes[3] #Dimension 2, number of samples or ranges
412
412
413 mode = shapes[4] #Mode of storing
413 mode = shapes[4] #Mode of storing
414
414
415 blockList = self.blockList
415 blockList = self.blockList
416
416
417 blocksPerFile = self.blocksPerFile
417 blocksPerFile = self.blocksPerFile
418
418
419 #Depending on what mode the data was stored
419 #Depending on what mode the data was stored
420 if mode == 0: #Divided in channels
420 if mode == 0: #Divided in channels
421 arrayData = dataset.value.astype(numpy.float)[0][blockList]
421 arrayData = dataset.value.astype(numpy.float)[0][blockList]
422 if mode == 1: #Divided in parameter
422 if mode == 1: #Divided in parameter
423 strds = 'table'
423 strds = 'table'
424 nDatas = nDim1
424 nDatas = nDim1
425 newShapes = (blocksPerFile,nDim2,nDim0)
425 newShapes = (blocksPerFile,nDim2,nDim0)
426 elif mode==2: #Concatenated in a table
426 elif mode==2: #Concatenated in a table
427 strds = 'table0'
427 strds = 'table0'
428 arrayData = dataset[strds].value
428 arrayData = dataset[strds].value
429 #Selecting part of the dataset
429 #Selecting part of the dataset
430 utctime = arrayData[:,0]
430 utctime = arrayData[:,0]
431 u, indices = numpy.unique(utctime, return_index=True)
431 u, indices = numpy.unique(utctime, return_index=True)
432
432
433 if blockList.size != indices.size:
433 if blockList.size != indices.size:
434 indMin = indices[blockList[0]]
434 indMin = indices[blockList[0]]
435 if blockList[1] + 1 >= indices.size:
435 if blockList[1] + 1 >= indices.size:
436 arrayData = arrayData[indMin:,:]
436 arrayData = arrayData[indMin:,:]
437 else:
437 else:
438 indMax = indices[blockList[1] + 1]
438 indMax = indices[blockList[1] + 1]
439 arrayData = arrayData[indMin:indMax,:]
439 arrayData = arrayData[indMin:indMax,:]
440 return arrayData
440 return arrayData
441
441
442 # One dimension
442 # One dimension
443 if nDims == 0:
443 if nDims == 0:
444 arrayData = dataset.value.astype(numpy.float)[0][blockList]
444 arrayData = dataset.value.astype(numpy.float)[0][blockList]
445
445
446 # Two dimensions
446 # Two dimensions
447 elif nDims == 2:
447 elif nDims == 2:
448 arrayData = numpy.zeros((blocksPerFile,nDim1,nDim0))
448 arrayData = numpy.zeros((blocksPerFile,nDim1,nDim0))
449 newShapes = (blocksPerFile,nDim0)
449 newShapes = (blocksPerFile,nDim0)
450 nDatas = nDim1
450 nDatas = nDim1
451
451
452 for i in range(nDatas):
452 for i in range(nDatas):
453 data = dataset[strds + str(i)].value
453 data = dataset[strds + str(i)].value
454 arrayData[:,i,:] = data[blockList,:]
454 arrayData[:,i,:] = data[blockList,:]
455
455
456 # Three dimensions
456 # Three dimensions
457 else:
457 else:
458 arrayData = numpy.zeros((blocksPerFile,nDim2,nDim1,nDim0))
458 arrayData = numpy.zeros((blocksPerFile,nDim2,nDim1,nDim0))
459 for i in range(nDatas):
459 for i in range(nDatas):
460
460
461 data = dataset[strds + str(i)].value
461 data = dataset[strds + str(i)].value
462
462
463 for b in range(blockList.size):
463 for b in range(blockList.size):
464 arrayData[b,:,i,:] = data[:,:,blockList[b]]
464 arrayData[b,:,i,:] = data[:,:,blockList[b]]
465
465
466 return arrayData
466 return arrayData
467
467
468 def __setDataOut(self):
468 def __setDataOut(self):
469 listMeta = self.listMeta
469 listMeta = self.listMeta
470 listMetaname = self.listMetaname
470 listMetaname = self.listMetaname
471 listDataname = self.listDataname
471 listDataname = self.listDataname
472 listData = self.listData
472 listData = self.listData
473 listShapes = self.listShapes
473 listShapes = self.listShapes
474
474
475 blockIndex = self.blockIndex
475 blockIndex = self.blockIndex
476 # blockList = self.blockList
476 # blockList = self.blockList
477
477
478 for i in range(len(listMeta)):
478 for i in range(len(listMeta)):
479 setattr(self.dataOut,listMetaname[i],listMeta[i])
479 setattr(self.dataOut,listMetaname[i],listMeta[i])
480
480
481 for j in range(len(listData)):
481 for j in range(len(listData)):
482 nShapes = listShapes[listDataname[j]][0]
482 nShapes = listShapes[listDataname[j]][0]
483 mode = listShapes[listDataname[j]][4]
483 mode = listShapes[listDataname[j]][4]
484 if nShapes == 1:
484 if nShapes == 1:
485 setattr(self.dataOut,listDataname[j],listData[j][blockIndex])
485 setattr(self.dataOut,listDataname[j],listData[j][blockIndex])
486 elif nShapes > 1:
486 elif nShapes > 1:
487 setattr(self.dataOut,listDataname[j],listData[j][blockIndex,:])
487 setattr(self.dataOut,listDataname[j],listData[j][blockIndex,:])
488 elif mode==0:
488 elif mode==0:
489 setattr(self.dataOut,listDataname[j],listData[j][blockIndex])
489 setattr(self.dataOut,listDataname[j],listData[j][blockIndex])
490 #Mode Meteors
490 #Mode Meteors
491 elif mode ==2:
491 elif mode ==2:
492 selectedData = self.__selectDataMode2(listData[j], blockIndex)
492 selectedData = self.__selectDataMode2(listData[j], blockIndex)
493 setattr(self.dataOut, listDataname[j], selectedData)
493 setattr(self.dataOut, listDataname[j], selectedData)
494 return
494 return
495
495
496 def __selectDataMode2(self, data, blockIndex):
496 def __selectDataMode2(self, data, blockIndex):
497 utctime = data[:,0]
497 utctime = data[:,0]
498 aux, indices = numpy.unique(utctime, return_inverse=True)
498 aux, indices = numpy.unique(utctime, return_inverse=True)
499 selInd = numpy.where(indices == blockIndex)[0]
499 selInd = numpy.where(indices == blockIndex)[0]
500 selData = data[selInd,:]
500 selData = data[selInd,:]
501
501
502 return selData
502 return selData
503
503
504 def getData(self):
504 def getData(self):
505
505
506 # if self.flagNoMoreFiles:
506 # if self.flagNoMoreFiles:
507 # self.dataOut.flagNoData = True
507 # self.dataOut.flagNoData = True
508 # print 'Process finished'
508 # print 'Process finished'
509 # return 0
509 # return 0
510 #
510 #
511 if self.blockIndex==self.blocksPerFile:
511 if self.blockIndex==self.blocksPerFile:
512 if not( self.__setNextFileOffline() ):
512 if not( self.__setNextFileOffline() ):
513 self.dataOut.flagNoData = True
513 self.dataOut.flagNoData = True
514 return 0
514 return 0
515
515
516 # if self.datablock == None: # setear esta condicion cuando no hayan datos por leers
516 # if self.datablock == None: # setear esta condicion cuando no hayan datos por leers
517 # self.dataOut.flagNoData = True
517 # self.dataOut.flagNoData = True
518 # return 0
518 # return 0
519 # self.__readData()
519 # self.__readData()
520 self.__setDataOut()
520 self.__setDataOut()
521 self.dataOut.flagNoData = False
521 self.dataOut.flagNoData = False
522
522
523 self.blockIndex += 1
523 self.blockIndex += 1
524
524
525 return
525 return
526
526
527 def run(self, **kwargs):
527 def run(self, **kwargs):
528
528
529 if not(self.isConfig):
529 if not(self.isConfig):
530 self.setup(**kwargs)
530 self.setup(**kwargs)
531 # self.setObjProperties()
531 # self.setObjProperties()
532 self.isConfig = True
532 self.isConfig = True
533
533
534 self.getData()
534 self.getData()
535
535
536 return
536 return
537
537
538 class ParamWriter(Operation):
538 class ParamWriter(Operation):
539 '''
539 '''
540 HDF5 Writer, stores parameters data in HDF5 format files
540 HDF5 Writer, stores parameters data in HDF5 format files
541
541
542 path: path where the files will be stored
542 path: path where the files will be stored
543
543
544 blocksPerFile: number of blocks that will be saved in per HDF5 format file
544 blocksPerFile: number of blocks that will be saved in per HDF5 format file
545
545
546 mode: selects the data stacking mode: '0' channels, '1' parameters, '3' table (for meteors)
546 mode: selects the data stacking mode: '0' channels, '1' parameters, '3' table (for meteors)
547
547
548 metadataList: list of attributes that will be stored as metadata
548 metadataList: list of attributes that will be stored as metadata
549
549
550 dataList: list of attributes that will be stores as data
550 dataList: list of attributes that will be stores as data
551
551
552 '''
552 '''
553
553
554
554
555 ext = ".hdf5"
555 ext = ".hdf5"
556
556
557 optchar = "D"
557 optchar = "D"
558
558
559 metaoptchar = "M"
559 metaoptchar = "M"
560
560
561 metaFile = None
561 metaFile = None
562
562
563 filename = None
563 filename = None
564
564
565 path = None
565 path = None
566
566
567 setFile = None
567 setFile = None
568
568
569 fp = None
569 fp = None
570
570
571 grp = None
571 grp = None
572
572
573 ds = None
573 ds = None
574
574
575 firsttime = True
575 firsttime = True
576
576
577 #Configurations
577 #Configurations
578
578
579 blocksPerFile = None
579 blocksPerFile = None
580
580
581 blockIndex = None
581 blockIndex = None
582
582
583 dataOut = None
583 dataOut = None
584
584
585 #Data Arrays
585 #Data Arrays
586
586
587 dataList = None
587 dataList = None
588
588
589 metadataList = None
589 metadataList = None
590
590
591 # arrayDim = None
591 # arrayDim = None
592
592
593 dsList = None #List of dictionaries with dataset properties
593 dsList = None #List of dictionaries with dataset properties
594
594
595 tableDim = None
595 tableDim = None
596
596
597 # dtype = [('arrayName', 'S20'),('nChannels', 'i'), ('nPoints', 'i'), ('nSamples', 'i'),('mode', 'b')]
597 # dtype = [('arrayName', 'S20'),('nChannels', 'i'), ('nPoints', 'i'), ('nSamples', 'i'),('mode', 'b')]
598
598
599 dtype = [('arrayName', 'S20'),('nDimensions', 'i'), ('dim2', 'i'), ('dim1', 'i'),('dim0', 'i'),('mode', 'b')]
599 dtype = [('arrayName', 'S20'),('nDimensions', 'i'), ('dim2', 'i'), ('dim1', 'i'),('dim0', 'i'),('mode', 'b')]
600
600
601 currentDay = None
601 currentDay = None
602
602
603 lastTime = None
603 lastTime = None
604
604
605 def __init__(self, **kwargs):
605 def __init__(self, **kwargs):
606 Operation.__init__(self, **kwargs)
606 Operation.__init__(self, **kwargs)
607 self.isConfig = False
607 self.isConfig = False
608 return
608 return
609
609
610 def setup(self, dataOut, **kwargs):
610 def setup(self, dataOut, **kwargs):
611
611
612 self.path = kwargs['path']
612 self.path = kwargs['path']
613
613
614 if kwargs.has_key('blocksPerFile'):
614 if kwargs.has_key('blocksPerFile'):
615 self.blocksPerFile = kwargs['blocksPerFile']
615 self.blocksPerFile = kwargs['blocksPerFile']
616 else:
616 else:
617 self.blocksPerFile = 10
617 self.blocksPerFile = 10
618
618
619 self.metadataList = kwargs['metadataList']
619 self.metadataList = kwargs['metadataList']
620 self.dataList = kwargs['dataList']
620 self.dataList = kwargs['dataList']
621 self.dataOut = dataOut
621 self.dataOut = dataOut
622
622
623 if kwargs.has_key('mode'):
623 if kwargs.has_key('mode'):
624 mode = kwargs['mode']
624 mode = kwargs['mode']
625
625
626 if type(mode) == int:
626 if type(mode) == int:
627 mode = numpy.zeros(len(self.dataList)) + mode
627 mode = numpy.zeros(len(self.dataList)) + mode
628 else:
628 else:
629 mode = numpy.ones(len(self.dataList))
629 mode = numpy.ones(len(self.dataList))
630
630
631 self.mode = mode
631 self.mode = mode
632
632
633 arrayDim = numpy.zeros((len(self.dataList),5))
633 arrayDim = numpy.zeros((len(self.dataList),5))
634
634
635 #Table dimensions
635 #Table dimensions
636 dtype0 = self.dtype
636 dtype0 = self.dtype
637 tableList = []
637 tableList = []
638
638
639 #Dictionary and list of tables
639 #Dictionary and list of tables
640 dsList = []
640 dsList = []
641
641
642 for i in range(len(self.dataList)):
642 for i in range(len(self.dataList)):
643 dsDict = {}
643 dsDict = {}
644 dataAux = getattr(self.dataOut, self.dataList[i])
644 dataAux = getattr(self.dataOut, self.dataList[i])
645 dsDict['variable'] = self.dataList[i]
645 dsDict['variable'] = self.dataList[i]
646 #--------------------- Conditionals ------------------------
646 #--------------------- Conditionals ------------------------
647 #There is no data
647 #There is no data
648
649
648 if dataAux is None:
650 if dataAux is None:
651
649 return 0
652 return 0
650
653
651 #Not array, just a number
654 #Not array, just a number
652 #Mode 0
655 #Mode 0
653 if type(dataAux)==float or type(dataAux)==int:
656 if type(dataAux)==float or type(dataAux)==int:
654 dsDict['mode'] = 0
657 dsDict['mode'] = 0
655 dsDict['nDim'] = 0
658 dsDict['nDim'] = 0
656 arrayDim[i,0] = 0
659 arrayDim[i,0] = 0
657 dsList.append(dsDict)
660 dsList.append(dsDict)
658
661
659 #Mode 2: meteors
662 #Mode 2: meteors
660 elif mode[i] == 2:
663 elif mode[i] == 2:
661 # dsDict['nDim'] = 0
664 # dsDict['nDim'] = 0
662 dsDict['dsName'] = 'table0'
665 dsDict['dsName'] = 'table0'
663 dsDict['mode'] = 2 # Mode meteors
666 dsDict['mode'] = 2 # Mode meteors
664 dsDict['shape'] = dataAux.shape[-1]
667 dsDict['shape'] = dataAux.shape[-1]
665 dsDict['nDim'] = 0
668 dsDict['nDim'] = 0
666 dsDict['dsNumber'] = 1
669 dsDict['dsNumber'] = 1
667
670
668 arrayDim[i,3] = dataAux.shape[-1]
671 arrayDim[i,3] = dataAux.shape[-1]
669 arrayDim[i,4] = mode[i] #Mode the data was stored
672 arrayDim[i,4] = mode[i] #Mode the data was stored
670
673
671 dsList.append(dsDict)
674 dsList.append(dsDict)
672
675
673 #Mode 1
676 #Mode 1
674 else:
677 else:
675 arrayDim0 = dataAux.shape #Data dimensions
678 arrayDim0 = dataAux.shape #Data dimensions
676 arrayDim[i,0] = len(arrayDim0) #Number of array dimensions
679 arrayDim[i,0] = len(arrayDim0) #Number of array dimensions
677 arrayDim[i,4] = mode[i] #Mode the data was stored
680 arrayDim[i,4] = mode[i] #Mode the data was stored
678
681
679 strtable = 'table'
682 strtable = 'table'
680 dsDict['mode'] = 1 # Mode parameters
683 dsDict['mode'] = 1 # Mode parameters
681
684
682 # Three-dimension arrays
685 # Three-dimension arrays
683 if len(arrayDim0) == 3:
686 if len(arrayDim0) == 3:
684 arrayDim[i,1:-1] = numpy.array(arrayDim0)
687 arrayDim[i,1:-1] = numpy.array(arrayDim0)
685 nTables = int(arrayDim[i,2])
688 nTables = int(arrayDim[i,2])
686 dsDict['dsNumber'] = nTables
689 dsDict['dsNumber'] = nTables
687 dsDict['shape'] = arrayDim[i,2:4]
690 dsDict['shape'] = arrayDim[i,2:4]
688 dsDict['nDim'] = 3
691 dsDict['nDim'] = 3
689
692
690 for j in range(nTables):
693 for j in range(nTables):
691 dsDict = dsDict.copy()
694 dsDict = dsDict.copy()
692 dsDict['dsName'] = strtable + str(j)
695 dsDict['dsName'] = strtable + str(j)
693 dsList.append(dsDict)
696 dsList.append(dsDict)
694
697
695 # Two-dimension arrays
698 # Two-dimension arrays
696 elif len(arrayDim0) == 2:
699 elif len(arrayDim0) == 2:
697 arrayDim[i,2:-1] = numpy.array(arrayDim0)
700 arrayDim[i,2:-1] = numpy.array(arrayDim0)
698 nTables = int(arrayDim[i,2])
701 nTables = int(arrayDim[i,2])
699 dsDict['dsNumber'] = nTables
702 dsDict['dsNumber'] = nTables
700 dsDict['shape'] = arrayDim[i,3]
703 dsDict['shape'] = arrayDim[i,3]
701 dsDict['nDim'] = 2
704 dsDict['nDim'] = 2
702
705
703 for j in range(nTables):
706 for j in range(nTables):
704 dsDict = dsDict.copy()
707 dsDict = dsDict.copy()
705 dsDict['dsName'] = strtable + str(j)
708 dsDict['dsName'] = strtable + str(j)
706 dsList.append(dsDict)
709 dsList.append(dsDict)
707
710
708 # One-dimension arrays
711 # One-dimension arrays
709 elif len(arrayDim0) == 1:
712 elif len(arrayDim0) == 1:
710 arrayDim[i,3] = arrayDim0[0]
713 arrayDim[i,3] = arrayDim0[0]
711 dsDict['shape'] = arrayDim0[0]
714 dsDict['shape'] = arrayDim0[0]
712 dsDict['dsNumber'] = 1
715 dsDict['dsNumber'] = 1
713 dsDict['dsName'] = strtable + str(0)
716 dsDict['dsName'] = strtable + str(0)
714 dsDict['nDim'] = 1
717 dsDict['nDim'] = 1
715 dsList.append(dsDict)
718 dsList.append(dsDict)
716
719
717 table = numpy.array((self.dataList[i],) + tuple(arrayDim[i,:]),dtype = dtype0)
720 table = numpy.array((self.dataList[i],) + tuple(arrayDim[i,:]),dtype = dtype0)
718 tableList.append(table)
721 tableList.append(table)
719
722
720 # self.arrayDim = arrayDim
723 # self.arrayDim = arrayDim
721 self.dsList = dsList
724 self.dsList = dsList
722 self.tableDim = numpy.array(tableList, dtype = dtype0)
725 self.tableDim = numpy.array(tableList, dtype = dtype0)
723 self.blockIndex = 0
726 self.blockIndex = 0
724
727
725 timeTuple = time.localtime(dataOut.utctime)
728 timeTuple = time.localtime(dataOut.utctime)
726 self.currentDay = timeTuple.tm_yday
729 self.currentDay = timeTuple.tm_yday
727 return 1
730 return 1
728
731
729 def putMetadata(self):
732 def putMetadata(self):
730
733
731 fp = self.createMetadataFile()
734 fp = self.createMetadataFile()
732 self.writeMetadata(fp)
735 self.writeMetadata(fp)
733 fp.close()
736 fp.close()
734 return
737 return
735
738
736 def createMetadataFile(self):
739 def createMetadataFile(self):
737 ext = self.ext
740 ext = self.ext
738 path = self.path
741 path = self.path
739 setFile = self.setFile
742 setFile = self.setFile
740
743
741 timeTuple = time.localtime(self.dataOut.utctime)
744 timeTuple = time.localtime(self.dataOut.utctime)
742
745
743 subfolder = ''
746 subfolder = ''
744 fullpath = os.path.join( path, subfolder )
747 fullpath = os.path.join( path, subfolder )
745
748
746 if not( os.path.exists(fullpath) ):
749 if not( os.path.exists(fullpath) ):
747 os.mkdir(fullpath)
750 os.mkdir(fullpath)
748 setFile = -1 #inicializo mi contador de seteo
751 setFile = -1 #inicializo mi contador de seteo
749
752
750 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
753 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
751 fullpath = os.path.join( path, subfolder )
754 fullpath = os.path.join( path, subfolder )
752
755
753 if not( os.path.exists(fullpath) ):
756 if not( os.path.exists(fullpath) ):
754 os.mkdir(fullpath)
757 os.mkdir(fullpath)
755 setFile = -1 #inicializo mi contador de seteo
758 setFile = -1 #inicializo mi contador de seteo
756
759
757 else:
760 else:
758 filesList = os.listdir( fullpath )
761 filesList = os.listdir( fullpath )
759 filesList = sorted( filesList, key=str.lower )
762 filesList = sorted( filesList, key=str.lower )
760 if len( filesList ) > 0:
763 if len( filesList ) > 0:
761 filesList = [k for k in filesList if 'M' in k]
764 filesList = [k for k in filesList if 'M' in k]
762 filen = filesList[-1]
765 filen = filesList[-1]
763 # el filename debera tener el siguiente formato
766 # el filename debera tener el siguiente formato
764 # 0 1234 567 89A BCDE (hex)
767 # 0 1234 567 89A BCDE (hex)
765 # x YYYY DDD SSS .ext
768 # x YYYY DDD SSS .ext
766 if isNumber( filen[8:11] ):
769 if isNumber( filen[8:11] ):
767 setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file
770 setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file
768 else:
771 else:
769 setFile = -1
772 setFile = -1
770 else:
773 else:
771 setFile = -1 #inicializo mi contador de seteo
774 setFile = -1 #inicializo mi contador de seteo
772
775
773 setFile += 1
776 setFile += 1
774
777
775 file = '%s%4.4d%3.3d%3.3d%s' % (self.metaoptchar,
778 file = '%s%4.4d%3.3d%3.3d%s' % (self.metaoptchar,
776 timeTuple.tm_year,
779 timeTuple.tm_year,
777 timeTuple.tm_yday,
780 timeTuple.tm_yday,
778 setFile,
781 setFile,
779 ext )
782 ext )
780
783
781 filename = os.path.join( path, subfolder, file )
784 filename = os.path.join( path, subfolder, file )
782 self.metaFile = file
785 self.metaFile = file
783 #Setting HDF5 File
786 #Setting HDF5 File
784 fp = h5py.File(filename,'w')
787 fp = h5py.File(filename,'w')
785
788
786 return fp
789 return fp
787
790
788 def writeMetadata(self, fp):
791 def writeMetadata(self, fp):
789
792
790 grp = fp.create_group("Metadata")
793 grp = fp.create_group("Metadata")
791 grp.create_dataset('array dimensions', data = self.tableDim, dtype = self.dtype)
794 grp.create_dataset('array dimensions', data = self.tableDim, dtype = self.dtype)
792
795
793 for i in range(len(self.metadataList)):
796 for i in range(len(self.metadataList)):
794 print '#####',self.metadataList[i], getattr(self.dataOut, self.metadataList[i])
797 print '#####',self.metadataList[i], getattr(self.dataOut, self.metadataList[i])
795 grp.create_dataset(self.metadataList[i], data=getattr(self.dataOut, self.metadataList[i]))
798 grp.create_dataset(self.metadataList[i], data=getattr(self.dataOut, self.metadataList[i]))
796 return
799 return
797
800
798 def timeFlag(self):
801 def timeFlag(self):
799 currentTime = self.dataOut.utctime
802 currentTime = self.dataOut.utctime
800
803
801 if self.lastTime is None:
804 if self.lastTime is None:
802 self.lastTime = currentTime
805 self.lastTime = currentTime
803
806
804 #Day
807 #Day
805 timeTuple = time.localtime(currentTime)
808 timeTuple = time.localtime(currentTime)
806 dataDay = timeTuple.tm_yday
809 dataDay = timeTuple.tm_yday
807
810
808 #Time
811 #Time
809 timeDiff = currentTime - self.lastTime
812 timeDiff = currentTime - self.lastTime
810
813
811 #Si el dia es diferente o si la diferencia entre un dato y otro supera la hora
814 #Si el dia es diferente o si la diferencia entre un dato y otro supera la hora
812 if dataDay != self.currentDay:
815 if dataDay != self.currentDay:
813 self.currentDay = dataDay
816 self.currentDay = dataDay
814 return True
817 return True
815 elif timeDiff > 3*60*60:
818 elif timeDiff > 3*60*60:
816 self.lastTime = currentTime
819 self.lastTime = currentTime
817 return True
820 return True
818 else:
821 else:
819 self.lastTime = currentTime
822 self.lastTime = currentTime
820 return False
823 return False
821
824
822 def setNextFile(self):
825 def setNextFile(self):
823
826
824 ext = self.ext
827 ext = self.ext
825 path = self.path
828 path = self.path
826 setFile = self.setFile
829 setFile = self.setFile
827 mode = self.mode
830 mode = self.mode
828
831
829 timeTuple = time.localtime(self.dataOut.utctime)
832 timeTuple = time.localtime(self.dataOut.utctime)
830 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
833 subfolder = 'd%4.4d%3.3d' % (timeTuple.tm_year,timeTuple.tm_yday)
831
834
832 fullpath = os.path.join( path, subfolder )
835 fullpath = os.path.join( path, subfolder )
833
836
834 if os.path.exists(fullpath):
837 if os.path.exists(fullpath):
835 filesList = os.listdir( fullpath )
838 filesList = os.listdir( fullpath )
836 filesList = [k for k in filesList if 'D' in k]
839 filesList = [k for k in filesList if 'D' in k]
837 if len( filesList ) > 0:
840 if len( filesList ) > 0:
838 filesList = sorted( filesList, key=str.lower )
841 filesList = sorted( filesList, key=str.lower )
839 filen = filesList[-1]
842 filen = filesList[-1]
840 # el filename debera tener el siguiente formato
843 # el filename debera tener el siguiente formato
841 # 0 1234 567 89A BCDE (hex)
844 # 0 1234 567 89A BCDE (hex)
842 # x YYYY DDD SSS .ext
845 # x YYYY DDD SSS .ext
843 if isNumber( filen[8:11] ):
846 if isNumber( filen[8:11] ):
844 setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file
847 setFile = int( filen[8:11] ) #inicializo mi contador de seteo al seteo del ultimo file
845 else:
848 else:
846 setFile = -1
849 setFile = -1
847 else:
850 else:
848 setFile = -1 #inicializo mi contador de seteo
851 setFile = -1 #inicializo mi contador de seteo
849 else:
852 else:
850 os.makedirs(fullpath)
853 os.makedirs(fullpath)
851 setFile = -1 #inicializo mi contador de seteo
854 setFile = -1 #inicializo mi contador de seteo
852
855
853 setFile += 1
856 setFile += 1
854
857
855 file = '%s%4.4d%3.3d%3.3d%s' % (self.optchar,
858 file = '%s%4.4d%3.3d%3.3d%s' % (self.optchar,
856 timeTuple.tm_year,
859 timeTuple.tm_year,
857 timeTuple.tm_yday,
860 timeTuple.tm_yday,
858 setFile,
861 setFile,
859 ext )
862 ext )
860
863
861 filename = os.path.join( path, subfolder, file )
864 filename = os.path.join( path, subfolder, file )
862
865
863 #Setting HDF5 File
866 #Setting HDF5 File
864 fp = h5py.File(filename,'w')
867 fp = h5py.File(filename,'w')
865 #write metadata
868 #write metadata
866 self.writeMetadata(fp)
869 self.writeMetadata(fp)
867 #Write data
870 #Write data
868 grp = fp.create_group("Data")
871 grp = fp.create_group("Data")
869 # grp.attrs['metadata'] = self.metaFile
872 # grp.attrs['metadata'] = self.metaFile
870
873
871 # grp.attrs['blocksPerFile'] = 0
874 # grp.attrs['blocksPerFile'] = 0
872 ds = []
875 ds = []
873 data = []
876 data = []
874 dsList = self.dsList
877 dsList = self.dsList
875 i = 0
878 i = 0
876 while i < len(dsList):
879 while i < len(dsList):
877 dsInfo = dsList[i]
880 dsInfo = dsList[i]
878 #One-dimension data
881 #One-dimension data
879 if dsInfo['mode'] == 0:
882 if dsInfo['mode'] == 0:
880 # ds0 = grp.create_dataset(self.dataList[i], (1,1), maxshape=(1,self.blocksPerFile) , chunks = True, dtype='S20')
883 # ds0 = grp.create_dataset(self.dataList[i], (1,1), maxshape=(1,self.blocksPerFile) , chunks = True, dtype='S20')
881 ds0 = grp.create_dataset(dsInfo['variable'], (1,1), maxshape=(1,self.blocksPerFile) , chunks = True, dtype=numpy.float64)
884 ds0 = grp.create_dataset(dsInfo['variable'], (1,1), maxshape=(1,self.blocksPerFile) , chunks = True, dtype=numpy.float64)
882 ds.append(ds0)
885 ds.append(ds0)
883 data.append([])
886 data.append([])
884 i += 1
887 i += 1
885 continue
888 continue
886 # nDimsForDs.append(nDims[i])
889 # nDimsForDs.append(nDims[i])
887
890
888 elif dsInfo['mode'] == 2:
891 elif dsInfo['mode'] == 2:
889 grp0 = grp.create_group(dsInfo['variable'])
892 grp0 = grp.create_group(dsInfo['variable'])
890 ds0 = grp0.create_dataset(dsInfo['dsName'], (1,dsInfo['shape']), data = numpy.zeros((1,dsInfo['shape'])) , maxshape=(None,dsInfo['shape']), chunks=True)
893 ds0 = grp0.create_dataset(dsInfo['dsName'], (1,dsInfo['shape']), data = numpy.zeros((1,dsInfo['shape'])) , maxshape=(None,dsInfo['shape']), chunks=True)
891 ds.append(ds0)
894 ds.append(ds0)
892 data.append([])
895 data.append([])
893 i += 1
896 i += 1
894 continue
897 continue
895
898
896 elif dsInfo['mode'] == 1:
899 elif dsInfo['mode'] == 1:
897 grp0 = grp.create_group(dsInfo['variable'])
900 grp0 = grp.create_group(dsInfo['variable'])
898
901
899 for j in range(dsInfo['dsNumber']):
902 for j in range(dsInfo['dsNumber']):
900 dsInfo = dsList[i]
903 dsInfo = dsList[i]
901 tableName = dsInfo['dsName']
904 tableName = dsInfo['dsName']
902 shape = int(dsInfo['shape'])
905 shape = int(dsInfo['shape'])
903
906
904 if dsInfo['nDim'] == 3:
907 if dsInfo['nDim'] == 3:
905 ds0 = grp0.create_dataset(tableName, (shape[0],shape[1],1) , data = numpy.zeros((shape[0],shape[1],1)), maxshape = (None,shape[1],None), chunks=True)
908 ds0 = grp0.create_dataset(tableName, (shape[0],shape[1],1) , data = numpy.zeros((shape[0],shape[1],1)), maxshape = (None,shape[1],None), chunks=True)
906 else:
909 else:
907 ds0 = grp0.create_dataset(tableName, (1,shape), data = numpy.zeros((1,shape)) , maxshape=(None,shape), chunks=True)
910 ds0 = grp0.create_dataset(tableName, (1,shape), data = numpy.zeros((1,shape)) , maxshape=(None,shape), chunks=True)
908
911
909 ds.append(ds0)
912 ds.append(ds0)
910 data.append([])
913 data.append([])
911 i += 1
914 i += 1
912 # nDimsForDs.append(nDims[i])
915 # nDimsForDs.append(nDims[i])
913
916
914 fp.flush()
917 fp.flush()
915 fp.close()
918 fp.close()
916
919
917 # self.nDatas = nDatas
920 # self.nDatas = nDatas
918 # self.nDims = nDims
921 # self.nDims = nDims
919 # self.nDimsForDs = nDimsForDs
922 # self.nDimsForDs = nDimsForDs
920 #Saving variables
923 #Saving variables
921 print 'Writing the file: %s'%filename
924 print 'Writing the file: %s'%filename
922 self.filename = filename
925 self.filename = filename
923 # self.fp = fp
926 # self.fp = fp
924 # self.grp = grp
927 # self.grp = grp
925 # self.grp.attrs.modify('nRecords', 1)
928 # self.grp.attrs.modify('nRecords', 1)
926 self.ds = ds
929 self.ds = ds
927 self.data = data
930 self.data = data
928 # self.setFile = setFile
931 # self.setFile = setFile
929 self.firsttime = True
932 self.firsttime = True
930 self.blockIndex = 0
933 self.blockIndex = 0
931 return
934 return
932
935
933 def putData(self):
936 def putData(self):
934
937
935 if self.blockIndex == self.blocksPerFile or self.timeFlag():
938 if self.blockIndex == self.blocksPerFile or self.timeFlag():
936 self.setNextFile()
939 self.setNextFile()
937
940
938 # if not self.firsttime:
941 # if not self.firsttime:
939 self.readBlock()
942 self.readBlock()
940 self.setBlock() #Prepare data to be written
943 self.setBlock() #Prepare data to be written
941 self.writeBlock() #Write data
944 self.writeBlock() #Write data
942
945
943 return
946 return
944
947
945 def readBlock(self):
948 def readBlock(self):
946
949
947 '''
950 '''
948 data Array configured
951 data Array configured
949
952
950
953
951 self.data
954 self.data
952 '''
955 '''
953 dsList = self.dsList
956 dsList = self.dsList
954 ds = self.ds
957 ds = self.ds
955 #Setting HDF5 File
958 #Setting HDF5 File
956 fp = h5py.File(self.filename,'r+')
959 fp = h5py.File(self.filename,'r+')
957 grp = fp["Data"]
960 grp = fp["Data"]
958 ind = 0
961 ind = 0
959
962
960 # grp.attrs['blocksPerFile'] = 0
963 # grp.attrs['blocksPerFile'] = 0
961 while ind < len(dsList):
964 while ind < len(dsList):
962 dsInfo = dsList[ind]
965 dsInfo = dsList[ind]
963
966
964 if dsInfo['mode'] == 0:
967 if dsInfo['mode'] == 0:
965 ds0 = grp[dsInfo['variable']]
968 ds0 = grp[dsInfo['variable']]
966 ds[ind] = ds0
969 ds[ind] = ds0
967 ind += 1
970 ind += 1
968 else:
971 else:
969
972
970 grp0 = grp[dsInfo['variable']]
973 grp0 = grp[dsInfo['variable']]
971
974
972 for j in range(dsInfo['dsNumber']):
975 for j in range(dsInfo['dsNumber']):
973 dsInfo = dsList[ind]
976 dsInfo = dsList[ind]
974 ds0 = grp0[dsInfo['dsName']]
977 ds0 = grp0[dsInfo['dsName']]
975 ds[ind] = ds0
978 ds[ind] = ds0
976 ind += 1
979 ind += 1
977
980
978 self.fp = fp
981 self.fp = fp
979 self.grp = grp
982 self.grp = grp
980 self.ds = ds
983 self.ds = ds
981
984
982 return
985 return
983
986
984 def setBlock(self):
987 def setBlock(self):
985 '''
988 '''
986 data Array configured
989 data Array configured
987
990
988
991
989 self.data
992 self.data
990 '''
993 '''
991 #Creating Arrays
994 #Creating Arrays
992 dsList = self.dsList
995 dsList = self.dsList
993 data = self.data
996 data = self.data
994 ind = 0
997 ind = 0
995
998
996 while ind < len(dsList):
999 while ind < len(dsList):
997 dsInfo = dsList[ind]
1000 dsInfo = dsList[ind]
998 dataAux = getattr(self.dataOut, dsInfo['variable'])
1001 dataAux = getattr(self.dataOut, dsInfo['variable'])
999
1002
1000 mode = dsInfo['mode']
1003 mode = dsInfo['mode']
1001 nDim = dsInfo['nDim']
1004 nDim = dsInfo['nDim']
1002
1005
1003 if mode == 0 or mode == 2 or nDim == 1:
1006 if mode == 0 or mode == 2 or nDim == 1:
1004 data[ind] = dataAux
1007 data[ind] = dataAux
1005 ind += 1
1008 ind += 1
1006 # elif nDim == 1:
1009 # elif nDim == 1:
1007 # data[ind] = numpy.reshape(dataAux,(numpy.size(dataAux),1))
1010 # data[ind] = numpy.reshape(dataAux,(numpy.size(dataAux),1))
1008 # ind += 1
1011 # ind += 1
1009 elif nDim == 2:
1012 elif nDim == 2:
1010 for j in range(dsInfo['dsNumber']):
1013 for j in range(dsInfo['dsNumber']):
1011 data[ind] = dataAux[j,:]
1014 data[ind] = dataAux[j,:]
1012 ind += 1
1015 ind += 1
1013 elif nDim == 3:
1016 elif nDim == 3:
1014 for j in range(dsInfo['dsNumber']):
1017 for j in range(dsInfo['dsNumber']):
1015 data[ind] = dataAux[:,j,:]
1018 data[ind] = dataAux[:,j,:]
1016 ind += 1
1019 ind += 1
1017
1020
1018 self.data = data
1021 self.data = data
1019 return
1022 return
1020
1023
1021 def writeBlock(self):
1024 def writeBlock(self):
1022 '''
1025 '''
1023 Saves the block in the HDF5 file
1026 Saves the block in the HDF5 file
1024 '''
1027 '''
1025 dsList = self.dsList
1028 dsList = self.dsList
1026
1029
1027 for i in range(len(self.ds)):
1030 for i in range(len(self.ds)):
1028 dsInfo = dsList[i]
1031 dsInfo = dsList[i]
1029 nDim = dsInfo['nDim']
1032 nDim = dsInfo['nDim']
1030 mode = dsInfo['mode']
1033 mode = dsInfo['mode']
1031
1034
1032 # First time
1035 # First time
1033 if self.firsttime:
1036 if self.firsttime:
1034 # self.ds[i].resize(self.data[i].shape)
1037 # self.ds[i].resize(self.data[i].shape)
1035 # self.ds[i][self.blockIndex,:] = self.data[i]
1038 # self.ds[i][self.blockIndex,:] = self.data[i]
1036 if type(self.data[i]) == numpy.ndarray:
1039 if type(self.data[i]) == numpy.ndarray:
1037
1040
1038 if nDim == 3:
1041 if nDim == 3:
1039 self.data[i] = self.data[i].reshape((self.data[i].shape[0],self.data[i].shape[1],1))
1042 self.data[i] = self.data[i].reshape((self.data[i].shape[0],self.data[i].shape[1],1))
1040 self.ds[i].resize(self.data[i].shape)
1043 self.ds[i].resize(self.data[i].shape)
1041 if mode == 2:
1044 if mode == 2:
1042 self.ds[i].resize(self.data[i].shape)
1045 self.ds[i].resize(self.data[i].shape)
1043 self.ds[i][:] = self.data[i]
1046 self.ds[i][:] = self.data[i]
1044 else:
1047 else:
1045
1048
1046 # From second time
1049 # From second time
1047 # Meteors!
1050 # Meteors!
1048 if mode == 2:
1051 if mode == 2:
1049 dataShape = self.data[i].shape
1052 dataShape = self.data[i].shape
1050 dsShape = self.ds[i].shape
1053 dsShape = self.ds[i].shape
1051 self.ds[i].resize((self.ds[i].shape[0] + dataShape[0],self.ds[i].shape[1]))
1054 self.ds[i].resize((self.ds[i].shape[0] + dataShape[0],self.ds[i].shape[1]))
1052 self.ds[i][dsShape[0]:,:] = self.data[i]
1055 self.ds[i][dsShape[0]:,:] = self.data[i]
1053 # No dimension
1056 # No dimension
1054 elif mode == 0:
1057 elif mode == 0:
1055 self.ds[i].resize((self.ds[i].shape[0], self.ds[i].shape[1] + 1))
1058 self.ds[i].resize((self.ds[i].shape[0], self.ds[i].shape[1] + 1))
1056 self.ds[i][0,-1] = self.data[i]
1059 self.ds[i][0,-1] = self.data[i]
1057 # One dimension
1060 # One dimension
1058 elif nDim == 1:
1061 elif nDim == 1:
1059 self.ds[i].resize((self.ds[i].shape[0] + 1, self.ds[i].shape[1]))
1062 self.ds[i].resize((self.ds[i].shape[0] + 1, self.ds[i].shape[1]))
1060 self.ds[i][-1,:] = self.data[i]
1063 self.ds[i][-1,:] = self.data[i]
1061 # Two dimension
1064 # Two dimension
1062 elif nDim == 2:
1065 elif nDim == 2:
1063 self.ds[i].resize((self.ds[i].shape[0] + 1,self.ds[i].shape[1]))
1066 self.ds[i].resize((self.ds[i].shape[0] + 1,self.ds[i].shape[1]))
1064 self.ds[i][self.blockIndex,:] = self.data[i]
1067 self.ds[i][self.blockIndex,:] = self.data[i]
1065 # Three dimensions
1068 # Three dimensions
1066 elif nDim == 3:
1069 elif nDim == 3:
1067 self.ds[i].resize((self.ds[i].shape[0],self.ds[i].shape[1],self.ds[i].shape[2]+1))
1070 self.ds[i].resize((self.ds[i].shape[0],self.ds[i].shape[1],self.ds[i].shape[2]+1))
1068 self.ds[i][:,:,-1] = self.data[i]
1071 self.ds[i][:,:,-1] = self.data[i]
1069
1072
1070 self.firsttime = False
1073 self.firsttime = False
1071 self.blockIndex += 1
1074 self.blockIndex += 1
1072
1075
1073 #Close to save changes
1076 #Close to save changes
1074 self.fp.flush()
1077 self.fp.flush()
1075 self.fp.close()
1078 self.fp.close()
1076 return
1079 return
1077
1080
1078 def run(self, dataOut, **kwargs):
1081 def run(self, dataOut, **kwargs):
1079
1082
1080 if not(self.isConfig):
1083 if not(self.isConfig):
1084
1081 flagdata = self.setup(dataOut, **kwargs)
1085 flagdata = self.setup(dataOut, **kwargs)
1082
1086
1083 if not(flagdata):
1087 if not(flagdata):
1084 return
1088 return
1085
1089
1086 self.isConfig = True
1090 self.isConfig = True
1087 # self.putMetadata()
1091 # self.putMetadata()
1088 self.setNextFile()
1092 self.setNextFile()
1089
1093
1090 self.putData()
1094 self.putData()
1091 return
1095 return
1 NO CONTENT: modified file
NO CONTENT: modified file
The requested commit or file is too big and content was truncated. Show full diff
@@ -1,1067 +1,1078
1 import numpy
1 import numpy
2
2
3 from jroproc_base import ProcessingUnit, Operation
3 from jroproc_base import ProcessingUnit, Operation
4 from schainpy.model.data.jrodata import Spectra
4 from schainpy.model.data.jrodata import Spectra
5 from schainpy.model.data.jrodata import hildebrand_sekhon
5 from schainpy.model.data.jrodata import hildebrand_sekhon
6
6
7 import matplotlib.pyplot as plt
7 import matplotlib.pyplot as plt
8
8
9 class SpectraProc(ProcessingUnit):
9 class SpectraProc(ProcessingUnit):
10
10
11 def __init__(self, **kwargs):
11 def __init__(self, **kwargs):
12
12
13 ProcessingUnit.__init__(self, **kwargs)
13 ProcessingUnit.__init__(self, **kwargs)
14
14
15 self.buffer = None
15 self.buffer = None
16 self.firstdatatime = None
16 self.firstdatatime = None
17 self.profIndex = 0
17 self.profIndex = 0
18 self.dataOut = Spectra()
18 self.dataOut = Spectra()
19 self.id_min = None
19 self.id_min = None
20 self.id_max = None
20 self.id_max = None
21
21
22 def __updateSpecFromVoltage(self):
22 def __updateSpecFromVoltage(self):
23
23
24 self.dataOut.timeZone = self.dataIn.timeZone
24 self.dataOut.timeZone = self.dataIn.timeZone
25 self.dataOut.dstFlag = self.dataIn.dstFlag
25 self.dataOut.dstFlag = self.dataIn.dstFlag
26 self.dataOut.errorCount = self.dataIn.errorCount
26 self.dataOut.errorCount = self.dataIn.errorCount
27 self.dataOut.useLocalTime = self.dataIn.useLocalTime
27 self.dataOut.useLocalTime = self.dataIn.useLocalTime
28
28
29 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
29 self.dataOut.radarControllerHeaderObj = self.dataIn.radarControllerHeaderObj.copy()
30 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()
30 self.dataOut.systemHeaderObj = self.dataIn.systemHeaderObj.copy()
31 self.dataOut.channelList = self.dataIn.channelList
31 self.dataOut.channelList = self.dataIn.channelList
32 self.dataOut.heightList = self.dataIn.heightList
32 self.dataOut.heightList = self.dataIn.heightList
33 self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')])
33 self.dataOut.dtype = numpy.dtype([('real','<f4'),('imag','<f4')])
34
34
35 self.dataOut.nBaud = self.dataIn.nBaud
35 self.dataOut.nBaud = self.dataIn.nBaud
36 self.dataOut.nCode = self.dataIn.nCode
36 self.dataOut.nCode = self.dataIn.nCode
37 self.dataOut.code = self.dataIn.code
37 self.dataOut.code = self.dataIn.code
38 self.dataOut.nProfiles = self.dataOut.nFFTPoints
38 self.dataOut.nProfiles = self.dataOut.nFFTPoints
39
39
40 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
40 self.dataOut.flagDiscontinuousBlock = self.dataIn.flagDiscontinuousBlock
41 self.dataOut.utctime = self.firstdatatime
41 self.dataOut.utctime = self.firstdatatime
42 self.dataOut.flagDecodeData = self.dataIn.flagDecodeData #asumo q la data esta decodificada
42 self.dataOut.flagDecodeData = self.dataIn.flagDecodeData #asumo q la data esta decodificada
43 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip
43 self.dataOut.flagDeflipData = self.dataIn.flagDeflipData #asumo q la data esta sin flip
44 self.dataOut.flagShiftFFT = False
44 self.dataOut.flagShiftFFT = False
45
45
46 self.dataOut.nCohInt = self.dataIn.nCohInt
46 self.dataOut.nCohInt = self.dataIn.nCohInt
47 self.dataOut.nIncohInt = 1
47 self.dataOut.nIncohInt = 1
48
48
49 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
49 self.dataOut.windowOfFilter = self.dataIn.windowOfFilter
50
50
51 self.dataOut.frequency = self.dataIn.frequency
51 self.dataOut.frequency = self.dataIn.frequency
52 self.dataOut.realtime = self.dataIn.realtime
52 self.dataOut.realtime = self.dataIn.realtime
53
53
54 self.dataOut.azimuth = self.dataIn.azimuth
54 self.dataOut.azimuth = self.dataIn.azimuth
55 self.dataOut.zenith = self.dataIn.zenith
55 self.dataOut.zenith = self.dataIn.zenith
56
56
57 self.dataOut.beam.codeList = self.dataIn.beam.codeList
57 self.dataOut.beam.codeList = self.dataIn.beam.codeList
58 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
58 self.dataOut.beam.azimuthList = self.dataIn.beam.azimuthList
59 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
59 self.dataOut.beam.zenithList = self.dataIn.beam.zenithList
60
60
61 def __getFft(self):
61 def __getFft(self):
62 """
62 """
63 Convierte valores de Voltaje a Spectra
63 Convierte valores de Voltaje a Spectra
64
64
65 Affected:
65 Affected:
66 self.dataOut.data_spc
66 self.dataOut.data_spc
67 self.dataOut.data_cspc
67 self.dataOut.data_cspc
68 self.dataOut.data_dc
68 self.dataOut.data_dc
69 self.dataOut.heightList
69 self.dataOut.heightList
70 self.profIndex
70 self.profIndex
71 self.buffer
71 self.buffer
72 self.dataOut.flagNoData
72 self.dataOut.flagNoData
73 """
73 """
74 fft_volt = numpy.fft.fft(self.buffer,n=self.dataOut.nFFTPoints,axis=1)
74 fft_volt = numpy.fft.fft(self.buffer,n=self.dataOut.nFFTPoints,axis=1)
75
75
76 fft_volt = fft_volt.astype(numpy.dtype('complex'))
76 fft_volt = fft_volt.astype(numpy.dtype('complex'))
77 dc = fft_volt[:,0,:]
77 dc = fft_volt[:,0,:]
78
78
79 #calculo de self-spectra
79 #calculo de self-spectra
80 fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,))
80 fft_volt = numpy.fft.fftshift(fft_volt,axes=(1,))
81 spc = fft_volt * numpy.conjugate(fft_volt)
81 spc = fft_volt * numpy.conjugate(fft_volt)
82 spc = spc.real
82 spc = spc.real
83
83
84 blocksize = 0
84 blocksize = 0
85 blocksize += dc.size
85 blocksize += dc.size
86 blocksize += spc.size
86 blocksize += spc.size
87
87
88 cspc = None
88 cspc = None
89 pairIndex = 0
89 pairIndex = 0
90 if self.dataOut.pairsList != None:
90 if self.dataOut.pairsList != None:
91 #calculo de cross-spectra
91 #calculo de cross-spectra
92 cspc = numpy.zeros((self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex')
92 cspc = numpy.zeros((self.dataOut.nPairs, self.dataOut.nFFTPoints, self.dataOut.nHeights), dtype='complex')
93 for pair in self.dataOut.pairsList:
93 for pair in self.dataOut.pairsList:
94 if pair[0] not in self.dataOut.channelList:
94 if pair[0] not in self.dataOut.channelList:
95 raise ValueError, "Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList))
95 raise ValueError, "Error getting CrossSpectra: pair 0 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList))
96 if pair[1] not in self.dataOut.channelList:
96 if pair[1] not in self.dataOut.channelList:
97 raise ValueError, "Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList))
97 raise ValueError, "Error getting CrossSpectra: pair 1 of %s is not in channelList = %s" %(str(pair), str(self.dataOut.channelList))
98
98
99 cspc[pairIndex,:,:] = fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])
99 cspc[pairIndex,:,:] = fft_volt[pair[0],:,:] * numpy.conjugate(fft_volt[pair[1],:,:])
100 pairIndex += 1
100 pairIndex += 1
101 blocksize += cspc.size
101 blocksize += cspc.size
102
102
103 self.dataOut.data_spc = spc
103 self.dataOut.data_spc = spc
104 self.dataOut.data_cspc = cspc
104 self.dataOut.data_cspc = cspc
105 self.dataOut.data_dc = dc
105 self.dataOut.data_dc = dc
106 self.dataOut.blockSize = blocksize
106 self.dataOut.blockSize = blocksize
107 self.dataOut.flagShiftFFT = True
107 self.dataOut.flagShiftFFT = True
108
108
109 def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], ippFactor=None):
109 def run(self, nProfiles=None, nFFTPoints=None, pairsList=[], ippFactor=None):
110
110
111 self.dataOut.flagNoData = True
111 self.dataOut.flagNoData = True
112
112
113 if self.dataIn.type == "Spectra":
113 if self.dataIn.type == "Spectra":
114 self.dataOut.copy(self.dataIn)
114 self.dataOut.copy(self.dataIn)
115 # self.__selectPairs(pairsList)
115 # self.__selectPairs(pairsList)
116 return True
116 return True
117
117
118 if self.dataIn.type == "Voltage":
118 if self.dataIn.type == "Voltage":
119
119
120 if nFFTPoints == None:
120 if nFFTPoints == None:
121 raise ValueError, "This SpectraProc.run() need nFFTPoints input variable"
121 raise ValueError, "This SpectraProc.run() need nFFTPoints input variable"
122
122
123 if nProfiles == None:
123 if nProfiles == None:
124 nProfiles = nFFTPoints
124 nProfiles = nFFTPoints
125
125
126 if ippFactor == None:
126 if ippFactor == None:
127 ippFactor = 1
127 ippFactor = 1
128
128
129 self.dataOut.ippFactor = ippFactor
129 self.dataOut.ippFactor = ippFactor
130
130
131 self.dataOut.nFFTPoints = nFFTPoints
131 self.dataOut.nFFTPoints = nFFTPoints
132 self.dataOut.pairsList = pairsList
132 self.dataOut.pairsList = pairsList
133
133
134 if self.buffer is None:
134 if self.buffer is None:
135 self.buffer = numpy.zeros( (self.dataIn.nChannels,
135 self.buffer = numpy.zeros( (self.dataIn.nChannels,
136 nProfiles,
136 nProfiles,
137 self.dataIn.nHeights),
137 self.dataIn.nHeights),
138 dtype='complex')
138 dtype='complex')
139
139
140 if self.dataIn.flagDataAsBlock:
140 if self.dataIn.flagDataAsBlock:
141 #data dimension: [nChannels, nProfiles, nSamples]
141 #data dimension: [nChannels, nProfiles, nSamples]
142
142
143 nVoltProfiles = self.dataIn.data.shape[1]
143 nVoltProfiles = self.dataIn.data.shape[1]
144 # nVoltProfiles = self.dataIn.nProfiles
144 # nVoltProfiles = self.dataIn.nProfiles
145
145
146 if nVoltProfiles == nProfiles:
146 if nVoltProfiles == nProfiles:
147 self.buffer = self.dataIn.data.copy()
147 self.buffer = self.dataIn.data.copy()
148 self.profIndex = nVoltProfiles
148 self.profIndex = nVoltProfiles
149
149
150 elif nVoltProfiles < nProfiles:
150 elif nVoltProfiles < nProfiles:
151
151
152 if self.profIndex == 0:
152 if self.profIndex == 0:
153 self.id_min = 0
153 self.id_min = 0
154 self.id_max = nVoltProfiles
154 self.id_max = nVoltProfiles
155
155
156 self.buffer[:,self.id_min:self.id_max,:] = self.dataIn.data
156 self.buffer[:,self.id_min:self.id_max,:] = self.dataIn.data
157 self.profIndex += nVoltProfiles
157 self.profIndex += nVoltProfiles
158 self.id_min += nVoltProfiles
158 self.id_min += nVoltProfiles
159 self.id_max += nVoltProfiles
159 self.id_max += nVoltProfiles
160 else:
160 else:
161 raise ValueError, "The type object %s has %d profiles, it should just has %d profiles"%(self.dataIn.type,self.dataIn.data.shape[1],nProfiles)
161 raise ValueError, "The type object %s has %d profiles, it should just has %d profiles"%(self.dataIn.type,self.dataIn.data.shape[1],nProfiles)
162 self.dataOut.flagNoData = True
162 self.dataOut.flagNoData = True
163 return 0
163 return 0
164 else:
164 else:
165
165
166 self.buffer[:,self.profIndex,:] = self.dataIn.data.copy()
166 self.buffer[:,self.profIndex,:] = self.dataIn.data.copy()
167 self.profIndex += 1
167 self.profIndex += 1
168
168
169 if self.firstdatatime == None:
169 if self.firstdatatime == None:
170 self.firstdatatime = self.dataIn.utctime
170 self.firstdatatime = self.dataIn.utctime
171
171
172 if self.profIndex == nProfiles:
172 if self.profIndex == nProfiles:
173 self.__updateSpecFromVoltage()
173 self.__updateSpecFromVoltage()
174 self.__getFft()
174 self.__getFft()
175
175
176 self.dataOut.flagNoData = False
176 self.dataOut.flagNoData = False
177 self.firstdatatime = None
177 self.firstdatatime = None
178 self.profIndex = 0
178 self.profIndex = 0
179
179
180 return True
180 return True
181
181
182 raise ValueError, "The type of input object '%s' is not valid"%(self.dataIn.type)
182 raise ValueError, "The type of input object '%s' is not valid"%(self.dataIn.type)
183
183
184 def __selectPairs(self, pairsList):
184 def __selectPairs(self, pairsList):
185
185
186 if channelList == None:
186 if channelList == None:
187 return
187 return
188
188
189 pairsIndexListSelected = []
189 pairsIndexListSelected = []
190
190
191 for thisPair in pairsList:
191 for thisPair in pairsList:
192
192
193 if thisPair not in self.dataOut.pairsList:
193 if thisPair not in self.dataOut.pairsList:
194 continue
194 continue
195
195
196 pairIndex = self.dataOut.pairsList.index(thisPair)
196 pairIndex = self.dataOut.pairsList.index(thisPair)
197
197
198 pairsIndexListSelected.append(pairIndex)
198 pairsIndexListSelected.append(pairIndex)
199
199
200 if not pairsIndexListSelected:
200 if not pairsIndexListSelected:
201 self.dataOut.data_cspc = None
201 self.dataOut.data_cspc = None
202 self.dataOut.pairsList = []
202 self.dataOut.pairsList = []
203 return
203 return
204
204
205 self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected]
205 self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected]
206 self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected]
206 self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected]
207
207
208 return
208 return
209
209
210 def __selectPairsByChannel(self, channelList=None):
210 def __selectPairsByChannel(self, channelList=None):
211
211
212 if channelList == None:
212 if channelList == None:
213 return
213 return
214
214
215 pairsIndexListSelected = []
215 pairsIndexListSelected = []
216 for pairIndex in self.dataOut.pairsIndexList:
216 for pairIndex in self.dataOut.pairsIndexList:
217 #First pair
217 #First pair
218 if self.dataOut.pairsList[pairIndex][0] not in channelList:
218 if self.dataOut.pairsList[pairIndex][0] not in channelList:
219 continue
219 continue
220 #Second pair
220 #Second pair
221 if self.dataOut.pairsList[pairIndex][1] not in channelList:
221 if self.dataOut.pairsList[pairIndex][1] not in channelList:
222 continue
222 continue
223
223
224 pairsIndexListSelected.append(pairIndex)
224 pairsIndexListSelected.append(pairIndex)
225
225
226 if not pairsIndexListSelected:
226 if not pairsIndexListSelected:
227 self.dataOut.data_cspc = None
227 self.dataOut.data_cspc = None
228 self.dataOut.pairsList = []
228 self.dataOut.pairsList = []
229 return
229 return
230
230
231 self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected]
231 self.dataOut.data_cspc = self.dataOut.data_cspc[pairsIndexListSelected]
232 self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected]
232 self.dataOut.pairsList = [self.dataOut.pairsList[i] for i in pairsIndexListSelected]
233
233
234 return
234 return
235
235
236 def selectChannels(self, channelList):
236 def selectChannels(self, channelList):
237
237
238 channelIndexList = []
238 channelIndexList = []
239
239
240 for channel in channelList:
240 for channel in channelList:
241 if channel not in self.dataOut.channelList:
241 if channel not in self.dataOut.channelList:
242 raise ValueError, "Error selecting channels, Channel %d is not valid.\nAvailable channels = %s" %(channel, str(self.dataOut.channelList))
242 raise ValueError, "Error selecting channels, Channel %d is not valid.\nAvailable channels = %s" %(channel, str(self.dataOut.channelList))
243
243
244 index = self.dataOut.channelList.index(channel)
244 index = self.dataOut.channelList.index(channel)
245 channelIndexList.append(index)
245 channelIndexList.append(index)
246
246
247 self.selectChannelsByIndex(channelIndexList)
247 self.selectChannelsByIndex(channelIndexList)
248
248
249 def selectChannelsByIndex(self, channelIndexList):
249 def selectChannelsByIndex(self, channelIndexList):
250 """
250 """
251 Selecciona un bloque de datos en base a canales segun el channelIndexList
251 Selecciona un bloque de datos en base a canales segun el channelIndexList
252
252
253 Input:
253 Input:
254 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
254 channelIndexList : lista sencilla de canales a seleccionar por ej. [2,3,7]
255
255
256 Affected:
256 Affected:
257 self.dataOut.data_spc
257 self.dataOut.data_spc
258 self.dataOut.channelIndexList
258 self.dataOut.channelIndexList
259 self.dataOut.nChannels
259 self.dataOut.nChannels
260
260
261 Return:
261 Return:
262 None
262 None
263 """
263 """
264
264
265 for channelIndex in channelIndexList:
265 for channelIndex in channelIndexList:
266 if channelIndex not in self.dataOut.channelIndexList:
266 if channelIndex not in self.dataOut.channelIndexList:
267 raise ValueError, "Error selecting channels: The value %d in channelIndexList is not valid.\nAvailable channel indexes = " %(channelIndex, self.dataOut.channelIndexList)
267 raise ValueError, "Error selecting channels: The value %d in channelIndexList is not valid.\nAvailable channel indexes = " %(channelIndex, self.dataOut.channelIndexList)
268
268
269 # nChannels = len(channelIndexList)
269 # nChannels = len(channelIndexList)
270
270
271 data_spc = self.dataOut.data_spc[channelIndexList,:]
271 data_spc = self.dataOut.data_spc[channelIndexList,:]
272 data_dc = self.dataOut.data_dc[channelIndexList,:]
272 data_dc = self.dataOut.data_dc[channelIndexList,:]
273
273
274 self.dataOut.data_spc = data_spc
274 self.dataOut.data_spc = data_spc
275 self.dataOut.data_dc = data_dc
275 self.dataOut.data_dc = data_dc
276
276
277 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
277 self.dataOut.channelList = [self.dataOut.channelList[i] for i in channelIndexList]
278 # self.dataOut.nChannels = nChannels
278 # self.dataOut.nChannels = nChannels
279
279
280 self.__selectPairsByChannel(self.dataOut.channelList)
280 self.__selectPairsByChannel(self.dataOut.channelList)
281
281
282 return 1
282 return 1
283
283
284
284
285 def selectFFTs(self, minFFT, maxFFT ):
285 def selectFFTs(self, minFFT, maxFFT ):
286 """
286 """
287 Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango
287 Selecciona un bloque de datos en base a un grupo de valores de puntos FFTs segun el rango
288 minFFT<= FFT <= maxFFT
288 minFFT<= FFT <= maxFFT
289 """
289 """
290
290
291 if (minFFT > maxFFT):
291 if (minFFT > maxFFT):
292 raise ValueError, "Error selecting heights: Height range (%d,%d) is not valid" % (minFFT, maxFFT)
292 raise ValueError, "Error selecting heights: Height range (%d,%d) is not valid" % (minFFT, maxFFT)
293
293
294 if (minFFT < self.dataOut.getFreqRange()[0]):
294 if (minFFT < self.dataOut.getFreqRange()[0]):
295 minFFT = self.dataOut.getFreqRange()[0]
295 minFFT = self.dataOut.getFreqRange()[0]
296
296
297 if (maxFFT > self.dataOut.getFreqRange()[-1]):
297 if (maxFFT > self.dataOut.getFreqRange()[-1]):
298 maxFFT = self.dataOut.getFreqRange()[-1]
298 maxFFT = self.dataOut.getFreqRange()[-1]
299
299
300 minIndex = 0
300 minIndex = 0
301 maxIndex = 0
301 maxIndex = 0
302 FFTs = self.dataOut.getFreqRange()
302 FFTs = self.dataOut.getFreqRange()
303
303
304 inda = numpy.where(FFTs >= minFFT)
304 inda = numpy.where(FFTs >= minFFT)
305 indb = numpy.where(FFTs <= maxFFT)
305 indb = numpy.where(FFTs <= maxFFT)
306
306
307 try:
307 try:
308 minIndex = inda[0][0]
308 minIndex = inda[0][0]
309 except:
309 except:
310 minIndex = 0
310 minIndex = 0
311
311
312 try:
312 try:
313 maxIndex = indb[0][-1]
313 maxIndex = indb[0][-1]
314 except:
314 except:
315 maxIndex = len(FFTs)
315 maxIndex = len(FFTs)
316
316
317 self.selectFFTsByIndex(minIndex, maxIndex)
317 self.selectFFTsByIndex(minIndex, maxIndex)
318
318
319 return 1
319 return 1
320
320
321
321
322 def setH0(self, h0, deltaHeight = None):
323
324 if not deltaHeight:
325 deltaHeight = self.dataOut.heightList[1] - self.dataOut.heightList[0]
326
327 nHeights = self.dataOut.nHeights
328
329 newHeiRange = h0 + numpy.arange(nHeights)*deltaHeight
330
331 self.dataOut.heightList = newHeiRange
332
322
333
323 def selectHeights(self, minHei, maxHei):
334 def selectHeights(self, minHei, maxHei):
324 """
335 """
325 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
336 Selecciona un bloque de datos en base a un grupo de valores de alturas segun el rango
326 minHei <= height <= maxHei
337 minHei <= height <= maxHei
327
338
328 Input:
339 Input:
329 minHei : valor minimo de altura a considerar
340 minHei : valor minimo de altura a considerar
330 maxHei : valor maximo de altura a considerar
341 maxHei : valor maximo de altura a considerar
331
342
332 Affected:
343 Affected:
333 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
344 Indirectamente son cambiados varios valores a travez del metodo selectHeightsByIndex
334
345
335 Return:
346 Return:
336 1 si el metodo se ejecuto con exito caso contrario devuelve 0
347 1 si el metodo se ejecuto con exito caso contrario devuelve 0
337 """
348 """
338
349
339
350
340 if (minHei > maxHei):
351 if (minHei > maxHei):
341 raise ValueError, "Error selecting heights: Height range (%d,%d) is not valid" % (minHei, maxHei)
352 raise ValueError, "Error selecting heights: Height range (%d,%d) is not valid" % (minHei, maxHei)
342
353
343 if (minHei < self.dataOut.heightList[0]):
354 if (minHei < self.dataOut.heightList[0]):
344 minHei = self.dataOut.heightList[0]
355 minHei = self.dataOut.heightList[0]
345
356
346 if (maxHei > self.dataOut.heightList[-1]):
357 if (maxHei > self.dataOut.heightList[-1]):
347 maxHei = self.dataOut.heightList[-1]
358 maxHei = self.dataOut.heightList[-1]
348
359
349 minIndex = 0
360 minIndex = 0
350 maxIndex = 0
361 maxIndex = 0
351 heights = self.dataOut.heightList
362 heights = self.dataOut.heightList
352
363
353 inda = numpy.where(heights >= minHei)
364 inda = numpy.where(heights >= minHei)
354 indb = numpy.where(heights <= maxHei)
365 indb = numpy.where(heights <= maxHei)
355
366
356 try:
367 try:
357 minIndex = inda[0][0]
368 minIndex = inda[0][0]
358 except:
369 except:
359 minIndex = 0
370 minIndex = 0
360
371
361 try:
372 try:
362 maxIndex = indb[0][-1]
373 maxIndex = indb[0][-1]
363 except:
374 except:
364 maxIndex = len(heights)
375 maxIndex = len(heights)
365
376
366 self.selectHeightsByIndex(minIndex, maxIndex)
377 self.selectHeightsByIndex(minIndex, maxIndex)
367
378
368
379
369 return 1
380 return 1
370
381
371 def getBeaconSignal(self, tauindex = 0, channelindex = 0, hei_ref=None):
382 def getBeaconSignal(self, tauindex = 0, channelindex = 0, hei_ref=None):
372 newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex])
383 newheis = numpy.where(self.dataOut.heightList>self.dataOut.radarControllerHeaderObj.Taus[tauindex])
373
384
374 if hei_ref != None:
385 if hei_ref != None:
375 newheis = numpy.where(self.dataOut.heightList>hei_ref)
386 newheis = numpy.where(self.dataOut.heightList>hei_ref)
376
387
377 minIndex = min(newheis[0])
388 minIndex = min(newheis[0])
378 maxIndex = max(newheis[0])
389 maxIndex = max(newheis[0])
379 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
390 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
380 heightList = self.dataOut.heightList[minIndex:maxIndex+1]
391 heightList = self.dataOut.heightList[minIndex:maxIndex+1]
381
392
382 # determina indices
393 # determina indices
383 nheis = int(self.dataOut.radarControllerHeaderObj.txB/(self.dataOut.heightList[1]-self.dataOut.heightList[0]))
394 nheis = int(self.dataOut.radarControllerHeaderObj.txB/(self.dataOut.heightList[1]-self.dataOut.heightList[0]))
384 avg_dB = 10*numpy.log10(numpy.sum(data_spc[channelindex,:,:],axis=0))
395 avg_dB = 10*numpy.log10(numpy.sum(data_spc[channelindex,:,:],axis=0))
385 beacon_dB = numpy.sort(avg_dB)[-nheis:]
396 beacon_dB = numpy.sort(avg_dB)[-nheis:]
386 beacon_heiIndexList = []
397 beacon_heiIndexList = []
387 for val in avg_dB.tolist():
398 for val in avg_dB.tolist():
388 if val >= beacon_dB[0]:
399 if val >= beacon_dB[0]:
389 beacon_heiIndexList.append(avg_dB.tolist().index(val))
400 beacon_heiIndexList.append(avg_dB.tolist().index(val))
390
401
391 #data_spc = data_spc[:,:,beacon_heiIndexList]
402 #data_spc = data_spc[:,:,beacon_heiIndexList]
392 data_cspc = None
403 data_cspc = None
393 if self.dataOut.data_cspc is not None:
404 if self.dataOut.data_cspc is not None:
394 data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1]
405 data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1]
395 #data_cspc = data_cspc[:,:,beacon_heiIndexList]
406 #data_cspc = data_cspc[:,:,beacon_heiIndexList]
396
407
397 data_dc = None
408 data_dc = None
398 if self.dataOut.data_dc is not None:
409 if self.dataOut.data_dc is not None:
399 data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1]
410 data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1]
400 #data_dc = data_dc[:,beacon_heiIndexList]
411 #data_dc = data_dc[:,beacon_heiIndexList]
401
412
402 self.dataOut.data_spc = data_spc
413 self.dataOut.data_spc = data_spc
403 self.dataOut.data_cspc = data_cspc
414 self.dataOut.data_cspc = data_cspc
404 self.dataOut.data_dc = data_dc
415 self.dataOut.data_dc = data_dc
405 self.dataOut.heightList = heightList
416 self.dataOut.heightList = heightList
406 self.dataOut.beacon_heiIndexList = beacon_heiIndexList
417 self.dataOut.beacon_heiIndexList = beacon_heiIndexList
407
418
408 return 1
419 return 1
409
420
410 def selectFFTsByIndex(self, minIndex, maxIndex):
421 def selectFFTsByIndex(self, minIndex, maxIndex):
411 """
422 """
412
423
413 """
424 """
414
425
415 if (minIndex < 0) or (minIndex > maxIndex):
426 if (minIndex < 0) or (minIndex > maxIndex):
416 raise ValueError, "Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)
427 raise ValueError, "Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)
417
428
418 if (maxIndex >= self.dataOut.nProfiles):
429 if (maxIndex >= self.dataOut.nProfiles):
419 maxIndex = self.dataOut.nProfiles-1
430 maxIndex = self.dataOut.nProfiles-1
420
431
421 #Spectra
432 #Spectra
422 data_spc = self.dataOut.data_spc[:,minIndex:maxIndex+1,:]
433 data_spc = self.dataOut.data_spc[:,minIndex:maxIndex+1,:]
423
434
424 data_cspc = None
435 data_cspc = None
425 if self.dataOut.data_cspc is not None:
436 if self.dataOut.data_cspc is not None:
426 data_cspc = self.dataOut.data_cspc[:,minIndex:maxIndex+1,:]
437 data_cspc = self.dataOut.data_cspc[:,minIndex:maxIndex+1,:]
427
438
428 data_dc = None
439 data_dc = None
429 if self.dataOut.data_dc is not None:
440 if self.dataOut.data_dc is not None:
430 data_dc = self.dataOut.data_dc[minIndex:maxIndex+1,:]
441 data_dc = self.dataOut.data_dc[minIndex:maxIndex+1,:]
431
442
432 self.dataOut.data_spc = data_spc
443 self.dataOut.data_spc = data_spc
433 self.dataOut.data_cspc = data_cspc
444 self.dataOut.data_cspc = data_cspc
434 self.dataOut.data_dc = data_dc
445 self.dataOut.data_dc = data_dc
435
446
436 self.dataOut.ippSeconds = self.dataOut.ippSeconds*(self.dataOut.nFFTPoints / numpy.shape(data_cspc)[1])
447 self.dataOut.ippSeconds = self.dataOut.ippSeconds*(self.dataOut.nFFTPoints / numpy.shape(data_cspc)[1])
437 self.dataOut.nFFTPoints = numpy.shape(data_cspc)[1]
448 self.dataOut.nFFTPoints = numpy.shape(data_cspc)[1]
438 self.dataOut.profilesPerBlock = numpy.shape(data_cspc)[1]
449 self.dataOut.profilesPerBlock = numpy.shape(data_cspc)[1]
439
450
440 #self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex+1]
451 #self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex+1]
441
452
442 return 1
453 return 1
443
454
444
455
445
456
446 def selectHeightsByIndex(self, minIndex, maxIndex):
457 def selectHeightsByIndex(self, minIndex, maxIndex):
447 """
458 """
448 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
459 Selecciona un bloque de datos en base a un grupo indices de alturas segun el rango
449 minIndex <= index <= maxIndex
460 minIndex <= index <= maxIndex
450
461
451 Input:
462 Input:
452 minIndex : valor de indice minimo de altura a considerar
463 minIndex : valor de indice minimo de altura a considerar
453 maxIndex : valor de indice maximo de altura a considerar
464 maxIndex : valor de indice maximo de altura a considerar
454
465
455 Affected:
466 Affected:
456 self.dataOut.data_spc
467 self.dataOut.data_spc
457 self.dataOut.data_cspc
468 self.dataOut.data_cspc
458 self.dataOut.data_dc
469 self.dataOut.data_dc
459 self.dataOut.heightList
470 self.dataOut.heightList
460
471
461 Return:
472 Return:
462 1 si el metodo se ejecuto con exito caso contrario devuelve 0
473 1 si el metodo se ejecuto con exito caso contrario devuelve 0
463 """
474 """
464
475
465 if (minIndex < 0) or (minIndex > maxIndex):
476 if (minIndex < 0) or (minIndex > maxIndex):
466 raise ValueError, "Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)
477 raise ValueError, "Error selecting heights: Index range (%d,%d) is not valid" % (minIndex, maxIndex)
467
478
468 if (maxIndex >= self.dataOut.nHeights):
479 if (maxIndex >= self.dataOut.nHeights):
469 maxIndex = self.dataOut.nHeights-1
480 maxIndex = self.dataOut.nHeights-1
470
481
471 #Spectra
482 #Spectra
472 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
483 data_spc = self.dataOut.data_spc[:,:,minIndex:maxIndex+1]
473
484
474 data_cspc = None
485 data_cspc = None
475 if self.dataOut.data_cspc is not None:
486 if self.dataOut.data_cspc is not None:
476 data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1]
487 data_cspc = self.dataOut.data_cspc[:,:,minIndex:maxIndex+1]
477
488
478 data_dc = None
489 data_dc = None
479 if self.dataOut.data_dc is not None:
490 if self.dataOut.data_dc is not None:
480 data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1]
491 data_dc = self.dataOut.data_dc[:,minIndex:maxIndex+1]
481
492
482 self.dataOut.data_spc = data_spc
493 self.dataOut.data_spc = data_spc
483 self.dataOut.data_cspc = data_cspc
494 self.dataOut.data_cspc = data_cspc
484 self.dataOut.data_dc = data_dc
495 self.dataOut.data_dc = data_dc
485
496
486 self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex+1]
497 self.dataOut.heightList = self.dataOut.heightList[minIndex:maxIndex+1]
487
498
488 return 1
499 return 1
489
500
490
501
491 def removeDC(self, mode = 2):
502 def removeDC(self, mode = 2):
492 jspectra = self.dataOut.data_spc
503 jspectra = self.dataOut.data_spc
493 jcspectra = self.dataOut.data_cspc
504 jcspectra = self.dataOut.data_cspc
494
505
495
506
496 num_chan = jspectra.shape[0]
507 num_chan = jspectra.shape[0]
497 num_hei = jspectra.shape[2]
508 num_hei = jspectra.shape[2]
498
509
499 if jcspectra is not None:
510 if jcspectra is not None:
500 jcspectraExist = True
511 jcspectraExist = True
501 num_pairs = jcspectra.shape[0]
512 num_pairs = jcspectra.shape[0]
502 else: jcspectraExist = False
513 else: jcspectraExist = False
503
514
504 freq_dc = jspectra.shape[1]/2
515 freq_dc = jspectra.shape[1]/2
505 ind_vel = numpy.array([-2,-1,1,2]) + freq_dc
516 ind_vel = numpy.array([-2,-1,1,2]) + freq_dc
506
517
507 if ind_vel[0]<0:
518 if ind_vel[0]<0:
508 ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof
519 ind_vel[range(0,1)] = ind_vel[range(0,1)] + self.num_prof
509
520
510 if mode == 1:
521 if mode == 1:
511 jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION
522 jspectra[:,freq_dc,:] = (jspectra[:,ind_vel[1],:] + jspectra[:,ind_vel[2],:])/2 #CORRECCION
512
523
513 if jcspectraExist:
524 if jcspectraExist:
514 jcspectra[:,freq_dc,:] = (jcspectra[:,ind_vel[1],:] + jcspectra[:,ind_vel[2],:])/2
525 jcspectra[:,freq_dc,:] = (jcspectra[:,ind_vel[1],:] + jcspectra[:,ind_vel[2],:])/2
515
526
516 if mode == 2:
527 if mode == 2:
517
528
518 vel = numpy.array([-2,-1,1,2])
529 vel = numpy.array([-2,-1,1,2])
519 xx = numpy.zeros([4,4])
530 xx = numpy.zeros([4,4])
520
531
521 for fil in range(4):
532 for fil in range(4):
522 xx[fil,:] = vel[fil]**numpy.asarray(range(4))
533 xx[fil,:] = vel[fil]**numpy.asarray(range(4))
523
534
524 xx_inv = numpy.linalg.inv(xx)
535 xx_inv = numpy.linalg.inv(xx)
525 xx_aux = xx_inv[0,:]
536 xx_aux = xx_inv[0,:]
526
537
527 for ich in range(num_chan):
538 for ich in range(num_chan):
528 yy = jspectra[ich,ind_vel,:]
539 yy = jspectra[ich,ind_vel,:]
529 jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy)
540 jspectra[ich,freq_dc,:] = numpy.dot(xx_aux,yy)
530
541
531 junkid = jspectra[ich,freq_dc,:]<=0
542 junkid = jspectra[ich,freq_dc,:]<=0
532 cjunkid = sum(junkid)
543 cjunkid = sum(junkid)
533
544
534 if cjunkid.any():
545 if cjunkid.any():
535 jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2
546 jspectra[ich,freq_dc,junkid.nonzero()] = (jspectra[ich,ind_vel[1],junkid] + jspectra[ich,ind_vel[2],junkid])/2
536
547
537 if jcspectraExist:
548 if jcspectraExist:
538 for ip in range(num_pairs):
549 for ip in range(num_pairs):
539 yy = jcspectra[ip,ind_vel,:]
550 yy = jcspectra[ip,ind_vel,:]
540 jcspectra[ip,freq_dc,:] = numpy.dot(xx_aux,yy)
551 jcspectra[ip,freq_dc,:] = numpy.dot(xx_aux,yy)
541
552
542
553
543 self.dataOut.data_spc = jspectra
554 self.dataOut.data_spc = jspectra
544 self.dataOut.data_cspc = jcspectra
555 self.dataOut.data_cspc = jcspectra
545
556
546 return 1
557 return 1
547
558
548 def removeInterference2(self):
559 def removeInterference2(self):
549
560
550 cspc = self.dataOut.data_cspc
561 cspc = self.dataOut.data_cspc
551 spc = self.dataOut.data_spc
562 spc = self.dataOut.data_spc
552 print numpy.shape(spc)
563 print numpy.shape(spc)
553 Heights = numpy.arange(cspc.shape[2])
564 Heights = numpy.arange(cspc.shape[2])
554 realCspc = numpy.abs(cspc)
565 realCspc = numpy.abs(cspc)
555
566
556 for i in range(cspc.shape[0]):
567 for i in range(cspc.shape[0]):
557 LinePower= numpy.sum(realCspc[i], axis=0)
568 LinePower= numpy.sum(realCspc[i], axis=0)
558 Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)]
569 Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)]
559 SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ]
570 SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ]
560 #print numpy.shape(realCspc)
571 #print numpy.shape(realCspc)
561 #print '',SelectedHeights, '', numpy.shape(realCspc[i,:,SelectedHeights])
572 #print '',SelectedHeights, '', numpy.shape(realCspc[i,:,SelectedHeights])
562 InterferenceSum = numpy.sum( realCspc[i,:,SelectedHeights], axis=0 )
573 InterferenceSum = numpy.sum( realCspc[i,:,SelectedHeights], axis=0 )
563 print SelectedHeights
574 print SelectedHeights
564 InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)]
575 InterferenceThresholdMin = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)]
565 InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)]
576 InterferenceThresholdMax = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.99)]
566
577
567
578
568 InterferenceRange = numpy.where( ([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) )
579 InterferenceRange = numpy.where( ([InterferenceSum > InterferenceThresholdMin]))# , InterferenceSum < InterferenceThresholdMax]) )
569 #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax]))
580 #InterferenceRange = numpy.where( ([InterferenceRange < InterferenceThresholdMax]))
570 if len(InterferenceRange)<int(cspc.shape[1]*0.3):
581 if len(InterferenceRange)<int(cspc.shape[1]*0.3):
571 cspc[i,InterferenceRange,:] = numpy.NaN
582 cspc[i,InterferenceRange,:] = numpy.NaN
572
583
573 print '########################################################################################'
584 print '########################################################################################'
574 print 'Len interference sum',len(InterferenceSum)
585 print 'Len interference sum',len(InterferenceSum)
575 print 'InterferenceThresholdMin', InterferenceThresholdMin, 'InterferenceThresholdMax', InterferenceThresholdMax
586 print 'InterferenceThresholdMin', InterferenceThresholdMin, 'InterferenceThresholdMax', InterferenceThresholdMax
576 print 'InterferenceRange',InterferenceRange
587 print 'InterferenceRange',InterferenceRange
577 print '########################################################################################'
588 print '########################################################################################'
578
589
579 ''' Ploteo '''
590 ''' Ploteo '''
580
591
581 #for i in range(3):
592 #for i in range(3):
582 #print 'FASE', numpy.shape(phase), y[25]
593 #print 'FASE', numpy.shape(phase), y[25]
583 #print numpy.shape(coherence)
594 #print numpy.shape(coherence)
584 #fig = plt.figure(10+ int(numpy.random.rand()*100))
595 #fig = plt.figure(10+ int(numpy.random.rand()*100))
585 #plt.plot( x[0:256],coherence[:,25] )
596 #plt.plot( x[0:256],coherence[:,25] )
586 #cohAv = numpy.average(coherence[i],1)
597 #cohAv = numpy.average(coherence[i],1)
587 #Pendiente = FrecRange * PhaseSlope[i]
598 #Pendiente = FrecRange * PhaseSlope[i]
588 #plt.plot( InterferenceSum)
599 #plt.plot( InterferenceSum)
589 #plt.plot( numpy.sort(InterferenceSum))
600 #plt.plot( numpy.sort(InterferenceSum))
590 #plt.plot( LinePower )
601 #plt.plot( LinePower )
591 #plt.plot( xFrec,phase[i])
602 #plt.plot( xFrec,phase[i])
592
603
593 #CSPCmean = numpy.mean(numpy.abs(CSPCSamples),0)
604 #CSPCmean = numpy.mean(numpy.abs(CSPCSamples),0)
594 #plt.plot(xFrec, FitGauss01)
605 #plt.plot(xFrec, FitGauss01)
595 #plt.plot(xFrec, CSPCmean)
606 #plt.plot(xFrec, CSPCmean)
596 #plt.plot(xFrec, numpy.abs(CSPCSamples[0]))
607 #plt.plot(xFrec, numpy.abs(CSPCSamples[0]))
597 #plt.plot(xFrec, FitGauss)
608 #plt.plot(xFrec, FitGauss)
598 #plt.plot(xFrec, yMean)
609 #plt.plot(xFrec, yMean)
599 #plt.plot(xFrec, numpy.abs(coherence[0]))
610 #plt.plot(xFrec, numpy.abs(coherence[0]))
600
611
601 #plt.axis([-12, 12, 15, 50])
612 #plt.axis([-12, 12, 15, 50])
602 #plt.title("%s" %( '%s %s, Channel %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S") , i)))
613 #plt.title("%s" %( '%s %s, Channel %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S") , i)))
603
614
604
615
605 #fig.savefig('/home/erick/Documents/Pics/nom{}.png'.format(int(numpy.random.rand()*100)))
616 #fig.savefig('/home/erick/Documents/Pics/nom{}.png'.format(int(numpy.random.rand()*100)))
606
617
607 #plt.show()
618 #plt.show()
608 #self.indice=self.indice+1
619 #self.indice=self.indice+1
609 #raise
620 #raise
610
621
611
622
612 self.dataOut.data_cspc = cspc
623 self.dataOut.data_cspc = cspc
613
624
614 # for i in range(spc.shape[0]):
625 # for i in range(spc.shape[0]):
615 # LinePower= numpy.sum(spc[i], axis=0)
626 # LinePower= numpy.sum(spc[i], axis=0)
616 # Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)]
627 # Threshold = numpy.amax(LinePower)-numpy.sort(LinePower)[len(Heights)-int(len(Heights)*0.1)]
617 # SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ]
628 # SelectedHeights = Heights[ numpy.where( LinePower < Threshold ) ]
618 # #print numpy.shape(realCspc)
629 # #print numpy.shape(realCspc)
619 # #print '',SelectedHeights, '', numpy.shape(realCspc[i,:,SelectedHeights])
630 # #print '',SelectedHeights, '', numpy.shape(realCspc[i,:,SelectedHeights])
620 # InterferenceSum = numpy.sum( spc[i,:,SelectedHeights], axis=0 )
631 # InterferenceSum = numpy.sum( spc[i,:,SelectedHeights], axis=0 )
621 # InterferenceThreshold = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)]
632 # InterferenceThreshold = numpy.sort(InterferenceSum)[int(len(InterferenceSum)*0.98)]
622 # InterferenceRange = numpy.where( InterferenceSum > InterferenceThreshold )
633 # InterferenceRange = numpy.where( InterferenceSum > InterferenceThreshold )
623 # if len(InterferenceRange)<int(spc.shape[1]*0.03):
634 # if len(InterferenceRange)<int(spc.shape[1]*0.03):
624 # spc[i,InterferenceRange,:] = numpy.NaN
635 # spc[i,InterferenceRange,:] = numpy.NaN
625
636
626 #self.dataOut.data_spc = spc
637 #self.dataOut.data_spc = spc
627
638
628 def removeInterference(self, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None):
639 def removeInterference(self, interf = 2,hei_interf = None, nhei_interf = None, offhei_interf = None):
629
640
630 jspectra = self.dataOut.data_spc
641 jspectra = self.dataOut.data_spc
631 jcspectra = self.dataOut.data_cspc
642 jcspectra = self.dataOut.data_cspc
632 jnoise = self.dataOut.getNoise()
643 jnoise = self.dataOut.getNoise()
633 num_incoh = self.dataOut.nIncohInt
644 num_incoh = self.dataOut.nIncohInt
634
645
635 num_channel = jspectra.shape[0]
646 num_channel = jspectra.shape[0]
636 num_prof = jspectra.shape[1]
647 num_prof = jspectra.shape[1]
637 num_hei = jspectra.shape[2]
648 num_hei = jspectra.shape[2]
638
649
639 #hei_interf
650 #hei_interf
640 if hei_interf is None:
651 if hei_interf is None:
641 count_hei = num_hei/2 #Como es entero no importa
652 count_hei = num_hei/2 #Como es entero no importa
642 hei_interf = numpy.asmatrix(range(count_hei)) + num_hei - count_hei
653 hei_interf = numpy.asmatrix(range(count_hei)) + num_hei - count_hei
643 hei_interf = numpy.asarray(hei_interf)[0]
654 hei_interf = numpy.asarray(hei_interf)[0]
644 #nhei_interf
655 #nhei_interf
645 if (nhei_interf == None):
656 if (nhei_interf == None):
646 nhei_interf = 5
657 nhei_interf = 5
647 if (nhei_interf < 1):
658 if (nhei_interf < 1):
648 nhei_interf = 1
659 nhei_interf = 1
649 if (nhei_interf > count_hei):
660 if (nhei_interf > count_hei):
650 nhei_interf = count_hei
661 nhei_interf = count_hei
651 if (offhei_interf == None):
662 if (offhei_interf == None):
652 offhei_interf = 0
663 offhei_interf = 0
653
664
654 ind_hei = range(num_hei)
665 ind_hei = range(num_hei)
655 # mask_prof = numpy.asarray(range(num_prof - 2)) + 1
666 # mask_prof = numpy.asarray(range(num_prof - 2)) + 1
656 # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1
667 # mask_prof[range(num_prof/2 - 1,len(mask_prof))] += 1
657 mask_prof = numpy.asarray(range(num_prof))
668 mask_prof = numpy.asarray(range(num_prof))
658 num_mask_prof = mask_prof.size
669 num_mask_prof = mask_prof.size
659 comp_mask_prof = [0, num_prof/2]
670 comp_mask_prof = [0, num_prof/2]
660
671
661
672
662 #noise_exist: Determina si la variable jnoise ha sido definida y contiene la informacion del ruido de cada canal
673 #noise_exist: Determina si la variable jnoise ha sido definida y contiene la informacion del ruido de cada canal
663 if (jnoise.size < num_channel or numpy.isnan(jnoise).any()):
674 if (jnoise.size < num_channel or numpy.isnan(jnoise).any()):
664 jnoise = numpy.nan
675 jnoise = numpy.nan
665 noise_exist = jnoise[0] < numpy.Inf
676 noise_exist = jnoise[0] < numpy.Inf
666
677
667 #Subrutina de Remocion de la Interferencia
678 #Subrutina de Remocion de la Interferencia
668 for ich in range(num_channel):
679 for ich in range(num_channel):
669 #Se ordena los espectros segun su potencia (menor a mayor)
680 #Se ordena los espectros segun su potencia (menor a mayor)
670 power = jspectra[ich,mask_prof,:]
681 power = jspectra[ich,mask_prof,:]
671 power = power[:,hei_interf]
682 power = power[:,hei_interf]
672 power = power.sum(axis = 0)
683 power = power.sum(axis = 0)
673 psort = power.ravel().argsort()
684 psort = power.ravel().argsort()
674
685
675 #Se estima la interferencia promedio en los Espectros de Potencia empleando
686 #Se estima la interferencia promedio en los Espectros de Potencia empleando
676 junkspc_interf = jspectra[ich,:,hei_interf[psort[range(offhei_interf, nhei_interf + offhei_interf)]]]
687 junkspc_interf = jspectra[ich,:,hei_interf[psort[range(offhei_interf, nhei_interf + offhei_interf)]]]
677
688
678 if noise_exist:
689 if noise_exist:
679 # tmp_noise = jnoise[ich] / num_prof
690 # tmp_noise = jnoise[ich] / num_prof
680 tmp_noise = jnoise[ich]
691 tmp_noise = jnoise[ich]
681 junkspc_interf = junkspc_interf - tmp_noise
692 junkspc_interf = junkspc_interf - tmp_noise
682 #junkspc_interf[:,comp_mask_prof] = 0
693 #junkspc_interf[:,comp_mask_prof] = 0
683
694
684 jspc_interf = junkspc_interf.sum(axis = 0) / nhei_interf
695 jspc_interf = junkspc_interf.sum(axis = 0) / nhei_interf
685 jspc_interf = jspc_interf.transpose()
696 jspc_interf = jspc_interf.transpose()
686 #Calculando el espectro de interferencia promedio
697 #Calculando el espectro de interferencia promedio
687 noiseid = numpy.where(jspc_interf <= tmp_noise/ numpy.sqrt(num_incoh))
698 noiseid = numpy.where(jspc_interf <= tmp_noise/ numpy.sqrt(num_incoh))
688 noiseid = noiseid[0]
699 noiseid = noiseid[0]
689 cnoiseid = noiseid.size
700 cnoiseid = noiseid.size
690 interfid = numpy.where(jspc_interf > tmp_noise/ numpy.sqrt(num_incoh))
701 interfid = numpy.where(jspc_interf > tmp_noise/ numpy.sqrt(num_incoh))
691 interfid = interfid[0]
702 interfid = interfid[0]
692 cinterfid = interfid.size
703 cinterfid = interfid.size
693
704
694 if (cnoiseid > 0): jspc_interf[noiseid] = 0
705 if (cnoiseid > 0): jspc_interf[noiseid] = 0
695
706
696 #Expandiendo los perfiles a limpiar
707 #Expandiendo los perfiles a limpiar
697 if (cinterfid > 0):
708 if (cinterfid > 0):
698 new_interfid = (numpy.r_[interfid - 1, interfid, interfid + 1] + num_prof)%num_prof
709 new_interfid = (numpy.r_[interfid - 1, interfid, interfid + 1] + num_prof)%num_prof
699 new_interfid = numpy.asarray(new_interfid)
710 new_interfid = numpy.asarray(new_interfid)
700 new_interfid = {x for x in new_interfid}
711 new_interfid = {x for x in new_interfid}
701 new_interfid = numpy.array(list(new_interfid))
712 new_interfid = numpy.array(list(new_interfid))
702 new_cinterfid = new_interfid.size
713 new_cinterfid = new_interfid.size
703 else: new_cinterfid = 0
714 else: new_cinterfid = 0
704
715
705 for ip in range(new_cinterfid):
716 for ip in range(new_cinterfid):
706 ind = junkspc_interf[:,new_interfid[ip]].ravel().argsort()
717 ind = junkspc_interf[:,new_interfid[ip]].ravel().argsort()
707 jspc_interf[new_interfid[ip]] = junkspc_interf[ind[nhei_interf/2],new_interfid[ip]]
718 jspc_interf[new_interfid[ip]] = junkspc_interf[ind[nhei_interf/2],new_interfid[ip]]
708
719
709
720
710 jspectra[ich,:,ind_hei] = jspectra[ich,:,ind_hei] - jspc_interf #Corregir indices
721 jspectra[ich,:,ind_hei] = jspectra[ich,:,ind_hei] - jspc_interf #Corregir indices
711
722
712 #Removiendo la interferencia del punto de mayor interferencia
723 #Removiendo la interferencia del punto de mayor interferencia
713 ListAux = jspc_interf[mask_prof].tolist()
724 ListAux = jspc_interf[mask_prof].tolist()
714 maxid = ListAux.index(max(ListAux))
725 maxid = ListAux.index(max(ListAux))
715
726
716
727
717 if cinterfid > 0:
728 if cinterfid > 0:
718 for ip in range(cinterfid*(interf == 2) - 1):
729 for ip in range(cinterfid*(interf == 2) - 1):
719 ind = (jspectra[ich,interfid[ip],:] < tmp_noise*(1 + 1/numpy.sqrt(num_incoh))).nonzero()
730 ind = (jspectra[ich,interfid[ip],:] < tmp_noise*(1 + 1/numpy.sqrt(num_incoh))).nonzero()
720 cind = len(ind)
731 cind = len(ind)
721
732
722 if (cind > 0):
733 if (cind > 0):
723 jspectra[ich,interfid[ip],ind] = tmp_noise*(1 + (numpy.random.uniform(cind) - 0.5)/numpy.sqrt(num_incoh))
734 jspectra[ich,interfid[ip],ind] = tmp_noise*(1 + (numpy.random.uniform(cind) - 0.5)/numpy.sqrt(num_incoh))
724
735
725 ind = numpy.array([-2,-1,1,2])
736 ind = numpy.array([-2,-1,1,2])
726 xx = numpy.zeros([4,4])
737 xx = numpy.zeros([4,4])
727
738
728 for id1 in range(4):
739 for id1 in range(4):
729 xx[:,id1] = ind[id1]**numpy.asarray(range(4))
740 xx[:,id1] = ind[id1]**numpy.asarray(range(4))
730
741
731 xx_inv = numpy.linalg.inv(xx)
742 xx_inv = numpy.linalg.inv(xx)
732 xx = xx_inv[:,0]
743 xx = xx_inv[:,0]
733 ind = (ind + maxid + num_mask_prof)%num_mask_prof
744 ind = (ind + maxid + num_mask_prof)%num_mask_prof
734 yy = jspectra[ich,mask_prof[ind],:]
745 yy = jspectra[ich,mask_prof[ind],:]
735 jspectra[ich,mask_prof[maxid],:] = numpy.dot(yy.transpose(),xx)
746 jspectra[ich,mask_prof[maxid],:] = numpy.dot(yy.transpose(),xx)
736
747
737
748
738 indAux = (jspectra[ich,:,:] < tmp_noise*(1-1/numpy.sqrt(num_incoh))).nonzero()
749 indAux = (jspectra[ich,:,:] < tmp_noise*(1-1/numpy.sqrt(num_incoh))).nonzero()
739 jspectra[ich,indAux[0],indAux[1]] = tmp_noise * (1 - 1/numpy.sqrt(num_incoh))
750 jspectra[ich,indAux[0],indAux[1]] = tmp_noise * (1 - 1/numpy.sqrt(num_incoh))
740
751
741 #Remocion de Interferencia en el Cross Spectra
752 #Remocion de Interferencia en el Cross Spectra
742 if jcspectra is None: return jspectra, jcspectra
753 if jcspectra is None: return jspectra, jcspectra
743 num_pairs = jcspectra.size/(num_prof*num_hei)
754 num_pairs = jcspectra.size/(num_prof*num_hei)
744 jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei)
755 jcspectra = jcspectra.reshape(num_pairs, num_prof, num_hei)
745
756
746 for ip in range(num_pairs):
757 for ip in range(num_pairs):
747
758
748 #-------------------------------------------
759 #-------------------------------------------
749
760
750 cspower = numpy.abs(jcspectra[ip,mask_prof,:])
761 cspower = numpy.abs(jcspectra[ip,mask_prof,:])
751 cspower = cspower[:,hei_interf]
762 cspower = cspower[:,hei_interf]
752 cspower = cspower.sum(axis = 0)
763 cspower = cspower.sum(axis = 0)
753
764
754 cspsort = cspower.ravel().argsort()
765 cspsort = cspower.ravel().argsort()
755 junkcspc_interf = jcspectra[ip,:,hei_interf[cspsort[range(offhei_interf, nhei_interf + offhei_interf)]]]
766 junkcspc_interf = jcspectra[ip,:,hei_interf[cspsort[range(offhei_interf, nhei_interf + offhei_interf)]]]
756 junkcspc_interf = junkcspc_interf.transpose()
767 junkcspc_interf = junkcspc_interf.transpose()
757 jcspc_interf = junkcspc_interf.sum(axis = 1)/nhei_interf
768 jcspc_interf = junkcspc_interf.sum(axis = 1)/nhei_interf
758
769
759 ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort()
770 ind = numpy.abs(jcspc_interf[mask_prof]).ravel().argsort()
760
771
761 median_real = numpy.median(numpy.real(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:]))
772 median_real = numpy.median(numpy.real(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:]))
762 median_imag = numpy.median(numpy.imag(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:]))
773 median_imag = numpy.median(numpy.imag(junkcspc_interf[mask_prof[ind[range(3*num_prof/4)]],:]))
763 junkcspc_interf[comp_mask_prof,:] = numpy.complex(median_real, median_imag)
774 junkcspc_interf[comp_mask_prof,:] = numpy.complex(median_real, median_imag)
764
775
765 for iprof in range(num_prof):
776 for iprof in range(num_prof):
766 ind = numpy.abs(junkcspc_interf[iprof,:]).ravel().argsort()
777 ind = numpy.abs(junkcspc_interf[iprof,:]).ravel().argsort()
767 jcspc_interf[iprof] = junkcspc_interf[iprof, ind[nhei_interf/2]]
778 jcspc_interf[iprof] = junkcspc_interf[iprof, ind[nhei_interf/2]]
768
779
769 #Removiendo la Interferencia
780 #Removiendo la Interferencia
770 jcspectra[ip,:,ind_hei] = jcspectra[ip,:,ind_hei] - jcspc_interf
781 jcspectra[ip,:,ind_hei] = jcspectra[ip,:,ind_hei] - jcspc_interf
771
782
772 ListAux = numpy.abs(jcspc_interf[mask_prof]).tolist()
783 ListAux = numpy.abs(jcspc_interf[mask_prof]).tolist()
773 maxid = ListAux.index(max(ListAux))
784 maxid = ListAux.index(max(ListAux))
774
785
775 ind = numpy.array([-2,-1,1,2])
786 ind = numpy.array([-2,-1,1,2])
776 xx = numpy.zeros([4,4])
787 xx = numpy.zeros([4,4])
777
788
778 for id1 in range(4):
789 for id1 in range(4):
779 xx[:,id1] = ind[id1]**numpy.asarray(range(4))
790 xx[:,id1] = ind[id1]**numpy.asarray(range(4))
780
791
781 xx_inv = numpy.linalg.inv(xx)
792 xx_inv = numpy.linalg.inv(xx)
782 xx = xx_inv[:,0]
793 xx = xx_inv[:,0]
783
794
784 ind = (ind + maxid + num_mask_prof)%num_mask_prof
795 ind = (ind + maxid + num_mask_prof)%num_mask_prof
785 yy = jcspectra[ip,mask_prof[ind],:]
796 yy = jcspectra[ip,mask_prof[ind],:]
786 jcspectra[ip,mask_prof[maxid],:] = numpy.dot(yy.transpose(),xx)
797 jcspectra[ip,mask_prof[maxid],:] = numpy.dot(yy.transpose(),xx)
787
798
788 #Guardar Resultados
799 #Guardar Resultados
789 self.dataOut.data_spc = jspectra
800 self.dataOut.data_spc = jspectra
790 self.dataOut.data_cspc = jcspectra
801 self.dataOut.data_cspc = jcspectra
791
802
792 return 1
803 return 1
793
804
794 def setRadarFrequency(self, frequency=None):
805 def setRadarFrequency(self, frequency=None):
795
806
796 if frequency != None:
807 if frequency != None:
797 self.dataOut.frequency = frequency
808 self.dataOut.frequency = frequency
798
809
799 return 1
810 return 1
800
811
801 def getNoise(self, minHei=None, maxHei=None, minVel=None, maxVel=None):
812 def getNoise(self, minHei=None, maxHei=None, minVel=None, maxVel=None):
802 #validacion de rango
813 #validacion de rango
803 if minHei == None:
814 if minHei == None:
804 minHei = self.dataOut.heightList[0]
815 minHei = self.dataOut.heightList[0]
805
816
806 if maxHei == None:
817 if maxHei == None:
807 maxHei = self.dataOut.heightList[-1]
818 maxHei = self.dataOut.heightList[-1]
808
819
809 if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei):
820 if (minHei < self.dataOut.heightList[0]) or (minHei > maxHei):
810 print 'minHei: %.2f is out of the heights range'%(minHei)
821 print 'minHei: %.2f is out of the heights range'%(minHei)
811 print 'minHei is setting to %.2f'%(self.dataOut.heightList[0])
822 print 'minHei is setting to %.2f'%(self.dataOut.heightList[0])
812 minHei = self.dataOut.heightList[0]
823 minHei = self.dataOut.heightList[0]
813
824
814 if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei):
825 if (maxHei > self.dataOut.heightList[-1]) or (maxHei < minHei):
815 print 'maxHei: %.2f is out of the heights range'%(maxHei)
826 print 'maxHei: %.2f is out of the heights range'%(maxHei)
816 print 'maxHei is setting to %.2f'%(self.dataOut.heightList[-1])
827 print 'maxHei is setting to %.2f'%(self.dataOut.heightList[-1])
817 maxHei = self.dataOut.heightList[-1]
828 maxHei = self.dataOut.heightList[-1]
818
829
819 # validacion de velocidades
830 # validacion de velocidades
820 velrange = self.dataOut.getVelRange(1)
831 velrange = self.dataOut.getVelRange(1)
821
832
822 if minVel == None:
833 if minVel == None:
823 minVel = velrange[0]
834 minVel = velrange[0]
824
835
825 if maxVel == None:
836 if maxVel == None:
826 maxVel = velrange[-1]
837 maxVel = velrange[-1]
827
838
828 if (minVel < velrange[0]) or (minVel > maxVel):
839 if (minVel < velrange[0]) or (minVel > maxVel):
829 print 'minVel: %.2f is out of the velocity range'%(minVel)
840 print 'minVel: %.2f is out of the velocity range'%(minVel)
830 print 'minVel is setting to %.2f'%(velrange[0])
841 print 'minVel is setting to %.2f'%(velrange[0])
831 minVel = velrange[0]
842 minVel = velrange[0]
832
843
833 if (maxVel > velrange[-1]) or (maxVel < minVel):
844 if (maxVel > velrange[-1]) or (maxVel < minVel):
834 print 'maxVel: %.2f is out of the velocity range'%(maxVel)
845 print 'maxVel: %.2f is out of the velocity range'%(maxVel)
835 print 'maxVel is setting to %.2f'%(velrange[-1])
846 print 'maxVel is setting to %.2f'%(velrange[-1])
836 maxVel = velrange[-1]
847 maxVel = velrange[-1]
837
848
838 # seleccion de indices para rango
849 # seleccion de indices para rango
839 minIndex = 0
850 minIndex = 0
840 maxIndex = 0
851 maxIndex = 0
841 heights = self.dataOut.heightList
852 heights = self.dataOut.heightList
842
853
843 inda = numpy.where(heights >= minHei)
854 inda = numpy.where(heights >= minHei)
844 indb = numpy.where(heights <= maxHei)
855 indb = numpy.where(heights <= maxHei)
845
856
846 try:
857 try:
847 minIndex = inda[0][0]
858 minIndex = inda[0][0]
848 except:
859 except:
849 minIndex = 0
860 minIndex = 0
850
861
851 try:
862 try:
852 maxIndex = indb[0][-1]
863 maxIndex = indb[0][-1]
853 except:
864 except:
854 maxIndex = len(heights)
865 maxIndex = len(heights)
855
866
856 if (minIndex < 0) or (minIndex > maxIndex):
867 if (minIndex < 0) or (minIndex > maxIndex):
857 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
868 raise ValueError, "some value in (%d,%d) is not valid" % (minIndex, maxIndex)
858
869
859 if (maxIndex >= self.dataOut.nHeights):
870 if (maxIndex >= self.dataOut.nHeights):
860 maxIndex = self.dataOut.nHeights-1
871 maxIndex = self.dataOut.nHeights-1
861
872
862 # seleccion de indices para velocidades
873 # seleccion de indices para velocidades
863 indminvel = numpy.where(velrange >= minVel)
874 indminvel = numpy.where(velrange >= minVel)
864 indmaxvel = numpy.where(velrange <= maxVel)
875 indmaxvel = numpy.where(velrange <= maxVel)
865 try:
876 try:
866 minIndexVel = indminvel[0][0]
877 minIndexVel = indminvel[0][0]
867 except:
878 except:
868 minIndexVel = 0
879 minIndexVel = 0
869
880
870 try:
881 try:
871 maxIndexVel = indmaxvel[0][-1]
882 maxIndexVel = indmaxvel[0][-1]
872 except:
883 except:
873 maxIndexVel = len(velrange)
884 maxIndexVel = len(velrange)
874
885
875 #seleccion del espectro
886 #seleccion del espectro
876 data_spc = self.dataOut.data_spc[:,minIndexVel:maxIndexVel+1,minIndex:maxIndex+1]
887 data_spc = self.dataOut.data_spc[:,minIndexVel:maxIndexVel+1,minIndex:maxIndex+1]
877 #estimacion de ruido
888 #estimacion de ruido
878 noise = numpy.zeros(self.dataOut.nChannels)
889 noise = numpy.zeros(self.dataOut.nChannels)
879
890
880 for channel in range(self.dataOut.nChannels):
891 for channel in range(self.dataOut.nChannels):
881 daux = data_spc[channel,:,:]
892 daux = data_spc[channel,:,:]
882 noise[channel] = hildebrand_sekhon(daux, self.dataOut.nIncohInt)
893 noise[channel] = hildebrand_sekhon(daux, self.dataOut.nIncohInt)
883
894
884 self.dataOut.noise_estimation = noise.copy()
895 self.dataOut.noise_estimation = noise.copy()
885
896
886 return 1
897 return 1
887
898
888 class IncohInt(Operation):
899 class IncohInt(Operation):
889
900
890
901
891 __profIndex = 0
902 __profIndex = 0
892 __withOverapping = False
903 __withOverapping = False
893
904
894 __byTime = False
905 __byTime = False
895 __initime = None
906 __initime = None
896 __lastdatatime = None
907 __lastdatatime = None
897 __integrationtime = None
908 __integrationtime = None
898
909
899 __buffer_spc = None
910 __buffer_spc = None
900 __buffer_cspc = None
911 __buffer_cspc = None
901 __buffer_dc = None
912 __buffer_dc = None
902
913
903 __dataReady = False
914 __dataReady = False
904
915
905 __timeInterval = None
916 __timeInterval = None
906
917
907 n = None
918 n = None
908
919
909
920
910
921
911 def __init__(self, **kwargs):
922 def __init__(self, **kwargs):
912
923
913 Operation.__init__(self, **kwargs)
924 Operation.__init__(self, **kwargs)
914 # self.isConfig = False
925 # self.isConfig = False
915
926
916 def setup(self, n=None, timeInterval=None, overlapping=False):
927 def setup(self, n=None, timeInterval=None, overlapping=False):
917 """
928 """
918 Set the parameters of the integration class.
929 Set the parameters of the integration class.
919
930
920 Inputs:
931 Inputs:
921
932
922 n : Number of coherent integrations
933 n : Number of coherent integrations
923 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
934 timeInterval : Time of integration. If the parameter "n" is selected this one does not work
924 overlapping :
935 overlapping :
925
936
926 """
937 """
927
938
928 self.__initime = None
939 self.__initime = None
929 self.__lastdatatime = 0
940 self.__lastdatatime = 0
930
941
931 self.__buffer_spc = 0
942 self.__buffer_spc = 0
932 self.__buffer_cspc = 0
943 self.__buffer_cspc = 0
933 self.__buffer_dc = 0
944 self.__buffer_dc = 0
934
945
935 self.__profIndex = 0
946 self.__profIndex = 0
936 self.__dataReady = False
947 self.__dataReady = False
937 self.__byTime = False
948 self.__byTime = False
938
949
939 if n is None and timeInterval is None:
950 if n is None and timeInterval is None:
940 raise ValueError, "n or timeInterval should be specified ..."
951 raise ValueError, "n or timeInterval should be specified ..."
941
952
942 if n is not None:
953 if n is not None:
943 self.n = int(n)
954 self.n = int(n)
944 else:
955 else:
945 self.__integrationtime = int(timeInterval) #if (type(timeInterval)!=integer) -> change this line
956 self.__integrationtime = int(timeInterval) #if (type(timeInterval)!=integer) -> change this line
946 self.n = None
957 self.n = None
947 self.__byTime = True
958 self.__byTime = True
948
959
949 def putData(self, data_spc, data_cspc, data_dc):
960 def putData(self, data_spc, data_cspc, data_dc):
950
961
951 """
962 """
952 Add a profile to the __buffer_spc and increase in one the __profileIndex
963 Add a profile to the __buffer_spc and increase in one the __profileIndex
953
964
954 """
965 """
955
966
956 self.__buffer_spc += data_spc
967 self.__buffer_spc += data_spc
957
968
958 if data_cspc is None:
969 if data_cspc is None:
959 self.__buffer_cspc = None
970 self.__buffer_cspc = None
960 else:
971 else:
961 self.__buffer_cspc += data_cspc
972 self.__buffer_cspc += data_cspc
962
973
963 if data_dc is None:
974 if data_dc is None:
964 self.__buffer_dc = None
975 self.__buffer_dc = None
965 else:
976 else:
966 self.__buffer_dc += data_dc
977 self.__buffer_dc += data_dc
967
978
968 self.__profIndex += 1
979 self.__profIndex += 1
969
980
970 return
981 return
971
982
972 def pushData(self):
983 def pushData(self):
973 """
984 """
974 Return the sum of the last profiles and the profiles used in the sum.
985 Return the sum of the last profiles and the profiles used in the sum.
975
986
976 Affected:
987 Affected:
977
988
978 self.__profileIndex
989 self.__profileIndex
979
990
980 """
991 """
981
992
982 data_spc = self.__buffer_spc
993 data_spc = self.__buffer_spc
983 data_cspc = self.__buffer_cspc
994 data_cspc = self.__buffer_cspc
984 data_dc = self.__buffer_dc
995 data_dc = self.__buffer_dc
985 n = self.__profIndex
996 n = self.__profIndex
986
997
987 self.__buffer_spc = 0
998 self.__buffer_spc = 0
988 self.__buffer_cspc = 0
999 self.__buffer_cspc = 0
989 self.__buffer_dc = 0
1000 self.__buffer_dc = 0
990 self.__profIndex = 0
1001 self.__profIndex = 0
991
1002
992 return data_spc, data_cspc, data_dc, n
1003 return data_spc, data_cspc, data_dc, n
993
1004
994 def byProfiles(self, *args):
1005 def byProfiles(self, *args):
995
1006
996 self.__dataReady = False
1007 self.__dataReady = False
997 avgdata_spc = None
1008 avgdata_spc = None
998 avgdata_cspc = None
1009 avgdata_cspc = None
999 avgdata_dc = None
1010 avgdata_dc = None
1000
1011
1001 self.putData(*args)
1012 self.putData(*args)
1002
1013
1003 if self.__profIndex == self.n:
1014 if self.__profIndex == self.n:
1004
1015
1005 avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData()
1016 avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData()
1006 self.n = n
1017 self.n = n
1007 self.__dataReady = True
1018 self.__dataReady = True
1008
1019
1009 return avgdata_spc, avgdata_cspc, avgdata_dc
1020 return avgdata_spc, avgdata_cspc, avgdata_dc
1010
1021
1011 def byTime(self, datatime, *args):
1022 def byTime(self, datatime, *args):
1012
1023
1013 self.__dataReady = False
1024 self.__dataReady = False
1014 avgdata_spc = None
1025 avgdata_spc = None
1015 avgdata_cspc = None
1026 avgdata_cspc = None
1016 avgdata_dc = None
1027 avgdata_dc = None
1017
1028
1018 self.putData(*args)
1029 self.putData(*args)
1019
1030
1020 if (datatime - self.__initime) >= self.__integrationtime:
1031 if (datatime - self.__initime) >= self.__integrationtime:
1021 avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData()
1032 avgdata_spc, avgdata_cspc, avgdata_dc, n = self.pushData()
1022 self.n = n
1033 self.n = n
1023 self.__dataReady = True
1034 self.__dataReady = True
1024
1035
1025 return avgdata_spc, avgdata_cspc, avgdata_dc
1036 return avgdata_spc, avgdata_cspc, avgdata_dc
1026
1037
1027 def integrate(self, datatime, *args):
1038 def integrate(self, datatime, *args):
1028
1039
1029 if self.__profIndex == 0:
1040 if self.__profIndex == 0:
1030 self.__initime = datatime
1041 self.__initime = datatime
1031
1042
1032 if self.__byTime:
1043 if self.__byTime:
1033 avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime(datatime, *args)
1044 avgdata_spc, avgdata_cspc, avgdata_dc = self.byTime(datatime, *args)
1034 else:
1045 else:
1035 avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args)
1046 avgdata_spc, avgdata_cspc, avgdata_dc = self.byProfiles(*args)
1036
1047
1037 if not self.__dataReady:
1048 if not self.__dataReady:
1038 return None, None, None, None
1049 return None, None, None, None
1039
1050
1040 return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc
1051 return self.__initime, avgdata_spc, avgdata_cspc, avgdata_dc
1041
1052
1042 def run(self, dataOut, n=None, timeInterval=None, overlapping=False):
1053 def run(self, dataOut, n=None, timeInterval=None, overlapping=False):
1043
1054
1044 if n==1:
1055 if n==1:
1045 return
1056 return
1046
1057
1047 dataOut.flagNoData = True
1058 dataOut.flagNoData = True
1048
1059
1049 if not self.isConfig:
1060 if not self.isConfig:
1050 self.setup(n, timeInterval, overlapping)
1061 self.setup(n, timeInterval, overlapping)
1051 self.isConfig = True
1062 self.isConfig = True
1052
1063
1053 avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime,
1064 avgdatatime, avgdata_spc, avgdata_cspc, avgdata_dc = self.integrate(dataOut.utctime,
1054 dataOut.data_spc,
1065 dataOut.data_spc,
1055 dataOut.data_cspc,
1066 dataOut.data_cspc,
1056 dataOut.data_dc)
1067 dataOut.data_dc)
1057
1068
1058 if self.__dataReady:
1069 if self.__dataReady:
1059
1070
1060 dataOut.data_spc = avgdata_spc
1071 dataOut.data_spc = avgdata_spc
1061 dataOut.data_cspc = avgdata_cspc
1072 dataOut.data_cspc = avgdata_cspc
1062 dataOut.data_dc = avgdata_dc
1073 dataOut.data_dc = avgdata_dc
1063
1074
1064 dataOut.nIncohInt *= self.n
1075 dataOut.nIncohInt *= self.n
1065 dataOut.utctime = avgdatatime
1076 dataOut.utctime = avgdatatime
1066 dataOut.flagNoData = False
1077 dataOut.flagNoData = False
1067
1078
@@ -1,1 +1,1
1 <Project description="Segundo Test" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/2018" /><Parameter format="date" id="191113" name="startDate" value="2018/01/26" /><Parameter format="date" id="191114" name="endDate" value="2018/01/26" /><Parameter format="time" id="191115" name="startTime" value="17:45:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:00" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="1" /></Operation><Operation id="19112" name="printInfo" priority="2" type="self" /><Operation id="19113" name="printNumberOfBlock" priority="3" type="self" /></ReadUnit><ProcUnit datatype="Parameters" id="1913" inputId="1912" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralFilters" priority="2" type="other"><Parameter format="float" id="191321" name="PositiveLimit" value="1.5" /><Parameter format="float" id="191322" name="NegativeLimit" value="12.5" /></Operation><Operation id="19133" name="PrecipitationProc" priority="3" type="other" /><Operation id="19134" name="ParametersPlot" priority="4" type="other"><Parameter format="int" id="191341" name="id" value="10" /><Parameter format="str" id="191342" name="wintitle" value="First_gg" /><Parameter format="str" id="191343" name="colormap" value="ocean_r" /><Parameter format="int" id="191344" name="zmin" value="00" /><Parameter format="int" id="191345" name="zmax" value="40" /><Parameter format="int" id="191346" name="ymin" value="0" /><Parameter format="int" id="191347" name="ymax" value="11" /><Parameter format="int" id="191348" name="xmin" value="17" /><Parameter format="int" id="191349" name="xmax" value="24" /><Parameter format="int" id="191350" name="save" value="1" /><Parameter format="str" id="191351" name="figpath" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/2018" /></Operation><Operation id="19135" name="SpcParamPlot" priority="5" type="other"><Parameter format="int" id="191351" name="id" value="21" /><Parameter format="str" id="191352" name="wintitle" value="Primer eco removido" /><Parameter format="str" id="191353" name="xaxis" value="velocity" /><Parameter format="int" id="191354" name="showprofile" value="1" /><Parameter format="int" id="191355" name="zmin" value="10" /><Parameter format="int" id="191356" name="zmax" value="40" /><Parameter format="int" id="191357" name="ymin" value="0" /><Parameter format="int" id="191358" name="ymax" value="10" /><Parameter format="int" id="191359" name="Selector" value="1" /></Operation></ProcUnit><ProcUnit datatype="SpectraProc" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="setRadarFrequency" priority="2" type="self"><Parameter format="float" id="191221" name="frequency" value="445.09e6" /></Operation></ProcUnit></Project> No newline at end of file
1 <Project description="Segundo Test" id="191" name="test01"><ReadUnit datatype="SpectraReader" id="1911" inputId="0" name="SpectraReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="SpectraReader" /><Parameter format="str" id="191112" name="path" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra" /><Parameter format="date" id="191113" name="startDate" value="2018/02/23" /><Parameter format="date" id="191114" name="endDate" value="2018/02/23" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="03:59:50" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="1" /></Operation><Operation id="19112" name="printInfo" priority="2" type="self" /><Operation id="19113" name="printNumberOfBlock" priority="3" type="self" /></ReadUnit><ProcUnit datatype="Parameters" id="1913" inputId="1912" name="ParametersProc"><Operation id="19131" name="run" priority="1" type="self" /><Operation id="19132" name="SpectralFilters" priority="2" type="other"><Parameter format="float" id="191321" name="PositiveLimit" value="1.5" /><Parameter format="float" id="191322" name="NegativeLimit" value="12.5" /></Operation><Operation id="19133" name="FullSpectralAnalysis" priority="3" type="other"><Parameter format="float" id="191331" name="SNRlimit" value="-16" /><Parameter format="float" id="191332" name="Xi01" value="1.500" /><Parameter format="float" id="191333" name="Xi02" value="1.500" /><Parameter format="float" id="191334" name="Xi12" value="0" /><Parameter format="float" id="191335" name="Eta01" value="0.875" /><Parameter format="float" id="191336" name="Eta02" value="-0.875" /><Parameter format="float" id="191337" name="Eta12" value="-1.750" /></Operation><Operation id="19134" name="WindProfilerPlot" priority="4" type="other"><Parameter format="int" id="191341" name="id" value="4" /><Parameter format="str" id="191342" name="wintitle" value="Wind Profiler" /><Parameter format="float" id="191343" name="xmin" value="0" /><Parameter format="float" id="191344" name="xmax" value="4" /><Parameter format="float" id="191345" name="ymin" value="0" /><Parameter format="int" id="191346" name="ymax" value="4" /><Parameter format="float" id="191347" name="zmin" value="-20" /><Parameter format="float" id="191348" name="zmax" value="20" /><Parameter format="float" id="191349" name="SNRmin" value="-20" /><Parameter format="float" id="191350" name="SNRmax" value="20" /><Parameter format="float" id="191351" name="zmin_ver" value="-200" /><Parameter format="float" id="191352" name="zmax_ver" value="200" /><Parameter format="float" id="191353" name="SNRthresh" value="-20" /><Parameter format="int" id="191354" name="save" value="1" /><Parameter format="str" id="191355" name="figpath" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/ImagenesTesis" /></Operation><Operation id="19135" name="ParamWriter" priority="5" type="other"><Parameter format="str" id="191351" name="path" value="/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/ImagenesTesis" /><Parameter format="int" id="191352" name="blocksPerFile" value="500" /><Parameter format="list" id="191353" name="metadataList" value="heightList,timeZone,paramInterval" /><Parameter format="list" id="191354" name="dataList" value="data_output,utctime,utctimeInit" /></Operation></ProcUnit><ProcUnit datatype="SpectraProc" id="1912" inputId="1911" name="SpectraProc"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="setRadarFrequency" priority="2" type="self"><Parameter format="float" id="191221" name="frequency" value="445.09e6" /></Operation><Operation id="19123" name="setH0" priority="3" type="self"><Parameter format="float" id="191231" name="h0" value="0.500" /></Operation></ProcUnit></Project> No newline at end of file
@@ -1,151 +1,152
1 #!/usr/bin/env python
1 #!/usr/bin/env python
2 import os, sys
2 import os, sys
3
3
4 # path = os.path.dirname(os.getcwd())
4 # path = os.path.dirname(os.getcwd())
5 # path = os.path.join(path, 'source')
5 # path = os.path.join(path, 'source')
6 # sys.path.insert(0, '../')
6 # sys.path.insert(0, '../')
7
7
8 from schainpy.controller import Project
8 from schainpy.controller import Project
9
9
10 xmin = '15.5'
10 xmin = '15.5'
11 xmax = '24'
11 xmax = '24'
12
12
13
13
14 desc = "ProcBLTR Test"
14 desc = "ProcBLTR Test"
15 filename = "ProcBLTR.xml"
15 filename = "ProcBLTR.xml"
16 figpath = '/media/erick/6F60F7113095A154/BLTR'
16 figpath = '/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/2018'
17
17
18 controllerObj = Project()
18 controllerObj = Project()
19
19
20
20
21 controllerObj.setup(id='191', name='test01', description=desc)
21 controllerObj.setup(id='191', name='test01', description=desc)
22
22
23 readUnitConfObj = controllerObj.addReadUnit(datatype='BLTRSpectraReader',
23 readUnitConfObj = controllerObj.addReadUnit(datatype='BLTRSpectraReader',
24 #path='/media/erick/6F60F7113095A154/BLTR/',
24 #path='/media/erick/6F60F7113095A154/BLTR/',
25 #path='/data/BLTR',
25 path='/home/erick/Documents/Data/BLTR_Data/fdt/',
26 path='/home/erick/Documents/Data/BLTR_Data/fdt/',
26 endDate='2017/10/19',
27 endDate='2016/11/01',
27 startTime='13:00:00',
28 startTime='0:00:00',
28 startDate='2016/11/8',
29 startDate='2016/11/01',
29 endTime='23:59:59',
30 endTime='23:59:59',
30
31
31
32
32 online=0,
33 online=0,
33 walk=0,
34 walk=0,
34 ReadMode='1')
35 ReadMode='1')
35 # expLabel='')
36 # expLabel='')
36
37
37 # opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
38 # opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
38
39
39 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
40 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
40
41
41
42
42 opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
43 opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
43 opObj11.addParameter(name='n', value='2', format='float')
44 opObj11.addParameter(name='n', value='2', format='float')
44
45
45 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
46 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
46 #opObj10 = procUnitConfObj1.addOperation(name='removeInterference2')
47 #opObj10 = procUnitConfObj1.addOperation(name='removeInterference2')
47
48
48 # opObj10 = procUnitConfObj1.addOperation(name='calcMag')
49 # opObj10 = procUnitConfObj1.addOperation(name='calcMag')
49
50
50 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
51 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
51 # opObj11.addParameter(name='id', value='21', format='int')
52 # opObj11.addParameter(name='id', value='21', format='int')
52 # opObj11.addParameter(name='wintitle', value='SpectraCutPlot', format='str')
53 # opObj11.addParameter(name='wintitle', value='SpectraCutPlot', format='str')
53 # opObj11.addParameter(name='xaxis', value='frequency', format='str')
54 # opObj11.addParameter(name='xaxis', value='frequency', format='str')
54 # opObj11.addParameter(name='colormap', value='winter', format='str')
55 # opObj11.addParameter(name='colormap', value='winter', format='str')
55 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
56 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
56 # opObj11.addParameter(name='xmax', value='0.005', format='float')
57 # opObj11.addParameter(name='xmax', value='0.005', format='float')
57 # #opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
58 # #opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
58 # #opObj10.addParameter(name='channelList', value='0,1', format='intlist')
59 # #opObj10.addParameter(name='channelList', value='0,1', format='intlist')
59 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
60 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
60 # opObj11.addParameter(name='id', value='21', format='int')
61 # opObj11.addParameter(name='id', value='21', format='int')
61 # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
62 # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
62 # #opObj11.addParameter(name='xaxis', value='Velocity', format='str')
63 # #opObj11.addParameter(name='xaxis', value='Velocity', format='str')
63
64
64 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
65 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
65 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
66 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
66 # opObj11.addParameter(name='xmax', value='0.005', format='float')
67 # opObj11.addParameter(name='xmax', value='0.005', format='float')
67
68
68 # opObj11.addParameter(name='ymin', value='225', format='float')
69 # opObj11.addParameter(name='ymin', value='225', format='float')
69 # opObj11.addParameter(name='ymax', value='3000', format='float')
70 # opObj11.addParameter(name='ymax', value='3000', format='float')
70 # opObj11.addParameter(name='zmin', value='-100', format='int')
71 # opObj11.addParameter(name='zmin', value='-100', format='int')
71 # opObj11.addParameter(name='zmax', value='-65', format='int')
72 # opObj11.addParameter(name='zmax', value='-65', format='int')
72
73
73 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
74 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
74 # opObj11.addParameter(name='id', value='10', format='int')
75 # opObj11.addParameter(name='id', value='10', format='int')
75 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
76 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
76 # opObj11.addParameter(name='ymin', value='0', format='float')
77 # opObj11.addParameter(name='ymin', value='0', format='float')
77 # opObj11.addParameter(name='ymax', value='4000', format='float')
78 # opObj11.addParameter(name='ymax', value='4000', format='float')
78 # #opObj11.addParameter(name='zmin', value='-100', format='int')
79 # #opObj11.addParameter(name='zmin', value='-100', format='int')
79 # #opObj11.addParameter(name='zmax', value='-70', format='int')
80 # #opObj11.addParameter(name='zmax', value='-70', format='int')
80 # opObj11.addParameter(name='zmin', value='-90', format='int')
81 # opObj11.addParameter(name='zmin', value='-90', format='int')
81 # opObj11.addParameter(name='zmax', value='-40', format='int')
82 # opObj11.addParameter(name='zmax', value='-40', format='int')
82 # opObj11.addParameter(name='showprofile', value='1', format='int')
83 # opObj11.addParameter(name='showprofile', value='1', format='int')
83 # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int')
84 # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int')
84
85
85 opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
86 # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
86 procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
87 # procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
87 opObj11.addParameter(name='id', value='2005', format='int')
88 # opObj11.addParameter(name='id', value='2005', format='int')
88 opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
89 # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
89 # opObj11.addParameter(name='exp_code', value='13', format='int')
90 # # opObj11.addParameter(name='exp_code', value='13', format='int')
90 opObj11.addParameter(name='xaxis', value='Velocity', format='str')
91 # opObj11.addParameter(name='xaxis', value='Velocity', format='str')
91 #opObj11.addParameter(name='xmin', value='-10', format='float')
92 #opObj11.addParameter(name='xmin', value='-10', format='float')
92 #opObj11.addParameter(name='xmax', value='10', format='float')
93 #opObj11.addParameter(name='xmax', value='10', format='float')
93 #opObj11.addParameter(name='ymin', value='225', format='float')
94 #opObj11.addParameter(name='ymin', value='225', format='float')
94 #opObj11.addParameter(name='ymax', value='3000', format='float')
95 #opObj11.addParameter(name='ymax', value='3000', format='float')
95 #opObj11.addParameter(name='phase_min', value='-4', format='int')
96 #opObj11.addParameter(name='phase_min', value='-4', format='int')
96 #opObj11.addParameter(name='phase_max', value='4', format='int')
97 #opObj11.addParameter(name='phase_max', value='4', format='int')
97
98
98 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj1.getId())
99 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj1.getId())
99 # procUnitConfObj2.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
100 # procUnitConfObj2.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
100
101
101 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
102 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
102 opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
103 #opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
103 opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
104 opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
104 opObj22.addParameter(name='SNRlimit', value='7', format='float')
105 opObj22.addParameter(name='SNRlimit', value='2', format='float')
105
106
106 opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
107 opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
107 opObj22.addParameter(name='id', value='4', format='int')
108 opObj22.addParameter(name='id', value='4', format='int')
108 opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
109 opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
109 opObj22.addParameter(name='save', value='1', format='bool')
110 #opObj22.addParameter(name='save', value='1', format='bool')
110 # opObj22.addParameter(name='figpath', value = '/home/erick/Pictures', format='str')
111 # opObj22.addParameter(name='figpath', value = '/home/erick/Pictures', format='str')
111
112
112 opObj22.addParameter(name='zmin', value='-20', format='int')
113 opObj22.addParameter(name='zmin', value='-20', format='int')
113 opObj22.addParameter(name='zmax', value='20', format='int')
114 opObj22.addParameter(name='zmax', value='20', format='int')
114 opObj22.addParameter(name='zmin_ver', value='-300', format='float')
115 opObj22.addParameter(name='zmin_ver', value='-300', format='float')
115 opObj22.addParameter(name='zmax_ver', value='300', format='float')
116 opObj22.addParameter(name='zmax_ver', value='300', format='float')
116 opObj22.addParameter(name='SNRmin', value='-5', format='int')
117 opObj22.addParameter(name='SNRmin', value='-5', format='int')
117 opObj22.addParameter(name='SNRmax', value='30', format='int')
118 opObj22.addParameter(name='SNRmax', value='30', format='int')
118 # opObj22.addParameter(name='SNRthresh', value='-3.5', format='float')
119 # opObj22.addParameter(name='SNRthresh', value='-3.5', format='float')
119 opObj22.addParameter(name='xmin', value='0', format='float')
120 opObj22.addParameter(name='xmin', value='0', format='float')
120 opObj22.addParameter(name='xmax', value='24', format='float')
121 opObj22.addParameter(name='xmax', value='24', format='float')
121 opObj22.addParameter(name='ymin', value='225', format='float')
122 opObj22.addParameter(name='ymin', value='225', format='float')
122 #opObj22.addParameter(name='ymax', value='2000', format='float')
123 #opObj22.addParameter(name='ymax', value='2000', format='float')
123 opObj22.addParameter(name='save', value='1', format='int')
124 opObj22.addParameter(name='save', value='1', format='int')
124 opObj22.addParameter(name='figpath', value=figpath, format='str')
125 opObj22.addParameter(name='figpath', value=figpath, format='str')
125
126
126
127
127 # opObj11.addParameter(name='pairlist', value='(1,0),(0,2),(1,2)', format='pairsList')
128 # opObj11.addParameter(name='pairlist', value='(1,0),(0,2),(1,2)', format='pairsList')
128 #opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
129 #opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
129 #opObj10.addParameter(name='minHei', value='225', format='float')
130 #opObj10.addParameter(name='minHei', value='225', format='float')
130 #opObj10.addParameter(name='maxHei', value='1000', format='float')
131 #opObj10.addParameter(name='maxHei', value='1000', format='float')
131
132
132 # opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other')
133 # opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other')
133 # opObj11.addParameter(name='id', value='102', format='int')
134 # opObj11.addParameter(name='id', value='102', format='int')
134 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
135 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
135 # opObj11.addParameter(name='ymin', value='225', format='float')
136 # opObj11.addParameter(name='ymin', value='225', format='float')
136 # opObj11.addParameter(name='ymax', value='4000', format='float')
137 # opObj11.addParameter(name='ymax', value='4000', format='float')
137
138
138 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
139 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
139 # opObj11.addParameter(name='xmin', value='8.5', format='float')
140 # opObj11.addParameter(name='xmin', value='8.5', format='float')
140 # opObj11.addParameter(name='xmax', value='9.5', format='float')
141 # opObj11.addParameter(name='xmax', value='9.5', format='float')
141 # opObj11.addParameter(name='figpath', value=figpath, format='str')
142 # opObj11.addParameter(name='figpath', value=figpath, format='str')
142 # opObj11.addParameter(name='save', value=1, format='bool')
143 # opObj11.addParameter(name='save', value=1, format='bool')
143 # opObj11.addParameter(name='pairsList', value='(1,0),(3,2)', format='pairsList')
144 # opObj11.addParameter(name='pairsList', value='(1,0),(3,2)', format='pairsList')
144
145
145 # opObj12 = procUnitConfObj1.addOperation(name='PublishData', optype='other')
146 # opObj12 = procUnitConfObj1.addOperation(name='PublishData', optype='other')
146 # opObj12.addParameter(name='zeromq', value=1, format='int')
147 # opObj12.addParameter(name='zeromq', value=1, format='int')
147 # opObj12.addParameter(name='verbose', value=0, format='bool')
148 # opObj12.addParameter(name='verbose', value=0, format='bool')
148 # opObj12.addParameter(name='server', value='erick2', format='str')
149 # opObj12.addParameter(name='server', value='erick2', format='str')
149 controllerObj.start()
150 controllerObj.start()
150
151
151
152
@@ -1,239 +1,239
1 import os, sys
1 import os, sys
2
2
3 from schainpy.controller import Project
3 from schainpy.controller import Project
4
4
5 if __name__ == '__main__':
5 if __name__ == '__main__':
6
6
7 desc = "Segundo Test"
7 desc = "Segundo Test"
8 filename = "schain.xml"
8 filename = "schain.xml"
9
9
10 pathW='/media/erick/6F60F7113095A154/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra'
10 pathW='/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra'
11 figpath = '/media/erick/6F60F7113095A154/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra'
11 figpath = '/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/pdataCLAIRE/Extra'
12
12
13 controllerObj = Project()
13 controllerObj = Project()
14
14
15 controllerObj.setup(id='191', name='test01', description=desc)
15 controllerObj.setup(id='191', name='test01', description=desc)
16
16
17 readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader',
17 readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader',
18 path='/media/erick/6F60F7113095A154/CLAIRE/CLAIRE_WINDS_2MHZ/DATA/',
18 path='/data/CLAIRE/CLAIRE_WINDS_2MHZ/DATA',
19 #path='/home/erick/Documents/Data/Claire_Data/raw',
19 #path='/home/erick/Documents/Data/Claire_Data/raw',
20 startDate='2018/02/01',
20 startDate='2018/02/22',
21 endDate='2018/02/01',
21 endDate='2018/02/24',
22 startTime='12:00:00',
22 startTime='00:00:00',
23 endTime='20:00:00',
23 endTime='23:59:00',
24 online=0,
24 online=0,
25 walk=1)
25 walk=1)
26
26
27 opObj00 = readUnitConfObj.addOperation(name='printInfo')
27 opObj00 = readUnitConfObj.addOperation(name='printInfo')
28 #
28 #
29 # procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc',
29 # procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc',
30 # inputId=readUnitConfObj.getId())
30 # inputId=readUnitConfObj.getId())
31 #
31 #
32 # opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
32 # opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
33 # opObj10.addParameter(name='minHei', value='0', format='float')
33 # opObj10.addParameter(name='minHei', value='0', format='float')
34 # opObj10.addParameter(name='maxHei', value='8', format='float')
34 # opObj10.addParameter(name='maxHei', value='8', format='float')
35 #
35 #
36 # opObj10 = procUnitConfObj0.addOperation(name='filterByHeights')
36 # opObj10 = procUnitConfObj0.addOperation(name='filterByHeights')
37 # opObj10.addParameter(name='window', value='2', format='float')
37 # opObj10.addParameter(name='window', value='2', format='float')
38 #
38 #
39 # opObj10 = procUnitConfObj0.addOperation(name='Decoder', optype='external')
39 # opObj10 = procUnitConfObj0.addOperation(name='Decoder', optype='external')
40 # opObj10.addParameter(name='code', value='1,-1', format='intlist')
40 # opObj10.addParameter(name='code', value='1,-1', format='intlist')
41 # opObj10.addParameter(name='nCode', value='2', format='float')
41 # opObj10.addParameter(name='nCode', value='2', format='float')
42 # opObj10.addParameter(name='nBaud', value='1', format='float')
42 # opObj10.addParameter(name='nBaud', value='1', format='float')
43 #
43 #
44 #
44 #
45 # opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
45 # opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
46 # opObj10.addParameter(name='n', value='1296', format='float')
46 # opObj10.addParameter(name='n', value='1296', format='float')
47
47
48 opObj00 = readUnitConfObj.addOperation(name='printNumberOfBlock')
48 opObj00 = readUnitConfObj.addOperation(name='printNumberOfBlock')
49
49
50 procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc',
50 procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc',
51 inputId=readUnitConfObj.getId())
51 inputId=readUnitConfObj.getId())
52
52
53
53
54 opObj10 = procUnitConfObj0.addOperation(name='setRadarFrequency')
54 opObj10 = procUnitConfObj0.addOperation(name='setRadarFrequency')
55 opObj10.addParameter(name='frequency', value='445.09e6', format='float')
55 opObj10.addParameter(name='frequency', value='445.09e6', format='float')
56
56
57 opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
57 opObj10 = procUnitConfObj0.addOperation(name='CohInt', optype='external')
58 opObj10.addParameter(name='n', value='2', format='float')
58 opObj10.addParameter(name='n', value='2', format='float')
59
59
60 #opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
60 #opObj10 = procUnitConfObj0.addOperation(name='selectHeights')
61 #opObj10.addParameter(name='minHei', value='1', format='float')
61 #opObj10.addParameter(name='minHei', value='1', format='float')
62 #opObj10.addParameter(name='maxHei', value='15', format='float')
62 #opObj10.addParameter(name='maxHei', value='15', format='float')
63
63
64 #opObj10 = procUnitConfObj0.addOperation(name='selectFFTs')
64 #opObj10 = procUnitConfObj0.addOperation(name='selectFFTs')
65 #opObj10.addParameter(name='minHei', value='', format='float')
65 #opObj10.addParameter(name='minHei', value='', format='float')
66 #opObj10.addParameter(name='maxHei', value='', format='float')
66 #opObj10.addParameter(name='maxHei', value='', format='float')
67
67
68 procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc',
68 procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc',
69 inputId=procUnitConfObj0.getId())
69 inputId=procUnitConfObj0.getId())
70
70
71 # Creating a processing object with its parameters
71 # Creating a processing object with its parameters
72 # schainpy.model.proc.jroproc_spectra.SpectraProc.run()
72 # schainpy.model.proc.jroproc_spectra.SpectraProc.run()
73 # If you need to add more parameters can use the "addParameter method"
73 # If you need to add more parameters can use the "addParameter method"
74 procUnitConfObj1.addParameter(name='nFFTPoints', value='256', format='int')
74 procUnitConfObj1.addParameter(name='nFFTPoints', value='256', format='int')
75
75
76
76
77 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
77 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
78 #opObj10 = procUnitConfObj1.addOperation(name='removeInterference')
78 #opObj10 = procUnitConfObj1.addOperation(name='removeInterference')
79 opObj10 = procUnitConfObj1.addOperation(name='IncohInt', optype='external')
79 opObj10 = procUnitConfObj1.addOperation(name='IncohInt', optype='external')
80 opObj10.addParameter(name='n', value='10', format='float')
80 opObj10.addParameter(name='n', value='10', format='float')
81
81
82
82
83
83
84 #opObj10 = procUnitConfObj1.addOperation(name='selectFFTs')
84 #opObj10 = procUnitConfObj1.addOperation(name='selectFFTs')
85 #opObj10.addParameter(name='minFFT', value='-15', format='float')
85 #opObj10.addParameter(name='minFFT', value='-15', format='float')
86 #opObj10.addParameter(name='maxFFT', value='15', format='float')
86 #opObj10.addParameter(name='maxFFT', value='15', format='float')
87
87
88
88
89
89
90 opObj10 = procUnitConfObj1.addOperation(name='SpectraWriter', optype='other')
90 opObj10 = procUnitConfObj1.addOperation(name='SpectraWriter', optype='other')
91 opObj10.addParameter(name='blocksPerFile', value='64', format = 'int')
91 opObj10.addParameter(name='blocksPerFile', value='64', format = 'int')
92 opObj10.addParameter(name='path', value=pathW)
92 opObj10.addParameter(name='path', value=pathW)
93 # Using internal methods
93 # Using internal methods
94 # schainpy.model.proc.jroproc_spectra.SpectraProc.selectChannels()
94 # schainpy.model.proc.jroproc_spectra.SpectraProc.selectChannels()
95 # opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
95 # opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
96 # opObj10.addParameter(name='channelList', value='0,1', format='intlist')
96 # opObj10.addParameter(name='channelList', value='0,1', format='intlist')
97
97
98 # Using internal methods
98 # Using internal methods
99 # schainpy.model.proc.jroproc_spectra.SpectraProc.selectHeights()
99 # schainpy.model.proc.jroproc_spectra.SpectraProc.selectHeights()
100 # opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
100 # opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
101 # opObj10.addParameter(name='minHei', value='90', format='float')
101 # opObj10.addParameter(name='minHei', value='90', format='float')
102 # opObj10.addParameter(name='maxHei', value='180', format='float')
102 # opObj10.addParameter(name='maxHei', value='180', format='float')
103
103
104 # Using external methods (new modules)
104 # Using external methods (new modules)
105 # #schainpy.model.proc.jroproc_spectra.IncohInt.setup()
105 # #schainpy.model.proc.jroproc_spectra.IncohInt.setup()
106 # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
106 # opObj12 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
107 # opObj12.addParameter(name='n', value='1', format='int')
107 # opObj12.addParameter(name='n', value='1', format='int')
108
108
109 # Using external methods (new modules)
109 # Using external methods (new modules)
110 # schainpy.model.graphics.jroplot_spectra.SpectraPlot.setup()
110 # schainpy.model.graphics.jroplot_spectra.SpectraPlot.setup()
111 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
111 opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='external')
112 opObj11.addParameter(name='id', value='11', format='int')
112 opObj11.addParameter(name='id', value='11', format='int')
113 opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
113 opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
114 opObj11.addParameter(name='xaxis', value='velocity', format='str')
114 opObj11.addParameter(name='xaxis', value='velocity', format='str')
115 # opObj11.addParameter(name='xmin', value='-10', format='int')
115 # opObj11.addParameter(name='xmin', value='-10', format='int')
116 # opObj11.addParameter(name='xmax', value='10', format='int')
116 # opObj11.addParameter(name='xmax', value='10', format='int')
117
117
118 # opObj11.addParameter(name='ymin', value='1', format='float')
118 # opObj11.addParameter(name='ymin', value='1', format='float')
119 # opObj11.addParameter(name='ymax', value='3', format='int')
119 # opObj11.addParameter(name='ymax', value='3', format='int')
120 #opObj11.addParameter(name='zmin', value='10', format='int')
120 #opObj11.addParameter(name='zmin', value='10', format='int')
121 #opObj11.addParameter(name='zmax', value='35', format='int')
121 #opObj11.addParameter(name='zmax', value='35', format='int')
122 # opObj11.addParameter(name='save', value='2', format='int')
122 # opObj11.addParameter(name='save', value='2', format='int')
123 # opObj11.addParameter(name='save', value='5', format='int')
123 # opObj11.addParameter(name='save', value='5', format='int')
124 # opObj11.addParameter(name='figpath', value=figpath, format='str')
124 # opObj11.addParameter(name='figpath', value=figpath, format='str')
125
125
126
126
127 opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
127 opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
128 procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
128 procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
129 opObj11.addParameter(name='id', value='2005', format='int')
129 opObj11.addParameter(name='id', value='2005', format='int')
130 #opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
130 #opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
131 #opObj11.addParameter(name='exp_code', value='13', format='int')
131 #opObj11.addParameter(name='exp_code', value='13', format='int')
132 opObj11.addParameter(name='xaxis', value='Velocity', format='str')
132 opObj11.addParameter(name='xaxis', value='Velocity', format='str')
133 #opObj11.addParameter(name='xmin', value='-6', format='float')
133 #opObj11.addParameter(name='xmin', value='-6', format='float')
134 #opObj11.addParameter(name='xmax', value='6', format='float')
134 #opObj11.addParameter(name='xmax', value='6', format='float')
135 opObj11.addParameter(name='zmin', value='15', format='float')
135 opObj11.addParameter(name='zmin', value='15', format='float')
136 opObj11.addParameter(name='zmax', value='50', format='float')
136 opObj11.addParameter(name='zmax', value='50', format='float')
137 opObj11.addParameter(name='ymin', value='0', format='float')
137 opObj11.addParameter(name='ymin', value='0', format='float')
138 opObj11.addParameter(name='ymax', value='7', format='float')
138 opObj11.addParameter(name='ymax', value='7', format='float')
139 #opObj11.addParameter(name='phase_min', value='-4', format='int')
139 #opObj11.addParameter(name='phase_min', value='-4', format='int')
140 #opObj11.addParameter(name='phase_max', value='4', format='int')
140 #opObj11.addParameter(name='phase_max', value='4', format='int')
141 #
141 #
142
142
143 # Using external methods (new modules)
143 # Using external methods (new modules)
144 # schainpy.model.graphics.jroplot_spectra.RTIPlot.setup()
144 # schainpy.model.graphics.jroplot_spectra.RTIPlot.setup()
145 opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
145 opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
146 opObj11.addParameter(name='id', value='30', format='int')
146 opObj11.addParameter(name='id', value='30', format='int')
147 opObj11.addParameter(name='wintitle', value='RTI', format='str')
147 opObj11.addParameter(name='wintitle', value='RTI', format='str')
148 opObj11.addParameter(name='zmin', value='15', format='int')
148 opObj11.addParameter(name='zmin', value='15', format='int')
149 opObj11.addParameter(name='zmax', value='40', format='int')
149 opObj11.addParameter(name='zmax', value='40', format='int')
150 opObj11.addParameter(name='ymin', value='1', format='int')
150 opObj11.addParameter(name='ymin', value='1', format='int')
151 opObj11.addParameter(name='ymax', value='7', format='int')
151 opObj11.addParameter(name='ymax', value='7', format='int')
152 opObj11.addParameter(name='showprofile', value='1', format='int')
152 opObj11.addParameter(name='showprofile', value='1', format='int')
153 # opObj11.addParameter(name='timerange', value=str(5*60*60*60), format='int')
153 # opObj11.addParameter(name='timerange', value=str(5*60*60*60), format='int')
154 #opObj11.addParameter(name='xmin', value='1', format='float')
154 #opObj11.addParameter(name='xmin', value='1', format='float')
155 #opObj11.addParameter(name='xmax', value='6', format='float')
155 #opObj11.addParameter(name='xmax', value='6', format='float')
156 opObj11.addParameter(name='save', value='1', format='int')
156 opObj11.addParameter(name='save', value='1', format='int')
157 opObj11.addParameter(name='figpath', value=figpath, format='str')
157 opObj11.addParameter(name='figpath', value=figpath, format='str')
158
158
159
159
160 # '''#########################################################################################'''
160 # '''#########################################################################################'''
161 #
161 #
162 #
162 #
163 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
163 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
164 # opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
164 # opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
165 #
165 #
166 # '''
166 # '''
167 # # Discriminacion de ecos
167 # # Discriminacion de ecos
168 # opObj11 = procUnitConfObj2.addOperation(name='GaussianFit', optype='other')
168 # opObj11 = procUnitConfObj2.addOperation(name='GaussianFit', optype='other')
169 # opObj11.addParameter(name='SNRlimit', value='0', format='int')
169 # opObj11.addParameter(name='SNRlimit', value='0', format='int')
170 # '''
170 # '''
171 #
171 #
172 # '''
172 # '''
173 # # Estimacion de Precipitacion
173 # # Estimacion de Precipitacion
174 # opObj11 = procUnitConfObj2.addOperation(name='PrecipitationProc', optype='other')
174 # opObj11 = procUnitConfObj2.addOperation(name='PrecipitationProc', optype='other')
175 # '''
175 # '''
176 #
176 #
177 # opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
177 # opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
178 #
178 #
179 # opObj22.addParameter(name='SNRlimit', value='-10', format='float')
179 # opObj22.addParameter(name='SNRlimit', value='-10', format='float')
180 # opObj22.addParameter(name='E01', value='1.500', format='float')
180 # opObj22.addParameter(name='E01', value='1.500', format='float')
181 # opObj22.addParameter(name='E02', value='1.500', format='float')
181 # opObj22.addParameter(name='E02', value='1.500', format='float')
182 # opObj22.addParameter(name='E12', value='0', format='float')
182 # opObj22.addParameter(name='E12', value='0', format='float')
183 # opObj22.addParameter(name='N01', value='0.875', format='float')
183 # opObj22.addParameter(name='N01', value='0.875', format='float')
184 # opObj22.addParameter(name='N02', value='-0.875', format='float')
184 # opObj22.addParameter(name='N02', value='-0.875', format='float')
185 # opObj22.addParameter(name='N12', value='-1.750', format='float')
185 # opObj22.addParameter(name='N12', value='-1.750', format='float')
186 #
186 #
187 #
187 #
188 # opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
188 # opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
189 # opObj22.addParameter(name='id', value='4', format='int')
189 # opObj22.addParameter(name='id', value='4', format='int')
190 # opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
190 # opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
191 # opObj22.addParameter(name='save', value='1', format='bool')
191 # opObj22.addParameter(name='save', value='1', format='bool')
192 # opObj22.addParameter(name='xmin', value='0', format='float')
192 # opObj22.addParameter(name='xmin', value='0', format='float')
193 # opObj22.addParameter(name='xmax', value='6', format='float')
193 # opObj22.addParameter(name='xmax', value='6', format='float')
194 # opObj22.addParameter(name='ymin', value='1', format='float')
194 # opObj22.addParameter(name='ymin', value='1', format='float')
195 # opObj22.addParameter(name='ymax', value='3.5', format='float')
195 # opObj22.addParameter(name='ymax', value='3.5', format='float')
196 # opObj22.addParameter(name='zmin', value='-1', format='float')
196 # opObj22.addParameter(name='zmin', value='-1', format='float')
197 # opObj22.addParameter(name='zmax', value='1', format='float')
197 # opObj22.addParameter(name='zmax', value='1', format='float')
198 # opObj22.addParameter(name='SNRmin', value='-15', format='float')
198 # opObj22.addParameter(name='SNRmin', value='-15', format='float')
199 # opObj22.addParameter(name='SNRmax', value='20', format='float')
199 # opObj22.addParameter(name='SNRmax', value='20', format='float')
200 # opObj22.addParameter(name='zmin_ver', value='-200', format='float')
200 # opObj22.addParameter(name='zmin_ver', value='-200', format='float')
201 # opObj22.addParameter(name='zmax_ver', value='200', format='float')
201 # opObj22.addParameter(name='zmax_ver', value='200', format='float')
202 # opObj22.addParameter(name='save', value='1', format='int')
202 # opObj22.addParameter(name='save', value='1', format='int')
203 # opObj22.addParameter(name='figpath', value=figpath, format='str')
203 # opObj22.addParameter(name='figpath', value=figpath, format='str')
204 #
204 #
205 #
205 #
206 #
206 #
207 # #opObj11.addParameter(name='zmin', value='75', format='int')
207 # #opObj11.addParameter(name='zmin', value='75', format='int')
208 #
208 #
209 # #opObj12 = procUnitConfObj2.addOperation(name='ParametersPlot', optype='other')
209 # #opObj12 = procUnitConfObj2.addOperation(name='ParametersPlot', optype='other')
210 # #opObj12.addParameter(name='id',value='4',format='int')
210 # #opObj12.addParameter(name='id',value='4',format='int')
211 # #opObj12.addParameter(name='wintitle',value='First_gg',format='str')
211 # #opObj12.addParameter(name='wintitle',value='First_gg',format='str')
212 # '''
212 # '''
213 # #Ploteo de Discriminacion de Gaussianas
213 # #Ploteo de Discriminacion de Gaussianas
214 #
214 #
215 # opObj11 = procUnitConfObj2.addOperation(name='FitGauPlot', optype='other')
215 # opObj11 = procUnitConfObj2.addOperation(name='FitGauPlot', optype='other')
216 # opObj11.addParameter(name='id', value='21', format='int')
216 # opObj11.addParameter(name='id', value='21', format='int')
217 # opObj11.addParameter(name='wintitle', value='Rainfall Gaussian', format='str')
217 # opObj11.addParameter(name='wintitle', value='Rainfall Gaussian', format='str')
218 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
218 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
219 # opObj11.addParameter(name='showprofile', value='1', format='int')
219 # opObj11.addParameter(name='showprofile', value='1', format='int')
220 # opObj11.addParameter(name='zmin', value='75', format='int')
220 # opObj11.addParameter(name='zmin', value='75', format='int')
221 # opObj11.addParameter(name='zmax', value='100', format='int')
221 # opObj11.addParameter(name='zmax', value='100', format='int')
222 # opObj11.addParameter(name='GauSelector', value='1', format='int')
222 # opObj11.addParameter(name='GauSelector', value='1', format='int')
223 # #opObj11.addParameter(name='save', value='1', format='int')
223 # #opObj11.addParameter(name='save', value='1', format='int')
224 # #opObj11.addParameter(name='figpath', value='/home/erick/Documents/Data/d2015106')
224 # #opObj11.addParameter(name='figpath', value='/home/erick/Documents/Data/d2015106')
225 #
225 #
226 # opObj11 = procUnitConfObj2.addOperation(name='FitGauPlot', optype='other')
226 # opObj11 = procUnitConfObj2.addOperation(name='FitGauPlot', optype='other')
227 # opObj11.addParameter(name='id', value='22', format='int')
227 # opObj11.addParameter(name='id', value='22', format='int')
228 # opObj11.addParameter(name='wintitle', value='Wind Gaussian', format='str')
228 # opObj11.addParameter(name='wintitle', value='Wind Gaussian', format='str')
229 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
229 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
230 # opObj11.addParameter(name='showprofile', value='1', format='int')
230 # opObj11.addParameter(name='showprofile', value='1', format='int')
231 # opObj11.addParameter(name='zmin', value='75', format='int')
231 # opObj11.addParameter(name='zmin', value='75', format='int')
232 # opObj11.addParameter(name='zmax', value='100', format='int')
232 # opObj11.addParameter(name='zmax', value='100', format='int')
233 # opObj11.addParameter(name='GauSelector', value='0', format='int')
233 # opObj11.addParameter(name='GauSelector', value='0', format='int')
234 # '''
234 # '''
235 #
235 #
236 #
236 #
237
237
238
238
239 controllerObj.start()
239 controllerObj.start()
General Comments 0
You need to be logged in to leave comments. Login now