comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Griddata and Contour questions
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Griddata and Contour questions [message #54823] Wed, 11 July 2007 09:17
Conor is currently offline  Conor
Messages: 138
Registered: February 2007
Senior Member
On Jul 11, 11:09 am, julia.kamenet...@gmail.com wrote:
> I'm somewhat new to IDL, and attempting to create contour plots of
> sets of astronomical data. We'd like to interpolate data points based
> on the known Gaussian beam size. It seems to me like the only routine
> in IDL to accomplish this would be the Kriging method of GRIDDATA
> using Gaussian covariance? I have a few questions about this...
>
> 1) In what units are parameters such as d and R (as specified in the
> help section on the variogram)? I am assuming that they are in units
> of spacing between adjacent grid points (ie, the distance from one to
> the next is equal to one), but please let me know if this is
> incorrect.
>
> 2) When I use this method, I receive an array that contains values way
> outside the range of the data. (My data is from about 20 to 200, and
> the returned array has values from about negative to positive
> 12,000!) I cannot get correct results, even with changing around my
> range value in the variogram, dimensions, or if I triangulate the data
> before.
>
> Some examples of ones I've tried:
>
> KRIGGRID2=GRIDDATA(158_ASCII.L,158_ASCII.B,158_ASCII.INTENSI TY, /
> KRIGING, DIMENSION=[500,386], VARIOGRAM=[3,24,0,1])
>
> KRIGGRID=GRIDDATA(158_ASCII.L,ASCII.B,158_ASCII.INTENSITY, /KRIGING,
> TRIANGLES=TR, ANISOTROPY=[1,1], DIMENSION=[500,386],
> VARIOGRAM=[3,24,0,1], SEARCH_ELLIPSE=20)
>
> Any idea what I'm doing wrong, and why I'm getting values that are
> clearly not interpolations of the defined points? I am able to grid
> using other methods and get reasonable contours with this data, but I
> cannot seem to get this method to work.
>
> 3) Once I have this data gridded, how can I then display it on the
> original coordinate axes, rather than axes that are just numbered by
> indices of the gridded array?
>
> It would be preferable to do this all using the iContour gridding
> wizard (as you can tell, I have little IDL command line experience),
> but as of yet I am not sure that any of the options in the wizard will
> interpolate the right way. If there is a suitable option, or one that
> is "close enough", I'd love to hear about it!
>
> Thank you for your time.

I have no idea if this is what you need, or what you want. Maybe it
is though, so I can show you what I do. I often use interpolation for
all sorts of things. I use a combination of triangulate and trigrid,
as recommended by online_help. I have a (command line) program I
wrote for this along time ago. The problem is that it was long enough
ago that I don't remember the details of how it actually works. So I
have to give you the program bereft of any useful comments. There
should be some helpful hints in the online_help for interpolate
though.

PRO inter,x,y,z,xval,yval,res, noextrapolate=noextrapolate

xx = x
yy = y
zz = z
triangulate, xx, yy, tr, b

res = fltarr(n_elements(xval))

FOR j = 0L, n_elements(xval)-1 DO BEGIN
xi = xval[j]
yi = yval[j]
p = 0.1
if keyword_set( noextrapolate ) then array = trigrid(xx, yy, zz,
tr, [0, 0], [xi-p, yi-p, xi+p, yi+p], NX=101, NY=101) else $
array = trigrid(xx, yy, zz, tr, EXTRAPOLATE=b, [0, 0], [xi-p, yi-
p, xi+p, yi+p], NX=101, NY=101)
res[j] = array[50, 50]

ENDFOR

END



You would call this by putting all the x data you want to interpolate
between in x, all the corresponding y data in y, and all their
corresponding values in z. Then, the values you want to interpolate
at go in xval and yval, and the result comes out in res. So you could
do something like this:

x = [findgen(10),findgen(10)]
y = [sin(findgen(10)),sin(findgen(10))+1]
z = [fltarr(10),fltarr(10)+1]
xval = [2.0,4.0,6.0]
yval = [1.5,0.0,0.0]
inter,x,y,z,xval,yval,res


In this case, the first sin curve has a value of 0, the second sine
curve has a value of 1, and the values in res are the interpolated
values between the two curves at the points [xval,yval]
Re: Griddata and Contour questions [message #54824 is a reply to message #54823] Wed, 11 July 2007 08:49 Go to previous message
Paolo Grigis is currently offline  Paolo Grigis
Messages: 171
Registered: December 2003
Senior Member
julia.kamenetzky@gmail.com wrote:
> I'm somewhat new to IDL, and attempting to create contour plots of
> sets of astronomical data. We'd like to interpolate data points based
> on the known Gaussian beam size. It seems to me like the only routine
> in IDL to accomplish this would be the Kriging method of GRIDDATA
> using Gaussian covariance? I have a few questions about this...
>

Probably you have a good reason for wanting to grid the data,
but just in case, since you mention this in conjunction with
contour, I'd like to point out that contour also works on
unstructured data.

Ciao,
Paolo
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Calculating a mean band
Next Topic: Size of image using tvscl?

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 19:22:25 PDT 2025

Total time taken to generate the page: 0.00593 seconds