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

Home » Public Forums » archive » Re: what is the best way to do a surface (or 2D) interpolation?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: what is the best way to do a surface (or 2D) interpolation? [message #62697] Wed, 24 September 2008 04:01 Go to previous message
paulartcoelho is currently offline  paulartcoelho
Messages: 30
Registered: March 2007
Member
hi brian,

thanks for your reply.

krig2d i couldn't make work, it returns a flat new grid with a weird
value. but i'll confess that i haven't understood a word of the "Model
Parameter Keywords" so i just took the same parameters of the example,
duh.

the method in
> "An Alternative Gridding
> Method" section from http://www.dfanning.com/code_tips/griddata.html.

is giving me promising results. i can obtain a new_grid that is
similar to the original, but i'm struggling a bit with the details
now. values that were low in the original grid, say <~ 10 will
disappear in the new one, i guess because i have too many zeros
around. if i try the cubic=-0.5 suggested in the help to improve the
reconstruction, i'll end up with values below 0 in some bins (no
negative values in the original). also i noticed that:

IDL> print,total(grid)
100.000

IDL> print,total(new_grid)
61.3827

i can re-normalize the new_grid to 100, but that won't retrieve the
lost low values, of course.

> One word of caution is that interpolation is great "inside" the range
> where you have data, however "outside" the region is extrapolation and
> is fraught with issues. I mean that your x's
> IDL> print,vz
> -1.62839 -1.23045 -0.628389 -0.327359 0.0483046
> 0.246672
> and the new x's that you want
> newx = [-2.0, -1.5, -1.0, -0.5, 0.0, 0.5]
> some are outside and you need to be a little careful that the answer
> actually makes sense as if often (maybe stronger than often) doesn't.

you're right. i have several sets of data and some of them can go out
to extreme values. but for the data that don't, i'd just need the
values there to be assumed to be zero. i thought i could do that just
adding the missing = 0 keyword in interpolate, but if i do that i end
up with a flat new_grid = 0. i wonder now if i should prepare the
original data before applying the interpolation, say extend it with
zeros myself?

i'm copying below what i'm doing:

IN_X FLOAT = Array[16]
IN_Y FLOAT = Array[6]
GRID FLOAT = Array[16, 6]

IDL> print,in_x
8.00000 8.14613 8.30103 8.44716 8.60206
8.74819 8.89763 9.04922 9.19866 9.35025
9.49969 9.65031
9.80003 9.94988 10.1000 10.2000

IDL> print,in_y
-1.62839 -1.23045 -0.628389 -0.327359 0.0483046
0.246672

IDL> print,grid
0.00000 26.1465 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000
0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000
0.00000 0.00000 0.00000 0.820449
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000
0.00000 0.00000 0.00000 0.00000
0.00000 2.53796 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000
0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000
0.00000 0.00000 0.00000 61.5708
0.00000 0.00000 0.00000 0.00000 0.00000
0.00000 0.00000 8.92427 0.00000 0.00000
0.00000 0.00000
0.00000 0.00000 0.00000 0.00000

out_x = [6.0,6.5,7.0,7.5,8.0,8.5,9.0,9.5,10.0,10.5]
out_y = [-2.0,-1.5,-1.0,-0.5,0.,0.5]
nx = n_elements(out_x)
ny = n_elements(out_y)
x = Interpol(Findgen(N_Elements(in_x)), in_x, out_x)
y = Interpol(Findgen(N_Elements(in_y)), in_y, out_y)
xx = Rebin(x, nx, ny, /SAMPLE)
yy = Rebin(Reform(y, 1, ny), nx, ny, /SAMPLE)
new_grid = interpolate(grid,xx,yy)


> Sorry to hijack your post Paula,

oh, be my guest :)

cheers,
paula
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Getting array indices
Next Topic: giving input to fortran program using spawn in IDL

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

Current Time: Wed Oct 08 14:07:16 PDT 2025

Total time taken to generate the page: 0.00258 seconds