##// END OF EJS Templates
Fix SkyMapPlot
Juan C. Espinoza -
r1095:c7ed06c70307
parent child
Show More
@@ -15,11 +15,11 from matplotlib.ticker import FuncFormatter, LinearLocator, MultipleLocator
15 15 from schainpy.model.proc.jroproc_base import Operation
16 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 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 21 ncmap = matplotlib.colors.LinearSegmentedColormap.from_list(
22 "jro", numpy.vstack((blu_values, jet_values)))
22 'jro', numpy.vstack((blu_values, jet_values)))
23 23 matplotlib.pyplot.register_cmap(cmap=ncmap)
24 24
25 25 CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'RdBu_r', 'seismic')]
@@ -88,6 +88,7 class PlotData(Operation, Process):
88 88 self.colorbar = kwargs.get('colorbar', True)
89 89 self.factors = kwargs.get('factors', [1, 1, 1, 1, 1, 1, 1, 1])
90 90 self.titles = ['' for __ in range(16)]
91 self.polar = False
91 92
92 93 def __fmtTime(self, x, pos):
93 94 '''
@@ -100,6 +101,10 class PlotData(Operation, Process):
100 101 Common setup for all figures, here figures and axes are created
101 102 '''
102 103
104 if self.CODE not in self.data:
105 raise ValueError(log.error('Missing data for {}'.format(self.CODE),
106 self.name))
107
103 108 self.setup()
104 109
105 110 self.time_label = 'LT' if self.localtime else 'UTC'
@@ -128,7 +133,7 class PlotData(Operation, Process):
128 133 facecolor='w')
129 134 self.figures.append(fig)
130 135 for n in range(self.nplots):
131 ax = fig.add_subplot(self.nrows, self.ncols, n + 1)
136 ax = fig.add_subplot(self.nrows, self.ncols, n + 1, polar=self.polar)
132 137 ax.tick_params(labelsize=8)
133 138 ax.firsttime = True
134 139 ax.index = 0
@@ -145,7 +150,7 class PlotData(Operation, Process):
145 150 fig = plt.figure(figsize=(self.width, self.height),
146 151 edgecolor='k',
147 152 facecolor='w')
148 ax = fig.add_subplot(1, 1, 1)
153 ax = fig.add_subplot(1, 1, 1, polar=self.polar)
149 154 ax.tick_params(labelsize=8)
150 155 ax.firsttime = True
151 156 ax.index = 0
@@ -343,7 +348,7 class PlotData(Operation, Process):
343 348 else:
344 349 if self.xaxis is 'time':
345 350 dt = self.getDateTime(self.max_time)
346 xmax = (dt.replace(hour=int(self.xmax), minute=0, second=0) - datetime.datetime(1970, 1, 1)).total_seconds()
351 xmax = (dt.replace(hour=int(self.xmax), minute=59, second=59) - datetime.datetime(1970, 1, 1)).total_seconds()
347 352 if self.data.localtime:
348 353 xmax += time.timezone
349 354 else:
@@ -356,8 +361,6 class PlotData(Operation, Process):
356 361 i = 1 if numpy.where(ymax < Y)[0][0] < 0 else numpy.where(ymax < Y)[0][0]
357 362 ystep = Y[i-1]/5
358 363
359 ystep = 200 if ymax >= 800 else 100 if ymax >= 400 else 50 if ymax >= 200 else 20
360
361 364 for n, ax in enumerate(self.axes):
362 365 if ax.firsttime:
363 366 ax.set_facecolor(self.bgcolor)
@@ -377,7 +380,7 class PlotData(Operation, Process):
377 380 [tick.set_visible(False)
378 381 for tick in self.pf_axes[n].get_yticklabels()]
379 382 if self.colorbar:
380 ax.cbar = plt.colorbar(ax.plt, ax=ax, pad=0.02, aspect=10)
383 ax.cbar = plt.colorbar(ax.plt, ax=ax, fraction=0.1, pad=0.02, aspect=10)
381 384 ax.cbar.ax.tick_params(labelsize=8)
382 385 ax.cbar.ax.press = None
383 386 if self.cb_label:
@@ -387,13 +390,20 class PlotData(Operation, Process):
387 390 else:
388 391 ax.cbar = None
389 392
393 if not self.polar:
394 ax.set_xlim(xmin, xmax)
395 ax.set_ylim(ymin, ymax)
390 396 ax.set_title('{} - {} {}'.format(
391 397 self.titles[n],
392 398 self.getDateTime(self.max_time).strftime('%H:%M:%S'),
393 399 self.time_label),
394 400 size=8)
395 ax.set_xlim(xmin, xmax)
396 ax.set_ylim(ymin, ymax)
401 else:
402 ax.set_title('{}'.format(self.titles[n]), size=8)
403 ax.set_ylim(0, 90)
404 ax.set_yticks(numpy.arange(0, 90, 20))
405 ax.yaxis.labelpad = 40
406
397 407
398 408 def __plot(self):
399 409 '''
@@ -405,7 +415,7 class PlotData(Operation, Process):
405 415
406 416 for n, fig in enumerate(self.figures):
407 417 if self.nrows == 0 or self.nplots == 0:
408 log.warning('No data', self.name)
418 fig.text(0.5, 0.5, 'No Data', fontsize='large', ha='center')
409 419 continue
410 420
411 421 fig.tight_layout()
@@ -427,7 +437,7 class PlotData(Operation, Process):
427 437 self.getDateTime(self.saveTime).strftime('%y%m%d_%H%M%S')
428 438 )
429 439 )
430 print 'Saving figure: {}'.format(figname)
440 log.log('Saving figure: {}'.format(figname), self.name)
431 441 fig.savefig(figname)
432 442
433 443 def plot(self):
@@ -810,7 +820,7 class PlotSkyMapData(PlotData):
810 820 Plot for meteors detection data
811 821 '''
812 822
813 CODE = 'met'
823 CODE = 'param'
814 824
815 825 def setup(self):
816 826
@@ -818,25 +828,17 class PlotSkyMapData(PlotData):
818 828 self.nrows = 1
819 829 self.width = 7.2
820 830 self.height = 7.2
821
831 self.nplots = 1
822 832 self.xlabel = 'Zonal Zenith Angle (deg)'
823 833 self.ylabel = 'Meridional Zenith Angle (deg)'
824
825 if self.figure is None:
826 self.figure = plt.figure(figsize=(self.width, self.height),
827 edgecolor='k',
828 facecolor='w')
829 else:
830 self.figure.clf()
831
832 self.ax = plt.subplot2grid(
833 (self.nrows, self.ncols), (0, 0), 1, 1, polar=True)
834 self.ax.firsttime = True
834 self.polar = True
835 self.ymin = -180
836 self.ymax = 180
837 self.colorbar = False
835 838
836 839 def plot(self):
837 840
838 arrayParameters = numpy.concatenate(
839 [self.data['param'][t] for t in self.times])
841 arrayParameters = numpy.concatenate(self.data['param'])
840 842 error = arrayParameters[:, -1]
841 843 indValid = numpy.where(error == 0)[0]
842 844 finalMeteor = arrayParameters[indValid, :]
@@ -846,24 +848,19 class PlotSkyMapData(PlotData):
846 848 x = finalAzimuth * numpy.pi / 180
847 849 y = finalZenith
848 850
849 if self.ax.firsttime:
850 self.ax.plot = self.ax.plot(x, y, 'bo', markersize=5)[0]
851 self.ax.set_ylim(0, 90)
852 self.ax.set_yticks(numpy.arange(0, 90, 20))
853 self.ax.set_xlabel(self.xlabel)
854 self.ax.set_ylabel(self.ylabel)
855 self.ax.yaxis.labelpad = 40
856 self.ax.firsttime = False
857 else:
858 self.ax.plot.set_data(x, y)
851 ax = self.axes[0]
859 852
853 if ax.firsttime:
854 ax.plot = ax.plot(x, y, 'bo', markersize=5)[0]
855 else:
856 ax.plot.set_data(x, y)
860 857
861 858 dt1 = self.getDateTime(self.min_time).strftime('%y/%m/%d %H:%M:%S')
862 859 dt2 = self.getDateTime(self.max_time).strftime('%y/%m/%d %H:%M:%S')
863 860 title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1,
864 861 dt2,
865 862 len(x))
866 self.ax.set_title(title, size=8)
863 self.titles[0] = title
867 864 self.saveTime = self.max_time
868 865
869 866
General Comments 0
You need to be logged in to leave comments. Login now