Go Back   Rhinocerus > Newsgroup > Newsgroup comp.lang.* 1 > Newsgroup comp.lang.idl-pvwave

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-29-2012, 11:02 AM
rjp23@le.ac.uk
Guest
 
Posts: n/a
Default Array Concatenation?

Hi

I have two 4 dimensional arrays like so:

Array[480, 241, 60, 124]

The 4th dimension (124 elements) is time. I want to concatenate the 1st timestep for the second array to the first array, something like this:


new=[array1, array2[*, *, *, 0]]

But I can't get the syntax correct to do the concatenation on the 4th dimension.

Any ideas what I'm doing wrong? I've tried various levels of []'s but can't get it working.

Cheers
Reply With Quote
Alt Today
Advertising
 
and become member of Rhinocerus
Standard Sponsored Links

  #2 (permalink)  
Old 06-29-2012, 02:46 PM
alx
Guest
 
Posts: n/a
Default Re: Array Concatenation?

On 29 juin, 13:02, rj...@le.ac.uk wrote:
> Hi
>
> I have two 4 dimensional arrays like so:
>
> Array[480, 241, 60, 124]
>
> The 4th dimension (124 elements) is time. I want to concatenate the 1st timestep for the second array to the first array, something like this:
>
> new=[array1, array2[*, *, *, 0]]
>
> But I can't get the syntax correct to do the concatenation on the 4th dimension.
>
> Any ideas what I'm doing wrong? I've tried various levels of []'s but can't get it working.
>
> Cheers
>
>


IDL concatenates arrays over the first dimension by using [array1,
array2] construct.
To achieve concatenation in your case, you might transpose your arrays
first, then transpose the result back, as follows:

new = transpose([transpose(array1), (transpose(array2))[0,*,*,*])

The second array must be transposed before you select last column
elements to avoid implicit elimination by IDL of the last dimension in
array2[*,*,*,0].

alain.
Reply With Quote
  #3 (permalink)  
Old 06-29-2012, 06:16 PM
Heinz Stege
Guest
 
Posts: n/a
Default Re: Array Concatenation?

On Fri, 29 Jun 2012 04:02:28 -0700 (PDT), rjp23@le.ac.uk wrote:

>Hi
>
>I have two 4 dimensional arrays like so:
>
>Array[480, 241, 60, 124]
>
>The 4th dimension (124 elements) is time. I want to concatenate the 1st timestep for the second array to the first array, something like this:
>
>
>new=[array1, array2[*, *, *, 0]]
>
>But I can't get the syntax correct to do the concatenation on the 4th dimension.
>
>Any ideas what I'm doing wrong? I've tried various levels of []'s but can't get it working.
>
>Cheers


David Fanning has written an article about this:
http://www.idlcoyote.com/tips/array_concatenation.html

HTH, Heinz
Reply With Quote
  #4 (permalink)  
Old 07-11-2012, 09:10 AM
Rob
Guest
 
Posts: n/a
Default Re: Array Concatenation?

On Friday, June 29, 2012 7:16:33 PM UTC+1, Heinz Stege wrote:
> On Fri, 29 Jun 2012 04:02:28 -0700 (PDT), rjp23@le.ac.uk wrote:
>
> >Hi
> >
> >I have two 4 dimensional arrays like so:
> >
> >Array[480, 241, 60, 124]
> >
> >The 4th dimension (124 elements) is time. I want to concatenate the 1st timestep for the second array to the first array, something like this:
> >
> >
> >new=[array1, array2[*, *, *, 0]]
> >
> >But I can't get the syntax correct to do the concatenation on the4th dimension.
> >
> >Any ideas what I'm doing wrong? I've tried various levels of []'s but can't get it working.
> >
> >Cheers
>
> David Fanning has written an article about this:
> http://www.idlcoyote.com/tips/array_concatenation.html
>
> HTH, Heinz


Unfortunately I believe the caveat to that article applies here:

"One caveat: a bug in IDL (as I see it) limits the practical concatenation dimension to 3, even though up to 8 dimensions are supported (i.e. only twopairs of extra brackets are allowed per entry... sorry no [[[[[[[a]]]]]]] permitted). You'll need higher magic if you use 8 dimensional datasets anyway. "

I guess what I was really asking was what this "higher magic" was.
Reply With Quote
  #5 (permalink)  
Old 07-11-2012, 11:15 AM
Heinz Stege
Guest
 
Posts: n/a
Default Re: Array Concatenation?

On Wed, 11 Jul 2012 02:10:33 -0700 (PDT), Rob wrote:

>On Friday, June 29, 2012 7:16:33 PM UTC+1, Heinz Stege wrote:
>>
>> David Fanning has written an article about this:
>> http://www.idlcoyote.com/tips/array_concatenation.html
>>
>> HTH, Heinz

>
>Unfortunately I believe the caveat to that article applies here:
>
>"One caveat: a bug in IDL (as I see it) limits the practical concatenation dimension to 3, even though up to 8 dimensions are supported (i.e. only two pairs of extra brackets are allowed per entry... sorry no [[[[[[[a]]]]]]] permitted). You'll need higher magic if you use 8 dimensional datasets anyway. "
>
>I guess what I was really asking was what this "higher magic" was.


I don't know what Davids "higher magic" is. (And up to now I didn't
know about this limitation to IDLs array concatenation.) My first try
would be to merge all dimensions before the one to concatenate by the
reform function:

a=indgen(6,5,4,3,2)
b=indgen(6,5,4,1,2)
a=reform(a,6*5*4,3,2,/overwrite)
b=reform(b,6*5*4,1,2,/overwrite)
c=[[a],[b]]
c=reform(c,6,5,4,4,2,/overwrite)

This results in an array C having the dimensions [6,5,4,4,2].

Cheers, Heinz
Reply With Quote
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 06:28 PM.


Copyright ©2009

LinkBacks Enabled by vBSEO 3.3.0 RC2 © 2009, Crawlability, Inc.