contourf interpolation/smoothness

This has probably been asked before, so I apologize...

Is it possible to improve the smoothness/interpolation used in contourf?
I know that the interpolation can be set for imshow(pcolor?), but I couldn't
see how to set it for contourf.

Right now, contourf is producing some relatively jagged output for my
dataset, and I'd like to try to smoothen it out, without resorting to using
pcolor/imshow...

Please help,
Thanks,
P.Romero

P.R. wrote:

This has probably been asked before, so I apologize...

Is it possible to improve the smoothness/interpolation used in contourf?
I know that the interpolation can be set for imshow(pcolor?), but I couldn't
see how to set it for contourf.

Right now, contourf is producing some relatively jagged output for my
dataset, and I'd like to try to smoothen it out, without resorting to using
pcolor/imshow...

There are two approaches:

1) manipulate the contours (the patch boundaries)
2) smooth and interpolate the data to a finer grid before contouring.

There are many problems with the first approach, and we have never tried to implement it.

That leaves the second method, which is really not a plotting task but a data processing task. You might want to see if there is a suitable tool in scipy.

Eric

···

Please help,
Thanks,
P.Romero

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Eric Firing wrote:

P.R. wrote:
  

This has probably been asked before, so I apologize...

Is it possible to improve the smoothness/interpolation used in contourf?
I know that the interpolation can be set for imshow(pcolor?), but I couldn't
see how to set it for contourf.

Right now, contourf is producing some relatively jagged output for my
dataset, and I'd like to try to smoothen it out, without resorting to using
pcolor/imshow...
    
There are two approaches:

1) manipulate the contours (the patch boundaries)
2) smooth and interpolate the data to a finer grid before contouring.

There are many problems with the first approach, and we have never tried to implement it.

That leaves the second method, which is really not a plotting task but a data processing task. You might want to see if there is a suitable tool in scipy.

Eric

Pablo: You could use the interp function in Basemap to bilinearly interpolate to a finer grid.

http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html#mpl_toolkits.basemap.interp

-Jeff

Jeff,

Perfect.
I'll give that a try...

Thanks again,
P.R.

···

-----Original Message-----
From: Jeff Whitaker [mailto:jswhit@…146…]
Sent: 2009-08-13 7:15 AM
To: Eric Firing
Cc: P.R.; matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] contourf interpolation/smoothness

Eric Firing wrote:

P.R. wrote:
  

This has probably been asked before, so I apologize...

Is it possible to improve the smoothness/interpolation used in contourf?
I know that the interpolation can be set for imshow(pcolor?), but I

couldn't

see how to set it for contourf.

Right now, contourf is producing some relatively jagged output for my
dataset, and I'd like to try to smoothen it out, without resorting to

using

pcolor/imshow...
    
There are two approaches:

1) manipulate the contours (the patch boundaries)
2) smooth and interpolate the data to a finer grid before contouring.

There are many problems with the first approach, and we have never tried
to implement it.

That leaves the second method, which is really not a plotting task but a
data processing task. You might want to see if there is a suitable tool
in scipy.

Eric

Pablo: You could use the interp function in Basemap to bilinearly
interpolate to a finer grid.

http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html#mpl_
toolkits.basemap.interp

-Jeff

Jeff,
One more question:
Given two arbitrary X&Y arrays, what's the easiest/fastest way to convert to
a finer array ?
(for example, convert a 0.5 degree 'X' or 'Y' array to a 0.25 array over the
same bounds as the original array)

- I need a method that can handle arbitrary grid sizes & resolutions, so I
can't just hard-code the X&Y sizes for the finer grid.

Any ideas?

Thanks,
P.Romero

···

-----Original Message-----
From: Jeff Whitaker [mailto:jswhit@…146…]
Sent: 2009-08-13 7:15 AM
To: Eric Firing
Cc: P.R.; matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] contourf interpolation/smoothness

Eric Firing wrote:

P.R. wrote:
  

This has probably been asked before, so I apologize...

Is it possible to improve the smoothness/interpolation used in contourf?
I know that the interpolation can be set for imshow(pcolor?), but I

couldn't

see how to set it for contourf.

Right now, contourf is producing some relatively jagged output for my
dataset, and I'd like to try to smoothen it out, without resorting to

using

pcolor/imshow...
    
There are two approaches:

1) manipulate the contours (the patch boundaries)
2) smooth and interpolate the data to a finer grid before contouring.

There are many problems with the first approach, and we have never tried
to implement it.

That leaves the second method, which is really not a plotting task but a
data processing task. You might want to see if there is a suitable tool
in scipy.

Eric

Pablo: You could use the interp function in Basemap to bilinearly
interpolate to a finer grid.

http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html#mpl_
toolkits.basemap.interp

-Jeff

P.R. wrote:

Jeff,
One more question:
Given two arbitrary X&Y arrays, what's the easiest/fastest way to convert to
a finer array ?
(for example, convert a 0.5 degree 'X' or 'Y' array to a 0.25 array over the
same bounds as the original array)

- I need a method that can handle arbitrary grid sizes & resolutions, so I
can't just hard-code the X&Y sizes for the finer grid.

Any ideas?

Thanks,
P.Romero
  

P.R. The interp function can do that easily, you just create an array of lats and lons defining the output grid by dividing the input grid size by 2. Is there something in the docstring that is not clear?

-Jeff

···

-----Original Message-----
From: Jeff Whitaker [mailto:jswhit@…146…] Sent: 2009-08-13 7:15 AM
To: Eric Firing
Cc: P.R.; matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] contourf interpolation/smoothness

Eric Firing wrote:
  

P.R. wrote:
  

This has probably been asked before, so I apologize...

Is it possible to improve the smoothness/interpolation used in contourf?
I know that the interpolation can be set for imshow(pcolor?), but I
      

couldn't
  

see how to set it for contourf.

Right now, contourf is producing some relatively jagged output for my
dataset, and I'd like to try to smoothen it out, without resorting to
      

using
  

pcolor/imshow...
    

There are two approaches:

1) manipulate the contours (the patch boundaries)
2) smooth and interpolate the data to a finer grid before contouring.

There are many problems with the first approach, and we have never tried to implement it.

That leaves the second method, which is really not a plotting task but a data processing task. You might want to see if there is a suitable tool in scipy.

Eric

Pablo: You could use the interp function in Basemap to bilinearly interpolate to a finer grid.

http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html#mpl_
toolkits.basemap.interp

-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-113
Boulder, CO, USA 80303-3328 Web : Jeffrey S. Whitaker: NOAA Physical Sciences Laboratory

Jeff,
The docstring is clear.
My question was on how to actually create the lats&lons arrays
(sorry, Im not a very strong python programmer).

Could you please recommend a method for dividing a lat/lon array in half?

Again, I apologize for asking such a basic question...

Thanks,
P.R.

···

-----Original Message-----
From: Jeff Whitaker [mailto:jswhit@…146…]
Sent: 2009-08-13 10:56 AM
To: P.R.
Cc: matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] contourf interpolation/smoothness

P.R. wrote:

Jeff,
One more question:
Given two arbitrary X&Y arrays, what's the easiest/fastest way to convert

to

a finer array ?
(for example, convert a 0.5 degree 'X' or 'Y' array to a 0.25 array over

the

same bounds as the original array)

- I need a method that can handle arbitrary grid sizes & resolutions, so I
can't just hard-code the X&Y sizes for the finer grid.

Any ideas?

Thanks,
P.Romero
  

P.R. The interp function can do that easily, you just create an array
of lats and lons defining the output grid by dividing the input grid
size by 2. Is there something in the docstring that is not clear?

-Jeff

-----Original Message-----
From: Jeff Whitaker [mailto:jswhit@…146…]
Sent: 2009-08-13 7:15 AM
To: Eric Firing
Cc: P.R.; matplotlib-users@lists.sourceforge.net
Subject: Re: [Matplotlib-users] contourf interpolation/smoothness

Eric Firing wrote:
  

P.R. wrote:
  

This has probably been asked before, so I apologize...

Is it possible to improve the smoothness/interpolation used in contourf?
I know that the interpolation can be set for imshow(pcolor?), but I
      

couldn't
  

see how to set it for contourf.

Right now, contourf is producing some relatively jagged output for my
dataset, and I'd like to try to smoothen it out, without resorting to
      

using
  

pcolor/imshow...
    

There are two approaches:

1) manipulate the contours (the patch boundaries)
2) smooth and interpolate the data to a finer grid before contouring.

There are many problems with the first approach, and we have never tried
to implement it.

That leaves the second method, which is really not a plotting task but a
data processing task. You might want to see if there is a suitable tool
in scipy.

Eric

Pablo: You could use the interp function in Basemap to bilinearly
interpolate to a finer grid.

http://matplotlib.sourceforge.net/basemap/doc/html/api/basemap_api.html#mpl_

toolkits.basemap.interp

-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-113
Boulder, CO, USA 80303-3328 Web : Jeffrey S. Whitaker: NOAA Physical Sciences Laboratory