Re: resampling on irregular grid [message #80380] |
Fri, 08 June 2012 06:00 |
natha
Messages: 482 Registered: October 2007
|
Senior Member |
|
|
When I re-sampling grids I normally use nearest neighbour interpolation. I create a matrix with the "projection" indices.
Something like :
FOR i=0l, N_ELEMENTS(lon_cart)-1 DO BEGIN
diff=(lon1-lon_cart[i])^2.+(lat1-lat_cart[i])^2.
min_latlon=MIN(diff,pos)
IF min_latlon LE tol THEN BEGIN
cart_xindex[i]=(pos MOD nlon)
cart_yindex[i]=(pos / nlon) + yy_ini
ENDIF
ENDFOR
This loop normally takes a lot of time but if one of your grids is regular you can improve it.
Hope this will help !
nata
|
|
|
Re: resampling on irregular grid [message #80382 is a reply to message #80380] |
Fri, 08 June 2012 04:18  |
Fabzi
Messages: 305 Registered: July 2010
|
Senior Member |
|
|
On 06/08/2012 06:38 AM, bing999 wrote:
> Hi,
>
> Thanks. Actually it is not an interpolation, as INTERPOL does it, that
> I want. It is really a resampling of my data on another grid. I need
> to conserve total(data).
> I agree my previous comment with f(x1,y1), etc, could have been
> misleading, sorry.
>
> I can achieve this with histogram functions for instance but it is not
> quite efficient...
You could try VALUE_LOCATE, maybe...
Fab
|
|
|
Re: resampling on irregular grid [message #80384 is a reply to message #80382] |
Thu, 07 June 2012 21:38  |
Thibault Garel
Messages: 55 Registered: October 2009
|
Member |
|
|
Hi,
Thanks. Actually it is not an interpolation, as INTERPOL does it, that
I want. It is really a resampling of my data on another grid. I need
to conserve total(data).
I agree my previous comment with f(x1,y1), etc, could have been
misleading, sorry.
I can achieve this with histogram functions for instance but it is not
quite efficient...
Cheers
> It sound like you just need to interpolate, e.g.
>
> IDL> d2 = interpol(d1,x1,x2)
>
> where x1,d1 are the input function points, and x2 is the output abscissa
>
>
>
>
>
>
>
> On Thursday, June 7, 2012 10:16:08 PM UTC-4, bing999 wrote:
>> Thanks Fab.
>
>> I tried GRIDDATA, but it works only for interpolation of surfaces,
>> i.e. it recomputes f(x,y) from (x1,y1) coordinates to (x2,y2)
>> coordinates. What I need is resampling a 1D array of data values,
>> initially binned on a x1 values, to x2 values. (with both x1 and x2
>> being two different irregular grids).
>
>> Cheers
>
>>> Hi,
>
>>> Try GRIDDATA.
>
>>> Cheers,
>
>>> Fab
|
|
|
Re: resampling on irregular grid [message #80385 is a reply to message #80384] |
Thu, 07 June 2012 20:52  |
wlandsman
Messages: 743 Registered: June 2000
|
Senior Member |
|
|
It sound like you just need to interpolate, e.g.
IDL> d2 = interpol(d1,x1,x2)
where x1,d1 are the input function points, and x2 is the output abscissa
On Thursday, June 7, 2012 10:16:08 PM UTC-4, bing999 wrote:
> Thanks Fab.
>
> I tried GRIDDATA, but it works only for interpolation of surfaces,
> i.e. it recomputes f(x,y) from (x1,y1) coordinates to (x2,y2)
> coordinates. What I need is resampling a 1D array of data values,
> initially binned on a x1 values, to x2 values. (with both x1 and x2
> being two different irregular grids).
>
> Cheers
>
>
>>
>> Hi,
>>
>> Try GRIDDATA.
>>
>> Cheers,
>>
>> Fab
|
|
|
Re: resampling on irregular grid [message #80387 is a reply to message #80385] |
Thu, 07 June 2012 19:16  |
Thibault Garel
Messages: 55 Registered: October 2009
|
Member |
|
|
Thanks Fab.
I tried GRIDDATA, but it works only for interpolation of surfaces,
i.e. it recomputes f(x,y) from (x1,y1) coordinates to (x2,y2)
coordinates. What I need is resampling a 1D array of data values,
initially binned on a x1 values, to x2 values. (with both x1 and x2
being two different irregular grids).
Cheers
>
> Hi,
>
> Try GRIDDATA.
>
> Cheers,
>
> Fab
|
|
|
Re: resampling on irregular grid [message #80392 is a reply to message #80387] |
Thu, 07 June 2012 03:53  |
Fabzi
Messages: 305 Registered: July 2010
|
Senior Member |
|
|
On 06/07/2012 04:25 AM, bing999 wrote:
> Hi,
>
> I would like to resample an array A, from an irregular grid to another
> one .
>
> The 1st column A[0,*] (= the x-axis) is irregularly binned, and the
> 2nd column A[1,*] contains the corresponding y-axis values.
> I just want to resample the 2nd column A[1,*] according to another x-
> axis irregular grid, with P elements instead of N.
>
> This operation doesn't look quite complicated to perform, but I was
> wondering if there exists an optimized IDL function doing this.
> (especially because I have to deal with large arrays and I want the
> operation to be efficient...). REBIN and CONGRID seem to work only on
> regular arrays...
>
> Any idea?
> Thanks!
Hi,
Try GRIDDATA.
Cheers,
Fab
|
|
|