@@ -1,1354 +1,1354 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import time, datetime, os |
|
2 | import time, datetime, os | |
3 | from graphics.figure import * |
|
3 | from graphics.figure import * | |
4 | def isRealtime(utcdatatime): |
|
4 | def isRealtime(utcdatatime): | |
5 | utcnow = time.mktime(datetime.datetime.utcnow().timetuple()) |
|
5 | utcnow = time.mktime(datetime.datetime.utcnow().timetuple()) | |
6 | delta = utcnow - utcdatatime # abs |
|
6 | delta = utcnow - utcdatatime # abs | |
7 | if delta >= 5*60.: |
|
7 | if delta >= 5*60.: | |
8 | return False |
|
8 | return False | |
9 | return True |
|
9 | return True | |
10 |
|
10 | |||
11 | class CrossSpectraPlot(Figure): |
|
11 | class CrossSpectraPlot(Figure): | |
12 |
|
12 | |||
13 | __isConfig = None |
|
13 | __isConfig = None | |
14 | __nsubplots = None |
|
14 | __nsubplots = None | |
15 |
|
15 | |||
16 | WIDTH = None |
|
16 | WIDTH = None | |
17 | HEIGHT = None |
|
17 | HEIGHT = None | |
18 | WIDTHPROF = None |
|
18 | WIDTHPROF = None | |
19 | HEIGHTPROF = None |
|
19 | HEIGHTPROF = None | |
20 | PREFIX = 'cspc' |
|
20 | PREFIX = 'cspc' | |
21 |
|
21 | |||
22 | def __init__(self): |
|
22 | def __init__(self): | |
23 |
|
23 | |||
24 | self.__isConfig = False |
|
24 | self.__isConfig = False | |
25 | self.__nsubplots = 4 |
|
25 | self.__nsubplots = 4 | |
26 |
|
26 | |||
27 | self.WIDTH = 250 |
|
27 | self.WIDTH = 250 | |
28 | self.HEIGHT = 250 |
|
28 | self.HEIGHT = 250 | |
29 | self.WIDTHPROF = 0 |
|
29 | self.WIDTHPROF = 0 | |
30 | self.HEIGHTPROF = 0 |
|
30 | self.HEIGHTPROF = 0 | |
31 |
|
31 | |||
32 | def getSubplots(self): |
|
32 | def getSubplots(self): | |
33 |
|
33 | |||
34 | ncol = 4 |
|
34 | ncol = 4 | |
35 | nrow = self.nplots |
|
35 | nrow = self.nplots | |
36 |
|
36 | |||
37 | return nrow, ncol |
|
37 | return nrow, ncol | |
38 |
|
38 | |||
39 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): |
|
39 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): | |
40 |
|
40 | |||
41 | self.__showprofile = showprofile |
|
41 | self.__showprofile = showprofile | |
42 | self.nplots = nplots |
|
42 | self.nplots = nplots | |
43 |
|
43 | |||
44 | ncolspan = 1 |
|
44 | ncolspan = 1 | |
45 | colspan = 1 |
|
45 | colspan = 1 | |
46 |
|
46 | |||
47 | self.createFigure(idfigure = idfigure, |
|
47 | self.createFigure(idfigure = idfigure, | |
48 | wintitle = wintitle, |
|
48 | wintitle = wintitle, | |
49 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
49 | widthplot = self.WIDTH + self.WIDTHPROF, | |
50 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
50 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
51 | show=True) |
|
51 | show=True) | |
52 |
|
52 | |||
53 | nrow, ncol = self.getSubplots() |
|
53 | nrow, ncol = self.getSubplots() | |
54 |
|
54 | |||
55 | counter = 0 |
|
55 | counter = 0 | |
56 | for y in range(nrow): |
|
56 | for y in range(nrow): | |
57 | for x in range(ncol): |
|
57 | for x in range(ncol): | |
58 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
58 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
59 |
|
59 | |||
60 | counter += 1 |
|
60 | counter += 1 | |
61 |
|
61 | |||
62 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
62 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
63 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
63 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
64 | save=False, figpath='./', figfile=None, |
|
64 | save=False, figpath='./', figfile=None, | |
65 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True): |
|
65 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r', show=True): | |
66 |
|
66 | |||
67 | """ |
|
67 | """ | |
68 |
|
68 | |||
69 | Input: |
|
69 | Input: | |
70 | dataOut : |
|
70 | dataOut : | |
71 | idfigure : |
|
71 | idfigure : | |
72 | wintitle : |
|
72 | wintitle : | |
73 | channelList : |
|
73 | channelList : | |
74 | showProfile : |
|
74 | showProfile : | |
75 | xmin : None, |
|
75 | xmin : None, | |
76 | xmax : None, |
|
76 | xmax : None, | |
77 | ymin : None, |
|
77 | ymin : None, | |
78 | ymax : None, |
|
78 | ymax : None, | |
79 | zmin : None, |
|
79 | zmin : None, | |
80 | zmax : None |
|
80 | zmax : None | |
81 | """ |
|
81 | """ | |
82 |
|
82 | |||
83 | if pairsList == None: |
|
83 | if pairsList == None: | |
84 | pairsIndexList = dataOut.pairsIndexList |
|
84 | pairsIndexList = dataOut.pairsIndexList | |
85 | else: |
|
85 | else: | |
86 | pairsIndexList = [] |
|
86 | pairsIndexList = [] | |
87 | for pair in pairsList: |
|
87 | for pair in pairsList: | |
88 | if pair not in dataOut.pairsList: |
|
88 | if pair not in dataOut.pairsList: | |
89 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
89 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
90 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
90 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
91 |
|
91 | |||
92 | if pairsIndexList == []: |
|
92 | if pairsIndexList == []: | |
93 | return |
|
93 | return | |
94 |
|
94 | |||
95 | if len(pairsIndexList) > 4: |
|
95 | if len(pairsIndexList) > 4: | |
96 | pairsIndexList = pairsIndexList[0:4] |
|
96 | pairsIndexList = pairsIndexList[0:4] | |
97 | factor = dataOut.normFactor |
|
97 | factor = dataOut.normFactor | |
98 | x = dataOut.getVelRange(1) |
|
98 | x = dataOut.getVelRange(1) | |
99 | y = dataOut.getHeiRange() |
|
99 | y = dataOut.getHeiRange() | |
100 | z = dataOut.data_spc[:,:,:]/factor |
|
100 | z = dataOut.data_spc[:,:,:]/factor | |
101 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
101 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
102 | avg = numpy.abs(numpy.average(z, axis=1)) |
|
102 | avg = numpy.abs(numpy.average(z, axis=1)) | |
103 | noise = dataOut.getNoise()/factor |
|
103 | noise = dataOut.getNoise()/factor | |
104 |
|
104 | |||
105 | zdB = 10*numpy.log10(z) |
|
105 | zdB = 10*numpy.log10(z) | |
106 | avgdB = 10*numpy.log10(avg) |
|
106 | avgdB = 10*numpy.log10(avg) | |
107 | noisedB = 10*numpy.log10(noise) |
|
107 | noisedB = 10*numpy.log10(noise) | |
108 |
|
108 | |||
109 |
|
109 | |||
110 | thisDatetime = dataOut.datatime |
|
110 | thisDatetime = dataOut.datatime | |
111 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
111 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
112 | xlabel = "Velocity (m/s)" |
|
112 | xlabel = "Velocity (m/s)" | |
113 | ylabel = "Range (Km)" |
|
113 | ylabel = "Range (Km)" | |
114 |
|
114 | |||
115 | if not self.__isConfig: |
|
115 | if not self.__isConfig: | |
116 |
|
116 | |||
117 | nplots = len(pairsIndexList) |
|
117 | nplots = len(pairsIndexList) | |
118 |
|
118 | |||
119 | self.setup(idfigure=idfigure, |
|
119 | self.setup(idfigure=idfigure, | |
120 | nplots=nplots, |
|
120 | nplots=nplots, | |
121 | wintitle=wintitle, |
|
121 | wintitle=wintitle, | |
122 | showprofile=showprofile, |
|
122 | showprofile=showprofile, | |
123 | show=show) |
|
123 | show=show) | |
124 |
|
124 | |||
125 | if xmin == None: xmin = numpy.nanmin(x) |
|
125 | if xmin == None: xmin = numpy.nanmin(x) | |
126 | if xmax == None: xmax = numpy.nanmax(x) |
|
126 | if xmax == None: xmax = numpy.nanmax(x) | |
127 | if ymin == None: ymin = numpy.nanmin(y) |
|
127 | if ymin == None: ymin = numpy.nanmin(y) | |
128 | if ymax == None: ymax = numpy.nanmax(y) |
|
128 | if ymax == None: ymax = numpy.nanmax(y) | |
129 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
129 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
130 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
130 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
131 |
|
131 | |||
132 | self.__isConfig = True |
|
132 | self.__isConfig = True | |
133 |
|
133 | |||
134 | self.setWinTitle(title) |
|
134 | self.setWinTitle(title) | |
135 |
|
135 | |||
136 | for i in range(self.nplots): |
|
136 | for i in range(self.nplots): | |
137 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
137 | pair = dataOut.pairsList[pairsIndexList[i]] | |
138 |
|
138 | |||
139 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) |
|
139 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) | |
140 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) |
|
140 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) | |
141 | axes0 = self.axesList[i*self.__nsubplots] |
|
141 | axes0 = self.axesList[i*self.__nsubplots] | |
142 | axes0.pcolor(x, y, zdB, |
|
142 | axes0.pcolor(x, y, zdB, | |
143 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
143 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
144 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
144 | xlabel=xlabel, ylabel=ylabel, title=title, | |
145 | ticksize=9, colormap=power_cmap, cblabel='') |
|
145 | ticksize=9, colormap=power_cmap, cblabel='') | |
146 |
|
146 | |||
147 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) |
|
147 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) | |
148 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) |
|
148 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) | |
149 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
149 | axes0 = self.axesList[i*self.__nsubplots+1] | |
150 | axes0.pcolor(x, y, zdB, |
|
150 | axes0.pcolor(x, y, zdB, | |
151 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
151 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
152 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
152 | xlabel=xlabel, ylabel=ylabel, title=title, | |
153 | ticksize=9, colormap=power_cmap, cblabel='') |
|
153 | ticksize=9, colormap=power_cmap, cblabel='') | |
154 |
|
154 | |||
155 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
155 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
156 | coherence = numpy.abs(coherenceComplex) |
|
156 | coherence = numpy.abs(coherenceComplex) | |
157 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
157 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
158 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi |
|
158 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi | |
159 |
|
159 | |||
160 | title = "Coherence %d%d" %(pair[0], pair[1]) |
|
160 | title = "Coherence %d%d" %(pair[0], pair[1]) | |
161 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
161 | axes0 = self.axesList[i*self.__nsubplots+2] | |
162 | axes0.pcolor(x, y, coherence, |
|
162 | axes0.pcolor(x, y, coherence, | |
163 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
163 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
164 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
164 | xlabel=xlabel, ylabel=ylabel, title=title, | |
165 | ticksize=9, colormap=coherence_cmap, cblabel='') |
|
165 | ticksize=9, colormap=coherence_cmap, cblabel='') | |
166 |
|
166 | |||
167 | title = "Phase %d%d" %(pair[0], pair[1]) |
|
167 | title = "Phase %d%d" %(pair[0], pair[1]) | |
168 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
168 | axes0 = self.axesList[i*self.__nsubplots+3] | |
169 | axes0.pcolor(x, y, phase, |
|
169 | axes0.pcolor(x, y, phase, | |
170 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
170 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
171 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
171 | xlabel=xlabel, ylabel=ylabel, title=title, | |
172 | ticksize=9, colormap=phase_cmap, cblabel='') |
|
172 | ticksize=9, colormap=phase_cmap, cblabel='') | |
173 |
|
173 | |||
174 |
|
174 | |||
175 |
|
175 | |||
176 | self.draw() |
|
176 | self.draw() | |
177 |
|
177 | |||
178 | if save: |
|
178 | if save: | |
179 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
179 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
180 | if figfile == None: |
|
180 | if figfile == None: | |
181 | figfile = self.getFilename(name = date) |
|
181 | figfile = self.getFilename(name = date) | |
182 |
|
182 | |||
183 | self.saveFigure(figpath, figfile) |
|
183 | self.saveFigure(figpath, figfile) | |
184 |
|
184 | |||
185 |
|
185 | |||
186 | class RTIPlot(Figure): |
|
186 | class RTIPlot(Figure): | |
187 |
|
187 | |||
188 | __isConfig = None |
|
188 | __isConfig = None | |
189 | __nsubplots = None |
|
189 | __nsubplots = None | |
190 |
|
190 | |||
191 | WIDTHPROF = None |
|
191 | WIDTHPROF = None | |
192 | HEIGHTPROF = None |
|
192 | HEIGHTPROF = None | |
193 | PREFIX = 'rti' |
|
193 | PREFIX = 'rti' | |
194 |
|
194 | |||
195 | def __init__(self): |
|
195 | def __init__(self): | |
196 |
|
196 | |||
197 | self.timerange = 2*60*60 |
|
197 | self.timerange = 2*60*60 | |
198 | self.__isConfig = False |
|
198 | self.__isConfig = False | |
199 | self.__nsubplots = 1 |
|
199 | self.__nsubplots = 1 | |
200 |
|
200 | |||
201 | self.WIDTH = 800 |
|
201 | self.WIDTH = 800 | |
202 | self.HEIGHT = 150 |
|
202 | self.HEIGHT = 150 | |
203 | self.WIDTHPROF = 120 |
|
203 | self.WIDTHPROF = 120 | |
204 | self.HEIGHTPROF = 0 |
|
204 | self.HEIGHTPROF = 0 | |
205 | self.counterftp = 0 |
|
205 | self.counterftp = 0 | |
206 |
|
206 | |||
207 | def getSubplots(self): |
|
207 | def getSubplots(self): | |
208 |
|
208 | |||
209 | ncol = 1 |
|
209 | ncol = 1 | |
210 | nrow = self.nplots |
|
210 | nrow = self.nplots | |
211 |
|
211 | |||
212 | return nrow, ncol |
|
212 | return nrow, ncol | |
213 |
|
213 | |||
214 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): |
|
214 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): | |
215 |
|
215 | |||
216 | self.__showprofile = showprofile |
|
216 | self.__showprofile = showprofile | |
217 | self.nplots = nplots |
|
217 | self.nplots = nplots | |
218 |
|
218 | |||
219 | ncolspan = 1 |
|
219 | ncolspan = 1 | |
220 | colspan = 1 |
|
220 | colspan = 1 | |
221 | if showprofile: |
|
221 | if showprofile: | |
222 | ncolspan = 7 |
|
222 | ncolspan = 7 | |
223 | colspan = 6 |
|
223 | colspan = 6 | |
224 | self.__nsubplots = 2 |
|
224 | self.__nsubplots = 2 | |
225 |
|
225 | |||
226 | self.createFigure(idfigure = idfigure, |
|
226 | self.createFigure(idfigure = idfigure, | |
227 | wintitle = wintitle, |
|
227 | wintitle = wintitle, | |
228 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
228 | widthplot = self.WIDTH + self.WIDTHPROF, | |
229 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
229 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
230 | show=show) |
|
230 | show=show) | |
231 |
|
231 | |||
232 | nrow, ncol = self.getSubplots() |
|
232 | nrow, ncol = self.getSubplots() | |
233 |
|
233 | |||
234 | counter = 0 |
|
234 | counter = 0 | |
235 | for y in range(nrow): |
|
235 | for y in range(nrow): | |
236 | for x in range(ncol): |
|
236 | for x in range(ncol): | |
237 |
|
237 | |||
238 | if counter >= self.nplots: |
|
238 | if counter >= self.nplots: | |
239 | break |
|
239 | break | |
240 |
|
240 | |||
241 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
241 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
242 |
|
242 | |||
243 | if showprofile: |
|
243 | if showprofile: | |
244 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
244 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
245 |
|
245 | |||
246 | counter += 1 |
|
246 | counter += 1 | |
247 |
|
247 | |||
248 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
248 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
249 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
249 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
250 | timerange=None, |
|
250 | timerange=None, | |
251 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, show=True): |
|
251 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, show=True): | |
252 |
|
252 | |||
253 | """ |
|
253 | """ | |
254 |
|
254 | |||
255 | Input: |
|
255 | Input: | |
256 | dataOut : |
|
256 | dataOut : | |
257 | idfigure : |
|
257 | idfigure : | |
258 | wintitle : |
|
258 | wintitle : | |
259 | channelList : |
|
259 | channelList : | |
260 | showProfile : |
|
260 | showProfile : | |
261 | xmin : None, |
|
261 | xmin : None, | |
262 | xmax : None, |
|
262 | xmax : None, | |
263 | ymin : None, |
|
263 | ymin : None, | |
264 | ymax : None, |
|
264 | ymax : None, | |
265 | zmin : None, |
|
265 | zmin : None, | |
266 | zmax : None |
|
266 | zmax : None | |
267 | """ |
|
267 | """ | |
268 |
|
268 | |||
269 | if channelList == None: |
|
269 | if channelList == None: | |
270 | channelIndexList = dataOut.channelIndexList |
|
270 | channelIndexList = dataOut.channelIndexList | |
271 | else: |
|
271 | else: | |
272 | channelIndexList = [] |
|
272 | channelIndexList = [] | |
273 | for channel in channelList: |
|
273 | for channel in channelList: | |
274 | if channel not in dataOut.channelList: |
|
274 | if channel not in dataOut.channelList: | |
275 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
275 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
276 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
276 | channelIndexList.append(dataOut.channelList.index(channel)) | |
277 |
|
277 | |||
278 | if timerange != None: |
|
278 | if timerange != None: | |
279 | self.timerange = timerange |
|
279 | self.timerange = timerange | |
280 |
|
280 | |||
281 | tmin = None |
|
281 | tmin = None | |
282 | tmax = None |
|
282 | tmax = None | |
283 | factor = dataOut.normFactor |
|
283 | factor = dataOut.normFactor | |
284 | x = dataOut.getTimeRange() |
|
284 | x = dataOut.getTimeRange() | |
285 | y = dataOut.getHeiRange() |
|
285 | y = dataOut.getHeiRange() | |
286 |
|
286 | |||
287 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
287 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
288 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
288 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
289 | avg = numpy.average(z, axis=1) |
|
289 | avg = numpy.average(z, axis=1) | |
290 |
|
290 | |||
291 | avgdB = 10.*numpy.log10(avg) |
|
291 | avgdB = 10.*numpy.log10(avg) | |
292 |
|
292 | |||
293 |
|
293 | |||
294 | thisDatetime = dataOut.datatime |
|
294 | thisDatetime = dataOut.datatime | |
295 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
295 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
296 | xlabel = "" |
|
296 | xlabel = "" | |
297 | ylabel = "Range (Km)" |
|
297 | ylabel = "Range (Km)" | |
298 |
|
298 | |||
299 | if not self.__isConfig: |
|
299 | if not self.__isConfig: | |
300 |
|
300 | |||
301 | nplots = len(channelIndexList) |
|
301 | nplots = len(channelIndexList) | |
302 |
|
302 | |||
303 | self.setup(idfigure=idfigure, |
|
303 | self.setup(idfigure=idfigure, | |
304 | nplots=nplots, |
|
304 | nplots=nplots, | |
305 | wintitle=wintitle, |
|
305 | wintitle=wintitle, | |
306 | showprofile=showprofile, |
|
306 | showprofile=showprofile, | |
307 | show=show) |
|
307 | show=show) | |
308 |
|
308 | |||
309 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
309 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
310 | if ymin == None: ymin = numpy.nanmin(y) |
|
310 | if ymin == None: ymin = numpy.nanmin(y) | |
311 | if ymax == None: ymax = numpy.nanmax(y) |
|
311 | if ymax == None: ymax = numpy.nanmax(y) | |
312 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
312 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
313 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
313 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
314 |
|
314 | |||
315 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
315 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
316 | self.__isConfig = True |
|
316 | self.__isConfig = True | |
317 |
|
317 | |||
318 |
|
318 | |||
319 | self.setWinTitle(title) |
|
319 | self.setWinTitle(title) | |
320 |
|
320 | |||
321 | for i in range(self.nplots): |
|
321 | for i in range(self.nplots): | |
322 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
322 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
323 | axes = self.axesList[i*self.__nsubplots] |
|
323 | axes = self.axesList[i*self.__nsubplots] | |
324 | zdB = avgdB[i].reshape((1,-1)) |
|
324 | zdB = avgdB[i].reshape((1,-1)) | |
325 | axes.pcolorbuffer(x, y, zdB, |
|
325 | axes.pcolorbuffer(x, y, zdB, | |
326 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
326 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
327 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
327 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
328 | ticksize=9, cblabel='', cbsize="1%") |
|
328 | ticksize=9, cblabel='', cbsize="1%") | |
329 |
|
329 | |||
330 | if self.__showprofile: |
|
330 | if self.__showprofile: | |
331 | axes = self.axesList[i*self.__nsubplots +1] |
|
331 | axes = self.axesList[i*self.__nsubplots +1] | |
332 | axes.pline(avgdB[i], y, |
|
332 | axes.pline(avgdB[i], y, | |
333 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
333 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
334 | xlabel='dB', ylabel='', title='', |
|
334 | xlabel='dB', ylabel='', title='', | |
335 | ytick_visible=False, |
|
335 | ytick_visible=False, | |
336 | grid='x') |
|
336 | grid='x') | |
337 |
|
337 | |||
338 | self.draw() |
|
338 | self.draw() | |
339 |
|
339 | |||
340 | if save: |
|
340 | if save: | |
341 |
|
341 | |||
342 | if figfile == None: |
|
342 | if figfile == None: | |
343 | figfile = self.getFilename(name = self.name) |
|
343 | figfile = self.getFilename(name = self.name) | |
344 |
|
344 | |||
345 | self.saveFigure(figpath, figfile) |
|
345 | self.saveFigure(figpath, figfile) | |
346 |
|
346 | |||
347 | self.counterftp += 1 |
|
347 | self.counterftp += 1 | |
348 | if (ftp and (self.counterftp==ftpratio)): |
|
348 | if (ftp and (self.counterftp==ftpratio)): | |
349 | figfilename = os.path.join(figpath,figfile) |
|
349 | figfilename = os.path.join(figpath,figfile) | |
350 | self.sendByFTP(figfilename) |
|
350 | self.sendByFTP(figfilename) | |
351 | self.counterftp = 0 |
|
351 | self.counterftp = 0 | |
352 |
|
352 | |||
353 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
353 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
354 | self.__isConfig = False |
|
354 | self.__isConfig = False | |
355 |
|
355 | |||
356 | class SpectraPlot(Figure): |
|
356 | class SpectraPlot(Figure): | |
357 |
|
357 | |||
358 | __isConfig = None |
|
358 | __isConfig = None | |
359 | __nsubplots = None |
|
359 | __nsubplots = None | |
360 |
|
360 | |||
361 | WIDTHPROF = None |
|
361 | WIDTHPROF = None | |
362 | HEIGHTPROF = None |
|
362 | HEIGHTPROF = None | |
363 | PREFIX = 'spc' |
|
363 | PREFIX = 'spc' | |
364 |
|
364 | |||
365 | def __init__(self): |
|
365 | def __init__(self): | |
366 |
|
366 | |||
367 | self.__isConfig = False |
|
367 | self.__isConfig = False | |
368 | self.__nsubplots = 1 |
|
368 | self.__nsubplots = 1 | |
369 |
|
369 | |||
370 | self.WIDTH = 230 |
|
370 | self.WIDTH = 230 | |
371 | self.HEIGHT = 250 |
|
371 | self.HEIGHT = 250 | |
372 | self.WIDTHPROF = 120 |
|
372 | self.WIDTHPROF = 120 | |
373 | self.HEIGHTPROF = 0 |
|
373 | self.HEIGHTPROF = 0 | |
374 |
|
374 | |||
375 | def getSubplots(self): |
|
375 | def getSubplots(self): | |
376 |
|
376 | |||
377 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
377 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
378 | nrow = int(self.nplots*1./ncol + 0.9) |
|
378 | nrow = int(self.nplots*1./ncol + 0.9) | |
379 |
|
379 | |||
380 | return nrow, ncol |
|
380 | return nrow, ncol | |
381 |
|
381 | |||
382 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): |
|
382 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): | |
383 |
|
383 | |||
384 | self.__showprofile = showprofile |
|
384 | self.__showprofile = showprofile | |
385 | self.nplots = nplots |
|
385 | self.nplots = nplots | |
386 |
|
386 | |||
387 | ncolspan = 1 |
|
387 | ncolspan = 1 | |
388 | colspan = 1 |
|
388 | colspan = 1 | |
389 | if showprofile: |
|
389 | if showprofile: | |
390 | ncolspan = 3 |
|
390 | ncolspan = 3 | |
391 | colspan = 2 |
|
391 | colspan = 2 | |
392 | self.__nsubplots = 2 |
|
392 | self.__nsubplots = 2 | |
393 |
|
393 | |||
394 | self.createFigure(idfigure = idfigure, |
|
394 | self.createFigure(idfigure = idfigure, | |
395 | wintitle = wintitle, |
|
395 | wintitle = wintitle, | |
396 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
396 | widthplot = self.WIDTH + self.WIDTHPROF, | |
397 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
397 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
398 | show=show) |
|
398 | show=show) | |
399 |
|
399 | |||
400 | nrow, ncol = self.getSubplots() |
|
400 | nrow, ncol = self.getSubplots() | |
401 |
|
401 | |||
402 | counter = 0 |
|
402 | counter = 0 | |
403 | for y in range(nrow): |
|
403 | for y in range(nrow): | |
404 | for x in range(ncol): |
|
404 | for x in range(ncol): | |
405 |
|
405 | |||
406 | if counter >= self.nplots: |
|
406 | if counter >= self.nplots: | |
407 | break |
|
407 | break | |
408 |
|
408 | |||
409 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
409 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
410 |
|
410 | |||
411 | if showprofile: |
|
411 | if showprofile: | |
412 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
412 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
413 |
|
413 | |||
414 | counter += 1 |
|
414 | counter += 1 | |
415 |
|
415 | |||
416 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
416 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
417 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
417 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
418 | save=False, figpath='./', figfile=None, show=True): |
|
418 | save=False, figpath='./', figfile=None, show=True): | |
419 |
|
419 | |||
420 | """ |
|
420 | """ | |
421 |
|
421 | |||
422 | Input: |
|
422 | Input: | |
423 | dataOut : |
|
423 | dataOut : | |
424 | idfigure : |
|
424 | idfigure : | |
425 | wintitle : |
|
425 | wintitle : | |
426 | channelList : |
|
426 | channelList : | |
427 | showProfile : |
|
427 | showProfile : | |
428 | xmin : None, |
|
428 | xmin : None, | |
429 | xmax : None, |
|
429 | xmax : None, | |
430 | ymin : None, |
|
430 | ymin : None, | |
431 | ymax : None, |
|
431 | ymax : None, | |
432 | zmin : None, |
|
432 | zmin : None, | |
433 | zmax : None |
|
433 | zmax : None | |
434 | """ |
|
434 | """ | |
435 |
|
435 | |||
436 | if channelList == None: |
|
436 | if channelList == None: | |
437 | channelIndexList = dataOut.channelIndexList |
|
437 | channelIndexList = dataOut.channelIndexList | |
438 | else: |
|
438 | else: | |
439 | channelIndexList = [] |
|
439 | channelIndexList = [] | |
440 | for channel in channelList: |
|
440 | for channel in channelList: | |
441 | if channel not in dataOut.channelList: |
|
441 | if channel not in dataOut.channelList: | |
442 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
442 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
443 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
443 | channelIndexList.append(dataOut.channelList.index(channel)) | |
444 | factor = dataOut.normFactor |
|
444 | factor = dataOut.normFactor | |
445 | x = dataOut.getVelRange(1) |
|
445 | x = dataOut.getVelRange(1) | |
446 | y = dataOut.getHeiRange() |
|
446 | y = dataOut.getHeiRange() | |
447 |
|
447 | |||
448 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
448 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
449 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
449 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
450 | avg = numpy.average(z, axis=1) |
|
450 | avg = numpy.average(z, axis=1) | |
451 | noise = dataOut.getNoise()/factor |
|
451 | noise = dataOut.getNoise()/factor | |
452 |
|
452 | |||
453 | zdB = 10*numpy.log10(z) |
|
453 | zdB = 10*numpy.log10(z) | |
454 | avgdB = 10*numpy.log10(avg) |
|
454 | avgdB = 10*numpy.log10(avg) | |
455 | noisedB = 10*numpy.log10(noise) |
|
455 | noisedB = 10*numpy.log10(noise) | |
456 |
|
456 | |||
457 | thisDatetime = dataOut.datatime |
|
457 | thisDatetime = dataOut.datatime | |
458 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
458 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
459 | xlabel = "Velocity (m/s)" |
|
459 | xlabel = "Velocity (m/s)" | |
460 | ylabel = "Range (Km)" |
|
460 | ylabel = "Range (Km)" | |
461 |
|
461 | |||
462 | if not self.__isConfig: |
|
462 | if not self.__isConfig: | |
463 |
|
463 | |||
464 | nplots = len(channelIndexList) |
|
464 | nplots = len(channelIndexList) | |
465 |
|
465 | |||
466 | self.setup(idfigure=idfigure, |
|
466 | self.setup(idfigure=idfigure, | |
467 | nplots=nplots, |
|
467 | nplots=nplots, | |
468 | wintitle=wintitle, |
|
468 | wintitle=wintitle, | |
469 | showprofile=showprofile, |
|
469 | showprofile=showprofile, | |
470 | show=show) |
|
470 | show=show) | |
471 |
|
471 | |||
472 | if xmin == None: xmin = numpy.nanmin(x) |
|
472 | if xmin == None: xmin = numpy.nanmin(x) | |
473 | if xmax == None: xmax = numpy.nanmax(x) |
|
473 | if xmax == None: xmax = numpy.nanmax(x) | |
474 | if ymin == None: ymin = numpy.nanmin(y) |
|
474 | if ymin == None: ymin = numpy.nanmin(y) | |
475 | if ymax == None: ymax = numpy.nanmax(y) |
|
475 | if ymax == None: ymax = numpy.nanmax(y) | |
476 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
476 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
477 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
477 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
478 |
|
478 | |||
479 | self.__isConfig = True |
|
479 | self.__isConfig = True | |
480 |
|
480 | |||
481 | self.setWinTitle(title) |
|
481 | self.setWinTitle(title) | |
482 |
|
482 | |||
483 | for i in range(self.nplots): |
|
483 | for i in range(self.nplots): | |
484 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i]) |
|
484 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i]) | |
485 | axes = self.axesList[i*self.__nsubplots] |
|
485 | axes = self.axesList[i*self.__nsubplots] | |
486 | axes.pcolor(x, y, zdB[i,:,:], |
|
486 | axes.pcolor(x, y, zdB[i,:,:], | |
487 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
487 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
488 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
488 | xlabel=xlabel, ylabel=ylabel, title=title, | |
489 | ticksize=9, cblabel='') |
|
489 | ticksize=9, cblabel='') | |
490 |
|
490 | |||
491 | if self.__showprofile: |
|
491 | if self.__showprofile: | |
492 | axes = self.axesList[i*self.__nsubplots +1] |
|
492 | axes = self.axesList[i*self.__nsubplots +1] | |
493 | axes.pline(avgdB[i], y, |
|
493 | axes.pline(avgdB[i], y, | |
494 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
494 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
495 | xlabel='dB', ylabel='', title='', |
|
495 | xlabel='dB', ylabel='', title='', | |
496 | ytick_visible=False, |
|
496 | ytick_visible=False, | |
497 | grid='x') |
|
497 | grid='x') | |
498 |
|
498 | |||
499 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
499 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
500 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
500 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
501 |
|
501 | |||
502 | self.draw() |
|
502 | self.draw() | |
503 |
|
503 | |||
504 | if save: |
|
504 | if save: | |
505 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
505 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
506 | if figfile == None: |
|
506 | if figfile == None: | |
507 | figfile = self.getFilename(name = date) |
|
507 | figfile = self.getFilename(name = date) | |
508 |
|
508 | |||
509 | self.saveFigure(figpath, figfile) |
|
509 | self.saveFigure(figpath, figfile) | |
510 |
|
510 | |||
511 | class Scope(Figure): |
|
511 | class Scope(Figure): | |
512 |
|
512 | |||
513 | __isConfig = None |
|
513 | __isConfig = None | |
514 |
|
514 | |||
515 | def __init__(self): |
|
515 | def __init__(self): | |
516 |
|
516 | |||
517 | self.__isConfig = False |
|
517 | self.__isConfig = False | |
518 | self.WIDTH = 600 |
|
518 | self.WIDTH = 600 | |
519 | self.HEIGHT = 200 |
|
519 | self.HEIGHT = 200 | |
520 |
|
520 | |||
521 | def getSubplots(self): |
|
521 | def getSubplots(self): | |
522 |
|
522 | |||
523 | nrow = self.nplots |
|
523 | nrow = self.nplots | |
524 | ncol = 3 |
|
524 | ncol = 3 | |
525 | return nrow, ncol |
|
525 | return nrow, ncol | |
526 |
|
526 | |||
527 | def setup(self, idfigure, nplots, wintitle, show): |
|
527 | def setup(self, idfigure, nplots, wintitle, show): | |
528 |
|
528 | |||
529 | self.nplots = nplots |
|
529 | self.nplots = nplots | |
530 |
|
530 | |||
531 | self.createFigure(idfigure=idfigure, |
|
531 | self.createFigure(idfigure=idfigure, | |
532 | wintitle=wintitle, |
|
532 | wintitle=wintitle, | |
533 | show=show) |
|
533 | show=show) | |
534 |
|
534 | |||
535 | nrow,ncol = self.getSubplots() |
|
535 | nrow,ncol = self.getSubplots() | |
536 | colspan = 3 |
|
536 | colspan = 3 | |
537 | rowspan = 1 |
|
537 | rowspan = 1 | |
538 |
|
538 | |||
539 | for i in range(nplots): |
|
539 | for i in range(nplots): | |
540 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
540 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
541 |
|
541 | |||
542 |
|
542 | |||
543 |
|
543 | |||
544 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
544 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
545 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
545 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, | |
546 | figpath='./', figfile=None, show=True): |
|
546 | figpath='./', figfile=None, show=True): | |
547 |
|
547 | |||
548 | """ |
|
548 | """ | |
549 |
|
549 | |||
550 | Input: |
|
550 | Input: | |
551 | dataOut : |
|
551 | dataOut : | |
552 | idfigure : |
|
552 | idfigure : | |
553 | wintitle : |
|
553 | wintitle : | |
554 | channelList : |
|
554 | channelList : | |
555 | xmin : None, |
|
555 | xmin : None, | |
556 | xmax : None, |
|
556 | xmax : None, | |
557 | ymin : None, |
|
557 | ymin : None, | |
558 | ymax : None, |
|
558 | ymax : None, | |
559 | """ |
|
559 | """ | |
560 |
|
560 | |||
561 | if channelList == None: |
|
561 | if channelList == None: | |
562 | channelIndexList = dataOut.channelIndexList |
|
562 | channelIndexList = dataOut.channelIndexList | |
563 | else: |
|
563 | else: | |
564 | channelIndexList = [] |
|
564 | channelIndexList = [] | |
565 | for channel in channelList: |
|
565 | for channel in channelList: | |
566 | if channel not in dataOut.channelList: |
|
566 | if channel not in dataOut.channelList: | |
567 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
567 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
568 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
568 | channelIndexList.append(dataOut.channelList.index(channel)) | |
569 |
|
569 | |||
570 | x = dataOut.heightList |
|
570 | x = dataOut.heightList | |
571 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
571 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
572 | y = y.real |
|
572 | y = y.real | |
573 |
|
573 | |||
574 | thisDatetime = dataOut.datatime |
|
574 | thisDatetime = dataOut.datatime | |
575 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
575 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
576 | xlabel = "Range (Km)" |
|
576 | xlabel = "Range (Km)" | |
577 | ylabel = "Intensity" |
|
577 | ylabel = "Intensity" | |
578 |
|
578 | |||
579 | if not self.__isConfig: |
|
579 | if not self.__isConfig: | |
580 | nplots = len(channelIndexList) |
|
580 | nplots = len(channelIndexList) | |
581 |
|
581 | |||
582 | self.setup(idfigure=idfigure, |
|
582 | self.setup(idfigure=idfigure, | |
583 | nplots=nplots, |
|
583 | nplots=nplots, | |
584 | wintitle=wintitle, |
|
584 | wintitle=wintitle, | |
585 | show=show) |
|
585 | show=show) | |
586 |
|
586 | |||
587 | if xmin == None: xmin = numpy.nanmin(x) |
|
587 | if xmin == None: xmin = numpy.nanmin(x) | |
588 | if xmax == None: xmax = numpy.nanmax(x) |
|
588 | if xmax == None: xmax = numpy.nanmax(x) | |
589 | if ymin == None: ymin = numpy.nanmin(y) |
|
589 | if ymin == None: ymin = numpy.nanmin(y) | |
590 | if ymax == None: ymax = numpy.nanmax(y) |
|
590 | if ymax == None: ymax = numpy.nanmax(y) | |
591 |
|
591 | |||
592 | self.__isConfig = True |
|
592 | self.__isConfig = True | |
593 |
|
593 | |||
594 | self.setWinTitle(title) |
|
594 | self.setWinTitle(title) | |
595 |
|
595 | |||
596 | for i in range(len(self.axesList)): |
|
596 | for i in range(len(self.axesList)): | |
597 | title = "Channel %d" %(i) |
|
597 | title = "Channel %d" %(i) | |
598 | axes = self.axesList[i] |
|
598 | axes = self.axesList[i] | |
599 | ychannel = y[i,:] |
|
599 | ychannel = y[i,:] | |
600 | axes.pline(x, ychannel, |
|
600 | axes.pline(x, ychannel, | |
601 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
601 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
602 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
602 | xlabel=xlabel, ylabel=ylabel, title=title) | |
603 |
|
603 | |||
604 | self.draw() |
|
604 | self.draw() | |
605 |
|
605 | |||
606 | if save: |
|
606 | if save: | |
607 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
607 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
608 | if figfile == None: |
|
608 | if figfile == None: | |
609 | figfile = self.getFilename(name = date) |
|
609 | figfile = self.getFilename(name = date) | |
610 |
|
610 | |||
611 | self.saveFigure(figpath, figfile) |
|
611 | self.saveFigure(figpath, figfile) | |
612 |
|
612 | |||
613 | class ProfilePlot(Figure): |
|
613 | class PowerProfilePlot(Figure): | |
614 | __isConfig = None |
|
614 | __isConfig = None | |
615 | __nsubplots = None |
|
615 | __nsubplots = None | |
616 |
|
616 | |||
617 | WIDTHPROF = None |
|
617 | WIDTHPROF = None | |
618 | HEIGHTPROF = None |
|
618 | HEIGHTPROF = None | |
619 | PREFIX = 'spcprofile' |
|
619 | PREFIX = 'spcprofile' | |
620 |
|
620 | |||
621 | def __init__(self): |
|
621 | def __init__(self): | |
622 | self.__isConfig = False |
|
622 | self.__isConfig = False | |
623 | self.__nsubplots = 1 |
|
623 | self.__nsubplots = 1 | |
624 |
|
624 | |||
625 | self.WIDTH = 300 |
|
625 | self.WIDTH = 300 | |
626 | self.HEIGHT = 500 |
|
626 | self.HEIGHT = 500 | |
627 |
|
627 | |||
628 | def getSubplots(self): |
|
628 | def getSubplots(self): | |
629 | ncol = 1 |
|
629 | ncol = 1 | |
630 | nrow = 1 |
|
630 | nrow = 1 | |
631 |
|
631 | |||
632 | return nrow, ncol |
|
632 | return nrow, ncol | |
633 |
|
633 | |||
634 | def setup(self, idfigure, nplots, wintitle, show): |
|
634 | def setup(self, idfigure, nplots, wintitle, show): | |
635 |
|
635 | |||
636 | self.nplots = nplots |
|
636 | self.nplots = nplots | |
637 |
|
637 | |||
638 | ncolspan = 1 |
|
638 | ncolspan = 1 | |
639 | colspan = 1 |
|
639 | colspan = 1 | |
640 |
|
640 | |||
641 | self.createFigure(idfigure = idfigure, |
|
641 | self.createFigure(idfigure = idfigure, | |
642 | wintitle = wintitle, |
|
642 | wintitle = wintitle, | |
643 | widthplot = self.WIDTH, |
|
643 | widthplot = self.WIDTH, | |
644 | heightplot = self.HEIGHT, |
|
644 | heightplot = self.HEIGHT, | |
645 | show=show) |
|
645 | show=show) | |
646 |
|
646 | |||
647 | nrow, ncol = self.getSubplots() |
|
647 | nrow, ncol = self.getSubplots() | |
648 |
|
648 | |||
649 | counter = 0 |
|
649 | counter = 0 | |
650 | for y in range(nrow): |
|
650 | for y in range(nrow): | |
651 | for x in range(ncol): |
|
651 | for x in range(ncol): | |
652 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
652 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
653 |
|
653 | |||
654 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
654 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
655 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
655 | xmin=None, xmax=None, ymin=None, ymax=None, | |
656 | save=False, figpath='./', figfile=None, show=True): |
|
656 | save=False, figpath='./', figfile=None, show=True): | |
657 |
|
657 | |||
658 | if channelList == None: |
|
658 | if channelList == None: | |
659 | channelIndexList = dataOut.channelIndexList |
|
659 | channelIndexList = dataOut.channelIndexList | |
660 | channelList = dataOut.channelList |
|
660 | channelList = dataOut.channelList | |
661 | else: |
|
661 | else: | |
662 | channelIndexList = [] |
|
662 | channelIndexList = [] | |
663 | for channel in channelList: |
|
663 | for channel in channelList: | |
664 | if channel not in dataOut.channelList: |
|
664 | if channel not in dataOut.channelList: | |
665 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
665 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
666 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
666 | channelIndexList.append(dataOut.channelList.index(channel)) | |
667 |
|
667 | |||
668 | factor = dataOut.normFactor |
|
668 | factor = dataOut.normFactor | |
669 | y = dataOut.getHeiRange() |
|
669 | y = dataOut.getHeiRange() | |
670 | x = dataOut.data_spc[channelIndexList,:,:]/factor |
|
670 | x = dataOut.data_spc[channelIndexList,:,:]/factor | |
671 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
671 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
672 | avg = numpy.average(x, axis=1) |
|
672 | avg = numpy.average(x, axis=1) | |
673 |
|
673 | |||
674 | avgdB = 10*numpy.log10(avg) |
|
674 | avgdB = 10*numpy.log10(avg) | |
675 |
|
675 | |||
676 | thisDatetime = dataOut.datatime |
|
676 | thisDatetime = dataOut.datatime | |
677 | title = "Power Profile" |
|
677 | title = "Power Profile" | |
678 | xlabel = "dB" |
|
678 | xlabel = "dB" | |
679 | ylabel = "Range (Km)" |
|
679 | ylabel = "Range (Km)" | |
680 |
|
680 | |||
681 | if not self.__isConfig: |
|
681 | if not self.__isConfig: | |
682 |
|
682 | |||
683 | nplots = 1 |
|
683 | nplots = 1 | |
684 |
|
684 | |||
685 | self.setup(idfigure=idfigure, |
|
685 | self.setup(idfigure=idfigure, | |
686 | nplots=nplots, |
|
686 | nplots=nplots, | |
687 | wintitle=wintitle, |
|
687 | wintitle=wintitle, | |
688 | show=show) |
|
688 | show=show) | |
689 |
|
689 | |||
690 | if ymin == None: ymin = numpy.nanmin(y) |
|
690 | if ymin == None: ymin = numpy.nanmin(y) | |
691 | if ymax == None: ymax = numpy.nanmax(y) |
|
691 | if ymax == None: ymax = numpy.nanmax(y) | |
692 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 |
|
692 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 | |
693 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 |
|
693 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 | |
694 |
|
694 | |||
695 | self.__isConfig = True |
|
695 | self.__isConfig = True | |
696 |
|
696 | |||
697 | self.setWinTitle(title) |
|
697 | self.setWinTitle(title) | |
698 |
|
698 | |||
699 |
|
699 | |||
700 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
700 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
701 | axes = self.axesList[0] |
|
701 | axes = self.axesList[0] | |
702 |
|
702 | |||
703 | legendlabels = ["channel %d"%x for x in channelList] |
|
703 | legendlabels = ["channel %d"%x for x in channelList] | |
704 | axes.pmultiline(avgdB, y, |
|
704 | axes.pmultiline(avgdB, y, | |
705 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
705 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
706 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
706 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
707 | ytick_visible=True, nxticks=5, |
|
707 | ytick_visible=True, nxticks=5, | |
708 | grid='x') |
|
708 | grid='x') | |
709 |
|
709 | |||
710 | self.draw() |
|
710 | self.draw() | |
711 |
|
711 | |||
712 | if save: |
|
712 | if save: | |
713 | date = thisDatetime.strftime("%Y%m%d") |
|
713 | date = thisDatetime.strftime("%Y%m%d") | |
714 | if figfile == None: |
|
714 | if figfile == None: | |
715 | figfile = self.getFilename(name = date) |
|
715 | figfile = self.getFilename(name = date) | |
716 |
|
716 | |||
717 | self.saveFigure(figpath, figfile) |
|
717 | self.saveFigure(figpath, figfile) | |
718 |
|
718 | |||
719 | class CoherenceMap(Figure): |
|
719 | class CoherenceMap(Figure): | |
720 | __isConfig = None |
|
720 | __isConfig = None | |
721 | __nsubplots = None |
|
721 | __nsubplots = None | |
722 |
|
722 | |||
723 | WIDTHPROF = None |
|
723 | WIDTHPROF = None | |
724 | HEIGHTPROF = None |
|
724 | HEIGHTPROF = None | |
725 | PREFIX = 'cmap' |
|
725 | PREFIX = 'cmap' | |
726 |
|
726 | |||
727 | def __init__(self): |
|
727 | def __init__(self): | |
728 | self.timerange = 2*60*60 |
|
728 | self.timerange = 2*60*60 | |
729 | self.__isConfig = False |
|
729 | self.__isConfig = False | |
730 | self.__nsubplots = 1 |
|
730 | self.__nsubplots = 1 | |
731 |
|
731 | |||
732 | self.WIDTH = 800 |
|
732 | self.WIDTH = 800 | |
733 | self.HEIGHT = 150 |
|
733 | self.HEIGHT = 150 | |
734 | self.WIDTHPROF = 120 |
|
734 | self.WIDTHPROF = 120 | |
735 | self.HEIGHTPROF = 0 |
|
735 | self.HEIGHTPROF = 0 | |
736 | self.counterftp = 0 |
|
736 | self.counterftp = 0 | |
737 |
|
737 | |||
738 | def getSubplots(self): |
|
738 | def getSubplots(self): | |
739 | ncol = 1 |
|
739 | ncol = 1 | |
740 | nrow = self.nplots*2 |
|
740 | nrow = self.nplots*2 | |
741 |
|
741 | |||
742 | return nrow, ncol |
|
742 | return nrow, ncol | |
743 |
|
743 | |||
744 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): |
|
744 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): | |
745 | self.__showprofile = showprofile |
|
745 | self.__showprofile = showprofile | |
746 | self.nplots = nplots |
|
746 | self.nplots = nplots | |
747 |
|
747 | |||
748 | ncolspan = 1 |
|
748 | ncolspan = 1 | |
749 | colspan = 1 |
|
749 | colspan = 1 | |
750 | if showprofile: |
|
750 | if showprofile: | |
751 | ncolspan = 7 |
|
751 | ncolspan = 7 | |
752 | colspan = 6 |
|
752 | colspan = 6 | |
753 | self.__nsubplots = 2 |
|
753 | self.__nsubplots = 2 | |
754 |
|
754 | |||
755 | self.createFigure(idfigure = idfigure, |
|
755 | self.createFigure(idfigure = idfigure, | |
756 | wintitle = wintitle, |
|
756 | wintitle = wintitle, | |
757 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
757 | widthplot = self.WIDTH + self.WIDTHPROF, | |
758 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
758 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
759 | show=True) |
|
759 | show=True) | |
760 |
|
760 | |||
761 | nrow, ncol = self.getSubplots() |
|
761 | nrow, ncol = self.getSubplots() | |
762 |
|
762 | |||
763 | for y in range(nrow): |
|
763 | for y in range(nrow): | |
764 | for x in range(ncol): |
|
764 | for x in range(ncol): | |
765 |
|
765 | |||
766 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
766 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
767 |
|
767 | |||
768 | if showprofile: |
|
768 | if showprofile: | |
769 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
769 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
770 |
|
770 | |||
771 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
771 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
772 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
772 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
773 | timerange=None, |
|
773 | timerange=None, | |
774 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, |
|
774 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, | |
775 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True): |
|
775 | coherence_cmap='jet', phase_cmap='RdBu_r', show=True): | |
776 |
|
776 | |||
777 | if pairsList == None: |
|
777 | if pairsList == None: | |
778 | pairsIndexList = dataOut.pairsIndexList |
|
778 | pairsIndexList = dataOut.pairsIndexList | |
779 | else: |
|
779 | else: | |
780 | pairsIndexList = [] |
|
780 | pairsIndexList = [] | |
781 | for pair in pairsList: |
|
781 | for pair in pairsList: | |
782 | if pair not in dataOut.pairsList: |
|
782 | if pair not in dataOut.pairsList: | |
783 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
783 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
784 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
784 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
785 |
|
785 | |||
786 | if timerange != None: |
|
786 | if timerange != None: | |
787 | self.timerange = timerange |
|
787 | self.timerange = timerange | |
788 |
|
788 | |||
789 | if pairsIndexList == []: |
|
789 | if pairsIndexList == []: | |
790 | return |
|
790 | return | |
791 |
|
791 | |||
792 | if len(pairsIndexList) > 4: |
|
792 | if len(pairsIndexList) > 4: | |
793 | pairsIndexList = pairsIndexList[0:4] |
|
793 | pairsIndexList = pairsIndexList[0:4] | |
794 |
|
794 | |||
795 | tmin = None |
|
795 | tmin = None | |
796 | tmax = None |
|
796 | tmax = None | |
797 | x = dataOut.getTimeRange() |
|
797 | x = dataOut.getTimeRange() | |
798 | y = dataOut.getHeiRange() |
|
798 | y = dataOut.getHeiRange() | |
799 |
|
799 | |||
800 | thisDatetime = dataOut.datatime |
|
800 | thisDatetime = dataOut.datatime | |
801 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
801 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
802 | xlabel = "" |
|
802 | xlabel = "" | |
803 | ylabel = "Range (Km)" |
|
803 | ylabel = "Range (Km)" | |
804 |
|
804 | |||
805 | if not self.__isConfig: |
|
805 | if not self.__isConfig: | |
806 | nplots = len(pairsIndexList) |
|
806 | nplots = len(pairsIndexList) | |
807 | self.setup(idfigure=idfigure, |
|
807 | self.setup(idfigure=idfigure, | |
808 | nplots=nplots, |
|
808 | nplots=nplots, | |
809 | wintitle=wintitle, |
|
809 | wintitle=wintitle, | |
810 | showprofile=showprofile, |
|
810 | showprofile=showprofile, | |
811 | show=show) |
|
811 | show=show) | |
812 |
|
812 | |||
813 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
813 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
814 | if ymin == None: ymin = numpy.nanmin(y) |
|
814 | if ymin == None: ymin = numpy.nanmin(y) | |
815 | if ymax == None: ymax = numpy.nanmax(y) |
|
815 | if ymax == None: ymax = numpy.nanmax(y) | |
816 |
|
816 | |||
817 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
817 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
818 |
|
818 | |||
819 | self.__isConfig = True |
|
819 | self.__isConfig = True | |
820 |
|
820 | |||
821 | self.setWinTitle(title) |
|
821 | self.setWinTitle(title) | |
822 |
|
822 | |||
823 | for i in range(self.nplots): |
|
823 | for i in range(self.nplots): | |
824 |
|
824 | |||
825 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
825 | pair = dataOut.pairsList[pairsIndexList[i]] | |
826 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
826 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
827 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) |
|
827 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) | |
828 | coherence = numpy.abs(avgcoherenceComplex) |
|
828 | coherence = numpy.abs(avgcoherenceComplex) | |
829 | # coherence = numpy.abs(coherenceComplex) |
|
829 | # coherence = numpy.abs(coherenceComplex) | |
830 | # avg = numpy.average(coherence, axis=0) |
|
830 | # avg = numpy.average(coherence, axis=0) | |
831 |
|
831 | |||
832 | z = coherence.reshape((1,-1)) |
|
832 | z = coherence.reshape((1,-1)) | |
833 |
|
833 | |||
834 | counter = 0 |
|
834 | counter = 0 | |
835 |
|
835 | |||
836 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
836 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
837 | axes = self.axesList[i*self.__nsubplots*2] |
|
837 | axes = self.axesList[i*self.__nsubplots*2] | |
838 | axes.pcolorbuffer(x, y, z, |
|
838 | axes.pcolorbuffer(x, y, z, | |
839 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
839 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
840 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
840 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
841 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") |
|
841 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") | |
842 |
|
842 | |||
843 | if self.__showprofile: |
|
843 | if self.__showprofile: | |
844 | counter += 1 |
|
844 | counter += 1 | |
845 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
845 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
846 | axes.pline(coherence, y, |
|
846 | axes.pline(coherence, y, | |
847 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, |
|
847 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, | |
848 | xlabel='', ylabel='', title='', ticksize=7, |
|
848 | xlabel='', ylabel='', title='', ticksize=7, | |
849 | ytick_visible=False, nxticks=5, |
|
849 | ytick_visible=False, nxticks=5, | |
850 | grid='x') |
|
850 | grid='x') | |
851 |
|
851 | |||
852 | counter += 1 |
|
852 | counter += 1 | |
853 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
853 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
854 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
854 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
855 | # avg = numpy.average(phase, axis=0) |
|
855 | # avg = numpy.average(phase, axis=0) | |
856 | z = phase.reshape((1,-1)) |
|
856 | z = phase.reshape((1,-1)) | |
857 |
|
857 | |||
858 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
858 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
859 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
859 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
860 | axes.pcolorbuffer(x, y, z, |
|
860 | axes.pcolorbuffer(x, y, z, | |
861 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
861 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
862 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
862 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
863 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") |
|
863 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") | |
864 |
|
864 | |||
865 | if self.__showprofile: |
|
865 | if self.__showprofile: | |
866 | counter += 1 |
|
866 | counter += 1 | |
867 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
867 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
868 | axes.pline(phase, y, |
|
868 | axes.pline(phase, y, | |
869 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, |
|
869 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, | |
870 | xlabel='', ylabel='', title='', ticksize=7, |
|
870 | xlabel='', ylabel='', title='', ticksize=7, | |
871 | ytick_visible=False, nxticks=4, |
|
871 | ytick_visible=False, nxticks=4, | |
872 | grid='x') |
|
872 | grid='x') | |
873 |
|
873 | |||
874 | self.draw() |
|
874 | self.draw() | |
875 |
|
875 | |||
876 | if save: |
|
876 | if save: | |
877 |
|
877 | |||
878 | if figfile == None: |
|
878 | if figfile == None: | |
879 | figfile = self.getFilename(name = self.name) |
|
879 | figfile = self.getFilename(name = self.name) | |
880 |
|
880 | |||
881 | self.saveFigure(figpath, figfile) |
|
881 | self.saveFigure(figpath, figfile) | |
882 |
|
882 | |||
883 | self.counterftp += 1 |
|
883 | self.counterftp += 1 | |
884 | if (ftp and (self.counterftp==ftpratio)): |
|
884 | if (ftp and (self.counterftp==ftpratio)): | |
885 | figfilename = os.path.join(figpath,figfile) |
|
885 | figfilename = os.path.join(figpath,figfile) | |
886 | self.sendByFTP(figfilename) |
|
886 | self.sendByFTP(figfilename) | |
887 | self.counterftp = 0 |
|
887 | self.counterftp = 0 | |
888 |
|
888 | |||
889 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
889 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
890 | self.__isConfig = False |
|
890 | self.__isConfig = False | |
891 |
|
891 | |||
892 | class RTIfromNoise(Figure): |
|
892 | class RTIfromNoise(Figure): | |
893 |
|
893 | |||
894 | __isConfig = None |
|
894 | __isConfig = None | |
895 | __nsubplots = None |
|
895 | __nsubplots = None | |
896 |
|
896 | |||
897 | PREFIX = 'rtinoise' |
|
897 | PREFIX = 'rtinoise' | |
898 |
|
898 | |||
899 | def __init__(self): |
|
899 | def __init__(self): | |
900 |
|
900 | |||
901 | self.timerange = 24*60*60 |
|
901 | self.timerange = 24*60*60 | |
902 | self.__isConfig = False |
|
902 | self.__isConfig = False | |
903 | self.__nsubplots = 1 |
|
903 | self.__nsubplots = 1 | |
904 |
|
904 | |||
905 | self.WIDTH = 820 |
|
905 | self.WIDTH = 820 | |
906 | self.HEIGHT = 200 |
|
906 | self.HEIGHT = 200 | |
907 | self.WIDTHPROF = 120 |
|
907 | self.WIDTHPROF = 120 | |
908 | self.HEIGHTPROF = 0 |
|
908 | self.HEIGHTPROF = 0 | |
909 | self.xdata = None |
|
909 | self.xdata = None | |
910 | self.ydata = None |
|
910 | self.ydata = None | |
911 |
|
911 | |||
912 | def getSubplots(self): |
|
912 | def getSubplots(self): | |
913 |
|
913 | |||
914 | ncol = 1 |
|
914 | ncol = 1 | |
915 | nrow = 1 |
|
915 | nrow = 1 | |
916 |
|
916 | |||
917 | return nrow, ncol |
|
917 | return nrow, ncol | |
918 |
|
918 | |||
919 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): |
|
919 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): | |
920 |
|
920 | |||
921 | self.__showprofile = showprofile |
|
921 | self.__showprofile = showprofile | |
922 | self.nplots = nplots |
|
922 | self.nplots = nplots | |
923 |
|
923 | |||
924 | ncolspan = 7 |
|
924 | ncolspan = 7 | |
925 | colspan = 6 |
|
925 | colspan = 6 | |
926 | self.__nsubplots = 2 |
|
926 | self.__nsubplots = 2 | |
927 |
|
927 | |||
928 | self.createFigure(idfigure = idfigure, |
|
928 | self.createFigure(idfigure = idfigure, | |
929 | wintitle = wintitle, |
|
929 | wintitle = wintitle, | |
930 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
930 | widthplot = self.WIDTH+self.WIDTHPROF, | |
931 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
931 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
932 | show=show) |
|
932 | show=show) | |
933 |
|
933 | |||
934 | nrow, ncol = self.getSubplots() |
|
934 | nrow, ncol = self.getSubplots() | |
935 |
|
935 | |||
936 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
936 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
937 |
|
937 | |||
938 |
|
938 | |||
939 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
939 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
940 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
940 | xmin=None, xmax=None, ymin=None, ymax=None, | |
941 | timerange=None, |
|
941 | timerange=None, | |
942 | save=False, figpath='./', figfile=None, show=True): |
|
942 | save=False, figpath='./', figfile=None, show=True): | |
943 |
|
943 | |||
944 | if channelList == None: |
|
944 | if channelList == None: | |
945 | channelIndexList = dataOut.channelIndexList |
|
945 | channelIndexList = dataOut.channelIndexList | |
946 | channelList = dataOut.channelList |
|
946 | channelList = dataOut.channelList | |
947 | else: |
|
947 | else: | |
948 | channelIndexList = [] |
|
948 | channelIndexList = [] | |
949 | for channel in channelList: |
|
949 | for channel in channelList: | |
950 | if channel not in dataOut.channelList: |
|
950 | if channel not in dataOut.channelList: | |
951 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
951 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
952 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
952 | channelIndexList.append(dataOut.channelList.index(channel)) | |
953 |
|
953 | |||
954 | if timerange != None: |
|
954 | if timerange != None: | |
955 | self.timerange = timerange |
|
955 | self.timerange = timerange | |
956 |
|
956 | |||
957 | tmin = None |
|
957 | tmin = None | |
958 | tmax = None |
|
958 | tmax = None | |
959 | x = dataOut.getTimeRange() |
|
959 | x = dataOut.getTimeRange() | |
960 | y = dataOut.getHeiRange() |
|
960 | y = dataOut.getHeiRange() | |
961 | factor = dataOut.normFactor |
|
961 | factor = dataOut.normFactor | |
962 | noise = dataOut.getNoise()/factor |
|
962 | noise = dataOut.getNoise()/factor | |
963 | noisedB = 10*numpy.log10(noise) |
|
963 | noisedB = 10*numpy.log10(noise) | |
964 |
|
964 | |||
965 | thisDatetime = dataOut.datatime |
|
965 | thisDatetime = dataOut.datatime | |
966 | title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
966 | title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
967 | xlabel = "" |
|
967 | xlabel = "" | |
968 | ylabel = "Range (Km)" |
|
968 | ylabel = "Range (Km)" | |
969 |
|
969 | |||
970 | if not self.__isConfig: |
|
970 | if not self.__isConfig: | |
971 |
|
971 | |||
972 | nplots = 1 |
|
972 | nplots = 1 | |
973 |
|
973 | |||
974 | self.setup(idfigure=idfigure, |
|
974 | self.setup(idfigure=idfigure, | |
975 | nplots=nplots, |
|
975 | nplots=nplots, | |
976 | wintitle=wintitle, |
|
976 | wintitle=wintitle, | |
977 | showprofile=showprofile, |
|
977 | showprofile=showprofile, | |
978 | show=show) |
|
978 | show=show) | |
979 |
|
979 | |||
980 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
980 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
981 | if ymin == None: ymin = numpy.nanmin(noisedB) |
|
981 | if ymin == None: ymin = numpy.nanmin(noisedB) | |
982 | if ymax == None: ymax = numpy.nanmax(noisedB) |
|
982 | if ymax == None: ymax = numpy.nanmax(noisedB) | |
983 |
|
983 | |||
984 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
984 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
985 | self.__isConfig = True |
|
985 | self.__isConfig = True | |
986 |
|
986 | |||
987 | self.xdata = numpy.array([]) |
|
987 | self.xdata = numpy.array([]) | |
988 | self.ydata = numpy.array([]) |
|
988 | self.ydata = numpy.array([]) | |
989 |
|
989 | |||
990 | self.setWinTitle(title) |
|
990 | self.setWinTitle(title) | |
991 |
|
991 | |||
992 |
|
992 | |||
993 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
993 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
994 |
|
994 | |||
995 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] |
|
995 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] | |
996 | axes = self.axesList[0] |
|
996 | axes = self.axesList[0] | |
997 |
|
997 | |||
998 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
998 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
999 |
|
999 | |||
1000 | if len(self.ydata)==0: |
|
1000 | if len(self.ydata)==0: | |
1001 | self.ydata = noisedB[channelIndexList].reshape(-1,1) |
|
1001 | self.ydata = noisedB[channelIndexList].reshape(-1,1) | |
1002 | else: |
|
1002 | else: | |
1003 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) |
|
1003 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) | |
1004 |
|
1004 | |||
1005 |
|
1005 | |||
1006 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1006 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1007 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
1007 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | |
1008 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
1008 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
1009 | XAxisAsTime=True |
|
1009 | XAxisAsTime=True | |
1010 | ) |
|
1010 | ) | |
1011 |
|
1011 | |||
1012 | self.draw() |
|
1012 | self.draw() | |
1013 |
|
1013 | |||
1014 | if save: |
|
1014 | if save: | |
1015 |
|
1015 | |||
1016 | if figfile == None: |
|
1016 | if figfile == None: | |
1017 | figfile = self.getFilename(name = self.name) |
|
1017 | figfile = self.getFilename(name = self.name) | |
1018 |
|
1018 | |||
1019 | self.saveFigure(figpath, figfile) |
|
1019 | self.saveFigure(figpath, figfile) | |
1020 |
|
1020 | |||
1021 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1021 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
1022 | self.__isConfig = False |
|
1022 | self.__isConfig = False | |
1023 | del self.xdata |
|
1023 | del self.xdata | |
1024 | del self.ydata |
|
1024 | del self.ydata | |
1025 |
|
1025 | |||
1026 |
|
1026 | |||
1027 | class SpectraHeisScope(Figure): |
|
1027 | class SpectraHeisScope(Figure): | |
1028 |
|
1028 | |||
1029 |
|
1029 | |||
1030 | __isConfig = None |
|
1030 | __isConfig = None | |
1031 | __nsubplots = None |
|
1031 | __nsubplots = None | |
1032 |
|
1032 | |||
1033 | WIDTHPROF = None |
|
1033 | WIDTHPROF = None | |
1034 | HEIGHTPROF = None |
|
1034 | HEIGHTPROF = None | |
1035 | PREFIX = 'spc' |
|
1035 | PREFIX = 'spc' | |
1036 |
|
1036 | |||
1037 | def __init__(self): |
|
1037 | def __init__(self): | |
1038 |
|
1038 | |||
1039 | self.__isConfig = False |
|
1039 | self.__isConfig = False | |
1040 | self.__nsubplots = 1 |
|
1040 | self.__nsubplots = 1 | |
1041 |
|
1041 | |||
1042 | self.WIDTH = 230 |
|
1042 | self.WIDTH = 230 | |
1043 | self.HEIGHT = 250 |
|
1043 | self.HEIGHT = 250 | |
1044 | self.WIDTHPROF = 120 |
|
1044 | self.WIDTHPROF = 120 | |
1045 | self.HEIGHTPROF = 0 |
|
1045 | self.HEIGHTPROF = 0 | |
1046 | self.counterftp = 0 |
|
1046 | self.counterftp = 0 | |
1047 |
|
1047 | |||
1048 | def getSubplots(self): |
|
1048 | def getSubplots(self): | |
1049 |
|
1049 | |||
1050 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
1050 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
1051 | nrow = int(self.nplots*1./ncol + 0.9) |
|
1051 | nrow = int(self.nplots*1./ncol + 0.9) | |
1052 |
|
1052 | |||
1053 | return nrow, ncol |
|
1053 | return nrow, ncol | |
1054 |
|
1054 | |||
1055 | def setup(self, idfigure, nplots, wintitle, show): |
|
1055 | def setup(self, idfigure, nplots, wintitle, show): | |
1056 |
|
1056 | |||
1057 | showprofile = False |
|
1057 | showprofile = False | |
1058 | self.__showprofile = showprofile |
|
1058 | self.__showprofile = showprofile | |
1059 | self.nplots = nplots |
|
1059 | self.nplots = nplots | |
1060 |
|
1060 | |||
1061 | ncolspan = 1 |
|
1061 | ncolspan = 1 | |
1062 | colspan = 1 |
|
1062 | colspan = 1 | |
1063 | if showprofile: |
|
1063 | if showprofile: | |
1064 | ncolspan = 3 |
|
1064 | ncolspan = 3 | |
1065 | colspan = 2 |
|
1065 | colspan = 2 | |
1066 | self.__nsubplots = 2 |
|
1066 | self.__nsubplots = 2 | |
1067 |
|
1067 | |||
1068 | self.createFigure(idfigure = idfigure, |
|
1068 | self.createFigure(idfigure = idfigure, | |
1069 | wintitle = wintitle, |
|
1069 | wintitle = wintitle, | |
1070 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
1070 | widthplot = self.WIDTH + self.WIDTHPROF, | |
1071 | heightplot = self.HEIGHT + self.HEIGHTPROF, |
|
1071 | heightplot = self.HEIGHT + self.HEIGHTPROF, | |
1072 | show = show) |
|
1072 | show = show) | |
1073 |
|
1073 | |||
1074 | nrow, ncol = self.getSubplots() |
|
1074 | nrow, ncol = self.getSubplots() | |
1075 |
|
1075 | |||
1076 | counter = 0 |
|
1076 | counter = 0 | |
1077 | for y in range(nrow): |
|
1077 | for y in range(nrow): | |
1078 | for x in range(ncol): |
|
1078 | for x in range(ncol): | |
1079 |
|
1079 | |||
1080 | if counter >= self.nplots: |
|
1080 | if counter >= self.nplots: | |
1081 | break |
|
1081 | break | |
1082 |
|
1082 | |||
1083 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
1083 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
1084 |
|
1084 | |||
1085 | if showprofile: |
|
1085 | if showprofile: | |
1086 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
1086 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
1087 |
|
1087 | |||
1088 | counter += 1 |
|
1088 | counter += 1 | |
1089 |
|
1089 | |||
1090 | # __isConfig = None |
|
1090 | # __isConfig = None | |
1091 | # def __init__(self): |
|
1091 | # def __init__(self): | |
1092 | # |
|
1092 | # | |
1093 | # self.__isConfig = False |
|
1093 | # self.__isConfig = False | |
1094 | # self.WIDTH = 600 |
|
1094 | # self.WIDTH = 600 | |
1095 | # self.HEIGHT = 200 |
|
1095 | # self.HEIGHT = 200 | |
1096 | # |
|
1096 | # | |
1097 | # def getSubplots(self): |
|
1097 | # def getSubplots(self): | |
1098 | # |
|
1098 | # | |
1099 | # nrow = self.nplots |
|
1099 | # nrow = self.nplots | |
1100 | # ncol = 3 |
|
1100 | # ncol = 3 | |
1101 | # return nrow, ncol |
|
1101 | # return nrow, ncol | |
1102 | # |
|
1102 | # | |
1103 | # def setup(self, idfigure, nplots, wintitle): |
|
1103 | # def setup(self, idfigure, nplots, wintitle): | |
1104 | # |
|
1104 | # | |
1105 | # self.nplots = nplots |
|
1105 | # self.nplots = nplots | |
1106 | # |
|
1106 | # | |
1107 | # self.createFigure(idfigure, wintitle) |
|
1107 | # self.createFigure(idfigure, wintitle) | |
1108 | # |
|
1108 | # | |
1109 | # nrow,ncol = self.getSubplots() |
|
1109 | # nrow,ncol = self.getSubplots() | |
1110 | # colspan = 3 |
|
1110 | # colspan = 3 | |
1111 | # rowspan = 1 |
|
1111 | # rowspan = 1 | |
1112 | # |
|
1112 | # | |
1113 | # for i in range(nplots): |
|
1113 | # for i in range(nplots): | |
1114 | # self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
1114 | # self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
1115 |
|
1115 | |||
1116 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
1116 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
1117 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
1117 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, | |
1118 | figpath='./', figfile=None, ftp=False, ftpratio=1, show=True): |
|
1118 | figpath='./', figfile=None, ftp=False, ftpratio=1, show=True): | |
1119 |
|
1119 | |||
1120 | """ |
|
1120 | """ | |
1121 |
|
1121 | |||
1122 | Input: |
|
1122 | Input: | |
1123 | dataOut : |
|
1123 | dataOut : | |
1124 | idfigure : |
|
1124 | idfigure : | |
1125 | wintitle : |
|
1125 | wintitle : | |
1126 | channelList : |
|
1126 | channelList : | |
1127 | xmin : None, |
|
1127 | xmin : None, | |
1128 | xmax : None, |
|
1128 | xmax : None, | |
1129 | ymin : None, |
|
1129 | ymin : None, | |
1130 | ymax : None, |
|
1130 | ymax : None, | |
1131 | """ |
|
1131 | """ | |
1132 |
|
1132 | |||
1133 | if dataOut.realtime: |
|
1133 | if dataOut.realtime: | |
1134 | if not(isRealtime(utcdatatime = dataOut.utctime)): |
|
1134 | if not(isRealtime(utcdatatime = dataOut.utctime)): | |
1135 | print 'Skipping this plot function' |
|
1135 | print 'Skipping this plot function' | |
1136 | return |
|
1136 | return | |
1137 |
|
1137 | |||
1138 | if channelList == None: |
|
1138 | if channelList == None: | |
1139 | channelIndexList = dataOut.channelIndexList |
|
1139 | channelIndexList = dataOut.channelIndexList | |
1140 | else: |
|
1140 | else: | |
1141 | channelIndexList = [] |
|
1141 | channelIndexList = [] | |
1142 | for channel in channelList: |
|
1142 | for channel in channelList: | |
1143 | if channel not in dataOut.channelList: |
|
1143 | if channel not in dataOut.channelList: | |
1144 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1144 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1145 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1145 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1146 |
|
1146 | |||
1147 | # x = dataOut.heightList |
|
1147 | # x = dataOut.heightList | |
1148 | c = 3E8 |
|
1148 | c = 3E8 | |
1149 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] |
|
1149 | deltaHeight = dataOut.heightList[1] - dataOut.heightList[0] | |
1150 | #deberia cambiar para el caso de 1Mhz y 100KHz |
|
1150 | #deberia cambiar para el caso de 1Mhz y 100KHz | |
1151 | x = numpy.arange(-1*dataOut.nHeights/2.,dataOut.nHeights/2.)*(c/(2*deltaHeight*dataOut.nHeights*1000)) |
|
1151 | x = numpy.arange(-1*dataOut.nHeights/2.,dataOut.nHeights/2.)*(c/(2*deltaHeight*dataOut.nHeights*1000)) | |
1152 | x= x/(10000.0) |
|
1152 | x= x/(10000.0) | |
1153 | # y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
1153 | # y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
1154 | # y = y.real |
|
1154 | # y = y.real | |
1155 | datadB = 10.*numpy.log10(dataOut.data_spc) |
|
1155 | datadB = 10.*numpy.log10(dataOut.data_spc) | |
1156 | y = datadB |
|
1156 | y = datadB | |
1157 |
|
1157 | |||
1158 | thisDatetime = dataOut.datatime |
|
1158 | thisDatetime = dataOut.datatime | |
1159 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1159 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1160 | xlabel = "Frequency x 10000" |
|
1160 | xlabel = "Frequency x 10000" | |
1161 | ylabel = "Intensity (dB)" |
|
1161 | ylabel = "Intensity (dB)" | |
1162 |
|
1162 | |||
1163 | if not self.__isConfig: |
|
1163 | if not self.__isConfig: | |
1164 | nplots = len(channelIndexList) |
|
1164 | nplots = len(channelIndexList) | |
1165 |
|
1165 | |||
1166 | self.setup(idfigure=idfigure, |
|
1166 | self.setup(idfigure=idfigure, | |
1167 | nplots=nplots, |
|
1167 | nplots=nplots, | |
1168 | wintitle=wintitle, |
|
1168 | wintitle=wintitle, | |
1169 | show=show) |
|
1169 | show=show) | |
1170 |
|
1170 | |||
1171 | if xmin == None: xmin = numpy.nanmin(x) |
|
1171 | if xmin == None: xmin = numpy.nanmin(x) | |
1172 | if xmax == None: xmax = numpy.nanmax(x) |
|
1172 | if xmax == None: xmax = numpy.nanmax(x) | |
1173 | if ymin == None: ymin = numpy.nanmin(y) |
|
1173 | if ymin == None: ymin = numpy.nanmin(y) | |
1174 | if ymax == None: ymax = numpy.nanmax(y) |
|
1174 | if ymax == None: ymax = numpy.nanmax(y) | |
1175 |
|
1175 | |||
1176 | self.__isConfig = True |
|
1176 | self.__isConfig = True | |
1177 |
|
1177 | |||
1178 | self.setWinTitle(title) |
|
1178 | self.setWinTitle(title) | |
1179 |
|
1179 | |||
1180 | for i in range(len(self.axesList)): |
|
1180 | for i in range(len(self.axesList)): | |
1181 | ychannel = y[i,:] |
|
1181 | ychannel = y[i,:] | |
1182 | title = "Channel %d - peak:%.2f" %(i,numpy.max(ychannel)) |
|
1182 | title = "Channel %d - peak:%.2f" %(i,numpy.max(ychannel)) | |
1183 | axes = self.axesList[i] |
|
1183 | axes = self.axesList[i] | |
1184 | axes.pline(x, ychannel, |
|
1184 | axes.pline(x, ychannel, | |
1185 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
1185 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
1186 | xlabel=xlabel, ylabel=ylabel, title=title, grid='both') |
|
1186 | xlabel=xlabel, ylabel=ylabel, title=title, grid='both') | |
1187 |
|
1187 | |||
1188 |
|
1188 | |||
1189 | self.draw() |
|
1189 | self.draw() | |
1190 |
|
1190 | |||
1191 | if save: |
|
1191 | if save: | |
1192 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1192 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1193 | if figfile == None: |
|
1193 | if figfile == None: | |
1194 | figfile = self.getFilename(name = date) |
|
1194 | figfile = self.getFilename(name = date) | |
1195 |
|
1195 | |||
1196 | self.saveFigure(figpath, figfile) |
|
1196 | self.saveFigure(figpath, figfile) | |
1197 |
|
1197 | |||
1198 | self.counterftp += 1 |
|
1198 | self.counterftp += 1 | |
1199 | if (ftp and (self.counterftp==ftpratio)): |
|
1199 | if (ftp and (self.counterftp==ftpratio)): | |
1200 | figfilename = os.path.join(figpath,figfile) |
|
1200 | figfilename = os.path.join(figpath,figfile) | |
1201 | self.sendByFTP(figfilename) |
|
1201 | self.sendByFTP(figfilename) | |
1202 | self.counterftp = 0 |
|
1202 | self.counterftp = 0 | |
1203 |
|
1203 | |||
1204 |
|
1204 | |||
1205 | class RTIfromSpectraHeis(Figure): |
|
1205 | class RTIfromSpectraHeis(Figure): | |
1206 |
|
1206 | |||
1207 | __isConfig = None |
|
1207 | __isConfig = None | |
1208 | __nsubplots = None |
|
1208 | __nsubplots = None | |
1209 |
|
1209 | |||
1210 | PREFIX = 'rtinoise' |
|
1210 | PREFIX = 'rtinoise' | |
1211 |
|
1211 | |||
1212 | def __init__(self): |
|
1212 | def __init__(self): | |
1213 |
|
1213 | |||
1214 | self.timerange = 24*60*60 |
|
1214 | self.timerange = 24*60*60 | |
1215 | self.__isConfig = False |
|
1215 | self.__isConfig = False | |
1216 | self.__nsubplots = 1 |
|
1216 | self.__nsubplots = 1 | |
1217 |
|
1217 | |||
1218 | self.WIDTH = 820 |
|
1218 | self.WIDTH = 820 | |
1219 | self.HEIGHT = 200 |
|
1219 | self.HEIGHT = 200 | |
1220 | self.WIDTHPROF = 120 |
|
1220 | self.WIDTHPROF = 120 | |
1221 | self.HEIGHTPROF = 0 |
|
1221 | self.HEIGHTPROF = 0 | |
1222 | self.counterftp = 0 |
|
1222 | self.counterftp = 0 | |
1223 | self.xdata = None |
|
1223 | self.xdata = None | |
1224 | self.ydata = None |
|
1224 | self.ydata = None | |
1225 |
|
1225 | |||
1226 | def getSubplots(self): |
|
1226 | def getSubplots(self): | |
1227 |
|
1227 | |||
1228 | ncol = 1 |
|
1228 | ncol = 1 | |
1229 | nrow = 1 |
|
1229 | nrow = 1 | |
1230 |
|
1230 | |||
1231 | return nrow, ncol |
|
1231 | return nrow, ncol | |
1232 |
|
1232 | |||
1233 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): |
|
1233 | def setup(self, idfigure, nplots, wintitle, showprofile=True, show=True): | |
1234 |
|
1234 | |||
1235 | self.__showprofile = showprofile |
|
1235 | self.__showprofile = showprofile | |
1236 | self.nplots = nplots |
|
1236 | self.nplots = nplots | |
1237 |
|
1237 | |||
1238 | ncolspan = 7 |
|
1238 | ncolspan = 7 | |
1239 | colspan = 6 |
|
1239 | colspan = 6 | |
1240 | self.__nsubplots = 2 |
|
1240 | self.__nsubplots = 2 | |
1241 |
|
1241 | |||
1242 | self.createFigure(idfigure = idfigure, |
|
1242 | self.createFigure(idfigure = idfigure, | |
1243 | wintitle = wintitle, |
|
1243 | wintitle = wintitle, | |
1244 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
1244 | widthplot = self.WIDTH+self.WIDTHPROF, | |
1245 | heightplot = self.HEIGHT+self.HEIGHTPROF, |
|
1245 | heightplot = self.HEIGHT+self.HEIGHTPROF, | |
1246 | show = show) |
|
1246 | show = show) | |
1247 |
|
1247 | |||
1248 | nrow, ncol = self.getSubplots() |
|
1248 | nrow, ncol = self.getSubplots() | |
1249 |
|
1249 | |||
1250 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
1250 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
1251 |
|
1251 | |||
1252 |
|
1252 | |||
1253 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
1253 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
1254 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
1254 | xmin=None, xmax=None, ymin=None, ymax=None, | |
1255 | timerange=None, |
|
1255 | timerange=None, | |
1256 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, show=True): |
|
1256 | save=False, figpath='./', figfile=None, ftp=False, ftpratio=1, show=True): | |
1257 |
|
1257 | |||
1258 | if channelList == None: |
|
1258 | if channelList == None: | |
1259 | channelIndexList = dataOut.channelIndexList |
|
1259 | channelIndexList = dataOut.channelIndexList | |
1260 | channelList = dataOut.channelList |
|
1260 | channelList = dataOut.channelList | |
1261 | else: |
|
1261 | else: | |
1262 | channelIndexList = [] |
|
1262 | channelIndexList = [] | |
1263 | for channel in channelList: |
|
1263 | for channel in channelList: | |
1264 | if channel not in dataOut.channelList: |
|
1264 | if channel not in dataOut.channelList: | |
1265 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
1265 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
1266 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
1266 | channelIndexList.append(dataOut.channelList.index(channel)) | |
1267 |
|
1267 | |||
1268 | if timerange != None: |
|
1268 | if timerange != None: | |
1269 | self.timerange = timerange |
|
1269 | self.timerange = timerange | |
1270 |
|
1270 | |||
1271 | tmin = None |
|
1271 | tmin = None | |
1272 | tmax = None |
|
1272 | tmax = None | |
1273 | x = dataOut.getTimeRange() |
|
1273 | x = dataOut.getTimeRange() | |
1274 | y = dataOut.getHeiRange() |
|
1274 | y = dataOut.getHeiRange() | |
1275 |
|
1275 | |||
1276 | factor = 1 |
|
1276 | factor = 1 | |
1277 | data = dataOut.data_spc/factor |
|
1277 | data = dataOut.data_spc/factor | |
1278 | data = numpy.average(data,axis=1) |
|
1278 | data = numpy.average(data,axis=1) | |
1279 | datadB = 10*numpy.log10(data) |
|
1279 | datadB = 10*numpy.log10(data) | |
1280 |
|
1280 | |||
1281 | # factor = dataOut.normFactor |
|
1281 | # factor = dataOut.normFactor | |
1282 | # noise = dataOut.getNoise()/factor |
|
1282 | # noise = dataOut.getNoise()/factor | |
1283 | # noisedB = 10*numpy.log10(noise) |
|
1283 | # noisedB = 10*numpy.log10(noise) | |
1284 |
|
1284 | |||
1285 | thisDatetime = dataOut.datatime |
|
1285 | thisDatetime = dataOut.datatime | |
1286 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1286 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1287 | xlabel = "Local Time" |
|
1287 | xlabel = "Local Time" | |
1288 | ylabel = "Intensity (dB)" |
|
1288 | ylabel = "Intensity (dB)" | |
1289 |
|
1289 | |||
1290 | if not self.__isConfig: |
|
1290 | if not self.__isConfig: | |
1291 |
|
1291 | |||
1292 | nplots = 1 |
|
1292 | nplots = 1 | |
1293 |
|
1293 | |||
1294 | self.setup(idfigure=idfigure, |
|
1294 | self.setup(idfigure=idfigure, | |
1295 | nplots=nplots, |
|
1295 | nplots=nplots, | |
1296 | wintitle=wintitle, |
|
1296 | wintitle=wintitle, | |
1297 | showprofile=showprofile, |
|
1297 | showprofile=showprofile, | |
1298 | show=show) |
|
1298 | show=show) | |
1299 |
|
1299 | |||
1300 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
1300 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
1301 | if ymin == None: ymin = numpy.nanmin(datadB) |
|
1301 | if ymin == None: ymin = numpy.nanmin(datadB) | |
1302 | if ymax == None: ymax = numpy.nanmax(datadB) |
|
1302 | if ymax == None: ymax = numpy.nanmax(datadB) | |
1303 |
|
1303 | |||
1304 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
1304 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
1305 | self.__isConfig = True |
|
1305 | self.__isConfig = True | |
1306 |
|
1306 | |||
1307 | self.xdata = numpy.array([]) |
|
1307 | self.xdata = numpy.array([]) | |
1308 | self.ydata = numpy.array([]) |
|
1308 | self.ydata = numpy.array([]) | |
1309 |
|
1309 | |||
1310 | self.setWinTitle(title) |
|
1310 | self.setWinTitle(title) | |
1311 |
|
1311 | |||
1312 |
|
1312 | |||
1313 | # title = "RTI %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
1313 | # title = "RTI %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
1314 | title = "RTI-Noise - %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
1314 | title = "RTI-Noise - %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
1315 |
|
1315 | |||
1316 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] |
|
1316 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] | |
1317 | axes = self.axesList[0] |
|
1317 | axes = self.axesList[0] | |
1318 |
|
1318 | |||
1319 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
1319 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
1320 |
|
1320 | |||
1321 | if len(self.ydata)==0: |
|
1321 | if len(self.ydata)==0: | |
1322 | self.ydata = datadB[channelIndexList].reshape(-1,1) |
|
1322 | self.ydata = datadB[channelIndexList].reshape(-1,1) | |
1323 | else: |
|
1323 | else: | |
1324 | self.ydata = numpy.hstack((self.ydata, datadB[channelIndexList].reshape(-1,1))) |
|
1324 | self.ydata = numpy.hstack((self.ydata, datadB[channelIndexList].reshape(-1,1))) | |
1325 |
|
1325 | |||
1326 |
|
1326 | |||
1327 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
1327 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
1328 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
1328 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | |
1329 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='.', markersize=8, linestyle="solid", grid='both', |
|
1329 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='.', markersize=8, linestyle="solid", grid='both', | |
1330 | XAxisAsTime=True |
|
1330 | XAxisAsTime=True | |
1331 | ) |
|
1331 | ) | |
1332 |
|
1332 | |||
1333 | self.draw() |
|
1333 | self.draw() | |
1334 |
|
1334 | |||
1335 | if save: |
|
1335 | if save: | |
1336 |
|
1336 | |||
1337 | if figfile == None: |
|
1337 | if figfile == None: | |
1338 | figfile = self.getFilename(name = self.name) |
|
1338 | figfile = self.getFilename(name = self.name) | |
1339 |
|
1339 | |||
1340 | self.saveFigure(figpath, figfile) |
|
1340 | self.saveFigure(figpath, figfile) | |
1341 |
|
1341 | |||
1342 | self.counterftp += 1 |
|
1342 | self.counterftp += 1 | |
1343 | if (ftp and (self.counterftp==ftpratio)): |
|
1343 | if (ftp and (self.counterftp==ftpratio)): | |
1344 | figfilename = os.path.join(figpath,figfile) |
|
1344 | figfilename = os.path.join(figpath,figfile) | |
1345 | self.sendByFTP(figfilename) |
|
1345 | self.sendByFTP(figfilename) | |
1346 | self.counterftp = 0 |
|
1346 | self.counterftp = 0 | |
1347 |
|
1347 | |||
1348 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
1348 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
1349 | self.__isConfig = False |
|
1349 | self.__isConfig = False | |
1350 | del self.xdata |
|
1350 | del self.xdata | |
1351 | del self.ydata |
|
1351 | del self.ydata | |
1352 |
|
1352 | |||
1353 |
|
1353 | |||
1354 | No newline at end of file |
|
1354 |
General Comments 0
You need to be logged in to leave comments.
Login now