##// END OF EJS Templates
add information in save plot and barcolor rwg
jespinoza -
r1477:ac0997d078b2
parent child
Show More
@@ -15,12 +15,12 import datetime
15 from collections import deque
15 from collections import deque
16 from functools import wraps
16 from functools import wraps
17 from threading import Thread
17 from threading import Thread
18 import matplotlib
18 import matplotlib,re
19
19
20 if 'BACKEND' in os.environ:
20 if 'BACKEND' in os.environ:
21 matplotlib.use(os.environ['BACKEND'])
21 matplotlib.use(os.environ['BACKEND'])
22 elif 'linux' in sys.platform:
22 elif 'linux' in sys.platform:
23 matplotlib.use("TkAgg")
23 matplotlib.use("Agg")#TkAgg
24 elif 'darwin' in sys.platform:
24 elif 'darwin' in sys.platform:
25 matplotlib.use('MacOSX')
25 matplotlib.use('MacOSX')
26 else:
26 else:
@@ -44,8 +44,11 ncmap = matplotlib.colors.LinearSegmentedColormap.from_list(
44 'jro', numpy.vstack((blu_values, jet_values)))
44 'jro', numpy.vstack((blu_values, jet_values)))
45 matplotlib.pyplot.register_cmap(cmap=ncmap)
45 matplotlib.pyplot.register_cmap(cmap=ncmap)
46
46
47 rwg=matplotlib.colors.LinearSegmentedColormap.from_list('rwg',["r", "w", "g"], N=256)
48 matplotlib.pyplot.register_cmap(cmap=rwg)
49
47 CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'viridis',
50 CMAPS = [plt.get_cmap(s) for s in ('jro', 'jet', 'viridis',
48 'plasma', 'inferno', 'Greys', 'seismic', 'bwr', 'coolwarm')]
51 'plasma', 'inferno', 'Greys', 'seismic', 'bwr', 'coolwarm','rwg')]
49
52
50 EARTH_RADIUS = 6.3710e3
53 EARTH_RADIUS = 6.3710e3
51
54
@@ -486,7 +489,10 class Plot(Operation):
486 figpause(0.01)
489 figpause(0.01)
487
490
488 if self.save:
491 if self.save:
489 self.save_figure(n)
492 if self.CODE=="PPI" or self.CODE=="RHI":
493 self.save_figure(n,stitle =self.titles)
494 else:
495 self.save_figure(n)
490
496
491 if self.server:
497 if self.server:
492 self.send_to_server()
498 self.send_to_server()
@@ -505,9 +511,13 class Plot(Operation):
505 metadata.update(meta)
511 metadata.update(meta)
506 self.data.update(data, timestamp, metadata)
512 self.data.update(data, timestamp, metadata)
507
513
508 def save_figure(self, n):
514 def save_figure(self, n,stitle=None):
509 '''
515 '''
510 '''
516 '''
517 if stitle is not None:
518 s_string = re.sub(r"[^A-Z0-9.]","",str(stitle))
519 new_string=s_string[:3]+"_"+"_"+s_string[4:6]+"_"+s_string[6:]
520
511 if self.oneFigure:
521 if self.oneFigure:
512 if (self.data.max_time - self.save_time) <= self.save_period:
522 if (self.data.max_time - self.save_time) <= self.save_period:
513 return
523 return
@@ -518,16 +528,29 class Plot(Operation):
518
528
519 if self.throttle == 0:
529 if self.throttle == 0:
520 if self.oneFigure:
530 if self.oneFigure:
521 figname = os.path.join(
531 if stitle is not None:
522 self.save,
532 figname = os.path.join(
523 self.save_code,
533 self.save,
524 '{}_{}.png'.format(
525 self.save_code,
534 self.save_code,
526 self.getDateTime(self.data.max_time).strftime(
535 '{}_{}_{}.png'.format(
527 '%Y%m%d_%H%M%S'
536 self.save_code,
528 ),
537 self.getDateTime(self.data.max_time).strftime(
538 '%Y%m%d_%H%M%S',
539 ),
540 new_string,
541 )
529 )
542 )
530 )
543 else:
544 figname = os.path.join(
545 self.save,
546 self.save_code,
547 '{}_{}.png'.format(
548 self.save_code,
549 self.getDateTime(self.data.max_time).strftime(
550 '%Y%m%d_%H%M%S'
551 ),
552 )
553 )
531 else:
554 else:
532 figname = os.path.join(
555 figname = os.path.join(
533 self.save,
556 self.save,
General Comments 0
You need to be logged in to leave comments. Login now