[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDFJava #HMB-497600]: Reading NDFD Files

This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.


  • Subject: [netCDFJava #HMB-497600]: Reading NDFD Files
  • Date: Tue, 27 Apr 2010 13:35:08 -0600

Hi Rob,

This is going to be a short answer because I'm leaving town today until May6. 
The coordinates are x and y for the NDFD type data. Once you have the file open 
as a GridDataset, then you can get the NetcdfFile associated with the 
GridDataset and get the values for x and y.

      NetcdfFile ncf = gridDataSet.getNetcdfFile();
      List<Variable> vars = ncf.getVariables();
      for (Variable var : vars) {
        System.out.println(var.getName());
      }
      Variable x = ncf.findVariable("x");
      // need to get the correct dimension here, 1072 was from my sample file
      Array data = x.read("0:1072");
      IndexIterator iter = data.getIndexIterator();
      System.out.print("x = "); 
      while (iter.hasNext()) {
        int val = iter.getIntNext();
        System.out.print(val +" ");
      }
      System.out.println();

      One also has get the y variable too.

      There are some GridCoordSys() routines to help too.

     
http://www.unidata.ucar.edu/software/netcdf-java/v2.2.22/javadoc/ucar/nc2/dt/GridCoordSystem.html

     There's probably a better way of doing this, I can revisit when I get back
Robb...


Ticket Details
===================
Ticket ID: HMB-497600
Department: Support netCDF Java
Priority: Normal
Status: Open