Discussion:
CONTOUR and automatic gridding of irregularly spaced data
(too old to reply)
Karlo Janos
2013-06-24 13:10:23 UTC
Permalink
Hi all,

IDL 8.2.3 provides automatic gridding of irregularly spaced data with
the CONTOUR function. Great, I thought in hope to get rid of my CONTOUR
plots in direct graphics.

But when I use a CONTOUR function plot combined with a 'Mollweide' MAP
projection and CENTER_LONGITUDE=nonzero_value the automatic gridding
yields a gap between the -180 and +180 degrees longitudes.
The gap exists even though I have used GRID_UNITS='degrees' which should
cause the use of the SPHERE keyword as it is stated in the documentation
of the CONTOUR function.

The only way to avoid this is manually invoking the gridding routines.

Did I do something wrong?
Or can someone confirm this behaviour?

Thanks and regards

Karlo
David Fanning
2013-06-24 13:21:30 UTC
Permalink
Post by Karlo Janos
IDL 8.2.3 provides automatic gridding of irregularly spaced data with
the CONTOUR function. Great, I thought in hope to get rid of my CONTOUR
plots in direct graphics.
But when I use a CONTOUR function plot combined with a 'Mollweide' MAP
projection and CENTER_LONGITUDE=nonzero_value the automatic gridding
yields a gap between the -180 and +180 degrees longitudes.
The gap exists even though I have used GRID_UNITS='degrees' which should
cause the use of the SPHERE keyword as it is stated in the documentation
of the CONTOUR function.
The only way to avoid this is manually invoking the gridding routines.
Did I do something wrong?
Let's just say you are not the first to be thrown upon the shoals of
disappointment. ;-)

Cheers,

David

P.S. What's wrong with gridding the data yourself? God knows, if you do,
it is one less thing to go wrong.
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Karlo Janos
2013-06-25 07:12:29 UTC
Permalink
Post by David Fanning
Let's just say you are not the first to be thrown upon the shoals of
disappointment. ;-)
Cheers,
David
P.S. What's wrong with gridding the data yourself? God knows, if you do,
it is one less thing to go wrong.
Thanks for your encouraging reply. ;-)
Well, what I _really_ want is a cell filled CONTOUR plot of the coloured
Voronoi cells which result from the (manual or automatic) gridding.
Apparently I have failed to use QHULL properly.

The following code avoids the gap between -180° and +180°:

rresult = SPH_SCAT( lons, lats, data, BOUNDS=[-180., -90., 180., 90.],
GS=[360./N_lons, 180./N_lats] )

cc = CONTOUR( rresult $
, DINDGEN(N_lons+1)/N_lons*360-180 $
, DINDGEN(N_lats+1)/N_lats*180-90 $
, /FILL $
, GRID_UNITS=2 $
)


But the grid is spaced equally in longitudes and latitudes. It is not a
real plot of the Voronoi cells based on the data coordinates.

Can you suggest an approach?

Thanks and regards

Karlo
David Fanning
2013-06-25 12:03:47 UTC
Permalink
Post by Karlo Janos
But the grid is spaced equally in longitudes and latitudes. It is not a
real plot of the Voronoi cells based on the data coordinates.
Can you suggest an approach?
I am not at all familiar with how the Contour function works, but how I
typically solve the "gap" problem is to just replicate the first
latitude column as the last column in both the latitude and data arrays.
This gives the direct graphics contour fill algorithm the information it
needs to close the contours over the gap. It also allows you to maintain
the irregular cell spacing of the original data.

Cheers,

David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
Karlo Janos
2013-06-25 13:24:48 UTC
Permalink
... to just replicate the first latitude column as the last column in
both the latitude and data arrays.
This gives the direct graphics contour fill algorithm the information it
needs to close the contours over the gap. It also allows you to maintain
the irregular cell spacing of the original data.
If I understand you correctly, that might work provided that I already
have columns of longitude data, i.e. equally or non-equally spaced
coordinates (but lying on the same longitude!).

This is not, what I meant by "irregular gridding". My data points are
scattered and have all different latitude and longitude values.

The automatic gridding of the old CONTOUR procedure in combination with
the "/IRREGULAR" keyword does what I need. The question now is what is
different between the CONTOUR procedure and the CONTOUR function?

Thanks and regards

Karlo

Loading...