Re: REFORM: new subscripts must not change the number elements in array [message #90428 is a reply to message #90424] |
Mon, 02 March 2015 09:20   |
Paul Van Delst[1]
Messages: 1157 Registered: April 2002
|
Senior Member |
|
|
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."
>
|
|
|