Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Idl-pvware > Re: GRIDDATA wo...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 28 Topic 5497 of 6400
Post > Topic >>

Re: GRIDDATA woes

by David Fanning <news@[EMAIL PROTECTED] > Mar 5, 2008 at 07:57 AM

Kenneth P. Bowman writes:

> VALUE_LOCATE finds the index of the point less than or equal to the
search
> value.  You are trying to interpolate exactly to the last point.  This
> code correctly computes the index of that point to be 7, but there
> is no point 8 to use for the interpolation.  This can be solved
> like this
> 
> IDL> lat = [-87.5, 50, 25, 0, 30, 45, 64, 87.5]
> IDL> y = Scale_Vector(findgen(7), -87.5, 87.499)    <------
> IDL> j = Value_Locate(lat, y)
> IDL> yj = j + (y - lat[j])/(lat[j+1] - lat[j]) 
> IDL> PRINT, yj
>       0.00000     0.212120     0.424240     0.636360      3.97220
>       5.70171      6.99996
> 
> Unfortunately, INTERPOLATE does not extrapolate when you are outside
> the domain of the function.

I'm going to agree with Ben, and keep VALUE_LOCATE out of it.
But, I've also used Paolo's suggestion. Here is code that I think
works well for me, and allows me to create any sized grid I
want.

In the code, lat is a 48-element vector that is irregularly
spaced, lon is a 96-element vector, that is regularly 
spaced, except for the two end members, and sit is the
2D array I wish to resample. In this code, I am trying to
resample to a 360x180 array, to make it consistent with other
arrays I have available to me.

   nx = 360 
   ny = 180 
   slon = Scale_Vector(Findgen(nx), 0.5, 359.5)
   slat = Scale_Vector(Findgen(ny), Min(lat), Max(lat))
   x = Interpol(Findgen(N_Elements(lon)), lon, slon)
   y = Interpol(Findgen(N_Elements(lat)), lat, slat)
   xx = Rebin(x, nx, ny, /SAMPLE)
   yy = Rebin(Reform(y, 1, ny), nx, ny)
   
   resampledArray = Interpolate(sit, xx, yy)

Even in this "worst case" scenario, I seem to get reasonably good
results. I *really* like that INTERPOL way of getting fractional
indices!

Cheers,

David

-- 
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Se****e ma de ni thui. ("Perhaps thou speakest truth.")
 




 28 Posts in Topic:
GRIDDATA woes
"ben.bighair" &  2008-03-02 18:57:27 
Re: GRIDDATA woes
Bill Gallery <wgallery  2008-03-03 11:00:55 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-04 10:05:13 
Re: GRIDDATA woes
"Kenneth P. Bowman&q  2008-03-03 08:24:14 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-04 08:35:55 
Re: GRIDDATA woes
"Kenneth P. Bowman&q  2008-03-04 21:04:16 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-04 22:04:32 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-04 12:49:54 
Re: GRIDDATA woes
"Kenneth P. Bowman&q  2008-03-04 20:55:19 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-05 07:57:59 
Re: GRIDDATA woes
Kenneth Bowman <k-bowm  2008-03-05 10:05:10 
Re: GRIDDATA woes
Kenneth Bowman <k-bowm  2008-03-05 08:14:03 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-04 14:14:37 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-04 09:03:31 
Re: GRIDDATA woes
"ben.bighair" &  2008-03-04 08:05:59 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-04 10:14:46 
Re: GRIDDATA woes
"Kenneth P. Bowman&q  2008-03-04 21:02:39 
Re: GRIDDATA woes
James Kuyper <jameskuy  2008-03-05 11:38:10 
Re: GRIDDATA woes
"Kenneth P. Bowman&q  2008-03-05 07:46:41 
Re: GRIDDATA woes
Brian Larsen <balarsen  2008-03-04 08:23:04 
Re: GRIDDATA woes
Bill Gallery <wgallery  2008-03-04 09:43:26 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-04 10:54:50 
Re: GRIDDATA woes
Bill Gallery <wgallery  2008-03-04 14:17:35 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-04 16:58:42 
Re: GRIDDATA woes
pgrigis@[EMAIL PROTECTED]  2008-03-04 14:39:31 
Re: GRIDDATA woes
"ben.bighair" &  2008-03-04 14:46:46 
Re: GRIDDATA woes
"ben.bighair" &  2008-03-04 19:14:26 
Re: GRIDDATA woes
David Fanning <news@[E  2008-03-04 22:10:22 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Nov 19 10:15:46 CST 2008.