ncfile.addDimension(null, time);
ncfile.addDimension(null, dirDim);
ncfile.addDimension(null, navDim);
Array varArray;
// make the variables
// time
Variable timeVar = new Variable(ncfile, null, null, "time");
timeVar.setDataType(DataType.INT);
timeVar.setDimensions("time");
timeVar.addAttribute(new Attribute("units",
"seconds since "
+ df.toDateTimeString(nomTime)));
timeVar.addAttribute(new Attribute("long_name", "time"));
varArray = new ArrayInt.D1(1);
((ArrayInt.D1) varArray).set(0, 0);
timeVar.setCachedData(varArray, false);
ncfile.addVariable(null, timeVar);
// lines and elements
Variable lineVar = new Variable(ncfile, null, null, "lines");
lineVar.setDataType(DataType.INT);
lineVar.setDimensions("lines");
//lineVar.addAttribute(new Attribute("units", "km"));
lineVar.addAttribute(new Attribute("standard_name",
"projection_y_coordinate"));
varArray = new ArrayInt.D1(numLines);
for (int i = 0; i < numLines; i++) {
int pos = nav.isFlippedLineCoordinates()
? i
: numLines - i - 1;
((ArrayInt.D1) varArray).set(i, pos);
}
lineVar.setCachedData(varArray, false);
ncfile.addVariable(null, lineVar);
Variable elementVar = new Variable(ncfile, null, null, "elements");
elementVar.setDataType(DataType.INT);
elementVar.setDimensions("elements");
//elementVar.addAttribute(new Attribute("units", "km"));
elementVar.addAttribute(new Attribute("standard_name",
"projection_x_coordinate"));
varArray = new ArrayInt.D1(numElements);
for (int i = 0; i < numElements; i++) {
((ArrayInt.D1) varArray).set(i, i);
}
elementVar.setCachedData(varArray, false);
ncfile.addVariable(null, elementVar);
// TODO: handle bands and calibrations
Variable bandVar = new Variable(ncfile, null, null, "bands");
bandVar.setDataType(DataType.INT);
bandVar.setDimensions("bands");
bandVar.addAttribute(new Attribute("long_name",
"spectral band number"));
bandVar.addAttribute(new Attribute("axis", "Z"));
Array bandArray = new ArrayInt.D1(numBands);
for (int i = 0; i < numBands; i++) {
((ArrayInt.D1) bandArray).set(i, bandMap[i]);
}
bandVar.setCachedData(bandArray, false);
ncfile.addVariable(null, bandVar);