list concatenation [message #92775] |
Fri, 26 February 2016 07:00  |
greg.addr
Messages: 160 Registered: May 2007
|
Senior Member |
|
|
I've accumulated a list of variable length arrays, e.g.
IDL> diam
[
[0.13860799, 0.035755500, 0.037822500],
[0.17081800],
[0.28975499, 0.050387200, 0.053300999],
[2.6970799, 1.3410200, 0.60130101],
[0.64086902, 0.61904001, 0.66626000, 0.27435899],
[0.86649197, 0.71003902],
[0.83967102, 0.47101700],
[0.18503401],
...
Is there a nice way to flatten this into a 1D array?
cheers,
Greg
|
|
|
Re: list concatenation [message #92777 is a reply to message #92775] |
Fri, 26 February 2016 08:04   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
http://www.harrisgeospatial.com/docs/LIST.html#ToArrayMethod
?
On 02/26/16 10:00, greg.addr@googlemail.com wrote:
>
> I've accumulated a list of variable length arrays, e.g.
>
> IDL> diam
> [
> [0.13860799, 0.035755500, 0.037822500],
> [0.17081800],
> [0.28975499, 0.050387200, 0.053300999],
> [2.6970799, 1.3410200, 0.60130101],
> [0.64086902, 0.61904001, 0.66626000, 0.27435899],
> [0.86649197, 0.71003902],
> [0.83967102, 0.47101700],
> [0.18503401],
>
> ...
>
>
> Is there a nice way to flatten this into a 1D array?
>
> cheers,
> Greg
>
|
|
|
Re: list concatenation [message #92778 is a reply to message #92777] |
Fri, 26 February 2016 08:08   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
I was curious as to how this works (never used the ToArray method):
IDL> l = LIST(Findgen(3), Findgen(12), Findgen(5))
IDL> l
[
[0.0000000, 1.0000000, 2.0000000],
[0.0000000, 1.0000000, 2.0000000, 3.0000000, 4.0000000, 5.0000000,
6.0000000, 7.0000000, 8.0000000, 9.0000000, 10.000000, 11.000000],
[0.0000000, 1.0000000, 2.0000000, 3.0000000, 4.0000000]
]
IDL> help, l.toarray()
% LIST::TOARRAY: Unable to concatenate arrays: Element 1
% Execution halted at: $MAIN$
Nup. How about the DIMENSION keyword?
IDL> help, l.toarray(dimension=1)
<Expression> FLOAT = Array[20]
Huh. Cool.
On 02/26/16 11:04, Paul van Delst wrote:
> http://www.harrisgeospatial.com/docs/LIST.html#ToArrayMethod
>
> ?
>
> On 02/26/16 10:00, greg.addr@googlemail.com wrote:
>>
>> I've accumulated a list of variable length arrays, e.g.
>>
>> IDL> diam
>> [
>> [0.13860799, 0.035755500, 0.037822500],
>> [0.17081800],
>> [0.28975499, 0.050387200, 0.053300999],
>> [2.6970799, 1.3410200, 0.60130101],
>> [0.64086902, 0.61904001, 0.66626000, 0.27435899],
>> [0.86649197, 0.71003902],
>> [0.83967102, 0.47101700],
>> [0.18503401],
>>
>> ...
>>
>>
>> Is there a nice way to flatten this into a 1D array?
>>
>> cheers,
>> Greg
>>
|
|
|
Re: list concatenation [message #92779 is a reply to message #92778] |
Fri, 26 February 2016 08:29  |
greg.addr
Messages: 160 Registered: May 2007
|
Senior Member |
|
|
On Friday, February 26, 2016 at 5:08:36 PM UTC+1, Paul van Delst wrote:
> I was curious as to how this works (never used the ToArray method):
>
> IDL> l = LIST(Findgen(3), Findgen(12), Findgen(5))
> IDL> l
> [
> [0.0000000, 1.0000000, 2.0000000],
> [0.0000000, 1.0000000, 2.0000000, 3.0000000, 4.0000000, 5.0000000,
> 6.0000000, 7.0000000, 8.0000000, 9.0000000, 10.000000, 11.000000],
> [0.0000000, 1.0000000, 2.0000000, 3.0000000, 4.0000000]
> ]
> IDL> help, l.toarray()
> % LIST::TOARRAY: Unable to concatenate arrays: Element 1
> % Execution halted at: $MAIN$
>
>
> Nup. How about the DIMENSION keyword?
>
> IDL> help, l.toarray(dimension=1)
> <Expression> FLOAT = Array[20]
>
> Huh. Cool.
>
>
> On 02/26/16 11:04, Paul van Delst wrote:
>> http://www.harrisgeospatial.com/docs/LIST.html#ToArrayMethod
>>
>> ?
>>
>> On 02/26/16 10:00, wrote:
>>>
>>> I've accumulated a list of variable length arrays, e.g.
>>>
>>> IDL> diam
>>> [
>>> [0.13860799, 0.035755500, 0.037822500],
>>> [0.17081800],
>>> [0.28975499, 0.050387200, 0.053300999],
>>> [2.6970799, 1.3410200, 0.60130101],
>>> [0.64086902, 0.61904001, 0.66626000, 0.27435899],
>>> [0.86649197, 0.71003902],
>>> [0.83967102, 0.47101700],
>>> [0.18503401],
>>>
>>> ...
>>>
>>>
>>> Is there a nice way to flatten this into a 1D array?
>>>
>>> cheers,
>>> Greg
>>>
Thanks, Paul - I should have seen that!
|
|
|