public static void main(String args[]) throws Exception {
long start = System.currentTimeMillis();
Map<String, ucar.unidata.geoloc.Station> staHash = new HashMap<String,ucar.unidata.geoloc.Station>();
String location = "R:/testdata/sounding/netcdf/Upperair_20070401_0000.nc";
NetcdfDataset ncfile = NetcdfDataset.openDataset(location);
ncfile.sendIospMessage(NetcdfFile.IOSP_MESSAGE_ADD_RECORD_STRUCTURE);
// look through record varibles, for those that have "manLevel" dimension
// make a StructureData object for those
StructureMembers sm = new StructureMembers("manLevel");
Dimension manDim = ncfile.findDimension("manLevel");
Structure record = (Structure) ncfile.findVariable("record");
List<Variable> allList = record.getVariables();
List<VariableSimpleIF> varList = new ArrayList<VariableSimpleIF>();
for (Variable v : allList) {
if ((v.getRank() == 1) && v.getDimension(0).equals(manDim)) {
// public VariableDS(NetcdfDataset ds, Group group, Structure parentStructure, String shortName, DataType dataType,
// String dims, String units, String desc) {
varList.add( new VariableDS(ncfile, null, null, v.getShortName(), v.getDataType(), "", v.getUnitsString(), v.getDescription()));
//(String name, String desc, String units, DataType dtype, int []shape)
sm.addMember(v.getShortName(), v.getDescription(), v.getUnitsString(), v.getDataType() , new int[0]); // scalar
}
}
ArrayStructureMA manAS = new ArrayStructureMA(sm, new int[] {manDim.getLength()} );
// need the date units
Variable time = ncfile.findVariable("synTime");
String timeUnits = ncfile.findAttValueIgnoreCase(time, "units", null);
timeUnits = StringUtil.remove(timeUnits, '('); // crappy fsl'ism
timeUnits = StringUtil.remove(timeUnits, ')');
DateUnit timeUnit = new DateUnit(timeUnits);
// extract stations