##// END OF EJS Templates
07/09/2017
ebocanegra -
r1027:f11c2da27e74
parent child
Show More

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

@@ -1,1541 +1,1584
1 '''
1 '''
2 Created on Jul 9, 2014
2 Created on Jul 9, 2014
3
3
4 @author: roj-idl71
4 @author: roj-idl71
5 '''
5 '''
6 import os
6 import os
7 import datetime
7 import datetime
8 import numpy
8 import numpy
9
9
10 import matplotlib.pyplot as plt
11
10 from figure import Figure, isRealtime, isTimeInHourRange
12 from figure import Figure, isRealtime, isTimeInHourRange
11 from plotting_codes import *
13 from plotting_codes import *
14 from matplotlib.pyplot import savefig
12
15
13 class SpectraPlot(Figure):
16 class SpectraPlot(Figure):
14
17
15 isConfig = None
18 isConfig = None
16 __nsubplots = None
19 __nsubplots = None
17
20
18 WIDTHPROF = None
21 WIDTHPROF = None
19 HEIGHTPROF = None
22 HEIGHTPROF = None
20 PREFIX = 'spc'
23 PREFIX = 'spc'
21
24
22 def __init__(self, **kwargs):
25 def __init__(self, **kwargs):
23 Figure.__init__(self, **kwargs)
26 Figure.__init__(self, **kwargs)
24 self.isConfig = False
27 self.isConfig = False
25 self.__nsubplots = 1
28 self.__nsubplots = 1
26
29
27 self.WIDTH = 250
30 self.WIDTH = 250
28 self.HEIGHT = 250
31 self.HEIGHT = 250
29 self.WIDTHPROF = 120
32 self.WIDTHPROF = 120
30 self.HEIGHTPROF = 0
33 self.HEIGHTPROF = 0
31 self.counter_imagwr = 0
34 self.counter_imagwr = 0
32
35
33 self.PLOT_CODE = SPEC_CODE
36 self.PLOT_CODE = SPEC_CODE
34
37
35 self.FTP_WEI = None
38 self.FTP_WEI = None
36 self.EXP_CODE = None
39 self.EXP_CODE = None
37 self.SUB_EXP_CODE = None
40 self.SUB_EXP_CODE = None
38 self.PLOT_POS = None
41 self.PLOT_POS = None
39
42
40 self.__xfilter_ena = False
43 self.__xfilter_ena = False
41 self.__yfilter_ena = False
44 self.__yfilter_ena = False
45
46 self.indice=1
42
47
43 def getSubplots(self):
48 def getSubplots(self):
44
49
45 ncol = int(numpy.sqrt(self.nplots)+0.9)
50 ncol = int(numpy.sqrt(self.nplots)+0.9)
46 nrow = int(self.nplots*1./ncol + 0.9)
51 nrow = int(self.nplots*1./ncol + 0.9)
47
52
48 return nrow, ncol
53 return nrow, ncol
49
54
50 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
55 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
51
56
52 self.__showprofile = showprofile
57 self.__showprofile = showprofile
53 self.nplots = nplots
58 self.nplots = nplots
54
59
55 ncolspan = 1
60 ncolspan = 1
56 colspan = 1
61 colspan = 1
57 if showprofile:
62 if showprofile:
58 ncolspan = 3
63 ncolspan = 3
59 colspan = 2
64 colspan = 2
60 self.__nsubplots = 2
65 self.__nsubplots = 2
61
66
62 self.createFigure(id = id,
67 self.createFigure(id = id,
63 wintitle = wintitle,
68 wintitle = wintitle,
64 widthplot = self.WIDTH + self.WIDTHPROF,
69 widthplot = self.WIDTH + self.WIDTHPROF,
65 heightplot = self.HEIGHT + self.HEIGHTPROF,
70 heightplot = self.HEIGHT + self.HEIGHTPROF,
66 show=show)
71 show=show)
67
72
68 nrow, ncol = self.getSubplots()
73 nrow, ncol = self.getSubplots()
69
74
70 counter = 0
75 counter = 0
71 for y in range(nrow):
76 for y in range(nrow):
72 for x in range(ncol):
77 for x in range(ncol):
73
78
74 if counter >= self.nplots:
79 if counter >= self.nplots:
75 break
80 break
76
81
77 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
82 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
78
83
79 if showprofile:
84 if showprofile:
80 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
85 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
81
86
82 counter += 1
87 counter += 1
83
88
84 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
89 def run(self, dataOut, id, wintitle="", channelList=None, showprofile=True,
85 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
90 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
86 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
91 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
87 server=None, folder=None, username=None, password=None,
92 server=None, folder=None, username=None, password=None,
88 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
93 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, realtime=False,
89 xaxis="frequency", colormap='jet', normFactor=None):
94 xaxis="frequency", colormap='jet', normFactor=None):
90
95
91 """
96 """
92
97
93 Input:
98 Input:
94 dataOut :
99 dataOut :
95 id :
100 id :
96 wintitle :
101 wintitle :
97 channelList :
102 channelList :
98 showProfile :
103 showProfile :
99 xmin : None,
104 xmin : None,
100 xmax : None,
105 xmax : None,
101 ymin : None,
106 ymin : None,
102 ymax : None,
107 ymax : None,
103 zmin : None,
108 zmin : None,
104 zmax : None
109 zmax : None
105 """
110 """
106 if realtime:
111 if realtime:
107 if not(isRealtime(utcdatatime = dataOut.utctime)):
112 if not(isRealtime(utcdatatime = dataOut.utctime)):
108 print 'Skipping this plot function'
113 print 'Skipping this plot function'
109 return
114 return
110
115
111 if channelList == None:
116 if channelList == None:
112 channelIndexList = dataOut.channelIndexList
117 channelIndexList = dataOut.channelIndexList
113 else:
118 else:
114 channelIndexList = []
119 channelIndexList = []
115 for channel in channelList:
120 for channel in channelList:
116 if channel not in dataOut.channelList:
121 if channel not in dataOut.channelList:
117 raise ValueError, "Channel %d is not in dataOut.channelList" %channel
122 raise ValueError, "Channel %d is not in dataOut.channelList" %channel
118 channelIndexList.append(dataOut.channelList.index(channel))
123 channelIndexList.append(dataOut.channelList.index(channel))
119
124
120 if normFactor is None:
125 if normFactor is None:
121 factor = dataOut.normFactor
126 factor = dataOut.normFactor
122 else:
127 else:
123 factor = normFactor
128 factor = normFactor
124 if xaxis == "frequency":
129 if xaxis == "frequency":
125 x = dataOut.getFreqRange(1)/1000.
130 x = dataOut.getFreqRange(1)/1000.
126 xlabel = "Frequency (kHz)"
131 xlabel = "Frequency (kHz)"
127
132
128 elif xaxis == "time":
133 elif xaxis == "time":
129 x = dataOut.getAcfRange(1)
134 x = dataOut.getAcfRange(1)
130 xlabel = "Time (ms)"
135 xlabel = "Time (ms)"
131
136
132 else:
137 else:
133 x = dataOut.getVelRange(1)
138 x = dataOut.getVelRange(1)
134 xlabel = "Velocity (m/s)"
139 xlabel = "Velocity (m/s)"
135
140
136 ylabel = "Range (Km)"
141 ylabel = "Range (Km)"
137
142
138 y = dataOut.getHeiRange()
143 y = dataOut.getHeiRange()
139
144
140 z = dataOut.data_spc/factor
145 z = dataOut.data_spc/factor
141 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
146 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
142 zdB = 10*numpy.log10(z)
147 zdB = 10*numpy.log10(z)
143
148
144 avg = numpy.average(z, axis=1)
149 avg = numpy.average(z, axis=1)
145 avgdB = 10*numpy.log10(avg)
150 avgdB = 10*numpy.log10(avg)
146
151
147 noise = dataOut.getNoise()/factor
152 noise = dataOut.getNoise()/factor
148 noisedB = 10*numpy.log10(noise)
153 noisedB = 10*numpy.log10(noise)
149
154
150 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
155 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
151 title = wintitle + " Spectra"
156 title = wintitle + " Spectra"
157
158
159
160 print 'len de X',len(x), numpy.shape(x), 'len de spc line',len(dataOut.data_spc[1,:,15]), numpy.shape(dataOut.data_spc)
161 print 'Altura:', y[0], y[1], y[13], y[14], y[10]
162 #a=z[1,:,15]
163
164 # fig = plt.figure(10+self.indice)
165 # plt.plot( x[0:128], zdB[0,:,10] )
166 # plt.axis([-12, 12, 15, 50])
167 # plt.title(" %s" %( '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))) )
168 # plt.ylabel('Intensidad [dB]')
169 # plt.xlabel('Velocidad [m/s]')
170 # fig.savefig('/home/erick/Documents/Pics/to{}.png'.format(self.indice))
171 #
172 # plt.show()
173 #
174 # self.indice=self.indice+1
175
176
177
152 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
178 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
153 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
179 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
154
180
155 if not self.isConfig:
181 if not self.isConfig:
156
182
157 nplots = len(channelIndexList)
183 nplots = len(channelIndexList)
158
184
159 self.setup(id=id,
185 self.setup(id=id,
160 nplots=nplots,
186 nplots=nplots,
161 wintitle=wintitle,
187 wintitle=wintitle,
162 showprofile=showprofile,
188 showprofile=showprofile,
163 show=show)
189 show=show)
164
190
165 if xmin == None: xmin = numpy.nanmin(x)
191 if xmin == None: xmin = numpy.nanmin(x)
166 if xmax == None: xmax = numpy.nanmax(x)
192 if xmax == None: xmax = numpy.nanmax(x)
167 if ymin == None: ymin = numpy.nanmin(y)
193 if ymin == None: ymin = numpy.nanmin(y)
168 if ymax == None: ymax = numpy.nanmax(y)
194 if ymax == None: ymax = numpy.nanmax(y)
169 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
195 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
170 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
196 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
171
197
172 self.FTP_WEI = ftp_wei
198 self.FTP_WEI = ftp_wei
173 self.EXP_CODE = exp_code
199 self.EXP_CODE = exp_code
174 self.SUB_EXP_CODE = sub_exp_code
200 self.SUB_EXP_CODE = sub_exp_code
175 self.PLOT_POS = plot_pos
201 self.PLOT_POS = plot_pos
176
202
177 self.isConfig = True
203 self.isConfig = True
178
204
179 self.setWinTitle(title)
205 self.setWinTitle(title)
180
206
181 for i in range(self.nplots):
207 for i in range(self.nplots):
182 index = channelIndexList[i]
208 index = channelIndexList[i]
183 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
209 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
184 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime)
210 title = "Channel %d: %4.2fdB: %s" %(dataOut.channelList[index], noisedB[index], str_datetime)
185 if len(dataOut.beam.codeList) != 0:
211 if len(dataOut.beam.codeList) != 0:
186 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)
212 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)
187
213
188 axes = self.axesList[i*self.__nsubplots]
214 axes = self.axesList[i*self.__nsubplots]
189 axes.pcolor(x, y, zdB[index,:,:],
215 axes.pcolor(x, y, zdB[index,:,:],
190 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
216 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
191 xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap,
217 xlabel=xlabel, ylabel=ylabel, title=title, colormap=colormap,
192 ticksize=9, cblabel='')
218 ticksize=9, cblabel='')
193
219
194 if self.__showprofile:
220 if self.__showprofile:
195 axes = self.axesList[i*self.__nsubplots +1]
221 axes = self.axesList[i*self.__nsubplots +1]
196 axes.pline(avgdB[index,:], y,
222 axes.pline(avgdB[index,:], y,
197 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
223 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
198 xlabel='dB', ylabel='', title='',
224 xlabel='dB', ylabel='', title='',
199 ytick_visible=False,
225 ytick_visible=False,
200 grid='x')
226 grid='x')
201
227
202 noiseline = numpy.repeat(noisedB[index], len(y))
228 noiseline = numpy.repeat(noisedB[index], len(y))
203 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
229 axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2)
204
230
205 self.draw()
231 self.draw()
206
232
207 if figfile == None:
233 if figfile == None:
208 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
234 str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S")
209 name = str_datetime
235 name = str_datetime
210 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
236 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
211 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
237 name = name + '_az' + '_%2.2f'%(dataOut.azimuth) + '_zn' + '_%2.2f'%(dataOut.zenith)
212 figfile = self.getFilename(name)
238 figfile = self.getFilename(name)
213
239
214 self.save(figpath=figpath,
240 self.save(figpath=figpath,
215 figfile=figfile,
241 figfile=figfile,
216 save=save,
242 save=save,
217 ftp=ftp,
243 ftp=ftp,
218 wr_period=wr_period,
244 wr_period=wr_period,
219 thisDatetime=thisDatetime)
245 thisDatetime=thisDatetime)
246
220
247
221 class CrossSpectraPlot(Figure):
248 class CrossSpectraPlot(Figure):
222
249
223 isConfig = None
250 isConfig = None
224 __nsubplots = None
251 __nsubplots = None
225
252
226 WIDTH = None
253 WIDTH = None
227 HEIGHT = None
254 HEIGHT = None
228 WIDTHPROF = None
255 WIDTHPROF = None
229 HEIGHTPROF = None
256 HEIGHTPROF = None
230 PREFIX = 'cspc'
257 PREFIX = 'cspc'
231
258
232 def __init__(self, **kwargs):
259 def __init__(self, **kwargs):
233 Figure.__init__(self, **kwargs)
260 Figure.__init__(self, **kwargs)
234 self.isConfig = False
261 self.isConfig = False
235 self.__nsubplots = 4
262 self.__nsubplots = 4
236 self.counter_imagwr = 0
263 self.counter_imagwr = 0
237 self.WIDTH = 250
264 self.WIDTH = 250
238 self.HEIGHT = 250
265 self.HEIGHT = 250
239 self.WIDTHPROF = 0
266 self.WIDTHPROF = 0
240 self.HEIGHTPROF = 0
267 self.HEIGHTPROF = 0
241
268
242 self.PLOT_CODE = CROSS_CODE
269 self.PLOT_CODE = CROSS_CODE
243 self.FTP_WEI = None
270 self.FTP_WEI = None
244 self.EXP_CODE = None
271 self.EXP_CODE = None
245 self.SUB_EXP_CODE = None
272 self.SUB_EXP_CODE = None
246 self.PLOT_POS = None
273 self.PLOT_POS = None
274
275 self.indice=0
247
276
248 def getSubplots(self):
277 def getSubplots(self):
249
278
250 ncol = 4
279 ncol = 4
251 nrow = self.nplots
280 nrow = self.nplots
252
281
253 return nrow, ncol
282 return nrow, ncol
254
283
255 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
284 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
256
285
257 self.__showprofile = showprofile
286 self.__showprofile = showprofile
258 self.nplots = nplots
287 self.nplots = nplots
259
288
260 ncolspan = 1
289 ncolspan = 1
261 colspan = 1
290 colspan = 1
262
291
263 self.createFigure(id = id,
292 self.createFigure(id = id,
264 wintitle = wintitle,
293 wintitle = wintitle,
265 widthplot = self.WIDTH + self.WIDTHPROF,
294 widthplot = self.WIDTH + self.WIDTHPROF,
266 heightplot = self.HEIGHT + self.HEIGHTPROF,
295 heightplot = self.HEIGHT + self.HEIGHTPROF,
267 show=True)
296 show=True)
268
297
269 nrow, ncol = self.getSubplots()
298 nrow, ncol = self.getSubplots()
270
299
271 counter = 0
300 counter = 0
272 for y in range(nrow):
301 for y in range(nrow):
273 for x in range(ncol):
302 for x in range(ncol):
274 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
303 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
275
304
276 counter += 1
305 counter += 1
277
306
278 def run(self, dataOut, id, wintitle="", pairsList=None,
307 def run(self, dataOut, id, wintitle="", pairsList=None,
279 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
308 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
280 coh_min=None, coh_max=None, phase_min=None, phase_max=None,
309 coh_min=None, coh_max=None, phase_min=None, phase_max=None,
281 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
310 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
282 power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
311 power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
283 server=None, folder=None, username=None, password=None,
312 server=None, folder=None, username=None, password=None,
284 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, normFactor=None,
313 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, normFactor=None,
285 xaxis='frequency'):
314 xaxis='frequency'):
286
315
287 """
316 """
288
317
289 Input:
318 Input:
290 dataOut :
319 dataOut :
291 id :
320 id :
292 wintitle :
321 wintitle :
293 channelList :
322 channelList :
294 showProfile :
323 showProfile :
295 xmin : None,
324 xmin : None,
296 xmax : None,
325 xmax : None,
297 ymin : None,
326 ymin : None,
298 ymax : None,
327 ymax : None,
299 zmin : None,
328 zmin : None,
300 zmax : None
329 zmax : None
301 """
330 """
302
331
303 if pairsList == None:
332 if pairsList == None:
304 pairsIndexList = dataOut.pairsIndexList
333 pairsIndexList = dataOut.pairsIndexList
305 else:
334 else:
306 pairsIndexList = []
335 pairsIndexList = []
307 for pair in pairsList:
336 for pair in pairsList:
308 if pair not in dataOut.pairsList:
337 if pair not in dataOut.pairsList:
309 raise ValueError, "Pair %s is not in dataOut.pairsList" %str(pair)
338 raise ValueError, "Pair %s is not in dataOut.pairsList" %str(pair)
310 pairsIndexList.append(dataOut.pairsList.index(pair))
339 pairsIndexList.append(dataOut.pairsList.index(pair))
311
340
312 if not pairsIndexList:
341 if not pairsIndexList:
313 return
342 return
314
343
315 if len(pairsIndexList) > 4:
344 if len(pairsIndexList) > 4:
316 pairsIndexList = pairsIndexList[0:4]
345 pairsIndexList = pairsIndexList[0:4]
317
346
318 if normFactor is None:
347 if normFactor is None:
319 factor = dataOut.normFactor
348 factor = dataOut.normFactor
320 else:
349 else:
321 factor = normFactor
350 factor = normFactor
322 x = dataOut.getVelRange(1)
351 x = dataOut.getVelRange(1)
323 y = dataOut.getHeiRange()
352 y = dataOut.getHeiRange()
324 z = dataOut.data_spc[:,:,:]/factor
353 z = dataOut.data_spc[:,:,:]/factor
325 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
354 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
326
355
327 noise = dataOut.noise/factor
356 noise = dataOut.noise/factor
328
357
329 zdB = 10*numpy.log10(z)
358 zdB = 10*numpy.log10(z)
330 noisedB = 10*numpy.log10(noise)
359 noisedB = 10*numpy.log10(noise)
331
360
332 if coh_min == None:
361 if coh_min == None:
333 coh_min = 0.0
362 coh_min = 0.0
334 if coh_max == None:
363 if coh_max == None:
335 coh_max = 1.0
364 coh_max = 1.0
336
365
337 if phase_min == None:
366 if phase_min == None:
338 phase_min = -180
367 phase_min = -180
339 if phase_max == None:
368 if phase_max == None:
340 phase_max = 180
369 phase_max = 180
341
370
342 #thisDatetime = dataOut.datatime
371 #thisDatetime = dataOut.datatime
343 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
372 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
344 title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
373 title = wintitle + " Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
345 # xlabel = "Velocity (m/s)"
374 # xlabel = "Velocity (m/s)"
346 ylabel = "Range (Km)"
375 ylabel = "Range (Km)"
347
376
348 if xaxis == "frequency":
377 if xaxis == "frequency":
349 x = dataOut.getFreqRange(1)/1000.
378 x = dataOut.getFreqRange(1)/1000.
350 xlabel = "Frequency (kHz)"
379 xlabel = "Frequency (kHz)"
351
380
352 elif xaxis == "time":
381 elif xaxis == "time":
353 x = dataOut.getAcfRange(1)
382 x = dataOut.getAcfRange(1)
354 xlabel = "Time (ms)"
383 xlabel = "Time (ms)"
355
384
356 else:
385 else:
357 x = dataOut.getVelRange(1)
386 x = dataOut.getVelRange(1)
358 xlabel = "Velocity (m/s)"
387 xlabel = "Velocity (m/s)"
359
388
360 if not self.isConfig:
389 if not self.isConfig:
361
390
362 nplots = len(pairsIndexList)
391 nplots = len(pairsIndexList)
363
392
364 self.setup(id=id,
393 self.setup(id=id,
365 nplots=nplots,
394 nplots=nplots,
366 wintitle=wintitle,
395 wintitle=wintitle,
367 showprofile=False,
396 showprofile=False,
368 show=show)
397 show=show)
369
398
370 avg = numpy.abs(numpy.average(z, axis=1))
399 avg = numpy.abs(numpy.average(z, axis=1))
371 avgdB = 10*numpy.log10(avg)
400 avgdB = 10*numpy.log10(avg)
372
401
373 if xmin == None: xmin = numpy.nanmin(x)
402 if xmin == None: xmin = numpy.nanmin(x)
374 if xmax == None: xmax = numpy.nanmax(x)
403 if xmax == None: xmax = numpy.nanmax(x)
375 if ymin == None: ymin = numpy.nanmin(y)
404 if ymin == None: ymin = numpy.nanmin(y)
376 if ymax == None: ymax = numpy.nanmax(y)
405 if ymax == None: ymax = numpy.nanmax(y)
377 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
406 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
378 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
407 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
379
408
380 self.FTP_WEI = ftp_wei
409 self.FTP_WEI = ftp_wei
381 self.EXP_CODE = exp_code
410 self.EXP_CODE = exp_code
382 self.SUB_EXP_CODE = sub_exp_code
411 self.SUB_EXP_CODE = sub_exp_code
383 self.PLOT_POS = plot_pos
412 self.PLOT_POS = plot_pos
384
413
385 self.isConfig = True
414 self.isConfig = True
386
415
387 self.setWinTitle(title)
416 self.setWinTitle(title)
417
388
418
389 for i in range(self.nplots):
419 for i in range(self.nplots):
390 pair = dataOut.pairsList[pairsIndexList[i]]
420 pair = dataOut.pairsList[pairsIndexList[i]]
391
421
392 chan_index0 = dataOut.channelList.index(pair[0])
422 chan_index0 = dataOut.channelList.index(pair[0])
393 chan_index1 = dataOut.channelList.index(pair[1])
423 chan_index1 = dataOut.channelList.index(pair[1])
394
424
395 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
425 str_datetime = '%s %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S"))
396 title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[chan_index0], str_datetime)
426 title = "Ch%d: %4.2fdB: %s" %(pair[0], noisedB[chan_index0], str_datetime)
397 zdB = 10.*numpy.log10(dataOut.data_spc[chan_index0,:,:]/factor)
427 zdB = 10.*numpy.log10(dataOut.data_spc[chan_index0,:,:]/factor)
398 axes0 = self.axesList[i*self.__nsubplots]
428 axes0 = self.axesList[i*self.__nsubplots]
399 axes0.pcolor(x, y, zdB,
429 axes0.pcolor(x, y, zdB,
400 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
430 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
401 xlabel=xlabel, ylabel=ylabel, title=title,
431 xlabel=xlabel, ylabel=ylabel, title=title,
402 ticksize=9, colormap=power_cmap, cblabel='')
432 ticksize=9, colormap=power_cmap, cblabel='')
403
433
404 title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[chan_index1], str_datetime)
434 title = "Ch%d: %4.2fdB: %s" %(pair[1], noisedB[chan_index1], str_datetime)
405 zdB = 10.*numpy.log10(dataOut.data_spc[chan_index1,:,:]/factor)
435 zdB = 10.*numpy.log10(dataOut.data_spc[chan_index1,:,:]/factor)
406 axes0 = self.axesList[i*self.__nsubplots+1]
436 axes0 = self.axesList[i*self.__nsubplots+1]
407 axes0.pcolor(x, y, zdB,
437 axes0.pcolor(x, y, zdB,
408 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
438 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
409 xlabel=xlabel, ylabel=ylabel, title=title,
439 xlabel=xlabel, ylabel=ylabel, title=title,
410 ticksize=9, colormap=power_cmap, cblabel='')
440 ticksize=9, colormap=power_cmap, cblabel='')
411
441
412 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[chan_index0,:,:]*dataOut.data_spc[chan_index1,:,:])
442 coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[chan_index0,:,:]*dataOut.data_spc[chan_index1,:,:])
413 coherence = numpy.abs(coherenceComplex)
443 coherence = numpy.abs(coherenceComplex)
414 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
444 # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi
415 phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi
445 phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi
446
447
448 # print 'FASE', numpy.shape(phase), y[10]
449 # fig = plt.figure(10+self.indice)
450 # plt.plot( x[0:128],phase[:,10] )
451 # #plt.axis([-12, 12, 15, 50])
452 # plt.title("%s" %( '%s %s, Channel %s'%(thisDatetime.strftime("%Y/%m/%d"),thisDatetime.strftime("%H:%M:%S") , i)))
453 # plt.ylabel('Desfase [grados]')
454 # plt.xlabel('Velocidad [m/s]')
455 # fig.savefig('/home/erick/Documents/Pics/to{}.png'.format(self.indice))
456 #
457 # plt.show()
458 # self.indice=self.indice+1
416
459
417 title = "Coherence Ch%d * Ch%d" %(pair[0], pair[1])
460 title = "Coherence Ch%d * Ch%d" %(pair[0], pair[1])
418 axes0 = self.axesList[i*self.__nsubplots+2]
461 axes0 = self.axesList[i*self.__nsubplots+2]
419 axes0.pcolor(x, y, coherence,
462 axes0.pcolor(x, y, coherence,
420 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=coh_min, zmax=coh_max,
463 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=coh_min, zmax=coh_max,
421 xlabel=xlabel, ylabel=ylabel, title=title,
464 xlabel=xlabel, ylabel=ylabel, title=title,
422 ticksize=9, colormap=coherence_cmap, cblabel='')
465 ticksize=9, colormap=coherence_cmap, cblabel='')
423
466
424 title = "Phase Ch%d * Ch%d" %(pair[0], pair[1])
467 title = "Phase Ch%d * Ch%d" %(pair[0], pair[1])
425 axes0 = self.axesList[i*self.__nsubplots+3]
468 axes0 = self.axesList[i*self.__nsubplots+3]
426 axes0.pcolor(x, y, phase,
469 axes0.pcolor(x, y, phase,
427 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
470 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
428 xlabel=xlabel, ylabel=ylabel, title=title,
471 xlabel=xlabel, ylabel=ylabel, title=title,
429 ticksize=9, colormap=phase_cmap, cblabel='')
472 ticksize=9, colormap=phase_cmap, cblabel='')
430
473
431
474
432
475
433 self.draw()
476 self.draw()
434
477
435 self.save(figpath=figpath,
478 self.save(figpath=figpath,
436 figfile=figfile,
479 figfile=figfile,
437 save=save,
480 save=save,
438 ftp=ftp,
481 ftp=ftp,
439 wr_period=wr_period,
482 wr_period=wr_period,
440 thisDatetime=thisDatetime)
483 thisDatetime=thisDatetime)
441
484
442
485
443 class RTIPlot(Figure):
486 class RTIPlot(Figure):
444
487
445 __isConfig = None
488 __isConfig = None
446 __nsubplots = None
489 __nsubplots = None
447
490
448 WIDTHPROF = None
491 WIDTHPROF = None
449 HEIGHTPROF = None
492 HEIGHTPROF = None
450 PREFIX = 'rti'
493 PREFIX = 'rti'
451
494
452 def __init__(self, **kwargs):
495 def __init__(self, **kwargs):
453
496
454 Figure.__init__(self, **kwargs)
497 Figure.__init__(self, **kwargs)
455 self.timerange = None
498 self.timerange = None
456 self.isConfig = False
499 self.isConfig = False
457 self.__nsubplots = 1
500 self.__nsubplots = 1
458
501
459 self.WIDTH = 800
502 self.WIDTH = 800
460 self.HEIGHT = 180
503 self.HEIGHT = 180
461 self.WIDTHPROF = 120
504 self.WIDTHPROF = 120
462 self.HEIGHTPROF = 0
505 self.HEIGHTPROF = 0
463 self.counter_imagwr = 0
506 self.counter_imagwr = 0
464
507
465 self.PLOT_CODE = RTI_CODE
508 self.PLOT_CODE = RTI_CODE
466
509
467 self.FTP_WEI = None
510 self.FTP_WEI = None
468 self.EXP_CODE = None
511 self.EXP_CODE = None
469 self.SUB_EXP_CODE = None
512 self.SUB_EXP_CODE = None
470 self.PLOT_POS = None
513 self.PLOT_POS = None
471 self.tmin = None
514 self.tmin = None
472 self.tmax = None
515 self.tmax = None
473
516
474 self.xmin = None
517 self.xmin = None
475 self.xmax = None
518 self.xmax = None
476
519
477 self.figfile = None
520 self.figfile = None
478
521
479 def getSubplots(self):
522 def getSubplots(self):
480
523
481 ncol = 1
524 ncol = 1
482 nrow = self.nplots
525 nrow = self.nplots
483
526
484 return nrow, ncol
527 return nrow, ncol
485
528
486 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
529 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
487
530
488 self.__showprofile = showprofile
531 self.__showprofile = showprofile
489 self.nplots = nplots
532 self.nplots = nplots
490
533
491 ncolspan = 1
534 ncolspan = 1
492 colspan = 1
535 colspan = 1
493 if showprofile:
536 if showprofile:
494 ncolspan = 7
537 ncolspan = 7
495 colspan = 6
538 colspan = 6
496 self.__nsubplots = 2
539 self.__nsubplots = 2
497
540
498 self.createFigure(id = id,
541 self.createFigure(id = id,
499 wintitle = wintitle,
542 wintitle = wintitle,
500 widthplot = self.WIDTH + self.WIDTHPROF,
543 widthplot = self.WIDTH + self.WIDTHPROF,
501 heightplot = self.HEIGHT + self.HEIGHTPROF,
544 heightplot = self.HEIGHT + self.HEIGHTPROF,
502 show=show)
545 show=show)
503
546
504 nrow, ncol = self.getSubplots()
547 nrow, ncol = self.getSubplots()
505
548
506 counter = 0
549 counter = 0
507 for y in range(nrow):
550 for y in range(nrow):
508 for x in range(ncol):
551 for x in range(ncol):
509
552
510 if counter >= self.nplots:
553 if counter >= self.nplots:
511 break
554 break
512
555
513 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
556 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
514
557
515 if showprofile:
558 if showprofile:
516 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
559 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
517
560
518 counter += 1
561 counter += 1
519
562
520 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
563 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
521 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
564 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
522 timerange=None, colormap='jet',
565 timerange=None, colormap='jet',
523 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
566 save=False, figpath='./', lastone=0,figfile=None, ftp=False, wr_period=1, show=True,
524 server=None, folder=None, username=None, password=None,
567 server=None, folder=None, username=None, password=None,
525 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, normFactor=None, HEIGHT=None):
568 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0, normFactor=None, HEIGHT=None):
526
569
527 """
570 """
528
571
529 Input:
572 Input:
530 dataOut :
573 dataOut :
531 id :
574 id :
532 wintitle :
575 wintitle :
533 channelList :
576 channelList :
534 showProfile :
577 showProfile :
535 xmin : None,
578 xmin : None,
536 xmax : None,
579 xmax : None,
537 ymin : None,
580 ymin : None,
538 ymax : None,
581 ymax : None,
539 zmin : None,
582 zmin : None,
540 zmax : None
583 zmax : None
541 """
584 """
542
585
543 #colormap = kwargs.get('colormap', 'jet')
586 #colormap = kwargs.get('colormap', 'jet')
544 if HEIGHT is not None:
587 if HEIGHT is not None:
545 self.HEIGHT = HEIGHT
588 self.HEIGHT = HEIGHT
546
589
547 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
590 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
548 return
591 return
549
592
550 if channelList == None:
593 if channelList == None:
551 channelIndexList = dataOut.channelIndexList
594 channelIndexList = dataOut.channelIndexList
552 else:
595 else:
553 channelIndexList = []
596 channelIndexList = []
554 for channel in channelList:
597 for channel in channelList:
555 if channel not in dataOut.channelList:
598 if channel not in dataOut.channelList:
556 raise ValueError, "Channel %d is not in dataOut.channelList"
599 raise ValueError, "Channel %d is not in dataOut.channelList"
557 channelIndexList.append(dataOut.channelList.index(channel))
600 channelIndexList.append(dataOut.channelList.index(channel))
558
601
559 if normFactor is None:
602 if normFactor is None:
560 factor = dataOut.normFactor
603 factor = dataOut.normFactor
561 else:
604 else:
562 factor = normFactor
605 factor = normFactor
563
606
564 # factor = dataOut.normFactor
607 # factor = dataOut.normFactor
565 x = dataOut.getTimeRange()
608 x = dataOut.getTimeRange()
566 y = dataOut.getHeiRange()
609 y = dataOut.getHeiRange()
567
610
568 z = dataOut.data_spc/factor
611 z = dataOut.data_spc/factor
569 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
612 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
570 avg = numpy.average(z, axis=1)
613 avg = numpy.average(z, axis=1)
571 avgdB = 10.*numpy.log10(avg)
614 avgdB = 10.*numpy.log10(avg)
572 # avgdB = dataOut.getPower()
615 # avgdB = dataOut.getPower()
573
616
574
617
575 thisDatetime = dataOut.datatime
618 thisDatetime = dataOut.datatime
576 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
619 # thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
577 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
620 title = wintitle + " RTI" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
578 xlabel = ""
621 xlabel = ""
579 ylabel = "Range (Km)"
622 ylabel = "Range (Km)"
580
623
581 update_figfile = False
624 update_figfile = False
582
625
583 if dataOut.ltctime >= self.xmax:
626 if dataOut.ltctime >= self.xmax:
584 self.counter_imagwr = wr_period
627 self.counter_imagwr = wr_period
585 self.isConfig = False
628 self.isConfig = False
586 update_figfile = True
629 update_figfile = True
587
630
588 if not self.isConfig:
631 if not self.isConfig:
589
632
590 nplots = len(channelIndexList)
633 nplots = len(channelIndexList)
591
634
592 self.setup(id=id,
635 self.setup(id=id,
593 nplots=nplots,
636 nplots=nplots,
594 wintitle=wintitle,
637 wintitle=wintitle,
595 showprofile=showprofile,
638 showprofile=showprofile,
596 show=show)
639 show=show)
597
640
598 if timerange != None:
641 if timerange != None:
599 self.timerange = timerange
642 self.timerange = timerange
600
643
601 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
644 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
602
645
603 noise = dataOut.noise/factor
646 noise = dataOut.noise/factor
604 noisedB = 10*numpy.log10(noise)
647 noisedB = 10*numpy.log10(noise)
605
648
606 if ymin == None: ymin = numpy.nanmin(y)
649 if ymin == None: ymin = numpy.nanmin(y)
607 if ymax == None: ymax = numpy.nanmax(y)
650 if ymax == None: ymax = numpy.nanmax(y)
608 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
651 if zmin == None: zmin = numpy.floor(numpy.nanmin(noisedB)) - 3
609 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
652 if zmax == None: zmax = numpy.ceil(numpy.nanmax(avgdB)) + 3
610
653
611 self.FTP_WEI = ftp_wei
654 self.FTP_WEI = ftp_wei
612 self.EXP_CODE = exp_code
655 self.EXP_CODE = exp_code
613 self.SUB_EXP_CODE = sub_exp_code
656 self.SUB_EXP_CODE = sub_exp_code
614 self.PLOT_POS = plot_pos
657 self.PLOT_POS = plot_pos
615
658
616 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
659 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
617 self.isConfig = True
660 self.isConfig = True
618 self.figfile = figfile
661 self.figfile = figfile
619 update_figfile = True
662 update_figfile = True
620
663
621 self.setWinTitle(title)
664 self.setWinTitle(title)
622
665
623 for i in range(self.nplots):
666 for i in range(self.nplots):
624 index = channelIndexList[i]
667 index = channelIndexList[i]
625 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
668 title = "Channel %d: %s" %(dataOut.channelList[index], thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
626 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
669 if ((dataOut.azimuth!=None) and (dataOut.zenith!=None)):
627 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
670 title = title + '_' + 'azimuth,zenith=%2.2f,%2.2f'%(dataOut.azimuth, dataOut.zenith)
628 axes = self.axesList[i*self.__nsubplots]
671 axes = self.axesList[i*self.__nsubplots]
629 zdB = avgdB[index].reshape((1,-1))
672 zdB = avgdB[index].reshape((1,-1))
630 axes.pcolorbuffer(x, y, zdB,
673 axes.pcolorbuffer(x, y, zdB,
631 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
674 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
632 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
675 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
633 ticksize=9, cblabel='', cbsize="1%", colormap=colormap)
676 ticksize=9, cblabel='', cbsize="1%", colormap=colormap)
634
677
635 if self.__showprofile:
678 if self.__showprofile:
636 axes = self.axesList[i*self.__nsubplots +1]
679 axes = self.axesList[i*self.__nsubplots +1]
637 axes.pline(avgdB[index], y,
680 axes.pline(avgdB[index], y,
638 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
681 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
639 xlabel='dB', ylabel='', title='',
682 xlabel='dB', ylabel='', title='',
640 ytick_visible=False,
683 ytick_visible=False,
641 grid='x')
684 grid='x')
642
685
643 self.draw()
686 self.draw()
644
687
645 self.save(figpath=figpath,
688 self.save(figpath=figpath,
646 figfile=figfile,
689 figfile=figfile,
647 save=save,
690 save=save,
648 ftp=ftp,
691 ftp=ftp,
649 wr_period=wr_period,
692 wr_period=wr_period,
650 thisDatetime=thisDatetime,
693 thisDatetime=thisDatetime,
651 update_figfile=update_figfile)
694 update_figfile=update_figfile)
652
695
653 class CoherenceMap(Figure):
696 class CoherenceMap(Figure):
654 isConfig = None
697 isConfig = None
655 __nsubplots = None
698 __nsubplots = None
656
699
657 WIDTHPROF = None
700 WIDTHPROF = None
658 HEIGHTPROF = None
701 HEIGHTPROF = None
659 PREFIX = 'cmap'
702 PREFIX = 'cmap'
660
703
661 def __init__(self, **kwargs):
704 def __init__(self, **kwargs):
662 Figure.__init__(self, **kwargs)
705 Figure.__init__(self, **kwargs)
663 self.timerange = 2*60*60
706 self.timerange = 2*60*60
664 self.isConfig = False
707 self.isConfig = False
665 self.__nsubplots = 1
708 self.__nsubplots = 1
666
709
667 self.WIDTH = 800
710 self.WIDTH = 800
668 self.HEIGHT = 180
711 self.HEIGHT = 180
669 self.WIDTHPROF = 120
712 self.WIDTHPROF = 120
670 self.HEIGHTPROF = 0
713 self.HEIGHTPROF = 0
671 self.counter_imagwr = 0
714 self.counter_imagwr = 0
672
715
673 self.PLOT_CODE = COH_CODE
716 self.PLOT_CODE = COH_CODE
674
717
675 self.FTP_WEI = None
718 self.FTP_WEI = None
676 self.EXP_CODE = None
719 self.EXP_CODE = None
677 self.SUB_EXP_CODE = None
720 self.SUB_EXP_CODE = None
678 self.PLOT_POS = None
721 self.PLOT_POS = None
679 self.counter_imagwr = 0
722 self.counter_imagwr = 0
680
723
681 self.xmin = None
724 self.xmin = None
682 self.xmax = None
725 self.xmax = None
683
726
684 def getSubplots(self):
727 def getSubplots(self):
685 ncol = 1
728 ncol = 1
686 nrow = self.nplots*2
729 nrow = self.nplots*2
687
730
688 return nrow, ncol
731 return nrow, ncol
689
732
690 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
733 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
691 self.__showprofile = showprofile
734 self.__showprofile = showprofile
692 self.nplots = nplots
735 self.nplots = nplots
693
736
694 ncolspan = 1
737 ncolspan = 1
695 colspan = 1
738 colspan = 1
696 if showprofile:
739 if showprofile:
697 ncolspan = 7
740 ncolspan = 7
698 colspan = 6
741 colspan = 6
699 self.__nsubplots = 2
742 self.__nsubplots = 2
700
743
701 self.createFigure(id = id,
744 self.createFigure(id = id,
702 wintitle = wintitle,
745 wintitle = wintitle,
703 widthplot = self.WIDTH + self.WIDTHPROF,
746 widthplot = self.WIDTH + self.WIDTHPROF,
704 heightplot = self.HEIGHT + self.HEIGHTPROF,
747 heightplot = self.HEIGHT + self.HEIGHTPROF,
705 show=True)
748 show=True)
706
749
707 nrow, ncol = self.getSubplots()
750 nrow, ncol = self.getSubplots()
708
751
709 for y in range(nrow):
752 for y in range(nrow):
710 for x in range(ncol):
753 for x in range(ncol):
711
754
712 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
755 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
713
756
714 if showprofile:
757 if showprofile:
715 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
758 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1)
716
759
717 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
760 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
718 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
761 xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None,
719 timerange=None, phase_min=None, phase_max=None,
762 timerange=None, phase_min=None, phase_max=None,
720 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
763 save=False, figpath='./', figfile=None, ftp=False, wr_period=1,
721 coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
764 coherence_cmap='jet', phase_cmap='RdBu_r', show=True,
722 server=None, folder=None, username=None, password=None,
765 server=None, folder=None, username=None, password=None,
723 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
766 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
724
767
725 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
768 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
726 return
769 return
727
770
728 if pairsList == None:
771 if pairsList == None:
729 pairsIndexList = dataOut.pairsIndexList
772 pairsIndexList = dataOut.pairsIndexList
730 else:
773 else:
731 pairsIndexList = []
774 pairsIndexList = []
732 for pair in pairsList:
775 for pair in pairsList:
733 if pair not in dataOut.pairsList:
776 if pair not in dataOut.pairsList:
734 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
777 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
735 pairsIndexList.append(dataOut.pairsList.index(pair))
778 pairsIndexList.append(dataOut.pairsList.index(pair))
736
779
737 if pairsIndexList == []:
780 if pairsIndexList == []:
738 return
781 return
739
782
740 if len(pairsIndexList) > 4:
783 if len(pairsIndexList) > 4:
741 pairsIndexList = pairsIndexList[0:4]
784 pairsIndexList = pairsIndexList[0:4]
742
785
743 if phase_min == None:
786 if phase_min == None:
744 phase_min = -180
787 phase_min = -180
745 if phase_max == None:
788 if phase_max == None:
746 phase_max = 180
789 phase_max = 180
747
790
748 x = dataOut.getTimeRange()
791 x = dataOut.getTimeRange()
749 y = dataOut.getHeiRange()
792 y = dataOut.getHeiRange()
750
793
751 thisDatetime = dataOut.datatime
794 thisDatetime = dataOut.datatime
752
795
753 title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
796 title = wintitle + " CoherenceMap" #: %s" %(thisDatetime.strftime("%d-%b-%Y"))
754 xlabel = ""
797 xlabel = ""
755 ylabel = "Range (Km)"
798 ylabel = "Range (Km)"
756 update_figfile = False
799 update_figfile = False
757
800
758 if not self.isConfig:
801 if not self.isConfig:
759 nplots = len(pairsIndexList)
802 nplots = len(pairsIndexList)
760 self.setup(id=id,
803 self.setup(id=id,
761 nplots=nplots,
804 nplots=nplots,
762 wintitle=wintitle,
805 wintitle=wintitle,
763 showprofile=showprofile,
806 showprofile=showprofile,
764 show=show)
807 show=show)
765
808
766 if timerange != None:
809 if timerange != None:
767 self.timerange = timerange
810 self.timerange = timerange
768
811
769 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
812 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
770
813
771 if ymin == None: ymin = numpy.nanmin(y)
814 if ymin == None: ymin = numpy.nanmin(y)
772 if ymax == None: ymax = numpy.nanmax(y)
815 if ymax == None: ymax = numpy.nanmax(y)
773 if zmin == None: zmin = 0.
816 if zmin == None: zmin = 0.
774 if zmax == None: zmax = 1.
817 if zmax == None: zmax = 1.
775
818
776 self.FTP_WEI = ftp_wei
819 self.FTP_WEI = ftp_wei
777 self.EXP_CODE = exp_code
820 self.EXP_CODE = exp_code
778 self.SUB_EXP_CODE = sub_exp_code
821 self.SUB_EXP_CODE = sub_exp_code
779 self.PLOT_POS = plot_pos
822 self.PLOT_POS = plot_pos
780
823
781 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
824 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
782
825
783 self.isConfig = True
826 self.isConfig = True
784 update_figfile = True
827 update_figfile = True
785
828
786 self.setWinTitle(title)
829 self.setWinTitle(title)
787
830
788 for i in range(self.nplots):
831 for i in range(self.nplots):
789
832
790 pair = dataOut.pairsList[pairsIndexList[i]]
833 pair = dataOut.pairsList[pairsIndexList[i]]
791
834
792 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
835 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0)
793 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
836 powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0)
794 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
837 powb = numpy.average(dataOut.data_spc[pair[1],:,:],axis=0)
795
838
796
839
797 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
840 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
798 coherence = numpy.abs(avgcoherenceComplex)
841 coherence = numpy.abs(avgcoherenceComplex)
799
842
800 z = coherence.reshape((1,-1))
843 z = coherence.reshape((1,-1))
801
844
802 counter = 0
845 counter = 0
803
846
804 title = "Coherence Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
847 title = "Coherence Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
805 axes = self.axesList[i*self.__nsubplots*2]
848 axes = self.axesList[i*self.__nsubplots*2]
806 axes.pcolorbuffer(x, y, z,
849 axes.pcolorbuffer(x, y, z,
807 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
850 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax,
808 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
851 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
809 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
852 ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%")
810
853
811 if self.__showprofile:
854 if self.__showprofile:
812 counter += 1
855 counter += 1
813 axes = self.axesList[i*self.__nsubplots*2 + counter]
856 axes = self.axesList[i*self.__nsubplots*2 + counter]
814 axes.pline(coherence, y,
857 axes.pline(coherence, y,
815 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
858 xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax,
816 xlabel='', ylabel='', title='', ticksize=7,
859 xlabel='', ylabel='', title='', ticksize=7,
817 ytick_visible=False, nxticks=5,
860 ytick_visible=False, nxticks=5,
818 grid='x')
861 grid='x')
819
862
820 counter += 1
863 counter += 1
821
864
822 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
865 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
823
866
824 z = phase.reshape((1,-1))
867 z = phase.reshape((1,-1))
825
868
826 title = "Phase Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
869 title = "Phase Ch%d * Ch%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
827 axes = self.axesList[i*self.__nsubplots*2 + counter]
870 axes = self.axesList[i*self.__nsubplots*2 + counter]
828 axes.pcolorbuffer(x, y, z,
871 axes.pcolorbuffer(x, y, z,
829 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
872 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax, zmin=phase_min, zmax=phase_max,
830 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
873 xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True,
831 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
874 ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%")
832
875
833 if self.__showprofile:
876 if self.__showprofile:
834 counter += 1
877 counter += 1
835 axes = self.axesList[i*self.__nsubplots*2 + counter]
878 axes = self.axesList[i*self.__nsubplots*2 + counter]
836 axes.pline(phase, y,
879 axes.pline(phase, y,
837 xmin=phase_min, xmax=phase_max, ymin=ymin, ymax=ymax,
880 xmin=phase_min, xmax=phase_max, ymin=ymin, ymax=ymax,
838 xlabel='', ylabel='', title='', ticksize=7,
881 xlabel='', ylabel='', title='', ticksize=7,
839 ytick_visible=False, nxticks=4,
882 ytick_visible=False, nxticks=4,
840 grid='x')
883 grid='x')
841
884
842 self.draw()
885 self.draw()
843
886
844 if dataOut.ltctime >= self.xmax:
887 if dataOut.ltctime >= self.xmax:
845 self.counter_imagwr = wr_period
888 self.counter_imagwr = wr_period
846 self.isConfig = False
889 self.isConfig = False
847 update_figfile = True
890 update_figfile = True
848
891
849 self.save(figpath=figpath,
892 self.save(figpath=figpath,
850 figfile=figfile,
893 figfile=figfile,
851 save=save,
894 save=save,
852 ftp=ftp,
895 ftp=ftp,
853 wr_period=wr_period,
896 wr_period=wr_period,
854 thisDatetime=thisDatetime,
897 thisDatetime=thisDatetime,
855 update_figfile=update_figfile)
898 update_figfile=update_figfile)
856
899
857 class PowerProfilePlot(Figure):
900 class PowerProfilePlot(Figure):
858
901
859 isConfig = None
902 isConfig = None
860 __nsubplots = None
903 __nsubplots = None
861
904
862 WIDTHPROF = None
905 WIDTHPROF = None
863 HEIGHTPROF = None
906 HEIGHTPROF = None
864 PREFIX = 'spcprofile'
907 PREFIX = 'spcprofile'
865
908
866 def __init__(self, **kwargs):
909 def __init__(self, **kwargs):
867 Figure.__init__(self, **kwargs)
910 Figure.__init__(self, **kwargs)
868 self.isConfig = False
911 self.isConfig = False
869 self.__nsubplots = 1
912 self.__nsubplots = 1
870
913
871 self.PLOT_CODE = POWER_CODE
914 self.PLOT_CODE = POWER_CODE
872
915
873 self.WIDTH = 300
916 self.WIDTH = 300
874 self.HEIGHT = 500
917 self.HEIGHT = 500
875 self.counter_imagwr = 0
918 self.counter_imagwr = 0
876
919
877 def getSubplots(self):
920 def getSubplots(self):
878 ncol = 1
921 ncol = 1
879 nrow = 1
922 nrow = 1
880
923
881 return nrow, ncol
924 return nrow, ncol
882
925
883 def setup(self, id, nplots, wintitle, show):
926 def setup(self, id, nplots, wintitle, show):
884
927
885 self.nplots = nplots
928 self.nplots = nplots
886
929
887 ncolspan = 1
930 ncolspan = 1
888 colspan = 1
931 colspan = 1
889
932
890 self.createFigure(id = id,
933 self.createFigure(id = id,
891 wintitle = wintitle,
934 wintitle = wintitle,
892 widthplot = self.WIDTH,
935 widthplot = self.WIDTH,
893 heightplot = self.HEIGHT,
936 heightplot = self.HEIGHT,
894 show=show)
937 show=show)
895
938
896 nrow, ncol = self.getSubplots()
939 nrow, ncol = self.getSubplots()
897
940
898 counter = 0
941 counter = 0
899 for y in range(nrow):
942 for y in range(nrow):
900 for x in range(ncol):
943 for x in range(ncol):
901 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
944 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
902
945
903 def run(self, dataOut, id, wintitle="", channelList=None,
946 def run(self, dataOut, id, wintitle="", channelList=None,
904 xmin=None, xmax=None, ymin=None, ymax=None,
947 xmin=None, xmax=None, ymin=None, ymax=None,
905 save=False, figpath='./', figfile=None, show=True,
948 save=False, figpath='./', figfile=None, show=True,
906 ftp=False, wr_period=1, server=None,
949 ftp=False, wr_period=1, server=None,
907 folder=None, username=None, password=None):
950 folder=None, username=None, password=None):
908
951
909
952
910 if channelList == None:
953 if channelList == None:
911 channelIndexList = dataOut.channelIndexList
954 channelIndexList = dataOut.channelIndexList
912 channelList = dataOut.channelList
955 channelList = dataOut.channelList
913 else:
956 else:
914 channelIndexList = []
957 channelIndexList = []
915 for channel in channelList:
958 for channel in channelList:
916 if channel not in dataOut.channelList:
959 if channel not in dataOut.channelList:
917 raise ValueError, "Channel %d is not in dataOut.channelList"
960 raise ValueError, "Channel %d is not in dataOut.channelList"
918 channelIndexList.append(dataOut.channelList.index(channel))
961 channelIndexList.append(dataOut.channelList.index(channel))
919
962
920 factor = dataOut.normFactor
963 factor = dataOut.normFactor
921
964
922 y = dataOut.getHeiRange()
965 y = dataOut.getHeiRange()
923
966
924 #for voltage
967 #for voltage
925 if dataOut.type == 'Voltage':
968 if dataOut.type == 'Voltage':
926 x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
969 x = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:])
927 x = x.real
970 x = x.real
928 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
971 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
929
972
930 #for spectra
973 #for spectra
931 if dataOut.type == 'Spectra':
974 if dataOut.type == 'Spectra':
932 x = dataOut.data_spc[channelIndexList,:,:]/factor
975 x = dataOut.data_spc[channelIndexList,:,:]/factor
933 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
976 x = numpy.where(numpy.isfinite(x), x, numpy.NAN)
934 x = numpy.average(x, axis=1)
977 x = numpy.average(x, axis=1)
935
978
936
979
937 xdB = 10*numpy.log10(x)
980 xdB = 10*numpy.log10(x)
938
981
939 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
982 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
940 title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y"))
983 title = wintitle + " Power Profile %s" %(thisDatetime.strftime("%d-%b-%Y"))
941 xlabel = "dB"
984 xlabel = "dB"
942 ylabel = "Range (Km)"
985 ylabel = "Range (Km)"
943
986
944 if not self.isConfig:
987 if not self.isConfig:
945
988
946 nplots = 1
989 nplots = 1
947
990
948 self.setup(id=id,
991 self.setup(id=id,
949 nplots=nplots,
992 nplots=nplots,
950 wintitle=wintitle,
993 wintitle=wintitle,
951 show=show)
994 show=show)
952
995
953 if ymin == None: ymin = numpy.nanmin(y)
996 if ymin == None: ymin = numpy.nanmin(y)
954 if ymax == None: ymax = numpy.nanmax(y)
997 if ymax == None: ymax = numpy.nanmax(y)
955 if xmin == None: xmin = numpy.nanmin(xdB)*0.9
998 if xmin == None: xmin = numpy.nanmin(xdB)*0.9
956 if xmax == None: xmax = numpy.nanmax(xdB)*1.1
999 if xmax == None: xmax = numpy.nanmax(xdB)*1.1
957
1000
958 self.isConfig = True
1001 self.isConfig = True
959
1002
960 self.setWinTitle(title)
1003 self.setWinTitle(title)
961
1004
962 title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1005 title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
963 axes = self.axesList[0]
1006 axes = self.axesList[0]
964
1007
965 legendlabels = ["channel %d"%x for x in channelList]
1008 legendlabels = ["channel %d"%x for x in channelList]
966 axes.pmultiline(xdB, y,
1009 axes.pmultiline(xdB, y,
967 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1010 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
968 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
1011 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
969 ytick_visible=True, nxticks=5,
1012 ytick_visible=True, nxticks=5,
970 grid='x')
1013 grid='x')
971
1014
972 self.draw()
1015 self.draw()
973
1016
974 self.save(figpath=figpath,
1017 self.save(figpath=figpath,
975 figfile=figfile,
1018 figfile=figfile,
976 save=save,
1019 save=save,
977 ftp=ftp,
1020 ftp=ftp,
978 wr_period=wr_period,
1021 wr_period=wr_period,
979 thisDatetime=thisDatetime)
1022 thisDatetime=thisDatetime)
980
1023
981 class SpectraCutPlot(Figure):
1024 class SpectraCutPlot(Figure):
982
1025
983 isConfig = None
1026 isConfig = None
984 __nsubplots = None
1027 __nsubplots = None
985
1028
986 WIDTHPROF = None
1029 WIDTHPROF = None
987 HEIGHTPROF = None
1030 HEIGHTPROF = None
988 PREFIX = 'spc_cut'
1031 PREFIX = 'spc_cut'
989
1032
990 def __init__(self, **kwargs):
1033 def __init__(self, **kwargs):
991 Figure.__init__(self, **kwargs)
1034 Figure.__init__(self, **kwargs)
992 self.isConfig = False
1035 self.isConfig = False
993 self.__nsubplots = 1
1036 self.__nsubplots = 1
994
1037
995 self.PLOT_CODE = POWER_CODE
1038 self.PLOT_CODE = POWER_CODE
996
1039
997 self.WIDTH = 700
1040 self.WIDTH = 700
998 self.HEIGHT = 500
1041 self.HEIGHT = 500
999 self.counter_imagwr = 0
1042 self.counter_imagwr = 0
1000
1043
1001 def getSubplots(self):
1044 def getSubplots(self):
1002 ncol = 1
1045 ncol = 1
1003 nrow = 1
1046 nrow = 1
1004
1047
1005 return nrow, ncol
1048 return nrow, ncol
1006
1049
1007 def setup(self, id, nplots, wintitle, show):
1050 def setup(self, id, nplots, wintitle, show):
1008
1051
1009 self.nplots = nplots
1052 self.nplots = nplots
1010
1053
1011 ncolspan = 1
1054 ncolspan = 1
1012 colspan = 1
1055 colspan = 1
1013
1056
1014 self.createFigure(id = id,
1057 self.createFigure(id = id,
1015 wintitle = wintitle,
1058 wintitle = wintitle,
1016 widthplot = self.WIDTH,
1059 widthplot = self.WIDTH,
1017 heightplot = self.HEIGHT,
1060 heightplot = self.HEIGHT,
1018 show=show)
1061 show=show)
1019
1062
1020 nrow, ncol = self.getSubplots()
1063 nrow, ncol = self.getSubplots()
1021
1064
1022 counter = 0
1065 counter = 0
1023 for y in range(nrow):
1066 for y in range(nrow):
1024 for x in range(ncol):
1067 for x in range(ncol):
1025 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1068 self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1)
1026
1069
1027 def run(self, dataOut, id, wintitle="", channelList=None,
1070 def run(self, dataOut, id, wintitle="", channelList=None,
1028 xmin=None, xmax=None, ymin=None, ymax=None,
1071 xmin=None, xmax=None, ymin=None, ymax=None,
1029 save=False, figpath='./', figfile=None, show=True,
1072 save=False, figpath='./', figfile=None, show=True,
1030 ftp=False, wr_period=1, server=None,
1073 ftp=False, wr_period=1, server=None,
1031 folder=None, username=None, password=None,
1074 folder=None, username=None, password=None,
1032 xaxis="frequency"):
1075 xaxis="frequency"):
1033
1076
1034
1077
1035 if channelList == None:
1078 if channelList == None:
1036 channelIndexList = dataOut.channelIndexList
1079 channelIndexList = dataOut.channelIndexList
1037 channelList = dataOut.channelList
1080 channelList = dataOut.channelList
1038 else:
1081 else:
1039 channelIndexList = []
1082 channelIndexList = []
1040 for channel in channelList:
1083 for channel in channelList:
1041 if channel not in dataOut.channelList:
1084 if channel not in dataOut.channelList:
1042 raise ValueError, "Channel %d is not in dataOut.channelList"
1085 raise ValueError, "Channel %d is not in dataOut.channelList"
1043 channelIndexList.append(dataOut.channelList.index(channel))
1086 channelIndexList.append(dataOut.channelList.index(channel))
1044
1087
1045 factor = dataOut.normFactor
1088 factor = dataOut.normFactor
1046
1089
1047 y = dataOut.getHeiRange()
1090 y = dataOut.getHeiRange()
1048
1091
1049 z = dataOut.data_spc/factor
1092 z = dataOut.data_spc/factor
1050 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1093 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
1051
1094
1052 hei_index = numpy.arange(25)*3 + 20
1095 hei_index = numpy.arange(25)*3 + 20
1053
1096
1054 if xaxis == "frequency":
1097 if xaxis == "frequency":
1055 x = dataOut.getFreqRange()/1000.
1098 x = dataOut.getFreqRange()/1000.
1056 zdB = 10*numpy.log10(z[0,:,hei_index])
1099 zdB = 10*numpy.log10(z[0,:,hei_index])
1057 xlabel = "Frequency (kHz)"
1100 xlabel = "Frequency (kHz)"
1058 ylabel = "Power (dB)"
1101 ylabel = "Power (dB)"
1059
1102
1060 elif xaxis == "time":
1103 elif xaxis == "time":
1061 x = dataOut.getAcfRange()
1104 x = dataOut.getAcfRange()
1062 zdB = z[0,:,hei_index]
1105 zdB = z[0,:,hei_index]
1063 xlabel = "Time (ms)"
1106 xlabel = "Time (ms)"
1064 ylabel = "ACF"
1107 ylabel = "ACF"
1065
1108
1066 else:
1109 else:
1067 x = dataOut.getVelRange()
1110 x = dataOut.getVelRange()
1068 zdB = 10*numpy.log10(z[0,:,hei_index])
1111 zdB = 10*numpy.log10(z[0,:,hei_index])
1069 xlabel = "Velocity (m/s)"
1112 xlabel = "Velocity (m/s)"
1070 ylabel = "Power (dB)"
1113 ylabel = "Power (dB)"
1071
1114
1072 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1115 thisDatetime = datetime.datetime.utcfromtimestamp(dataOut.getTimeRange()[0])
1073 title = wintitle + " Range Cuts %s" %(thisDatetime.strftime("%d-%b-%Y"))
1116 title = wintitle + " Range Cuts %s" %(thisDatetime.strftime("%d-%b-%Y"))
1074
1117
1075 if not self.isConfig:
1118 if not self.isConfig:
1076
1119
1077 nplots = 1
1120 nplots = 1
1078
1121
1079 self.setup(id=id,
1122 self.setup(id=id,
1080 nplots=nplots,
1123 nplots=nplots,
1081 wintitle=wintitle,
1124 wintitle=wintitle,
1082 show=show)
1125 show=show)
1083
1126
1084 if xmin == None: xmin = numpy.nanmin(x)*0.9
1127 if xmin == None: xmin = numpy.nanmin(x)*0.9
1085 if xmax == None: xmax = numpy.nanmax(x)*1.1
1128 if xmax == None: xmax = numpy.nanmax(x)*1.1
1086 if ymin == None: ymin = numpy.nanmin(zdB)
1129 if ymin == None: ymin = numpy.nanmin(zdB)
1087 if ymax == None: ymax = numpy.nanmax(zdB)
1130 if ymax == None: ymax = numpy.nanmax(zdB)
1088
1131
1089 self.isConfig = True
1132 self.isConfig = True
1090
1133
1091 self.setWinTitle(title)
1134 self.setWinTitle(title)
1092
1135
1093 title = "Spectra Cuts: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1136 title = "Spectra Cuts: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S"))
1094 axes = self.axesList[0]
1137 axes = self.axesList[0]
1095
1138
1096 legendlabels = ["Range = %dKm" %y[i] for i in hei_index]
1139 legendlabels = ["Range = %dKm" %y[i] for i in hei_index]
1097
1140
1098 axes.pmultilineyaxis( x, zdB,
1141 axes.pmultilineyaxis( x, zdB,
1099 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1142 xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax,
1100 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
1143 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels,
1101 ytick_visible=True, nxticks=5,
1144 ytick_visible=True, nxticks=5,
1102 grid='x')
1145 grid='x')
1103
1146
1104 self.draw()
1147 self.draw()
1105
1148
1106 self.save(figpath=figpath,
1149 self.save(figpath=figpath,
1107 figfile=figfile,
1150 figfile=figfile,
1108 save=save,
1151 save=save,
1109 ftp=ftp,
1152 ftp=ftp,
1110 wr_period=wr_period,
1153 wr_period=wr_period,
1111 thisDatetime=thisDatetime)
1154 thisDatetime=thisDatetime)
1112
1155
1113 class Noise(Figure):
1156 class Noise(Figure):
1114
1157
1115 isConfig = None
1158 isConfig = None
1116 __nsubplots = None
1159 __nsubplots = None
1117
1160
1118 PREFIX = 'noise'
1161 PREFIX = 'noise'
1119
1162
1120
1163
1121 def __init__(self, **kwargs):
1164 def __init__(self, **kwargs):
1122 Figure.__init__(self, **kwargs)
1165 Figure.__init__(self, **kwargs)
1123 self.timerange = 24*60*60
1166 self.timerange = 24*60*60
1124 self.isConfig = False
1167 self.isConfig = False
1125 self.__nsubplots = 1
1168 self.__nsubplots = 1
1126 self.counter_imagwr = 0
1169 self.counter_imagwr = 0
1127 self.WIDTH = 800
1170 self.WIDTH = 800
1128 self.HEIGHT = 400
1171 self.HEIGHT = 400
1129 self.WIDTHPROF = 120
1172 self.WIDTHPROF = 120
1130 self.HEIGHTPROF = 0
1173 self.HEIGHTPROF = 0
1131 self.xdata = None
1174 self.xdata = None
1132 self.ydata = None
1175 self.ydata = None
1133
1176
1134 self.PLOT_CODE = NOISE_CODE
1177 self.PLOT_CODE = NOISE_CODE
1135
1178
1136 self.FTP_WEI = None
1179 self.FTP_WEI = None
1137 self.EXP_CODE = None
1180 self.EXP_CODE = None
1138 self.SUB_EXP_CODE = None
1181 self.SUB_EXP_CODE = None
1139 self.PLOT_POS = None
1182 self.PLOT_POS = None
1140 self.figfile = None
1183 self.figfile = None
1141
1184
1142 self.xmin = None
1185 self.xmin = None
1143 self.xmax = None
1186 self.xmax = None
1144
1187
1145 def getSubplots(self):
1188 def getSubplots(self):
1146
1189
1147 ncol = 1
1190 ncol = 1
1148 nrow = 1
1191 nrow = 1
1149
1192
1150 return nrow, ncol
1193 return nrow, ncol
1151
1194
1152 def openfile(self, filename):
1195 def openfile(self, filename):
1153 dirname = os.path.dirname(filename)
1196 dirname = os.path.dirname(filename)
1154
1197
1155 if not os.path.exists(dirname):
1198 if not os.path.exists(dirname):
1156 os.mkdir(dirname)
1199 os.mkdir(dirname)
1157
1200
1158 f = open(filename,'w+')
1201 f = open(filename,'w+')
1159 f.write('\n\n')
1202 f.write('\n\n')
1160 f.write('JICAMARCA RADIO OBSERVATORY - Noise \n')
1203 f.write('JICAMARCA RADIO OBSERVATORY - Noise \n')
1161 f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' )
1204 f.write('DD MM YYYY HH MM SS Channel0 Channel1 Channel2 Channel3\n\n' )
1162 f.close()
1205 f.close()
1163
1206
1164 def save_data(self, filename_phase, data, data_datetime):
1207 def save_data(self, filename_phase, data, data_datetime):
1165
1208
1166 f=open(filename_phase,'a')
1209 f=open(filename_phase,'a')
1167
1210
1168 timetuple_data = data_datetime.timetuple()
1211 timetuple_data = data_datetime.timetuple()
1169 day = str(timetuple_data.tm_mday)
1212 day = str(timetuple_data.tm_mday)
1170 month = str(timetuple_data.tm_mon)
1213 month = str(timetuple_data.tm_mon)
1171 year = str(timetuple_data.tm_year)
1214 year = str(timetuple_data.tm_year)
1172 hour = str(timetuple_data.tm_hour)
1215 hour = str(timetuple_data.tm_hour)
1173 minute = str(timetuple_data.tm_min)
1216 minute = str(timetuple_data.tm_min)
1174 second = str(timetuple_data.tm_sec)
1217 second = str(timetuple_data.tm_sec)
1175
1218
1176 data_msg = ''
1219 data_msg = ''
1177 for i in range(len(data)):
1220 for i in range(len(data)):
1178 data_msg += str(data[i]) + ' '
1221 data_msg += str(data[i]) + ' '
1179
1222
1180 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' ' + data_msg + '\n')
1223 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' ' + data_msg + '\n')
1181 f.close()
1224 f.close()
1182
1225
1183
1226
1184 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1227 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1185
1228
1186 self.__showprofile = showprofile
1229 self.__showprofile = showprofile
1187 self.nplots = nplots
1230 self.nplots = nplots
1188
1231
1189 ncolspan = 7
1232 ncolspan = 7
1190 colspan = 6
1233 colspan = 6
1191 self.__nsubplots = 2
1234 self.__nsubplots = 2
1192
1235
1193 self.createFigure(id = id,
1236 self.createFigure(id = id,
1194 wintitle = wintitle,
1237 wintitle = wintitle,
1195 widthplot = self.WIDTH+self.WIDTHPROF,
1238 widthplot = self.WIDTH+self.WIDTHPROF,
1196 heightplot = self.HEIGHT+self.HEIGHTPROF,
1239 heightplot = self.HEIGHT+self.HEIGHTPROF,
1197 show=show)
1240 show=show)
1198
1241
1199 nrow, ncol = self.getSubplots()
1242 nrow, ncol = self.getSubplots()
1200
1243
1201 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1244 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1202
1245
1203
1246
1204 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1247 def run(self, dataOut, id, wintitle="", channelList=None, showprofile='True',
1205 xmin=None, xmax=None, ymin=None, ymax=None,
1248 xmin=None, xmax=None, ymin=None, ymax=None,
1206 timerange=None,
1249 timerange=None,
1207 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1250 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1208 server=None, folder=None, username=None, password=None,
1251 server=None, folder=None, username=None, password=None,
1209 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1252 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1210
1253
1211 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1254 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1212 return
1255 return
1213
1256
1214 if channelList == None:
1257 if channelList == None:
1215 channelIndexList = dataOut.channelIndexList
1258 channelIndexList = dataOut.channelIndexList
1216 channelList = dataOut.channelList
1259 channelList = dataOut.channelList
1217 else:
1260 else:
1218 channelIndexList = []
1261 channelIndexList = []
1219 for channel in channelList:
1262 for channel in channelList:
1220 if channel not in dataOut.channelList:
1263 if channel not in dataOut.channelList:
1221 raise ValueError, "Channel %d is not in dataOut.channelList"
1264 raise ValueError, "Channel %d is not in dataOut.channelList"
1222 channelIndexList.append(dataOut.channelList.index(channel))
1265 channelIndexList.append(dataOut.channelList.index(channel))
1223
1266
1224 x = dataOut.getTimeRange()
1267 x = dataOut.getTimeRange()
1225 #y = dataOut.getHeiRange()
1268 #y = dataOut.getHeiRange()
1226 factor = dataOut.normFactor
1269 factor = dataOut.normFactor
1227 noise = dataOut.noise[channelIndexList]/factor
1270 noise = dataOut.noise[channelIndexList]/factor
1228 noisedB = 10*numpy.log10(noise)
1271 noisedB = 10*numpy.log10(noise)
1229
1272
1230 thisDatetime = dataOut.datatime
1273 thisDatetime = dataOut.datatime
1231
1274
1232 title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1275 title = wintitle + " Noise" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1233 xlabel = ""
1276 xlabel = ""
1234 ylabel = "Intensity (dB)"
1277 ylabel = "Intensity (dB)"
1235 update_figfile = False
1278 update_figfile = False
1236
1279
1237 if not self.isConfig:
1280 if not self.isConfig:
1238
1281
1239 nplots = 1
1282 nplots = 1
1240
1283
1241 self.setup(id=id,
1284 self.setup(id=id,
1242 nplots=nplots,
1285 nplots=nplots,
1243 wintitle=wintitle,
1286 wintitle=wintitle,
1244 showprofile=showprofile,
1287 showprofile=showprofile,
1245 show=show)
1288 show=show)
1246
1289
1247 if timerange != None:
1290 if timerange != None:
1248 self.timerange = timerange
1291 self.timerange = timerange
1249
1292
1250 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1293 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1251
1294
1252 if ymin == None: ymin = numpy.floor(numpy.nanmin(noisedB)) - 10.0
1295 if ymin == None: ymin = numpy.floor(numpy.nanmin(noisedB)) - 10.0
1253 if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0
1296 if ymax == None: ymax = numpy.nanmax(noisedB) + 10.0
1254
1297
1255 self.FTP_WEI = ftp_wei
1298 self.FTP_WEI = ftp_wei
1256 self.EXP_CODE = exp_code
1299 self.EXP_CODE = exp_code
1257 self.SUB_EXP_CODE = sub_exp_code
1300 self.SUB_EXP_CODE = sub_exp_code
1258 self.PLOT_POS = plot_pos
1301 self.PLOT_POS = plot_pos
1259
1302
1260
1303
1261 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1304 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1262 self.isConfig = True
1305 self.isConfig = True
1263 self.figfile = figfile
1306 self.figfile = figfile
1264 self.xdata = numpy.array([])
1307 self.xdata = numpy.array([])
1265 self.ydata = numpy.array([])
1308 self.ydata = numpy.array([])
1266
1309
1267 update_figfile = True
1310 update_figfile = True
1268
1311
1269 #open file beacon phase
1312 #open file beacon phase
1270 path = '%s%03d' %(self.PREFIX, self.id)
1313 path = '%s%03d' %(self.PREFIX, self.id)
1271 noise_file = os.path.join(path,'%s.txt'%self.name)
1314 noise_file = os.path.join(path,'%s.txt'%self.name)
1272 self.filename_noise = os.path.join(figpath,noise_file)
1315 self.filename_noise = os.path.join(figpath,noise_file)
1273
1316
1274 self.setWinTitle(title)
1317 self.setWinTitle(title)
1275
1318
1276 title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1319 title = "Noise %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1277
1320
1278 legendlabels = ["channel %d"%(idchannel) for idchannel in channelList]
1321 legendlabels = ["channel %d"%(idchannel) for idchannel in channelList]
1279 axes = self.axesList[0]
1322 axes = self.axesList[0]
1280
1323
1281 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1324 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1282
1325
1283 if len(self.ydata)==0:
1326 if len(self.ydata)==0:
1284 self.ydata = noisedB.reshape(-1,1)
1327 self.ydata = noisedB.reshape(-1,1)
1285 else:
1328 else:
1286 self.ydata = numpy.hstack((self.ydata, noisedB.reshape(-1,1)))
1329 self.ydata = numpy.hstack((self.ydata, noisedB.reshape(-1,1)))
1287
1330
1288
1331
1289 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1332 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1290 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1333 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1291 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1334 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1292 XAxisAsTime=True, grid='both'
1335 XAxisAsTime=True, grid='both'
1293 )
1336 )
1294
1337
1295 self.draw()
1338 self.draw()
1296
1339
1297 if dataOut.ltctime >= self.xmax:
1340 if dataOut.ltctime >= self.xmax:
1298 self.counter_imagwr = wr_period
1341 self.counter_imagwr = wr_period
1299 self.isConfig = False
1342 self.isConfig = False
1300 update_figfile = True
1343 update_figfile = True
1301
1344
1302 self.save(figpath=figpath,
1345 self.save(figpath=figpath,
1303 figfile=figfile,
1346 figfile=figfile,
1304 save=save,
1347 save=save,
1305 ftp=ftp,
1348 ftp=ftp,
1306 wr_period=wr_period,
1349 wr_period=wr_period,
1307 thisDatetime=thisDatetime,
1350 thisDatetime=thisDatetime,
1308 update_figfile=update_figfile)
1351 update_figfile=update_figfile)
1309
1352
1310 #store data beacon phase
1353 #store data beacon phase
1311 if save:
1354 if save:
1312 self.save_data(self.filename_noise, noisedB, thisDatetime)
1355 self.save_data(self.filename_noise, noisedB, thisDatetime)
1313
1356
1314 class BeaconPhase(Figure):
1357 class BeaconPhase(Figure):
1315
1358
1316 __isConfig = None
1359 __isConfig = None
1317 __nsubplots = None
1360 __nsubplots = None
1318
1361
1319 PREFIX = 'beacon_phase'
1362 PREFIX = 'beacon_phase'
1320
1363
1321 def __init__(self, **kwargs):
1364 def __init__(self, **kwargs):
1322 Figure.__init__(self, **kwargs)
1365 Figure.__init__(self, **kwargs)
1323 self.timerange = 24*60*60
1366 self.timerange = 24*60*60
1324 self.isConfig = False
1367 self.isConfig = False
1325 self.__nsubplots = 1
1368 self.__nsubplots = 1
1326 self.counter_imagwr = 0
1369 self.counter_imagwr = 0
1327 self.WIDTH = 800
1370 self.WIDTH = 800
1328 self.HEIGHT = 400
1371 self.HEIGHT = 400
1329 self.WIDTHPROF = 120
1372 self.WIDTHPROF = 120
1330 self.HEIGHTPROF = 0
1373 self.HEIGHTPROF = 0
1331 self.xdata = None
1374 self.xdata = None
1332 self.ydata = None
1375 self.ydata = None
1333
1376
1334 self.PLOT_CODE = BEACON_CODE
1377 self.PLOT_CODE = BEACON_CODE
1335
1378
1336 self.FTP_WEI = None
1379 self.FTP_WEI = None
1337 self.EXP_CODE = None
1380 self.EXP_CODE = None
1338 self.SUB_EXP_CODE = None
1381 self.SUB_EXP_CODE = None
1339 self.PLOT_POS = None
1382 self.PLOT_POS = None
1340
1383
1341 self.filename_phase = None
1384 self.filename_phase = None
1342
1385
1343 self.figfile = None
1386 self.figfile = None
1344
1387
1345 self.xmin = None
1388 self.xmin = None
1346 self.xmax = None
1389 self.xmax = None
1347
1390
1348 def getSubplots(self):
1391 def getSubplots(self):
1349
1392
1350 ncol = 1
1393 ncol = 1
1351 nrow = 1
1394 nrow = 1
1352
1395
1353 return nrow, ncol
1396 return nrow, ncol
1354
1397
1355 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1398 def setup(self, id, nplots, wintitle, showprofile=True, show=True):
1356
1399
1357 self.__showprofile = showprofile
1400 self.__showprofile = showprofile
1358 self.nplots = nplots
1401 self.nplots = nplots
1359
1402
1360 ncolspan = 7
1403 ncolspan = 7
1361 colspan = 6
1404 colspan = 6
1362 self.__nsubplots = 2
1405 self.__nsubplots = 2
1363
1406
1364 self.createFigure(id = id,
1407 self.createFigure(id = id,
1365 wintitle = wintitle,
1408 wintitle = wintitle,
1366 widthplot = self.WIDTH+self.WIDTHPROF,
1409 widthplot = self.WIDTH+self.WIDTHPROF,
1367 heightplot = self.HEIGHT+self.HEIGHTPROF,
1410 heightplot = self.HEIGHT+self.HEIGHTPROF,
1368 show=show)
1411 show=show)
1369
1412
1370 nrow, ncol = self.getSubplots()
1413 nrow, ncol = self.getSubplots()
1371
1414
1372 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1415 self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1)
1373
1416
1374 def save_phase(self, filename_phase):
1417 def save_phase(self, filename_phase):
1375 f = open(filename_phase,'w+')
1418 f = open(filename_phase,'w+')
1376 f.write('\n\n')
1419 f.write('\n\n')
1377 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
1420 f.write('JICAMARCA RADIO OBSERVATORY - Beacon Phase \n')
1378 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' )
1421 f.write('DD MM YYYY HH MM SS pair(2,0) pair(2,1) pair(2,3) pair(2,4)\n\n' )
1379 f.close()
1422 f.close()
1380
1423
1381 def save_data(self, filename_phase, data, data_datetime):
1424 def save_data(self, filename_phase, data, data_datetime):
1382 f=open(filename_phase,'a')
1425 f=open(filename_phase,'a')
1383 timetuple_data = data_datetime.timetuple()
1426 timetuple_data = data_datetime.timetuple()
1384 day = str(timetuple_data.tm_mday)
1427 day = str(timetuple_data.tm_mday)
1385 month = str(timetuple_data.tm_mon)
1428 month = str(timetuple_data.tm_mon)
1386 year = str(timetuple_data.tm_year)
1429 year = str(timetuple_data.tm_year)
1387 hour = str(timetuple_data.tm_hour)
1430 hour = str(timetuple_data.tm_hour)
1388 minute = str(timetuple_data.tm_min)
1431 minute = str(timetuple_data.tm_min)
1389 second = str(timetuple_data.tm_sec)
1432 second = str(timetuple_data.tm_sec)
1390 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
1433 f.write(day+' '+month+' '+year+' '+hour+' '+minute+' '+second+' '+str(data[0])+' '+str(data[1])+' '+str(data[2])+' '+str(data[3])+'\n')
1391 f.close()
1434 f.close()
1392
1435
1393
1436
1394 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1437 def run(self, dataOut, id, wintitle="", pairsList=None, showprofile='True',
1395 xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None,
1438 xmin=None, xmax=None, ymin=None, ymax=None, hmin=None, hmax=None,
1396 timerange=None,
1439 timerange=None,
1397 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1440 save=False, figpath='./', figfile=None, show=True, ftp=False, wr_period=1,
1398 server=None, folder=None, username=None, password=None,
1441 server=None, folder=None, username=None, password=None,
1399 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1442 ftp_wei=0, exp_code=0, sub_exp_code=0, plot_pos=0):
1400
1443
1401 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1444 if not isTimeInHourRange(dataOut.datatime, xmin, xmax):
1402 return
1445 return
1403
1446
1404 if pairsList == None:
1447 if pairsList == None:
1405 pairsIndexList = dataOut.pairsIndexList[:10]
1448 pairsIndexList = dataOut.pairsIndexList[:10]
1406 else:
1449 else:
1407 pairsIndexList = []
1450 pairsIndexList = []
1408 for pair in pairsList:
1451 for pair in pairsList:
1409 if pair not in dataOut.pairsList:
1452 if pair not in dataOut.pairsList:
1410 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1453 raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair)
1411 pairsIndexList.append(dataOut.pairsList.index(pair))
1454 pairsIndexList.append(dataOut.pairsList.index(pair))
1412
1455
1413 if pairsIndexList == []:
1456 if pairsIndexList == []:
1414 return
1457 return
1415
1458
1416 # if len(pairsIndexList) > 4:
1459 # if len(pairsIndexList) > 4:
1417 # pairsIndexList = pairsIndexList[0:4]
1460 # pairsIndexList = pairsIndexList[0:4]
1418
1461
1419 hmin_index = None
1462 hmin_index = None
1420 hmax_index = None
1463 hmax_index = None
1421
1464
1422 if hmin != None and hmax != None:
1465 if hmin != None and hmax != None:
1423 indexes = numpy.arange(dataOut.nHeights)
1466 indexes = numpy.arange(dataOut.nHeights)
1424 hmin_list = indexes[dataOut.heightList >= hmin]
1467 hmin_list = indexes[dataOut.heightList >= hmin]
1425 hmax_list = indexes[dataOut.heightList <= hmax]
1468 hmax_list = indexes[dataOut.heightList <= hmax]
1426
1469
1427 if hmin_list.any():
1470 if hmin_list.any():
1428 hmin_index = hmin_list[0]
1471 hmin_index = hmin_list[0]
1429
1472
1430 if hmax_list.any():
1473 if hmax_list.any():
1431 hmax_index = hmax_list[-1]+1
1474 hmax_index = hmax_list[-1]+1
1432
1475
1433 x = dataOut.getTimeRange()
1476 x = dataOut.getTimeRange()
1434 #y = dataOut.getHeiRange()
1477 #y = dataOut.getHeiRange()
1435
1478
1436
1479
1437 thisDatetime = dataOut.datatime
1480 thisDatetime = dataOut.datatime
1438
1481
1439 title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1482 title = wintitle + " Signal Phase" # : %s" %(thisDatetime.strftime("%d-%b-%Y"))
1440 xlabel = "Local Time"
1483 xlabel = "Local Time"
1441 ylabel = "Phase (degrees)"
1484 ylabel = "Phase (degrees)"
1442
1485
1443 update_figfile = False
1486 update_figfile = False
1444
1487
1445 nplots = len(pairsIndexList)
1488 nplots = len(pairsIndexList)
1446 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1489 #phase = numpy.zeros((len(pairsIndexList),len(dataOut.beacon_heiIndexList)))
1447 phase_beacon = numpy.zeros(len(pairsIndexList))
1490 phase_beacon = numpy.zeros(len(pairsIndexList))
1448 for i in range(nplots):
1491 for i in range(nplots):
1449 pair = dataOut.pairsList[pairsIndexList[i]]
1492 pair = dataOut.pairsList[pairsIndexList[i]]
1450 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0)
1493 ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i], :, hmin_index:hmax_index], axis=0)
1451 powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0)
1494 powa = numpy.average(dataOut.data_spc[pair[0], :, hmin_index:hmax_index], axis=0)
1452 powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0)
1495 powb = numpy.average(dataOut.data_spc[pair[1], :, hmin_index:hmax_index], axis=0)
1453 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1496 avgcoherenceComplex = ccf/numpy.sqrt(powa*powb)
1454 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1497 phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi
1455
1498
1456 #print "Phase %d%d" %(pair[0], pair[1])
1499 #print "Phase %d%d" %(pair[0], pair[1])
1457 #print phase[dataOut.beacon_heiIndexList]
1500 #print phase[dataOut.beacon_heiIndexList]
1458
1501
1459 if dataOut.beacon_heiIndexList:
1502 if dataOut.beacon_heiIndexList:
1460 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1503 phase_beacon[i] = numpy.average(phase[dataOut.beacon_heiIndexList])
1461 else:
1504 else:
1462 phase_beacon[i] = numpy.average(phase)
1505 phase_beacon[i] = numpy.average(phase)
1463
1506
1464 if not self.isConfig:
1507 if not self.isConfig:
1465
1508
1466 nplots = len(pairsIndexList)
1509 nplots = len(pairsIndexList)
1467
1510
1468 self.setup(id=id,
1511 self.setup(id=id,
1469 nplots=nplots,
1512 nplots=nplots,
1470 wintitle=wintitle,
1513 wintitle=wintitle,
1471 showprofile=showprofile,
1514 showprofile=showprofile,
1472 show=show)
1515 show=show)
1473
1516
1474 if timerange != None:
1517 if timerange != None:
1475 self.timerange = timerange
1518 self.timerange = timerange
1476
1519
1477 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1520 self.xmin, self.xmax = self.getTimeLim(x, xmin, xmax, timerange)
1478
1521
1479 if ymin == None: ymin = 0
1522 if ymin == None: ymin = 0
1480 if ymax == None: ymax = 360
1523 if ymax == None: ymax = 360
1481
1524
1482 self.FTP_WEI = ftp_wei
1525 self.FTP_WEI = ftp_wei
1483 self.EXP_CODE = exp_code
1526 self.EXP_CODE = exp_code
1484 self.SUB_EXP_CODE = sub_exp_code
1527 self.SUB_EXP_CODE = sub_exp_code
1485 self.PLOT_POS = plot_pos
1528 self.PLOT_POS = plot_pos
1486
1529
1487 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1530 self.name = thisDatetime.strftime("%Y%m%d_%H%M%S")
1488 self.isConfig = True
1531 self.isConfig = True
1489 self.figfile = figfile
1532 self.figfile = figfile
1490 self.xdata = numpy.array([])
1533 self.xdata = numpy.array([])
1491 self.ydata = numpy.array([])
1534 self.ydata = numpy.array([])
1492
1535
1493 update_figfile = True
1536 update_figfile = True
1494
1537
1495 #open file beacon phase
1538 #open file beacon phase
1496 path = '%s%03d' %(self.PREFIX, self.id)
1539 path = '%s%03d' %(self.PREFIX, self.id)
1497 beacon_file = os.path.join(path,'%s.txt'%self.name)
1540 beacon_file = os.path.join(path,'%s.txt'%self.name)
1498 self.filename_phase = os.path.join(figpath,beacon_file)
1541 self.filename_phase = os.path.join(figpath,beacon_file)
1499 #self.save_phase(self.filename_phase)
1542 #self.save_phase(self.filename_phase)
1500
1543
1501
1544
1502 #store data beacon phase
1545 #store data beacon phase
1503 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1546 #self.save_data(self.filename_phase, phase_beacon, thisDatetime)
1504
1547
1505 self.setWinTitle(title)
1548 self.setWinTitle(title)
1506
1549
1507
1550
1508 title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1551 title = "Phase Plot %s" %(thisDatetime.strftime("%Y/%m/%d %H:%M:%S"))
1509
1552
1510 legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1553 legendlabels = ["Pair (%d,%d)"%(pair[0], pair[1]) for pair in dataOut.pairsList]
1511
1554
1512 axes = self.axesList[0]
1555 axes = self.axesList[0]
1513
1556
1514 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1557 self.xdata = numpy.hstack((self.xdata, x[0:1]))
1515
1558
1516 if len(self.ydata)==0:
1559 if len(self.ydata)==0:
1517 self.ydata = phase_beacon.reshape(-1,1)
1560 self.ydata = phase_beacon.reshape(-1,1)
1518 else:
1561 else:
1519 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1562 self.ydata = numpy.hstack((self.ydata, phase_beacon.reshape(-1,1)))
1520
1563
1521
1564
1522 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1565 axes.pmultilineyaxis(x=self.xdata, y=self.ydata,
1523 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1566 xmin=self.xmin, xmax=self.xmax, ymin=ymin, ymax=ymax,
1524 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1567 xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid",
1525 XAxisAsTime=True, grid='both'
1568 XAxisAsTime=True, grid='both'
1526 )
1569 )
1527
1570
1528 self.draw()
1571 self.draw()
1529
1572
1530 if dataOut.ltctime >= self.xmax:
1573 if dataOut.ltctime >= self.xmax:
1531 self.counter_imagwr = wr_period
1574 self.counter_imagwr = wr_period
1532 self.isConfig = False
1575 self.isConfig = False
1533 update_figfile = True
1576 update_figfile = True
1534
1577
1535 self.save(figpath=figpath,
1578 self.save(figpath=figpath,
1536 figfile=figfile,
1579 figfile=figfile,
1537 save=save,
1580 save=save,
1538 ftp=ftp,
1581 ftp=ftp,
1539 wr_period=wr_period,
1582 wr_period=wr_period,
1540 thisDatetime=thisDatetime,
1583 thisDatetime=thisDatetime,
1541 update_figfile=update_figfile)
1584 update_figfile=update_figfile)
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,1193 +1,1194
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 duplicity.path import Path
16 from duplicity.path import Path
17 from numpy.ma.core import getdata
17 from numpy.ma.core import getdata
18
18
19 SPEED_OF_LIGHT = 299792458
19 SPEED_OF_LIGHT = 299792458
20 SPEED_OF_LIGHT = 3e8
20 SPEED_OF_LIGHT = 3e8
21
21
22 try:
22 try:
23 from gevent import sleep
23 from gevent import sleep
24 except:
24 except:
25 from time import sleep
25 from time import sleep
26
26
27 from schainpy.model.data.jrodata import Spectra
27 from schainpy.model.data.jrodata import Spectra
28 #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
28 #from schainpy.model.data.BLTRheaderIO import FileHeader, RecordHeader
29 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
29 from schainpy.model.proc.jroproc_base import ProcessingUnit, Operation
30 #from schainpy.model.io.jroIO_bltr import BLTRReader
30 #from schainpy.model.io.jroIO_bltr import BLTRReader
31 from numpy import imag, shape, NaN
31 from numpy import imag, shape, NaN
32
32
33 from jroIO_base import JRODataReader
33 from jroIO_base import JRODataReader
34
34
35
35
36 class Header(object):
36 class Header(object):
37
37
38 def __init__(self):
38 def __init__(self):
39 raise NotImplementedError
39 raise NotImplementedError
40
40
41
41
42 def read(self):
42 def read(self):
43
43
44 raise NotImplementedError
44 raise NotImplementedError
45
45
46 def write(self):
46 def write(self):
47
47
48 raise NotImplementedError
48 raise NotImplementedError
49
49
50 def printInfo(self):
50 def printInfo(self):
51
51
52 message = "#"*50 + "\n"
52 message = "#"*50 + "\n"
53 message += self.__class__.__name__.upper() + "\n"
53 message += self.__class__.__name__.upper() + "\n"
54 message += "#"*50 + "\n"
54 message += "#"*50 + "\n"
55
55
56 keyList = self.__dict__.keys()
56 keyList = self.__dict__.keys()
57 keyList.sort()
57 keyList.sort()
58
58
59 for key in keyList:
59 for key in keyList:
60 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
60 message += "%s = %s" %(key, self.__dict__[key]) + "\n"
61
61
62 if "size" not in keyList:
62 if "size" not in keyList:
63 attr = getattr(self, "size")
63 attr = getattr(self, "size")
64
64
65 if attr:
65 if attr:
66 message += "%s = %s" %("size", attr) + "\n"
66 message += "%s = %s" %("size", attr) + "\n"
67
67
68 #print message
68 #print message
69
69
70
70
71
71
72
72
73
73
74 FILE_STRUCTURE = numpy.dtype([ #HEADER 48bytes
74 FILE_STRUCTURE = numpy.dtype([ #HEADER 48bytes
75 ('FileMgcNumber','<u4'), #0x23020100
75 ('FileMgcNumber','<u4'), #0x23020100
76 ('nFDTdataRecors','<u4'), #No Of FDT data records in this file (0 or more)
76 ('nFDTdataRecors','<u4'), #No Of FDT data records in this file (0 or more)
77 ('OffsetStartHeader','<u4'),
77 ('OffsetStartHeader','<u4'),
78 ('RadarUnitId','<u4'),
78 ('RadarUnitId','<u4'),
79 ('SiteName',numpy.str_,32), #Null terminated
79 ('SiteName',numpy.str_,32), #Null terminated
80 ])
80 ])
81
81
82 class FileHeaderBLTR(Header):
82 class FileHeaderBLTR(Header):
83
83
84 def __init__(self):
84 def __init__(self):
85
85
86 self.FileMgcNumber= 0 #0x23020100
86 self.FileMgcNumber= 0 #0x23020100
87 self.nFDTdataRecors=0 #No Of FDT data records in this file (0 or more)
87 self.nFDTdataRecors=0 #No Of FDT data records in this file (0 or more)
88 self.RadarUnitId= 0
88 self.RadarUnitId= 0
89 self.OffsetStartHeader=0
89 self.OffsetStartHeader=0
90 self.SiteName= ""
90 self.SiteName= ""
91 self.size = 48
91 self.size = 48
92
92
93 def FHread(self, fp):
93 def FHread(self, fp):
94 #try:
94 #try:
95 startFp = open(fp,"rb")
95 startFp = open(fp,"rb")
96
96
97 header = numpy.fromfile(startFp, FILE_STRUCTURE,1)
97 header = numpy.fromfile(startFp, FILE_STRUCTURE,1)
98
98
99 print ' '
99 print ' '
100 print 'puntero file header', startFp.tell()
100 print 'puntero file header', startFp.tell()
101 print ' '
101 print ' '
102
102
103
103
104 ''' numpy.fromfile(file, dtype, count, sep='')
104 ''' numpy.fromfile(file, dtype, count, sep='')
105 file : file or str
105 file : file or str
106 Open file object or filename.
106 Open file object or filename.
107
107
108 dtype : data-type
108 dtype : data-type
109 Data type of the returned array. For binary files, it is used to determine
109 Data type of the returned array. For binary files, it is used to determine
110 the size and byte-order of the items in the file.
110 the size and byte-order of the items in the file.
111
111
112 count : int
112 count : int
113 Number of items to read. -1 means all items (i.e., the complete file).
113 Number of items to read. -1 means all items (i.e., the complete file).
114
114
115 sep : str
115 sep : str
116 Separator between items if file is a text file. Empty ("") separator means
116 Separator between items if file is a text file. Empty ("") separator means
117 the file should be treated as binary. Spaces (" ") in the separator match zero
117 the file should be treated as binary. Spaces (" ") in the separator match zero
118 or more whitespace characters. A separator consisting only of spaces must match
118 or more whitespace characters. A separator consisting only of spaces must match
119 at least one whitespace.
119 at least one whitespace.
120
120
121 '''
121 '''
122
122
123
123
124
124
125 self.FileMgcNumber= hex(header['FileMgcNumber'][0])
125 self.FileMgcNumber= hex(header['FileMgcNumber'][0])
126 self.nFDTdataRecors=int(header['nFDTdataRecors'][0]) #No Of FDT data records in this file (0 or more)
126 self.nFDTdataRecors=int(header['nFDTdataRecors'][0]) #No Of FDT data records in this file (0 or more)
127 self.RadarUnitId= int(header['RadarUnitId'][0])
127 self.RadarUnitId= int(header['RadarUnitId'][0])
128 self.OffsetStartHeader= int(header['OffsetStartHeader'][0])
128 self.OffsetStartHeader= int(header['OffsetStartHeader'][0])
129 self.SiteName= str(header['SiteName'][0])
129 self.SiteName= str(header['SiteName'][0])
130
130
131 #print 'Numero de bloques', self.nFDTdataRecors
131 #print 'Numero de bloques', self.nFDTdataRecors
132
132
133
133
134 if self.size <48:
134 if self.size <48:
135 return 0
135 return 0
136
136
137 return 1
137 return 1
138
138
139
139
140 def write(self, fp):
140 def write(self, fp):
141
141
142 headerTuple = (self.FileMgcNumber,
142 headerTuple = (self.FileMgcNumber,
143 self.nFDTdataRecors,
143 self.nFDTdataRecors,
144 self.RadarUnitId,
144 self.RadarUnitId,
145 self.SiteName,
145 self.SiteName,
146 self.size)
146 self.size)
147
147
148
148
149 header = numpy.array(headerTuple, FILE_STRUCTURE)
149 header = numpy.array(headerTuple, FILE_STRUCTURE)
150 # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)
150 # numpy.array(object, dtype=None, copy=True, order=None, subok=False, ndmin=0)
151 header.tofile(fp)
151 header.tofile(fp)
152 ''' ndarray.tofile(fid, sep, format) Write array to a file as text or binary (default).
152 ''' ndarray.tofile(fid, sep, format) Write array to a file as text or binary (default).
153
153
154 fid : file or str
154 fid : file or str
155 An open file object, or a string containing a filename.
155 An open file object, or a string containing a filename.
156
156
157 sep : str
157 sep : str
158 Separator between array items for text output. If "" (empty), a binary file is written,
158 Separator between array items for text output. If "" (empty), a binary file is written,
159 equivalent to file.write(a.tobytes()).
159 equivalent to file.write(a.tobytes()).
160
160
161 format : str
161 format : str
162 Format string for text file output. Each entry in the array is formatted to text by
162 Format string for text file output. Each entry in the array is formatted to text by
163 first converting it to the closest Python type, and then using "format" % item.
163 first converting it to the closest Python type, and then using "format" % item.
164
164
165 '''
165 '''
166
166
167 return 1
167 return 1
168
168
169
169
170
170
171
171
172
172
173 RECORD_STRUCTURE = numpy.dtype([ #RECORD HEADER 180+20N bytes
173 RECORD_STRUCTURE = numpy.dtype([ #RECORD HEADER 180+20N bytes
174 ('RecMgcNumber','<u4'), #0x23030001
174 ('RecMgcNumber','<u4'), #0x23030001
175 ('RecCounter','<u4'), #Record counter(0,1, ...)
175 ('RecCounter','<u4'), #Record counter(0,1, ...)
176 ('Off2StartNxtRec','<u4'), #Offset to start of next record form start of this record
176 ('Off2StartNxtRec','<u4'), #Offset to start of next record form start of this record
177 ('Off2StartData','<u4'), #Offset to start of data from start of this record
177 ('Off2StartData','<u4'), #Offset to start of data from start of this record
178 ('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds)
178 ('nUtime','<i4'), #Epoch time stamp of start of acquisition (seconds)
179 ('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999)
179 ('nMilisec','<u4'), #Millisecond component of time stamp (0,...,999)
180 ('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated)
180 ('ExpTagName',numpy.str_,32), #Experiment tag name (null terminated)
181 ('ExpComment',numpy.str_,32), #Experiment comment (null terminated)
181 ('ExpComment',numpy.str_,32), #Experiment comment (null terminated)
182 ('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North)
182 ('SiteLatDegrees','<f4'), #Site latitude (from GPS) in degrees (positive implies North)
183 ('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East)
183 ('SiteLongDegrees','<f4'), #Site longitude (from GPS) in degrees (positive implies East)
184 ('RTCgpsStatus','<u4'), #RTC GPS engine status (0=SEEK, 1=LOCK, 2=NOT FITTED, 3=UNAVAILABLE)
184 ('RTCgpsStatus','<u4'), #RTC GPS engine status (0=SEEK, 1=LOCK, 2=NOT FITTED, 3=UNAVAILABLE)
185 ('TransmitFrec','<u4'), #Transmit frequency (Hz)
185 ('TransmitFrec','<u4'), #Transmit frequency (Hz)
186 ('ReceiveFrec','<u4'), #Receive frequency
186 ('ReceiveFrec','<u4'), #Receive frequency
187 ('FirstOsciFrec','<u4'), #First local oscillator frequency (Hz)
187 ('FirstOsciFrec','<u4'), #First local oscillator frequency (Hz)
188 ('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2")
188 ('Polarisation','<u4'), #(0="O", 1="E", 2="linear 1", 3="linear2")
189 ('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3)
189 ('ReceiverFiltSett','<u4'), #Receiver filter settings (0,1,2,3)
190 ('nModesInUse','<u4'), #Number of modes in use (1 or 2)
190 ('nModesInUse','<u4'), #Number of modes in use (1 or 2)
191 ('DualModeIndex','<u4'), #Dual Mode index number for these data (0 or 1)
191 ('DualModeIndex','<u4'), #Dual Mode index number for these data (0 or 1)
192 ('DualModeRange','<u4'), #Dual Mode range correction for these data (m)
192 ('DualModeRange','<u4'), #Dual Mode range correction for these data (m)
193 ('nDigChannels','<u4'), #Number of digital channels acquired (2*N)
193 ('nDigChannels','<u4'), #Number of digital channels acquired (2*N)
194 ('SampResolution','<u4'), #Sampling resolution (meters)
194 ('SampResolution','<u4'), #Sampling resolution (meters)
195 ('nHeights','<u4'), #Number of range gates sampled
195 ('nHeights','<u4'), #Number of range gates sampled
196 ('StartRangeSamp','<u4'), #Start range of sampling (meters)
196 ('StartRangeSamp','<u4'), #Start range of sampling (meters)
197 ('PRFhz','<u4'), #PRF (Hz)
197 ('PRFhz','<u4'), #PRF (Hz)
198 ('nCohInt','<u4'), #Integrations
198 ('nCohInt','<u4'), #Integrations
199 ('nProfiles','<u4'), #Number of data points transformed
199 ('nProfiles','<u4'), #Number of data points transformed
200 ('nChannels','<u4'), #Number of receive beams stored in file (1 or N)
200 ('nChannels','<u4'), #Number of receive beams stored in file (1 or N)
201 ('nIncohInt','<u4'), #Number of spectral averages
201 ('nIncohInt','<u4'), #Number of spectral averages
202 ('FFTwindowingInd','<u4'), #FFT windowing index (0 = no window)
202 ('FFTwindowingInd','<u4'), #FFT windowing index (0 = no window)
203 ('BeamAngleAzim','<f4'), #Beam steer angle (azimuth) in degrees (clockwise from true North)
203 ('BeamAngleAzim','<f4'), #Beam steer angle (azimuth) in degrees (clockwise from true North)
204 ('BeamAngleZen','<f4'), #Beam steer angle (zenith) in degrees (0=> vertical)
204 ('BeamAngleZen','<f4'), #Beam steer angle (zenith) in degrees (0=> vertical)
205 ('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
205 ('AntennaCoord0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
206 ('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
206 ('AntennaAngl0','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
207 ('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
207 ('AntennaCoord1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
208 ('AntennaAngl1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
208 ('AntennaAngl1','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
209 ('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
209 ('AntennaCoord2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
210 ('AntennaAngl2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
210 ('AntennaAngl2','<f4'), #Antenna coordinates (Range(meters), Bearing(degrees)) - N pairs
211 ('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values
211 ('RecPhaseCalibr0','<f4'), #Receiver phase calibration (degrees) - N values
212 ('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values
212 ('RecPhaseCalibr1','<f4'), #Receiver phase calibration (degrees) - N values
213 ('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values
213 ('RecPhaseCalibr2','<f4'), #Receiver phase calibration (degrees) - N values
214 ('RecAmpCalibr0','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
214 ('RecAmpCalibr0','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
215 ('RecAmpCalibr1','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
215 ('RecAmpCalibr1','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
216 ('RecAmpCalibr2','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
216 ('RecAmpCalibr2','<f4'), #Receiver amplitude calibration (ratio relative to receiver one) - N values
217 ('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values
217 ('ReceiverGaindB0','<i4'), #Receiver gains in dB - N values
218 ('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values
218 ('ReceiverGaindB1','<i4'), #Receiver gains in dB - N values
219 ('ReceiverGaindB2','<i4'), #Receiver gains in dB - N values
219 ('ReceiverGaindB2','<i4'), #Receiver gains in dB - N values
220 ])
220 ])
221
221
222
222
223 class RecordHeaderBLTR(Header):
223 class RecordHeaderBLTR(Header):
224
224
225 def __init__(self, RecMgcNumber=None, RecCounter= 0, Off2StartNxtRec= 811248,
225 def __init__(self, RecMgcNumber=None, RecCounter= 0, Off2StartNxtRec= 811248,
226 nUtime= 0, nMilisec= 0, ExpTagName= None,
226 nUtime= 0, nMilisec= 0, ExpTagName= None,
227 ExpComment=None, SiteLatDegrees=0, SiteLongDegrees= 0,
227 ExpComment=None, SiteLatDegrees=0, SiteLongDegrees= 0,
228 RTCgpsStatus= 0, TransmitFrec= 0, ReceiveFrec= 0,
228 RTCgpsStatus= 0, TransmitFrec= 0, ReceiveFrec= 0,
229 FirstOsciFrec= 0, Polarisation= 0, ReceiverFiltSett= 0,
229 FirstOsciFrec= 0, Polarisation= 0, ReceiverFiltSett= 0,
230 nModesInUse= 0, DualModeIndex= 0, DualModeRange= 0,
230 nModesInUse= 0, DualModeIndex= 0, DualModeRange= 0,
231 nDigChannels= 0, SampResolution= 0, nHeights= 0,
231 nDigChannels= 0, SampResolution= 0, nHeights= 0,
232 StartRangeSamp= 0, PRFhz= 0, nCohInt= 0,
232 StartRangeSamp= 0, PRFhz= 0, nCohInt= 0,
233 nProfiles= 0, nChannels= 0, nIncohInt= 0,
233 nProfiles= 0, nChannels= 0, nIncohInt= 0,
234 FFTwindowingInd= 0, BeamAngleAzim= 0, BeamAngleZen= 0,
234 FFTwindowingInd= 0, BeamAngleAzim= 0, BeamAngleZen= 0,
235 AntennaCoord0= 0, AntennaCoord1= 0, AntennaCoord2= 0,
235 AntennaCoord0= 0, AntennaCoord1= 0, AntennaCoord2= 0,
236 RecPhaseCalibr0= 0, RecPhaseCalibr1= 0, RecPhaseCalibr2= 0,
236 RecPhaseCalibr0= 0, RecPhaseCalibr1= 0, RecPhaseCalibr2= 0,
237 RecAmpCalibr0= 0, RecAmpCalibr1= 0, RecAmpCalibr2= 0,
237 RecAmpCalibr0= 0, RecAmpCalibr1= 0, RecAmpCalibr2= 0,
238 AntennaAngl0=0, AntennaAngl1=0, AntennaAngl2=0,
238 AntennaAngl0=0, AntennaAngl1=0, AntennaAngl2=0,
239 ReceiverGaindB0= 0, ReceiverGaindB1= 0, ReceiverGaindB2= 0, Off2StartData=0, OffsetStartHeader=0):
239 ReceiverGaindB0= 0, ReceiverGaindB1= 0, ReceiverGaindB2= 0, Off2StartData=0, OffsetStartHeader=0):
240
240
241 self.RecMgcNumber = RecMgcNumber #0x23030001
241 self.RecMgcNumber = RecMgcNumber #0x23030001
242 self.RecCounter = RecCounter
242 self.RecCounter = RecCounter
243 self.Off2StartNxtRec = Off2StartNxtRec
243 self.Off2StartNxtRec = Off2StartNxtRec
244 self.Off2StartData = Off2StartData
244 self.Off2StartData = Off2StartData
245 self.nUtime = nUtime
245 self.nUtime = nUtime
246 self.nMilisec = nMilisec
246 self.nMilisec = nMilisec
247 self.ExpTagName = ExpTagName
247 self.ExpTagName = ExpTagName
248 self.ExpComment = ExpComment
248 self.ExpComment = ExpComment
249 self.SiteLatDegrees = SiteLatDegrees
249 self.SiteLatDegrees = SiteLatDegrees
250 self.SiteLongDegrees = SiteLongDegrees
250 self.SiteLongDegrees = SiteLongDegrees
251 self.RTCgpsStatus = RTCgpsStatus
251 self.RTCgpsStatus = RTCgpsStatus
252 self.TransmitFrec = TransmitFrec
252 self.TransmitFrec = TransmitFrec
253 self.ReceiveFrec = ReceiveFrec
253 self.ReceiveFrec = ReceiveFrec
254 self.FirstOsciFrec = FirstOsciFrec
254 self.FirstOsciFrec = FirstOsciFrec
255 self.Polarisation = Polarisation
255 self.Polarisation = Polarisation
256 self.ReceiverFiltSett = ReceiverFiltSett
256 self.ReceiverFiltSett = ReceiverFiltSett
257 self.nModesInUse = nModesInUse
257 self.nModesInUse = nModesInUse
258 self.DualModeIndex = DualModeIndex
258 self.DualModeIndex = DualModeIndex
259 self.DualModeRange = DualModeRange
259 self.DualModeRange = DualModeRange
260 self.nDigChannels = nDigChannels
260 self.nDigChannels = nDigChannels
261 self.SampResolution = SampResolution
261 self.SampResolution = SampResolution
262 self.nHeights = nHeights
262 self.nHeights = nHeights
263 self.StartRangeSamp = StartRangeSamp
263 self.StartRangeSamp = StartRangeSamp
264 self.PRFhz = PRFhz
264 self.PRFhz = PRFhz
265 self.nCohInt = nCohInt
265 self.nCohInt = nCohInt
266 self.nProfiles = nProfiles
266 self.nProfiles = nProfiles
267 self.nChannels = nChannels
267 self.nChannels = nChannels
268 self.nIncohInt = nIncohInt
268 self.nIncohInt = nIncohInt
269 self.FFTwindowingInd = FFTwindowingInd
269 self.FFTwindowingInd = FFTwindowingInd
270 self.BeamAngleAzim = BeamAngleAzim
270 self.BeamAngleAzim = BeamAngleAzim
271 self.BeamAngleZen = BeamAngleZen
271 self.BeamAngleZen = BeamAngleZen
272 self.AntennaCoord0 = AntennaCoord0
272 self.AntennaCoord0 = AntennaCoord0
273 self.AntennaAngl0 = AntennaAngl0
273 self.AntennaAngl0 = AntennaAngl0
274 self.AntennaAngl1 = AntennaAngl1
274 self.AntennaAngl1 = AntennaAngl1
275 self.AntennaAngl2 = AntennaAngl2
275 self.AntennaAngl2 = AntennaAngl2
276 self.AntennaCoord1 = AntennaCoord1
276 self.AntennaCoord1 = AntennaCoord1
277 self.AntennaCoord2 = AntennaCoord2
277 self.AntennaCoord2 = AntennaCoord2
278 self.RecPhaseCalibr0 = RecPhaseCalibr0
278 self.RecPhaseCalibr0 = RecPhaseCalibr0
279 self.RecPhaseCalibr1 = RecPhaseCalibr1
279 self.RecPhaseCalibr1 = RecPhaseCalibr1
280 self.RecPhaseCalibr2 = RecPhaseCalibr2
280 self.RecPhaseCalibr2 = RecPhaseCalibr2
281 self.RecAmpCalibr0 = RecAmpCalibr0
281 self.RecAmpCalibr0 = RecAmpCalibr0
282 self.RecAmpCalibr1 = RecAmpCalibr1
282 self.RecAmpCalibr1 = RecAmpCalibr1
283 self.RecAmpCalibr2 = RecAmpCalibr2
283 self.RecAmpCalibr2 = RecAmpCalibr2
284 self.ReceiverGaindB0 = ReceiverGaindB0
284 self.ReceiverGaindB0 = ReceiverGaindB0
285 self.ReceiverGaindB1 = ReceiverGaindB1
285 self.ReceiverGaindB1 = ReceiverGaindB1
286 self.ReceiverGaindB2 = ReceiverGaindB2
286 self.ReceiverGaindB2 = ReceiverGaindB2
287 self.OffsetStartHeader = 48
287 self.OffsetStartHeader = 48
288
288
289
289
290
290
291 def RHread(self, fp):
291 def RHread(self, fp):
292 #print fp
292 #print fp
293 #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('/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.
294 startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file.
294 startFp = open(fp,"rb") #The method tell() returns the current position of the file read/write pointer within the file.
295 #RecCounter=0
295 #RecCounter=0
296 #Off2StartNxtRec=811248
296 #Off2StartNxtRec=811248
297 OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
297 OffRHeader= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
298 print ' '
298 print ' '
299 print 'puntero Record Header', startFp.tell()
299 print 'puntero Record Header', startFp.tell()
300 print ' '
300 print ' '
301
301
302
302
303 startFp.seek(OffRHeader, os.SEEK_SET)
303 startFp.seek(OffRHeader, os.SEEK_SET)
304
304
305 print ' '
305 print ' '
306 print 'puntero Record Header con seek', startFp.tell()
306 print 'puntero Record Header con seek', startFp.tell()
307 print ' '
307 print ' '
308
308
309 #print 'Posicion del bloque: ',OffRHeader
309 #print 'Posicion del bloque: ',OffRHeader
310
310
311 header = numpy.fromfile(startFp,RECORD_STRUCTURE,1)
311 header = numpy.fromfile(startFp,RECORD_STRUCTURE,1)
312
312
313 print ' '
313 print ' '
314 print 'puntero Record Header con seek', startFp.tell()
314 print 'puntero Record Header con seek', startFp.tell()
315 print ' '
315 print ' '
316
316
317 print ' '
317 print ' '
318 #
318 #
319 #print 'puntero Record Header despues de seek', header.tell()
319 #print 'puntero Record Header despues de seek', header.tell()
320 print ' '
320 print ' '
321
321
322 self.RecMgcNumber = hex(header['RecMgcNumber'][0]) #0x23030001
322 self.RecMgcNumber = hex(header['RecMgcNumber'][0]) #0x23030001
323 self.RecCounter = int(header['RecCounter'][0])
323 self.RecCounter = int(header['RecCounter'][0])
324 self.Off2StartNxtRec = int(header['Off2StartNxtRec'][0])
324 self.Off2StartNxtRec = int(header['Off2StartNxtRec'][0])
325 self.Off2StartData = int(header['Off2StartData'][0])
325 self.Off2StartData = int(header['Off2StartData'][0])
326 self.nUtime = header['nUtime'][0]
326 self.nUtime = header['nUtime'][0]
327 self.nMilisec = header['nMilisec'][0]
327 self.nMilisec = header['nMilisec'][0]
328 self.ExpTagName = str(header['ExpTagName'][0])
328 self.ExpTagName = str(header['ExpTagName'][0])
329 self.ExpComment = str(header['ExpComment'][0])
329 self.ExpComment = str(header['ExpComment'][0])
330 self.SiteLatDegrees = header['SiteLatDegrees'][0]
330 self.SiteLatDegrees = header['SiteLatDegrees'][0]
331 self.SiteLongDegrees = header['SiteLongDegrees'][0]
331 self.SiteLongDegrees = header['SiteLongDegrees'][0]
332 self.RTCgpsStatus = header['RTCgpsStatus'][0]
332 self.RTCgpsStatus = header['RTCgpsStatus'][0]
333 self.TransmitFrec = header['TransmitFrec'][0]
333 self.TransmitFrec = header['TransmitFrec'][0]
334 self.ReceiveFrec = header['ReceiveFrec'][0]
334 self.ReceiveFrec = header['ReceiveFrec'][0]
335 self.FirstOsciFrec = header['FirstOsciFrec'][0]
335 self.FirstOsciFrec = header['FirstOsciFrec'][0]
336 self.Polarisation = header['Polarisation'][0]
336 self.Polarisation = header['Polarisation'][0]
337 self.ReceiverFiltSett = header['ReceiverFiltSett'][0]
337 self.ReceiverFiltSett = header['ReceiverFiltSett'][0]
338 self.nModesInUse = header['nModesInUse'][0]
338 self.nModesInUse = header['nModesInUse'][0]
339 self.DualModeIndex = header['DualModeIndex'][0]
339 self.DualModeIndex = header['DualModeIndex'][0]
340 self.DualModeRange = header['DualModeRange'][0]
340 self.DualModeRange = header['DualModeRange'][0]
341 self.nDigChannels = header['nDigChannels'][0]
341 self.nDigChannels = header['nDigChannels'][0]
342 self.SampResolution = header['SampResolution'][0]
342 self.SampResolution = header['SampResolution'][0]
343 self.nHeights = header['nHeights'][0]
343 self.nHeights = header['nHeights'][0]
344 self.StartRangeSamp = header['StartRangeSamp'][0]
344 self.StartRangeSamp = header['StartRangeSamp'][0]
345 self.PRFhz = header['PRFhz'][0]
345 self.PRFhz = header['PRFhz'][0]
346 self.nCohInt = header['nCohInt'][0]
346 self.nCohInt = header['nCohInt'][0]
347 self.nProfiles = header['nProfiles'][0]
347 self.nProfiles = header['nProfiles'][0]
348 self.nChannels = header['nChannels'][0]
348 self.nChannels = header['nChannels'][0]
349 self.nIncohInt = header['nIncohInt'][0]
349 self.nIncohInt = header['nIncohInt'][0]
350 self.FFTwindowingInd = header['FFTwindowingInd'][0]
350 self.FFTwindowingInd = header['FFTwindowingInd'][0]
351 self.BeamAngleAzim = header['BeamAngleAzim'][0]
351 self.BeamAngleAzim = header['BeamAngleAzim'][0]
352 self.BeamAngleZen = header['BeamAngleZen'][0]
352 self.BeamAngleZen = header['BeamAngleZen'][0]
353 self.AntennaCoord0 = header['AntennaCoord0'][0]
353 self.AntennaCoord0 = header['AntennaCoord0'][0]
354 self.AntennaAngl0 = header['AntennaAngl0'][0]
354 self.AntennaAngl0 = header['AntennaAngl0'][0]
355 self.AntennaCoord1 = header['AntennaCoord1'][0]
355 self.AntennaCoord1 = header['AntennaCoord1'][0]
356 self.AntennaAngl1 = header['AntennaAngl1'][0]
356 self.AntennaAngl1 = header['AntennaAngl1'][0]
357 self.AntennaCoord2 = header['AntennaCoord2'][0]
357 self.AntennaCoord2 = header['AntennaCoord2'][0]
358 self.AntennaAngl2 = header['AntennaAngl2'][0]
358 self.AntennaAngl2 = header['AntennaAngl2'][0]
359 self.RecPhaseCalibr0 = header['RecPhaseCalibr0'][0]
359 self.RecPhaseCalibr0 = header['RecPhaseCalibr0'][0]
360 self.RecPhaseCalibr1 = header['RecPhaseCalibr1'][0]
360 self.RecPhaseCalibr1 = header['RecPhaseCalibr1'][0]
361 self.RecPhaseCalibr2 = header['RecPhaseCalibr2'][0]
361 self.RecPhaseCalibr2 = header['RecPhaseCalibr2'][0]
362 self.RecAmpCalibr0 = header['RecAmpCalibr0'][0]
362 self.RecAmpCalibr0 = header['RecAmpCalibr0'][0]
363 self.RecAmpCalibr1 = header['RecAmpCalibr1'][0]
363 self.RecAmpCalibr1 = header['RecAmpCalibr1'][0]
364 self.RecAmpCalibr2 = header['RecAmpCalibr2'][0]
364 self.RecAmpCalibr2 = header['RecAmpCalibr2'][0]
365 self.ReceiverGaindB0 = header['ReceiverGaindB0'][0]
365 self.ReceiverGaindB0 = header['ReceiverGaindB0'][0]
366 self.ReceiverGaindB1 = header['ReceiverGaindB1'][0]
366 self.ReceiverGaindB1 = header['ReceiverGaindB1'][0]
367 self.ReceiverGaindB2 = header['ReceiverGaindB2'][0]
367 self.ReceiverGaindB2 = header['ReceiverGaindB2'][0]
368
368
369 self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
369 self.ipp= 0.5*(SPEED_OF_LIGHT/self.PRFhz)
370
370
371 self.RHsize = 180+20*self.nChannels
371 self.RHsize = 180+20*self.nChannels
372 self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
372 self.Datasize= self.nProfiles*self.nChannels*self.nHeights*2*4
373 #print 'Datasize',self.Datasize
373 #print 'Datasize',self.Datasize
374 endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
374 endFp = self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec
375
375
376 print '=============================================='
376 print '=============================================='
377 print 'RecMgcNumber ',self.RecMgcNumber
377 print 'RecMgcNumber ',self.RecMgcNumber
378 print 'RecCounter ',self.RecCounter
378 print 'RecCounter ',self.RecCounter
379 print 'Off2StartNxtRec ',self.Off2StartNxtRec
379 print 'Off2StartNxtRec ',self.Off2StartNxtRec
380 print 'Off2StartData ',self.Off2StartData
380 print 'Off2StartData ',self.Off2StartData
381 print 'Range Resolution ',self.SampResolution
381 print 'Range Resolution ',self.SampResolution
382 print 'First Height ',self.StartRangeSamp
382 print 'First Height ',self.StartRangeSamp
383 print 'PRF (Hz) ',self.PRFhz
383 print 'PRF (Hz) ',self.PRFhz
384 print 'Heights (K) ',self.nHeights
384 print 'Heights (K) ',self.nHeights
385 print 'Channels (N) ',self.nChannels
385 print 'Channels (N) ',self.nChannels
386 print 'Profiles (J) ',self.nProfiles
386 print 'Profiles (J) ',self.nProfiles
387 print 'iCoh ',self.nCohInt
387 print 'iCoh ',self.nCohInt
388 print 'iInCoh ',self.nIncohInt
388 print 'iInCoh ',self.nIncohInt
389 print 'BeamAngleAzim ',self.BeamAngleAzim
389 print 'BeamAngleAzim ',self.BeamAngleAzim
390 print 'BeamAngleZen ',self.BeamAngleZen
390 print 'BeamAngleZen ',self.BeamAngleZen
391
391
392 #print 'ModoEnUso ',self.DualModeIndex
392 #print 'ModoEnUso ',self.DualModeIndex
393 #print 'UtcTime ',self.nUtime
393 #print 'UtcTime ',self.nUtime
394 #print 'MiliSec ',self.nMilisec
394 #print 'MiliSec ',self.nMilisec
395 #print 'Exp TagName ',self.ExpTagName
395 #print 'Exp TagName ',self.ExpTagName
396 #print 'Exp Comment ',self.ExpComment
396 #print 'Exp Comment ',self.ExpComment
397 #print 'FFT Window Index ',self.FFTwindowingInd
397 #print 'FFT Window Index ',self.FFTwindowingInd
398 #print 'N Dig. Channels ',self.nDigChannels
398 #print 'N Dig. Channels ',self.nDigChannels
399 print 'Size de bloque ',self.RHsize
399 print 'Size de bloque ',self.RHsize
400 print 'DataSize ',self.Datasize
400 print 'DataSize ',self.Datasize
401 print 'BeamAngleAzim ',self.BeamAngleAzim
401 print 'BeamAngleAzim ',self.BeamAngleAzim
402 #print 'AntennaCoord0 ',self.AntennaCoord0
402 #print 'AntennaCoord0 ',self.AntennaCoord0
403 #print 'AntennaAngl0 ',self.AntennaAngl0
403 #print 'AntennaAngl0 ',self.AntennaAngl0
404 #print 'AntennaCoord1 ',self.AntennaCoord1
404 #print 'AntennaCoord1 ',self.AntennaCoord1
405 #print 'AntennaAngl1 ',self.AntennaAngl1
405 #print 'AntennaAngl1 ',self.AntennaAngl1
406 #print 'AntennaCoord2 ',self.AntennaCoord2
406 #print 'AntennaCoord2 ',self.AntennaCoord2
407 #print 'AntennaAngl2 ',self.AntennaAngl2
407 #print 'AntennaAngl2 ',self.AntennaAngl2
408 print 'RecPhaseCalibr0 ',self.RecPhaseCalibr0
408 print 'RecPhaseCalibr0 ',self.RecPhaseCalibr0
409 print 'RecPhaseCalibr1 ',self.RecPhaseCalibr1
409 print 'RecPhaseCalibr1 ',self.RecPhaseCalibr1
410 print 'RecPhaseCalibr2 ',self.RecPhaseCalibr2
410 print 'RecPhaseCalibr2 ',self.RecPhaseCalibr2
411 print 'RecAmpCalibr0 ',self.RecAmpCalibr0
411 print 'RecAmpCalibr0 ',self.RecAmpCalibr0
412 print 'RecAmpCalibr1 ',self.RecAmpCalibr1
412 print 'RecAmpCalibr1 ',self.RecAmpCalibr1
413 print 'RecAmpCalibr2 ',self.RecAmpCalibr2
413 print 'RecAmpCalibr2 ',self.RecAmpCalibr2
414 print 'ReceiverGaindB0 ',self.ReceiverGaindB0
414 print 'ReceiverGaindB0 ',self.ReceiverGaindB0
415 print 'ReceiverGaindB1 ',self.ReceiverGaindB1
415 print 'ReceiverGaindB1 ',self.ReceiverGaindB1
416 print 'ReceiverGaindB2 ',self.ReceiverGaindB2
416 print 'ReceiverGaindB2 ',self.ReceiverGaindB2
417 print '=============================================='
417 print '=============================================='
418
418
419 if OffRHeader > endFp:
419 if OffRHeader > endFp:
420 sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp)
420 sys.stderr.write("Warning %s: Size value read from System Header is lower than it has to be\n" %fp)
421 return 0
421 return 0
422
422
423 if OffRHeader < endFp:
423 if OffRHeader < endFp:
424 sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp)
424 sys.stderr.write("Warning %s: Size value read from System Header size is greater than it has to be\n" %fp)
425 return 0
425 return 0
426
426
427 return 1
427 return 1
428
428
429
429
430 class BLTRReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODataReader):
430 class BLTRReader (ProcessingUnit, FileHeaderBLTR, RecordHeaderBLTR, JRODataReader):
431
431
432 path = None
432 path = None
433 startDate = None
433 startDate = None
434 endDate = None
434 endDate = None
435 startTime = None
435 startTime = None
436 endTime = None
436 endTime = None
437 walk = None
437 walk = None
438 isConfig = False
438 isConfig = False
439
439
440
440
441 fileList= None
441 fileList= None
442
442
443 #metadata
443 #metadata
444 TimeZone= None
444 TimeZone= None
445 Interval= None
445 Interval= None
446 heightList= None
446 heightList= None
447
447
448 #data
448 #data
449 data= None
449 data= None
450 utctime= None
450 utctime= None
451
451
452
452
453
453
454 def __init__(self, **kwargs):
454 def __init__(self, **kwargs):
455
455
456 #Eliminar de la base la herencia
456 #Eliminar de la base la herencia
457 ProcessingUnit.__init__(self, **kwargs)
457 ProcessingUnit.__init__(self, **kwargs)
458
458
459 # self.isConfig = False
459 # self.isConfig = False
460
460
461 #self.pts2read_SelfSpectra = 0
461 #self.pts2read_SelfSpectra = 0
462 #self.pts2read_CrossSpectra = 0
462 #self.pts2read_CrossSpectra = 0
463 #self.pts2read_DCchannels = 0
463 #self.pts2read_DCchannels = 0
464 #self.datablock = None
464 #self.datablock = None
465 self.utc = None
465 self.utc = None
466 self.ext = ".fdt"
466 self.ext = ".fdt"
467 self.optchar = "P"
467 self.optchar = "P"
468 self.fpFile=None
468 self.fpFile=None
469 self.fp = None
469 self.fp = None
470 self.BlockCounter=0
470 self.BlockCounter=0
471 self.dtype = None
471 self.dtype = None
472 self.fileSizeByHeader = None
472 self.fileSizeByHeader = None
473 self.filenameList = []
473 self.filenameList = []
474 self.fileSelector = 0
474 self.fileSelector = 0
475 self.Off2StartNxtRec=0
475 self.Off2StartNxtRec=0
476 self.RecCounter=0
476 self.RecCounter=0
477 self.flagNoMoreFiles = 0
477 self.flagNoMoreFiles = 0
478 self.data_spc=None
478 self.data_spc=None
479 self.data_cspc=None
479 self.data_cspc=None
480 self.data_output=None
480 self.data_output=None
481 self.path = None
481 self.path = None
482 self.OffsetStartHeader=0
482 self.OffsetStartHeader=0
483 self.Off2StartData=0
483 self.Off2StartData=0
484 self.ipp = 0
484 self.ipp = 0
485 self.nFDTdataRecors=0
485 self.nFDTdataRecors=0
486 self.blocksize = 0
486 self.blocksize = 0
487 self.dataOut = Spectra()
487 self.dataOut = Spectra()
488 self.profileIndex = 1 #Always
488 self.profileIndex = 1 #Always
489 self.dataOut.flagNoData=False
489 self.dataOut.flagNoData=False
490 self.dataOut.nRdPairs = 0
490 self.dataOut.nRdPairs = 0
491 self.dataOut.pairsList = []
491 self.dataOut.pairsList = []
492 self.dataOut.data_spc=None
492 self.dataOut.data_spc=None
493 self.dataOut.noise=[]
493 self.dataOut.noise=[]
494 self.dataOut.velocityX=[]
494 self.dataOut.velocityX=[]
495 self.dataOut.velocityY=[]
495 self.dataOut.velocityY=[]
496 self.dataOut.velocityV=[]
496 self.dataOut.velocityV=[]
497
497
498
498
499
499
500 def Files2Read(self, fp):
500 def Files2Read(self, fp):
501 '''
501 '''
502 Function that indicates the number of .fdt files that exist in the folder to be read.
502 Function that indicates the number of .fdt files that exist in the folder to be read.
503 It also creates an organized list with the names of the files to read.
503 It also creates an organized list with the names of the files to read.
504 '''
504 '''
505 #self.__checkPath()
505 #self.__checkPath()
506
506
507 ListaData=os.listdir(fp) #Gets the list of files within the fp address
507 ListaData=os.listdir(fp) #Gets the list of files within the fp address
508 ListaData=sorted(ListaData) #Sort the list of files from least to largest by names
508 ListaData=sorted(ListaData) #Sort the list of files from least to largest by names
509 nFiles=0 #File Counter
509 nFiles=0 #File Counter
510 FileList=[] #A list is created that will contain the .fdt files
510 FileList=[] #A list is created that will contain the .fdt files
511 for IndexFile in ListaData :
511 for IndexFile in ListaData :
512 if '.fdt' in IndexFile:
512 if '.fdt' in IndexFile:
513 FileList.append(IndexFile)
513 FileList.append(IndexFile)
514 nFiles+=1
514 nFiles+=1
515
515
516 #print 'Files2Read'
516 #print 'Files2Read'
517 #print 'Existen '+str(nFiles)+' archivos .fdt'
517 #print 'Existen '+str(nFiles)+' archivos .fdt'
518
518
519 self.filenameList=FileList #List of files from least to largest by names
519 self.filenameList=FileList #List of files from least to largest by names
520
520
521
521
522 def run(self, **kwargs):
522 def run(self, **kwargs):
523 '''
523 '''
524 This method will be the one that will initiate the data entry, will be called constantly.
524 This method will be the one that will initiate the data entry, will be called constantly.
525 You should first verify that your Setup () is set up and then continue to acquire
525 You should first verify that your Setup () is set up and then continue to acquire
526 the data to be processed with getData ().
526 the data to be processed with getData ().
527 '''
527 '''
528 if not self.isConfig:
528 if not self.isConfig:
529 self.setup(**kwargs)
529 self.setup(**kwargs)
530 self.isConfig = True
530 self.isConfig = True
531
531
532 self.getData()
532 self.getData()
533 #print 'running'
533 #print 'running'
534
534
535
535
536 def setup(self, path=None,
536 def setup(self, path=None,
537 startDate=None,
537 startDate=None,
538 endDate=None,
538 endDate=None,
539 startTime=None,
539 startTime=None,
540 endTime=None,
540 endTime=None,
541 walk=True,
541 walk=True,
542 timezone='utc',
542 timezone='utc',
543 code = None,
543 code = None,
544 online=False,
544 online=False,
545 ReadMode=None,
545 ReadMode=None,
546 **kwargs):
546 **kwargs):
547
547
548 self.isConfig = True
548 self.isConfig = True
549
549
550 self.path=path
550 self.path=path
551 self.startDate=startDate
551 self.startDate=startDate
552 self.endDate=endDate
552 self.endDate=endDate
553 self.startTime=startTime
553 self.startTime=startTime
554 self.endTime=endTime
554 self.endTime=endTime
555 self.walk=walk
555 self.walk=walk
556 self.ReadMode=int(ReadMode)
556 self.ReadMode=int(ReadMode)
557
557
558 pass
558 pass
559
559
560
560
561 def getData(self):
561 def getData(self):
562 '''
562 '''
563 Before starting this function, you should check that there is still an unread file,
563 Before starting this function, you should check that there is still an unread file,
564 If there are still blocks to read or if the data block is empty.
564 If there are still blocks to read or if the data block is empty.
565
565
566 You should call the file "read".
566 You should call the file "read".
567
567
568 '''
568 '''
569
569
570 if self.flagNoMoreFiles:
570 if self.flagNoMoreFiles:
571 self.dataOut.flagNoData = True
571 self.dataOut.flagNoData = True
572 print 'NoData se vuelve true'
572 print 'NoData se vuelve true'
573 return 0
573 return 0
574
574
575 self.fp=self.path
575 self.fp=self.path
576 self.Files2Read(self.fp)
576 self.Files2Read(self.fp)
577 self.readFile(self.fp)
577 self.readFile(self.fp)
578 self.dataOut.data_spc = self.data_spc
578 self.dataOut.data_spc = self.data_spc
579 self.dataOut.data_cspc =self.data_cspc
579 self.dataOut.data_cspc =self.data_cspc
580 self.dataOut.data_output=self.data_output
580 self.dataOut.data_output=self.data_output
581
581
582 print 'self.dataOut.data_output', shape(self.dataOut.data_output)
582 print 'self.dataOut.data_output', shape(self.dataOut.data_output)
583
583
584 #self.removeDC()
584 #self.removeDC()
585 return self.dataOut.data_spc
585 return self.dataOut.data_spc
586
586
587
587
588 def readFile(self,fp):
588 def readFile(self,fp):
589 '''
589 '''
590 You must indicate if you are reading in Online or Offline mode and load the
590 You must indicate if you are reading in Online or Offline mode and load the
591 The parameters for this file reading mode.
591 The parameters for this file reading mode.
592
592
593 Then you must do 2 actions:
593 Then you must do 2 actions:
594
594
595 1. Get the BLTR FileHeader.
595 1. Get the BLTR FileHeader.
596 2. Start reading the first block.
596 2. Start reading the first block.
597 '''
597 '''
598
598
599 #The address of the folder is generated the name of the .fdt file that will be read
599 #The address of the folder is generated the name of the .fdt file that will be read
600 print "File: ",self.fileSelector+1
600 print "File: ",self.fileSelector+1
601
601
602 if self.fileSelector < len(self.filenameList):
602 if self.fileSelector < len(self.filenameList):
603
603
604 self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
604 self.fpFile=str(fp)+'/'+str(self.filenameList[self.fileSelector])
605 #print self.fpFile
605 #print self.fpFile
606 fheader = FileHeaderBLTR()
606 fheader = FileHeaderBLTR()
607 fheader.FHread(self.fpFile) #Bltr FileHeader Reading
607 fheader.FHread(self.fpFile) #Bltr FileHeader Reading
608 self.nFDTdataRecors=fheader.nFDTdataRecors
608 self.nFDTdataRecors=fheader.nFDTdataRecors
609
609
610 self.readBlock() #Block reading
610 self.readBlock() #Block reading
611 else:
611 else:
612 print 'readFile FlagNoData becomes true'
612 print 'readFile FlagNoData becomes true'
613 self.flagNoMoreFiles=True
613 self.flagNoMoreFiles=True
614 self.dataOut.flagNoData = True
614 self.dataOut.flagNoData = True
615 return 0
615 return 0
616
616
617 def getVelRange(self, extrapoints=0):
617 def getVelRange(self, extrapoints=0):
618 Lambda= SPEED_OF_LIGHT/50000000
618 Lambda= SPEED_OF_LIGHT/50000000
619 PRF = self.dataOut.PRF#1./(self.dataOut.ippSeconds * self.dataOut.nCohInt)
619 PRF = self.dataOut.PRF#1./(self.dataOut.ippSeconds * self.dataOut.nCohInt)
620 Vmax=-Lambda/(4.*(1./PRF)*self.dataOut.nCohInt*2.)
620 Vmax=-Lambda/(4.*(1./PRF)*self.dataOut.nCohInt*2.)
621 deltafreq = PRF / (self.nProfiles)
621 deltafreq = PRF / (self.nProfiles)
622 deltavel = (Vmax*2) / (self.nProfiles)
622 deltavel = (Vmax*2) / (self.nProfiles)
623 freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2
623 freqrange = deltafreq*(numpy.arange(self.nProfiles)-self.nProfiles/2.) - deltafreq/2
624 velrange = deltavel*(numpy.arange(self.nProfiles)-self.nProfiles/2.)
624 velrange = deltavel*(numpy.arange(self.nProfiles)-self.nProfiles/2.)
625 return velrange
625 return velrange
626
626
627 def readBlock(self):
627 def readBlock(self):
628 '''
628 '''
629 It should be checked if the block has data, if it is not passed to the next file.
629 It should be checked if the block has data, if it is not passed to the next file.
630
630
631 Then the following is done:
631 Then the following is done:
632
632
633 1. Read the RecordHeader
633 1. Read the RecordHeader
634 2. Fill the buffer with the current block number.
634 2. Fill the buffer with the current block number.
635
635
636 '''
636 '''
637
637
638 if self.BlockCounter < self.nFDTdataRecors-2:
638 if self.BlockCounter < self.nFDTdataRecors-2:
639 print self.nFDTdataRecors, 'CONDICION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
639 print self.nFDTdataRecors, 'CONDICION!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!'
640 if self.ReadMode==1:
640 if self.ReadMode==1:
641 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter+1)
641 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter+1)
642 elif self.ReadMode==0:
642 elif self.ReadMode==0:
643 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter)
643 rheader = RecordHeaderBLTR(RecCounter=self.BlockCounter)
644
644
645 rheader.RHread(self.fpFile) #Bltr FileHeader Reading
645 rheader.RHread(self.fpFile) #Bltr FileHeader Reading
646
646
647 self.OffsetStartHeader=rheader.OffsetStartHeader
647 self.OffsetStartHeader=rheader.OffsetStartHeader
648 self.RecCounter=rheader.RecCounter
648 self.RecCounter=rheader.RecCounter
649 self.Off2StartNxtRec=rheader.Off2StartNxtRec
649 self.Off2StartNxtRec=rheader.Off2StartNxtRec
650 self.Off2StartData=rheader.Off2StartData
650 self.Off2StartData=rheader.Off2StartData
651 self.nProfiles=rheader.nProfiles
651 self.nProfiles=rheader.nProfiles
652 self.nChannels=rheader.nChannels
652 self.nChannels=rheader.nChannels
653 self.nHeights=rheader.nHeights
653 self.nHeights=rheader.nHeights
654 self.frequency=rheader.TransmitFrec
654 self.frequency=rheader.TransmitFrec
655 self.DualModeIndex=rheader.DualModeIndex
655 self.DualModeIndex=rheader.DualModeIndex
656
656
657 self.pairsList =[(0,1),(0,2),(1,2)]
657 self.pairsList =[(0,1),(0,2),(1,2)]
658 self.dataOut.pairsList = self.pairsList
658 self.dataOut.pairsList = self.pairsList
659
659
660 self.nRdPairs=len(self.dataOut.pairsList)
660 self.nRdPairs=len(self.dataOut.pairsList)
661 self.dataOut.nRdPairs = self.nRdPairs
661 self.dataOut.nRdPairs = self.nRdPairs
662
662
663 self.__firstHeigth=rheader.StartRangeSamp
663 self.__firstHeigth=rheader.StartRangeSamp
664 self.__deltaHeigth=rheader.SampResolution
664 self.__deltaHeigth=rheader.SampResolution
665 self.dataOut.heightList= self.__firstHeigth + numpy.array(range(self.nHeights))*self.__deltaHeigth
665 self.dataOut.heightList= self.__firstHeigth + numpy.array(range(self.nHeights))*self.__deltaHeigth
666 self.dataOut.channelList = range(self.nChannels)
666 self.dataOut.channelList = range(self.nChannels)
667 self.dataOut.nProfiles=rheader.nProfiles
667 self.dataOut.nProfiles=rheader.nProfiles
668 self.dataOut.nIncohInt=rheader.nIncohInt
668 self.dataOut.nIncohInt=rheader.nIncohInt
669 self.dataOut.nCohInt=rheader.nCohInt
669 self.dataOut.nCohInt=rheader.nCohInt
670 self.dataOut.ippSeconds= 1/float(rheader.PRFhz)
670 self.dataOut.ippSeconds= 1/float(rheader.PRFhz)
671 self.dataOut.PRF=rheader.PRFhz
671 self.dataOut.PRF=rheader.PRFhz
672 self.dataOut.nFFTPoints=rheader.nProfiles
672 self.dataOut.nFFTPoints=rheader.nProfiles
673 self.dataOut.utctime=rheader.nUtime
673 self.dataOut.utctime=rheader.nUtime
674 self.dataOut.timeZone=0
674 self.dataOut.timeZone=0
675 self.dataOut.normFactor= self.dataOut.nProfiles*self.dataOut.nIncohInt*self.dataOut.nCohInt
675 self.dataOut.normFactor= self.dataOut.nProfiles*self.dataOut.nIncohInt*self.dataOut.nCohInt
676 self.dataOut.outputInterval= self.dataOut.ippSeconds * self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles
676 self.dataOut.outputInterval= self.dataOut.ippSeconds * self.dataOut.nCohInt * self.dataOut.nIncohInt * self.nProfiles
677
677
678 self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN
678 self.data_output=numpy.ones([3,rheader.nHeights])*numpy.NaN
679 print 'self.data_output', shape(self.data_output)
679 print 'self.data_output', shape(self.data_output)
680 self.dataOut.velocityX=[]
680 self.dataOut.velocityX=[]
681 self.dataOut.velocityY=[]
681 self.dataOut.velocityY=[]
682 self.dataOut.velocityV=[]
682 self.dataOut.velocityV=[]
683
683
684 '''Block Reading, the Block Data is received and Reshape is used to give it
684 '''Block Reading, the Block Data is received and Reshape is used to give it
685 shape.
685 shape.
686 '''
686 '''
687
687
688 #Procedure to take the pointer to where the date block starts
688 #Procedure to take the pointer to where the date block starts
689 startDATA = open(self.fpFile,"rb")
689 startDATA = open(self.fpFile,"rb")
690 OffDATA= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec+self.Off2StartData
690 OffDATA= self.OffsetStartHeader + self.RecCounter*self.Off2StartNxtRec+self.Off2StartData
691 startDATA.seek(OffDATA, os.SEEK_SET)
691 startDATA.seek(OffDATA, os.SEEK_SET)
692
692
693 def moving_average(x, N=2):
693 def moving_average(x, N=2):
694 return numpy.convolve(x, numpy.ones((N,))/N)[(N-1):]
694 return numpy.convolve(x, numpy.ones((N,))/N)[(N-1):]
695
695
696 def gaus(xSamples,a,x0,sigma):
696 def gaus(xSamples,a,x0,sigma):
697 return a*exp(-(xSamples-x0)**2/(2*sigma**2))
697 return a*exp(-(xSamples-x0)**2/(2*sigma**2))
698
698
699 def Find(x,value):
699 def Find(x,value):
700 for index in range(len(x)):
700 for index in range(len(x)):
701 if x[index]==value:
701 if x[index]==value:
702 return index
702 return index
703
703
704 def pol2cart(rho, phi):
704 def pol2cart(rho, phi):
705 x = rho * numpy.cos(phi)
705 x = rho * numpy.cos(phi)
706 y = rho * numpy.sin(phi)
706 y = rho * numpy.sin(phi)
707 return(x, y)
707 return(x, y)
708
708
709
709
710
710
711
711
712 if self.DualModeIndex==self.ReadMode:
712 if self.DualModeIndex==self.ReadMode:
713
713
714 self.data_fft = numpy.fromfile( startDATA, [('complex','<c8')],self.nProfiles*self.nChannels*self.nHeights )
714 self.data_fft = numpy.fromfile( startDATA, [('complex','<c8')],self.nProfiles*self.nChannels*self.nHeights )
715
715
716 self.data_fft=self.data_fft.astype(numpy.dtype('complex'))
716 self.data_fft=self.data_fft.astype(numpy.dtype('complex'))
717
717
718 self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles ))
718 self.data_block=numpy.reshape(self.data_fft,(self.nHeights, self.nChannels, self.nProfiles ))
719
719
720 self.data_block = numpy.transpose(self.data_block, (1,2,0))
720 self.data_block = numpy.transpose(self.data_block, (1,2,0))
721
721
722 copy = self.data_block.copy()
722 copy = self.data_block.copy()
723 spc = copy * numpy.conjugate(copy)
723 spc = copy * numpy.conjugate(copy)
724
724
725 self.data_spc = numpy.absolute(spc) # valor absoluto o magnitud
725 self.data_spc = numpy.absolute(spc) # valor absoluto o magnitud
726
726
727 factor = self.dataOut.normFactor
727 factor = self.dataOut.normFactor
728
728
729
729
730 z = self.data_spc.copy()#/factor
730 z = self.data_spc.copy()#/factor
731 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
731 z = numpy.where(numpy.isfinite(z), z, numpy.NAN)
732 #zdB = 10*numpy.log10(z)
732 #zdB = 10*numpy.log10(z)
733 print ' '
733 print ' '
734 print 'Z: '
734 print 'Z: '
735 print shape(z)
735 print shape(z)
736 print ' '
736 print ' '
737 print ' '
737 print ' '
738
738
739 self.dataOut.data_spc=self.data_spc
739 self.dataOut.data_spc=self.data_spc
740
740
741 self.noise = self.dataOut.getNoise(ymin_index=80, ymax_index=132)#/factor
741 self.noise = self.dataOut.getNoise(ymin_index=80, ymax_index=132)#/factor
742 #noisedB = 10*numpy.log10(self.noise)
742 #noisedB = 10*numpy.log10(self.noise)
743
743
744
744
745 ySamples=numpy.ones([3,self.nProfiles])
745 ySamples=numpy.ones([3,self.nProfiles])
746 phase=numpy.ones([3,self.nProfiles])
746 phase=numpy.ones([3,self.nProfiles])
747 CSPCSamples=numpy.ones([3,self.nProfiles],dtype=numpy.complex_)
747 CSPCSamples=numpy.ones([3,self.nProfiles],dtype=numpy.complex_)
748 coherence=numpy.ones([3,self.nProfiles])
748 coherence=numpy.ones([3,self.nProfiles])
749 PhaseSlope=numpy.ones(3)
749 PhaseSlope=numpy.ones(3)
750 PhaseInter=numpy.ones(3)
750 PhaseInter=numpy.ones(3)
751
751
752 '''****** Getting CrossSpectra ******'''
752 '''****** Getting CrossSpectra ******'''
753 cspc=self.data_block.copy()
753 cspc=self.data_block.copy()
754 self.data_cspc=self.data_block.copy()
754 self.data_cspc=self.data_block.copy()
755
755
756 xFrec=self.getVelRange(1)
756 xFrec=self.getVelRange(1)
757 VelRange=self.getVelRange(1)
757 VelRange=self.getVelRange(1)
758 self.dataOut.VelRange=VelRange
758 self.dataOut.VelRange=VelRange
759 #print ' '
759 #print ' '
760 #print ' '
760 #print ' '
761 #print 'xFrec',xFrec
761 #print 'xFrec',xFrec
762 #print ' '
762 #print ' '
763 #print ' '
763 #print ' '
764 #Height=35
764 #Height=35
765
765 for i in range(self.nRdPairs):
766 for i in range(self.nRdPairs):
766
767
767 chan_index0 = self.dataOut.pairsList[i][0]
768 chan_index0 = self.dataOut.pairsList[i][0]
768 chan_index1 = self.dataOut.pairsList[i][1]
769 chan_index1 = self.dataOut.pairsList[i][1]
769
770
770 self.data_cspc[i,:,:]=cspc[chan_index0,:,:] * numpy.conjugate(cspc[chan_index1,:,:])
771 self.data_cspc[i,:,:]=cspc[chan_index0,:,:] * numpy.conjugate(cspc[chan_index1,:,:])
771
772
772
773
773 '''Getting Eij and Nij'''
774 '''Getting Eij and Nij'''
774 (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
775 (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
775 (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
776 (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
776 (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
777 (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
777
778
778 E01=AntennaX0-AntennaX1
779 E01=AntennaX0-AntennaX1
779 N01=AntennaY0-AntennaY1
780 N01=AntennaY0-AntennaY1
780
781
781 E02=AntennaX0-AntennaX2
782 E02=AntennaX0-AntennaX2
782 N02=AntennaY0-AntennaY2
783 N02=AntennaY0-AntennaY2
783
784
784 E12=AntennaX1-AntennaX2
785 E12=AntennaX1-AntennaX2
785 N12=AntennaY1-AntennaY2
786 N12=AntennaY1-AntennaY2
786
787
787 self.ChanDist= numpy.array([[E01, N01],[E02,N02],[E12,N12]])
788 self.ChanDist= numpy.array([[E01, N01],[E02,N02],[E12,N12]])
788
789
789 self.dataOut.ChanDist = self.ChanDist
790 self.dataOut.ChanDist = self.ChanDist
790
791
791
792
792 # for Height in range(self.nHeights):
793 # for Height in range(self.nHeights):
793 #
794 #
794 # for i in range(self.nRdPairs):
795 # for i in range(self.nRdPairs):
795 #
796 #
796 # '''****** Line of Data SPC ******'''
797 # '''****** Line of Data SPC ******'''
797 # zline=z[i,:,Height]
798 # zline=z[i,:,Height]
798 #
799 #
799 # '''****** DC is removed ******'''
800 # '''****** DC is removed ******'''
800 # DC=Find(zline,numpy.amax(zline))
801 # DC=Find(zline,numpy.amax(zline))
801 # zline[DC]=(zline[DC-1]+zline[DC+1])/2
802 # zline[DC]=(zline[DC-1]+zline[DC+1])/2
802 #
803 #
803 #
804 #
804 # '''****** SPC is normalized ******'''
805 # '''****** SPC is normalized ******'''
805 # FactNorm= zline.copy() / numpy.sum(zline.copy())
806 # FactNorm= zline.copy() / numpy.sum(zline.copy())
806 # FactNorm= FactNorm/numpy.sum(FactNorm)
807 # FactNorm= FactNorm/numpy.sum(FactNorm)
807 #
808 #
808 # SmoothSPC=moving_average(FactNorm,N=3)
809 # SmoothSPC=moving_average(FactNorm,N=3)
809 #
810 #
810 # xSamples = ar(range(len(SmoothSPC)))
811 # xSamples = ar(range(len(SmoothSPC)))
811 # ySamples[i] = SmoothSPC-self.noise[i]
812 # ySamples[i] = SmoothSPC-self.noise[i]
812 #
813 #
813 # for i in range(self.nRdPairs):
814 # for i in range(self.nRdPairs):
814 #
815 #
815 # '''****** Line of Data CSPC ******'''
816 # '''****** Line of Data CSPC ******'''
816 # cspcLine=self.data_cspc[i,:,Height].copy()
817 # cspcLine=self.data_cspc[i,:,Height].copy()
817 #
818 #
818 #
819 #
819 #
820 #
820 # '''****** CSPC is normalized ******'''
821 # '''****** CSPC is normalized ******'''
821 # chan_index0 = self.dataOut.pairsList[i][0]
822 # chan_index0 = self.dataOut.pairsList[i][0]
822 # chan_index1 = self.dataOut.pairsList[i][1]
823 # chan_index1 = self.dataOut.pairsList[i][1]
823 # CSPCFactor= numpy.sum(ySamples[chan_index0]) * numpy.sum(ySamples[chan_index1])
824 # CSPCFactor= numpy.sum(ySamples[chan_index0]) * numpy.sum(ySamples[chan_index1])
824 #
825 #
825 #
826 #
826 # CSPCNorm= cspcLine.copy() / numpy.sqrt(CSPCFactor)
827 # CSPCNorm= cspcLine.copy() / numpy.sqrt(CSPCFactor)
827 #
828 #
828 #
829 #
829 # CSPCSamples[i] = CSPCNorm-self.noise[i]
830 # CSPCSamples[i] = CSPCNorm-self.noise[i]
830 # coherence[i] = numpy.abs(CSPCSamples[i]) / numpy.sqrt(CSPCFactor)
831 # coherence[i] = numpy.abs(CSPCSamples[i]) / numpy.sqrt(CSPCFactor)
831 #
832 #
832 # '''****** DC is removed ******'''
833 # '''****** DC is removed ******'''
833 # DC=Find(coherence[i],numpy.amax(coherence[i]))
834 # DC=Find(coherence[i],numpy.amax(coherence[i]))
834 # coherence[i][DC]=(coherence[i][DC-1]+coherence[i][DC+1])/2
835 # coherence[i][DC]=(coherence[i][DC-1]+coherence[i][DC+1])/2
835 # coherence[i]= moving_average(coherence[i],N=2)
836 # coherence[i]= moving_average(coherence[i],N=2)
836 #
837 #
837 # phase[i] = moving_average( numpy.arctan2(CSPCSamples[i].imag, CSPCSamples[i].real),N=1)#*180/numpy.pi
838 # phase[i] = moving_average( numpy.arctan2(CSPCSamples[i].imag, CSPCSamples[i].real),N=1)#*180/numpy.pi
838 #
839 #
839 #
840 #
840 # '''****** Getting fij width ******'''
841 # '''****** Getting fij width ******'''
841 #
842 #
842 # yMean=[]
843 # yMean=[]
843 # yMean2=[]
844 # yMean2=[]
844 #
845 #
845 # for j in range(len(ySamples[1])):
846 # for j in range(len(ySamples[1])):
846 # yMean=numpy.append(yMean,numpy.average([ySamples[0,j],ySamples[1,j],ySamples[2,j]]))
847 # yMean=numpy.append(yMean,numpy.average([ySamples[0,j],ySamples[1,j],ySamples[2,j]]))
847 #
848 #
848 # '''******* Getting fitting Gaussian ******'''
849 # '''******* Getting fitting Gaussian ******'''
849 # meanGauss=sum(xSamples*yMean) / len(xSamples)
850 # meanGauss=sum(xSamples*yMean) / len(xSamples)
850 # sigma=sum(yMean*(xSamples-meanGauss)**2) / len(xSamples)
851 # sigma=sum(yMean*(xSamples-meanGauss)**2) / len(xSamples)
851 # #print 'Height',Height,'SNR', meanGauss/sigma**2
852 # #print 'Height',Height,'SNR', meanGauss/sigma**2
852 #
853 #
853 # if (abs(meanGauss/sigma**2) > 0.0001) :
854 # if (abs(meanGauss/sigma**2) > 0.0001) :
854 #
855 #
855 # try:
856 # try:
856 # popt,pcov = curve_fit(gaus,xSamples,yMean,p0=[1,meanGauss,sigma])
857 # popt,pcov = curve_fit(gaus,xSamples,yMean,p0=[1,meanGauss,sigma])
857 #
858 #
858 # if numpy.amax(popt)>numpy.amax(yMean)*0.3:
859 # if numpy.amax(popt)>numpy.amax(yMean)*0.3:
859 # FitGauss=gaus(xSamples,*popt)
860 # FitGauss=gaus(xSamples,*popt)
860 #
861 #
861 # else:
862 # else:
862 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
863 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
863 # print 'Verificador: Dentro', Height
864 # print 'Verificador: Dentro', Height
864 # except RuntimeError:
865 # except RuntimeError:
865 #
866 #
866 # try:
867 # try:
867 # for j in range(len(ySamples[1])):
868 # for j in range(len(ySamples[1])):
868 # yMean2=numpy.append(yMean2,numpy.average([ySamples[1,j],ySamples[2,j]]))
869 # 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 # popt,pcov = curve_fit(gaus,xSamples,yMean2,p0=[1,meanGauss,sigma])
870 # FitGauss=gaus(xSamples,*popt)
871 # FitGauss=gaus(xSamples,*popt)
871 # print 'Verificador: Exepcion1', Height
872 # print 'Verificador: Exepcion1', Height
872 # except RuntimeError:
873 # except RuntimeError:
873 #
874 #
874 # try:
875 # try:
875 # popt,pcov = curve_fit(gaus,xSamples,ySamples[1],p0=[1,meanGauss,sigma])
876 # popt,pcov = curve_fit(gaus,xSamples,ySamples[1],p0=[1,meanGauss,sigma])
876 # FitGauss=gaus(xSamples,*popt)
877 # FitGauss=gaus(xSamples,*popt)
877 # print 'Verificador: Exepcion2', Height
878 # print 'Verificador: Exepcion2', Height
878 # except RuntimeError:
879 # except RuntimeError:
879 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
880 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
880 # print 'Verificador: Exepcion3', Height
881 # print 'Verificador: Exepcion3', Height
881 # else:
882 # else:
882 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
883 # FitGauss=numpy.ones(len(xSamples))*numpy.mean(yMean)
883 # #print 'Verificador: Fuera', Height
884 # #print 'Verificador: Fuera', Height
884 #
885 #
885 #
886 #
886 #
887 #
887 # Maximun=numpy.amax(yMean)
888 # Maximun=numpy.amax(yMean)
888 # eMinus1=Maximun*numpy.exp(-1)
889 # eMinus1=Maximun*numpy.exp(-1)
889 #
890 #
890 # HWpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-eMinus1)))
891 # HWpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-eMinus1)))
891 # HalfWidth= xFrec[HWpos]
892 # HalfWidth= xFrec[HWpos]
892 # GCpos=Find(FitGauss, numpy.amax(FitGauss))
893 # GCpos=Find(FitGauss, numpy.amax(FitGauss))
893 # Vpos=Find(FactNorm, numpy.amax(FactNorm))
894 # Vpos=Find(FactNorm, numpy.amax(FactNorm))
894 # #Vpos=numpy.sum(FactNorm)/len(FactNorm)
895 # #Vpos=numpy.sum(FactNorm)/len(FactNorm)
895 # #Vpos=Find(FactNorm, min(FactNorm, key=lambda value:abs(value- numpy.mean(FactNorm) )))
896 # #Vpos=Find(FactNorm, min(FactNorm, key=lambda value:abs(value- numpy.mean(FactNorm) )))
896 # #print 'GCpos',GCpos, numpy.amax(FitGauss), 'HWpos',HWpos
897 # #print 'GCpos',GCpos, numpy.amax(FitGauss), 'HWpos',HWpos
897 # '''****** Getting Fij ******'''
898 # '''****** Getting Fij ******'''
898 #
899 #
899 # GaussCenter=xFrec[GCpos]
900 # GaussCenter=xFrec[GCpos]
900 # if (GaussCenter<0 and HalfWidth>0) or (GaussCenter>0 and HalfWidth<0):
901 # if (GaussCenter<0 and HalfWidth>0) or (GaussCenter>0 and HalfWidth<0):
901 # Fij=abs(GaussCenter)+abs(HalfWidth)+0.0000001
902 # Fij=abs(GaussCenter)+abs(HalfWidth)+0.0000001
902 # else:
903 # else:
903 # Fij=abs(GaussCenter-HalfWidth)+0.0000001
904 # Fij=abs(GaussCenter-HalfWidth)+0.0000001
904 #
905 #
905 # '''****** Getting Frecuency range of significant data ******'''
906 # '''****** Getting Frecuency range of significant data ******'''
906 #
907 #
907 # Rangpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.10)))
908 # Rangpos=Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.10)))
908 #
909 #
909 # if Rangpos<GCpos:
910 # if Rangpos<GCpos:
910 # Range=numpy.array([Rangpos,2*GCpos-Rangpos])
911 # Range=numpy.array([Rangpos,2*GCpos-Rangpos])
911 # else:
912 # else:
912 # Range=numpy.array([2*GCpos-Rangpos,Rangpos])
913 # Range=numpy.array([2*GCpos-Rangpos,Rangpos])
913 #
914 #
914 # FrecRange=xFrec[Range[0]:Range[1]]
915 # FrecRange=xFrec[Range[0]:Range[1]]
915 #
916 #
916 # #print 'FrecRange', FrecRange
917 # #print 'FrecRange', FrecRange
917 # '''****** Getting SCPC Slope ******'''
918 # '''****** Getting SCPC Slope ******'''
918 #
919 #
919 # for i in range(self.nRdPairs):
920 # for i in range(self.nRdPairs):
920 #
921 #
921 # if len(FrecRange)>5 and len(FrecRange)<self.nProfiles*0.5:
922 # if len(FrecRange)>5 and len(FrecRange)<self.nProfiles*0.5:
922 # PhaseRange=moving_average(phase[i,Range[0]:Range[1]],N=3)
923 # PhaseRange=moving_average(phase[i,Range[0]:Range[1]],N=3)
923 #
924 #
924 # slope, intercept, r_value, p_value, std_err = stats.linregress(FrecRange,PhaseRange)
925 # slope, intercept, r_value, p_value, std_err = stats.linregress(FrecRange,PhaseRange)
925 # PhaseSlope[i]=slope
926 # PhaseSlope[i]=slope
926 # PhaseInter[i]=intercept
927 # PhaseInter[i]=intercept
927 # else:
928 # else:
928 # PhaseSlope[i]=0
929 # PhaseSlope[i]=0
929 # PhaseInter[i]=0
930 # PhaseInter[i]=0
930 #
931 #
931 # # plt.figure(i+15)
932 # # plt.figure(i+15)
932 # # plt.title('FASE ( CH%s*CH%s )' %(self.dataOut.pairsList[i][0],self.dataOut.pairsList[i][1]))
933 # # plt.title('FASE ( CH%s*CH%s )' %(self.dataOut.pairsList[i][0],self.dataOut.pairsList[i][1]))
933 # # plt.xlabel('Frecuencia (KHz)')
934 # # plt.xlabel('Frecuencia (KHz)')
934 # # plt.ylabel('Magnitud')
935 # # plt.ylabel('Magnitud')
935 # # #plt.subplot(311+i)
936 # # #plt.subplot(311+i)
936 # # plt.plot(FrecRange,PhaseRange,'b')
937 # # plt.plot(FrecRange,PhaseRange,'b')
937 # # plt.plot(FrecRange,FrecRange*PhaseSlope[i]+PhaseInter[i],'r')
938 # # plt.plot(FrecRange,FrecRange*PhaseSlope[i]+PhaseInter[i],'r')
938 #
939 #
939 # #plt.axis([-0.6, 0.2, -3.2, 3.2])
940 # #plt.axis([-0.6, 0.2, -3.2, 3.2])
940 #
941 #
941 #
942 #
942 # '''Getting constant C'''
943 # '''Getting constant C'''
943 # cC=(Fij*numpy.pi)**2
944 # cC=(Fij*numpy.pi)**2
944 #
945 #
945 # # '''Getting Eij and Nij'''
946 # # '''Getting Eij and Nij'''
946 # # (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
947 # # (AntennaX0,AntennaY0)=pol2cart(rheader.AntennaCoord0, rheader.AntennaAngl0*numpy.pi/180)
947 # # (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
948 # # (AntennaX1,AntennaY1)=pol2cart(rheader.AntennaCoord1, rheader.AntennaAngl1*numpy.pi/180)
948 # # (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
949 # # (AntennaX2,AntennaY2)=pol2cart(rheader.AntennaCoord2, rheader.AntennaAngl2*numpy.pi/180)
949 # #
950 # #
950 # # E01=AntennaX0-AntennaX1
951 # # E01=AntennaX0-AntennaX1
951 # # N01=AntennaY0-AntennaY1
952 # # N01=AntennaY0-AntennaY1
952 # #
953 # #
953 # # E02=AntennaX0-AntennaX2
954 # # E02=AntennaX0-AntennaX2
954 # # N02=AntennaY0-AntennaY2
955 # # N02=AntennaY0-AntennaY2
955 # #
956 # #
956 # # E12=AntennaX1-AntennaX2
957 # # E12=AntennaX1-AntennaX2
957 # # N12=AntennaY1-AntennaY2
958 # # N12=AntennaY1-AntennaY2
958 #
959 #
959 # '''****** Getting constants F and G ******'''
960 # '''****** Getting constants F and G ******'''
960 # MijEijNij=numpy.array([[E02,N02], [E12,N12]])
961 # MijEijNij=numpy.array([[E02,N02], [E12,N12]])
961 # MijResult0=(-PhaseSlope[1]*cC) / (2*numpy.pi)
962 # MijResult0=(-PhaseSlope[1]*cC) / (2*numpy.pi)
962 # MijResult1=(-PhaseSlope[2]*cC) / (2*numpy.pi)
963 # MijResult1=(-PhaseSlope[2]*cC) / (2*numpy.pi)
963 # MijResults=numpy.array([MijResult0,MijResult1])
964 # MijResults=numpy.array([MijResult0,MijResult1])
964 # (cF,cG) = numpy.linalg.solve(MijEijNij, MijResults)
965 # (cF,cG) = numpy.linalg.solve(MijEijNij, MijResults)
965 #
966 #
966 # '''****** Getting constants A, B and H ******'''
967 # '''****** Getting constants A, B and H ******'''
967 # W01=numpy.amax(coherence[0])
968 # W01=numpy.amax(coherence[0])
968 # W02=numpy.amax(coherence[1])
969 # W02=numpy.amax(coherence[1])
969 # W12=numpy.amax(coherence[2])
970 # W12=numpy.amax(coherence[2])
970 #
971 #
971 # WijResult0=((cF*E01+cG*N01)**2)/cC - numpy.log(W01 / numpy.sqrt(numpy.pi/cC))
972 # 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 # 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 # WijResult2=((cF*E12+cG*N12)**2)/cC - numpy.log(W12 / numpy.sqrt(numpy.pi/cC))
974 #
975 #
975 # WijResults=numpy.array([WijResult0, WijResult1, WijResult2])
976 # WijResults=numpy.array([WijResult0, WijResult1, WijResult2])
976 #
977 #
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 # 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 # (cA,cB,cH) = numpy.linalg.solve(WijEijNij, WijResults)
979 #
980 #
980 # VxVy=numpy.array([[cA,cH],[cH,cB]])
981 # VxVy=numpy.array([[cA,cH],[cH,cB]])
981 #
982 #
982 # VxVyResults=numpy.array([-cF,-cG])
983 # VxVyResults=numpy.array([-cF,-cG])
983 # (Vx,Vy) = numpy.linalg.solve(VxVy, VxVyResults)
984 # (Vx,Vy) = numpy.linalg.solve(VxVy, VxVyResults)
984 # Vzon = Vy
985 # Vzon = Vy
985 # Vmer = Vx
986 # Vmer = Vx
986 # Vmag=numpy.sqrt(Vzon**2+Vmer**2)
987 # Vmag=numpy.sqrt(Vzon**2+Vmer**2)
987 # Vang=numpy.arctan2(Vmer,Vzon)
988 # Vang=numpy.arctan2(Vmer,Vzon)
988 #
989 #
989 # if abs(Vy)<100 and abs(Vy)> 0.:
990 # if abs(Vy)<100 and abs(Vy)> 0.:
990 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, Vzon) #Vmag
991 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, Vzon) #Vmag
991 # #print 'Vmag',Vmag
992 # #print 'Vmag',Vmag
992 # else:
993 # else:
993 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, NaN)
994 # self.dataOut.velocityX=numpy.append(self.dataOut.velocityX, NaN)
994 #
995 #
995 # if abs(Vx)<100 and abs(Vx) > 0.:
996 # if abs(Vx)<100 and abs(Vx) > 0.:
996 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, Vmer) #Vang
997 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, Vmer) #Vang
997 # #print 'Vang',Vang
998 # #print 'Vang',Vang
998 # else:
999 # else:
999 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, NaN)
1000 # self.dataOut.velocityY=numpy.append(self.dataOut.velocityY, NaN)
1000 #
1001 #
1001 # if abs(GaussCenter)<2:
1002 # if abs(GaussCenter)<2:
1002 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, xFrec[Vpos])
1003 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, xFrec[Vpos])
1003 #
1004 #
1004 # else:
1005 # else:
1005 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, NaN)
1006 # self.dataOut.velocityV=numpy.append(self.dataOut.velocityV, NaN)
1006 #
1007 #
1007 #
1008 #
1008 # # print '********************************************'
1009 # # print '********************************************'
1009 # # print 'HalfWidth ', HalfWidth
1010 # # print 'HalfWidth ', HalfWidth
1010 # # print 'Maximun ', Maximun
1011 # # print 'Maximun ', Maximun
1011 # # print 'eMinus1 ', eMinus1
1012 # # print 'eMinus1 ', eMinus1
1012 # # print 'Rangpos ', Rangpos
1013 # # print 'Rangpos ', Rangpos
1013 # # print 'GaussCenter ',GaussCenter
1014 # # print 'GaussCenter ',GaussCenter
1014 # # print 'E01 ',E01
1015 # # print 'E01 ',E01
1015 # # print 'N01 ',N01
1016 # # print 'N01 ',N01
1016 # # print 'E02 ',E02
1017 # # print 'E02 ',E02
1017 # # print 'N02 ',N02
1018 # # print 'N02 ',N02
1018 # # print 'E12 ',E12
1019 # # print 'E12 ',E12
1019 # # print 'N12 ',N12
1020 # # print 'N12 ',N12
1020 # #print 'self.dataOut.velocityX ', self.dataOut.velocityX
1021 # #print 'self.dataOut.velocityX ', self.dataOut.velocityX
1021 # # print 'Fij ', Fij
1022 # # print 'Fij ', Fij
1022 # # print 'cC ', cC
1023 # # print 'cC ', cC
1023 # # print 'cF ', cF
1024 # # print 'cF ', cF
1024 # # print 'cG ', cG
1025 # # print 'cG ', cG
1025 # # print 'cA ', cA
1026 # # print 'cA ', cA
1026 # # print 'cB ', cB
1027 # # print 'cB ', cB
1027 # # print 'cH ', cH
1028 # # print 'cH ', cH
1028 # # print 'Vx ', Vx
1029 # # print 'Vx ', Vx
1029 # # print 'Vy ', Vy
1030 # # print 'Vy ', Vy
1030 # # print 'Vmag ', Vmag
1031 # # print 'Vmag ', Vmag
1031 # # print 'Vang ', Vang*180/numpy.pi
1032 # # print 'Vang ', Vang*180/numpy.pi
1032 # # print 'PhaseSlope ',PhaseSlope[0]
1033 # # print 'PhaseSlope ',PhaseSlope[0]
1033 # # print 'PhaseSlope ',PhaseSlope[1]
1034 # # print 'PhaseSlope ',PhaseSlope[1]
1034 # # print 'PhaseSlope ',PhaseSlope[2]
1035 # # print 'PhaseSlope ',PhaseSlope[2]
1035 # # print '********************************************'
1036 # # print '********************************************'
1036 # #print 'data_output',shape(self.dataOut.velocityX), shape(self.dataOut.velocityY)
1037 # #print 'data_output',shape(self.dataOut.velocityX), shape(self.dataOut.velocityY)
1037 #
1038 #
1038 # #print 'self.dataOut.velocityX', len(self.dataOut.velocityX)
1039 # #print 'self.dataOut.velocityX', len(self.dataOut.velocityX)
1039 # #print 'self.dataOut.velocityY', len(self.dataOut.velocityY)
1040 # #print 'self.dataOut.velocityY', len(self.dataOut.velocityY)
1040 # #print 'self.dataOut.velocityV', self.dataOut.velocityV
1041 # #print 'self.dataOut.velocityV', self.dataOut.velocityV
1041 #
1042 #
1042 # self.data_output[0]=numpy.array(self.dataOut.velocityX)
1043 # self.data_output[0]=numpy.array(self.dataOut.velocityX)
1043 # self.data_output[1]=numpy.array(self.dataOut.velocityY)
1044 # self.data_output[1]=numpy.array(self.dataOut.velocityY)
1044 # self.data_output[2]=numpy.array(self.dataOut.velocityV)
1045 # self.data_output[2]=numpy.array(self.dataOut.velocityV)
1045 #
1046 #
1046 # prin= self.data_output[0][~numpy.isnan(self.data_output[0])]
1047 # prin= self.data_output[0][~numpy.isnan(self.data_output[0])]
1047 # print ' '
1048 # print ' '
1048 # print 'VmagAverage',numpy.mean(prin)
1049 # print 'VmagAverage',numpy.mean(prin)
1049 # print ' '
1050 # print ' '
1050 # # plt.figure(5)
1051 # # plt.figure(5)
1051 # # plt.subplot(211)
1052 # # plt.subplot(211)
1052 # # plt.plot(self.dataOut.velocityX,'yo:')
1053 # # plt.plot(self.dataOut.velocityX,'yo:')
1053 # # plt.subplot(212)
1054 # # plt.subplot(212)
1054 # # plt.plot(self.dataOut.velocityY,'yo:')
1055 # # plt.plot(self.dataOut.velocityY,'yo:')
1055 #
1056 #
1056 # # plt.figure(1)
1057 # # plt.figure(1)
1057 # # # plt.subplot(121)
1058 # # # plt.subplot(121)
1058 # # # plt.plot(xFrec,ySamples[0],'k',label='Ch0')
1059 # # # plt.plot(xFrec,ySamples[0],'k',label='Ch0')
1059 # # # plt.plot(xFrec,ySamples[1],'g',label='Ch1')
1060 # # # plt.plot(xFrec,ySamples[1],'g',label='Ch1')
1060 # # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1061 # # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1061 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1062 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1062 # # # plt.legend()
1063 # # # plt.legend()
1063 # # plt.title('DATOS A ALTURA DE 2850 METROS')
1064 # # plt.title('DATOS A ALTURA DE 2850 METROS')
1064 # #
1065 # #
1065 # # plt.xlabel('Frecuencia (KHz)')
1066 # # plt.xlabel('Frecuencia (KHz)')
1066 # # plt.ylabel('Magnitud')
1067 # # plt.ylabel('Magnitud')
1067 # # # plt.subplot(122)
1068 # # # plt.subplot(122)
1068 # # # plt.title('Fit for Time Constant')
1069 # # # plt.title('Fit for Time Constant')
1069 # # #plt.plot(xFrec,zline)
1070 # # #plt.plot(xFrec,zline)
1070 # # #plt.plot(xFrec,SmoothSPC,'g')
1071 # # #plt.plot(xFrec,SmoothSPC,'g')
1071 # # plt.plot(xFrec,FactNorm)
1072 # # plt.plot(xFrec,FactNorm)
1072 # # plt.axis([-4, 4, 0, 0.15])
1073 # # plt.axis([-4, 4, 0, 0.15])
1073 # # # plt.xlabel('SelfSpectra KHz')
1074 # # # plt.xlabel('SelfSpectra KHz')
1074 # #
1075 # #
1075 # # plt.figure(10)
1076 # # plt.figure(10)
1076 # # # plt.subplot(121)
1077 # # # plt.subplot(121)
1077 # # plt.plot(xFrec,ySamples[0],'b',label='Ch0')
1078 # # plt.plot(xFrec,ySamples[0],'b',label='Ch0')
1078 # # plt.plot(xFrec,ySamples[1],'y',label='Ch1')
1079 # # plt.plot(xFrec,ySamples[1],'y',label='Ch1')
1079 # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1080 # # plt.plot(xFrec,ySamples[2],'r',label='Ch2')
1080 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1081 # # # plt.plot(xFrec,FitGauss,'yo:',label='fit')
1081 # # plt.legend()
1082 # # plt.legend()
1082 # # plt.title('SELFSPECTRA EN CANALES')
1083 # # plt.title('SELFSPECTRA EN CANALES')
1083 # #
1084 # #
1084 # # plt.xlabel('Frecuencia (KHz)')
1085 # # plt.xlabel('Frecuencia (KHz)')
1085 # # plt.ylabel('Magnitud')
1086 # # plt.ylabel('Magnitud')
1086 # # # plt.subplot(122)
1087 # # # plt.subplot(122)
1087 # # # plt.title('Fit for Time Constant')
1088 # # # plt.title('Fit for Time Constant')
1088 # # #plt.plot(xFrec,zline)
1089 # # #plt.plot(xFrec,zline)
1089 # # #plt.plot(xFrec,SmoothSPC,'g')
1090 # # #plt.plot(xFrec,SmoothSPC,'g')
1090 # # # plt.plot(xFrec,FactNorm)
1091 # # # plt.plot(xFrec,FactNorm)
1091 # # # plt.axis([-4, 4, 0, 0.15])
1092 # # # plt.axis([-4, 4, 0, 0.15])
1092 # # # plt.xlabel('SelfSpectra KHz')
1093 # # # plt.xlabel('SelfSpectra KHz')
1093 # #
1094 # #
1094 # # plt.figure(9)
1095 # # plt.figure(9)
1095 # #
1096 # #
1096 # #
1097 # #
1097 # # plt.title('DATOS SUAVIZADOS')
1098 # # plt.title('DATOS SUAVIZADOS')
1098 # # plt.xlabel('Frecuencia (KHz)')
1099 # # plt.xlabel('Frecuencia (KHz)')
1099 # # plt.ylabel('Magnitud')
1100 # # plt.ylabel('Magnitud')
1100 # # plt.plot(xFrec,SmoothSPC,'g')
1101 # # plt.plot(xFrec,SmoothSPC,'g')
1101 # #
1102 # #
1102 # # #plt.plot(xFrec,FactNorm)
1103 # # #plt.plot(xFrec,FactNorm)
1103 # # plt.axis([-4, 4, 0, 0.15])
1104 # # plt.axis([-4, 4, 0, 0.15])
1104 # # # plt.xlabel('SelfSpectra KHz')
1105 # # # plt.xlabel('SelfSpectra KHz')
1105 # # #
1106 # # #
1106 # # plt.figure(2)
1107 # # plt.figure(2)
1107 # # # #plt.subplot(121)
1108 # # # #plt.subplot(121)
1108 # # plt.plot(xFrec,yMean,'r',label='Mean SelfSpectra')
1109 # # plt.plot(xFrec,yMean,'r',label='Mean SelfSpectra')
1109 # # plt.plot(xFrec,FitGauss,'yo:',label='Ajuste Gaussiano')
1110 # # 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[Rangpos],FitGauss[Find(FitGauss,min(FitGauss, key=lambda value:abs(value-Maximun*0.1)))],'bo')
1111 # # # #plt.plot(xFrec,phase)
1112 # # # #plt.plot(xFrec,phase)
1112 # # # plt.xlabel('Suavizado, promediado KHz')
1113 # # # plt.xlabel('Suavizado, promediado KHz')
1113 # # plt.title('SELFSPECTRA PROMEDIADO')
1114 # # plt.title('SELFSPECTRA PROMEDIADO')
1114 # # # #plt.subplot(122)
1115 # # # #plt.subplot(122)
1115 # # # #plt.plot(xSamples,zline)
1116 # # # #plt.plot(xSamples,zline)
1116 # # plt.xlabel('Frecuencia (KHz)')
1117 # # plt.xlabel('Frecuencia (KHz)')
1117 # # plt.ylabel('Magnitud')
1118 # # plt.ylabel('Magnitud')
1118 # # plt.legend()
1119 # # plt.legend()
1119 # # #
1120 # # #
1120 # # # plt.figure(3)
1121 # # # plt.figure(3)
1121 # # # plt.subplot(311)
1122 # # # plt.subplot(311)
1122 # # # #plt.plot(xFrec,phase[0])
1123 # # # #plt.plot(xFrec,phase[0])
1123 # # # plt.plot(xFrec,phase[0],'g')
1124 # # # plt.plot(xFrec,phase[0],'g')
1124 # # # plt.subplot(312)
1125 # # # plt.subplot(312)
1125 # # # plt.plot(xFrec,phase[1],'g')
1126 # # # plt.plot(xFrec,phase[1],'g')
1126 # # # plt.subplot(313)
1127 # # # plt.subplot(313)
1127 # # # plt.plot(xFrec,phase[2],'g')
1128 # # # plt.plot(xFrec,phase[2],'g')
1128 # # # #plt.plot(xFrec,phase[2])
1129 # # # #plt.plot(xFrec,phase[2])
1129 # # #
1130 # # #
1130 # # # plt.figure(4)
1131 # # # plt.figure(4)
1131 # # #
1132 # # #
1132 # # # plt.plot(xSamples,coherence[0],'b')
1133 # # # plt.plot(xSamples,coherence[0],'b')
1133 # # # plt.plot(xSamples,coherence[1],'r')
1134 # # # plt.plot(xSamples,coherence[1],'r')
1134 # # # plt.plot(xSamples,coherence[2],'g')
1135 # # # plt.plot(xSamples,coherence[2],'g')
1135 # # plt.show()
1136 # # plt.show()
1136 # # #
1137 # # #
1137 # # # plt.clf()
1138 # # # plt.clf()
1138 # # # plt.cla()
1139 # # # plt.cla()
1139 # # # plt.close()
1140 # # # plt.close()
1140 #
1141 #
1141 # print ' '
1142 # print ' '
1142
1143
1143
1144
1144
1145
1145 self.BlockCounter+=2
1146 self.BlockCounter+=2
1146
1147
1147 else:
1148 else:
1148 self.fileSelector+=1
1149 self.fileSelector+=1
1149 self.BlockCounter=0
1150 self.BlockCounter=0
1150 print "Next File"
1151 print "Next File"
1151
1152
1152
1153
1153
1154
1154 class BLTRWriter(ProcessingUnit):
1155 class BLTRWriter(ProcessingUnit):
1155 '''
1156 '''
1156 classdocs
1157 classdocs
1157 '''
1158 '''
1158
1159
1159 def __init__(self):
1160 def __init__(self):
1160 '''
1161 '''
1161 Constructor
1162 Constructor
1162 '''
1163 '''
1163 self.dataOut = None
1164 self.dataOut = None
1164
1165
1165 self.isConfig = False
1166 self.isConfig = False
1166
1167
1167 def setup(self, dataIn, path, blocksPerFile, set=0, ext=None):
1168 def setup(self, dataIn, path, blocksPerFile, set=0, ext=None):
1168 '''
1169 '''
1169 In this method we should set all initial parameters.
1170 In this method we should set all initial parameters.
1170
1171
1171 Input:
1172 Input:
1172 dataIn : Input data will also be outputa data
1173 dataIn : Input data will also be outputa data
1173
1174
1174 '''
1175 '''
1175 self.dataOut = dataIn
1176 self.dataOut = dataIn
1176
1177
1177 self.isConfig = True
1178 self.isConfig = True
1178
1179
1179 return
1180 return
1180
1181
1181 def run(self, dataIn, **kwargs):
1182 def run(self, dataIn, **kwargs):
1182 '''
1183 '''
1183 This method will be called many times so here you should put all your code
1184 This method will be called many times so here you should put all your code
1184
1185
1185 Inputs:
1186 Inputs:
1186
1187
1187 dataIn : object with the data
1188 dataIn : object with the data
1188
1189
1189 '''
1190 '''
1190
1191
1191 if not self.isConfig:
1192 if not self.isConfig:
1192 self.setup(dataIn, **kwargs)
1193 self.setup(dataIn, **kwargs)
1193
1194
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
1 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
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 NO CONTENT: modified file, binary diff hidden
NO CONTENT: modified file, binary diff hidden
@@ -1,1 +1,1
1 <Project description="read bltr data sswma file" id="191" name="test1"><ReadUnit datatype="testBLTRReader" id="1911" inputId="0" name="testBLTRReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="testBLTRReader" /><Parameter format="str" id="191112" name="path" value="/media/erick/6F60F7113095A154/BLTR" /><Parameter format="date" id="191113" name="startDate" value="2017/01/17" /><Parameter format="date" id="191114" name="endDate" value="2018/01/01" /><Parameter format="time" id="191115" name="startTime" value="00:00:00" /><Parameter format="time" id="191116" name="endTime" value="23:59:59" /><Parameter format="str" id="191118" name="ext" value="sswma" /></Operation></ReadUnit><ProcUnit datatype="BLTRProcess" id="1912" inputId="1911" name="BLTRProcess"><Operation id="19121" name="run" priority="1" type="self" /><Operation id="19122" name="SnrFilter" priority="2" type="self"><Parameter format="float" id="191221" name="snr_val" value="-20" /><Parameter format="int" id="191222" name="modetofilter" value="2" /></Operation><Operation id="19123" name="OutliersFilter" priority="3" type="self"><Parameter format="str" id="191231" name="svalue" value="meridional" /><Parameter format="str" id="191232" name="svalue2" value="inTime" /><Parameter format="float" id="191233" name="method" value="0" /><Parameter format="float" id="191234" name="factor" value="2" /><Parameter format="float" id="191235" name="filter" value="0" /><Parameter format="float" id="191236" name="npoints" value="9" /><Parameter format="int" id="191237" name="modetofilter" value="2" /></Operation><Operation id="19124" name="OutliersFilter" priority="4" type="self"><Parameter format="str" id="191241" name="svalue" value="zonal" /><Parameter format="str" id="191242" name="svalue2" value="inTime" /><Parameter format="float" id="191243" name="method" value="0" /><Parameter format="float" id="191244" name="factor" value="2" /><Parameter format="float" id="191245" name="filter" value="0" /><Parameter format="float" id="191246" name="npoints" value="9" /><Parameter format="int" id="191247" name="modetofilter" value="2" /></Operation><Operation id="19125" name="OutliersFilter" priority="5" type="self"><Parameter format="str" id="191251" name="svalue" value="vertical" /><Parameter format="str" id="191252" name="svalue2" value="inHeight" /><Parameter format="float" id="191253" name="method" value="0" /><Parameter format="float" id="191254" name="factor" value="2" /><Parameter format="float" id="191255" name="filter" value="0" /><Parameter format="float" id="191256" name="npoints" value="9" /><Parameter format="int" id="191257" name="modetofilter" value="2" /></Operation><Operation id="19126" name="prePlot" priority="6" type="self"><Parameter format="int" id="191261" name="modeselect" value="1" /></Operation><Operation id="19127" name="WindProfilerPlot" priority="7" type="other"><Parameter format="int" id="191271" name="id" value="1" /><Parameter format="str" id="191272" name="wintitle" value="" /><Parameter format="intlist" id="191273" name="channelList" value="0" /><Parameter format="int" id="191274" name="SNRmin" value="-10" /><Parameter format="int" id="191275" name="SNRmax" value="50" /><Parameter format="float" id="191276" name="SNRthresh" value="0" /><Parameter format="float" id="191277" name="xmin" value="0" /><Parameter format="float" id="191278" name="xmax" value="24" /><Parameter format="float" id="191279" name="ymax" value="3" /><Parameter format="float" id="191280" name="zmin" value="-20" /><Parameter format="float" id="191281" name="zmax" value="20" /><Parameter format="float" id="191282" name="zmin_ver" value="-200" /><Parameter format="float" id="191283" name="zmax_ver" value="200" /></Operation><Operation id="19128" name="prePlot" priority="8" type="self"><Parameter format="int" id="191281" name="modeselect" value="2" /></Operation><Operation id="19129" name="WindProfilerPlot" priority="9" type="other"><Parameter format="int" id="191291" name="id" value="2" /><Parameter format="str" id="191292" name="wintitle" value="" /><Parameter format="bool" id="191293" name="save" value="1" /><Parameter format="str" id="191294" name="figpath" value="/media/erick/6F60F7113095A154/BLTR/" /><Parameter format="int" id="191295" name="SNRmin" value="-20" /><Parameter format="int" id="191296" name="SNRmax" value="40" /><Parameter format="float" id="191297" name="SNRthresh" value="0" /><Parameter format="float" id="191298" name="xmin" value="0" /><Parameter format="float" id="191299" name="xmax" value="24" /><Parameter format="float" id="191300" name="ymin" value="0" /><Parameter format="float" id="191301" name="ymax" value="10" /><Parameter format="float" id="191302" name="zmin" value="-4" /><Parameter format="float" id="191303" name="zmax" value="4" /><Parameter format="float" id="191304" name="zmin_ver" value="-200" /><Parameter format="float" id="191305" name="zmax_ver" value="200" /></Operation></ProcUnit></Project> No newline at end of file
1 <Project description="Segundo Test" id="191" name="test01"><ReadUnit datatype="VoltageReader" id="1911" inputId="0" name="VoltageReader"><Operation id="19111" name="run" priority="1" type="self"><Parameter format="str" id="191111" name="datatype" value="VoltageReader" /><Parameter format="str" id="191112" name="path" value="/home/erick/Documents/Data/Claire_Data/raw" /><Parameter format="date" id="191113" name="startDate" value="2017/07/26" /><Parameter format="date" id="191114" name="endDate" value="2017/07/26" /><Parameter format="time" id="191115" name="startTime" value="10:02:00" /><Parameter format="time" id="191116" name="endTime" value="10:11:00" /><Parameter format="int" id="191118" name="online" value="0" /><Parameter format="int" id="191119" name="walk" value="1" /></Operation><Operation id="19112" name="printNumberOfBlock" priority="2" type="self" /></ReadUnit><ProcUnit datatype="SpectraProc" id="1913" inputId="1912" name="SpectraProc"><Operation id="19131" name="run" priority="1" type="self"><Parameter format="int" id="191311" name="nFFTPoints" value="128" /><Parameter format="pairslist" id="191312" name="pairsList" value="(0,1),(0,2),(1,2)" /></Operation><Operation id="19132" name="removeDC" priority="2" type="self" /><Operation id="19133" name="IncohInt" priority="3" type="external"><Parameter format="float" id="191331" name="n" value="30" /></Operation><Operation id="19134" name="CrossSpectraPlot" priority="4" type="other"><Parameter format="str" id="191341" name="phase_cmap" value="bwr" /><Parameter format="int" id="191342" name="id" value="2005" /><Parameter format="str" id="191343" name="wintitle" value="CrossSpectraPlot_ShortPulse" /><Parameter format="str" id="191344" name="xaxis" value="Velocity" /><Parameter format="float" id="191345" name="ymin" value="1" /><Parameter format="int" id="191346" name="ymax" value="7" /><Parameter format="int" id="191347" name="zmin" value="15" /><Parameter format="int" id="191348" name="zmax" value="60" /><Parameter format="int" id="191349" name="save" value="2" /><Parameter format="str" id="191350" name="figpath" value="/media/erick/6F60F7113095A154/CLAIRE/CLAIRE_WINDS_2MHZ/Images" /></Operation></ProcUnit><ProcUnit datatype="VoltageProc" id="1912" inputId="1911" name="VoltageProc"><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="selectHeights" priority="3" type="self"><Parameter format="float" id="191231" name="minHei" value="0" /><Parameter format="float" id="191232" name="maxHei" value="64" /></Operation></ProcUnit><ProcUnit datatype="Parameters" id="1914" inputId="1913" name="ParametersProc"><Operation id="19141" name="run" priority="1" type="self" /><Operation id="19142" name="GaussianFit" priority="2" type="other" /></ProcUnit></Project> No newline at end of file
@@ -1,171 +1,171
1 '''
1 '''
2 Created on Nov 09, 2016
2 Created on Nov 09, 2016
3
3
4 @author: roj- LouVD
4 @author: roj- LouVD
5 '''
5 '''
6 import os, sys
6 import os, sys
7
7
8
8
9 path = os.path.split(os.getcwd())[0]
9 path = os.path.split(os.getcwd())[0]
10 path = os.path.split(path)[0]
10 path = os.path.split(path)[0]
11
11
12 sys.path.insert(0, path)
12 sys.path.insert(0, path)
13
13
14 from schainpy.controller import Project
14 from schainpy.controller import Project
15
15
16 filename = 'test1.xml'
16 filename = 'test1.xml'
17 # path = '/home/jespinoza/workspace/data/bltr/'
17 # path = '/home/jespinoza/workspace/data/bltr/'
18 path = '/media/erick/6F60F7113095A154/BLTR/'
18 path = '/media/erick/6F60F7113095A154/BLTR/'
19 desc = "read bltr data sswma file"
19 desc = "read bltr data sswma file"
20 figpath = '/media/erick/6F60F7113095A154/BLTR/'
20 figpath = '/media/erick/6F60F7113095A154/BLTR/'
21 pathhdf5 = '/tmp/'
21 pathhdf5 = '/tmp/'
22
22
23 controllerObj = Project()
23 controllerObj = Project()
24
24
25 controllerObj.setup(id = '191', name='test1', description=desc)
25 controllerObj.setup(id = '191', name='test1', description=desc)
26 readUnitConfObj = controllerObj.addReadUnit(datatype='testBLTRReader',
26 readUnitConfObj = controllerObj.addReadUnit(datatype='testBLTRReader',
27 path=path,
27 path=path,
28 startDate='2017/01/17',
28 startDate='2017/01/17',
29 endDate='2018/01/01',
29 endDate='2018/01/01',
30 startTime='00:00:00',
30 startTime='00:00:00',
31 endTime='23:59:59',
31 endTime='23:59:59',
32 ext='sswma')
32 ext='sswma')
33
33
34 procUnitConfObj1 = controllerObj.addProcUnit(datatype='BLTRProcess',
34 procUnitConfObj1 = controllerObj.addProcUnit(datatype='BLTRProcess',
35 inputId=readUnitConfObj.getId())
35 inputId=readUnitConfObj.getId())
36
36
37 '''-------------------------------------------Processing--------------------------------------------'''
37 '''-------------------------------------------Processing--------------------------------------------'''
38
38
39 '''MODE 1: LOW ATMOSPHERE: 0- 3 km'''
39 '''MODE 1: LOW ATMOSPHERE: 0- 3 km'''
40 # opObj10 = procUnitConfObj1.addOperation(name='SnrFilter')
40 # opObj10 = procUnitConfObj1.addOperation(name='SnrFilter')
41 # opObj10.addParameter(name='snr_val', value='-10', format='float')
41 # opObj10.addParameter(name='snr_val', value='-10', format='float')
42 # opObj10.addParameter(name='modetofilter', value='1', format='int')
42 # opObj10.addParameter(name='modetofilter', value='1', format='int')
43 #
43 #
44 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
44 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
45 # opObj10.addParameter(name='svalue', value='meridional', format='str')
45 # opObj10.addParameter(name='svalue', value='meridional', format='str')
46 # opObj10.addParameter(name='svalue2', value='inTime', format='str')
46 # opObj10.addParameter(name='svalue2', value='inTime', format='str')
47 # opObj10.addParameter(name='method', value='0', format='float')
47 # opObj10.addParameter(name='method', value='0', format='float')
48 # opObj10.addParameter(name='factor', value='1', format='float')
48 # opObj10.addParameter(name='factor', value='1', format='float')
49 # opObj10.addParameter(name='filter', value='0', format='float')
49 # opObj10.addParameter(name='filter', value='0', format='float')
50 # opObj10.addParameter(name='npoints', value='5', format='float')
50 # opObj10.addParameter(name='npoints', value='5', format='float')
51 # opObj10.addParameter(name='modetofilter', value='1', format='int')
51 # opObj10.addParameter(name='modetofilter', value='1', format='int')
52 # #
52 # #
53 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
53 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
54 # opObj10.addParameter(name='svalue', value='zonal', format='str')
54 # opObj10.addParameter(name='svalue', value='zonal', format='str')
55 # opObj10.addParameter(name='svalue2', value='inTime', format='str')
55 # opObj10.addParameter(name='svalue2', value='inTime', format='str')
56 # opObj10.addParameter(name='method', value='0', format='float')
56 # opObj10.addParameter(name='method', value='0', format='float')
57 # opObj10.addParameter(name='factor', value='1', format='float')
57 # opObj10.addParameter(name='factor', value='1', format='float')
58 # opObj10.addParameter(name='filter', value='0', format='float')
58 # opObj10.addParameter(name='filter', value='0', format='float')
59 # opObj10.addParameter(name='npoints', value='5', format='float')
59 # opObj10.addParameter(name='npoints', value='5', format='float')
60 # opObj10.addParameter(name='modetofilter', value='1', format='int')
60 # opObj10.addParameter(name='modetofilter', value='1', format='int')
61 # #
61 # #
62 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
62 # opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
63 # opObj10.addParameter(name='svalue', value='vertical', format='str')
63 # opObj10.addParameter(name='svalue', value='vertical', format='str')
64 # opObj10.addParameter(name='svalue2', value='inHeight', format='str')
64 # opObj10.addParameter(name='svalue2', value='inHeight', format='str')
65 # opObj10.addParameter(name='method', value='0', format='float')
65 # opObj10.addParameter(name='method', value='0', format='float')
66 # opObj10.addParameter(name='factor', value='2', format='float')
66 # opObj10.addParameter(name='factor', value='2', format='float')
67 # opObj10.addParameter(name='filter', value='0', format='float')
67 # opObj10.addParameter(name='filter', value='0', format='float')
68 # opObj10.addParameter(name='npoints', value='9', format='float')
68 # opObj10.addParameter(name='npoints', value='9', format='float')
69 # opObj10.addParameter(name='modetofilter', value='1', format='int')
69 # opObj10.addParameter(name='modetofilter', value='1', format='int')
70 #
70 #
71
71
72 ''' MODE 2: 0 - 10 km '''
72 ''' MODE 2: 0 - 10 km '''
73
73
74 opObj10 = procUnitConfObj1.addOperation(name='SnrFilter')
74 opObj10 = procUnitConfObj1.addOperation(name='SnrFilter')
75 opObj10.addParameter(name='snr_val', value='-20', format='float')
75 opObj10.addParameter(name='snr_val', value='-20', format='float')
76 opObj10.addParameter(name='modetofilter', value='2', format='int')
76 opObj10.addParameter(name='modetofilter', value='2', format='int')
77
77
78 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
78 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
79 opObj10.addParameter(name='svalue', value='meridional', format='str')
79 opObj10.addParameter(name='svalue', value='meridional', format='str')
80 opObj10.addParameter(name='svalue2', value='inTime', format='str')
80 opObj10.addParameter(name='svalue2', value='inTime', format='str')
81 opObj10.addParameter(name='method', value='0', format='float')
81 opObj10.addParameter(name='method', value='0', format='float')
82 opObj10.addParameter(name='factor', value='2', format='float')
82 opObj10.addParameter(name='factor', value='2', format='float')
83 opObj10.addParameter(name='filter', value='0', format='float')
83 opObj10.addParameter(name='filter', value='0', format='float')
84 opObj10.addParameter(name='npoints', value='9', format='float')
84 opObj10.addParameter(name='npoints', value='9', format='float')
85 opObj10.addParameter(name='modetofilter', value='2', format='int')
85 opObj10.addParameter(name='modetofilter', value='2', format='int')
86 # #
86 # #
87 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
87 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
88 opObj10.addParameter(name='svalue', value='zonal', format='str')
88 opObj10.addParameter(name='svalue', value='zonal', format='str')
89 opObj10.addParameter(name='svalue2', value='inTime', format='str')
89 opObj10.addParameter(name='svalue2', value='inTime', format='str')
90 opObj10.addParameter(name='method', value='0', format='float')
90 opObj10.addParameter(name='method', value='0', format='float')
91 opObj10.addParameter(name='factor', value='2', format='float')
91 opObj10.addParameter(name='factor', value='2', format='float')
92 opObj10.addParameter(name='filter', value='0', format='float')
92 opObj10.addParameter(name='filter', value='0', format='float')
93 opObj10.addParameter(name='npoints', value='9', format='float')
93 opObj10.addParameter(name='npoints', value='9', format='float')
94 opObj10.addParameter(name='modetofilter', value='2', format='int')
94 opObj10.addParameter(name='modetofilter', value='2', format='int')
95 # #
95 # #
96 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
96 opObj10 = procUnitConfObj1.addOperation(name='OutliersFilter')
97 opObj10.addParameter(name='svalue', value='vertical', format='str')
97 opObj10.addParameter(name='svalue', value='vertical', format='str')
98 opObj10.addParameter(name='svalue2', value='inHeight', format='str')
98 opObj10.addParameter(name='svalue2', value='inHeight', format='str')
99 opObj10.addParameter(name='method', value='0', format='float')
99 opObj10.addParameter(name='method', value='0', format='float')
100 opObj10.addParameter(name='factor', value='2', format='float')
100 opObj10.addParameter(name='factor', value='2', format='float')
101 opObj10.addParameter(name='filter', value='0', format='float')
101 opObj10.addParameter(name='filter', value='0', format='float')
102 opObj10.addParameter(name='npoints', value='9', format='float')
102 opObj10.addParameter(name='npoints', value='9', format='float')
103 opObj10.addParameter(name='modetofilter', value='2', format='int')
103 opObj10.addParameter(name='modetofilter', value='2', format='int')
104
104
105 # '''-----------------------------------------Writing-------------------------------------------'''
105 # '''-----------------------------------------Writing-------------------------------------------'''
106 #
106 #
107 # # opObj10 = procUnitConfObj1.addOperation(name='testBLTRWriter',optype='other')
107 # # opObj10 = procUnitConfObj1.addOperation(name='testBLTRWriter',optype='other')
108 # # opObj10.addParameter(name='path', value = pathhdf5)
108 # # opObj10.addParameter(name='path', value = pathhdf5)
109 # # opObj10.addParameter(name='modetowrite', value = '2',format='int')
109 # # opObj10.addParameter(name='modetowrite', value = '2',format='int')
110 # #
110 # #
111 # # opObj10 = procUnitConfObj1.addOperation(name='testBLTRWriter',optype='other')
111 # # opObj10 = procUnitConfObj1.addOperation(name='testBLTRWriter',optype='other')
112 # # opObj10.addParameter(name='path', value = pathhdf5)
112 # # opObj10.addParameter(name='path', value = pathhdf5)
113 # # opObj10.addParameter(name='modetowrite', value = '1',format='int')
113 # # opObj10.addParameter(name='modetowrite', value = '1',format='int')
114 #
114 #
115 # '''----------------------------------------Plotting--------------------------------------------'''
115 # '''----------------------------------------Plotting--------------------------------------------'''
116 #
116 #
117 opObj10 = procUnitConfObj1.addOperation(name='prePlot')
117 opObj10 = procUnitConfObj1.addOperation(name='prePlot')
118 opObj10.addParameter(name='modeselect',value='1',format='int')
118 opObj10.addParameter(name='modeselect',value='1',format='int')
119 # #
119 # #
120 opObj10 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other')
120 opObj10 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other')
121 opObj10.addParameter(name='id', value='1', format='int')
121 opObj10.addParameter(name='id', value='1', format='int')
122 opObj10.addParameter(name='wintitle', value='', format='str')
122 opObj10.addParameter(name='wintitle', value='', format='str')
123 opObj10.addParameter(name='channelList', value='0', format='intlist')
123 opObj10.addParameter(name='channelList', value='0', format='intlist')
124 #opObj10.addParameter(name='save', value='1', format='bool')
124 #opObj10.addParameter(name='save', value='1', format='bool')
125 #opObj10.addParameter(name='figpath', value=figpath, format='str')
125 #opObj10.addParameter(name='figpath', value=figpath, format='str')
126 opObj10.addParameter(name='SNRmin', value='-10', format='int')
126 opObj10.addParameter(name='SNRmin', value='-10', format='int')
127 opObj10.addParameter(name='SNRmax', value='50', format='int')
127 opObj10.addParameter(name='SNRmax', value='50', format='int')
128 opObj10.addParameter(name='SNRthresh', value='0', format='float')
128 opObj10.addParameter(name='SNRthresh', value='0', format='float')
129 opObj10.addParameter(name='xmin', value='0', format='float')
129 opObj10.addParameter(name='xmin', value='0', format='float')
130 opObj10.addParameter(name='xmax', value='24', format='float')
130 opObj10.addParameter(name='xmax', value='24', format='float')
131 opObj10.addParameter(name='ymax', value='3', format='float')
131 opObj10.addParameter(name='ymax', value='3', format='float')
132 opObj10.addParameter(name='zmin', value='-20', format='float')
132 opObj10.addParameter(name='zmin', value='-20', format='float')
133 opObj10.addParameter(name='zmax', value='20', format='float')
133 opObj10.addParameter(name='zmax', value='20', format='float')
134 opObj10.addParameter(name='zmin_ver', value='-200', format='float')
134 opObj10.addParameter(name='zmin_ver', value='-200', format='float')
135 opObj10.addParameter(name='zmax_ver', value='200', format='float')
135 opObj10.addParameter(name='zmax_ver', value='200', format='float')
136 #opObj10.addParameter(name='showprofile', value='1', format='bool')
136 #opObj10.addParameter(name='showprofile', value='1', format='bool')
137 #opObj10.addParameter(name='show', value='1', format='bool')
137 #opObj10.addParameter(name='show', value='1', format='bool')
138
138
139 opObj10 = procUnitConfObj1.addOperation(name='prePlot')
139 opObj10 = procUnitConfObj1.addOperation(name='prePlot')
140 opObj10.addParameter(name='modeselect',value='2',format='int')
140 opObj10.addParameter(name='modeselect',value='2',format='int')
141 #
141 #
142 opObj10 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other')
142 opObj10 = procUnitConfObj1.addOperation(name='WindProfilerPlot', optype='other')
143 opObj10.addParameter(name='id', value='2', format='int')
143 opObj10.addParameter(name='id', value='2', format='int')
144 opObj10.addParameter(name='wintitle', value='', format='str')
144 opObj10.addParameter(name='wintitle', value='', format='str')
145 #opObj10.addParameter(name='channelList', value='0', format='intlist')
145 #opObj10.addParameter(name='channelList', value='0', format='intlist')
146 opObj10.addParameter(name='save', value='1', format='bool')
146 opObj10.addParameter(name='save', value='1', format='bool')
147 opObj10.addParameter(name='figpath', value=figpath, format='str')
147 opObj10.addParameter(name='figpath', value=figpath, format='str')
148 opObj10.addParameter(name='SNRmin', value='-20', format='int')
148 opObj10.addParameter(name='SNRmin', value='-20', format='int')
149 opObj10.addParameter(name='SNRmax', value='40', format='int')
149 opObj10.addParameter(name='SNRmax', value='40', format='int')
150 opObj10.addParameter(name='SNRthresh', value='0', format='float')
150 opObj10.addParameter(name='SNRthresh', value='0', format='float')
151 opObj10.addParameter(name='xmin', value='0', format='float')
151 opObj10.addParameter(name='xmin', value='0', format='float')
152 opObj10.addParameter(name='xmax', value='24', format='float')
152 opObj10.addParameter(name='xmax', value='24', format='float')
153 opObj10.addParameter(name='ymin', value='0', format='float')
153 opObj10.addParameter(name='ymin', value='0', format='float')
154 opObj10.addParameter(name='ymax', value='10', format='float')
154 opObj10.addParameter(name='ymax', value='7', format='float')
155 opObj10.addParameter(name='zmin', value='-4', format='float')
155 opObj10.addParameter(name='zmin', value='-4', format='float')
156 opObj10.addParameter(name='zmax', value='4', format='float')
156 opObj10.addParameter(name='zmax', value='4', format='float')
157 opObj10.addParameter(name='zmin_ver', value='-200', format='float')
157 opObj10.addParameter(name='zmin_ver', value='-200', format='float')
158 opObj10.addParameter(name='zmax_ver', value='200', format='float')
158 opObj10.addParameter(name='zmax_ver', value='200', format='float')
159 #opObj10.addParameter(name='showprofile', value='1', format='bool')
159 #opObj10.addParameter(name='showprofile', value='1', format='bool')
160 #opObj10.addParameter(name='show', value='1', format='bool')
160 #opObj10.addParameter(name='show', value='1', format='bool')
161
161
162 # # print "Escribiendo el archivo XML"
162 # # print "Escribiendo el archivo XML"
163 # controllerObj.writeXml(filename)
163 # controllerObj.writeXml(filename)
164 # # print "Leyendo el archivo XML"
164 # # print "Leyendo el archivo XML"
165 # controllerObj.readXml(filename)
165 # controllerObj.readXml(filename)
166
166
167 # controllerObj.createObjects()
167 # controllerObj.createObjects()
168 # controllerObj.connectObjects()
168 # controllerObj.connectObjects()
169 # controllerObj.run()
169 # controllerObj.run()
170 controllerObj.start()
170 controllerObj.start()
171
171
@@ -1,150 +1,151
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 = '/media/erick/6F60F7113095A154/BLTR'
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='BLTRReader',
23 readUnitConfObj = controllerObj.addReadUnit(datatype='BLTRReader',
24 path='/media/erick/6F60F7113095A154/BLTR/',
24 path='/media/erick/6F60F7113095A154/BLTR/',
25
25
26 endDate='2017/10/19',
26 endDate='2017/10/19',
27 startTime='13:00:00',
27 startTime='13:00:00',
28 startDate='2016/11/8',
28 startDate='2016/11/8',
29 endTime='23:59:59',
29 endTime='23:59:59',
30
30
31
31
32 online=0,
32 online=0,
33 walk=0,
33 walk=0,
34 ReadMode='1')
34 ReadMode='1')
35 # expLabel='')
35 # expLabel='')
36
36
37 # opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
37 # opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock')
38
38
39 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
39 procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId())
40
40
41
41
42
42
43 opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
43 opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other')
44 opObj11.addParameter(name='n', value='3', format='float')
44 opObj11.addParameter(name='n', value='3', format='float')
45
45
46 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
46 opObj10 = procUnitConfObj1.addOperation(name='removeDC')
47
47
48 # opObj10 = procUnitConfObj1.addOperation(name='calcMag')
48 # opObj10 = procUnitConfObj1.addOperation(name='calcMag')
49
49
50 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
50 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
51 # opObj11.addParameter(name='id', value='21', format='int')
51 # opObj11.addParameter(name='id', value='21', format='int')
52 # opObj11.addParameter(name='wintitle', value='SpectraCutPlot', format='str')
52 # opObj11.addParameter(name='wintitle', value='SpectraCutPlot', format='str')
53 # opObj11.addParameter(name='xaxis', value='frequency', format='str')
53 # opObj11.addParameter(name='xaxis', value='frequency', format='str')
54 # opObj11.addParameter(name='colormap', value='winter', format='str')
54 # opObj11.addParameter(name='colormap', value='winter', format='str')
55 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
55 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
56 # opObj11.addParameter(name='xmax', value='0.005', format='float')
56 # opObj11.addParameter(name='xmax', value='0.005', format='float')
57 # #opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
57 # #opObj10 = procUnitConfObj1.addOperation(name='selectChannels')
58 # #opObj10.addParameter(name='channelList', value='0,1', format='intlist')
58 # #opObj10.addParameter(name='channelList', value='0,1', format='intlist')
59 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
59 # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other')
60 # opObj11.addParameter(name='id', value='21', format='int')
60 # opObj11.addParameter(name='id', value='21', format='int')
61 # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
61 # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str')
62 # #opObj11.addParameter(name='xaxis', value='Velocity', format='str')
62 # #opObj11.addParameter(name='xaxis', value='Velocity', format='str')
63
63
64 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
64 # opObj11.addParameter(name='xaxis', value='velocity', format='str')
65 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
65 # opObj11.addParameter(name='xmin', value='-0.005', format='float')
66 # opObj11.addParameter(name='xmax', value='0.005', format='float')
66 # opObj11.addParameter(name='xmax', value='0.005', format='float')
67
67
68 # opObj11.addParameter(name='ymin', value='225', format='float')
68 # opObj11.addParameter(name='ymin', value='225', format='float')
69 # opObj11.addParameter(name='ymax', value='3000', format='float')
69 # opObj11.addParameter(name='ymax', value='3000', format='float')
70 # opObj11.addParameter(name='zmin', value='-100', format='int')
70 # opObj11.addParameter(name='zmin', value='-100', format='int')
71 # opObj11.addParameter(name='zmax', value='-65', format='int')
71 # opObj11.addParameter(name='zmax', value='-65', format='int')
72
72
73 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
73 # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other')
74 # opObj11.addParameter(name='id', value='10', format='int')
74 # opObj11.addParameter(name='id', value='10', format='int')
75 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
75 # opObj11.addParameter(name='wintitle', value='RTI', format='str')
76 # opObj11.addParameter(name='ymin', value='0', format='float')
76 # opObj11.addParameter(name='ymin', value='0', format='float')
77 # opObj11.addParameter(name='ymax', value='4000', format='float')
77 # opObj11.addParameter(name='ymax', value='4000', format='float')
78 # #opObj11.addParameter(name='zmin', value='-100', format='int')
78 # #opObj11.addParameter(name='zmin', value='-100', format='int')
79 # #opObj11.addParameter(name='zmax', value='-70', format='int')
79 # #opObj11.addParameter(name='zmax', value='-70', format='int')
80 # opObj11.addParameter(name='zmin', value='-90', format='int')
80 # opObj11.addParameter(name='zmin', value='-90', format='int')
81 # opObj11.addParameter(name='zmax', value='-40', format='int')
81 # opObj11.addParameter(name='zmax', value='-40', format='int')
82 # opObj11.addParameter(name='showprofile', value='1', format='int')
82 # opObj11.addParameter(name='showprofile', value='1', format='int')
83 # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int')
83 # opObj11.addParameter(name='timerange', value=str(2*60*60), format='int')
84
84
85 opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
85 opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other')
86 procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
86 procUnitConfObj1.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
87 opObj11.addParameter(name='id', value='2005', format='int')
87 opObj11.addParameter(name='id', value='2005', format='int')
88 opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
88 opObj11.addParameter(name='wintitle', value='CrossSpectraPlot_ShortPulse', format='str')
89 # opObj11.addParameter(name='exp_code', value='13', format='int')
89 # opObj11.addParameter(name='exp_code', value='13', format='int')
90 opObj11.addParameter(name='xaxis', value='Velocity', format='str')
90 opObj11.addParameter(name='xaxis', value='Velocity', format='str')
91 #opObj11.addParameter(name='xmin', value='-10', format='float')
91 #opObj11.addParameter(name='xmin', value='-10', format='float')
92 #opObj11.addParameter(name='xmax', value='10', format='float')
92 #opObj11.addParameter(name='xmax', value='10', format='float')
93 #opObj11.addParameter(name='ymin', value='225', format='float')
93 #opObj11.addParameter(name='ymin', value='225', format='float')
94 #opObj11.addParameter(name='ymax', value='3000', format='float')
94 #opObj11.addParameter(name='ymax', value='3000', format='float')
95 #opObj11.addParameter(name='phase_min', value='-4', format='int')
95 #opObj11.addParameter(name='phase_min', value='-4', format='int')
96 #opObj11.addParameter(name='phase_max', value='4', format='int')
96 #opObj11.addParameter(name='phase_max', value='4', format='int')
97
97
98 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj1.getId())
98 # procUnitConfObj2 = controllerObj.addProcUnit(datatype='CorrelationProc', inputId=procUnitConfObj1.getId())
99 # procUnitConfObj2.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
99 # procUnitConfObj2.addParameter(name='pairsList', value='(0,1),(0,2),(1,2)', format='pairsList')
100
100
101 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
101 procUnitConfObj2 = controllerObj.addProcUnit(datatype='Parameters', inputId=procUnitConfObj1.getId())
102 opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
102 opObj11 = procUnitConfObj2.addOperation(name='SpectralMoments', optype='other')
103 opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
103 opObj22 = procUnitConfObj2.addOperation(name='FullSpectralAnalysis', optype='other')
104 opObj22.addParameter(name='SNRlimit', value='-4', format='float')
104 #
105 #
105 opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
106 opObj22 = procUnitConfObj2.addOperation(name='WindProfilerPlot', optype='other')
106 opObj22.addParameter(name='id', value='4', format='int')
107 opObj22.addParameter(name='id', value='4', format='int')
107 opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
108 opObj22.addParameter(name='wintitle', value='Wind Profiler', format='str')
108 opObj22.addParameter(name='save', value='1', format='bool')
109 opObj22.addParameter(name='save', value='1', format='bool')
109 # opObj22.addParameter(name='figpath', value = '/home/erick/Pictures', format='str')
110 # opObj22.addParameter(name='figpath', value = '/home/erick/Pictures', format='str')
110
111
111 opObj22.addParameter(name='zmin', value='-20', format='int')
112 opObj22.addParameter(name='zmin', value='-20', format='int')
112 opObj22.addParameter(name='zmax', value='20', format='int')
113 opObj22.addParameter(name='zmax', value='20', format='int')
113 opObj22.addParameter(name='zmin_ver', value='-250', format='float')
114 opObj22.addParameter(name='zmin_ver', value='-250', format='float')
114 opObj22.addParameter(name='zmax_ver', value='250', format='float')
115 opObj22.addParameter(name='zmax_ver', value='250', format='float')
115 opObj22.addParameter(name='SNRmin', value='-5', format='int')
116 opObj22.addParameter(name='SNRmin', value='-5', format='int')
116 opObj22.addParameter(name='SNRmax', value='30', format='int')
117 opObj22.addParameter(name='SNRmax', value='30', format='int')
117 # opObj22.addParameter(name='SNRthresh', value='-3.5', format='float')
118 # opObj22.addParameter(name='SNRthresh', value='-3.5', format='float')
118 opObj22.addParameter(name='xmin', value=0, format='float')
119 opObj22.addParameter(name='xmin', value='0', format='float')
119 opObj22.addParameter(name='xmax', value=24, format='float')
120 opObj22.addParameter(name='xmax', value='24', format='float')
120 opObj22.addParameter(name='ymin', value='225', format='float')
121 opObj22.addParameter(name='ymin', value='225', format='float')
121 #opObj22.addParameter(name='ymax', value='2000', format='float')
122 #opObj22.addParameter(name='ymax', value='2000', format='float')
122 opObj22.addParameter(name='save', value='1', format='int')
123 opObj22.addParameter(name='save', value='1', format='int')
123 opObj22.addParameter(name='figpath', value=figpath, format='str')
124 opObj22.addParameter(name='figpath', value=figpath, format='str')
124
125
125
126
126 # opObj11.addParameter(name='pairlist', value='(1,0),(0,2),(1,2)', format='pairsList')
127 # opObj11.addParameter(name='pairlist', value='(1,0),(0,2),(1,2)', format='pairsList')
127 #opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
128 #opObj10 = procUnitConfObj1.addOperation(name='selectHeights')
128 #opObj10.addParameter(name='minHei', value='225', format='float')
129 #opObj10.addParameter(name='minHei', value='225', format='float')
129 #opObj10.addParameter(name='maxHei', value='1000', format='float')
130 #opObj10.addParameter(name='maxHei', value='1000', format='float')
130
131
131 # opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other')
132 # opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other')
132 # opObj11.addParameter(name='id', value='102', format='int')
133 # opObj11.addParameter(name='id', value='102', format='int')
133 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
134 # opObj11.addParameter(name='wintitle', value='Coherence', format='str')
134 # opObj11.addParameter(name='ymin', value='225', format='float')
135 # opObj11.addParameter(name='ymin', value='225', format='float')
135 # opObj11.addParameter(name='ymax', value='4000', format='float')
136 # opObj11.addParameter(name='ymax', value='4000', format='float')
136
137
137 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
138 # opObj11.addParameter(name='phase_cmap', value='jet', format='str')
138 # opObj11.addParameter(name='xmin', value='8.5', format='float')
139 # opObj11.addParameter(name='xmin', value='8.5', format='float')
139 # opObj11.addParameter(name='xmax', value='9.5', format='float')
140 # opObj11.addParameter(name='xmax', value='9.5', format='float')
140 # opObj11.addParameter(name='figpath', value=figpath, format='str')
141 # opObj11.addParameter(name='figpath', value=figpath, format='str')
141 # opObj11.addParameter(name='save', value=1, format='bool')
142 # opObj11.addParameter(name='save', value=1, format='bool')
142 # opObj11.addParameter(name='pairsList', value='(1,0),(3,2)', format='pairsList')
143 # opObj11.addParameter(name='pairsList', value='(1,0),(3,2)', format='pairsList')
143
144
144 # opObj12 = procUnitConfObj1.addOperation(name='PublishData', optype='other')
145 # opObj12 = procUnitConfObj1.addOperation(name='PublishData', optype='other')
145 # opObj12.addParameter(name='zeromq', value=1, format='int')
146 # opObj12.addParameter(name='zeromq', value=1, format='int')
146 # opObj12.addParameter(name='verbose', value=0, format='bool')
147 # opObj12.addParameter(name='verbose', value=0, format='bool')
147 # opObj12.addParameter(name='server', value='erick2', format='str')
148 # opObj12.addParameter(name='server', value='erick2', format='str')
148 controllerObj.start()
149 controllerObj.start()
149
150
150
151
General Comments 0
You need to be logged in to leave comments. Login now