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.
Dear all, I'm having some problems reading data from a particular NetCDF file. The code i'm using is: NetcdfDataset nc NetcdfDataset.openDataset("C:\\data\\OA_20060830.nc", true, null); GridDataset gd = new GridDataset(nc); GeoGrid gg = gd.findGridByName("temperature"); Array arr = gg.readYXData(0, 0); IndexIterator it = arr.getIndexIteratorFast(); while (it.hasNext()) { double val = it.getDoubleNext(); System.out.println("" + val); } nc.close(); I just get a load of NaNs, even though I know that there are valid data in the file (ncBrowse displays the data perfectly). The only unusual thing about the data is that the data are stored as short integers, with an offset and scale factor: short temperature(time, depth, latitude, longitude); :long_name = "Temperature"; :missing_value = 32767; // short :_FillValue = 32767; // short :units = "degree_Celsius"; :valid_min = -3; // short :valid_max = 40; // short :add_offset = 20.0; // double :scale_factor = 0.0010; // double :comment = "Temperature estimate (by objective analysis)"; I understood that the NetcdfDataset class automatically dealt with offsets and scale factors in "enhanced" mode, which is what I am using (or trying to use). Hence I was expecting to "see" the data as an array of doubles. The same happens if I use getFloatNext() or getShortNext(). Can anyone see what I'm doing wrong? Thanks in advance, Jon -- -------------------------------------------------------------- Dr Jon Blower Tel: +44 118 378 5213 (direct line) Technical Director Tel: +44 118 378 8741 (ESSC) Reading e-Science Centre Fax: +44 118 378 6413 ESSC Email: jdb@xxxxxxxxxxxxxxxxxxxx University of Reading 3 Earley Gate Reading RG6 6AL, UK -------------------------------------------------------------- ============================================================================== To unsubscribe netcdf-java, visit: http://www.unidata.ucar.edu/mailing-list-delete-form.html ==============================================================================
netcdf-java
archives: