@@ -24,6 +24,7 matplotlib.pyplot.register_cmap(cmap=ncmap) | |||
|
24 | 24 | |
|
25 | 25 | CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'RdBu_r', 'seismic')] |
|
26 | 26 | |
|
27 | ||
|
27 | 28 | def figpause(interval): |
|
28 | 29 | backend = plt.rcParams['backend'] |
|
29 | 30 | if backend in matplotlib.rcsetup.interactive_bk: |
@@ -35,6 +36,7 def figpause(interval): | |||
|
35 | 36 | canvas.start_event_loop(interval) |
|
36 | 37 | return |
|
37 | 38 | |
|
39 | ||
|
38 | 40 | class PlotData(Operation, Process): |
|
39 | 41 | ''' |
|
40 | 42 | Base class for Schain plotting operations |
@@ -51,6 +53,7 class PlotData(Operation, Process): | |||
|
51 | 53 | |
|
52 | 54 | Operation.__init__(self, plot=True, **kwargs) |
|
53 | 55 | Process.__init__(self) |
|
56 | self.contador = 0 | |
|
54 | 57 | self.kwargs['code'] = self.CODE |
|
55 | 58 | self.mp = False |
|
56 | 59 | self.data = None |
@@ -80,7 +83,7 class PlotData(Operation, Process): | |||
|
80 | 83 | self.ymin = kwargs.get('ymin', None) |
|
81 | 84 | self.ymax = kwargs.get('ymax', None) |
|
82 | 85 | self.xlabel = kwargs.get('xlabel', None) |
|
83 |
self.__MAXNUMY = kwargs.get('decimation', |
|
|
86 | self.__MAXNUMY = kwargs.get('decimation', 300) | |
|
84 | 87 | self.showSNR = kwargs.get('showSNR', False) |
|
85 | 88 | self.oneFigure = kwargs.get('oneFigure', True) |
|
86 | 89 | self.width = kwargs.get('width', None) |
@@ -204,7 +207,8 class PlotData(Operation, Process): | |||
|
204 | 207 | ax = [ax for ax in self.axes if cb_ax == ax.cbar.ax][0] |
|
205 | 208 | pt = ax.cbar.ax.bbox.get_points()[:,1] |
|
206 | 209 | nrm = ax.cbar.norm |
|
207 |
vmin, vmax, p0, p1, pS = ( |
|
|
210 | vmin, vmax, p0, p1, pS = ( | |
|
211 | nrm.vmin, nrm.vmax, pt[0], pt[1], event.y) | |
|
208 | 212 | scale = 2 if event.step == 1 else 0.5 |
|
209 | 213 |
point = vmin + (vmax - vmin) / (p1 - p0)*(pS - p0) |
|
210 | 214 | ax.cbar.norm.vmin = point - scale*(point - vmin) |
@@ -332,7 +336,8 class PlotData(Operation, Process): | |||
|
332 | 336 | else: |
|
333 | 337 | if self.xaxis is 'time': |
|
334 | 338 |
dt = self.getDateTime(self.min_time) |
|
335 |
xmin = (dt.replace(hour=int(self.xmin), minute=0, second=0) - |
|
|
339 | xmin = (dt.replace(hour=int(self.xmin), minute=0, second=0) - | |
|
340 | datetime.datetime(1970, 1, 1)).total_seconds() | |
|
336 | 341 | if self.data.localtime: |
|
337 | 342 | xmin += time.timezone |
|
338 | 343 | else: |
@@ -343,7 +348,8 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) - |
|
|
351 | xmax = (dt.replace(hour=int(self.xmax), minute=0, second=0) - | |
|
352 | datetime.datetime(1970, 1, 1)).total_seconds() | |
|
347 | 353 | if self.data.localtime: |
|
348 | 354 | xmax += time.timezone |
|
349 | 355 | else: |
@@ -353,7 +359,8 class PlotData(Operation, Process): | |||
|
353 | 359 |
ymax = self.ymax if self.ymax else numpy.nanmax(self.y) |
|
354 | 360 | |
|
355 | 361 | Y = numpy.array([10, 20, 50, 100, 200, 500, 1000, 2000]) |
|
356 |
i = 1 if numpy.where(ymax < Y)[ |
|
|
362 | i = 1 if numpy.where(ymax < Y)[ | |
|
363 | 0][0] < 0 else numpy.where(ymax < Y)[0][0] | |
|
357 | 364 | ystep = Y[i-1]/5 |
|
358 | 365 | |
|
359 | 366 | ystep = 200 if ymax >= 800 else 100 if ymax >= 400 else 50 if ymax >= 200 else 20 |
@@ -413,7 +420,8 class PlotData(Operation, Process): | |||
|
413 | 420 | self.getDateTime(self.max_time).strftime('%Y/%m/%d'))) |
|
414 | 421 | # fig.canvas.draw() |
|
415 | 422 | |
|
416 |
if self.save |
|
|
423 | if self.save: # and self.data.ended: | |
|
424 | self.contador += 1 | |
|
417 | 425 | channels = range(self.nrows) |
|
418 | 426 | if self.oneFigure: |
|
419 | 427 | label = '' |
@@ -421,10 +429,12 class PlotData(Operation, Process): | |||
|
421 | 429 | label = '_{}'.format(channels[n]) |
|
422 | 430 | figname = os.path.join( |
|
423 | 431 | self.save, |
|
424 | '{}{}_{}.png'.format( | |
|
432 | '{}{}_{}{}.png'.format( | |
|
425 | 433 | self.CODE, |
|
426 | 434 | label, |
|
427 |
self.getDateTime(self.saveTime).strftime( |
|
|
435 | self.getDateTime(self.saveTime).strftime( | |
|
436 | '%y%m%d_%H%M%S'), | |
|
437 | str(self.contador), | |
|
428 | 438 | ) |
|
429 | 439 | ) |
|
430 | 440 | print 'Saving figure: {}'.format(figname) |
@@ -857,7 +867,6 class PlotSkyMapData(PlotData): | |||
|
857 | 867 | else: |
|
858 | 868 | self.ax.plot.set_data(x, y) |
|
859 | 869 | |
|
860 | ||
|
861 | 870 | dt1 = self.getDateTime(self.min_time).strftime('%y/%m/%d %H:%M:%S') |
|
862 | 871 | dt2 = self.getDateTime(self.max_time).strftime('%y/%m/%d %H:%M:%S') |
|
863 | 872 | title = 'Meteor Detection Sky Map\n %s - %s \n Number of events: %5.0f\n' % (dt1, |
@@ -906,8 +915,10 class PlotParamData(PlotRTIData): | |||
|
906 | 915 | for n, ax in enumerate(self.axes): |
|
907 | 916 | |
|
908 | 917 | x, y, z = self.fill_gaps(*self.decimate()) |
|
909 |
self.zmax = self.zmax if self.zmax is not None else numpy.max( |
|
|
910 | self.zmin = self.zmin if self.zmin is not None else numpy.min(self.z[n]) | |
|
918 | self.zmax = self.zmax if self.zmax is not None else numpy.max( | |
|
919 | self.z[n]) | |
|
920 | self.zmin = self.zmin if self.zmin is not None else numpy.min( | |
|
921 | self.z[n]) | |
|
911 | 922 | |
|
912 | 923 | if ax.firsttime: |
|
913 | 924 | if self.zlimits is not None: |
@@ -930,6 +941,7 class PlotParamData(PlotRTIData): | |||
|
930 | 941 | |
|
931 | 942 | self.saveTime = self.min_time |
|
932 | 943 | |
|
944 | ||
|
933 | 945 | class PlotOutputData(PlotParamData): |
|
934 | 946 | ''' |
|
935 | 947 | Plot data_output object |
General Comments 0
You need to be logged in to leave comments.
Login now