Re: [netcdfgroup] How to read grib2 files using Netcdf Java API?

ok, i see,

your problem is that you dont have grib.jar in your path. youll also
need jpeg2000.jar for grib2. Perhaps you should use toolsUI.jar to
make sure things work, then try paring down to a minimal set of jars
needed after that.

im working on a better description of the jar dependencies, but for
now http://www.unidata.ucar.edu/software/netcdf-java/v4.0/README
should help.

Valliappa Lakshmanan wrote:
> org.wdssii.ncingest.Grib2Ingest is my application i.e. the class that has
> the line of code that calls NetcdfDataSet.open()
>
> Lak
>
> On Tue, Jan 20, 2009 at 4:23 PM, John Caron <caron@xxxxxxxxxxxxxxxx
> <mailto:caron@xxxxxxxxxxxxxxxx>> wrote:
>
>     Hi Lak:
>
>     You have a strange class: "org.wdssii.ncingest.Grib2Ingest" where does
>     that come from ?
>
>
>
>     Valliappa Lakshmanan wrote:
>     > John,
>     >
>     > I downloaded the latest netcdf-4.0.jar and tried it.  I still get the
>     > same problem.  Here's the stacktrace, in case the line numbers help
>     > isolate the issue:
>     >
>     >     [java] 2009-01-20 14:26:46,867 [main] WARN
>     > org.wdssii.ncingest.Grib2Ingest - java.io.IOException: Cant read
>     > /scratch2/lakshman/modelmining/WRFPRS_GrbF21.grib2: not a valid
>     NetCDF file.
>     >      [java]     at ucar.nc2.NetcdfFile.open(NetcdfFile.java:628)
>     >      [java]     at ucar.nc2.NetcdfFile.open(NetcdfFile.java:335)
>     >      [java]     at ucar.nc2.NetcdfFile.open(NetcdfFile.java:305)
>     >      [java]     at ucar.nc2.NetcdfFile.open(NetcdfFile.java:292)
>     >      [java]     at ucar.nc2.NetcdfFile.open(NetcdfFile.java:280)
>     >
>     > The code that throws the exception is simply:
>     >      NetcdfDataset.open("/scratch2/..../filename.grib2");
>     >
>     > My classpath consists of the following jar files (netcdf
>     dependencies in
>     > bold):
>     >
>     > commons-logging.jar
>     > *jdom_1.1.jar*
>     > jnotify-0.91.jar
>     > jstl.jar
>     > junit.jar
>     > *log4j-1.2.14.jar*
>     > *netcdf-4.0.jar*
>     > servlet-api.jar
>     > *slf4j-api-1.1.0.jar
>     > slf4j-log4j12-1.1.0.jar*
>     > spring.jar
>     > standard.jar
>     >
>     > thanks
>     > Lak
>     >
>     >
>     > On Fri, Dec 12, 2008 at 6:06 PM, John Caron
>     <caron@xxxxxxxxxxxxxxxx <mailto:caron@xxxxxxxxxxxxxxxx>
>     > <mailto:caron@xxxxxxxxxxxxxxxx <mailto:caron@xxxxxxxxxxxxxxxx>>>
>     wrote:
>     >
>     >     Hi Lak:
>     >
>     >     Im not having any trouble opening from either 4.0 or latest
>     2.2. Can
>     >     you recheck your classpath? Also 4.0 has got less bugs in it
>     at this
>     >     point, so you might try it.
>     >
>     >     Valliappa Lakshmanan wrote:
>     >     > John, thanks for looking at this. The file (74MB) is now at:
>     >     >
>     >     > http://cimms.ou.edu/~lakshman/data/WRFPRS_GrbF21.grib2
>     <http://cimms.ou.edu/%7Elakshman/data/WRFPRS_GrbF21.grib2>
>     >     <http://cimms.ou.edu/%7Elakshman/data/WRFPRS_GrbF21.grib2>
>     >     >
>     >     > Lak
>     >     >
>     >     >
>     >     > On Fri, Dec 12, 2008 at 1:28 PM, John Caron
>     >     <caron@xxxxxxxxxxxxxxxx <mailto:caron@xxxxxxxxxxxxxxxx>
>     <mailto:caron@xxxxxxxxxxxxxxxx <mailto:caron@xxxxxxxxxxxxxxxx>>
>     >     > <mailto:caron@xxxxxxxxxxxxxxxx
>     <mailto:caron@xxxxxxxxxxxxxxxx> <mailto:caron@xxxxxxxxxxxxxxxx
>     <mailto:caron@xxxxxxxxxxxxxxxx>>>>
>     >     wrote:
>     >     >
>     >     >     Hi Lak:
>     >     >
>     >     >     NetcdfDataset.open() should have worked.
>     >     >
>     >     >     Can you send us the file, and we'll check why its not
>     working.
>     >     >
>     >     >     Valliappa Lakshmanan wrote:
>     >     >     > I know there must be a very simple way to do this, but I
>     >     can't seem to
>     >     >     > find any example or documentation.
>     >     >     >
>     >     >     > I want to read a Grib2 file using the Java Netcdf API
>     and tried:
>     >     >     >
>     >     >     > File file = new File("/tmp/WRFPRS_GrbF21.grib2");  // a
>     >     grib2 file
>     >     >     > NetcdfFile ncfile =
>     NetcdfDataset.open(file.getAbsolutePath());
>     >     >     >
>     >     >     > but get an IOException stating: Cant read
>     >     >     /tmp/WRFPRS_GrbF21.grib2: not
>     >     >     > a valid NetCDF file.
>     >     >     >
>     >     >     > I tried using ucar.dt.grid.GridDataSet.open() and got the
>     >     same result.
>     >     >     >
>     >     >     > In case it was a classpath/jar problem, I added
>     toolsUI.jar from
>     >     >     netcdf
>     >     >     > 2.2.22 to my classpath (has grib.jar).
>     >     >     > Same result.  What am I missing?
>     >     >     >
>     >     >     > thanks
>     >     >     > Lak
>     >     >     >
>     >     >     >
>     >     >     >
>     >     >     >
>     >     >
>     >
>     ------------------------------------------------------------------------
>     >     >     >
>     >     >     > _______________________________________________
>     >     >     > netcdfgroup mailing list
>     >     >     > netcdfgroup@xxxxxxxxxxxxxxxx
>     <mailto:netcdfgroup@xxxxxxxxxxxxxxxx>
>     >     <mailto:netcdfgroup@xxxxxxxxxxxxxxxx
>     <mailto:netcdfgroup@xxxxxxxxxxxxxxxx>>
>     >     <mailto:netcdfgroup@xxxxxxxxxxxxxxxx
>     <mailto:netcdfgroup@xxxxxxxxxxxxxxxx>
>     >     <mailto:netcdfgroup@xxxxxxxxxxxxxxxx
>     <mailto:netcdfgroup@xxxxxxxxxxxxxxxx>>>
>     >     >     > For list information or to unsubscribe,  visit:
>     >     >     http://www.unidata.ucar.edu/mailing_lists/
>     >     >
>     >     >
>     >
>     >
>
>



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