Polar plots of radar scans

Dear all,

I am just looking at matplotlib for the first time and liking very much
what I see. I have a requirement to try and plot a horizontal scan from
a radar. The incoming data is simply array(distanceFromInstrument,
azimuth). Has anybody tried doing for a polar plot without converting
the data to a lat/lon grid first?

An example of what I'd like to do is visible at:

http://www.chilbolton.rl.ac.uk/weather/latest/latest_ppi_v2.png

Thanks,

Ag

···

--
Ag Stephens Tel: +44 (0)1392
884263
BADC - UK Met Office Coordinator Fax: +44 (0)1392 885681
Met Office, A2 - W004, FitzRoy Road, Exeter, EX1 3PB, UK.
E-mail (Met Office): ag.stephens@...960...
E-mail (BADC): a.stephens@...959...
Home page: http://home.badc.rl.ac.uk/astephens
                              
BADC details:
British Atmospheric Data Centre, Rutherford Appleton Laboratory,

Chilton, Didcot, OX11 0QX, UK. http://badc.nerc.ac.uk

Stephens, A (Ag) wrote:

Dear all,

I am just looking at matplotlib for the first time and liking very much
what I see. I have a requirement to try and plot a horizontal scan from
a radar. The incoming data is simply array(distanceFromInstrument,
azimuth). Has anybody tried doing for a polar plot without converting
the data to a lat/lon grid first?

An example of what I'd like to do is visible at:

http://www.chilbolton.rl.ac.uk/weather/latest/latest_ppi_v2.png

Thanks,

Ag
  

Ag: You should be able to use either contourf or pcolor to make the plot by just passing it the X and Y coordinates of the radial distance, azimuth points. Here's a simple example:

from pylab import *
deltatheta = 2.*pi/100.
theta = arange(0.,2.*pi,deltatheta)
R = arange(0.,pi,deltatheta)
r,t = meshgrid(R, theta)
Z = sin(r)*sin(3.*t)
X = r*cos(t)
Y = r*sin(t)
figure(figsize=(8,8))
cs = contourf(X, Y, Z)
title('Simple polar contour plot')
show()

-Jeff

···

--
Jeffrey S. Whitaker Phone : (303)497-6313
Meteorologist FAX : (303)497-6449
NOAA/OAR/PSD R/PSD1 Email : Jeffrey.S.Whitaker@...259...
325 Broadway Office : Skaggs Research Cntr 1D-124
Boulder, CO, USA 80303-3328 Web : http://tinyurl.com/5telg

Jeff Whitaker wrote:

Stephens, A (Ag) wrote:

Ag: You should be able to use either contourf or pcolor to make the plot by just passing it the X and Y coordinates of the radial distance, azimuth points. Here's a simple example:

from pylab import *
deltatheta = 2.*pi/100.

theta = arange(0.,2.*pi,deltatheta)
R = arange(0.,pi,deltatheta)
r,t = meshgrid(R, theta)

I see this kind of code a lot on this list. I just want to point out that in NumPy (and Numeric and Numarray) you don't have to completely generate the "meshgrid" like this because of broadcasting. All you need is for r to be Nx1 and t to be 1xN and the broadcasting will take care of it so that Z, X, and Y below are all NxN. This can save space and time particularly for large values of N.

In NumPy (and old SciPy) there is even a simple constructor for these "open" grids:

r,t = ogrid[0:pi:deltatheta, 0:2*pi:deltatheta]

would replace the three lines above.

Z = sin(r)*sin(3.*t)
X = r*cos(t)
Y = r*sin(t)
figure(figsize=(8,8))
cs = contourf(X, Y, Z)
title('Simple polar contour plot')
show()

Sorry for the somewhat off-topic post.

-Travis