Re: question about array interpolation [message #64743] |
Thu, 15 January 2009 01:17 |
Carsten Lechte
Messages: 124 Registered: August 2006
|
Senior Member |
|
|
Hu wrote:
> Yes, mike got it,we can replace 'zero's as other unmeaningful symbols,
> I just want to replace these unmeaningful symbols with interpolated
> values from the known values.
how about this:
IDL> x = [1,2,0,0,5,6,0,8,9, 0,9,8,0,0,0,0,3,2,0]
IDL> xi = where( x gt 0)
IDL> xv = x[xi]
IDL> print, xi, xv
0 1 4 5 7 8 10
11 16 17
1 2 5 6 8 9 9
8 3 2
good data is in xi, xv
IDL> yi = where( x eq 0)
IDL> yv = interpol( xv, xi, yi)
% Compiled module: INTERPOL.
IDL> print, yv
3 4 7 9 7 6 5
4 1
merge data in xv with yv:
IDL> y = x
IDL> y[yi] = yv
IDL> print, y
1 2 3 4 5 6 7
8 9 9 9 8 7
6 5 4 3 2 1
IDL>
note: this does not "complete the hill" in 8 9 0 9 8 to 8 9 10 9 8, but linearly
interpolates to 8 9 9 9 8.
chl
|
|
|
Re: question about array interpolation [message #64744 is a reply to message #64743] |
Thu, 15 January 2009 01:09  |
Carsten Lechte
Messages: 124 Registered: August 2006
|
Senior Member |
|
|
David Fanning wrote:
> x = [1,2,0,0,5,6,0,8,9, 0,9,8,0,0,0,0,3,2,0]
> y = [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]
I think he wants to interpolate where x is 0,
taking the non-zero elements of x as his data to
interpolate from, i.e. 1,2,0,0,5 becomes 1,2,3,4,5.
That does not explain why 9,0,9 beocmes 9,10,9.
chl
|
|
|
Re: question about array interpolation [message #64753 is a reply to message #64744] |
Wed, 14 January 2009 13:52  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On Jan 14, 1:54 pm, Hu <jha...@gmail.com> wrote:
> On Jan 14, 3:44 pm, "mgal...@gmail.com" <mgal...@gmail.com> wrote:
>
>
>
>> On Jan 14, 1:40 pm, David Fanning <n...@dfanning.com> wrote:
>
>>> Hu writes:
>>>> Oh, that's depressing.
>>>> I mean, it looks like a simple question, but really not.
>>>> anyway, thanks you, David.
>
>>> I'm clearly missing something. What looks simple to you?
>>> How would you describe what you want to do in words?
>
>>> x = [1,2,0,0,5,6,0,8,9, 0,9,8,0,0,0,0,3,2,0]
>>> y = [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]
>
>>> I just don't see any relationship between those
>>> two arrays at all. I've got to start eating more
>>> of the fish oil tablets or something.
>
>> I think the zeros are meant to be undefined values that should be
>> replaced by an interpolated value.
>
>> Mike
>> --www.michaelgalloy.com
>> Tech-X Corporation
>> Associate Research Scientist
>
> Yes, mike got it,we can replace 'zero's as other unmeaningful symbols,
> I just want to replace these unmeaningful symbols with interpolated
> values from the known values.
>
> sorry for any misunderstanding in my questions.
OK, how about:
ind = where(x ne 0, count, complement=c)
result = interpol(x[ind], ind, c)
y = x
y[c] = result
print, y
Mike
--
www.michaelgalloy.com
Tech-X Corporation
Associate Research Scientist
|
|
|
Re: question about array interpolation [message #64755 is a reply to message #64753] |
Wed, 14 January 2009 12:54  |
Hu
Messages: 35 Registered: January 2009
|
Member |
|
|
On Jan 14, 3:44 pm, "mgal...@gmail.com" <mgal...@gmail.com> wrote:
> On Jan 14, 1:40 pm, David Fanning <n...@dfanning.com> wrote:
>
>> Hu writes:
>>> Oh, that's depressing.
>>> I mean, it looks like a simple question, but really not.
>>> anyway, thanks you, David.
>
>> I'm clearly missing something. What looks simple to you?
>> How would you describe what you want to do in words?
>
>> x = [1,2,0,0,5,6,0,8,9, 0,9,8,0,0,0,0,3,2,0]
>> y = [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]
>
>> I just don't see any relationship between those
>> two arrays at all. I've got to start eating more
>> of the fish oil tablets or something.
>
> I think the zeros are meant to be undefined values that should be
> replaced by an interpolated value.
>
> Mike
> --www.michaelgalloy.com
> Tech-X Corporation
> Associate Research Scientist
Yes, mike got it,we can replace 'zero's as other unmeaningful symbols,
I just want to replace these unmeaningful symbols with interpolated
values from the known values.
sorry for any misunderstanding in my questions.
|
|
|
|
Re: question about array interpolation [message #64757 is a reply to message #64756] |
Wed, 14 January 2009 12:44  |
Michael Galloy
Messages: 1114 Registered: April 2006
|
Senior Member |
|
|
On Jan 14, 1:40 pm, David Fanning <n...@dfanning.com> wrote:
> Hu writes:
>> Oh, that's depressing.
>> I mean, it looks like a simple question, but really not.
>> anyway, thanks you, David.
>
> I'm clearly missing something. What looks simple to you?
> How would you describe what you want to do in words?
>
> x = [1,2,0,0,5,6,0,8,9, 0,9,8,0,0,0,0,3,2,0]
> y = [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]
>
> I just don't see any relationship between those
> two arrays at all. I've got to start eating more
> of the fish oil tablets or something.
I think the zeros are meant to be undefined values that should be
replaced by an interpolated value.
Mike
--
www.michaelgalloy.com
Tech-X Corporation
Associate Research Scientist
|
|
|
Re: question about array interpolation [message #64758 is a reply to message #64757] |
Wed, 14 January 2009 12:40  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Hu writes:
> Oh, that's depressing.
> I mean, it looks like a simple question, but really not.
> anyway, thanks you, David.
I'm clearly missing something. What looks simple to you?
How would you describe what you want to do in words?
x = [1,2,0,0,5,6,0,8,9, 0,9,8,0,0,0,0,3,2,0]
y = [1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]
I just don't see any relationship between those
two arrays at all. I've got to start eating more
of the fish oil tablets or something.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: question about array interpolation [message #64759 is a reply to message #64758] |
Wed, 14 January 2009 12:16  |
Hu
Messages: 35 Registered: January 2009
|
Member |
|
|
On Jan 14, 3:03 pm, David Fanning <n...@dfanning.com> wrote:
> Hu writes:
>> Supposing that I got an array X=[1,2,
>> 0,0,5,6,0,8,9,0,9,8,0,0,0,0,3,2,0] ,is there any functions in IDL that
>> can change array X into Y=[1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1] ?
>
>> at first, I through it looks like an interpolation question, but after
>> I tried a few interpolation functions like INTERPOLATE, INTERPOL . I
>> do not get the ideal answer, So... post it here
>
> I'm pretty sure there is no function on Earth that can
> convert X into Y, but I'm waiting with bated breath,
> just like you. :-)
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Oh, that's depressing.
I mean, it looks like a simple question, but really not.
anyway, thanks you, David.
|
|
|
Re: question about array interpolation [message #64760 is a reply to message #64759] |
Wed, 14 January 2009 12:03  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Hu writes:
> Supposing that I got an array X=[1,2,
> 0,0,5,6,0,8,9,0,9,8,0,0,0,0,3,2,0] ,is there any functions in IDL that
> can change array X into Y=[1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1] ?
>
> at first, I through it looks like an interpolation question, but after
> I tried a few interpolation functions like INTERPOLATE, INTERPOL . I
> do not get the ideal answer, So... post it here
I'm pretty sure there is no function on Earth that can
convert X into Y, but I'm waiting with bated breath,
just like you. :-)
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|