---------- Forwarded message ----------
Date: Tue, 5 Aug 2008 10:59:21 -0400
From: "Bali, Pelin" <address@hidden>
To: address@hidden
Subject: decoders] Grib1 Indexer and GDS info
I am using the Grib1Indexer to read the Grib file. I need to get the
information lat, long, and nxny (145 X 73) as indicated below. I tried
to use Index.GdsRecord, however I wasn't successful. Although I could
get start points of lat and long, I wasn't able to get neither
resolution nor the end points of lat & long by using gdsRecord. Could
you please show me some that direction on how to get this information?
Thanks in advance.
------------
rec 98:1554711:date 2008080400 TMP kpds5=11 kpds6=105 kpds7=2
levels=(0,2) grid=16 2 m above gnd 24hr fcst:
TMP=Temp. [K]
timerange 0 P1 24 P2 0 TimeU 1 nx 145 ny 73 GDS grid 0 num_in_ave 0
missing 0
center 1 subcenter 0 process 45 Table 1 scan: WE:SN winds(N/S)
latlon: lat -90.000000 to 90.000000 by 2.500000 nxny 10585
long 0.000000 to 360.000000 by 2.500000, (145 x 73) scan 64
mode 128 bdsgrid 1--
The following is how I use the grib indexer to get the grib data.
RandomAccessFile raf = new RandomAccessFile(filePath, "r");
Grib1Indexer indexer = new Grib1Indexer();
PrintStream ps = new PrintStream(indexPath);
indexer.writeFileIndex(raf, ps, false );
Index index = new Index();
boolean rc = index.open(indexPath);
ArrayList gribIndexRecords = index.getGribRecords();
ArrayList<GdsRecord> gdsRecords = index.getHorizCoordSys();
//
// Build a hashmap for the GDS keys.
//
java.util.HashMap gdsMap = new java.util.HashMap();
for (int a = 0; a < gdsRecords.size(); a++) {
GdsRecord gdsRecord = gdsRecords.get(a);
gdsMap.put(gdsRecord.gdsKey, gdsRecord);
}
for (Iterator it = gribIndexRecords.iterator (); it.hasNext (); ) {
zz++;
GribRecord gribRecord = (GribRecord)it.next();
if (gribRecord != null) {
//
// Select only temperature.
//
if (gribRecord.paramNumber == 11 ) {
if (gribRecord.levelType1 == 105) {
if (gribRecord.levelValue1 == 2.0) {
if (gribRecord.forecastTime ==
24) {
Grib1Data grib1data =
new Grib1Data(raf);
if (gdsMap.get(gribRecord.gdsKey) !=
null) {
GdsRecord gds =
(GdsRecord)gdsMap.get(gribRecord.gdsKey);
System.out.println("Dx: " + gds.dx);
System.out.println("Dy: " + gds.dy);
System.out.println("Grid Shape Code: " + gds.grid_shape_code);
System.out.println("Grid Type: " + gds.grid_type);
System.out.println("La1: " + gds.La1);
System.out.println("LaD: " + gds.LaD);
System.out.println("Latin1: " + gds.latin1);
System.out.println("Latin2: " + gds.latin2);
System.out.println("Lo1: " + gds.Lo1);
System.out.println("LoV: " + gds.LoV);
System.out.println("Major Axis Earth " + gds.major_axis_earth);
System.out.println("Minor Axis Earth " + gds.minor_axis_earth);
System.out.println("Nx: " + gds.nx);
System.out.println("Ny: " + gds.ny);
System.out.println("Radius Spherical Earth: " +
gds.radius_spherical_earth);
System.out.println("Resolution: " + gds.resolution);
System.out.println("Winds: " + gds.winds);
}
float[] arr =
grib1data.getData(gribRecord.offset1, gribRecord.decimalScale,
gribRecord.bmsExists);
} // hour 24
} // 2m
} //above ground
} // end of temperature
} // grib record is not null
} // end for
Sincerely,
Pelin Bali
WeatherPredict Consulting, Inc.
3200 Atlantic Avenue, Suite 114
Raleigh, NC 27604
Phone (Direct): 919-239-8833
Phone (Main) : 919-876-3633
Fax : 919-876-4469
"Imagination will often carry us to worlds that never were.
But without it we go nowhere." - Carl Sagan (Cosmos - 1980)