def animation(self): import vcs,cdms,tempfile,os canvas=vcs.init() # Construct VCS object to generate image # Get subset of data cdms.setAutoReshapeMode('on') if (len(self.var.shape) == 4): a = self.var[0:12,0] elif (len(self.var.shape) == 3): a = self.var[0:12] else: a = None cdms.setAutoReshapeMode('off') # Create image in background if (a != None): gif_file = tempfile.mktemp() # Generate temporary file to store GIF image for i in range(a.shape[0]): canvas.plot(a[i],'default','isofill',variable=self.var,bg=1) # Generate VCS isofill image gif_name = canvas.gif(gif_file) # Generate temporary GIF image canvas.clear() # Clear the VCS Canvas for next image f=open(gif_name,'rb') # Open temporary GIF image s=f.read() # Read temporary GIF image f.close() # Close GIF image os.remove(gif_name) # Remove temporary GIF image, else: s=None return s # Return GIF image string
def plot_one_average (self, averager, template='default', graphics_mode='isofill'): import vcs, cdms canvas=vcs.init() # Construct VCS object to generate image cdms.setAutoReshapeMode('off') a, keyargs = averager(self.var) apply(canvas.plot, (a, template, graphics_mode), keyargs) # Generate VCS isofill image return gifiate(canvas)
def plot(self): """Plot self using first time and level only.""" import vcs, cdms, VCSRegion canvas=vcs.init() # Construct VCS object to generate image cdms.setAutoReshapeMode('off') a, keyargs = VCSRegion.getRegion(self.var, time=None, level=None, other=None) apply(canvas.plot, (a, 'default', 'isofill'), keyargs) # Generate VCS isofill image return gifiate(canvas) # Return GIF image string
def plot_four_views (self, f1, f2, f3, f4, graphics_mode='isofill'): import vcs, cdms canvas=vcs.init() # Construct VCS object to generate image cdms.setAutoReshapeMode('off') for template, f in (('UL1of4',f1), ('UR2of4',f2), ('LL3of4', f3), ('LR4of4', f4)): a, keyargs = f(self.var) keyargs['long_name'] = 'Seasonal Averages' apply(canvas.plot, (a, template, graphics_mode), keyargs) # Generate VCS isofill image return gifiate(canvas)
def plot_one_average(self, averager, template='default', graphics_mode='isofill'): import vcs, cdms canvas = vcs.init() # Construct VCS object to generate image cdms.setAutoReshapeMode('off') a, keyargs = averager(self.var) apply(canvas.plot, (a, template, graphics_mode), keyargs) # Generate VCS isofill image return gifiate(canvas)
def plot_four_views(self, f1, f2, f3, f4, graphics_mode='isofill'): import vcs, cdms canvas = vcs.init() # Construct VCS object to generate image cdms.setAutoReshapeMode('off') for template, f in (('UL1of4', f1), ('UR2of4', f2), ('LL3of4', f3), ('LR4of4', f4)): a, keyargs = f(self.var) keyargs['long_name'] = 'Seasonal Averages' apply(canvas.plot, (a, template, graphics_mode), keyargs) # Generate VCS isofill image return gifiate(canvas)
def plot(self): """Plot self using first time and level only.""" import vcs, cdms, VCSRegion canvas = vcs.init() # Construct VCS object to generate image cdms.setAutoReshapeMode('off') a, keyargs = VCSRegion.getRegion(self.var, time=None, level=None, other=None) apply(canvas.plot, (a, 'default', 'isofill'), keyargs) # Generate VCS isofill image return gifiate(canvas) # Return GIF image string
def animation(self): import vcs, cdms, tempfile, os canvas = vcs.init() # Construct VCS object to generate image # Get subset of data cdms.setAutoReshapeMode('on') if (len(self.var.shape) == 4): a = self.var[0:12, 0] elif (len(self.var.shape) == 3): a = self.var[0:12] else: a = None cdms.setAutoReshapeMode('off') # Create image in background if (a != None): gif_file = tempfile.mktemp( ) # Generate temporary file to store GIF image for i in range(a.shape[0]): canvas.plot(a[i], 'default', 'isofill', variable=self.var, bg=1) # Generate VCS isofill image gif_name = canvas.gif(gif_file) # Generate temporary GIF image canvas.clear() # Clear the VCS Canvas for next image f = open(gif_name, 'rb') # Open temporary GIF image s = f.read() # Read temporary GIF image f.close() # Close GIF image os.remove(gif_name) # Remove temporary GIF image, else: s = None return s # Return GIF image string