[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [netcdf-java] Decoding NDFD Severe Weather product Problem
- Subject: Re: [netcdf-java] Decoding NDFD Severe Weather product Problem
- Date: Wed, 5 Jan 2011 12:17:58 -0700 (MST)
Jeff.
GetLocalUseSection attached, made changes so all local use sections are
being written out. These ascii identifiers are similar to the METAR
bulletins identifiers for weather.
Robb...
On Wed, 5 Jan 2011, Jeff Brogden wrote:
Robb,
Hi Jeff,
The current grib decoder doesn't have a path to access the LocalUseSection
directly. The grib library needs to be refactored to permit this option.
With that being said, attached is a standalone program called
GetLocalUseSection that takes 1 or 2 parameters, input Grib file and
optional output file that reads the LocalUseSection of the first record in
the Grib file. Since my test cases didn't have any files that use the
LocalUseSection the code is untested. Could you send a sample file so it
can be added to the test cases? My thinking was you could decoder the
LocalUseSection and then add those parameters. Hopefully this will provide
a path to the LOcalUseSection until the Grib Library can be refactored.
I did not receive an attachment with your email. I don't know if the list
stripped it or not. If you could send it to me again, I would appreciate it.
Thanks,
Here's an url from NDFD about LocalUseSection( section 2 ). From the
documentation, it imples that these parameter might be static, could just
be my interpretation.
From my understanding, and from looking at several data files, the table
matches an integer to a string. In one case, 1 might be AS.Y and the next
time, 1 might be SC.Y. What each integer maps to changes based on the
warnings issued at that time. The text AS.Y and SC.Y, however, mean the same
thing each time. So, there is no way of knowing what the integers stored in
the data section refer to without the table in the LUS to decode them.
Thanks for helping with this problem!
--
=======================================================================
Jeff Brogden CIMMS/OU
address@hidden
===============================================================================
Robb Kambic Unidata Program Center
Software Engineer II Univ. Corp for Atmospheric Research
address@hidden WWW: http://www.unidata.ucar.edu/
===============================================================================
/*
* Copyright 1998-2009 University Corporation for Atmospheric Research/Unidata
*
* Portions of this software were developed by the Unidata Program at the
* University Corporation for Atmospheric Research.
*
* Access and use of this software shall impose the following obligations
* and understandings on the user. The user is granted the right, without
* any fee or cost, to use, copy, modify, alter, enhance and distribute
* this software, and any derivative works thereof, and its supporting
* documentation for any purpose whatsoever, provided that this entire
* notice appears in all copies of the software, derivative works and
* supporting documentation. Further, UCAR requests that the user credit
* UCAR/Unidata in any publications that result from the use of this
* software or in any product that includes this software. The names UCAR
* and/or Unidata, however, may not be used in any advertising or publicity
* to endorse or promote any products or commercial entity unless specific
* written permission is obtained from UCAR/Unidata. The user also
* understands that UCAR/Unidata is not obligated to provide the user with
* any support, consulting, training or assistance of any kind with regard
* to the use, operation and performance of this software nor to provide
* the user with any updates, revisions, new versions or "bug fixes."
*
* THIS SOFTWARE IS PROVIDED BY UCAR/UNIDATA "AS IS" AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL UCAR/UNIDATA BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE ACCESS, USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/**
* User: rkambic
* Date: Jan 4, 2011
* Time: 12:50:08 PM
*/
package ucar.grib.grib2;
import ucar.unidata.io.RandomAccessFile;
import java.io.*;
import java.util.ArrayList;
import java.util.List;
public class GetLocalUseSection {
public static void main( String args[] ) {
RandomAccessFile raf = null;
Grib2Record firstRecord = null;
try {
PrintStream ps = System.out;
if (args.length == 2 ) { // input file, output file
raf = new RandomAccessFile(args[0], "r");
ps = new PrintStream(
new FilterOutputStream(
new FileOutputStream(args[1], false)));
} else if (args.length == 1) {
raf = new RandomAccessFile(args[0], "r");
} else {
System.exit(0);
}
raf.order(RandomAccessFile.BIG_ENDIAN);
Grib2Input g2i = new Grib2Input(raf);
// params getProducts (implies unique GDSs too), oneRecord
raf.seek(0);
g2i.scan(false, false);
List<Grib2Record> record = g2i.getRecords();
for( Grib2Record g2r : record ) {
byte[] lus = g2r.getLocalUseSection() ;
if( lus != null || lus.length != 0 ) {
// packing method
System.out.println( lus[0]);
// account for the packing method, so start with 1
//ps.write( lus, 1, lus.length -1 );
for( int i = 1; i < lus.length; i++ )
ps.print( lus[ i ] +" ");
ps.println();
}
}
ps.flush();
ps.close();
raf.close(); // done reading
// Catch thrown errors from GribFile
} catch (FileNotFoundException noFileError) {
System.err.println("FileNotFoundException : " + noFileError);
} catch (IOException ioError) {
System.err.println("IOException : " + ioError);
}
}
}