Another attempt... [Fwd: XYT and XYZT grid with only 1 X and 1 Y point in axis]

Hi Folks,

I wondering if this is a bug or a feature.  getGrids recognizes grids with only 1 X and 1 Y in the case below where there is no vertical axis, but reports no grids when there is a vertical axis.  Can somebody explain why?

To be sure, I ran the attached code using the 2.2.09 release.

Roland

-------- Original Message --------
Subject: XYT and XYZT grid with only 1 X and 1 Y point in axis
Date: Mon, 08 Aug 2005 11:24:31 -0500
From: Roland Schweitzer <Roland.Schweitzer@xxxxxxxx>
To: netcdf-java <netcdf-java@xxxxxxxxxxxxxxxx>


Hi,

I am using the Java netCDF library (version 2.2.something -- how to I 
tell which from the jar?) to extract the GeoGrids from the netCDF 
dataset from these two URLs.

Both are degenerate in the sense that there is only one X and one Y in 
the "grid", but none the less in the case of the XYT file the GeoGrids 
are returned successfully.

However in the second case where a similar XY grid is defined, but 
includes a Z axis getGrids() returns an empty list.  I think it should 
be able to return grids (albeit degenerate) just the same as the XYT case.

XYT Grid:

http://dods.ndbc.noaa.gov/cgi-bin/nph-dods/dods/stdmet/42001/42001h2001.nc


XYZT Grid:

http://dods.ndbc.noaa.gov/cgi-bin/nph-dods/dods/adcp/41012/41012a2002.nc

Thanks,
Roland

/**
 * 
 */
package gov.noaa.pmel.tmap;

import java.util.Iterator;
import java.util.List;

import ucar.nc2.dataset.CoordinateAxis1D;
import ucar.nc2.dataset.NetcdfDataset;
import ucar.nc2.dataset.grid.GeoGrid;
import ucar.nc2.dataset.grid.GridCoordSys;
import ucar.nc2.dataset.grid.GridDataset;
import ucar.nc2.dods.DODSNetcdfFile;

/**
 * @author Roland Schweitzer
 * 
 */
public class OneByOneGrid {

    /**
     * @param args
     */
    public static void main(String[] args) {
        String[] data = {
                
"http://dods.ndbc.noaa.gov/cgi-bin/nph-dods/dods/stdmet/42001/42001h2001.nc";,
                
"http://dods.ndbc.noaa.gov/cgi-bin/nph-dods/dods/adcp/41012/41012a2002.nc"; };

        for (int i = 0; i < data.length; i++) {
            System.out.println("Data set: " + data[i]);
            try {
                String url = DODSNetcdfFile.canonicalURL(data[i]);
                NetcdfDataset ncds = NetcdfDataset.openDataset(url);
                GridDataset gridDs = new GridDataset(ncds);
                List grids = gridDs.getGrids();
                if (grids.size() > 0) {
                    for (Iterator git = grids.iterator(); git.hasNext();) {
                        GeoGrid grid = (GeoGrid) git.next();
                        System.out.println(grid.getDescription());
                        GridCoordSys gcs = grid.getCoordinateSystem();
                        CoordinateAxis1D xAxis = (CoordinateAxis1D) 
gcs.getXHorizAxis();
                        CoordinateAxis1D yAxis = (CoordinateAxis1D) 
gcs.getYHorizAxis();
                        if (xAxis != null) {
                            System.out.println(xAxis.toString());
                        }
                        if (yAxis != null) {
                            System.out.println(yAxis.toString());
                        }
                        if (gcs.hasVerticalAxis()) {
                            CoordinateAxis1D zAxis = gcs.getVerticalAxis();
                            System.out.println(zAxis.toString());
                        }
                        if (gcs.hasTimeAxis()) {
                            CoordinateAxis1D tAxis = gcs.getTimeAxis();
                            System.out.println(tAxis.toString());
                        }
                    }
                } else {
                    System.out.println("\tNo grids found.");
                }
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }

    }

}