On 9/3/07, Roger GALLOU (AGO) <roger.gallou@xxxxxx> wrote:
> Hello,
>
> I'm working with Java nc2 library and I wish to read Etopo files (which
> are in NetCDF format) with the methods of the library. I work with
> MatLab R2006b.
> I want to sample the data in Latitude and Longitude, ie, I don't want to
> read all the data but only two samples among 4.
>
> In Java, I manage to read it with loop in latitude and longitude but
> it isn't satisfied by the process time which is more longer than the
> version with mex version.
>
> Do you know a method with Java which is so faster than with mex functions ?
>
Roger,
Did you know that SNCTOOLS can read NetCDF files into Matlab using
NetCDF-Java? All you have to do is edit "nc_method.m" and change
"method=mexnc" to "method=java".
At least on the file I tried, using SNCTOOLS "nc_varget" function
(java) is then faster than using the mex-file based "NetCDF toolkit":
>> tic;a=nc_varget('VS_ele.nc','lon',[0],[2],[2]);toc
Elapsed time is 0.083326 seconds.
>> a
a =
-72.6249
-72.5983
>> tic;nc=netcdf('VS_ele.nc');a=nc{'lon'}(1:2:3);close(nc);toc
Elapsed time is 0.369757 seconds.
>> a
a =
-72.6249
-72.5983
You can explore the "nc_varget_java.m" routine in the SNCTOOLS
"private" directory to see the NetCDF java routines used.
-Rich
--
Dr. Richard P. Signell (508) 457-2229
USGS, 384 Woods Hole Rd.
Woods Hole, MA 02543-1598