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.
Hiya Rob,
Here's some code snippets for using GridDataset getting times for a variable
and NetcdfFile to get the time.
RObb...
GridDataset gridDataSet = GridDataset.open( fileName );
GridDatatype mt = gridDataSet.findGridDatatype("Minimum_temperature");
List times = ((GeoGrid) mt).getTimes();
for( Object t : times ) {
System.out.println( t.toString() );
}
or
NetcdfFile ncf = NetcdfFile.open( fileName );
// time dimension is also a variable
Variable time = ncf.findVariable("time");
Array data = time.read("0:39");
IndexIterator iter = data.getIndexIterator();
System.out.print("time = ");
while (iter.hasNext()) {
int val = iter.getIntNext();
System.out.print(val +" ");
}
Ticket Details
===================
Ticket ID: HMB-497600
Department: Support netCDF Java
Priority: Normal
Status: Open