Re: elegant array index expansion using INTERPOLATE [message #58040] |
Fri, 11 January 2008 14:32 |
Bob[3]
Messages: 60 Registered: December 2006
|
Member |
|
|
On Jan 11, 5:07 pm, "Ryan." <rchug...@brutus.uwaterloo.ca> wrote:
> > Isn't array[expidxrange] just array[3:6] or
>
>> array[idxrange[0]:idxrange[1]] ?
>> ...or are you after the explicit list of expidxrange?
>
> Hi Bob,
>
> 'expidxrange' is just a 2-element array. I find the indices using
> another method and throw them into a 2-element array. I ultimately need
> to extract the explicit list of elements from 'array'.
>
> Ryan.
Looked to me like expidxrange was the 4 element array [3,4,5,6] in
your example and
idxrange was the 2 element array giving the endpoints of expidxrange.
Anyway, using the ':' notation on your array should get you your list
of elements without having to calculate an explicit list of indexes
(since you want all indexes between the endpoints).
Bob.
|
|
|
Re: elegant array index expansion using INTERPOLATE [message #58042 is a reply to message #58040] |
Fri, 11 January 2008 14:07  |
Ryan.
Messages: 77 Registered: March 2006
|
Member |
|
|
> Isn't array[expidxrange] just array[3:6] or
> array[idxrange[0]:idxrange[1]] ?
> ...or are you after the explicit list of expidxrange?
Hi Bob,
'expidxrange' is just a 2-element array. I find the indices using
another method and throw them into a 2-element array. I ultimately need
to extract the explicit list of elements from 'array'.
Ryan.
|
|
|
Re: elegant array index expansion using INTERPOLATE [message #58043 is a reply to message #58042] |
Fri, 11 January 2008 13:56  |
Bob[3]
Messages: 60 Registered: December 2006
|
Member |
|
|
On Jan 11, 3:33 pm, "Ryan." <rchug...@brutus.uwaterloo.ca> wrote:
> Hi All,
>
> If I have a range of array indices I want to be able to interpolate
> between this to get all indices in between. What is an elegant way of
> doing this?
>
> Here is an example of what I want:
>
> array = [0,2,4,6,8,10,12,14,16,18]
> idxrange = [3, 6]
>
> expidxrange = Interpolate('idxrange') to get [3,4,5,6]
>
> so that I can get
> array[expidxrange] OR [6,8,10,12]
>
> I would like it to be as general as possible. This is what I have, but
> it doesn't work for a range of 1:
>
> expidxrange = INTERPOLATE(idx, $
> (1./(idxrange[1]-idxrange[0])*FINDGEN(idxrange[1]-idxrange[0 ]) ) )
>
> Any thoughts?
>
> Ryan.
Isn't array[expidxrange] just array[3:6] or
array[idxrange[0]:idxrange[1]] ?
...or are you after the explicit list of expidxrange?
Bob.
|
|
|
|
Re: elegant array index expansion using INTERPOLATE [message #58048 is a reply to message #58045] |
Fri, 11 January 2008 12:45  |
Vince Hradil
Messages: 574 Registered: December 1999
|
Senior Member |
|
|
On Jan 11, 2:33 pm, "Ryan." <rchug...@brutus.uwaterloo.ca> wrote:
> Hi All,
>
> If I have a range of array indices I want to be able to interpolate
> between this to get all indices in between. What is an elegant way of
> doing this?
>
> Here is an example of what I want:
>
> array = [0,2,4,6,8,10,12,14,16,18]
> idxrange = [3, 6]
>
> expidxrange = Interpolate('idxrange') to get [3,4,5,6]
>
> so that I can get
> array[expidxrange] OR [6,8,10,12]
>
> I would like it to be as general as possible. This is what I have, but
> it doesn't work for a range of 1:
>
> expidxrange = INTERPOLATE(idx, $
> (1./(idxrange[1]-idxrange[0])*FINDGEN(idxrange[1]-idxrange[0 ]) ) )
>
> Any thoughts?
>
> Ryan.
Do you want:
expidxrange = lindgen(idxrange[1]-idxrange[0]+1)+idxrange[0]
|
|
|