return sb.toString();
}
private void addTime3Coordinates(NetcdfDataset newds, Gridset gridset, List<Inventory> invList, String type) {
DateFormatter formatter = new DateFormatter();
boolean useRun = type.equals(FORECAST);
// add the time dimensions
int n = invList.size();
String dimName = gridset.timeDimName;
Group g = newds.getRootGroup();
g.remove(g.findDimension(dimName));
g.addDimension(new Dimension(dimName, n));
// make the time coordinate variable data
ArrayDouble.D1 offsetData = new ArrayDouble.D1(n);
for (int i = 0; i < n; i++) {
Inventory inv = invList.get(i);
double offsetHour = getOffsetHour(baseDate, useRun ? inv.runTime : inv.forecastTime);
offsetData.set(i, offsetHour);
}
// add the time coordinate variable
String typeName = useRun ? "run" : "forecast";
String desc = typeName + " time coordinate";
VariableDS timeCoordinate = new VariableDS(newds, g, null, dimName, DataType.DOUBLE, dimName,
"hours since " + formatter.toDateTimeStringISO(baseDate), desc);
timeCoordinate.setCachedData(offsetData, true);
timeCoordinate.addAttribute(new Attribute("long_name", desc));
timeCoordinate.addAttribute(new Attribute("standard_name", useRun ? "forecast_reference_time" : "time"));
timeCoordinate.addAttribute(new Attribute(_Coordinate.AxisType, AxisType.Time.toString()));
newds.addVariable(g, timeCoordinate);
// add the runtime coordinate
ArrayObject.D1 runData = new ArrayObject.D1(String.class, n);
for (int i = 0; i < n; i++) {
Inventory inv = invList.get(i);
runData.set(i, formatter.toDateTimeStringISO(inv.runTime));
}
desc = "model run dates for coordinate = " + dimName;
VariableDS runtimeCoordinate = new VariableDS(newds, newds.getRootGroup(), null, dimName + "_run",
DataType.STRING, dimName, null, desc);