Dear visad group
I am totally new in visad library and netcdf manipulation.
The file I am trying to manipulate has this features:
Netcdfile follows the convention CF-1.0
type: Time -> ((Longitude, Latitude, zlev) -> (sst, anom, err, ice)
It is 2D because zlev is 0.
I wrote a small java program where I can read a Netcdf file and list
values following some examples from netcdf library,
My question is how can I transform this array into a format that visad can
understand. As instance FieldImpl.
My goal is to get isotherms (contours) lat,lon using some visad contour
class.
Thanks in advance
Jose
code:
dataFile=NetcdfFile.open("d:/mymodel.nc");
Variable tempVar = dataFile.findVariable("sst");
if (tempVar == null) {
System.out.println("Cant find Variable sst");
return;
}else{
// read variable
int [] shape = tempVar.getShape();
int recLen = shape[0]; // number of times
int[] origin = new int[4];
shape[0] = 1; // only one rec per read
// loop over the rec dimension
for (int rec = 0; rec < recLen; rec++) {
origin[0] = rec; // read this index
// Get the lat/lon data from the file.
ArrayShort.D2 tempArray = null;
try {
tempArray = (ArrayShort.D2) (tempVar.read(origin, shape).reduce());
} catch (InvalidRangeException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// now checking the value
for (int lvl = 0; lvl < NLVL; lvl++)
for (int lat = 0; lat < NLAT; lat++)
for (int lon = 0; lon < NLON; lon++) {
// System.out.println(tempArray.get(1,1, lat, lon));
System.out.println("Longitude:" + lon);
System.out.println("Latitude:" + lat);
System.out.println("Temp:" + Float.toString(tempArray.get(lat, lon)));
}
}