On Monday, March 2, 2015 at 3:04:41 PM UTC+1, g.na...@gmail.com wrote:
> Hi
>
> I have two 3D arrays Ax and Ay with the following dimensions[100,4,4]=[time,x,y].
>
> I wanted to interpolate my matrices Ax and Ay and make them to have dimensions of [100,8,8]. A part of my code is shown below:
>
> size = 8
> Ax_2D_INT = fltarr(100,size,size)
> Ay_2D_INT = fltarr(100,size,size)
>
> for i=0, 99 do begin
> Ax_2D = REFORM(Ax[i,*,*]) ;change 3D to 2D
> Ay_2D = REFORM(Ay[i,*,*])
>
> dimensions_I_need = size(Dindgen(size,size),/Dimensions)
> dimensions_I_have = size(Ax_2D,/Dimensions)
>
> X = cgScaleVector(Dindgen(dimensions_I_need[0]), 0, dimensions_I_have[0]-1)
>
> Y = cgScaleVector(Dindgen(dimensions_I_need[1]), 0, dimensions_I_have[1]-1)
>
> Ax_2D_INT = INTERPOLATE(Ax_2D,X, Y, /GRID)
> Ay_2D_INT = INTERPOLATE(Ay_2D,X, Y, /GRID)
> endfor
>
> I got the following error but I couldn't figure out why.
> Attempt to subscript DIMENSIONS_I_HAVE with <INT ( 1)> is out of range.
I've tried you code and got no error. In your test, you don't provide Ax and Ay. I've build them up myself as
Ax = randomu(s,100,size,size)
Ay = randomu(s,100,size,size)
and the code runs without errors.
My guess, is that Ax and/or Ay contain bad data (!null) or something similar.
Check your two input arrays.
Next thing I would highly recommend, is to avoid using variable names for which you also have functions. Don't use size = 8. This is just a source of trouble.
By the way, the error you described, happens when for example:
IDL> DIMENSIONS_I_HAVE = size(findgen(5), /dimensions)
IDL> print, DIMENSIONS_I_HAVE[1]
% Attempt to subscript DIMENSIONS_I_HAVE with <INT ( 1)> is out of range.
I made on purpose DIMENSIONS_I_HAVE have only one dimension. Then you cannot subscript the second dimension. So some when, your array Ax_2D has only one dimension. Try maybe printing "i" in the loop just before
Y = cgScaleVector(Dindgen(dimensions_I_need[1]), 0, dimensions_I_have[1]-1)
Then check the value of i that generated the error and have a look at that Ay[i,*,*].
Good luck,
Helder
|