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

[netCDFJava #APE-712909]: How To Get Grib2Pds.TimeInterval of Grib2 File



Grib2Customizer.getForecastTimeInterval();

what is the large data processing system?

John

> Hello John,
> We are building a large data processing system with NetCDF java utilities, 
> nearly 90% of the codes are finished, however we are using low level Grib 
> APIs. I think totally substitution all the low level APIs into high level 
> APIs requires too much work. We just want to know how to retrieve the 
> forecast range when Grib2Pds.isTimeInterval() equals to "true". So could you 
> give me some suggestions?
> By the way, here is our Java simple demo girb2 decoder, could you give us an 
> equal demo please, using high level APIs like NetCDFFile.open()? Because the 
> documentations are not so detail, so we don't quite know about how to use the 
> high level APIs to decode grib files.
> 
> 
> import java.io.IOException;
> import ucar.nc2.grib.GribTables;
> import ucar.nc2.grib.grib1.*;
> import ucar.nc2.grib.grib1.Grib1Gds.LatLon;
> import ucar.nc2.grib.grib1.tables.Grib1ParamTableReader;
> import ucar.nc2.grib.grib2.*;
> import ucar.nc2.grib.grib2.table.*;
> import ucar.unidata.io.RandomAccessFile;
> 
> public class SimpleDecoder {
> 
> public static void readGrib2(String fileName) throws IOException {
> RandomAccessFile raf = new RandomAccessFile (fileName, "r");
> Grib2RecordScanner reader = new Grib2RecordScanner(raf);
> while (reader.hasNext()) {
> Grib2Record record = reader.next();
> Grib2SectionIdentification identification = record.getId();
> Grib2SectionGridDefinition gridDefinition = record.getGDSsection();
> Grib2Gds.LatLon gdsLatLon = (Grib2Gds.LatLon) gridDefinition.getGDS();
> Grib2Pds grib2Pds = record.getPDS();
> Grib2Customizer customizer = Grib2Customizer.factory (record);
> Grib2Customizer grib2Customizer = Grib2Customizer.factory( record );
> 
> //get Element Name
> GribTables.Parameter grib2Parameter = grib2Customizer.getParameter( 
> record.getIs().getDiscipline(), grib2Pds.getParameterCategory(), 
> grib2Pds.getParameterNumber() );
> String element = grib2Parameter.getName();
> String unit = grib2Parameter.getUnit();
> 
> int levelType = grib2Pds.getLevelType1();
> int level;
> if ( levelType == 100 )//Isobaric surface
> level = (int)record.getPDS().getLevelValue1() / 100;//Pa to hPa
> 
> int year = identification.getYear();
> int month =  identification.getMonth();
> int day = identification.getDay();
> int hour = identification.getHour();
> 
> int forecastTime = record.getPDS().getForecastTime();
> if ( grib2Pds.isTimeInterval() )
> {
> 
> }
> else
> {
> 
> }
> 
> //get grid range
> float startLatitude = gdsLatLon.la1;
> float endLatitude = gdsLatLon.la2;
> float LatitudeGridSpace = gdsLatLon.deltaLat;
> int ny = gdsLatLon.getNy();
> float startLongitude = gdsLatLon.lo1;
> float endLongitude = gdsLatLon.lo2;
> float longitudeGridSpace = gdsLatLon.deltaLon;
> int nx = gdsLatLon.getNx();
> 
> float data[] = record.readData( raf );//get Data
> }
> }
> }
> 
> 
> 
> > To: address@hidden
> > Subject: [netCDFJava #APE-712909]: How To Get Grib2Pds.TimeInterval of 
> > Grib2 File
> > Date: Thu, 16 Apr 2015 13:20:52 -0600
> > CC: address@hidden
> > From: address@hidden
> >
> > > Hello,
> > > When I'm decoding a Grib2 file, I meet some elements like APCP, whose 
> > > Grib2Pds.isTimeInterval() equals to "true", so maybe I should get the 
> > > Grib2Pds.TimeInterval.timeRangeLength instead of 
> > > Grib2Pds.getForecastTime(). But the Grib2Pds.TimeInterval is a static 
> > > nested class if Grib2Pds, so how can I get the variable of 
> > > Grib2Pds.TimeInterval with an instance of outer class Grib2Pds? Could you 
> > > provide me a demo Java program? Thanks.
> > >
> > > Ruotong Wang
> > >
> >
> > Hi Ruotong :
> >
> > We dont support the low level GRIB at a user level. Just open the file 
> > through NetcdfFile.open().
> >
> > John
> >
> > Ticket Details
> > ===================
> > Ticket ID: APE-712909
> > Department: Support netCDF Java
> > Priority: Normal
> > Status: Closed
> >
> 

Ticket Details
===================
Ticket ID: APE-712909
Department: Support netCDF Java
Priority: Normal
Status: Open