Project

General

Profile

NetCDF: Index exceeds dimension bound

Added by Angela Meyer about 11 years ago

Hi,

I'm having issues with a netcdf file (attached aod.nc):

cdo sellonlatbox,-180,180,-20,20 aod.nc ofile.nc
cdf_get_vara_float : ncid = 65536 varid = 4
Error (cdf_get_vara_float) : NetCDF: Index exceeds dimension bound

Any hints what is going wrong?

Thanks
Angela

aod.nc (7.45 MB) aod.nc

Replies (4)

RE: NetCDF: Index exceeds dimension bound - Added by Jaison-Thomas Ambadan about 11 years ago

Hi,

here is the "ncdump -h" of your attached file:

netcdf aod {
dimensions:
nwl = 14 ;
lat = 96 ;
mlev = 40 ;
ilev = 41 ;
time = UNLIMITED ; // (12 currently)

there is no "lon" dimension. And CDO doesn't support [I guess] generic NetCDF files. However, you may try the same by selecting the appropriate variable along with "selindexbox" (see the docs for more info)

for example:

cdo -selindexbox,1,14,1,96 -selvar,aod aod.nc ofile.nc

Cheers,
J.

RE: NetCDF: Index exceeds dimension bound - Added by Angela Meyer about 11 years ago

Thanks, Jaison.

I'd like to average a field over a particular latitude range (e.g. 20N-20S), and the field is on a lat,lev grid as in the previously attached file, so there's no lon dimension. I haven't found a way to do this average in cdo, so I added a lon dimension. Now the original lat-lev field is repeated at every longitude, which should allow me to use "cdo fldmean -sellonlatbox .." on the new field. I've attached the corresponding file (aod_lon.nc). Sellonlatbox won't work on it though, and I wonder why..

cdo sellonlatbox,-180,180,-20,20 aod_lon.nc ofile.nc
cdf_get_vara_float : ncid = 65536 varid = 4
Error (cdf_get_vara_float) : NetCDF: Index exceeds dimension bound

Cheers
Angela

RE: NetCDF: Index exceeds dimension bound - Added by Jaison-Thomas Ambadan about 11 years ago

Hi,

I think the problem is that the NetCDF variable attibuted/co-ordinate variables are not in the standard format which cdo recognize. For example, although ncdump -h shows there are 12 time steps, CDO only show one timestep. so I think it might better to edit the file manually :( and then apply the cdo operator:

1. ncdump aod_lon.nc > my_data.dat
2. open the file "my_data.dat" in an editor and change all (search & replace) the "nwl" (which I guess is the levels) to "lev" 
3. change the "time = 12 ;" (on top) to time = UNLIMITED ; 
4. change "float aod(nwl, lon, lat, time) ;" to "float aod(time, lat, lon, lev) ;" 
5. save file with all changes
6. ncgen -o new_file.nc my_data.dat

now try

cdo sinfov new_file.nc

which shows all the 12 time steps, and

cdo sellonlatbox,-180,180,-20,20 new_file.nc ofile.nc

will work now but of course, check the results.

I'd like to average a field over a particular latitude

you could use "mermean" (see docs: meridinonal stats) in the original file, I guess?

Anyway, hope this helps,

Cheers,
J.

RE: NetCDF: Index exceeds dimension bound - Added by Uwe Schulzweida about 11 years ago

Yes, the order of the array dimensions is not supported in CDO. At least the time dimension have to be the first dimension.

    (1-4/4)