}
}
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);
// cal data array
ArrayFloat.D1 latData =
(ArrayFloat.D1) Array.factory(DataType.FLOAT,
new int[] { n });
ArrayFloat.D1 lonData =
(ArrayFloat.D1) Array.factory(DataType.FLOAT,
new int[] { n });
ArrayFloat.D1 altData =
(ArrayFloat.D1) Array.factory(DataType.FLOAT,
new int[] { n });
ArrayDouble.D1 timeData =
(ArrayDouble.D1) Array.factory(DataType.DOUBLE,
new int[] { n });
this.conventionName = "Cosmic3";
int iyr = ds.readAttributeInteger(null, "year", 2009);
int mon = ds.readAttributeInteger(null, "month", 0);
int iday = ds.readAttributeInteger(null, "day", 0);
int ihr = ds.readAttributeInteger(null, "hour", 0);
int min = ds.readAttributeInteger(null, "minute", 0);
int sec = ds.readAttributeInteger(null, "second", 0);
double start = ds.readAttributeDouble(null, "startTime",
Double.NaN);
double stop = ds.readAttributeDouble(null, "stopTime",
Double.NaN);
double incr = (stop - start) / n;
int t = 0;
// double julian = juday(mon, iday, iyr);
// cal the dtheta based pm attributes
double dtheta = gast(iyr, mon, iday, ihr, min, sec, t);
Variable tVar = ds.findVariable("time");
String timeUnits = "seconds since 1980-01-06 00:00:00"; //dtime.getUnit().toString();
tVar.removeAttributeIgnoreCase("valid_range");
tVar.removeAttributeIgnoreCase("units");
tVar.addAttribute(new Attribute("units", timeUnits));
tVar.addAttribute(new Attribute(_Coordinate.AxisType,
AxisType.Time.toString()));
Variable v = ds.findVariable("xLeo");
Array xLeo = v.read();
v = ds.findVariable("yLeo");
Array yLeo = v.read();
v = ds.findVariable("zLeo");
Array zLeo = v.read();
Array tArray = tVar.read();
double pi = 3.1415926;
double a = 6378.1370;
double b = 6356.7523142;
IndexIterator iiter0 = xLeo.getIndexIterator();