Exemple #1
0
    def __call__(self, **params):

        p = ParamOverrides(self, params)
        name = p.plot_template.keys().pop(0)
        plot = make_template_plot(p.plot_template,
                                  p.sheet.views.Maps,
                                  p.sheet.xdensity,
                                  p.sheet.bounds,
                                  p.normalize,
                                  name=p.plot_template[name])
        fig = plt.figure(figsize=(5, 5))
        if plot:
            bitmap = plot.bitmap
            isint = plt.isinteractive(
            )  # Temporarily make non-interactive for plotting
            plt.ioff()  # Turn interactive mode off

            plt.imshow(bitmap.image, origin='lower', interpolation='nearest')
            plt.axis('off')

            for (t, pref, sel, c) in p.overlay:
                v = plt.flipud(p.sheet.views.Maps[pref].view()[0])
                if (t == 'contours'):
                    plt.contour(v, [sel, sel], colors=c, linewidths=2)

                if (t == 'arrows'):
                    s = plt.flipud(p.sheet.views.Maps[sel].view()[0])
                    scale = int(np.ceil(np.log10(len(v))))
                    X = np.array([x for x in xrange(len(v) / scale)])
                    v_sc = np.zeros((len(v) / scale, len(v) / scale))
                    s_sc = np.zeros((len(v) / scale, len(v) / scale))
                    for i in X:
                        for j in X:
                            v_sc[i][j] = v[scale * i][scale * j]
                            s_sc[i][j] = s[scale * i][scale * j]
                    plt.quiver(scale * X,
                               scale * X,
                               -np.cos(2 * np.pi * v_sc) * s_sc,
                               -np.sin(2 * np.pi * v_sc) * s_sc,
                               color=c,
                               edgecolors=c,
                               minshaft=3,
                               linewidths=1)

            p.title = '%s overlaid with %s at time %s' % (plot.name, pref,
                                                          topo.sim.timestr())
            if isint: plt.ion()
            p.filename_suffix = "_" + p.sheet.name
            self._generate_figure(p)
            return fig
Exemple #2
0
 def get_array(self,vname):
     """
     Return a given array from the output file.  Must be returned as a
     2D array with top to bottom orientation (like an image).
     """
     v=self.f.variables[vname]
     v=pylab.flipud(v)
     return v
Exemple #3
0
 def get_array(self,vname):
     """
     Return a single time slice of a variable from a Netcdf file.
     """
     v=self.f.variables[vname]
     v=v[self.istep,:,:]
     v=pylab.flipud(v)
     return v
 def get_array(self,vname):
     '''Return a single time slice of a variable from a WRF output file.'''
     v=self.f.variables[vname]
     v=v[self.istep,:,:].squeeze()
     if self.isfiregrid(vname):
         v=v[:-self.sry(),:-self.srx()]
     v=pylab.flipud(v)
     if vname == 'FGRNHFX' or vname == 'GRNHFX':
         v[:]=v*0.239005736
     return v
Exemple #5
0
 def get_array(self, vname):
     '''Return a single time slice of a variable from a WRF output file.'''
     v = self.f.variables[vname]
     v = v[self.istep, :, :].squeeze()
     if self.isfiregrid(vname):
         v = v[:-self.sry(), :-self.srx()]
     v = pylab.flipud(v)
     if vname == 'FGRNHFX' or vname == 'GRNHFX':
         v[:] = v * 0.239005736
     return v
   def __call__(self, **params):

       p=ParamOverrides(self,params)
       name=p.plot_template.keys().pop(0)
       plot=make_template_plot(p.plot_template,
                               p.sheet.views.Maps, p.sheet.xdensity,p.sheet.bounds,
                               p.normalize,name=p.plot_template[name])
       fig = plt.figure(figsize=(5,5))
       if plot:
           bitmap=plot.bitmap
           isint=plt.isinteractive() # Temporarily make non-interactive for plotting
           plt.ioff()                                         # Turn interactive mode off

           plt.imshow(bitmap.image,origin='lower',interpolation='nearest')
           plt.axis('off')

           for (t,pref,sel,c) in p.overlay:
               v = plt.flipud(p.sheet.views.Maps[pref].view()[0])
               if (t=='contours'):
                   plt.contour(v,[sel,sel],colors=c,linewidths=2)

               if (t=='arrows'):
                   s = plt.flipud(p.sheet.views.Maps[sel].view()[0])
                   scale = int(np.ceil(np.log10(len(v))))
                   X = np.array([x for x in xrange(len(v)/scale)])
                   v_sc = np.zeros((len(v)/scale,len(v)/scale))
                   s_sc = np.zeros((len(v)/scale,len(v)/scale))
                   for i in X:
                       for j in X:
                           v_sc[i][j] = v[scale*i][scale*j]
                           s_sc[i][j] = s[scale*i][scale*j]
                   plt.quiver(scale*X, scale*X, -np.cos(2*np.pi*v_sc)*s_sc,
                              -np.sin(2*np.pi*v_sc)*s_sc, color=c,
                              edgecolors=c, minshaft=3, linewidths=1)

           p.title='%s overlaid with %s at time %s' %(plot.name,pref,topo.sim.timestr())
           if isint: plt.ion()
           p.filename_suffix="_"+p.sheet.name
           self._generate_figure(p)
           return fig
 def get_array(self,vname):
     '''Return a given array from the output file.  Must be returned as a
     2D array with top to bottom orientation (like an image).'''
     v=self.f.variables[vname]
     v=pylab.flipud(v)
     return v
Exemple #8
0
 def get_array(self, vname):
     '''Return a single time slice of a variable from a WRF output file.'''
     v = self.f.variables[vname]
     v = v[self.istep, :, :]
     v = pylab.flipud(v)
     return v
Exemple #9
0
 def get_array(self,vname):
     '''Return a single time slice of a variable from a WRF output file.'''
     v=self.f.variables[vname]
     v=v[self.istep,:,:]
     v=pylab.flipud(v)
     return v