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.

[netcdf-java] IOException in CFGridWriter2 when using lat/lon bounding box

Hello,

I’m getting an IOException in CFGridWriter2.writeFile when writing to netcdf4 
or netcdf4_classic files and specifying a lat/lon bounding box.  Here’s the 
stack trace:

Mar 30, 2015 2:25:51 PM ucar.nc2.jni.netcdf.Nc4Iosp load
INFO: NetCDF-4 C library loaded (jna_path='null', libname='netcdf').
NetCDF-4 C library loaded (jna_path='null', libname='netcdf').
Netcdf nc_inq_libvers='4.3.2 of Feb 11 2015 10:12:33 $' isProtected=false
Exception in thread "main" java.io.IOException: -101: NetCDF: HDF error
        at ucar.nc2.jni.netcdf.Nc4Iosp.writeData(Nc4Iosp.java:2767)
        at ucar.nc2.jni.netcdf.Nc4Iosp.writeData(Nc4Iosp.java:2721)
        at ucar.nc2.NetcdfFileWriter.write(NetcdfFileWriter.java:934)
        at ucar.nc2.NetcdfFileWriter.write(NetcdfFileWriter.java:918)
        at ucar.nc2.FileWriter2.copyAll(FileWriter2.java:427)
        at ucar.nc2.FileWriter2.copyVarData(FileWriter2.java:380)
        at 
ucar.nc2.dt.grid.CFGridWriter2.writeOrTestSize(CFGridWriter2.java:240)
        at ucar.nc2.dt.grid.CFGridWriter2.writeFile(CFGridWriter2.java:112)
        at SimpleConversionTest.main(SimpleConversionTest.java:30)

 Here is my test code:

///////////////////////////////////////////////////////////////////
import ucar.nc2.dt.grid.GridDataset;
import ucar.nc2.dt.grid.CFGridWriter2;
import ucar.nc2.NetcdfFileWriter;
import ucar.unidata.geoloc.LatLonRect;
import ucar.ma2.InvalidRangeException;

import java.io.IOException;
import java.util.List;
import java.util.ArrayList;

public class SimpleConversionTest {

    public static void main(String[] args) 
            throws IOException, InvalidRangeException {

        String path = "./";
        String in_filename = 
"patmosx_v05r04_GOES-13_geo_d201305100515_c20150301.nc";
        String out_filename = "test-out.nc";

        // assemble list of parameters we want to include
        List<String> gridList = new ArrayList<String>();
        gridList.add("temp_11_0um_nom");

        GridDataset gd = GridDataset.open(path+in_filename);

        LatLonRect rect = new LatLonRect("41, -91, 5, 5");
        System.out.println("LowerLeft: " + rect.getLowerLeftPoint());
        System.out.println("UpperRight: " + rect.getUpperRightPoint());
        CFGridWriter2.writeFile(
                gd,
                gridList,
                rect, // lat/lon subset
                null, // projRect, can be null
                1, // horizStride
                null, // zRange
                null, // dateRange
                1, // strideTime
                true, // addLatLon, not sure what this does
                NetcdfFileWriter.createNew(
                        NetcdfFileWriter.Version.netcdf4,
                        path+out_filename
                    )
                );

        gd.close(); 

    }

}
///////////////////////////////////////////////////////////////////

If I specify “null” to CFGridWriter2.writeFile’s lat/lon subset argument, the 
code executes successfully.  But, the lat/lon subsetting feature is key to what 
we are trying to accomplish. Also, if I use “netcdf3” as the filetype, the code 
will execute successfully even with the subset box specified.

The input file used by the example code can be found here:
ftp://ftp.ssec.wisc.edu/pub/ssec/patmosx_v05r04_GOES-13_geo_d201305100515_c20150301.nc
 
<ftp://ftp.ssec.wisc.edu/pub/ssec/patmosx_v05r04_GOES-13_geo_d201305100515_c20150301.nc>

Version details:
I’m using "netcdfAll-4.5.jar” dated March 6, 2015.  (I just grabbed a 4.6 jar 
and am getting the same error there as well).
HDF5 version:  1.8.14
NetCDF4 (native) version:  4.3.2

Thanks for any help or advice!
Mike Hiley
CIMSS/SSEC/UW-Madison

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