[Matplotlib-users] pcolor and
Matplotlib users, I've been using pcolor and pcolormesh to plot results from the NCEP Reanalysis. I've noticed that the plotted values are slightly offset. Googling around I see that matlab has this quality, which I assume matplotlib inherited. # If your georeferenced image is in lat/long coordinates (i.e. each data row is along a line of constant latitude, each column a line of equal longitude), ... you MUST remember to offset your coordinates by one-half of the pixel spacing. This is because of the different behaviors of p_color and image when given the same data. 1. image will center the drawn (i,j) pixel on the (i,j)th entry of the X/Y matrices. 2. p_color with shading flat will draw a panel between the (i,j), (i+1,j),(i+1,j+1),(i,j+1) coordinates of the X/Y matrices with a color corresponding to the data value at (i,j). Thus everything will appear shifted by one half a pixel spacing. and % Since the grid is rectangluar in lat/long (i.e. not % really a projection at all, althouhg it is included in % m_map under the name 'equidistant cyldindrical'), we % don't want to use the 'image' technique. Instead... % Create a grid, offsetting by half a grid point to account % for the flat pcolor [Plg,Plt]=meshgrid(Plon-0.25,Plat+0.25); The data I'm using uses polar grids centered on +-90.0 which give a latitude array as such [-90. -87.5 -85. -82.5 -80. -77.5 -75. -72.5 -70. -67.5 -65. -62.5 -60. -57.5 -55. -52.5 -50. -47.5 -45. -42.5 -40. -37.5 -35. -32.5 -30. -27.5 -25. -22.5 -20. -17.5 -15. -12.5 -10. -7.5 -5. -2.5 0.2.5 5.7.5 10. 12.5 15. 17.5 20. 22.5 25. 27.5 30. 32.5 35. 37.5 40. 42.5 45. 47.5 50. 52.5 55. 57.5 60. 62.5 65. 67.5 70. 72.5 75. 77.5 80. 82.5 85. 87.5 90. ] Is there a simple way to shift this data so my global plots look correct? So far my results result in an empty line along the south pole or I end up with an extra latitude which pcolor doesn't like. Thanks, Mike - This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/ ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Re: [Matplotlib-users] can matplotlib do this?
Thanks Jeff, To clarify, I'm sampling a numpy array (regular lon/lat grid) and extracting a series of same size frames (say 60 longitude grids and 30 latitude grids) around a feature of interest, which can be centered somewhere on the map. What I want to do is accumulate statistics with these frames such that the relative size/distances are persevered, which of course means that I can't just add a frame centered on 30N with one centered on 80N. Ideally, I'd like to interpolate each frame to a common point (lon/lat) and display the results either in the common grid space or as radial distances from the common point. Since you're a meteorologist I can simply say I'm creating an ensemble average of extra tropical cyclones from a dozen or so computer models (each with very different resolutions). I want to see how cloud and precipitation features in each model's cyclones compare to a similar product I'm producing from satellite data using weather model output to locate the cyclones. Much the same thing as the link I provided. Thanks for your suggests as transform_scalar sounds like a good place to begin. Mike On Dec 11, 2007, at 4:57 PM, Jeff Whitaker wrote: mbauer wrote: Matplotlib users, I looking to tap your wealth of ideas and experience to help solve a problem I'm working on. The problem: I have a series of 2d scalar arrays representing a fixed width/height lon/lat box centered on an arbitrary lon/lat. I need to average these composites on a common basis that accommodates the scale changes due to latitude, preferably by shifting everything to a common central lon/lat (a polar/radial distance basis would work too). I want a plot of the end result too and I'm like to do everything with matplotlib and python so that it folds into the rest of my program. Something similar can be seen at http://www.atmos.washington.edu/~robwood/topic_cyclones.htm I've been looking at transform_scalar from basemap but I'm not quite sure this is what I should use. Mike: transform_scalar does simple bilinear interpolation from a lat/lon grid to a regular grid in map projection coordinates. If your map projection is just a lat/lon projection, then this amounts to interpolating from one lat/lon grid to another. If anyone can offer a solution, a point in the right direction, or just wave me off this path I'd be most appreciative. I'm sure numpy/matplotlib can do what you need to do. Matplotlib can certainly make a plot similar to the one given in your link. I think you question relates more to the processing of your arrays though, and not specifically the plotting. Are all your 2d arrays the same shape (the same number of lats and lons)? Are they just centered on different regions? If so, I think you can just multiply each grid point by the cosine of latitude to get the proper area weighting before summing them together. But perhaps I'm missing the essence of your question -Jeff -- Jeffrey S. Whitaker Phone : (303)497-6313 Meteorologist FAX: (303)497-6449 NOAA/OAR/PSD R/PSD1Email : [EMAIL PROTECTED] 325 BroadwayOffice : Skaggs Research Cntr 1D-124 Boulder, CO, USA 80303-3328 Web: http://tinyurl.com/5telg - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users
[Matplotlib-users] can matplotlib do this?
Matplotlib users, I looking to tap your wealth of ideas and experience to help solve a problem I'm working on. The problem: I have a series of 2d scalar arrays representing a fixed width/height lon/lat box centered on an arbitrary lon/lat. I need to average these composites on a common basis that accommodates the scale changes due to latitude, preferably by shifting everything to a common central lon/lat (a polar/radial distance basis would work too). I want a plot of the end result too and I'm like to do everything with matplotlib and python so that it folds into the rest of my program. Something similar can be seen at http://www.atmos.washington.edu/~robwood/topic_cyclones.htm I've been looking at transform_scalar from basemap but I'm not quite sure this is what I should use. If anyone can offer a solution, a point in the right direction, or just wave me off this path I'd be most appreciative. Mike - SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php ___ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users