| I am writing some low level code(because i need to), to read grib files and all the values that i print out on the console do not match the values when i dump them out to a file. The grib file that i am testing against is including in this e-mail for those that want to take a look. |
Attachment:
gfs20090907162501123.grb
Description: Binary data
Also i seem to be having problems getting actual String literals for certain codes.. like the parameter name for code 11 is Temperature and the Unit type is K in this case but it seems that the way to get these are not very intuitive to get using Index and my GribRecords variable in the code below. Maybe someone could shed some light on this?? In advance, i want to thank all those that can take the time to look through this. --Chad here is my code below with output: public class GribPlugin { java.io.PrintStream ps; String[] fileDump; Grib1GridDefinitionSection gridSection; String testfile = "gfs20090907162501123.grb"; public GribPlugin() throws IOException, NoValidGribException, NotSupportedException{ ucar.unidata.io.RandomAccessFile gribfile = new ucar.unidata.io.RandomAccessFile(testfile, "rw"); type = file.getEdition(gribfile); System.out.println("File read in: " + testfile + ", Type of Grib File is " + type); fileDump = new String[3]; fileDump[0] = "gfs20090907162501123.grb"; fileDump[1] = "gribdump.out"; fileDump[2] = "true"; try{ gridSection = new Grib1GridDefinitionSection(gribfile); System.out.println("defining a new gridsection"); } catch(IOException e){ throw new IOException("Grid Section " + e); } System.out.println("grid definition section"); System.out.println("dx: " + gridSection.getDx() + ", dy: " + gridSection.getDy() + ", La1: " + gridSection.getLa1() + ", La2: " + gridSection.getLa2() + ", Lo1: " + gridSection.getLo1() + ", Lo2: " + gridSection.getLo2() + ", Nx: " + gridSection.getNx() + ", Ny: " + gridSection.getNy() + ", Grid Section Name: " + gridSection.getName()); System.out.println("File Dump Information"); gribDump.main(fileDump); System.out.println("Dump GridFile Info Out To File"); ps = new java.io.PrintStream("grib.out"); index = gribIndex.writeFileIndex(gribfile, ps, true);
//this is printing out the grib records System.out.println("Grib Records"); gribRecords = index.getGribRecords(); System.out.println("Number of Grib Records: " + gribRecords.size()); for(int i = 0; i < gribRecords.size(); i++){ System.out.println(gribRecords.get(i).category + " " + gribRecords.get(i).center + " " + gribRecords.get(i).discipline + " " + gribRecords.get(i).paramNumber + " " + <--how do you convert this to the equivalent param name?? gribRecords.get(i).productType + " " + gribRecords.get(i).decimalScale + " " + gribRecords.get(i).gdsKey + " " + gribRecords.get(i).typeGenProcess + " " + gribRecords.get(i).forecastTime + " " + gribRecords.get(i).refTime + " " + gribRecords.get(i).subCenter + " " + gribRecords.get(i).bmsExists); } //end for } //end public class constructor } // end class GribPlugin Console Output: File read in: gfs20090907162501123.grb, Type of Grib File is 1 GribPDSLevel: Table 3 level 96 is not implemented yet PDS: Time Unit 9 is not yet supported Using default table:resources/grib/tables/wmo_2_v1.tab (0:0:-1) defining a new gridsection Grid 28 not configured yet grid definition section dx: 2.632, dy: 0.0, La1: -8355.851, La2: 591.622, Lo1: 65.536, Lo2: 0.256, Nx: 540, Ny: 24583, Grid Section Name: Latitude/Longitude Grid File Dump Information gds exception was caught Dump GridFile Info Out To File Grib Records Number of Grib Records: 3 -1 7 0 11 10 1 2350466037 96 24 2009-09-07T06:00:00Z 0 false -1 7 0 11 10 1 2350466037 96 48 2009-09-07T06:00:00Z 0 false -1 7 0 11 10 1 2350466037 96 72 2009-09-07T06:00:00Z 0 false ***** Now you will notice that my grid definition section does not match any of the parameters from the grid dump below(except for the grid section name). My question is, is why is this and/or what am i doing wrong here??? Those numbers that i get from the Console output just do not make any sense to me at all. ***** GridDump Output: Header : GRIB1 Discipline : 0 Meteorological Products GRIB Edition : 1 GRIB length : 354 Originating Center : 7 US National Weather Service (NCEP) Originating Sub-Center : 0 WMO Secretariat Product Definition : 10 product valid at reference time P1 Parameter Category : -1 Meteorological Parameters Parameter Name : 11 TMP Temperature Parameter Units : K Reference Time : 2009-09-07T06:00:00Z Time Units : hour Time Range Indicator : product valid at RT + P1 Time 1 (P1) : 24 Time 2 (P2) : 0 Generating Process Type : 96 Global Forecast System Model (formerly known as the Aviation) Level Type : 1 surface Level Value 1 : 0.0 Level Value 2 : 0.0 GDS Exists : true BMS Exists : false Number of data points : 3447 Grid Name : Latitude/Longitude Grid Grid Shape: 0 spherical Spherical earth radius: 6367.47 Nx : 16 Ny : 15 La1 : 0.0 Lo1 : -100.0 Resolution & Component flags : 128 Winds : True La2 : 29.0 Lo2 : -70.0 |
netcdf-java list information:
netcdf-java listnetcdf-java archives: