@@ -20,9 +20,7 blu_values = matplotlib.pyplot.get_cmap("seismic_r", 20)(numpy.arange(20))[10:15 | |||||
20 | ncmap = matplotlib.colors.LinearSegmentedColormap.from_list("jro", numpy.vstack((blu_values, jet_values))) |
|
20 | ncmap = matplotlib.colors.LinearSegmentedColormap.from_list("jro", numpy.vstack((blu_values, jet_values))) | |
21 | matplotlib.pyplot.register_cmap(cmap=ncmap) |
|
21 | matplotlib.pyplot.register_cmap(cmap=ncmap) | |
22 |
|
22 | |||
23 | func = lambda x, pos: '{}'.format(datetime.datetime.fromtimestamp(x).strftime('%H:%M')) |
|
23 | func = lambda x, pos: '{}'.format(datetime.datetime.utcfromtimestamp(x).strftime('%H:%M')) | |
24 |
|
||||
25 | UT1970 = datetime.datetime(1970, 1, 1) - datetime.timedelta(seconds=time.timezone) |
|
|||
26 |
|
24 | |||
27 | CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'RdBu_r', 'seismic')] |
|
25 | CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'RdBu_r', 'seismic')] | |
28 |
|
26 | |||
@@ -113,6 +111,7 class PlotData(Operation, Process): | |||||
113 | ax.tick_params(labelsize=8) |
|
111 | ax.tick_params(labelsize=8) | |
114 | ax.firsttime = True |
|
112 | ax.firsttime = True | |
115 | ax.index = 0 |
|
113 | ax.index = 0 | |
|
114 | ax.press = None | |||
116 | self.axes.append(ax) |
|
115 | self.axes.append(ax) | |
117 | if self.showprofile: |
|
116 | if self.showprofile: | |
118 | cax = self.__add_axes(ax, size=size, pad=pad) |
|
117 | cax = self.__add_axes(ax, size=size, pad=pad) | |
@@ -129,6 +128,7 class PlotData(Operation, Process): | |||||
129 | ax.tick_params(labelsize=8) |
|
128 | ax.tick_params(labelsize=8) | |
130 | ax.firsttime = True |
|
129 | ax.firsttime = True | |
131 | ax.index = 0 |
|
130 | ax.index = 0 | |
|
131 | ax.press = None | |||
132 | self.figures.append(fig) |
|
132 | self.figures.append(fig) | |
133 | self.axes.append(ax) |
|
133 | self.axes.append(ax) | |
134 | if self.showprofile: |
|
134 | if self.showprofile: | |
@@ -145,14 +145,18 class PlotData(Operation, Process): | |||||
145 | self.cmaps.append(cmap) |
|
145 | self.cmaps.append(cmap) | |
146 |
|
146 | |||
147 | for fig in self.figures: |
|
147 | for fig in self.figures: | |
148 |
fig.canvas.mpl_connect('key_press_event', self. |
|
148 | fig.canvas.mpl_connect('key_press_event', self.OnKeyPress) | |
|
149 | fig.canvas.mpl_connect('scroll_event', self.OnBtnScroll) | |||
|
150 | fig.canvas.mpl_connect('button_press_event', self.onBtnPress) | |||
|
151 | fig.canvas.mpl_connect('motion_notify_event', self.onMotion) | |||
|
152 | fig.canvas.mpl_connect('button_release_event', self.onBtnRelease) | |||
149 |
|
153 | |||
150 |
def |
|
154 | def OnKeyPress(self, event): | |
151 | ''' |
|
155 | ''' | |
|
156 | Event for pressing keys (up, down) change colormap | |||
152 | ''' |
|
157 | ''' | |
153 |
|
158 | ax = event.inaxes | ||
154 |
f |
|
159 | if ax in self.axes: | |
155 | if ax == event.inaxes: |
|
|||
156 |
|
|
160 | if event.key == 'down': | |
157 |
|
|
161 | ax.index += 1 | |
158 |
|
|
162 | elif event.key == 'up': | |
@@ -167,6 +171,76 class PlotData(Operation, Process): | |||||
167 |
|
|
171 | ax.plt.set_cmap(cmap) | |
168 |
|
|
172 | ax.cbar.patch.figure.canvas.draw() | |
169 |
|
173 | |||
|
174 | def OnBtnScroll(self, event): | |||
|
175 | ''' | |||
|
176 | Event for scrolling, scale figure | |||
|
177 | ''' | |||
|
178 | cb_ax = event.inaxes | |||
|
179 | if cb_ax in [ax.cbar.ax for ax in self.axes]: | |||
|
180 | ax = [ax for ax in self.axes if cb_ax == ax.cbar.ax][0] | |||
|
181 | pt = ax.cbar.ax.bbox.get_points()[:,1] | |||
|
182 | nrm = ax.cbar.norm | |||
|
183 | vmin, vmax, p0, p1, pS = (nrm.vmin, nrm.vmax, pt[0], pt[1], event.y) | |||
|
184 | scale = 2 if event.step == 1 else 0.5 | |||
|
185 | point = vmin + (vmax - vmin) / (p1 - p0)*(pS - p0) | |||
|
186 | ax.cbar.norm.vmin = point - scale*(point - vmin) | |||
|
187 | ax.cbar.norm.vmax = point - scale*(point - vmax) | |||
|
188 | ax.plt.set_norm(ax.cbar.norm) | |||
|
189 | ax.cbar.draw_all() | |||
|
190 | ax.cbar.patch.figure.canvas.draw() | |||
|
191 | ||||
|
192 | def onBtnPress(self, event): | |||
|
193 | ''' | |||
|
194 | Event for mouse button press | |||
|
195 | ''' | |||
|
196 | cb_ax = event.inaxes | |||
|
197 | if cb_ax is None: | |||
|
198 | return | |||
|
199 | ||||
|
200 | if cb_ax in [ax.cbar.ax for ax in self.axes]: | |||
|
201 | cb_ax.press = event.x, event.y | |||
|
202 | else: | |||
|
203 | cb_ax.press = None | |||
|
204 | ||||
|
205 | def onMotion(self, event): | |||
|
206 | ''' | |||
|
207 | Event for move inside colorbar | |||
|
208 | ''' | |||
|
209 | cb_ax = event.inaxes | |||
|
210 | if cb_ax is None: | |||
|
211 | return | |||
|
212 | if cb_ax not in [ax.cbar.ax for ax in self.axes]: | |||
|
213 | return | |||
|
214 | if cb_ax.press is None: | |||
|
215 | return | |||
|
216 | ||||
|
217 | ax = [ax for ax in self.axes if cb_ax == ax.cbar.ax][0] | |||
|
218 | xprev, yprev = cb_ax.press | |||
|
219 | dx = event.x - xprev | |||
|
220 | dy = event.y - yprev | |||
|
221 | cb_ax.press = event.x, event.y | |||
|
222 | scale = ax.cbar.norm.vmax - ax.cbar.norm.vmin | |||
|
223 | perc = 0.03 | |||
|
224 | ||||
|
225 | if event.button == 1: | |||
|
226 | ax.cbar.norm.vmin -= (perc*scale)*numpy.sign(dy) | |||
|
227 | ax.cbar.norm.vmax -= (perc*scale)*numpy.sign(dy) | |||
|
228 | elif event.button == 3: | |||
|
229 | ax.cbar.norm.vmin -= (perc*scale)*numpy.sign(dy) | |||
|
230 | ax.cbar.norm.vmax += (perc*scale)*numpy.sign(dy) | |||
|
231 | ||||
|
232 | ax.cbar.draw_all() | |||
|
233 | ax.plt.set_norm(ax.cbar.norm) | |||
|
234 | ax.cbar.patch.figure.canvas.draw() | |||
|
235 | ||||
|
236 | def onBtnRelease(self, event): | |||
|
237 | ''' | |||
|
238 | Event for mouse button release | |||
|
239 | ''' | |||
|
240 | cb_ax = event.inaxes | |||
|
241 | if cb_ax is not None: | |||
|
242 | cb_ax.press = None | |||
|
243 | ||||
170 | def __add_axes(self, ax, size='30%', pad='8%'): |
|
244 | def __add_axes(self, ax, size='30%', pad='8%'): | |
171 | ''' |
|
245 | ''' | |
172 | Add new axes to the given figure |
|
246 | Add new axes to the given figure | |
@@ -233,9 +307,8 class PlotData(Operation, Process): | |||||
233 | xmin = self.min_time |
|
307 | xmin = self.min_time | |
234 | else: |
|
308 | else: | |
235 | if self.xaxis is 'time': |
|
309 | if self.xaxis is 'time': | |
236 | dt = datetime.datetime.fromtimestamp(self.min_time) |
|
310 | dt = datetime.datetime.utcfromtimestamp(self.min_time) | |
237 | xmin = (datetime.datetime.combine(dt.date(), |
|
311 | xmin = (dt.replace(hour=int(self.xmin), minute=0, second=0) - datetime.datetime(1970, 1, 1)).total_seconds() | |
238 | datetime.time(int(self.xmin), 0, 0))-UT1970).total_seconds() |
|
|||
239 | else: |
|
312 | else: | |
240 | xmin = self.xmin |
|
313 | xmin = self.xmin | |
241 |
|
314 | |||
@@ -243,16 +316,17 class PlotData(Operation, Process): | |||||
243 | xmax = xmin+self.xrange*60*60 |
|
316 | xmax = xmin+self.xrange*60*60 | |
244 | else: |
|
317 | else: | |
245 | if self.xaxis is 'time': |
|
318 | if self.xaxis is 'time': | |
246 | dt = datetime.datetime.fromtimestamp(self.min_time) |
|
319 | dt = datetime.datetime.utcfromtimestamp(self.min_time) | |
247 | xmax = (datetime.datetime.combine(dt.date(), |
|
320 | xmax = (dt.replace(hour=int(self.xmax), minute=0, second=0) - datetime.datetime(1970, 1, 1)).total_seconds() | |
248 | datetime.time(int(self.xmax), 0, 0))-UT1970).total_seconds() |
|
|||
249 | else: |
|
321 | else: | |
250 | xmax = self.xmax |
|
322 | xmax = self.xmax | |
251 |
|
323 | |||
252 | ymin = self.ymin if self.ymin else numpy.nanmin(self.y) |
|
324 | ymin = self.ymin if self.ymin else numpy.nanmin(self.y) | |
253 | ymax = self.ymax if self.ymax else numpy.nanmax(self.y) |
|
325 | ymax = self.ymax if self.ymax else numpy.nanmax(self.y) | |
254 |
|
326 | |||
255 | ystep = 200 if ymax>= 800 else 100 if ymax>=400 else 50 if ymax>=200 else 20 |
|
327 | Y = numpy.array([10, 20, 50, 100, 200, 500, 1000, 2000]) | |
|
328 | i = 1 if numpy.where(ymax < Y)[0][0] < 0 else numpy.where(ymax < Y)[0][0] | |||
|
329 | ystep = Y[i-1]/5 | |||
256 |
|
330 | |||
257 | for n, ax in enumerate(self.axes): |
|
331 | for n, ax in enumerate(self.axes): | |
258 | if ax.firsttime: |
|
332 | if ax.firsttime: | |
@@ -274,6 +348,7 class PlotData(Operation, Process): | |||||
274 | if self.colorbar: |
|
348 | if self.colorbar: | |
275 | ax.cbar = plt.colorbar(ax.plt, ax=ax, pad=0.02, aspect=10) |
|
349 | ax.cbar = plt.colorbar(ax.plt, ax=ax, pad=0.02, aspect=10) | |
276 | ax.cbar.ax.tick_params(labelsize=8) |
|
350 | ax.cbar.ax.tick_params(labelsize=8) | |
|
351 | ax.cbar.ax.press = None | |||
277 | if self.cb_label: |
|
352 | if self.cb_label: | |
278 | ax.cbar.set_label(self.cb_label, size=8) |
|
353 | ax.cbar.set_label(self.cb_label, size=8) | |
279 | elif self.cb_labels: |
|
354 | elif self.cb_labels: | |
@@ -281,7 +356,7 class PlotData(Operation, Process): | |||||
281 |
|
356 | |||
282 | ax.set_title('{} - {} {}'.format( |
|
357 | ax.set_title('{} - {} {}'.format( | |
283 | self.titles[n], |
|
358 | self.titles[n], | |
284 | datetime.datetime.fromtimestamp(self.max_time).strftime('%H:%M:%S'), |
|
359 | datetime.datetime.utcfromtimestamp(self.max_time).strftime('%H:%M:%S'), | |
285 | self.time_label), |
|
360 | self.time_label), | |
286 | size=8) |
|
361 | size=8) | |
287 | ax.set_xlim(xmin, xmax) |
|
362 | ax.set_xlim(xmin, xmax) | |
@@ -304,7 +379,7 class PlotData(Operation, Process): | |||||
304 |
|
379 | |||
305 | fig.tight_layout() |
|
380 | fig.tight_layout() | |
306 | fig.canvas.manager.set_window_title('{} - {}'.format(self.title, |
|
381 | fig.canvas.manager.set_window_title('{} - {}'.format(self.title, | |
307 | datetime.datetime.fromtimestamp(self.max_time).strftime('%Y/%m/%d'))) |
|
382 | datetime.datetime.utcfromtimestamp(self.max_time).strftime('%Y/%m/%d'))) | |
308 | # fig.canvas.draw() |
|
383 | # fig.canvas.draw() | |
309 |
|
384 | |||
310 | if self.save and self.data.ended: |
|
385 | if self.save and self.data.ended: | |
@@ -318,7 +393,7 class PlotData(Operation, Process): | |||||
318 | '{}{}_{}.png'.format( |
|
393 | '{}{}_{}.png'.format( | |
319 | self.CODE, |
|
394 | self.CODE, | |
320 | label, |
|
395 | label, | |
321 | datetime.datetime.fromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S') |
|
396 | datetime.datetime.utcfromtimestamp(self.saveTime).strftime('%y%m%d_%H%M%S') | |
322 | ) |
|
397 | ) | |
323 | ) |
|
398 | ) | |
324 | print 'Saving figure: {}'.format(figname) |
|
399 | print 'Saving figure: {}'.format(figname) | |
@@ -739,8 +814,8 class PlotSkyMapData(PlotData): | |||||
739 | self.ax.plot.set_data(x, y) |
|
814 | self.ax.plot.set_data(x, y) | |
740 |
|
815 | |||
741 |
|
816 | |||
742 | dt1 = datetime.datetime.fromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S') |
|
817 | dt1 = datetime.datetime.utcfromtimestamp(self.min_time).strftime('%y/%m/%d %H:%M:%S') | |
743 | dt2 = datetime.datetime.fromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S') |
|
818 | dt2 = datetime.datetime.utcfromtimestamp(self.max_time).strftime('%y/%m/%d %H:%M:%S') | |
744 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, |
|
819 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, | |
745 | dt2, |
|
820 | dt2, | |
746 | len(x)) |
|
821 | len(x)) | |
@@ -787,13 +862,14 class PlotParamData(PlotRTIData): | |||||
787 | for n, ax in enumerate(self.axes): |
|
862 | for n, ax in enumerate(self.axes): | |
788 |
|
863 | |||
789 | x, y, z = self.fill_gaps(*self.decimate()) |
|
864 | x, y, z = self.fill_gaps(*self.decimate()) | |
|
865 | self.zmax = self.zmax if self.zmax is not None else numpy.max(self.z[n]) | |||
|
866 | self.zmin = self.zmin if self.zmin is not None else numpy.min(self.z[n]) | |||
790 |
|
867 | |||
791 | if ax.firsttime: |
|
868 | if ax.firsttime: | |
792 | if self.zlimits is not None: |
|
869 | if self.zlimits is not None: | |
793 | self.zmin, self.zmax = self.zlimits[n] |
|
870 | self.zmin, self.zmax = self.zlimits[n] | |
794 | self.zmax = self.zmax if self.zmax is not None else numpy.nanmax(abs(self.z[:-1, :])) |
|
871 | ||
795 | self.zmin = self.zmin if self.zmin is not None else -self.zmax |
|
872 | ax.plt = ax.pcolormesh(x, y, z[n].T*self.factors[n], | |
796 | ax.plt = ax.pcolormesh(x, y, z[n, :, :].T*self.factors[n], |
|
|||
797 | vmin=self.zmin, |
|
873 | vmin=self.zmin, | |
798 | vmax=self.zmax, |
|
874 | vmax=self.zmax, | |
799 | cmap=self.cmaps[n] |
|
875 | cmap=self.cmaps[n] | |
@@ -802,7 +878,7 class PlotParamData(PlotRTIData): | |||||
802 | if self.zlimits is not None: |
|
878 | if self.zlimits is not None: | |
803 | self.zmin, self.zmax = self.zlimits[n] |
|
879 | self.zmin, self.zmax = self.zlimits[n] | |
804 | ax.collections.remove(ax.collections[0]) |
|
880 | ax.collections.remove(ax.collections[0]) | |
805 |
ax.plt = ax.pcolormesh(x, y, z[n |
|
881 | ax.plt = ax.pcolormesh(x, y, z[n].T*self.factors[n], | |
806 | vmin=self.zmin, |
|
882 | vmin=self.zmin, | |
807 | vmax=self.zmax, |
|
883 | vmax=self.zmax, | |
808 | cmap=self.cmaps[n] |
|
884 | cmap=self.cmaps[n] | |
@@ -810,7 +886,7 class PlotParamData(PlotRTIData): | |||||
810 |
|
886 | |||
811 | self.saveTime = self.min_time |
|
887 | self.saveTime = self.min_time | |
812 |
|
888 | |||
813 | class PlotOuputData(PlotParamData): |
|
889 | class PlotOutputData(PlotParamData): | |
814 | ''' |
|
890 | ''' | |
815 | Plot data_output object |
|
891 | Plot data_output object | |
816 | ''' |
|
892 | ''' |
@@ -560,7 +560,7 class PlotterReceiver(ProcessingUnit, Process): | |||||
560 |
|
560 | |||
561 | while True: |
|
561 | while True: | |
562 | dataOut = self.receiver.recv_pyobj() |
|
562 | dataOut = self.receiver.recv_pyobj() | |
563 | dt = datetime.datetime.fromtimestamp(dataOut.utctime).date() |
|
563 | dt = datetime.datetime.utcfromtimestamp(dataOut.utctime).date() | |
564 | sended = False |
|
564 | sended = False | |
565 | if dt not in self.dates: |
|
565 | if dt not in self.dates: | |
566 | if self.data: |
|
566 | if self.data: |
General Comments 0
You need to be logged in to leave comments.
Login now