start = top;
}
}
Dimension dim = ds.findDimension("MSL_alt");
Variable dimV = ds.findVariable("MSL_alt");
Array dimU = dimV.read();
int inscr = (dimU.getFloat(1) - dimU.getFloat(0)) > 0
? 1
: 0;
int n = dim.getLength();
double incr = (stop - start) / n;
String timeUnits = "seconds since 1980-01-06 00:00:00";
Variable timeVar = new VariableDS(ds, null, null, "time",
DataType.DOUBLE, dim.getName(),
timeUnits, null);
ds.addVariable(null, timeVar);
timeVar.addAttribute(new Attribute("units", timeUnits));
timeVar.addAttribute(new Attribute(_Coordinate.AxisType,
AxisType.Time.toString()));
int dir = ds.readAttributeInteger(null, "irs", 1);
ArrayDouble.D1 data =
(ArrayDouble.D1) Array.factory(DataType.DOUBLE,
new int[] { n });
if (inscr == 0) {
if (dir == 1) {
for (int i = 0; i < n; i++) {
data.set(i, start + i * incr);
}
} else {
for (int i = 0; i < n; i++) {
data.set(i, stop - i * incr);
}
}
} else {
for (int i = 0; i < n; i++) {
data.set(i, stop - i * incr);
}
}
timeVar.setCachedData(data, false);
}
Variable v = ds.findVariable("Lat");
if (v == null) {
v = ds.findVariable("GEO_lat");
}
v.addAttribute(new Attribute(_Coordinate.AxisType,
AxisType.Lat.toString()));
Variable v1 = ds.findVariable("Lon");
if (v1 == null) {
v1 = ds.findVariable("GEO_lon");
}
v1.addAttribute(new Attribute(_Coordinate.AxisType,
AxisType.Lon.toString()));
} else {
Dimension dim = ds.findDimension("time");
int n = dim.getLength();
Variable latVar = new VariableDS(ds, null, null, "Lat",
DataType.FLOAT, dim.getName(),
"degree", null);
latVar.addAttribute(new Attribute(_Coordinate.AxisType,
AxisType.Lat.toString()));
ds.addVariable(null, latVar);
Variable lonVar = new VariableDS(ds, null, null, "Lon",
DataType.FLOAT, dim.getName(),
"degree", null);
lonVar.addAttribute(new Attribute(_Coordinate.AxisType,
AxisType.Lon.toString()));
ds.addVariable(null, lonVar);
Variable altVar = new VariableDS(ds, null, null, "MSL_alt",
DataType.FLOAT, dim.getName(),
"meter", null);
altVar.addAttribute(new Attribute(_Coordinate.AxisType,
AxisType.Height.toString()));
ds.addVariable(null, altVar);