##// END OF EJS Templates
Add RHI plot mode to PlotPolarMapData
jespinoza -
r1141:2145c6c87174
parent child
Show More
@@ -1,1042 +1,1085
1
1
2 import os
2 import os
3 import time
3 import time
4 import glob
4 import glob
5 import datetime
5 import datetime
6 from multiprocessing import Process
6 from multiprocessing import Process
7
7
8 import zmq
8 import zmq
9 import numpy
9 import numpy
10 import matplotlib
10 import matplotlib
11 import matplotlib.pyplot as plt
11 import matplotlib.pyplot as plt
12 from mpl_toolkits.axes_grid1 import make_axes_locatable
12 from mpl_toolkits.axes_grid1 import make_axes_locatable
13 from matplotlib.ticker import FuncFormatter, LinearLocator, MultipleLocator
13 from matplotlib.ticker import FuncFormatter, LinearLocator, MultipleLocator
14
14
15 from schainpy.model.proc.jroproc_base import Operation
15 from schainpy.model.proc.jroproc_base import Operation
16 from schainpy.utils import log
16 from schainpy.utils import log
17
17
18 jet_values = matplotlib.pyplot.get_cmap('jet', 100)(numpy.arange(100))[10:90]
18 jet_values = matplotlib.pyplot.get_cmap('jet', 100)(numpy.arange(100))[10:90]
19 blu_values = matplotlib.pyplot.get_cmap(
19 blu_values = matplotlib.pyplot.get_cmap(
20 'seismic_r', 20)(numpy.arange(20))[10:15]
20 'seismic_r', 20)(numpy.arange(20))[10:15]
21 ncmap = matplotlib.colors.LinearSegmentedColormap.from_list(
21 ncmap = matplotlib.colors.LinearSegmentedColormap.from_list(
22 'jro', numpy.vstack((blu_values, jet_values)))
22 'jro', numpy.vstack((blu_values, jet_values)))
23 matplotlib.pyplot.register_cmap(cmap=ncmap)
23 matplotlib.pyplot.register_cmap(cmap=ncmap)
24
24
25 CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'viridis', 'plasma', 'inferno', 'Greys', 'seismic', 'bwr', 'coolwarm', 'spectral')]
25 CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'viridis', 'plasma', 'inferno', 'Greys', 'seismic', 'bwr', 'coolwarm', 'spectral')]
26
26
27
27
28 def figpause(interval):
28 def figpause(interval):
29 backend = plt.rcParams['backend']
29 backend = plt.rcParams['backend']
30 if backend in matplotlib.rcsetup.interactive_bk:
30 if backend in matplotlib.rcsetup.interactive_bk:
31 figManager = matplotlib._pylab_helpers.Gcf.get_active()
31 figManager = matplotlib._pylab_helpers.Gcf.get_active()
32 if figManager is not None:
32 if figManager is not None:
33 canvas = figManager.canvas
33 canvas = figManager.canvas
34 if canvas.figure.stale:
34 if canvas.figure.stale:
35 canvas.draw()
35 canvas.draw()
36 canvas.start_event_loop(interval)
36 canvas.start_event_loop(interval)
37 return
37 return
38
38
39
39
40 class PlotData(Operation, Process):
40 class PlotData(Operation, Process):
41 '''
41 '''
42 Base class for Schain plotting operations
42 Base class for Schain plotting operations
43 '''
43 '''
44
44
45 CODE = 'Figure'
45 CODE = 'Figure'
46 colormap = 'jro'
46 colormap = 'jro'
47 bgcolor = 'white'
47 bgcolor = 'white'
48 CONFLATE = False
48 CONFLATE = False
49 __missing = 1E30
49 __missing = 1E30
50
50
51 __attrs__ = ['show', 'save', 'xmin', 'xmax', 'ymin', 'ymax', 'zmin', 'zmax',
51 __attrs__ = ['show', 'save', 'xmin', 'xmax', 'ymin', 'ymax', 'zmin', 'zmax',
52 'zlimits', 'xlabel', 'ylabel', 'xaxis','cb_label', 'title',
52 'zlimits', 'xlabel', 'ylabel', 'xaxis','cb_label', 'title',
53 'colorbar', 'bgcolor', 'width', 'height', 'localtime', 'oneFigure',
53 'colorbar', 'bgcolor', 'width', 'height', 'localtime', 'oneFigure',
54 'showprofile', 'decimation', 'ftp']
54 'showprofile', 'decimation', 'ftp']
55
55
56 def __init__(self, **kwargs):
56 def __init__(self, **kwargs):
57
57
58 Operation.__init__(self, plot=True, **kwargs)
58 Operation.__init__(self, plot=True, **kwargs)
59 Process.__init__(self)
59 Process.__init__(self)
60
60
61 self.kwargs['code'] = self.CODE
61 self.kwargs['code'] = self.CODE
62 self.mp = False
62 self.mp = False
63 self.data = None
63 self.data = None
64 self.isConfig = False
64 self.isConfig = False
65 self.figures = []
65 self.figures = []
66 self.axes = []
66 self.axes = []
67 self.cb_axes = []
67 self.cb_axes = []
68 self.localtime = kwargs.pop('localtime', True)
68 self.localtime = kwargs.pop('localtime', True)
69 self.show = kwargs.get('show', True)
69 self.show = kwargs.get('show', True)
70 self.save = kwargs.get('save', False)
70 self.save = kwargs.get('save', False)
71 self.ftp = kwargs.get('ftp', False)
71 self.ftp = kwargs.get('ftp', False)
72 self.colormap = kwargs.get('colormap', self.colormap)
72 self.colormap = kwargs.get('colormap', self.colormap)
73 self.colormap_coh = kwargs.get('colormap_coh', 'jet')
73 self.colormap_coh = kwargs.get('colormap_coh', 'jet')
74 self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r')
74 self.colormap_phase = kwargs.get('colormap_phase', 'RdBu_r')
75 self.colormaps = kwargs.get('colormaps', None)
75 self.colormaps = kwargs.get('colormaps', None)
76 self.bgcolor = kwargs.get('bgcolor', self.bgcolor)
76 self.bgcolor = kwargs.get('bgcolor', self.bgcolor)
77 self.showprofile = kwargs.get('showprofile', False)
77 self.showprofile = kwargs.get('showprofile', False)
78 self.title = kwargs.get('wintitle', self.CODE.upper())
78 self.title = kwargs.get('wintitle', self.CODE.upper())
79 self.cb_label = kwargs.get('cb_label', None)
79 self.cb_label = kwargs.get('cb_label', None)
80 self.cb_labels = kwargs.get('cb_labels', None)
80 self.cb_labels = kwargs.get('cb_labels', None)
81 self.labels = kwargs.get('labels', None)
81 self.labels = kwargs.get('labels', None)
82 self.xaxis = kwargs.get('xaxis', 'frequency')
82 self.xaxis = kwargs.get('xaxis', 'frequency')
83 self.zmin = kwargs.get('zmin', None)
83 self.zmin = kwargs.get('zmin', None)
84 self.zmax = kwargs.get('zmax', None)
84 self.zmax = kwargs.get('zmax', None)
85 self.zlimits = kwargs.get('zlimits', None)
85 self.zlimits = kwargs.get('zlimits', None)
86 self.xmin = kwargs.get('xmin', None)
86 self.xmin = kwargs.get('xmin', None)
87 self.xmax = kwargs.get('xmax', None)
87 self.xmax = kwargs.get('xmax', None)
88 self.xrange = kwargs.get('xrange', 24)
88 self.xrange = kwargs.get('xrange', 24)
89 self.xscale = kwargs.get('xscale', None)
89 self.xscale = kwargs.get('xscale', None)
90 self.ymin = kwargs.get('ymin', None)
90 self.ymin = kwargs.get('ymin', None)
91 self.ymax = kwargs.get('ymax', None)
91 self.ymax = kwargs.get('ymax', None)
92 self.yscale = kwargs.get('yscale', None)
92 self.yscale = kwargs.get('yscale', None)
93 self.xlabel = kwargs.get('xlabel', None)
93 self.xlabel = kwargs.get('xlabel', None)
94 self.decimation = kwargs.get('decimation', None)
94 self.decimation = kwargs.get('decimation', None)
95 self.showSNR = kwargs.get('showSNR', False)
95 self.showSNR = kwargs.get('showSNR', False)
96 self.oneFigure = kwargs.get('oneFigure', True)
96 self.oneFigure = kwargs.get('oneFigure', True)
97 self.width = kwargs.get('width', None)
97 self.width = kwargs.get('width', None)
98 self.height = kwargs.get('height', None)
98 self.height = kwargs.get('height', None)
99 self.colorbar = kwargs.get('colorbar', True)
99 self.colorbar = kwargs.get('colorbar', True)
100 self.factors = kwargs.get('factors', [1, 1, 1, 1, 1, 1, 1, 1])
100 self.factors = kwargs.get('factors', [1, 1, 1, 1, 1, 1, 1, 1])
101 self.channels = kwargs.get('channels', None)
101 self.channels = kwargs.get('channels', None)
102 self.titles = kwargs.get('titles', [])
102 self.titles = kwargs.get('titles', [])
103 self.polar = False
103 self.polar = False
104
104
105 def __fmtTime(self, x, pos):
105 def __fmtTime(self, x, pos):
106 '''
106 '''
107 '''
107 '''
108
108
109 return '{}'.format(self.getDateTime(x).strftime('%H:%M'))
109 return '{}'.format(self.getDateTime(x).strftime('%H:%M'))
110
110
111 def __setup(self):
111 def __setup(self):
112 '''
112 '''
113 Common setup for all figures, here figures and axes are created
113 Common setup for all figures, here figures and axes are created
114 '''
114 '''
115
115
116 if self.CODE not in self.data:
116 if self.CODE not in self.data:
117 raise ValueError(log.error('Missing data for {}'.format(self.CODE),
117 raise ValueError(log.error('Missing data for {}'.format(self.CODE),
118 self.name))
118 self.name))
119
119
120 self.setup()
120 self.setup()
121
121
122 self.time_label = 'LT' if self.localtime else 'UTC'
122 self.time_label = 'LT' if self.localtime else 'UTC'
123 if self.data.localtime:
123 if self.data.localtime:
124 self.getDateTime = datetime.datetime.fromtimestamp
124 self.getDateTime = datetime.datetime.fromtimestamp
125 else:
125 else:
126 self.getDateTime = datetime.datetime.utcfromtimestamp
126 self.getDateTime = datetime.datetime.utcfromtimestamp
127
127
128 if self.width is None:
128 if self.width is None:
129 self.width = 8
129 self.width = 8
130
130
131 self.figures = []
131 self.figures = []
132 self.axes = []
132 self.axes = []
133 self.cb_axes = []
133 self.cb_axes = []
134 self.pf_axes = []
134 self.pf_axes = []
135 self.cmaps = []
135 self.cmaps = []
136
136
137 size = '15%' if self.ncols == 1 else '30%'
137 size = '15%' if self.ncols == 1 else '30%'
138 pad = '4%' if self.ncols == 1 else '8%'
138 pad = '4%' if self.ncols == 1 else '8%'
139
139
140 if self.oneFigure:
140 if self.oneFigure:
141 if self.height is None:
141 if self.height is None:
142 self.height = 1.4 * self.nrows + 1
142 self.height = 1.4 * self.nrows + 1
143 fig = plt.figure(figsize=(self.width, self.height),
143 fig = plt.figure(figsize=(self.width, self.height),
144 edgecolor='k',
144 edgecolor='k',
145 facecolor='w')
145 facecolor='w')
146 self.figures.append(fig)
146 self.figures.append(fig)
147 for n in range(self.nplots):
147 for n in range(self.nplots):
148 ax = fig.add_subplot(self.nrows, self.ncols,
148 ax = fig.add_subplot(self.nrows, self.ncols,
149 n + 1, polar=self.polar)
149 n + 1, polar=self.polar)
150 ax.tick_params(labelsize=8)
150 ax.tick_params(labelsize=8)
151 ax.firsttime = True
151 ax.firsttime = True
152 ax.index = 0
152 ax.index = 0
153 ax.press = None
153 ax.press = None
154 self.axes.append(ax)
154 self.axes.append(ax)
155 if self.showprofile:
155 if self.showprofile:
156 cax = self.__add_axes(ax, size=size, pad=pad)
156 cax = self.__add_axes(ax, size=size, pad=pad)
157 cax.tick_params(labelsize=8)
157 cax.tick_params(labelsize=8)
158 self.pf_axes.append(cax)
158 self.pf_axes.append(cax)
159 else:
159 else:
160 if self.height is None:
160 if self.height is None:
161 self.height = 3
161 self.height = 3
162 for n in range(self.nplots):
162 for n in range(self.nplots):
163 fig = plt.figure(figsize=(self.width, self.height),
163 fig = plt.figure(figsize=(self.width, self.height),
164 edgecolor='k',
164 edgecolor='k',
165 facecolor='w')
165 facecolor='w')
166 ax = fig.add_subplot(1, 1, 1, polar=self.polar)
166 ax = fig.add_subplot(1, 1, 1, polar=self.polar)
167 ax.tick_params(labelsize=8)
167 ax.tick_params(labelsize=8)
168 ax.firsttime = True
168 ax.firsttime = True
169 ax.index = 0
169 ax.index = 0
170 ax.press = None
170 ax.press = None
171 self.figures.append(fig)
171 self.figures.append(fig)
172 self.axes.append(ax)
172 self.axes.append(ax)
173 if self.showprofile:
173 if self.showprofile:
174 cax = self.__add_axes(ax, size=size, pad=pad)
174 cax = self.__add_axes(ax, size=size, pad=pad)
175 cax.tick_params(labelsize=8)
175 cax.tick_params(labelsize=8)
176 self.pf_axes.append(cax)
176 self.pf_axes.append(cax)
177
177
178 for n in range(self.nrows):
178 for n in range(self.nrows):
179 if self.colormaps is not None:
179 if self.colormaps is not None:
180 cmap = plt.get_cmap(self.colormaps[n])
180 cmap = plt.get_cmap(self.colormaps[n])
181 else:
181 else:
182 cmap = plt.get_cmap(self.colormap)
182 cmap = plt.get_cmap(self.colormap)
183 cmap.set_bad(self.bgcolor, 1.)
183 cmap.set_bad(self.bgcolor, 1.)
184 self.cmaps.append(cmap)
184 self.cmaps.append(cmap)
185
185
186 for fig in self.figures:
186 for fig in self.figures:
187 fig.canvas.mpl_connect('key_press_event', self.OnKeyPress)
187 fig.canvas.mpl_connect('key_press_event', self.OnKeyPress)
188 fig.canvas.mpl_connect('scroll_event', self.OnBtnScroll)
188 fig.canvas.mpl_connect('scroll_event', self.OnBtnScroll)
189 fig.canvas.mpl_connect('button_press_event', self.onBtnPress)
189 fig.canvas.mpl_connect('button_press_event', self.onBtnPress)
190 fig.canvas.mpl_connect('motion_notify_event', self.onMotion)
190 fig.canvas.mpl_connect('motion_notify_event', self.onMotion)
191 fig.canvas.mpl_connect('button_release_event', self.onBtnRelease)
191 fig.canvas.mpl_connect('button_release_event', self.onBtnRelease)
192 if self.show:
192 if self.show:
193 fig.show()
193 fig.show()
194
194
195 def OnKeyPress(self, event):
195 def OnKeyPress(self, event):
196 '''
196 '''
197 Event for pressing keys (up, down) change colormap
197 Event for pressing keys (up, down) change colormap
198 '''
198 '''
199 ax = event.inaxes
199 ax = event.inaxes
200 if ax in self.axes:
200 if ax in self.axes:
201 if event.key == 'down':
201 if event.key == 'down':
202 ax.index += 1
202 ax.index += 1
203 elif event.key == 'up':
203 elif event.key == 'up':
204 ax.index -= 1
204 ax.index -= 1
205 if ax.index < 0:
205 if ax.index < 0:
206 ax.index = len(CMAPS) - 1
206 ax.index = len(CMAPS) - 1
207 elif ax.index == len(CMAPS):
207 elif ax.index == len(CMAPS):
208 ax.index = 0
208 ax.index = 0
209 cmap = CMAPS[ax.index]
209 cmap = CMAPS[ax.index]
210 ax.cbar.set_cmap(cmap)
210 ax.cbar.set_cmap(cmap)
211 ax.cbar.draw_all()
211 ax.cbar.draw_all()
212 ax.plt.set_cmap(cmap)
212 ax.plt.set_cmap(cmap)
213 ax.cbar.patch.figure.canvas.draw()
213 ax.cbar.patch.figure.canvas.draw()
214 self.colormap = cmap.name
214 self.colormap = cmap.name
215
215
216 def OnBtnScroll(self, event):
216 def OnBtnScroll(self, event):
217 '''
217 '''
218 Event for scrolling, scale figure
218 Event for scrolling, scale figure
219 '''
219 '''
220 cb_ax = event.inaxes
220 cb_ax = event.inaxes
221 if cb_ax in [ax.cbar.ax for ax in self.axes if ax.cbar]:
221 if cb_ax in [ax.cbar.ax for ax in self.axes if ax.cbar]:
222 ax = [ax for ax in self.axes if cb_ax == ax.cbar.ax][0]
222 ax = [ax for ax in self.axes if cb_ax == ax.cbar.ax][0]
223 pt = ax.cbar.ax.bbox.get_points()[:, 1]
223 pt = ax.cbar.ax.bbox.get_points()[:, 1]
224 nrm = ax.cbar.norm
224 nrm = ax.cbar.norm
225 vmin, vmax, p0, p1, pS = (
225 vmin, vmax, p0, p1, pS = (
226 nrm.vmin, nrm.vmax, pt[0], pt[1], event.y)
226 nrm.vmin, nrm.vmax, pt[0], pt[1], event.y)
227 scale = 2 if event.step == 1 else 0.5
227 scale = 2 if event.step == 1 else 0.5
228 point = vmin + (vmax - vmin) / (p1 - p0) * (pS - p0)
228 point = vmin + (vmax - vmin) / (p1 - p0) * (pS - p0)
229 ax.cbar.norm.vmin = point - scale * (point - vmin)
229 ax.cbar.norm.vmin = point - scale * (point - vmin)
230 ax.cbar.norm.vmax = point - scale * (point - vmax)
230 ax.cbar.norm.vmax = point - scale * (point - vmax)
231 ax.plt.set_norm(ax.cbar.norm)
231 ax.plt.set_norm(ax.cbar.norm)
232 ax.cbar.draw_all()
232 ax.cbar.draw_all()
233 ax.cbar.patch.figure.canvas.draw()
233 ax.cbar.patch.figure.canvas.draw()
234
234
235 def onBtnPress(self, event):
235 def onBtnPress(self, event):
236 '''
236 '''
237 Event for mouse button press
237 Event for mouse button press
238 '''
238 '''
239 cb_ax = event.inaxes
239 cb_ax = event.inaxes
240 if cb_ax is None:
240 if cb_ax is None:
241 return
241 return
242
242
243 if cb_ax in [ax.cbar.ax for ax in self.axes if ax.cbar]:
243 if cb_ax in [ax.cbar.ax for ax in self.axes if ax.cbar]:
244 cb_ax.press = event.x, event.y
244 cb_ax.press = event.x, event.y
245 else:
245 else:
246 cb_ax.press = None
246 cb_ax.press = None
247
247
248 def onMotion(self, event):
248 def onMotion(self, event):
249 '''
249 '''
250 Event for move inside colorbar
250 Event for move inside colorbar
251 '''
251 '''
252 cb_ax = event.inaxes
252 cb_ax = event.inaxes
253 if cb_ax is None:
253 if cb_ax is None:
254 return
254 return
255 if cb_ax not in [ax.cbar.ax for ax in self.axes if ax.cbar]:
255 if cb_ax not in [ax.cbar.ax for ax in self.axes if ax.cbar]:
256 return
256 return
257 if cb_ax.press is None:
257 if cb_ax.press is None:
258 return
258 return
259
259
260 ax = [ax for ax in self.axes if cb_ax == ax.cbar.ax][0]
260 ax = [ax for ax in self.axes if cb_ax == ax.cbar.ax][0]
261 xprev, yprev = cb_ax.press
261 xprev, yprev = cb_ax.press
262 dx = event.x - xprev
262 dx = event.x - xprev
263 dy = event.y - yprev
263 dy = event.y - yprev
264 cb_ax.press = event.x, event.y
264 cb_ax.press = event.x, event.y
265 scale = ax.cbar.norm.vmax - ax.cbar.norm.vmin
265 scale = ax.cbar.norm.vmax - ax.cbar.norm.vmin
266 perc = 0.03
266 perc = 0.03
267
267
268 if event.button == 1:
268 if event.button == 1:
269 ax.cbar.norm.vmin -= (perc * scale) * numpy.sign(dy)
269 ax.cbar.norm.vmin -= (perc * scale) * numpy.sign(dy)
270 ax.cbar.norm.vmax -= (perc * scale) * numpy.sign(dy)
270 ax.cbar.norm.vmax -= (perc * scale) * numpy.sign(dy)
271 elif event.button == 3:
271 elif event.button == 3:
272 ax.cbar.norm.vmin -= (perc * scale) * numpy.sign(dy)
272 ax.cbar.norm.vmin -= (perc * scale) * numpy.sign(dy)
273 ax.cbar.norm.vmax += (perc * scale) * numpy.sign(dy)
273 ax.cbar.norm.vmax += (perc * scale) * numpy.sign(dy)
274
274
275 ax.cbar.draw_all()
275 ax.cbar.draw_all()
276 ax.plt.set_norm(ax.cbar.norm)
276 ax.plt.set_norm(ax.cbar.norm)
277 ax.cbar.patch.figure.canvas.draw()
277 ax.cbar.patch.figure.canvas.draw()
278
278
279 def onBtnRelease(self, event):
279 def onBtnRelease(self, event):
280 '''
280 '''
281 Event for mouse button release
281 Event for mouse button release
282 '''
282 '''
283 cb_ax = event.inaxes
283 cb_ax = event.inaxes
284 if cb_ax is not None:
284 if cb_ax is not None:
285 cb_ax.press = None
285 cb_ax.press = None
286
286
287 def __add_axes(self, ax, size='30%', pad='8%'):
287 def __add_axes(self, ax, size='30%', pad='8%'):
288 '''
288 '''
289 Add new axes to the given figure
289 Add new axes to the given figure
290 '''
290 '''
291 divider = make_axes_locatable(ax)
291 divider = make_axes_locatable(ax)
292 nax = divider.new_horizontal(size=size, pad=pad)
292 nax = divider.new_horizontal(size=size, pad=pad)
293 ax.figure.add_axes(nax)
293 ax.figure.add_axes(nax)
294 return nax
294 return nax
295
295
296 self.setup()
296 self.setup()
297
297
298 def setup(self):
298 def setup(self):
299 '''
299 '''
300 This method should be implemented in the child class, the following
300 This method should be implemented in the child class, the following
301 attributes should be set:
301 attributes should be set:
302
302
303 self.nrows: number of rows
303 self.nrows: number of rows
304 self.ncols: number of cols
304 self.ncols: number of cols
305 self.nplots: number of plots (channels or pairs)
305 self.nplots: number of plots (channels or pairs)
306 self.ylabel: label for Y axes
306 self.ylabel: label for Y axes
307 self.titles: list of axes title
307 self.titles: list of axes title
308
308
309 '''
309 '''
310 raise(NotImplementedError, 'Implement this method in child class')
310 raise(NotImplementedError, 'Implement this method in child class')
311
311
312 def fill_gaps(self, x_buffer, y_buffer, z_buffer):
312 def fill_gaps(self, x_buffer, y_buffer, z_buffer):
313 '''
313 '''
314 Create a masked array for missing data
314 Create a masked array for missing data
315 '''
315 '''
316 if x_buffer.shape[0] < 2:
316 if x_buffer.shape[0] < 2:
317 return x_buffer, y_buffer, z_buffer
317 return x_buffer, y_buffer, z_buffer
318
318
319 deltas = x_buffer[1:] - x_buffer[0:-1]
319 deltas = x_buffer[1:] - x_buffer[0:-1]
320 x_median = numpy.median(deltas)
320 x_median = numpy.median(deltas)
321
321
322 index = numpy.where(deltas > 5 * x_median)
322 index = numpy.where(deltas > 5 * x_median)
323
323
324 if len(index[0]) != 0:
324 if len(index[0]) != 0:
325 z_buffer[::, index[0], ::] = self.__missing
325 z_buffer[::, index[0], ::] = self.__missing
326 z_buffer = numpy.ma.masked_inside(z_buffer,
326 z_buffer = numpy.ma.masked_inside(z_buffer,
327 0.99 * self.__missing,
327 0.99 * self.__missing,
328 1.01 * self.__missing)
328 1.01 * self.__missing)
329
329
330 return x_buffer, y_buffer, z_buffer
330 return x_buffer, y_buffer, z_buffer
331
331
332 def decimate(self):
332 def decimate(self):
333
333
334 # dx = int(len(self.x)/self.__MAXNUMX) + 1
334 # dx = int(len(self.x)/self.__MAXNUMX) + 1
335 dy = int(len(self.y) / self.decimation) + 1
335 dy = int(len(self.y) / self.decimation) + 1
336
336
337 # x = self.x[::dx]
337 # x = self.x[::dx]
338 x = self.x
338 x = self.x
339 y = self.y[::dy]
339 y = self.y[::dy]
340 z = self.z[::, ::, ::dy]
340 z = self.z[::, ::, ::dy]
341
341
342 return x, y, z
342 return x, y, z
343
343
344 def format(self):
344 def format(self):
345 '''
345 '''
346 Set min and max values, labels, ticks and titles
346 Set min and max values, labels, ticks and titles
347 '''
347 '''
348
348
349 if self.xmin is None:
349 if self.xmin is None:
350 xmin = self.min_time
350 xmin = self.min_time
351 else:
351 else:
352 if self.xaxis is 'time':
352 if self.xaxis is 'time':
353 dt = self.getDateTime(self.min_time)
353 dt = self.getDateTime(self.min_time)
354 xmin = (dt.replace(hour=int(self.xmin), minute=0, second=0) -
354 xmin = (dt.replace(hour=int(self.xmin), minute=0, second=0) -
355 datetime.datetime(1970, 1, 1)).total_seconds()
355 datetime.datetime(1970, 1, 1)).total_seconds()
356 if self.data.localtime:
356 if self.data.localtime:
357 xmin += time.timezone
357 xmin += time.timezone
358 else:
358 else:
359 xmin = self.xmin
359 xmin = self.xmin
360
360
361 if self.xmax is None:
361 if self.xmax is None:
362 xmax = xmin + self.xrange * 60 * 60
362 xmax = xmin + self.xrange * 60 * 60
363 else:
363 else:
364 if self.xaxis is 'time':
364 if self.xaxis is 'time':
365 dt = self.getDateTime(self.max_time)
365 dt = self.getDateTime(self.max_time)
366 xmax = (dt.replace(hour=int(self.xmax), minute=59, second=59) -
366 xmax = (dt.replace(hour=int(self.xmax), minute=59, second=59) -
367 datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=1)).total_seconds()
367 datetime.datetime(1970, 1, 1) + datetime.timedelta(seconds=1)).total_seconds()
368 if self.data.localtime:
368 if self.data.localtime:
369 xmax += time.timezone
369 xmax += time.timezone
370 else:
370 else:
371 xmax = self.xmax
371 xmax = self.xmax
372
372
373 ymin = self.ymin if self.ymin else numpy.nanmin(self.y)
373 ymin = self.ymin if self.ymin else numpy.nanmin(self.y)
374 ymax = self.ymax if self.ymax else numpy.nanmax(self.y)
374 ymax = self.ymax if self.ymax else numpy.nanmax(self.y)
375
375
376 Y = numpy.array([5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000])
376 Y = numpy.array([5, 10, 20, 50, 100, 200, 500, 1000, 2000, 5000])
377 i = 1 if numpy.where(abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0]
377 i = 1 if numpy.where(abs(ymax-ymin) <= Y)[0][0] < 0 else numpy.where(abs(ymax-ymin) <= Y)[0][0]
378 ystep = Y[i] / 5.
378 ystep = Y[i] / 5.
379
379
380 for n, ax in enumerate(self.axes):
380 for n, ax in enumerate(self.axes):
381 if ax.firsttime:
381 if ax.firsttime:
382 ax.set_facecolor(self.bgcolor)
382 ax.set_facecolor(self.bgcolor)
383 ax.yaxis.set_major_locator(MultipleLocator(ystep))
383 ax.yaxis.set_major_locator(MultipleLocator(ystep))
384 ax.xaxis.set_major_locator(MultipleLocator(ystep))
384 ax.xaxis.set_major_locator(MultipleLocator(ystep))
385 if self.xscale:
385 if self.xscale:
386 ax.xaxis.set_major_formatter(FuncFormatter(lambda x, pos: '{0:g}'.format(x*self.xscale)))
386 ax.xaxis.set_major_formatter(FuncFormatter(lambda x, pos: '{0:g}'.format(x*self.xscale)))
387 if self.xscale:
387 if self.xscale:
388 ax.yaxis.set_major_formatter(FuncFormatter(lambda x, pos: '{0:g}'.format(x*self.yscale)))
388 ax.yaxis.set_major_formatter(FuncFormatter(lambda x, pos: '{0:g}'.format(x*self.yscale)))
389 if self.xaxis is 'time':
389 if self.xaxis is 'time':
390 ax.xaxis.set_major_formatter(FuncFormatter(self.__fmtTime))
390 ax.xaxis.set_major_formatter(FuncFormatter(self.__fmtTime))
391 ax.xaxis.set_major_locator(LinearLocator(9))
391 ax.xaxis.set_major_locator(LinearLocator(9))
392 if self.xlabel is not None:
392 if self.xlabel is not None:
393 ax.set_xlabel(self.xlabel)
393 ax.set_xlabel(self.xlabel)
394 ax.set_ylabel(self.ylabel)
394 ax.set_ylabel(self.ylabel)
395 ax.firsttime = False
395 ax.firsttime = False
396 if self.showprofile:
396 if self.showprofile:
397 self.pf_axes[n].set_ylim(ymin, ymax)
397 self.pf_axes[n].set_ylim(ymin, ymax)
398 self.pf_axes[n].set_xlim(self.zmin, self.zmax)
398 self.pf_axes[n].set_xlim(self.zmin, self.zmax)
399 self.pf_axes[n].set_xlabel('dB')
399 self.pf_axes[n].set_xlabel('dB')
400 self.pf_axes[n].grid(b=True, axis='x')
400 self.pf_axes[n].grid(b=True, axis='x')
401 [tick.set_visible(False)
401 [tick.set_visible(False)
402 for tick in self.pf_axes[n].get_yticklabels()]
402 for tick in self.pf_axes[n].get_yticklabels()]
403 if self.colorbar:
403 if self.colorbar:
404 ax.cbar = plt.colorbar(
404 ax.cbar = plt.colorbar(
405 ax.plt, ax=ax, fraction=0.05, pad=0.02, aspect=10)
405 ax.plt, ax=ax, fraction=0.05, pad=0.02, aspect=10)
406 ax.cbar.ax.tick_params(labelsize=8)
406 ax.cbar.ax.tick_params(labelsize=8)
407 ax.cbar.ax.press = None
407 ax.cbar.ax.press = None
408 if self.cb_label:
408 if self.cb_label:
409 ax.cbar.set_label(self.cb_label, size=8)
409 ax.cbar.set_label(self.cb_label, size=8)
410 elif self.cb_labels:
410 elif self.cb_labels:
411 ax.cbar.set_label(self.cb_labels[n], size=8)
411 ax.cbar.set_label(self.cb_labels[n], size=8)
412 else:
412 else:
413 ax.cbar = None
413 ax.cbar = None
414
414
415 if not self.polar:
415 if not self.polar:
416 ax.set_xlim(xmin, xmax)
416 ax.set_xlim(xmin, xmax)
417 ax.set_ylim(ymin, ymax)
417 ax.set_ylim(ymin, ymax)
418 ax.set_title('{} - {} {}'.format(
418 ax.set_title('{} - {} {}'.format(
419 self.titles[n],
419 self.titles[n],
420 self.getDateTime(self.max_time).strftime('%H:%M:%S'),
420 self.getDateTime(self.max_time).strftime('%H:%M:%S'),
421 self.time_label),
421 self.time_label),
422 size=8)
422 size=8)
423 else:
423 else:
424 ax.set_title('{}'.format(self.titles[n]), size=8)
424 ax.set_title('{}'.format(self.titles[n]), size=8)
425 ax.set_ylim(0, 90)
425 ax.set_ylim(0, 90)
426 ax.set_yticks(numpy.arange(0, 90, 20))
426 ax.set_yticks(numpy.arange(0, 90, 20))
427 ax.yaxis.labelpad = 40
427 ax.yaxis.labelpad = 40
428
428
429 def __plot(self):
429 def __plot(self):
430 '''
430 '''
431 '''
431 '''
432 log.log('Plotting', self.name)
432 log.log('Plotting', self.name)
433
433
434 try:
434 try:
435 self.plot()
435 self.plot()
436 self.format()
436 self.format()
437 except:
437 except Exception as e:
438 log.warning('{} Plot could not be updated... check data'.format(self.CODE), self.name)
438 log.warning('{} Plot could not be updated... check data'.format(self.CODE), self.name)
439 log.error(str(e), '')
440 return
439
441
440 for n, fig in enumerate(self.figures):
442 for n, fig in enumerate(self.figures):
441 if self.nrows == 0 or self.nplots == 0:
443 if self.nrows == 0 or self.nplots == 0:
442 log.warning('No data', self.name)
444 log.warning('No data', self.name)
443 fig.text(0.5, 0.5, 'No Data', fontsize='large', ha='center')
445 fig.text(0.5, 0.5, 'No Data', fontsize='large', ha='center')
444 fig.canvas.manager.set_window_title(self.CODE)
446 fig.canvas.manager.set_window_title(self.CODE)
445 continue
447 continue
446
448
447 fig.tight_layout()
449 fig.tight_layout()
448 fig.canvas.manager.set_window_title('{} - {}'.format(self.title,
450 fig.canvas.manager.set_window_title('{} - {}'.format(self.title,
449 self.getDateTime(self.max_time).strftime('%Y/%m/%d')))
451 self.getDateTime(self.max_time).strftime('%Y/%m/%d')))
450 fig.canvas.draw()
452 fig.canvas.draw()
451
453
452 if self.save and (self.data.ended or not self.data.buffering):
454 if self.save and (self.data.ended or not self.data.buffering):
453
455
454 if self.labels:
456 if self.save_labels:
455 labels = self.labels
457 labels = self.save_labels
456 else:
458 else:
457 labels = range(self.nrows)
459 labels = range(self.nrows)
458
460
459 if self.oneFigure:
461 if self.oneFigure:
460 label = ''
462 label = ''
461 else:
463 else:
462 label = '-{}'.format(labels[n])
464 label = '-{}'.format(labels[n])
463 figname = os.path.join(
465 figname = os.path.join(
464 self.save,
466 self.save,
465 self.CODE,
467 self.CODE,
466 '{}{}_{}.png'.format(
468 '{}{}_{}.png'.format(
467 self.CODE,
469 self.CODE,
468 label,
470 label,
469 self.getDateTime(self.saveTime).strftime(
471 self.getDateTime(self.saveTime).strftime(
470 '%Y%m%d_%H%M%S'),
472 '%Y%m%d_%H%M%S'),
471 )
473 )
472 )
474 )
473 log.log('Saving figure: {}'.format(figname), self.name)
475 log.log('Saving figure: {}'.format(figname), self.name)
474 if not os.path.isdir(os.path.dirname(figname)):
476 if not os.path.isdir(os.path.dirname(figname)):
475 os.makedirs(os.path.dirname(figname))
477 os.makedirs(os.path.dirname(figname))
476 fig.savefig(figname)
478 fig.savefig(figname)
477
479
478 def plot(self):
480 def plot(self):
479 '''
481 '''
480 '''
482 '''
481 raise(NotImplementedError, 'Implement this method in child class')
483 raise(NotImplementedError, 'Implement this method in child class')
482
484
483 def run(self):
485 def run(self):
484
486
485 log.log('Starting', self.name)
487 log.log('Starting', self.name)
486
488
487 context = zmq.Context()
489 context = zmq.Context()
488 receiver = context.socket(zmq.SUB)
490 receiver = context.socket(zmq.SUB)
489 receiver.setsockopt(zmq.SUBSCRIBE, '')
491 receiver.setsockopt(zmq.SUBSCRIBE, '')
490 receiver.setsockopt(zmq.CONFLATE, self.CONFLATE)
492 receiver.setsockopt(zmq.CONFLATE, self.CONFLATE)
491
493
492 if 'server' in self.kwargs['parent']:
494 if 'server' in self.kwargs['parent']:
493 receiver.connect(
495 receiver.connect(
494 'ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server']))
496 'ipc:///tmp/{}.plots'.format(self.kwargs['parent']['server']))
495 else:
497 else:
496 receiver.connect("ipc:///tmp/zmq.plots")
498 receiver.connect("ipc:///tmp/zmq.plots")
497
499
498 while True:
500 while True:
499 try:
501 try:
500 self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK)
502 self.data = receiver.recv_pyobj(flags=zmq.NOBLOCK)
501 if self.data.localtime and self.localtime:
503 if self.data.localtime and self.localtime:
502 self.times = self.data.times
504 self.times = self.data.times
503 elif self.data.localtime and not self.localtime:
505 elif self.data.localtime and not self.localtime:
504 self.times = self.data.times + time.timezone
506 self.times = self.data.times + time.timezone
505 elif not self.data.localtime and self.localtime:
507 elif not self.data.localtime and self.localtime:
506 self.times = self.data.times - time.timezone
508 self.times = self.data.times - time.timezone
507 else:
509 else:
508 self.times = self.data.times
510 self.times = self.data.times
509
511
510 self.min_time = self.times[0]
512 self.min_time = self.times[0]
511 self.max_time = self.times[-1]
513 self.max_time = self.times[-1]
512
514
513 if self.isConfig is False:
515 if self.isConfig is False:
514 self.__setup()
516 self.__setup()
515 self.isConfig = True
517 self.isConfig = True
516
518
517 self.__plot()
519 self.__plot()
518
520
519 except zmq.Again as e:
521 except zmq.Again as e:
520 # log.log('.', tag='', nl=False)
522 # log.log('.', tag='', nl=False)
521 if self.data:
523 if self.data:
522 figpause(self.data.throttle)
524 figpause(self.data.throttle)
523 else:
525 else:
524 time.sleep(2)
526 time.sleep(2)
525
527
526 def close(self):
528 def close(self):
527 if self.data:
529 if self.data:
528 self.__plot()
530 self.__plot()
529
531
530
532
531 class PlotSpectraData(PlotData):
533 class PlotSpectraData(PlotData):
532 '''
534 '''
533 Plot for Spectra data
535 Plot for Spectra data
534 '''
536 '''
535
537
536 CODE = 'spc'
538 CODE = 'spc'
537 colormap = 'jro'
539 colormap = 'jro'
538
540
539 def setup(self):
541 def setup(self):
540 self.nplots = len(self.data.channels)
542 self.nplots = len(self.data.channels)
541 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
543 self.ncols = int(numpy.sqrt(self.nplots) + 0.9)
542 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
544 self.nrows = int((1.0 * self.nplots / self.ncols) + 0.9)
543 self.width = 3.4 * self.ncols
545 self.width = 3.4 * self.ncols
544 self.height = 3 * self.nrows
546 self.height = 3 * self.nrows
545 self.cb_label = 'dB'
547 self.cb_label = 'dB'
546 if self.showprofile:
548 if self.showprofile:
547 self.width += 0.8 * self.ncols
549 self.width += 0.8 * self.ncols
548
550
549 self.ylabel = 'Range [km]'
551 self.ylabel = 'Range [km]'
550
552
551 def plot(self):
553 def plot(self):
552 if self.xaxis == "frequency":
554 if self.xaxis == "frequency":
553 x = self.data.xrange[0]
555 x = self.data.xrange[0]
554 self.xlabel = "Frequency (kHz)"
556 self.xlabel = "Frequency (kHz)"
555 elif self.xaxis == "time":
557 elif self.xaxis == "time":
556 x = self.data.xrange[1]
558 x = self.data.xrange[1]
557 self.xlabel = "Time (ms)"
559 self.xlabel = "Time (ms)"
558 else:
560 else:
559 x = self.data.xrange[2]
561 x = self.data.xrange[2]
560 self.xlabel = "Velocity (m/s)"
562 self.xlabel = "Velocity (m/s)"
561
563
562 if self.CODE == 'spc_mean':
564 if self.CODE == 'spc_mean':
563 x = self.data.xrange[2]
565 x = self.data.xrange[2]
564 self.xlabel = "Velocity (m/s)"
566 self.xlabel = "Velocity (m/s)"
565
567
566 self.titles = []
568 self.titles = []
567
569
568 y = self.data.heights
570 y = self.data.heights
569 self.y = y
571 self.y = y
570 z = self.data['spc']
572 z = self.data['spc']
571
573
572 for n, ax in enumerate(self.axes):
574 for n, ax in enumerate(self.axes):
573 noise = self.data['noise'][n][-1]
575 noise = self.data['noise'][n][-1]
574 if self.CODE == 'spc_mean':
576 if self.CODE == 'spc_mean':
575 mean = self.data['mean'][n][-1]
577 mean = self.data['mean'][n][-1]
576 if ax.firsttime:
578 if ax.firsttime:
577 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
579 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
578 self.xmin = self.xmin if self.xmin else -self.xmax
580 self.xmin = self.xmin if self.xmin else -self.xmax
579 self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
581 self.zmin = self.zmin if self.zmin else numpy.nanmin(z)
580 self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
582 self.zmax = self.zmax if self.zmax else numpy.nanmax(z)
581 ax.plt = ax.pcolormesh(x, y, z[n].T,
583 ax.plt = ax.pcolormesh(x, y, z[n].T,
582 vmin=self.zmin,
584 vmin=self.zmin,
583 vmax=self.zmax,
585 vmax=self.zmax,
584 cmap=plt.get_cmap(self.colormap)
586 cmap=plt.get_cmap(self.colormap)
585 )
587 )
586
588
587 if self.showprofile:
589 if self.showprofile:
588 ax.plt_profile = self.pf_axes[n].plot(
590 ax.plt_profile = self.pf_axes[n].plot(
589 self.data['rti'][n][-1], y)[0]
591 self.data['rti'][n][-1], y)[0]
590 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
592 ax.plt_noise = self.pf_axes[n].plot(numpy.repeat(noise, len(y)), y,
591 color="k", linestyle="dashed", lw=1)[0]
593 color="k", linestyle="dashed", lw=1)[0]
592 if self.CODE == 'spc_mean':
594 if self.CODE == 'spc_mean':
593 ax.plt_mean = ax.plot(mean, y, color='k')[0]
595 ax.plt_mean = ax.plot(mean, y, color='k')[0]
594 else:
596 else:
595 ax.plt.set_array(z[n].T.ravel())
597 ax.plt.set_array(z[n].T.ravel())
596 if self.showprofile:
598 if self.showprofile:
597 ax.plt_profile.set_data(self.data['rti'][n][-1], y)
599 ax.plt_profile.set_data(self.data['rti'][n][-1], y)
598 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
600 ax.plt_noise.set_data(numpy.repeat(noise, len(y)), y)
599 if self.CODE == 'spc_mean':
601 if self.CODE == 'spc_mean':
600 ax.plt_mean.set_data(mean, y)
602 ax.plt_mean.set_data(mean, y)
601
603
602 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
604 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
603 self.saveTime = self.max_time
605 self.saveTime = self.max_time
604
606
605
607
606 class PlotCrossSpectraData(PlotData):
608 class PlotCrossSpectraData(PlotData):
607
609
608 CODE = 'cspc'
610 CODE = 'cspc'
609 zmin_coh = None
611 zmin_coh = None
610 zmax_coh = None
612 zmax_coh = None
611 zmin_phase = None
613 zmin_phase = None
612 zmax_phase = None
614 zmax_phase = None
613
615
614 def setup(self):
616 def setup(self):
615
617
616 self.ncols = 4
618 self.ncols = 4
617 self.nrows = len(self.data.pairs)
619 self.nrows = len(self.data.pairs)
618 self.nplots = self.nrows * 4
620 self.nplots = self.nrows * 4
619 self.width = 3.4 * self.ncols
621 self.width = 3.4 * self.ncols
620 self.height = 3 * self.nrows
622 self.height = 3 * self.nrows
621 self.ylabel = 'Range [km]'
623 self.ylabel = 'Range [km]'
622 self.showprofile = False
624 self.showprofile = False
623
625
624 def plot(self):
626 def plot(self):
625
627
626 if self.xaxis == "frequency":
628 if self.xaxis == "frequency":
627 x = self.data.xrange[0]
629 x = self.data.xrange[0]
628 self.xlabel = "Frequency (kHz)"
630 self.xlabel = "Frequency (kHz)"
629 elif self.xaxis == "time":
631 elif self.xaxis == "time":
630 x = self.data.xrange[1]
632 x = self.data.xrange[1]
631 self.xlabel = "Time (ms)"
633 self.xlabel = "Time (ms)"
632 else:
634 else:
633 x = self.data.xrange[2]
635 x = self.data.xrange[2]
634 self.xlabel = "Velocity (m/s)"
636 self.xlabel = "Velocity (m/s)"
635
637
636 self.titles = []
638 self.titles = []
637
639
638 y = self.data.heights
640 y = self.data.heights
639 self.y = y
641 self.y = y
640 spc = self.data['spc']
642 spc = self.data['spc']
641 cspc = self.data['cspc']
643 cspc = self.data['cspc']
642
644
643 for n in range(self.nrows):
645 for n in range(self.nrows):
644 noise = self.data['noise'][n][-1]
646 noise = self.data['noise'][n][-1]
645 pair = self.data.pairs[n]
647 pair = self.data.pairs[n]
646 ax = self.axes[4 * n]
648 ax = self.axes[4 * n]
647 ax3 = self.axes[4 * n + 3]
649 ax3 = self.axes[4 * n + 3]
648 if ax.firsttime:
650 if ax.firsttime:
649 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
651 self.xmax = self.xmax if self.xmax else numpy.nanmax(x)
650 self.xmin = self.xmin if self.xmin else -self.xmax
652 self.xmin = self.xmin if self.xmin else -self.xmax
651 self.zmin = self.zmin if self.zmin else numpy.nanmin(spc)
653 self.zmin = self.zmin if self.zmin else numpy.nanmin(spc)
652 self.zmax = self.zmax if self.zmax else numpy.nanmax(spc)
654 self.zmax = self.zmax if self.zmax else numpy.nanmax(spc)
653 ax.plt = ax.pcolormesh(x, y, spc[pair[0]].T,
655 ax.plt = ax.pcolormesh(x, y, spc[pair[0]].T,
654 vmin=self.zmin,
656 vmin=self.zmin,
655 vmax=self.zmax,
657 vmax=self.zmax,
656 cmap=plt.get_cmap(self.colormap)
658 cmap=plt.get_cmap(self.colormap)
657 )
659 )
658 else:
660 else:
659 ax.plt.set_array(spc[pair[0]].T.ravel())
661 ax.plt.set_array(spc[pair[0]].T.ravel())
660 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
662 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
661
663
662 ax = self.axes[4 * n + 1]
664 ax = self.axes[4 * n + 1]
663 if ax.firsttime:
665 if ax.firsttime:
664 ax.plt = ax.pcolormesh(x, y, spc[pair[1]].T,
666 ax.plt = ax.pcolormesh(x, y, spc[pair[1]].T,
665 vmin=self.zmin,
667 vmin=self.zmin,
666 vmax=self.zmax,
668 vmax=self.zmax,
667 cmap=plt.get_cmap(self.colormap)
669 cmap=plt.get_cmap(self.colormap)
668 )
670 )
669 else:
671 else:
670 ax.plt.set_array(spc[pair[1]].T.ravel())
672 ax.plt.set_array(spc[pair[1]].T.ravel())
671 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
673 self.titles.append('CH {}: {:3.2f}dB'.format(n, noise))
672
674
673 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
675 out = cspc[n] / numpy.sqrt(spc[pair[0]] * spc[pair[1]])
674 coh = numpy.abs(out)
676 coh = numpy.abs(out)
675 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
677 phase = numpy.arctan2(out.imag, out.real) * 180 / numpy.pi
676
678
677 ax = self.axes[4 * n + 2]
679 ax = self.axes[4 * n + 2]
678 if ax.firsttime:
680 if ax.firsttime:
679 ax.plt = ax.pcolormesh(x, y, coh.T,
681 ax.plt = ax.pcolormesh(x, y, coh.T,
680 vmin=0,
682 vmin=0,
681 vmax=1,
683 vmax=1,
682 cmap=plt.get_cmap(self.colormap_coh)
684 cmap=plt.get_cmap(self.colormap_coh)
683 )
685 )
684 else:
686 else:
685 ax.plt.set_array(coh.T.ravel())
687 ax.plt.set_array(coh.T.ravel())
686 self.titles.append(
688 self.titles.append(
687 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
689 'Coherence Ch{} * Ch{}'.format(pair[0], pair[1]))
688
690
689 ax = self.axes[4 * n + 3]
691 ax = self.axes[4 * n + 3]
690 if ax.firsttime:
692 if ax.firsttime:
691 ax.plt = ax.pcolormesh(x, y, phase.T,
693 ax.plt = ax.pcolormesh(x, y, phase.T,
692 vmin=-180,
694 vmin=-180,
693 vmax=180,
695 vmax=180,
694 cmap=plt.get_cmap(self.colormap_phase)
696 cmap=plt.get_cmap(self.colormap_phase)
695 )
697 )
696 else:
698 else:
697 ax.plt.set_array(phase.T.ravel())
699 ax.plt.set_array(phase.T.ravel())
698 self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1]))
700 self.titles.append('Phase CH{} * CH{}'.format(pair[0], pair[1]))
699
701
700 self.saveTime = self.max_time
702 self.saveTime = self.max_time
701
703
702
704
703 class PlotSpectraMeanData(PlotSpectraData):
705 class PlotSpectraMeanData(PlotSpectraData):
704 '''
706 '''
705 Plot for Spectra and Mean
707 Plot for Spectra and Mean
706 '''
708 '''
707 CODE = 'spc_mean'
709 CODE = 'spc_mean'
708 colormap = 'jro'
710 colormap = 'jro'
709
711
710
712
711 class PlotRTIData(PlotData):
713 class PlotRTIData(PlotData):
712 '''
714 '''
713 Plot for RTI data
715 Plot for RTI data
714 '''
716 '''
715
717
716 CODE = 'rti'
718 CODE = 'rti'
717 colormap = 'jro'
719 colormap = 'jro'
718
720
719 def setup(self):
721 def setup(self):
720 self.xaxis = 'time'
722 self.xaxis = 'time'
721 self.ncols = 1
723 self.ncols = 1
722 self.nrows = len(self.data.channels)
724 self.nrows = len(self.data.channels)
723 self.nplots = len(self.data.channels)
725 self.nplots = len(self.data.channels)
724 self.ylabel = 'Range [km]'
726 self.ylabel = 'Range [km]'
725 self.cb_label = 'dB'
727 self.cb_label = 'dB'
726 self.titles = ['{} Channel {}'.format(
728 self.titles = ['{} Channel {}'.format(
727 self.CODE.upper(), x) for x in range(self.nrows)]
729 self.CODE.upper(), x) for x in range(self.nrows)]
728
730
729 def plot(self):
731 def plot(self):
730 self.x = self.times
732 self.x = self.times
731 self.y = self.data.heights
733 self.y = self.data.heights
732 self.z = self.data[self.CODE]
734 self.z = self.data[self.CODE]
733 self.z = numpy.ma.masked_invalid(self.z)
735 self.z = numpy.ma.masked_invalid(self.z)
734
736
735 if self.decimation is None:
737 if self.decimation is None:
736 x, y, z = self.fill_gaps(self.x, self.y, self.z)
738 x, y, z = self.fill_gaps(self.x, self.y, self.z)
737 else:
739 else:
738 x, y, z = self.fill_gaps(*self.decimate())
740 x, y, z = self.fill_gaps(*self.decimate())
739
741
740 for n, ax in enumerate(self.axes):
742 for n, ax in enumerate(self.axes):
741 self.zmin = self.zmin if self.zmin else numpy.min(self.z)
743 self.zmin = self.zmin if self.zmin else numpy.min(self.z)
742 self.zmax = self.zmax if self.zmax else numpy.max(self.z)
744 self.zmax = self.zmax if self.zmax else numpy.max(self.z)
743 if ax.firsttime:
745 if ax.firsttime:
744 ax.plt = ax.pcolormesh(x, y, z[n].T,
746 ax.plt = ax.pcolormesh(x, y, z[n].T,
745 vmin=self.zmin,
747 vmin=self.zmin,
746 vmax=self.zmax,
748 vmax=self.zmax,
747 cmap=plt.get_cmap(self.colormap)
749 cmap=plt.get_cmap(self.colormap)
748 )
750 )
749 if self.showprofile:
751 if self.showprofile:
750 ax.plot_profile = self.pf_axes[n].plot(
752 ax.plot_profile = self.pf_axes[n].plot(
751 self.data['rti'][n][-1], self.y)[0]
753 self.data['rti'][n][-1], self.y)[0]
752 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y,
754 ax.plot_noise = self.pf_axes[n].plot(numpy.repeat(self.data['noise'][n][-1], len(self.y)), self.y,
753 color="k", linestyle="dashed", lw=1)[0]
755 color="k", linestyle="dashed", lw=1)[0]
754 else:
756 else:
755 ax.collections.remove(ax.collections[0])
757 ax.collections.remove(ax.collections[0])
756 ax.plt = ax.pcolormesh(x, y, z[n].T,
758 ax.plt = ax.pcolormesh(x, y, z[n].T,
757 vmin=self.zmin,
759 vmin=self.zmin,
758 vmax=self.zmax,
760 vmax=self.zmax,
759 cmap=plt.get_cmap(self.colormap)
761 cmap=plt.get_cmap(self.colormap)
760 )
762 )
761 if self.showprofile:
763 if self.showprofile:
762 ax.plot_profile.set_data(self.data['rti'][n][-1], self.y)
764 ax.plot_profile.set_data(self.data['rti'][n][-1], self.y)
763 ax.plot_noise.set_data(numpy.repeat(
765 ax.plot_noise.set_data(numpy.repeat(
764 self.data['noise'][n][-1], len(self.y)), self.y)
766 self.data['noise'][n][-1], len(self.y)), self.y)
765
767
766 self.saveTime = self.min_time
768 self.saveTime = self.min_time
767
769
768
770
769 class PlotCOHData(PlotRTIData):
771 class PlotCOHData(PlotRTIData):
770 '''
772 '''
771 Plot for Coherence data
773 Plot for Coherence data
772 '''
774 '''
773
775
774 CODE = 'coh'
776 CODE = 'coh'
775
777
776 def setup(self):
778 def setup(self):
777 self.xaxis = 'time'
779 self.xaxis = 'time'
778 self.ncols = 1
780 self.ncols = 1
779 self.nrows = len(self.data.pairs)
781 self.nrows = len(self.data.pairs)
780 self.nplots = len(self.data.pairs)
782 self.nplots = len(self.data.pairs)
781 self.ylabel = 'Range [km]'
783 self.ylabel = 'Range [km]'
782 if self.CODE == 'coh':
784 if self.CODE == 'coh':
783 self.cb_label = ''
785 self.cb_label = ''
784 self.titles = [
786 self.titles = [
785 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
787 'Coherence Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
786 else:
788 else:
787 self.cb_label = 'Degrees'
789 self.cb_label = 'Degrees'
788 self.titles = [
790 self.titles = [
789 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
791 'Phase Map Ch{} * Ch{}'.format(x[0], x[1]) for x in self.data.pairs]
790
792
791
793
792 class PlotPHASEData(PlotCOHData):
794 class PlotPHASEData(PlotCOHData):
793 '''
795 '''
794 Plot for Phase map data
796 Plot for Phase map data
795 '''
797 '''
796
798
797 CODE = 'phase'
799 CODE = 'phase'
798 colormap = 'seismic'
800 colormap = 'seismic'
799
801
800
802
801 class PlotNoiseData(PlotData):
803 class PlotNoiseData(PlotData):
802 '''
804 '''
803 Plot for noise
805 Plot for noise
804 '''
806 '''
805
807
806 CODE = 'noise'
808 CODE = 'noise'
807
809
808 def setup(self):
810 def setup(self):
809 self.xaxis = 'time'
811 self.xaxis = 'time'
810 self.ncols = 1
812 self.ncols = 1
811 self.nrows = 1
813 self.nrows = 1
812 self.nplots = 1
814 self.nplots = 1
813 self.ylabel = 'Intensity [dB]'
815 self.ylabel = 'Intensity [dB]'
814 self.titles = ['Noise']
816 self.titles = ['Noise']
815 self.colorbar = False
817 self.colorbar = False
816
818
817 def plot(self):
819 def plot(self):
818
820
819 x = self.times
821 x = self.times
820 xmin = self.min_time
822 xmin = self.min_time
821 xmax = xmin + self.xrange * 60 * 60
823 xmax = xmin + self.xrange * 60 * 60
822 Y = self.data[self.CODE]
824 Y = self.data[self.CODE]
823
825
824 if self.axes[0].firsttime:
826 if self.axes[0].firsttime:
825 for ch in self.data.channels:
827 for ch in self.data.channels:
826 y = Y[ch]
828 y = Y[ch]
827 self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch))
829 self.axes[0].plot(x, y, lw=1, label='Ch{}'.format(ch))
828 plt.legend()
830 plt.legend()
829 else:
831 else:
830 for ch in self.data.channels:
832 for ch in self.data.channels:
831 y = Y[ch]
833 y = Y[ch]
832 self.axes[0].lines[ch].set_data(x, y)
834 self.axes[0].lines[ch].set_data(x, y)
833
835
834 self.ymin = numpy.nanmin(Y) - 5
836 self.ymin = numpy.nanmin(Y) - 5
835 self.ymax = numpy.nanmax(Y) + 5
837 self.ymax = numpy.nanmax(Y) + 5
836 self.saveTime = self.min_time
838 self.saveTime = self.min_time
837
839
838
840
839 class PlotSNRData(PlotRTIData):
841 class PlotSNRData(PlotRTIData):
840 '''
842 '''
841 Plot for SNR Data
843 Plot for SNR Data
842 '''
844 '''
843
845
844 CODE = 'snr'
846 CODE = 'snr'
845 colormap = 'jet'
847 colormap = 'jet'
846
848
847
849
848 class PlotDOPData(PlotRTIData):
850 class PlotDOPData(PlotRTIData):
849 '''
851 '''
850 Plot for DOPPLER Data
852 Plot for DOPPLER Data
851 '''
853 '''
852
854
853 CODE = 'dop'
855 CODE = 'dop'
854 colormap = 'jet'
856 colormap = 'jet'
855
857
856
858
857 class PlotSkyMapData(PlotData):
859 class PlotSkyMapData(PlotData):
858 '''
860 '''
859 Plot for meteors detection data
861 Plot for meteors detection data
860 '''
862 '''
861
863
862 CODE = 'param'
864 CODE = 'param'
863
865
864 def setup(self):
866 def setup(self):
865
867
866 self.ncols = 1
868 self.ncols = 1
867 self.nrows = 1
869 self.nrows = 1
868 self.width = 7.2
870 self.width = 7.2
869 self.height = 7.2
871 self.height = 7.2
870 self.nplots = 1
872 self.nplots = 1
871 self.xlabel = 'Zonal Zenith Angle (deg)'
873 self.xlabel = 'Zonal Zenith Angle (deg)'
872 self.ylabel = 'Meridional Zenith Angle (deg)'
874 self.ylabel = 'Meridional Zenith Angle (deg)'
873 self.polar = True
875 self.polar = True
874 self.ymin = -180
876 self.ymin = -180
875 self.ymax = 180
877 self.ymax = 180
876 self.colorbar = False
878 self.colorbar = False
877
879
878 def plot(self):
880 def plot(self):
879
881
880 arrayParameters = numpy.concatenate(self.data['param'])
882 arrayParameters = numpy.concatenate(self.data['param'])
881 error = arrayParameters[:, -1]
883 error = arrayParameters[:, -1]
882 indValid = numpy.where(error == 0)[0]
884 indValid = numpy.where(error == 0)[0]
883 finalMeteor = arrayParameters[indValid, :]
885 finalMeteor = arrayParameters[indValid, :]
884 finalAzimuth = finalMeteor[:, 3]
886 finalAzimuth = finalMeteor[:, 3]
885 finalZenith = finalMeteor[:, 4]
887 finalZenith = finalMeteor[:, 4]
886
888
887 x = finalAzimuth * numpy.pi / 180
889 x = finalAzimuth * numpy.pi / 180
888 y = finalZenith
890 y = finalZenith
889
891
890 ax = self.axes[0]
892 ax = self.axes[0]
891
893
892 if ax.firsttime:
894 if ax.firsttime:
893 ax.plot = ax.plot(x, y, 'bo', markersize=5)[0]
895 ax.plot = ax.plot(x, y, 'bo', markersize=5)[0]
894 else:
896 else:
895 ax.plot.set_data(x, y)
897 ax.plot.set_data(x, y)
896
898
897 dt1 = self.getDateTime(self.min_time).strftime('%y/%m/%d %H:%M:%S')
899 dt1 = self.getDateTime(self.min_time).strftime('%y/%m/%d %H:%M:%S')
898 dt2 = self.getDateTime(self.max_time).strftime('%y/%m/%d %H:%M:%S')
900 dt2 = self.getDateTime(self.max_time).strftime('%y/%m/%d %H:%M:%S')
899 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
901 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
900 dt2,
902 dt2,
901 len(x))
903 len(x))
902 self.titles[0] = title
904 self.titles[0] = title
903 self.saveTime = self.max_time
905 self.saveTime = self.max_time
904
906
905
907
906 class PlotParamData(PlotRTIData):
908 class PlotParamData(PlotRTIData):
907 '''
909 '''
908 Plot for data_param object
910 Plot for data_param object
909 '''
911 '''
910
912
911 CODE = 'param'
913 CODE = 'param'
912 colormap = 'seismic'
914 colormap = 'seismic'
913
915
914 def setup(self):
916 def setup(self):
915 self.xaxis = 'time'
917 self.xaxis = 'time'
916 self.ncols = 1
918 self.ncols = 1
917 self.nrows = self.data.shape(self.CODE)[0]
919 self.nrows = self.data.shape(self.CODE)[0]
918 self.nplots = self.nrows
920 self.nplots = self.nrows
919 if self.showSNR:
921 if self.showSNR:
920 self.nrows += 1
922 self.nrows += 1
921 self.nplots += 1
923 self.nplots += 1
922
924
923 self.ylabel = 'Height [km]'
925 self.ylabel = 'Height [km]'
924 if not self.titles:
926 if not self.titles:
925 self.titles = self.data.parameters \
927 self.titles = self.data.parameters \
926 if self.data.parameters else ['Param {}'.format(x) for x in xrange(self.nrows)]
928 if self.data.parameters else ['Param {}'.format(x) for x in xrange(self.nrows)]
927 if self.showSNR:
929 if self.showSNR:
928 self.titles.append('SNR')
930 self.titles.append('SNR')
929
931
930 def plot(self):
932 def plot(self):
931 self.data.normalize_heights()
933 self.data.normalize_heights()
932 self.x = self.times
934 self.x = self.times
933 self.y = self.data.heights
935 self.y = self.data.heights
934 if self.showSNR:
936 if self.showSNR:
935 self.z = numpy.concatenate(
937 self.z = numpy.concatenate(
936 (self.data[self.CODE], self.data['snr'])
938 (self.data[self.CODE], self.data['snr'])
937 )
939 )
938 else:
940 else:
939 self.z = self.data[self.CODE]
941 self.z = self.data[self.CODE]
940
942
941 self.z = numpy.ma.masked_invalid(self.z)
943 self.z = numpy.ma.masked_invalid(self.z)
942
944
943 if self.decimation is None:
945 if self.decimation is None:
944 x, y, z = self.fill_gaps(self.x, self.y, self.z)
946 x, y, z = self.fill_gaps(self.x, self.y, self.z)
945 else:
947 else:
946 x, y, z = self.fill_gaps(*self.decimate())
948 x, y, z = self.fill_gaps(*self.decimate())
947
949
948 for n, ax in enumerate(self.axes):
950 for n, ax in enumerate(self.axes):
949
951
950 self.zmax = self.zmax if self.zmax is not None else numpy.max(
952 self.zmax = self.zmax if self.zmax is not None else numpy.max(
951 self.z[n])
953 self.z[n])
952 self.zmin = self.zmin if self.zmin is not None else numpy.min(
954 self.zmin = self.zmin if self.zmin is not None else numpy.min(
953 self.z[n])
955 self.z[n])
954
956
955 if ax.firsttime:
957 if ax.firsttime:
956 if self.zlimits is not None:
958 if self.zlimits is not None:
957 self.zmin, self.zmax = self.zlimits[n]
959 self.zmin, self.zmax = self.zlimits[n]
958
960
959 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
961 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
960 vmin=self.zmin,
962 vmin=self.zmin,
961 vmax=self.zmax,
963 vmax=self.zmax,
962 cmap=self.cmaps[n]
964 cmap=self.cmaps[n]
963 )
965 )
964 else:
966 else:
965 if self.zlimits is not None:
967 if self.zlimits is not None:
966 self.zmin, self.zmax = self.zlimits[n]
968 self.zmin, self.zmax = self.zlimits[n]
967 ax.collections.remove(ax.collections[0])
969 ax.collections.remove(ax.collections[0])
968 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
970 ax.plt = ax.pcolormesh(x, y, z[n].T * self.factors[n],
969 vmin=self.zmin,
971 vmin=self.zmin,
970 vmax=self.zmax,
972 vmax=self.zmax,
971 cmap=self.cmaps[n]
973 cmap=self.cmaps[n]
972 )
974 )
973
975
974 self.saveTime = self.min_time
976 self.saveTime = self.min_time
975
977
976
978
977 class PlotOutputData(PlotParamData):
979 class PlotOutputData(PlotParamData):
978 '''
980 '''
979 Plot data_output object
981 Plot data_output object
980 '''
982 '''
981
983
982 CODE = 'output'
984 CODE = 'output'
983 colormap = 'seismic'
985 colormap = 'seismic'
984
986
985
987
986 class PlotPolarMapData(PlotData):
988 class PlotPolarMapData(PlotData):
987 '''
989 '''
988 Plot for meteors detection data
990 Plot for meteors detection data
989 '''
991 '''
990
992
991 CODE = 'param'
993 CODE = 'param'
992 colormap = 'seismic'
994 colormap = 'seismic'
993
995
994 def setup(self):
996 def setup(self):
995 self.ncols = 1
997 self.ncols = 1
996 self.nrows = 1
998 self.nrows = 1
997 self.width = 9
999 self.width = 9
998 self.height = 8
1000 self.height = 8
999 if self.channels is not None:
1001 if self.channels is not None:
1000 self.nplots = len(self.channels)
1002 self.nplots = len(self.channels)
1001 self.nrows = len(self.channels)
1003 self.nrows = len(self.channels)
1002 else:
1004 else:
1003 self.nplots = self.data.shape(self.CODE)[0]
1005 self.nplots = self.data.shape(self.CODE)[0]
1004 self.nrows = self.nplots
1006 self.nrows = self.nplots
1005 self.channels = range(self.nplots)
1007 self.channels = range(self.nplots)
1008 if self.data.meta['mode'] == 'E':
1006 self.xlabel = 'Zonal Distance (km)'
1009 self.xlabel = 'Zonal Distance (km)'
1007 self.ylabel = 'Meridional Distance (km)'
1010 self.ylabel = 'Meridional Distance (km)'
1011 else:
1012 self.xlabel = 'Range (km)'
1013 self.ylabel = 'Height (km)'
1008 self.bgcolor = 'white'
1014 self.bgcolor = 'white'
1015 self.cb_labels = self.data.meta['units']
1016 # self.polar = True
1009
1017
1010 def plot(self):
1018 def plot(self):
1011
1019
1012 for n, ax in enumerate(self.axes):
1020 for n, ax in enumerate(self.axes):
1013 data = self.data['param'][self.channels[n]]
1021 data = self.data['param'][self.channels[n]]
1014
1022
1015 zeniths = numpy.arange(data.shape[1])
1023 zeniths = numpy.linspace(0, self.data.meta['max_range'], data.shape[1])
1024 if self.data.meta['mode'] == 'E':
1016 azimuths = -numpy.radians(self.data.heights)+numpy.pi/2
1025 azimuths = -numpy.radians(self.data.heights)+numpy.pi/2
1017 self.y = zeniths
1026 r, theta = numpy.meshgrid(zeniths, azimuths)
1018
1027 x, y = r*numpy.cos(theta)*numpy.cos(numpy.radians(self.data.meta['elevation'])), r*numpy.sin(theta)*numpy.cos(numpy.radians(self.data.meta['elevation']))
1028 else:
1029 azimuths = numpy.radians(self.data.heights)
1019 r, theta = numpy.meshgrid(zeniths, azimuths)
1030 r, theta = numpy.meshgrid(zeniths, azimuths)
1020 x, y = r*numpy.cos(theta), r*numpy.sin(theta)
1031 x, y = r*numpy.cos(theta), r*numpy.sin(theta)
1032 self.y = zeniths
1021
1033
1022 if ax.firsttime:
1034 if ax.firsttime:
1023 if self.zlimits is not None:
1035 if self.zlimits is not None:
1024 self.zmin, self.zmax = self.zlimits[n]
1036 self.zmin, self.zmax = self.zlimits[n]
1025 ax.plt = ax.pcolormesh(x, y, numpy.ma.array(data, mask=numpy.isnan(data)),
1037 ax.plt = ax.pcolormesh(#r, theta, numpy.ma.array(data, mask=numpy.isnan(data)),
1038 x, y, numpy.ma.array(data, mask=numpy.isnan(data)),
1026 vmin=self.zmin,
1039 vmin=self.zmin,
1027 vmax=self.zmax,
1040 vmax=self.zmax,
1028 cmap=self.cmaps[n])
1041 cmap=self.cmaps[n])
1029 else:
1042 else:
1030 if self.zlimits is not None:
1043 if self.zlimits is not None:
1031 self.zmin, self.zmax = self.zlimits[n]
1044 self.zmin, self.zmax = self.zlimits[n]
1032 ax.collections.remove(ax.collections[0])
1045 ax.collections.remove(ax.collections[0])
1033 ax.plt = ax.pcolormesh(x, y, numpy.ma.array(data, mask=numpy.isnan(data)),
1046 ax.plt = ax.pcolormesh(# r, theta, numpy.ma.array(data, mask=numpy.isnan(data)),
1047 x, y, numpy.ma.array(data, mask=numpy.isnan(data)),
1034 vmin=self.zmin,
1048 vmin=self.zmin,
1035 vmax=self.zmax,
1049 vmax=self.zmax,
1036 cmap=self.cmaps[n])
1050 cmap=self.cmaps[n])
1037
1051
1052 if self.data.meta['mode'] == 'A':
1053 continue
1054 '''
1055 f = open('/data/workspace/schain_scripts/map_lima.csv')
1056
1057 lat1 = -11.96
1058 lon1 = -76.54
1059
1060 for line in f:
1061 label, x, y = [s.strip() for s in line.split(',') if s]
1062 lat2 = float(y)
1063 lon2 = float(x)
1064
1065 dx = (lon2-lon1)*40000*numpy.cos((lat1+lat2)*numpy.pi/360)/360
1066 dy = (lat1-lat2)*40000/360
1067 print label, dx, dy
1068 if label == 'map':
1069 print 'SDHSDHSDHSGHSDFHSDF'
1070 ax.plot([dx], [dy],'--k')
1071 else:
1072 ax.plot([dx], [dy],'.b', ms=2)
1073 '''
1074 if self.data.meta['mode'] == 'E':
1075 title = 'El={}$^\circ$'.format(self.data.meta['elevation'])
1076 label = 'E{:d}'.format(int(self.data.meta['elevation']))
1077 else:
1078 title = 'Az={}$^\circ$'.format(self.data.meta['azimuth'])
1079 label = 'A{:d}'.format(int(self.data.meta['azimuth']))
1038
1080
1039 title = ''
1081 self.save_labels = ['{}-{}'.format(lbl, label) for lbl in self.labels]
1040
1082 self.titles = ['{} {}'.format(self.data.parameters[x], title) for x in self.channels]
1041 self.titles = [self.data.parameters[x] for x in self.channels]
1042 self.saveTime = self.max_time
1083 self.saveTime = self.max_time
1084
1085
General Comments 0
You need to be logged in to leave comments. Login now