John-
John Caron wrote:
Don Murray wrote:
I have some code that reads a netCDF file using the ucar.netcdf
package. I wanted to use VariableStandardized from ucar.nc2,
so need to move my code to use ucar.nc2. I've got lines like:
ncFile.get("Latitude").getDouble(new int[] {0}));
Variable v = ncFile.findVariable("Latitude");
Array a = v.read(); // does the actual I/O
Index ima = a.getIndex();
double lat = a.getDouble(ima.set0(0));
I changed some of my code so that I now have a method:
public static double getDouble(Variable v, int[] index) throws
IOException {
Array a = v.read();
Index ima = a.getIndex();
return a.getDouble(ima.set(index));
}
to replace
var.getDouble(index)
with
getDouble(var, index)
This ends up taking WAY longer than the old ucar.netcdf stuff.
Is there any caching done or does it read the entire variable
into memory for each call? In some cases, I'm looping over
a set of variables so the getDouble is being called 10-20 times
on each variable. Is there a way to see if I've already read
in the Array if there is no caching?