@@ -1,990 +1,990 | |||||
1 | import numpy |
|
1 | import numpy | |
2 | import time, datetime |
|
2 | import time, datetime | |
3 | from graphics.figure import * |
|
3 | from graphics.figure import * | |
4 |
|
4 | |||
5 | class CrossSpectraPlot(Figure): |
|
5 | class CrossSpectraPlot(Figure): | |
6 |
|
6 | |||
7 | __isConfig = None |
|
7 | __isConfig = None | |
8 | __nsubplots = None |
|
8 | __nsubplots = None | |
9 |
|
9 | |||
10 | WIDTH = None |
|
10 | WIDTH = None | |
11 | HEIGHT = None |
|
11 | HEIGHT = None | |
12 | WIDTHPROF = None |
|
12 | WIDTHPROF = None | |
13 | HEIGHTPROF = None |
|
13 | HEIGHTPROF = None | |
14 | PREFIX = 'cspc' |
|
14 | PREFIX = 'cspc' | |
15 |
|
15 | |||
16 | def __init__(self): |
|
16 | def __init__(self): | |
17 |
|
17 | |||
18 | self.__isConfig = False |
|
18 | self.__isConfig = False | |
19 | self.__nsubplots = 4 |
|
19 | self.__nsubplots = 4 | |
20 |
|
20 | |||
21 | self.WIDTH = 250 |
|
21 | self.WIDTH = 250 | |
22 | self.HEIGHT = 250 |
|
22 | self.HEIGHT = 250 | |
23 | self.WIDTHPROF = 0 |
|
23 | self.WIDTHPROF = 0 | |
24 | self.HEIGHTPROF = 0 |
|
24 | self.HEIGHTPROF = 0 | |
25 |
|
25 | |||
26 | def getSubplots(self): |
|
26 | def getSubplots(self): | |
27 |
|
27 | |||
28 | ncol = 4 |
|
28 | ncol = 4 | |
29 | nrow = self.nplots |
|
29 | nrow = self.nplots | |
30 |
|
30 | |||
31 | return nrow, ncol |
|
31 | return nrow, ncol | |
32 |
|
32 | |||
33 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
33 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
34 |
|
34 | |||
35 | self.__showprofile = showprofile |
|
35 | self.__showprofile = showprofile | |
36 | self.nplots = nplots |
|
36 | self.nplots = nplots | |
37 |
|
37 | |||
38 | ncolspan = 1 |
|
38 | ncolspan = 1 | |
39 | colspan = 1 |
|
39 | colspan = 1 | |
40 |
|
40 | |||
41 | self.createFigure(idfigure = idfigure, |
|
41 | self.createFigure(idfigure = idfigure, | |
42 | wintitle = wintitle, |
|
42 | wintitle = wintitle, | |
43 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
43 | widthplot = self.WIDTH + self.WIDTHPROF, | |
44 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
44 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
45 |
|
45 | |||
46 | nrow, ncol = self.getSubplots() |
|
46 | nrow, ncol = self.getSubplots() | |
47 |
|
47 | |||
48 | counter = 0 |
|
48 | counter = 0 | |
49 | for y in range(nrow): |
|
49 | for y in range(nrow): | |
50 | for x in range(ncol): |
|
50 | for x in range(ncol): | |
51 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
51 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
52 |
|
52 | |||
53 | counter += 1 |
|
53 | counter += 1 | |
54 |
|
54 | |||
55 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
55 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
56 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
56 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
57 | save=False, figpath='./', figfile=None, |
|
57 | save=False, figpath='./', figfile=None, | |
58 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r'): |
|
58 | power_cmap='jet', coherence_cmap='jet', phase_cmap='RdBu_r'): | |
59 |
|
59 | |||
60 | """ |
|
60 | """ | |
61 |
|
61 | |||
62 | Input: |
|
62 | Input: | |
63 | dataOut : |
|
63 | dataOut : | |
64 | idfigure : |
|
64 | idfigure : | |
65 | wintitle : |
|
65 | wintitle : | |
66 | channelList : |
|
66 | channelList : | |
67 | showProfile : |
|
67 | showProfile : | |
68 | xmin : None, |
|
68 | xmin : None, | |
69 | xmax : None, |
|
69 | xmax : None, | |
70 | ymin : None, |
|
70 | ymin : None, | |
71 | ymax : None, |
|
71 | ymax : None, | |
72 | zmin : None, |
|
72 | zmin : None, | |
73 | zmax : None |
|
73 | zmax : None | |
74 | """ |
|
74 | """ | |
75 |
|
75 | |||
76 | if pairsList == None: |
|
76 | if pairsList == None: | |
77 | pairsIndexList = dataOut.pairsIndexList |
|
77 | pairsIndexList = dataOut.pairsIndexList | |
78 | else: |
|
78 | else: | |
79 | pairsIndexList = [] |
|
79 | pairsIndexList = [] | |
80 | for pair in pairsList: |
|
80 | for pair in pairsList: | |
81 | if pair not in dataOut.pairsList: |
|
81 | if pair not in dataOut.pairsList: | |
82 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
82 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
83 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
83 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
84 |
|
84 | |||
85 | if pairsIndexList == []: |
|
85 | if pairsIndexList == []: | |
86 | return |
|
86 | return | |
87 |
|
87 | |||
88 | if len(pairsIndexList) > 4: |
|
88 | if len(pairsIndexList) > 4: | |
89 | pairsIndexList = pairsIndexList[0:4] |
|
89 | pairsIndexList = pairsIndexList[0:4] | |
90 | factor = dataOut.normFactor |
|
90 | factor = dataOut.normFactor | |
91 | x = dataOut.getVelRange(1) |
|
91 | x = dataOut.getVelRange(1) | |
92 | y = dataOut.getHeiRange() |
|
92 | y = dataOut.getHeiRange() | |
93 | z = dataOut.data_spc[:,:,:]/factor |
|
93 | z = dataOut.data_spc[:,:,:]/factor | |
94 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
94 | # z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
95 | avg = numpy.abs(numpy.average(z, axis=1)) |
|
95 | avg = numpy.abs(numpy.average(z, axis=1)) | |
96 | noise = dataOut.getNoise()/factor |
|
96 | noise = dataOut.getNoise()/factor | |
97 |
|
97 | |||
98 | zdB = 10*numpy.log10(z) |
|
98 | zdB = 10*numpy.log10(z) | |
99 | avgdB = 10*numpy.log10(avg) |
|
99 | avgdB = 10*numpy.log10(avg) | |
100 | noisedB = 10*numpy.log10(noise) |
|
100 | noisedB = 10*numpy.log10(noise) | |
101 |
|
101 | |||
102 |
|
102 | |||
103 | thisDatetime = dataOut.datatime |
|
103 | thisDatetime = dataOut.datatime | |
104 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
104 | title = "Cross-Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
105 | xlabel = "Velocity (m/s)" |
|
105 | xlabel = "Velocity (m/s)" | |
106 | ylabel = "Range (Km)" |
|
106 | ylabel = "Range (Km)" | |
107 |
|
107 | |||
108 | if not self.__isConfig: |
|
108 | if not self.__isConfig: | |
109 |
|
109 | |||
110 | nplots = len(pairsIndexList) |
|
110 | nplots = len(pairsIndexList) | |
111 |
|
111 | |||
112 | self.setup(idfigure=idfigure, |
|
112 | self.setup(idfigure=idfigure, | |
113 | nplots=nplots, |
|
113 | nplots=nplots, | |
114 | wintitle=wintitle, |
|
114 | wintitle=wintitle, | |
115 | showprofile=showprofile) |
|
115 | showprofile=showprofile) | |
116 |
|
116 | |||
117 | if xmin == None: xmin = numpy.nanmin(x) |
|
117 | if xmin == None: xmin = numpy.nanmin(x) | |
118 | if xmax == None: xmax = numpy.nanmax(x) |
|
118 | if xmax == None: xmax = numpy.nanmax(x) | |
119 | if ymin == None: ymin = numpy.nanmin(y) |
|
119 | if ymin == None: ymin = numpy.nanmin(y) | |
120 | if ymax == None: ymax = numpy.nanmax(y) |
|
120 | if ymax == None: ymax = numpy.nanmax(y) | |
121 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
121 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
122 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
122 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
123 |
|
123 | |||
124 | self.__isConfig = True |
|
124 | self.__isConfig = True | |
125 |
|
125 | |||
126 | self.setWinTitle(title) |
|
126 | self.setWinTitle(title) | |
127 |
|
127 | |||
128 | for i in range(self.nplots): |
|
128 | for i in range(self.nplots): | |
129 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
129 | pair = dataOut.pairsList[pairsIndexList[i]] | |
130 |
|
130 | |||
131 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) |
|
131 | title = "Channel %d: %4.2fdB" %(pair[0], noisedB[pair[0]]) | |
132 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) |
|
132 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[0],:,:]/factor) | |
133 | axes0 = self.axesList[i*self.__nsubplots] |
|
133 | axes0 = self.axesList[i*self.__nsubplots] | |
134 | axes0.pcolor(x, y, zdB, |
|
134 | axes0.pcolor(x, y, zdB, | |
135 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
135 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
136 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
136 | xlabel=xlabel, ylabel=ylabel, title=title, | |
137 | ticksize=9, colormap=power_cmap, cblabel='') |
|
137 | ticksize=9, colormap=power_cmap, cblabel='') | |
138 |
|
138 | |||
139 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) |
|
139 | title = "Channel %d: %4.2fdB" %(pair[1], noisedB[pair[1]]) | |
140 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) |
|
140 | zdB = 10.*numpy.log10(dataOut.data_spc[pair[1],:,:]/factor) | |
141 | axes0 = self.axesList[i*self.__nsubplots+1] |
|
141 | axes0 = self.axesList[i*self.__nsubplots+1] | |
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 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
147 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
148 | coherence = numpy.abs(coherenceComplex) |
|
148 | coherence = numpy.abs(coherenceComplex) | |
149 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
149 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
150 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi |
|
150 | phase = numpy.arctan2(coherenceComplex.imag, coherenceComplex.real)*180/numpy.pi | |
151 |
|
151 | |||
152 | title = "Coherence %d%d" %(pair[0], pair[1]) |
|
152 | title = "Coherence %d%d" %(pair[0], pair[1]) | |
153 | axes0 = self.axesList[i*self.__nsubplots+2] |
|
153 | axes0 = self.axesList[i*self.__nsubplots+2] | |
154 | axes0.pcolor(x, y, coherence, |
|
154 | axes0.pcolor(x, y, coherence, | |
155 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
155 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
156 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
156 | xlabel=xlabel, ylabel=ylabel, title=title, | |
157 | ticksize=9, colormap=coherence_cmap, cblabel='') |
|
157 | ticksize=9, colormap=coherence_cmap, cblabel='') | |
158 |
|
158 | |||
159 | title = "Phase %d%d" %(pair[0], pair[1]) |
|
159 | title = "Phase %d%d" %(pair[0], pair[1]) | |
160 | axes0 = self.axesList[i*self.__nsubplots+3] |
|
160 | axes0 = self.axesList[i*self.__nsubplots+3] | |
161 | axes0.pcolor(x, y, phase, |
|
161 | axes0.pcolor(x, y, phase, | |
162 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
162 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
163 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
163 | xlabel=xlabel, ylabel=ylabel, title=title, | |
164 | ticksize=9, colormap=phase_cmap, cblabel='') |
|
164 | ticksize=9, colormap=phase_cmap, cblabel='') | |
165 |
|
165 | |||
166 |
|
166 | |||
167 |
|
167 | |||
168 | self.draw() |
|
168 | self.draw() | |
169 |
|
169 | |||
170 | if save: |
|
170 | if save: | |
171 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
171 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
172 | if figfile == None: |
|
172 | if figfile == None: | |
173 | figfile = self.getFilename(name = date) |
|
173 | figfile = self.getFilename(name = date) | |
174 |
|
174 | |||
175 | self.saveFigure(figpath, figfile) |
|
175 | self.saveFigure(figpath, figfile) | |
176 |
|
176 | |||
177 |
|
177 | |||
178 | class RTIPlot(Figure): |
|
178 | class RTIPlot(Figure): | |
179 |
|
179 | |||
180 | __isConfig = None |
|
180 | __isConfig = None | |
181 | __nsubplots = None |
|
181 | __nsubplots = None | |
182 |
|
182 | |||
183 | WIDTHPROF = None |
|
183 | WIDTHPROF = None | |
184 | HEIGHTPROF = None |
|
184 | HEIGHTPROF = None | |
185 | PREFIX = 'rti' |
|
185 | PREFIX = 'rti' | |
186 |
|
186 | |||
187 | def __init__(self): |
|
187 | def __init__(self): | |
188 |
|
188 | |||
189 | self.timerange = 2*60*60 |
|
189 | self.timerange = 2*60*60 | |
190 | self.__isConfig = False |
|
190 | self.__isConfig = False | |
191 | self.__nsubplots = 1 |
|
191 | self.__nsubplots = 1 | |
192 |
|
192 | |||
193 | self.WIDTH = 800 |
|
193 | self.WIDTH = 800 | |
194 |
self.HEIGHT = 1 |
|
194 | self.HEIGHT = 150 | |
195 | self.WIDTHPROF = 120 |
|
195 | self.WIDTHPROF = 120 | |
196 | self.HEIGHTPROF = 0 |
|
196 | self.HEIGHTPROF = 0 | |
197 |
|
197 | |||
198 | def getSubplots(self): |
|
198 | def getSubplots(self): | |
199 |
|
199 | |||
200 | ncol = 1 |
|
200 | ncol = 1 | |
201 | nrow = self.nplots |
|
201 | nrow = self.nplots | |
202 |
|
202 | |||
203 | return nrow, ncol |
|
203 | return nrow, ncol | |
204 |
|
204 | |||
205 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
205 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
206 |
|
206 | |||
207 | self.__showprofile = showprofile |
|
207 | self.__showprofile = showprofile | |
208 | self.nplots = nplots |
|
208 | self.nplots = nplots | |
209 |
|
209 | |||
210 | ncolspan = 1 |
|
210 | ncolspan = 1 | |
211 | colspan = 1 |
|
211 | colspan = 1 | |
212 | if showprofile: |
|
212 | if showprofile: | |
213 | ncolspan = 7 |
|
213 | ncolspan = 7 | |
214 | colspan = 6 |
|
214 | colspan = 6 | |
215 | self.__nsubplots = 2 |
|
215 | self.__nsubplots = 2 | |
216 |
|
216 | |||
217 | self.createFigure(idfigure = idfigure, |
|
217 | self.createFigure(idfigure = idfigure, | |
218 | wintitle = wintitle, |
|
218 | wintitle = wintitle, | |
219 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
219 | widthplot = self.WIDTH + self.WIDTHPROF, | |
220 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
220 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
221 |
|
221 | |||
222 | nrow, ncol = self.getSubplots() |
|
222 | nrow, ncol = self.getSubplots() | |
223 |
|
223 | |||
224 | counter = 0 |
|
224 | counter = 0 | |
225 | for y in range(nrow): |
|
225 | for y in range(nrow): | |
226 | for x in range(ncol): |
|
226 | for x in range(ncol): | |
227 |
|
227 | |||
228 | if counter >= self.nplots: |
|
228 | if counter >= self.nplots: | |
229 | break |
|
229 | break | |
230 |
|
230 | |||
231 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
231 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
232 |
|
232 | |||
233 | if showprofile: |
|
233 | if showprofile: | |
234 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
234 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
235 |
|
235 | |||
236 | counter += 1 |
|
236 | counter += 1 | |
237 |
|
237 | |||
238 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
238 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
239 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
239 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
240 | timerange=None, |
|
240 | timerange=None, | |
241 | save=False, figpath='./', figfile=None): |
|
241 | save=False, figpath='./', figfile=None): | |
242 |
|
242 | |||
243 | """ |
|
243 | """ | |
244 |
|
244 | |||
245 | Input: |
|
245 | Input: | |
246 | dataOut : |
|
246 | dataOut : | |
247 | idfigure : |
|
247 | idfigure : | |
248 | wintitle : |
|
248 | wintitle : | |
249 | channelList : |
|
249 | channelList : | |
250 | showProfile : |
|
250 | showProfile : | |
251 | xmin : None, |
|
251 | xmin : None, | |
252 | xmax : None, |
|
252 | xmax : None, | |
253 | ymin : None, |
|
253 | ymin : None, | |
254 | ymax : None, |
|
254 | ymax : None, | |
255 | zmin : None, |
|
255 | zmin : None, | |
256 | zmax : None |
|
256 | zmax : None | |
257 | """ |
|
257 | """ | |
258 |
|
258 | |||
259 | if channelList == None: |
|
259 | if channelList == None: | |
260 | channelIndexList = dataOut.channelIndexList |
|
260 | channelIndexList = dataOut.channelIndexList | |
261 | else: |
|
261 | else: | |
262 | channelIndexList = [] |
|
262 | channelIndexList = [] | |
263 | for channel in channelList: |
|
263 | for channel in channelList: | |
264 | if channel not in dataOut.channelList: |
|
264 | if channel not in dataOut.channelList: | |
265 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
265 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
266 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
266 | channelIndexList.append(dataOut.channelList.index(channel)) | |
267 |
|
267 | |||
268 | if timerange != None: |
|
268 | if timerange != None: | |
269 | self.timerange = timerange |
|
269 | self.timerange = timerange | |
270 |
|
270 | |||
271 | tmin = None |
|
271 | tmin = None | |
272 | tmax = None |
|
272 | tmax = None | |
273 | factor = dataOut.normFactor |
|
273 | factor = dataOut.normFactor | |
274 | x = dataOut.getTimeRange() |
|
274 | x = dataOut.getTimeRange() | |
275 | y = dataOut.getHeiRange() |
|
275 | y = dataOut.getHeiRange() | |
276 |
|
276 | |||
277 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
277 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
278 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
278 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
279 | avg = numpy.average(z, axis=1) |
|
279 | avg = numpy.average(z, axis=1) | |
280 |
|
280 | |||
281 | avgdB = 10.*numpy.log10(avg) |
|
281 | avgdB = 10.*numpy.log10(avg) | |
282 |
|
282 | |||
283 |
|
283 | |||
284 | thisDatetime = dataOut.datatime |
|
284 | thisDatetime = dataOut.datatime | |
285 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
285 | title = "RTI: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
286 |
xlabel = " |
|
286 | xlabel = "" | |
287 | ylabel = "Range (Km)" |
|
287 | ylabel = "Range (Km)" | |
288 |
|
288 | |||
289 | if not self.__isConfig: |
|
289 | if not self.__isConfig: | |
290 |
|
290 | |||
291 | nplots = len(channelIndexList) |
|
291 | nplots = len(channelIndexList) | |
292 |
|
292 | |||
293 | self.setup(idfigure=idfigure, |
|
293 | self.setup(idfigure=idfigure, | |
294 | nplots=nplots, |
|
294 | nplots=nplots, | |
295 | wintitle=wintitle, |
|
295 | wintitle=wintitle, | |
296 | showprofile=showprofile) |
|
296 | showprofile=showprofile) | |
297 |
|
297 | |||
298 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
298 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
299 | if ymin == None: ymin = numpy.nanmin(y) |
|
299 | if ymin == None: ymin = numpy.nanmin(y) | |
300 | if ymax == None: ymax = numpy.nanmax(y) |
|
300 | if ymax == None: ymax = numpy.nanmax(y) | |
301 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
301 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
302 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
302 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
303 |
|
303 | |||
304 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
304 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
305 | self.__isConfig = True |
|
305 | self.__isConfig = True | |
306 |
|
306 | |||
307 |
|
307 | |||
308 | self.setWinTitle(title) |
|
308 | self.setWinTitle(title) | |
309 |
|
309 | |||
310 | for i in range(self.nplots): |
|
310 | for i in range(self.nplots): | |
311 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
311 | title = "Channel %d: %s" %(dataOut.channelList[i], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
312 | axes = self.axesList[i*self.__nsubplots] |
|
312 | axes = self.axesList[i*self.__nsubplots] | |
313 | zdB = avgdB[i].reshape((1,-1)) |
|
313 | zdB = avgdB[i].reshape((1,-1)) | |
314 | axes.pcolor(x, y, zdB, |
|
314 | axes.pcolor(x, y, zdB, | |
315 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
315 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
316 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
316 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
317 | ticksize=9, cblabel='', cbsize="1%") |
|
317 | ticksize=9, cblabel='', cbsize="1%") | |
318 |
|
318 | |||
319 | if self.__showprofile: |
|
319 | if self.__showprofile: | |
320 | axes = self.axesList[i*self.__nsubplots +1] |
|
320 | axes = self.axesList[i*self.__nsubplots +1] | |
321 | axes.pline(avgdB[i], y, |
|
321 | axes.pline(avgdB[i], y, | |
322 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
322 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
323 | xlabel='dB', ylabel='', title='', |
|
323 | xlabel='dB', ylabel='', title='', | |
324 | ytick_visible=False, |
|
324 | ytick_visible=False, | |
325 | grid='x') |
|
325 | grid='x') | |
326 |
|
326 | |||
327 | self.draw() |
|
327 | self.draw() | |
328 |
|
328 | |||
329 | if save: |
|
329 | if save: | |
330 |
|
330 | |||
331 | if figfile == None: |
|
331 | if figfile == None: | |
332 | figfile = self.getFilename(name = self.name) |
|
332 | figfile = self.getFilename(name = self.name) | |
333 |
|
333 | |||
334 | self.saveFigure(figpath, figfile) |
|
334 | self.saveFigure(figpath, figfile) | |
335 |
|
335 | |||
336 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
336 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
337 | self.__isConfig = False |
|
337 | self.__isConfig = False | |
338 |
|
338 | |||
339 | class SpectraPlot(Figure): |
|
339 | class SpectraPlot(Figure): | |
340 |
|
340 | |||
341 | __isConfig = None |
|
341 | __isConfig = None | |
342 | __nsubplots = None |
|
342 | __nsubplots = None | |
343 |
|
343 | |||
344 | WIDTHPROF = None |
|
344 | WIDTHPROF = None | |
345 | HEIGHTPROF = None |
|
345 | HEIGHTPROF = None | |
346 | PREFIX = 'spc' |
|
346 | PREFIX = 'spc' | |
347 |
|
347 | |||
348 | def __init__(self): |
|
348 | def __init__(self): | |
349 |
|
349 | |||
350 | self.__isConfig = False |
|
350 | self.__isConfig = False | |
351 | self.__nsubplots = 1 |
|
351 | self.__nsubplots = 1 | |
352 |
|
352 | |||
353 | self.WIDTH = 230 |
|
353 | self.WIDTH = 230 | |
354 | self.HEIGHT = 250 |
|
354 | self.HEIGHT = 250 | |
355 | self.WIDTHPROF = 120 |
|
355 | self.WIDTHPROF = 120 | |
356 | self.HEIGHTPROF = 0 |
|
356 | self.HEIGHTPROF = 0 | |
357 |
|
357 | |||
358 | def getSubplots(self): |
|
358 | def getSubplots(self): | |
359 |
|
359 | |||
360 | ncol = int(numpy.sqrt(self.nplots)+0.9) |
|
360 | ncol = int(numpy.sqrt(self.nplots)+0.9) | |
361 | nrow = int(self.nplots*1./ncol + 0.9) |
|
361 | nrow = int(self.nplots*1./ncol + 0.9) | |
362 |
|
362 | |||
363 | return nrow, ncol |
|
363 | return nrow, ncol | |
364 |
|
364 | |||
365 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
365 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
366 |
|
366 | |||
367 | self.__showprofile = showprofile |
|
367 | self.__showprofile = showprofile | |
368 | self.nplots = nplots |
|
368 | self.nplots = nplots | |
369 |
|
369 | |||
370 | ncolspan = 1 |
|
370 | ncolspan = 1 | |
371 | colspan = 1 |
|
371 | colspan = 1 | |
372 | if showprofile: |
|
372 | if showprofile: | |
373 | ncolspan = 3 |
|
373 | ncolspan = 3 | |
374 | colspan = 2 |
|
374 | colspan = 2 | |
375 | self.__nsubplots = 2 |
|
375 | self.__nsubplots = 2 | |
376 |
|
376 | |||
377 | self.createFigure(idfigure = idfigure, |
|
377 | self.createFigure(idfigure = idfigure, | |
378 | wintitle = wintitle, |
|
378 | wintitle = wintitle, | |
379 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
379 | widthplot = self.WIDTH + self.WIDTHPROF, | |
380 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
380 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
381 |
|
381 | |||
382 | nrow, ncol = self.getSubplots() |
|
382 | nrow, ncol = self.getSubplots() | |
383 |
|
383 | |||
384 | counter = 0 |
|
384 | counter = 0 | |
385 | for y in range(nrow): |
|
385 | for y in range(nrow): | |
386 | for x in range(ncol): |
|
386 | for x in range(ncol): | |
387 |
|
387 | |||
388 | if counter >= self.nplots: |
|
388 | if counter >= self.nplots: | |
389 | break |
|
389 | break | |
390 |
|
390 | |||
391 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
391 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
392 |
|
392 | |||
393 | if showprofile: |
|
393 | if showprofile: | |
394 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
394 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
395 |
|
395 | |||
396 | counter += 1 |
|
396 | counter += 1 | |
397 |
|
397 | |||
398 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
398 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
399 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
399 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
400 | save=False, figpath='./', figfile=None): |
|
400 | save=False, figpath='./', figfile=None): | |
401 |
|
401 | |||
402 | """ |
|
402 | """ | |
403 |
|
403 | |||
404 | Input: |
|
404 | Input: | |
405 | dataOut : |
|
405 | dataOut : | |
406 | idfigure : |
|
406 | idfigure : | |
407 | wintitle : |
|
407 | wintitle : | |
408 | channelList : |
|
408 | channelList : | |
409 | showProfile : |
|
409 | showProfile : | |
410 | xmin : None, |
|
410 | xmin : None, | |
411 | xmax : None, |
|
411 | xmax : None, | |
412 | ymin : None, |
|
412 | ymin : None, | |
413 | ymax : None, |
|
413 | ymax : None, | |
414 | zmin : None, |
|
414 | zmin : None, | |
415 | zmax : None |
|
415 | zmax : None | |
416 | """ |
|
416 | """ | |
417 |
|
417 | |||
418 | if channelList == None: |
|
418 | if channelList == None: | |
419 | channelIndexList = dataOut.channelIndexList |
|
419 | channelIndexList = dataOut.channelIndexList | |
420 | else: |
|
420 | else: | |
421 | channelIndexList = [] |
|
421 | channelIndexList = [] | |
422 | for channel in channelList: |
|
422 | for channel in channelList: | |
423 | if channel not in dataOut.channelList: |
|
423 | if channel not in dataOut.channelList: | |
424 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
424 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
425 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
425 | channelIndexList.append(dataOut.channelList.index(channel)) | |
426 | factor = dataOut.normFactor |
|
426 | factor = dataOut.normFactor | |
427 | x = dataOut.getVelRange(1) |
|
427 | x = dataOut.getVelRange(1) | |
428 | y = dataOut.getHeiRange() |
|
428 | y = dataOut.getHeiRange() | |
429 |
|
429 | |||
430 | z = dataOut.data_spc[channelIndexList,:,:]/factor |
|
430 | z = dataOut.data_spc[channelIndexList,:,:]/factor | |
431 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) |
|
431 | z = numpy.where(numpy.isfinite(z), z, numpy.NAN) | |
432 | avg = numpy.average(z, axis=1) |
|
432 | avg = numpy.average(z, axis=1) | |
433 | noise = dataOut.getNoise()/factor |
|
433 | noise = dataOut.getNoise()/factor | |
434 |
|
434 | |||
435 | zdB = 10*numpy.log10(z) |
|
435 | zdB = 10*numpy.log10(z) | |
436 | avgdB = 10*numpy.log10(avg) |
|
436 | avgdB = 10*numpy.log10(avg) | |
437 | noisedB = 10*numpy.log10(noise) |
|
437 | noisedB = 10*numpy.log10(noise) | |
438 |
|
438 | |||
439 | thisDatetime = dataOut.datatime |
|
439 | thisDatetime = dataOut.datatime | |
440 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
440 | title = "Spectra: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
441 | xlabel = "Velocity (m/s)" |
|
441 | xlabel = "Velocity (m/s)" | |
442 | ylabel = "Range (Km)" |
|
442 | ylabel = "Range (Km)" | |
443 |
|
443 | |||
444 | if not self.__isConfig: |
|
444 | if not self.__isConfig: | |
445 |
|
445 | |||
446 | nplots = len(channelIndexList) |
|
446 | nplots = len(channelIndexList) | |
447 |
|
447 | |||
448 | self.setup(idfigure=idfigure, |
|
448 | self.setup(idfigure=idfigure, | |
449 | nplots=nplots, |
|
449 | nplots=nplots, | |
450 | wintitle=wintitle, |
|
450 | wintitle=wintitle, | |
451 | showprofile=showprofile) |
|
451 | showprofile=showprofile) | |
452 |
|
452 | |||
453 | if xmin == None: xmin = numpy.nanmin(x) |
|
453 | if xmin == None: xmin = numpy.nanmin(x) | |
454 | if xmax == None: xmax = numpy.nanmax(x) |
|
454 | if xmax == None: xmax = numpy.nanmax(x) | |
455 | if ymin == None: ymin = numpy.nanmin(y) |
|
455 | if ymin == None: ymin = numpy.nanmin(y) | |
456 | if ymax == None: ymax = numpy.nanmax(y) |
|
456 | if ymax == None: ymax = numpy.nanmax(y) | |
457 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 |
|
457 | if zmin == None: zmin = numpy.nanmin(avgdB)*0.9 | |
458 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 |
|
458 | if zmax == None: zmax = numpy.nanmax(avgdB)*0.9 | |
459 |
|
459 | |||
460 | self.__isConfig = True |
|
460 | self.__isConfig = True | |
461 |
|
461 | |||
462 | self.setWinTitle(title) |
|
462 | self.setWinTitle(title) | |
463 |
|
463 | |||
464 | for i in range(self.nplots): |
|
464 | for i in range(self.nplots): | |
465 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i]) |
|
465 | title = "Channel %d: %4.2fdB" %(dataOut.channelList[i], noisedB[i]) | |
466 | axes = self.axesList[i*self.__nsubplots] |
|
466 | axes = self.axesList[i*self.__nsubplots] | |
467 | axes.pcolor(x, y, zdB[i,:,:], |
|
467 | axes.pcolor(x, y, zdB[i,:,:], | |
468 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, |
|
468 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, zmin=zmin, zmax=zmax, | |
469 | xlabel=xlabel, ylabel=ylabel, title=title, |
|
469 | xlabel=xlabel, ylabel=ylabel, title=title, | |
470 | ticksize=9, cblabel='') |
|
470 | ticksize=9, cblabel='') | |
471 |
|
471 | |||
472 | if self.__showprofile: |
|
472 | if self.__showprofile: | |
473 | axes = self.axesList[i*self.__nsubplots +1] |
|
473 | axes = self.axesList[i*self.__nsubplots +1] | |
474 | axes.pline(avgdB[i], y, |
|
474 | axes.pline(avgdB[i], y, | |
475 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, |
|
475 | xmin=zmin, xmax=zmax, ymin=ymin, ymax=ymax, | |
476 | xlabel='dB', ylabel='', title='', |
|
476 | xlabel='dB', ylabel='', title='', | |
477 | ytick_visible=False, |
|
477 | ytick_visible=False, | |
478 | grid='x') |
|
478 | grid='x') | |
479 |
|
479 | |||
480 | noiseline = numpy.repeat(noisedB[i], len(y)) |
|
480 | noiseline = numpy.repeat(noisedB[i], len(y)) | |
481 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) |
|
481 | axes.addpline(noiseline, y, idline=1, color="black", linestyle="dashed", lw=2) | |
482 |
|
482 | |||
483 | self.draw() |
|
483 | self.draw() | |
484 |
|
484 | |||
485 | if save: |
|
485 | if save: | |
486 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
486 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
487 | if figfile == None: |
|
487 | if figfile == None: | |
488 | figfile = self.getFilename(name = date) |
|
488 | figfile = self.getFilename(name = date) | |
489 |
|
489 | |||
490 | self.saveFigure(figpath, figfile) |
|
490 | self.saveFigure(figpath, figfile) | |
491 |
|
491 | |||
492 | class Scope(Figure): |
|
492 | class Scope(Figure): | |
493 |
|
493 | |||
494 | __isConfig = None |
|
494 | __isConfig = None | |
495 |
|
495 | |||
496 | def __init__(self): |
|
496 | def __init__(self): | |
497 |
|
497 | |||
498 | self.__isConfig = False |
|
498 | self.__isConfig = False | |
499 | self.WIDTH = 600 |
|
499 | self.WIDTH = 600 | |
500 | self.HEIGHT = 200 |
|
500 | self.HEIGHT = 200 | |
501 |
|
501 | |||
502 | def getSubplots(self): |
|
502 | def getSubplots(self): | |
503 |
|
503 | |||
504 | nrow = self.nplots |
|
504 | nrow = self.nplots | |
505 | ncol = 3 |
|
505 | ncol = 3 | |
506 | return nrow, ncol |
|
506 | return nrow, ncol | |
507 |
|
507 | |||
508 | def setup(self, idfigure, nplots, wintitle): |
|
508 | def setup(self, idfigure, nplots, wintitle): | |
509 |
|
509 | |||
510 | self.nplots = nplots |
|
510 | self.nplots = nplots | |
511 |
|
511 | |||
512 | self.createFigure(idfigure, wintitle) |
|
512 | self.createFigure(idfigure, wintitle) | |
513 |
|
513 | |||
514 | nrow,ncol = self.getSubplots() |
|
514 | nrow,ncol = self.getSubplots() | |
515 | colspan = 3 |
|
515 | colspan = 3 | |
516 | rowspan = 1 |
|
516 | rowspan = 1 | |
517 |
|
517 | |||
518 | for i in range(nplots): |
|
518 | for i in range(nplots): | |
519 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) |
|
519 | self.addAxes(nrow, ncol, i, 0, colspan, rowspan) | |
520 |
|
520 | |||
521 |
|
521 | |||
522 |
|
522 | |||
523 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
523 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
524 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, |
|
524 | xmin=None, xmax=None, ymin=None, ymax=None, save=False, | |
525 | figpath='./', figfile=None): |
|
525 | figpath='./', figfile=None): | |
526 |
|
526 | |||
527 | """ |
|
527 | """ | |
528 |
|
528 | |||
529 | Input: |
|
529 | Input: | |
530 | dataOut : |
|
530 | dataOut : | |
531 | idfigure : |
|
531 | idfigure : | |
532 | wintitle : |
|
532 | wintitle : | |
533 | channelList : |
|
533 | channelList : | |
534 | xmin : None, |
|
534 | xmin : None, | |
535 | xmax : None, |
|
535 | xmax : None, | |
536 | ymin : None, |
|
536 | ymin : None, | |
537 | ymax : None, |
|
537 | ymax : None, | |
538 | """ |
|
538 | """ | |
539 |
|
539 | |||
540 | if channelList == None: |
|
540 | if channelList == None: | |
541 | channelIndexList = dataOut.channelIndexList |
|
541 | channelIndexList = dataOut.channelIndexList | |
542 | else: |
|
542 | else: | |
543 | channelIndexList = [] |
|
543 | channelIndexList = [] | |
544 | for channel in channelList: |
|
544 | for channel in channelList: | |
545 | if channel not in dataOut.channelList: |
|
545 | if channel not in dataOut.channelList: | |
546 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
546 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
547 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
547 | channelIndexList.append(dataOut.channelList.index(channel)) | |
548 |
|
548 | |||
549 | x = dataOut.heightList |
|
549 | x = dataOut.heightList | |
550 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) |
|
550 | y = dataOut.data[channelIndexList,:] * numpy.conjugate(dataOut.data[channelIndexList,:]) | |
551 | y = y.real |
|
551 | y = y.real | |
552 |
|
552 | |||
553 | thisDatetime = dataOut.datatime |
|
553 | thisDatetime = dataOut.datatime | |
554 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
554 | title = "Scope: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
555 | xlabel = "Range (Km)" |
|
555 | xlabel = "Range (Km)" | |
556 | ylabel = "Intensity" |
|
556 | ylabel = "Intensity" | |
557 |
|
557 | |||
558 | if not self.__isConfig: |
|
558 | if not self.__isConfig: | |
559 | nplots = len(channelIndexList) |
|
559 | nplots = len(channelIndexList) | |
560 |
|
560 | |||
561 | self.setup(idfigure=idfigure, |
|
561 | self.setup(idfigure=idfigure, | |
562 | nplots=nplots, |
|
562 | nplots=nplots, | |
563 | wintitle=wintitle) |
|
563 | wintitle=wintitle) | |
564 |
|
564 | |||
565 | if xmin == None: xmin = numpy.nanmin(x) |
|
565 | if xmin == None: xmin = numpy.nanmin(x) | |
566 | if xmax == None: xmax = numpy.nanmax(x) |
|
566 | if xmax == None: xmax = numpy.nanmax(x) | |
567 | if ymin == None: ymin = numpy.nanmin(y) |
|
567 | if ymin == None: ymin = numpy.nanmin(y) | |
568 | if ymax == None: ymax = numpy.nanmax(y) |
|
568 | if ymax == None: ymax = numpy.nanmax(y) | |
569 |
|
569 | |||
570 | self.__isConfig = True |
|
570 | self.__isConfig = True | |
571 |
|
571 | |||
572 | self.setWinTitle(title) |
|
572 | self.setWinTitle(title) | |
573 |
|
573 | |||
574 | for i in range(len(self.axesList)): |
|
574 | for i in range(len(self.axesList)): | |
575 | title = "Channel %d" %(i) |
|
575 | title = "Channel %d" %(i) | |
576 | axes = self.axesList[i] |
|
576 | axes = self.axesList[i] | |
577 | ychannel = y[i,:] |
|
577 | ychannel = y[i,:] | |
578 | axes.pline(x, ychannel, |
|
578 | axes.pline(x, ychannel, | |
579 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
579 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
580 | xlabel=xlabel, ylabel=ylabel, title=title) |
|
580 | xlabel=xlabel, ylabel=ylabel, title=title) | |
581 |
|
581 | |||
582 | self.draw() |
|
582 | self.draw() | |
583 |
|
583 | |||
584 | if save: |
|
584 | if save: | |
585 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
585 | date = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
586 | if figfile == None: |
|
586 | if figfile == None: | |
587 | figfile = self.getFilename(name = date) |
|
587 | figfile = self.getFilename(name = date) | |
588 |
|
588 | |||
589 | self.saveFigure(figpath, figfile) |
|
589 | self.saveFigure(figpath, figfile) | |
590 |
|
590 | |||
591 | class ProfilePlot(Figure): |
|
591 | class ProfilePlot(Figure): | |
592 | __isConfig = None |
|
592 | __isConfig = None | |
593 | __nsubplots = None |
|
593 | __nsubplots = None | |
594 |
|
594 | |||
595 | WIDTHPROF = None |
|
595 | WIDTHPROF = None | |
596 | HEIGHTPROF = None |
|
596 | HEIGHTPROF = None | |
597 | PREFIX = 'spcprofile' |
|
597 | PREFIX = 'spcprofile' | |
598 |
|
598 | |||
599 | def __init__(self): |
|
599 | def __init__(self): | |
600 | self.__isConfig = False |
|
600 | self.__isConfig = False | |
601 | self.__nsubplots = 1 |
|
601 | self.__nsubplots = 1 | |
602 |
|
602 | |||
603 | self.WIDTH = 300 |
|
603 | self.WIDTH = 300 | |
604 | self.HEIGHT = 500 |
|
604 | self.HEIGHT = 500 | |
605 |
|
605 | |||
606 | def getSubplots(self): |
|
606 | def getSubplots(self): | |
607 | ncol = 1 |
|
607 | ncol = 1 | |
608 | nrow = 1 |
|
608 | nrow = 1 | |
609 |
|
609 | |||
610 | return nrow, ncol |
|
610 | return nrow, ncol | |
611 |
|
611 | |||
612 | def setup(self, idfigure, nplots, wintitle): |
|
612 | def setup(self, idfigure, nplots, wintitle): | |
613 |
|
613 | |||
614 | self.nplots = nplots |
|
614 | self.nplots = nplots | |
615 |
|
615 | |||
616 | ncolspan = 1 |
|
616 | ncolspan = 1 | |
617 | colspan = 1 |
|
617 | colspan = 1 | |
618 |
|
618 | |||
619 | self.createFigure(idfigure = idfigure, |
|
619 | self.createFigure(idfigure = idfigure, | |
620 | wintitle = wintitle, |
|
620 | wintitle = wintitle, | |
621 | widthplot = self.WIDTH, |
|
621 | widthplot = self.WIDTH, | |
622 | heightplot = self.HEIGHT) |
|
622 | heightplot = self.HEIGHT) | |
623 |
|
623 | |||
624 | nrow, ncol = self.getSubplots() |
|
624 | nrow, ncol = self.getSubplots() | |
625 |
|
625 | |||
626 | counter = 0 |
|
626 | counter = 0 | |
627 | for y in range(nrow): |
|
627 | for y in range(nrow): | |
628 | for x in range(ncol): |
|
628 | for x in range(ncol): | |
629 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
629 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
630 |
|
630 | |||
631 | def run(self, dataOut, idfigure, wintitle="", channelList=None, |
|
631 | def run(self, dataOut, idfigure, wintitle="", channelList=None, | |
632 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
632 | xmin=None, xmax=None, ymin=None, ymax=None, | |
633 | save=False, figpath='./', figfile=None): |
|
633 | save=False, figpath='./', figfile=None): | |
634 |
|
634 | |||
635 | if channelList == None: |
|
635 | if channelList == None: | |
636 | channelIndexList = dataOut.channelIndexList |
|
636 | channelIndexList = dataOut.channelIndexList | |
637 | channelList = dataOut.channelList |
|
637 | channelList = dataOut.channelList | |
638 | else: |
|
638 | else: | |
639 | channelIndexList = [] |
|
639 | channelIndexList = [] | |
640 | for channel in channelList: |
|
640 | for channel in channelList: | |
641 | if channel not in dataOut.channelList: |
|
641 | if channel not in dataOut.channelList: | |
642 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
642 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
643 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
643 | channelIndexList.append(dataOut.channelList.index(channel)) | |
644 |
|
644 | |||
645 | factor = dataOut.normFactor |
|
645 | factor = dataOut.normFactor | |
646 | y = dataOut.getHeiRange() |
|
646 | y = dataOut.getHeiRange() | |
647 | x = dataOut.data_spc[channelIndexList,:,:]/factor |
|
647 | x = dataOut.data_spc[channelIndexList,:,:]/factor | |
648 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) |
|
648 | x = numpy.where(numpy.isfinite(x), x, numpy.NAN) | |
649 | avg = numpy.average(x, axis=1) |
|
649 | avg = numpy.average(x, axis=1) | |
650 |
|
650 | |||
651 | avgdB = 10*numpy.log10(avg) |
|
651 | avgdB = 10*numpy.log10(avg) | |
652 |
|
652 | |||
653 | thisDatetime = dataOut.datatime |
|
653 | thisDatetime = dataOut.datatime | |
654 | title = "Power Profile" |
|
654 | title = "Power Profile" | |
655 | xlabel = "dB" |
|
655 | xlabel = "dB" | |
656 | ylabel = "Range (Km)" |
|
656 | ylabel = "Range (Km)" | |
657 |
|
657 | |||
658 | if not self.__isConfig: |
|
658 | if not self.__isConfig: | |
659 |
|
659 | |||
660 | nplots = 1 |
|
660 | nplots = 1 | |
661 |
|
661 | |||
662 | self.setup(idfigure=idfigure, |
|
662 | self.setup(idfigure=idfigure, | |
663 | nplots=nplots, |
|
663 | nplots=nplots, | |
664 | wintitle=wintitle) |
|
664 | wintitle=wintitle) | |
665 |
|
665 | |||
666 | if ymin == None: ymin = numpy.nanmin(y) |
|
666 | if ymin == None: ymin = numpy.nanmin(y) | |
667 | if ymax == None: ymax = numpy.nanmax(y) |
|
667 | if ymax == None: ymax = numpy.nanmax(y) | |
668 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 |
|
668 | if xmin == None: xmin = numpy.nanmin(avgdB)*0.9 | |
669 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 |
|
669 | if xmax == None: xmax = numpy.nanmax(avgdB)*0.9 | |
670 |
|
670 | |||
671 | self.__isConfig = True |
|
671 | self.__isConfig = True | |
672 |
|
672 | |||
673 | self.setWinTitle(title) |
|
673 | self.setWinTitle(title) | |
674 |
|
674 | |||
675 |
|
675 | |||
676 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
676 | title = "Power Profile: %s" %(thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
677 | axes = self.axesList[0] |
|
677 | axes = self.axesList[0] | |
678 |
|
678 | |||
679 | legendlabels = ["channel %d"%x for x in channelList] |
|
679 | legendlabels = ["channel %d"%x for x in channelList] | |
680 | axes.pmultiline(avgdB, y, |
|
680 | axes.pmultiline(avgdB, y, | |
681 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, |
|
681 | xmin=xmin, xmax=xmax, ymin=ymin, ymax=ymax, | |
682 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, |
|
682 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, | |
683 | ytick_visible=True, nxticks=5, |
|
683 | ytick_visible=True, nxticks=5, | |
684 | grid='x') |
|
684 | grid='x') | |
685 |
|
685 | |||
686 | self.draw() |
|
686 | self.draw() | |
687 |
|
687 | |||
688 | if save: |
|
688 | if save: | |
689 | date = thisDatetime.strftime("%Y%m%d") |
|
689 | date = thisDatetime.strftime("%Y%m%d") | |
690 | if figfile == None: |
|
690 | if figfile == None: | |
691 | figfile = self.getFilename(name = date) |
|
691 | figfile = self.getFilename(name = date) | |
692 |
|
692 | |||
693 | self.saveFigure(figpath, figfile) |
|
693 | self.saveFigure(figpath, figfile) | |
694 |
|
694 | |||
695 | class CoherenceMap(Figure): |
|
695 | class CoherenceMap(Figure): | |
696 | __isConfig = None |
|
696 | __isConfig = None | |
697 | __nsubplots = None |
|
697 | __nsubplots = None | |
698 |
|
698 | |||
699 | WIDTHPROF = None |
|
699 | WIDTHPROF = None | |
700 | HEIGHTPROF = None |
|
700 | HEIGHTPROF = None | |
701 | PREFIX = 'cmap' |
|
701 | PREFIX = 'cmap' | |
702 |
|
702 | |||
703 | def __init__(self): |
|
703 | def __init__(self): | |
704 | self.timerange = 2*60*60 |
|
704 | self.timerange = 2*60*60 | |
705 | self.__isConfig = False |
|
705 | self.__isConfig = False | |
706 | self.__nsubplots = 1 |
|
706 | self.__nsubplots = 1 | |
707 |
|
707 | |||
708 | self.WIDTH = 800 |
|
708 | self.WIDTH = 800 | |
709 |
self.HEIGHT = 1 |
|
709 | self.HEIGHT = 150 | |
710 | self.WIDTHPROF = 120 |
|
710 | self.WIDTHPROF = 120 | |
711 | self.HEIGHTPROF = 0 |
|
711 | self.HEIGHTPROF = 0 | |
712 |
|
712 | |||
713 | def getSubplots(self): |
|
713 | def getSubplots(self): | |
714 | ncol = 1 |
|
714 | ncol = 1 | |
715 | nrow = self.nplots*2 |
|
715 | nrow = self.nplots*2 | |
716 |
|
716 | |||
717 | return nrow, ncol |
|
717 | return nrow, ncol | |
718 |
|
718 | |||
719 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
719 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
720 | self.__showprofile = showprofile |
|
720 | self.__showprofile = showprofile | |
721 | self.nplots = nplots |
|
721 | self.nplots = nplots | |
722 |
|
722 | |||
723 | ncolspan = 1 |
|
723 | ncolspan = 1 | |
724 | colspan = 1 |
|
724 | colspan = 1 | |
725 | if showprofile: |
|
725 | if showprofile: | |
726 | ncolspan = 7 |
|
726 | ncolspan = 7 | |
727 | colspan = 6 |
|
727 | colspan = 6 | |
728 | self.__nsubplots = 2 |
|
728 | self.__nsubplots = 2 | |
729 |
|
729 | |||
730 | self.createFigure(idfigure = idfigure, |
|
730 | self.createFigure(idfigure = idfigure, | |
731 | wintitle = wintitle, |
|
731 | wintitle = wintitle, | |
732 | widthplot = self.WIDTH + self.WIDTHPROF, |
|
732 | widthplot = self.WIDTH + self.WIDTHPROF, | |
733 | heightplot = self.HEIGHT + self.HEIGHTPROF) |
|
733 | heightplot = self.HEIGHT + self.HEIGHTPROF) | |
734 |
|
734 | |||
735 | nrow, ncol = self.getSubplots() |
|
735 | nrow, ncol = self.getSubplots() | |
736 |
|
736 | |||
737 | for y in range(nrow): |
|
737 | for y in range(nrow): | |
738 | for x in range(ncol): |
|
738 | for x in range(ncol): | |
739 |
|
739 | |||
740 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) |
|
740 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan, colspan, 1) | |
741 |
|
741 | |||
742 | if showprofile: |
|
742 | if showprofile: | |
743 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) |
|
743 | self.addAxes(nrow, ncol*ncolspan, y, x*ncolspan+colspan, 1, 1) | |
744 |
|
744 | |||
745 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', |
|
745 | def run(self, dataOut, idfigure, wintitle="", pairsList=None, showprofile='True', | |
746 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, |
|
746 | xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None, | |
747 | timerange=None, |
|
747 | timerange=None, | |
748 | save=False, figpath='./', figfile=None, |
|
748 | save=False, figpath='./', figfile=None, | |
749 | coherence_cmap='jet', phase_cmap='RdBu_r'): |
|
749 | coherence_cmap='jet', phase_cmap='RdBu_r'): | |
750 |
|
750 | |||
751 | if pairsList == None: |
|
751 | if pairsList == None: | |
752 | pairsIndexList = dataOut.pairsIndexList |
|
752 | pairsIndexList = dataOut.pairsIndexList | |
753 | else: |
|
753 | else: | |
754 | pairsIndexList = [] |
|
754 | pairsIndexList = [] | |
755 | for pair in pairsList: |
|
755 | for pair in pairsList: | |
756 | if pair not in dataOut.pairsList: |
|
756 | if pair not in dataOut.pairsList: | |
757 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) |
|
757 | raise ValueError, "Pair %s is not in dataOut.pairsList" %(pair) | |
758 | pairsIndexList.append(dataOut.pairsList.index(pair)) |
|
758 | pairsIndexList.append(dataOut.pairsList.index(pair)) | |
759 |
|
759 | |||
760 | if timerange != None: |
|
760 | if timerange != None: | |
761 | self.timerange = timerange |
|
761 | self.timerange = timerange | |
762 |
|
762 | |||
763 | if pairsIndexList == []: |
|
763 | if pairsIndexList == []: | |
764 | return |
|
764 | return | |
765 |
|
765 | |||
766 | if len(pairsIndexList) > 4: |
|
766 | if len(pairsIndexList) > 4: | |
767 | pairsIndexList = pairsIndexList[0:4] |
|
767 | pairsIndexList = pairsIndexList[0:4] | |
768 |
|
768 | |||
769 | tmin = None |
|
769 | tmin = None | |
770 | tmax = None |
|
770 | tmax = None | |
771 | x = dataOut.getTimeRange() |
|
771 | x = dataOut.getTimeRange() | |
772 | y = dataOut.getHeiRange() |
|
772 | y = dataOut.getHeiRange() | |
773 |
|
773 | |||
774 | thisDatetime = dataOut.datatime |
|
774 | thisDatetime = dataOut.datatime | |
775 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
775 | title = "CoherenceMap: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
776 | xlabel = "" |
|
776 | xlabel = "" | |
777 | ylabel = "Range (Km)" |
|
777 | ylabel = "Range (Km)" | |
778 |
|
778 | |||
779 | if not self.__isConfig: |
|
779 | if not self.__isConfig: | |
780 | nplots = len(pairsIndexList) |
|
780 | nplots = len(pairsIndexList) | |
781 | self.setup(idfigure=idfigure, |
|
781 | self.setup(idfigure=idfigure, | |
782 | nplots=nplots, |
|
782 | nplots=nplots, | |
783 | wintitle=wintitle, |
|
783 | wintitle=wintitle, | |
784 | showprofile=showprofile) |
|
784 | showprofile=showprofile) | |
785 |
|
785 | |||
786 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
786 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
787 | if ymin == None: ymin = numpy.nanmin(y) |
|
787 | if ymin == None: ymin = numpy.nanmin(y) | |
788 | if ymax == None: ymax = numpy.nanmax(y) |
|
788 | if ymax == None: ymax = numpy.nanmax(y) | |
789 |
|
789 | |||
790 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
790 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
791 |
|
791 | |||
792 | self.__isConfig = True |
|
792 | self.__isConfig = True | |
793 |
|
793 | |||
794 | self.setWinTitle(title) |
|
794 | self.setWinTitle(title) | |
795 |
|
795 | |||
796 | for i in range(self.nplots): |
|
796 | for i in range(self.nplots): | |
797 |
|
797 | |||
798 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
798 | pair = dataOut.pairsList[pairsIndexList[i]] | |
799 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) |
|
799 | coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
800 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) |
|
800 | avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) | |
801 | coherence = numpy.abs(avgcoherenceComplex) |
|
801 | coherence = numpy.abs(avgcoherenceComplex) | |
802 | # coherence = numpy.abs(coherenceComplex) |
|
802 | # coherence = numpy.abs(coherenceComplex) | |
803 | # avg = numpy.average(coherence, axis=0) |
|
803 | # avg = numpy.average(coherence, axis=0) | |
804 |
|
804 | |||
805 | z = coherence.reshape((1,-1)) |
|
805 | z = coherence.reshape((1,-1)) | |
806 |
|
806 | |||
807 | counter = 0 |
|
807 | counter = 0 | |
808 |
|
808 | |||
809 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
809 | title = "Coherence %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
810 | axes = self.axesList[i*self.__nsubplots*2] |
|
810 | axes = self.axesList[i*self.__nsubplots*2] | |
811 | axes.pcolor(x, y, z, |
|
811 | axes.pcolor(x, y, z, | |
812 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, |
|
812 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=0, zmax=1, | |
813 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
813 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
814 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") |
|
814 | ticksize=9, cblabel='', colormap=coherence_cmap, cbsize="1%") | |
815 |
|
815 | |||
816 | if self.__showprofile: |
|
816 | if self.__showprofile: | |
817 | counter += 1 |
|
817 | counter += 1 | |
818 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
818 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
819 | axes.pline(coherence, y, |
|
819 | axes.pline(coherence, y, | |
820 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, |
|
820 | xmin=0, xmax=1, ymin=ymin, ymax=ymax, | |
821 | xlabel='', ylabel='', title='', ticksize=7, |
|
821 | xlabel='', ylabel='', title='', ticksize=7, | |
822 | ytick_visible=False, nxticks=5, |
|
822 | ytick_visible=False, nxticks=5, | |
823 | grid='x') |
|
823 | grid='x') | |
824 |
|
824 | |||
825 | counter += 1 |
|
825 | counter += 1 | |
826 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi |
|
826 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
827 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
827 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi | |
828 | # avg = numpy.average(phase, axis=0) |
|
828 | # avg = numpy.average(phase, axis=0) | |
829 | z = phase.reshape((1,-1)) |
|
829 | z = phase.reshape((1,-1)) | |
830 |
|
830 | |||
831 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
|
831 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) | |
832 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
832 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
833 | axes.pcolor(x, y, z, |
|
833 | axes.pcolor(x, y, z, | |
834 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, |
|
834 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, zmin=-180, zmax=180, | |
835 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, |
|
835 | xlabel=xlabel, ylabel=ylabel, title=title, rti=True, XAxisAsTime=True, | |
836 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") |
|
836 | ticksize=9, cblabel='', colormap=phase_cmap, cbsize="1%") | |
837 |
|
837 | |||
838 | if self.__showprofile: |
|
838 | if self.__showprofile: | |
839 | counter += 1 |
|
839 | counter += 1 | |
840 | axes = self.axesList[i*self.__nsubplots*2 + counter] |
|
840 | axes = self.axesList[i*self.__nsubplots*2 + counter] | |
841 | axes.pline(phase, y, |
|
841 | axes.pline(phase, y, | |
842 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, |
|
842 | xmin=-180, xmax=180, ymin=ymin, ymax=ymax, | |
843 | xlabel='', ylabel='', title='', ticksize=7, |
|
843 | xlabel='', ylabel='', title='', ticksize=7, | |
844 | ytick_visible=False, nxticks=4, |
|
844 | ytick_visible=False, nxticks=4, | |
845 | grid='x') |
|
845 | grid='x') | |
846 |
|
846 | |||
847 | self.draw() |
|
847 | self.draw() | |
848 |
|
848 | |||
849 | if save: |
|
849 | if save: | |
850 |
|
850 | |||
851 | if figfile == None: |
|
851 | if figfile == None: | |
852 | figfile = self.getFilename(name = self.name) |
|
852 | figfile = self.getFilename(name = self.name) | |
853 |
|
853 | |||
854 | self.saveFigure(figpath, figfile) |
|
854 | self.saveFigure(figpath, figfile) | |
855 |
|
855 | |||
856 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
856 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
857 | self.__isConfig = False |
|
857 | self.__isConfig = False | |
858 |
|
858 | |||
859 | class RTIfromNoise(Figure): |
|
859 | class RTIfromNoise(Figure): | |
860 |
|
860 | |||
861 | __isConfig = None |
|
861 | __isConfig = None | |
862 | __nsubplots = None |
|
862 | __nsubplots = None | |
863 |
|
863 | |||
864 | PREFIX = 'rtinoise' |
|
864 | PREFIX = 'rtinoise' | |
865 |
|
865 | |||
866 | def __init__(self): |
|
866 | def __init__(self): | |
867 |
|
867 | |||
868 | self.timerange = 24*60*60 |
|
868 | self.timerange = 24*60*60 | |
869 | self.__isConfig = False |
|
869 | self.__isConfig = False | |
870 | self.__nsubplots = 1 |
|
870 | self.__nsubplots = 1 | |
871 |
|
871 | |||
872 | self.WIDTH = 820 |
|
872 | self.WIDTH = 820 | |
873 | self.HEIGHT = 200 |
|
873 | self.HEIGHT = 200 | |
874 | self.WIDTHPROF = 120 |
|
874 | self.WIDTHPROF = 120 | |
875 | self.HEIGHTPROF = 0 |
|
875 | self.HEIGHTPROF = 0 | |
876 | self.xdata = None |
|
876 | self.xdata = None | |
877 | self.ydata = None |
|
877 | self.ydata = None | |
878 |
|
878 | |||
879 | def getSubplots(self): |
|
879 | def getSubplots(self): | |
880 |
|
880 | |||
881 | ncol = 1 |
|
881 | ncol = 1 | |
882 | nrow = 1 |
|
882 | nrow = 1 | |
883 |
|
883 | |||
884 | return nrow, ncol |
|
884 | return nrow, ncol | |
885 |
|
885 | |||
886 | def setup(self, idfigure, nplots, wintitle, showprofile=True): |
|
886 | def setup(self, idfigure, nplots, wintitle, showprofile=True): | |
887 |
|
887 | |||
888 | self.__showprofile = showprofile |
|
888 | self.__showprofile = showprofile | |
889 | self.nplots = nplots |
|
889 | self.nplots = nplots | |
890 |
|
890 | |||
891 | ncolspan = 7 |
|
891 | ncolspan = 7 | |
892 | colspan = 6 |
|
892 | colspan = 6 | |
893 | self.__nsubplots = 2 |
|
893 | self.__nsubplots = 2 | |
894 |
|
894 | |||
895 | self.createFigure(idfigure = idfigure, |
|
895 | self.createFigure(idfigure = idfigure, | |
896 | wintitle = wintitle, |
|
896 | wintitle = wintitle, | |
897 | widthplot = self.WIDTH+self.WIDTHPROF, |
|
897 | widthplot = self.WIDTH+self.WIDTHPROF, | |
898 | heightplot = self.HEIGHT+self.HEIGHTPROF) |
|
898 | heightplot = self.HEIGHT+self.HEIGHTPROF) | |
899 |
|
899 | |||
900 | nrow, ncol = self.getSubplots() |
|
900 | nrow, ncol = self.getSubplots() | |
901 |
|
901 | |||
902 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) |
|
902 | self.addAxes(nrow, ncol*ncolspan, 0, 0, colspan, 1) | |
903 |
|
903 | |||
904 |
|
904 | |||
905 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', |
|
905 | def run(self, dataOut, idfigure, wintitle="", channelList=None, showprofile='True', | |
906 | xmin=None, xmax=None, ymin=None, ymax=None, |
|
906 | xmin=None, xmax=None, ymin=None, ymax=None, | |
907 | timerange=None, |
|
907 | timerange=None, | |
908 | save=False, figpath='./', figfile=None): |
|
908 | save=False, figpath='./', figfile=None): | |
909 |
|
909 | |||
910 | if channelList == None: |
|
910 | if channelList == None: | |
911 | channelIndexList = dataOut.channelIndexList |
|
911 | channelIndexList = dataOut.channelIndexList | |
912 | channelList = dataOut.channelList |
|
912 | channelList = dataOut.channelList | |
913 | else: |
|
913 | else: | |
914 | channelIndexList = [] |
|
914 | channelIndexList = [] | |
915 | for channel in channelList: |
|
915 | for channel in channelList: | |
916 | if channel not in dataOut.channelList: |
|
916 | if channel not in dataOut.channelList: | |
917 | raise ValueError, "Channel %d is not in dataOut.channelList" |
|
917 | raise ValueError, "Channel %d is not in dataOut.channelList" | |
918 | channelIndexList.append(dataOut.channelList.index(channel)) |
|
918 | channelIndexList.append(dataOut.channelList.index(channel)) | |
919 |
|
919 | |||
920 | if timerange != None: |
|
920 | if timerange != None: | |
921 | self.timerange = timerange |
|
921 | self.timerange = timerange | |
922 |
|
922 | |||
923 | tmin = None |
|
923 | tmin = None | |
924 | tmax = None |
|
924 | tmax = None | |
925 | x = dataOut.getTimeRange() |
|
925 | x = dataOut.getTimeRange() | |
926 | y = dataOut.getHeiRange() |
|
926 | y = dataOut.getHeiRange() | |
927 | factor = dataOut.normFactor |
|
927 | factor = dataOut.normFactor | |
928 | noise = dataOut.getNoise()/factor |
|
928 | noise = dataOut.getNoise()/factor | |
929 | noisedB = 10*numpy.log10(noise) |
|
929 | noisedB = 10*numpy.log10(noise) | |
930 |
|
930 | |||
931 | thisDatetime = dataOut.datatime |
|
931 | thisDatetime = dataOut.datatime | |
932 | title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
932 | title = "RTI Noise: %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
933 | xlabel = "" |
|
933 | xlabel = "" | |
934 | ylabel = "Range (Km)" |
|
934 | ylabel = "Range (Km)" | |
935 |
|
935 | |||
936 | if not self.__isConfig: |
|
936 | if not self.__isConfig: | |
937 |
|
937 | |||
938 | nplots = 1 |
|
938 | nplots = 1 | |
939 |
|
939 | |||
940 | self.setup(idfigure=idfigure, |
|
940 | self.setup(idfigure=idfigure, | |
941 | nplots=nplots, |
|
941 | nplots=nplots, | |
942 | wintitle=wintitle, |
|
942 | wintitle=wintitle, | |
943 | showprofile=showprofile) |
|
943 | showprofile=showprofile) | |
944 |
|
944 | |||
945 | tmin, tmax = self.getTimeLim(x, xmin, xmax) |
|
945 | tmin, tmax = self.getTimeLim(x, xmin, xmax) | |
946 | if ymin == None: ymin = numpy.nanmin(noisedB) |
|
946 | if ymin == None: ymin = numpy.nanmin(noisedB) | |
947 | if ymax == None: ymax = numpy.nanmax(noisedB) |
|
947 | if ymax == None: ymax = numpy.nanmax(noisedB) | |
948 |
|
948 | |||
949 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") |
|
949 | self.name = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
950 | self.__isConfig = True |
|
950 | self.__isConfig = True | |
951 |
|
951 | |||
952 | self.xdata = numpy.array([]) |
|
952 | self.xdata = numpy.array([]) | |
953 | self.ydata = numpy.array([]) |
|
953 | self.ydata = numpy.array([]) | |
954 |
|
954 | |||
955 | self.setWinTitle(title) |
|
955 | self.setWinTitle(title) | |
956 |
|
956 | |||
957 |
|
957 | |||
958 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) |
|
958 | title = "RTI Noise %s" %(thisDatetime.strftime("%d-%b-%Y")) | |
959 |
|
959 | |||
960 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] |
|
960 | legendlabels = ["channel %d"%idchannel for idchannel in channelList] | |
961 | axes = self.axesList[0] |
|
961 | axes = self.axesList[0] | |
962 |
|
962 | |||
963 | self.xdata = numpy.hstack((self.xdata, x[0:1])) |
|
963 | self.xdata = numpy.hstack((self.xdata, x[0:1])) | |
964 |
|
964 | |||
965 | if len(self.ydata)==0: |
|
965 | if len(self.ydata)==0: | |
966 | self.ydata = noisedB[channelIndexList].reshape(-1,1) |
|
966 | self.ydata = noisedB[channelIndexList].reshape(-1,1) | |
967 | else: |
|
967 | else: | |
968 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) |
|
968 | self.ydata = numpy.hstack((self.ydata, noisedB[channelIndexList].reshape(-1,1))) | |
969 |
|
969 | |||
970 |
|
970 | |||
971 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, |
|
971 | axes.pmultilineyaxis(x=self.xdata, y=self.ydata, | |
972 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, |
|
972 | xmin=tmin, xmax=tmax, ymin=ymin, ymax=ymax, | |
973 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", |
|
973 | xlabel=xlabel, ylabel=ylabel, title=title, legendlabels=legendlabels, marker='x', markersize=8, linestyle="solid", | |
974 | XAxisAsTime=True |
|
974 | XAxisAsTime=True | |
975 | ) |
|
975 | ) | |
976 |
|
976 | |||
977 | self.draw() |
|
977 | self.draw() | |
978 |
|
978 | |||
979 | if save: |
|
979 | if save: | |
980 |
|
980 | |||
981 | if figfile == None: |
|
981 | if figfile == None: | |
982 | figfile = self.getFilename(name = self.name) |
|
982 | figfile = self.getFilename(name = self.name) | |
983 |
|
983 | |||
984 | self.saveFigure(figpath, figfile) |
|
984 | self.saveFigure(figpath, figfile) | |
985 |
|
985 | |||
986 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: |
|
986 | if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
987 | self.__isConfig = False |
|
987 | self.__isConfig = False | |
988 | del self.xdata |
|
988 | del self.xdata | |
989 | del self.ydata |
|
989 | del self.ydata | |
990 | No newline at end of file |
|
990 |
General Comments 0
You need to be logged in to leave comments.
Login now