[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[netCDFJava #QDJ-903556]: error when reading grib2 files
- Subject: [netCDFJava #QDJ-903556]: error when reading grib2 files
- Date: Mon, 22 Feb 2010 10:18:35 -0700
Hiya Ravi,
As Ethan mentioned, using the netCDF-java API eliminates the need to deal with
the many details of the Grib format. As a test case, one file was downloaded
from the ftp site and it opened fine in the ToolsUI program. Also, the file was
dumped using the Grib2Dump grib library utility. This is working below the
netCDF API so I don't suggest using these programs.
% java -Xmx256m ucar.grib.grib2.Grib2Dump ruc2.t00z.bgrb13anl.grib2
Looking at your code snipet, it appears that the opened RandomAccessFile never
set the order to RandomAccessFile.BIG_ENDIAN so the data wasn't read correctly.
This a code extraction from the Grib2Dump program:
raf = new RandomAccessFile(args[0], "r");
raf.order(RandomAccessFile.BIG_ENDIAN);
// Create Grib2Input instance
Grib2Input g2i = new Grib2Input(raf);
// boolean params getProductsOnly, oneRecord
g2i.scan(false, false);
// record contains objects for all 8 Grib2 sections
List records = g2i.getRecords();
for (int i = 0; i < records.size(); i++) {
Grib2Record record = (Grib2Record) records.get(i);
Grib2IndicatorSection is = record.getIs();
Grib2IdentificationSection id = record.getId();
Grib2GridDefinitionSection gds = record.getGDS();
Grib2ProductDefinitionSection pds = record.getPDS();
}
Again it will save yourself much time working at the netCDF API level.
RObb...
Ticket Details
===================
Ticket ID: QDJ-903556
Department: Support netCDF Java
Priority: Normal
Status: Open