comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » list concatenation
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
list concatenation [message #92775] Fri, 26 February 2016 07:00 Go to next message
greg.addr is currently offline  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 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  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 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  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 Go to previous message
greg.addr is currently offline  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!
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: AWK inside idl
Next Topic: Running a code multiple times automatically

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Wed Oct 08 15:26:47 PDT 2025

Total time taken to generate the page: 0.00650 seconds