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

[netCDFJava #QDJ-903556]: error when reading grib2 files



Hi Ravi,

We highly recommend that you use the netCDF-java API rather than the GRIB 
library API. If you are not familiar with the netCDF-Java library, the 
following are good links to help you get started.

The netCDF-Java Tutorial: 
http://www.unidata.ucar.edu/software/netcdf-java/tutorial/index.html

and the javadocs:

http://www.unidata.ucar.edu/software/netcdf-java/v4.1/javadoc/index.html

in particular the javadocs for ucar.nc2.NetcdfFile and 
ucar.nc2.dataset.NetcdfDataset may be useful. The following could replace your 
RandomAccessFile and GRIB library call:

  NetcdfFile ncf = NetcdfFile.open( "C:\\temp\\ruc2.t00z.bgrb20f01.grib2");

We make this recommendation because the GRIB library is a very low level 
library that lacks many of the features of the netCDF-java library. If there 
are details of the GRIB file that you need and are not able to access through 
the netCDF-Java library, we would like to hear about that and fix the omission 
if possible.

Thanks,

Ethan

Robb Kambic wrote:
> The library doesn't permit one to access individual sections of a Grib
> file unless there is a file seek to the starting point to the section
> first. Since you are writing code, look at Grib2Input.scan() method to
> see the order in which the sections are read sequentially. There is a
> program called Grib2Dump that reads a grib file and it returns all the
> metadata about a file including offsets to important sections so that
> one can seek to those offsets then read the sections. There are
> javaDocs to the grib library at:
> http://www.unidata.ucar.edu/software/decoders/

> There is a program that manages the details of a grib file, it's called
> ToolsUI that will let you view the metadata as well as extract the data,
> it's also on the netcdf-java page.

> The error you encounter was that the file pointer was not at the start
> of the Grib2IndicatorSection in the grib file, it was at the header of
> the file.
>
> Ravi Bhargava wrote:
> > I am trying to read in grib2 files at 
> > ftp://ftpprd.ncep.noaa.gov/pub/data/nccf/com/ruc/prod/ruc2a.20100216/
> > using the jar netcdfAll-4.1.jar as below:
> > 
> > public static void main(String[] args) {
> > try {
> >   RandomAccessFile random =  new 
> > RandomAccessFile("C:\\temp\\ruc2.t00z.bgrb20f01.grib2","rw");
> >   Grib2IndicatorSection section0 = new 
> > Grib2IndicatorSection(random);<-----error here ........
> > }
> > catch(IOException ex) {
> >   ex.printStackTrace();
> >   System.out.println("exception="+ex.getMessage());
> > }
> > }
> > 
> > I get the following exception:
> > 
> > ucar.grib.NotSupportedException: GRIB edition 66 is not yet supported
> > at 
> > ucar.grib.grib2.Grib2IndicatorSection.<init>(Grib2IndicatorSection.java:125)
> > 
> > Please let me know how to fix this problem.


Ticket Details
===================
Ticket ID: QDJ-903556
Department: Support netCDF Java
Priority: Normal
Status: Closed