With apologies for replying to my own reply, but if you really want an
array B=[100,200,200] from a starting A=[200,200] array, you just use
TRANSPOSE (http://www.exelisvis.com/docs/TRANSPOSE.html) on the result
from REBIN:
IDL> help, b
B LONG = Array[4, 4, 10]
IDL> b = transpose(b,[2,0,1])
IDL> help, b
B LONG = Array[10, 4, 4]
IDL> print, b[0,*,*]
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
IDL> print, b[6,*,*]
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
On 03/02/15 12:20, Paul van Delst wrote:
> On 03/02/15 11:46, g.nacarts@gmail.com wrote:
>> I didn't understand the logic of this reform(a, 100l, 200l*2l). If
>> instead of A=[200,200] we have A=[216,216] and we want 120x(216x216)
>> then this is written as reform(a, 120l, 216l*2l). Is that correct?
>
> No. That is not correct.
>
> Read:
> http://www.exelisvis.com/docs/REFORM.html
>
> The very first line of the description (actually, the only line) says:
> <quote>
> The REFORM function changes the dimensions of an array without changing
> the total number of elements.
> </quote>
>
> If you start with A=[200,200] and you want B=[200,200,100] (i.e. 100
> sets of 200x200 arrays) then REFORM is not the command to use.
>
> I think you want REBIN:
> http://www.exelisvis.com/docs/REBIN.html
>
> IDL> a=lindgen(4,4)
> IDL> print, a
> 0 1 2 3
> 4 5 6 7
> 8 9 10 11
> 12 13 14 15
>
> Now create 10 "copies" of a, stacked into a 3-D array:
>
> IDL> b=rebin(a,4,4,10)
>
> IDL> print, b[*,*,0]
> 0 1 2 3
> 4 5 6 7
> 8 9 10 11
> 12 13 14 15
> IDL> print, b[*,*,6]
> 0 1 2 3
> 4 5 6 7
> 8 9 10 11
> 12 13 14 15
>
>>
>> I am trying to understand how you end up with reform(a, 100l,
>> 200l*2l). Because when I typed this a = randomu(s, 216,216) help,
>> reform(a, 120l, 216l*2l,/overwrite) I got the same error "REFORM: New
>> subscripts must not change the number elements in A."
>>
|