Re: Interpolation problem [message #36907 is a reply to message #36824] |
Tue, 04 November 2003 03:26   |
sdj
Messages: 20 Registered: November 2003
|
Junior Member |
|
|
Thank you for the help, yes your program indeed does the trick.
The only minor thing I had to change was to set the valid data NE to
-1 AND NE to -9999 (see my original message), and then overwrite the
interpolated values of the -9999 indices with the original data.
Thus, I end up interpolating the missing values without taking into
account the non-valid ones.
PRO test2
; Make a data set
n = 100
data = SIN( FINDGEN(n,n)/n^2 )
; Missing data
mx = RANDOMU(1, n, /LONG) MOD n^2
data[mx] = -1
; Non-valid data
nv = RANDOMU(2, n, /LONG) MOD n^2
data[nv] = -9999
valid = WHERE(data NE -1 AND data NE -9999)
ix = valid MOD n
iy = valid / n
; Fill in missing data
TRIANGULATE,ix,iy,tr
new = TRIGRID(ix, iy, data[valid],tr, NX = n, NY = n)
;Reset non-valid values equal to -9999
new[nv] = data[nv]
Again, thanks for your help.
Hasta lluego,
Pepe
the_cacc@hotmail.com (trouble) wrote in message news:<5f9f0a23.0311031206.167c106a@posting.google.com>...
> sdj@tiscali.it (Pepe) wrote in message news:<56bc95a7.0311030321.42de483d@posting.google.com>...
>>
>> I have a 2-d array on a regular grid with valid values which are all
>> +ve. Non valid values are set to -9999 and some 'intermediate' values
>> I would like to interpolate are set to -1.
>
> It sounds like you may be mis-understanding the MISSING keyword in
> interpolate. In fact, you may want to be using different functions
> altogther: TRIANGULATE & TRIGRID.
>
> Try the program below and see if it's what you're looking for.
>
> Ciao.
>
> ;--------------------------------------------------
> PRO test
>
> ; Make a data set
> n = 100
> data = SIN( FINDGEN(n,n)/n^2 )
>
> ; Missing data
> mx = RANDOMU(1,n,/LONG) MOD n^2
> data[mx] = -1
> valid = WHERE(data NE -1)
> ix = valid MOD n
> iy = valid / n
>
> ; Fill in missing data
> TRIANGULATE,ix,iy,tr
> new = TRIGRID(ix,iy,data[valid],tr,NX=n,NY=n)
>
> ; Display.
> tvscl,data >0
> tvscl,new
>
> END
> ;------------------------------------------------
|
|
|