connect the dots . . . A question [message #33821] |
Mon, 03 February 2003 17:21  |
Sean Raffuse
Messages: 46 Registered: July 2001
|
Member |
|
|
Hello venerable newsgroup.
I have an algorithmic question.
I'd like to interpolate values for everywhere in an array that I don't have
data. e.g.
myFullArray = intarr(12)
values = [10,20,30,20] ;the values I do have
indexes = [2,4,6,10] ;the locations associated with these values
In other words, I want to turn this [?,?,10,?,20,?,30,?,?,?,20,?]
into this [10,10,10,15,20,25,30,28,25,23,20,20]
Any thoughts?
Thanks in advance,
Sean
|
|
|
Re: connect the dots . . . A question [message #33905 is a reply to message #33821] |
Tue, 04 February 2003 07:42  |
Sean Raffuse
Messages: 46 Registered: July 2001
|
Member |
|
|
"Thomas Gutzler" <tgutzler@ee.uwa.edu.au> wrote in message
news:3E3F25C5.4040206@ee.uwa.edu.au...
> Sean Raffuse wrote:
>> Hello venerable newsgroup.
>
>
> You might need.
> newindexes = indgen(12)
> myFullArray = INTERPOL(values,indexes,newindexes)
>
> which gives you an interpolated result:
> [0, 5, 10, 15, 20, 25, 30, 28, 25, 23, 20, 18]
>
> If you really want to get rid of the interpolated values at the indexes
> 0, 1 and 11 ... well
>
> changeme = VALUE_LOCATE(indexes,newindexes)
> myFullArray[WHERE(changeme LT 0)] = values[0]
> myFullArray[WHERE(changeme GT N_ELEMENTS(values)-2)] =
> values[N_ELEMENTS(values)-1]
> or, as I've learned :)
> myFullArray[WHERE(changeme GT N_ELEMENTS(values)-2)] =
> (values[[2147483647L]])[0]
>
> Result:
> [10, 10, 10, 15, 20, 25, 30, 28, 25, 23, 20, 20]
>
> Maybe this can be done better :)
>
> Tom
Thanks! That may be what I'm looking for. It is important for the values
outside the first and last known values not be interpolated.
>
|
|
|
Re: connect the dots . . . A question [message #33918 is a reply to message #33821] |
Mon, 03 February 2003 18:30  |
Thomas Gutzler
Messages: 44 Registered: November 2002
|
Member |
|
|
Sean Raffuse wrote:
> Hello venerable newsgroup.
Hi Sean
> I have an algorithmic question.
>
> I'd like to interpolate values for everywhere in an array that I don't have
> data. e.g.
>
> myFullArray = intarr(12)
> values = [10,20,30,20] ;the values I do have
> indexes = [2,4,6,10] ;the locations associated with these values
>
> In other words, I want to turn this [?,?,10,?,20,?,30,?,?,?,20,?]
>
> into this [10,10,10,15,20,25,30,28,25,23,20,20]
>
> Any thoughts?
You might need.
newindexes = indgen(12)
myFullArray = INTERPOL(values,indexes,newindexes)
which gives you an interpolated result:
[0, 5, 10, 15, 20, 25, 30, 28, 25, 23, 20, 18]
If you really want to get rid of the interpolated values at the indexes
0, 1 and 11 ... well
changeme = VALUE_LOCATE(indexes,newindexes)
myFullArray[WHERE(changeme LT 0)] = values[0]
myFullArray[WHERE(changeme GT N_ELEMENTS(values)-2)] =
values[N_ELEMENTS(values)-1]
or, as I've learned :)
myFullArray[WHERE(changeme GT N_ELEMENTS(values)-2)] =
(values[[2147483647L]])[0]
Result:
[10, 10, 10, 15, 20, 25, 30, 28, 25, 23, 20, 20]
Maybe this can be done better :)
Tom
|
|
|