Michael Bauer wrote:
> I'd like to make pcolor images using non-'cyl' projections, but I want  
> the pcolor pixels to be trapezoidal rather than rectangular. Is this  
> possible?
>
> Mike
>
> Example script"
>
> # example data
> lonin = numpy.arange(0.,360.,2.5)
> latin = numpy.arange(-90.,92.5,2.5)
> field = numpy.ones([len(latin),len(lonin)]) +  
> 10.0*numpy.random.random([len(latin),len(lonin)])
>
> # adapt for plot
> #field,lons = addcyclic(field,lonin)
> #field,lons = shiftgrid(180.,field,lons,start=False)
> # offset for pcolor
> field = 0.5*(field[:-1,:-1]+field[1:,1:])
>
> fig = figure()
> canvas = FigureCanvas(fig)
> the_map = Basemap(resolution='c',projection='lcc',llcrnrlon=-75.,
>                    llcrnrlat=15.,urcrnrlon=40.,urcrnrlat=60.,lat_1=50.,
>                    lon_0=-45.)
>
> # convert to projected coordinates
> dx = 2.*pi*the_map.rmajor/len(lons)
> nx = int((the_map.xmax-the_map.xmin)/dx)+1
> ny = int((the_map.ymax-the_map.ymin)/dx)+1
> z,x,y =  
> the_map.transform_scalar(field,lons,lats,nx,ny,returnxy=True,order=0)
>
> # creates seemingly correct image in term of grid placement, but with  
> rectangular pixels
> the_image = the_map.pcolor(x,y,z,shading='flat')
>
>   
Mike:  There's no need to do the interpolation to map projection 
coordinates.  Just pass pcolor the vertices of the lat/lon grid in map 
projection coordinates, i.e.

x,y = the_map(lons, lats)
the_image = the_map.pcolor(x,y,field)

The resulting pixels will not be square, but will have the shape of 
lat/lon boxes in projected coordinates.

-Jeff

-- 
Jeffrey S. Whitaker         Phone : (303)497-6313
NOAA/OAR/CDC  R/PSD1        FAX   : (303)497-6449
325 Broadway                Boulder, CO, USA 80305-3328


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to