You say that uwind
is defined at each lat, lon, height, and time, but you are only giving three indices when you call uwind[i][i][j]
. So the output will be a 1-d array. Giving a 4th index, e.g. uwind[i,i,j,j]
should resolve the error.
However, conceptually I'm not sure why you're using the latstep
index i
for both of the first two dimensions. If you're just trying to write the array to an external file, consider the pickle
(or cPickle
) built-in library. (Looping over each gridpoint and time is extremely inefficient.)
Also, I'm assuming you're using the netCDF4
module, in which case there is no need for the float()
conversion -- the values will be floating point numbers already (which you can test with, e.g. type(uwind[0,0,0,0]
).