def plot_variable(self,va,lv,**kwargs): self.fig = plt.figure() m, x, y = self.basemap_setup(nc,**kwargs) # Scales, colourmaps in here data = self.get(va,**kwargs) if not 'scale' in kwargs: m.contourf(x,y,data) else: m.contourf(x,y,data,N.arange(*kwargs['scale'])) if self.C.plot_titles: title = utils.string_from_time('title',self.t) plt.title(title) if self.C.colorbar: plt.colorbar(orientation='horizontal') # SAVE FIGURE datestr = utils.string_from_time('output',self.t) lv_na = utils.get_level_naming(lv,va) na = (va,lv_na,datestr) self.fname = self.create_fname(*na) # pdb.set_trace() self.save(self.fig,self.output_root,self.fname) plt.close()
def plot_streamlines(self,va,lv,**kwargs): fig = plt.figure() # Scales, colourmaps in here # Get data u_all = self.get('U10',**kwargs)[:] v_all = self.get('V10',**kwargs)[:] u = self.cut_2D_array(u_all) v = self.cut_2D_array(v_all) m, x, y = self.basemap_setup(**kwargs) """ # Density depends on which version # Wanting to match 3 km WRF (which had 2.5 density) # Should work out dx, dy in __init__ method! WRF_density = 2.5 WRF_res = 3.0 if self.version == 3: RUC_res = 13.0 density = WRF_density * RUC_res/WRF_res """ density = 2.5 #x = N.array(range(u.shape[0])) #y = N.array(range(v.shape[1])) #pdb.set_trace() #m.streamplot(x[self.x_dim/2,:],y[:,self.y_dim/2],u,v,density=density,linewidth=0.75,color='k') #m.streamplot(x[y.shape[1]/2,:],y[:,x.shape[0]/2],u,v,density=density,linewidth=0.75,color='k') #plt.streamplot(x[:,0],y[0,:],u,v)#,density=density,linewidth=0.75,color='k') m.streamplot(y[0,:],x[:,0],u,v,density=density,linewidth=0.75,color='k') #m.quiver(x,y,u,v) if self.C.plot_titles: title = utils.string_from_time('title',self.t) plt.title(title) # SAVE FIGURE datestr = utils.string_from_time('output',self.t) lv_na = utils.get_level_naming(va,lv=lv) na = (va,lv_na,datestr) self.fname = self.create_fname(*na) # pdb.set_trace() self.save(fig,self.output_root,self.fname) plt.close()
def plot(self,va,lv,times,**kwargs): for t in times: fig = plt.figure() data = self.get(va,lv,t) m, x, y = self.basemap_setup() if 'scale' in kwargs: S = kwargs['scale'] f1 = m.contour(x,y,data,S,colors='k') else: f1 = m.contour(x,y,data,colors='k') if self.C.plot_titles: title = utils.string_from_time('title',t) plt.title(title) if 'wind_overlay' in kwargs: jet = kwargs['wind_overlay'] wind = self.get('wind',lv,t) windplot = m.contourf(x,y,wind,jet,alpha=0.6) plt.colorbar(windplot) elif 'W_overlay' in kwargs: Wscale = kwargs['W_overlay'] W = self.get('W',lv,t) windplot = m.contourf(x,y,W,alpha=0.6) plt.colorbar(windplot) # if self.C.colorbar: # plt.colorbar(orientation='horizontal') datestr = utils.string_from_time('output',t) fname = '_'.join(('ECMWF',va,str(lv),datestr)) + '.png' print("Plotting {0} at {1} for {2}".format( va,lv,datestr)) plt.clabel(f1, inline=1, fmt='%4u', fontsize=12, colors='k') utils.trycreate(self.C.output_root) plt.savefig(os.path.join(self.C.output_root,fname)) plt.clf() plt.close()
def plot(self, va, lv, times, **kwargs): for t in times: fig = plt.figure() data = self.get(va, lv, t) m, x, y = self.basemap_setup() if 'scale' in kwargs: S = kwargs['scale'] f1 = m.contour(x, y, data, S, colors='k') else: f1 = m.contour(x, y, data, colors='k') if self.C.plot_titles: title = utils.string_from_time('title', t) plt.title(title) if 'wind_overlay' in kwargs: jet = kwargs['wind_overlay'] wind = self.get('wind', lv, t) windplot = m.contourf(x, y, wind, jet, alpha=0.6) plt.colorbar(windplot) elif 'W_overlay' in kwargs: Wscale = kwargs['W_overlay'] W = self.get('W', lv, t) windplot = m.contourf(x, y, W, alpha=0.6) plt.colorbar(windplot) # if self.C.colorbar: # plt.colorbar(orientation='horizontal') datestr = utils.string_from_time('output', t) fname = '_'.join(('ECMWF', va, str(lv), datestr)) + '.png' print("Plotting {0} at {1} for {2}".format(va, lv, datestr)) plt.clabel(f1, inline=1, fmt='%4u', fontsize=12, colors='k') utils.trycreate(self.C.output_root) plt.savefig(os.path.join(self.C.output_root, fname)) plt.clf() plt.close()