// 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
int nrecs = 0;
StructureDataIterator iter = record.getStructureIterator();
while (iter.hasNext()) {
StructureData sdata = iter.next();
String name = sdata.getScalarString("staName");
ucar.unidata.geoloc.Station s = staHash.get(name);
if (s == null) {
float lat = sdata.convertScalarFloat("staLat");
float lon = sdata.convertScalarFloat("staLon");
float elev = sdata.convertScalarFloat("staElev");
s = new StationImpl(name, "", lat, lon, elev);
staHash.put(name, s);
}
nrecs++;
}
List<ucar.unidata.geoloc.Station> stnList = Arrays.asList( staHash.values().toArray( new ucar.unidata.geoloc.Station[staHash.size()]) );
Collections.sort(stnList);
// create the writer
WriterProfileObsDataset writer = new WriterProfileObsDataset(location+".out", "rewrite "+location);
writer.writeHeader(stnList, varList, nrecs, "prMan");
// extract records
iter = record.getStructureIterator();
while (iter.hasNext()) {
StructureData sdata = iter.next();
String name = sdata.getScalarString("staName");
double timeValue = sdata.convertScalarDouble("synTime");
Date date = timeUnit.makeDate(timeValue);
// transfer to the ArrayStructure
List<String> names = sm.getMemberNames();
for (String mname : names) {
manAS.setMemberArray( mname, sdata.getArray( mname));