On Tue, Nov 20, 2012 at 1:16 PM, Muhali <mu...@us...> wrote:
> Adapting example_opendap.m as follows
>
> ----
> pkg load octcdf
> nc = netcdf(ncfile='http://hycom.coaps.fsu.edu/thredds/dodsC/atl_ops','r');
> N=size(nc{'ssh'})
> ssh = ncread(ncfile, 'ssh', [1 1 1], [1 1 N(3)])
> ----
>
> I get
>
> N =
>
> 730 1609 1678
>
> error: Error while retrieving variable: NetCDF: Index exceeds dimension
> bound.
> error: called from:
> error: /usr/local/octave-dev/share/octave/packages/octcdf-1.1.5/ncread.m
> at line 51, column 3
> error: foo.m at line 5, column 5
>
> The 4th argument of ncread is the 'count' vector, so it should be able read
> N(3) variables. Or am I missing something?
>
>
ncread from matlab adopted a different ordering convention than octcdf
(which follows the original matlab toolbox from USGS). The order of
dimensions are reversed. For example octcdf would report a file as
time,lat,lon while ncread lon,lat,time. It is better not to mix ncread
which direct calls to octcdf (it ends up to be confusing). If you want
to use ncread and need to know the size of a variable, it is better to
use ncinfo:
>> vinfo = ncinfo('http://hycom.coaps.fsu.edu/thredds/dodsC/atl_ops','ssh');
>> vinfo.Size
ans =
1678 1609 730
Cheers,
Alex
|