NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.

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

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
Hi Folks,<br>
<br>
I wondering if this is a bug or a feature.&nbsp; 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.&nbsp; Can somebody
explain why?<br>
<br>
To be sure, I ran the attached code using the 2.2.09 release.<br>
<br>
Roland<br>
<br>
-------- Original Message --------
<table border="0" cellpadding="0" cellspacing="0">
  <tbody>
    <tr>
      <th align="right" nowrap="nowrap" valign="baseline">Subject: </th>
      <td>XYT and XYZT grid with only 1 X and 1 Y point in axis</td>
    </tr>
    <tr>
      <th align="right" nowrap="nowrap" valign="baseline">Date: </th>
      <td>Mon, 08 Aug 2005 11:24:31 -0500</td>
    </tr>
    <tr>
      <th align="right" nowrap="nowrap" valign="baseline">From: </th>
      <td>Roland Schweitzer <a class="moz-txt-link-rfc2396E" 
href="mailto:Roland.Schweitzer@xxxxxxxx";>&lt;Roland.Schweitzer@xxxxxxxx&gt;</a></td>
    </tr>
    <tr>
      <th align="right" nowrap="nowrap" valign="baseline">To: </th>
      <td>netcdf-java <a class="moz-txt-link-rfc2396E" 
href="mailto:netcdf-java@xxxxxxxxxxxxxxxx";>&lt;netcdf-java@xxxxxxxxxxxxxxxx&gt;</a></td>
    </tr>
  </tbody>
</table>
<br>
<br>
<pre>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:

<a class="moz-txt-link-freetext" 
href="http://dods.ndbc.noaa.gov/cgi-bin/nph-dods/dods/stdmet/42001/42001h2001.nc";>http://dods.ndbc.noaa.gov/cgi-bin/nph-dods/dods/stdmet/42001/42001h2001.nc</a>


XYZT Grid:

<a class="moz-txt-link-freetext" 
href="http://dods.ndbc.noaa.gov/cgi-bin/nph-dods/dods/adcp/41012/41012a2002.nc";>http://dods.ndbc.noaa.gov/cgi-bin/nph-dods/dods/adcp/41012/41012a2002.nc</a>

Thanks,
Roland

</pre>
</body>
</html>
/**
 * 
 */
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());
            }
        }

    }

}
  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-java archives: