int nlevel = code_levelslookup( pcode );
int [] levels;
//prod_info_size = 2 * (int) (num_bin * scale + 0.5);
//dimensions: radial, bin
ncfile.addAttribute(null, new Attribute("cdm_data_type", FeatureType.RADIAL.toString()));
Dimension radialDim = new Dimension("azimuth", num_radials);
ncfile.addDimension( null, radialDim);
Dimension binDim = new Dimension("gate", num_bin);
ncfile.addDimension( null, binDim);
dims.add( radialDim);
dims.add( binDim);
ArrayList dims1 = new ArrayList();
ArrayList dims2 = new ArrayList();
dims1.add(radialDim);
dims2.add(binDim);
// Variable aziVar = new Variable(ncfile, null, null, "azimuth");
// aziVar.setDataType(DataType.FLOAT);
// aziVar.setDimensions(dims1);
// ncfile.addVariable(null, aziVar);
// aziVar.addAttribute( new Attribute("long_name", "azimuth angle in degrees: 0 = true north, 90 = east"));
// aziVar.addAttribute( new Attribute("units", "degrees"));
// aziVar.setSPobject( new Vinfo (numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, null, 0));
// dims1 = new ArrayList();
// dims1.add(binDim);
//Variable gateV = new Variable(ncfile, null, null, "gate1");
//gateV.setDataType(DataType.FLOAT);
//gateV.setDimensions(dims2);
//ncfile.addVariable(null, gateV);
//gateV.addAttribute( new Attribute("long_name", "radial distance to start of gate"));
//gateV.addAttribute( new Attribute("units", "m"));
//gateV.setSPobject( new Vinfo (numX, numX0, numY, radp_scale, hoff, hedsiz, isR, isZ, null, null, 0, 0));
isR = true;
// add elevation coordinate variable
String vName = "elevation";
String lName = "elevation angle in degres: 0 = parallel to pedestal base, 90 = perpendicular";
Attribute att = new Attribute(_Coordinate.AxisType, AxisType.RadialElevation.toString());
addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, p3);
// add azimuth coordinate variable
vName = "azimuth";
lName = "azimuth angle in degrees: 0 = true north, 90 = east";
att = new Attribute(_Coordinate.AxisType, AxisType.RadialAzimuth.toString());
addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, 0);
// add gate coordinate variable
vName = "gate";
lName = "Radial distance to the start of gate";
att = new Attribute(_Coordinate.AxisType, AxisType.RadialDistance.toString());
addParameter(vName, lName, ncfile, dims2, att, DataType.FLOAT, "meters",hoff, hedsiz, isZ, radp_scale);
// add radial coordinate variable
vName = "latitude";
lName = "Latitude of the instrument";
att = new Attribute(_Coordinate.AxisType, AxisType.Lat.toString());
addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, 0);
vName = "longitude";
lName = "Longitude of the instrument";
att = new Attribute(_Coordinate.AxisType, AxisType.Lon.toString());
addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "degrees",hoff, hedsiz, isZ, 0);
vName = "altitude";
lName = "Altitude in meters (asl) of the instrument";
att = new Attribute(_Coordinate.AxisType, AxisType.Height.toString());
addParameter(vName, lName, ncfile, dims1, att, DataType.FLOAT, "meters",hoff, hedsiz, isZ, 0);
vName = "rays_time";
lName = "rays time";
att = new Attribute(_Coordinate.AxisType, AxisType.Time.toString());
addParameter(vName, lName, ncfile, dims1, att, DataType.DOUBLE, "milliseconds since 1970-01-01 00:00 UTC"
,hoff, hedsiz, isZ, 0);
//add RAW, BRIT variables for all radial variable
if(pcode == 182 || pcode == 99 ) {
levels = getTDWRLevels(nlevel, threshold);
iscale = 10;
} else if (pcode == 186 || pcode == 94) {
threshold[0] = -320;
threshold[1] = 5;
threshold[2] = 254;
levels = getTDWRLevels(nlevel, threshold);
iscale = 10;
} else if (pcode == 32 ) {
levels = getTDWRLevels1(nlevel, threshold);
iscale = 10;
} else if (pcode == 138) {
levels = getTDWRLevels1(nlevel, threshold);
iscale = 100;
} else if (pcode == 134 || pcode == 135) {
levels = getTDWRLevels2(nlevel, threshold);
iscale = 1;
} else {
levels = getLevels(nlevel, threshold);
}
Variable v = new Variable(ncfile, null, null, cname + "_RAW");
v.setDataType(DataType.BYTE);
v.setDimensions(dims);
ncfile.addVariable(null, v);
v.addAttribute( new Attribute("units", cunit));
String coordinates = "elevation azimuth gate rays_time latitude longitude altitude";
v.addAttribute( new Attribute(_Coordinate.Axes, coordinates));
v.addAttribute( new Attribute("_unsigned", "true"));
v.setSPobject( new Vinfo (numX, numX0, numY, numY0, hoff, hedsiz, isR, isZ, null, levels, 0, nlevel));
// addVariable(cname + "_Brightness", ctitle + " Brightness", ncfile, dims, coordinates, DataType.FLOAT,
// cunit, hoff, hedsiz, isZ, nlevel, levels, iscale);