Problem reading NCAR NetCDF formatted SPOL files with Java

Hello,

I tried to read an NCAR-style NetCDF file of SPOL radar data just now, and encountered a strange problem. Using the following code snippet:

NetcdfFile ncFile = NetcdfFile.open("ncswp_SPOL_20040805_210010.172_u1_s1_0.8_SUR_.nc");
  Variable fields = ncFile.findVariable("field_names");
  char[][] fieldnames = (char[][])fields.read().copyToNDJavaArray();
  for (int fieldI = 0; fieldI < fieldnames.length; ++fieldI) {
      String name = new String(fieldnames[fieldI]);
System.out.println("Found field '" + name + "'");
      name = name.trim();
System.out.println(" trimmed '" + name + "'");
      Variable field = ncFile.findVariable(name);
      if (field == null) continue; //should not be possible
String description = field.findAttribute("long_name").getStringValue().trim();
System.out.println("  is " + description);
        String units =  field.getUnitsString();
System.out.println("  in " + units);
  }


I got (in part) the following result:


Found field 'SW              '
 trimmed 'SW'
  is Spectral width
  in meters/second
Found field 'VR`a&?@?
                    '
 trimmed 'VR`a&?@?'
Found field 'ZDR???? ?'
 trimmed 'ZDR????  ?'


As you can see, it worked just fine for SW (and the 15 fields preceding it), but VR and ZDR have trailing garbage (poorly represented here; it looked much worse in Java - also seems to change from run to run of the program) that prevents me from finding the variable. If I use ncdump -h to view the same file, all 18 fields look fine. I tried several SPOL NetCDF files, always with the same results. I am not sure whether the problem is with the files themselves, how I am trying to read them, or the Java NetCDF library itself.

--
Jochen Deyke - jdeyke@xxxxxxxxxxxxxxxxxxx

A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?

==============================================================================
To unsubscribe netcdf-java, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================