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

Re: Fw: decoders] Grib1 Indexer and GDS info (fwd)



Bali,

your support msg has been sitting in my spam folder for months now, i just clean it out so that;s the reason for delay. There is an online support on unidata's home page and it's more dependable.

I going to address your msg in a general manner until we get to the same level. The Grib decoder package was meant to only be a low level API, the data resolution that you are looking for would be easier to use a ToolsUI program the uses the Grib package. Actually i think you should be able to do the refinement w/o doing any coding. The ToolsUI program is located at:
https://www.unidata.ucar.edu/software/netcdf-java/

It will read in the file and it has options to select areas of data, the documentation is a little scarce but intuitive. The is also NCML that will let you manipulate the output files.


On the other hand:
The grib package provides a dump, indexer and getData program that can be used as templates to get the info you were looking for. There are javadocs on all these routines on the decoders page.

There is also a display package IDV that could do the data processing.


Hope this helps.
RObb...











---------- 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)




===============================================================================
Robb Kambic                                Unidata Program Center
Software Engineer III                      Univ. Corp for Atmospheric Research
address@hidden             WWW: http://www.unidata.ucar.edu/
===============================================================================