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