This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
On Tue, 26 Feb 2008, Jelle Ferwerda wrote:
Dear Rob,Finally.. I cracked it. I took one of the files in the indexer, and deleted all that was unneeded for my implementation.
Good job, if you want to read the data for that product you could add the code:
Grib2Data g2d = new Grib2Data(raf); float data[] = g2d.getData(GdsOffset, PdsOffset); if (data != null) { int row = 0; for (int j = 0; j < data.length; j++) { //if( j % 800 == 0 ) // used to test quasi data //ps.println( "row ="+ row++ ); ps.println("data[ " + j + " ]=" + data[j]); } } raf.close(); This code was extracted from Grib2GetData.java. robb...
I realize.. It is not the cleanest code in the world, but I managed to get the gdsoffset; I am sure I can get the rest to work too. Also, I found out that IDL can be called through a java interface, so all the data processing I will just handle in a familiar environment.Thanks so much for your assistence! Cheers, Jelle.PS: The code I use now for finding the offset (Still need to integrate & type juggle a bit) is:String InFile = "C:\\java\\data\\MPE_20080222_0915_M9_00.grb"; int ProdInt = 0; // Index nr of product we want // Yes we want output to memory Boolean ToMem = true; // Create a unidata specified RandomAccesFile for readingucar.unidata.io.RandomAccessFile InRA = new ucar.unidata.io.RandomAccessFile(InFile, "r"); try {InRA.seek(0); // Create an index of the file Grib2Input g2i = new Grib2Input(InRA); g2i.scan(true, false); ArrayList products = g2i.getProducts(); for (int i = 0; i < products.size(); i++) {if(i==ProdInt) // This I could clean up and just all the ProdInt in once go{ Grib2Product product = (Grib2Product) products.get(i); Grib2ProductDefinitionSection pds = product.getPDS(); Grib2IdentificationSection id = product.getID(); long GDSOFF = product.getGdsOffset(); long PDSOFF = product.getPdsOffset(); System.out.println(GDSOFF); System.out.println(PDSOFF); } } } catch (NotSupportedException noSupport) { System.err.println("NotSupportedException : " + noSupport); } System.out.println( "-----------------end------------------------"); ----------------------------------------------- Jelle Ferwerda Postdoctoral Research Fellow Animal Behavior Research Group Department of Zoology / University of Oxford South Parks Road / Oxford / OX13PS United Kingdom email: address@hidden Office Phone: +44 18652 71214 WWW: http://www.bio-vision.nl http://www.cookseasonal.com -----------------------------------------------
=============================================================================== Robb Kambic Unidata Program Center Software Engineer III Univ. Corp for Atmospheric Research address@hidden WWW: http://www.unidata.ucar.edu/ ===============================================================================