Re: Limiting concatenation IDL 5.5 [message #31228] |
Thu, 27 June 2002 22:11  |
Dick Jackson
Messages: 347 Registered: August 1998
|
Senior Member |
|
|
"William Thompson" <thompson@orpheus.nascom.nasa.gov> wrote in message
news:afg4kr$hlu$1@skates.gsfc.nasa.gov...
> Randall Skelton <rhskelto@atm.ox.ac.uk> writes:
>
>> Ok... I have to ask. Is there actually a nice, clean way to
concatenate
>> multidimensional arrays in IDL?
>
>> a = make_array(2,2,2,2)
>> b = make_array(2,2,2,5)
>
>> data1 = [ [[[a]]] , [[[b]]] ]
>
>> Obviously the above fails, but what is the solution? Surely some
>> combination of rebin/reform...
>
> How about
>
> c = make_array(2,2,2,7)
> c(0,0,0,0) = a
> c(0,0,0,2) = b
>
> Of course, you'd want to put this into a routine, with calls to
SIZE(), etc.
[Uh, David, make sure Bill gets a seat on the board of that IDL Experts'
group.]
Nice point, Bill! Your idea takes a bit of hackery, I'll take a swipe at
some of it:
concatSize = Size(a)
concatSize[dim+1] = concatSize[dim+1] + (Size(b))[dim+1]
c=Make_Array(Size=concatSize)
nDims=Size(a,/N_Dimensions)
aDims=Size(a,/Dimensions)
; This needs to be generalized for all
; possible values of nDims from 1 to 8, (4 assumed)
; either by a CASE statement or tricky
; string handling and Execute():
c[0, 0, 0, 0] = a
c[dim eq 0 ? aDims[0] : 0, $
dim eq 1 ? aDims[1] : 0, $
dim eq 2 ? aDims[2] : 0, $
dim eq 3 ? aDims[3] : 0]=b
Cheers,
--
-Dick
Dick Jackson / dick@d-jackson.com
D-Jackson Software Consulting / http://www.d-jackson.com
Calgary, Alberta, Canada / +1-403-242-7398 / Fax: 241-7392
|
|
|