Hi everyone,

I was hoping to get some help with reading values from a GRIB file for a
certain pressure level. I can successfully read values for single level
fields but when it comes to specifying a pressure level, I'm stuck.

I'm working with the GFS GRIB files available at
http://www.ftp.ncep.noaa.gov/data/nccf/com/gfs/prod/gfs.2018012300/ etc. as
gfs.t00z.pgrb2.0p50.f000 etc.

I've determined that the "Temperature_isobaric" coverage has "TIME" (one
value per file) and "isobaric" dimensions, with the latter having 31
pressure levels between 100 and 100,000 Pa.

The relevant part of my code is as follows:

NetCDFReader reader = new NetCDFReader(..., null);

//dynamic parameters
Map<String, ParameterDescriptor<List>> parameterDescriptors = new
HashMap<>();
for (ParameterDescriptor<List> parameterDescriptor :
reader.getDynamicParameters(coverageName))
    parameterDescriptors.put(parameterDescriptor.getName().getCode(),
parameterDescriptor);

//time parameter
ParameterValue<List> timeValue = ImageMosaicFormat.TIME.createValue();
timeValue.setValue(Collections.singletonList(Date.from(Instant.parse("..."))));
//single time step in GRIB

//isobaric parameter
ParameterValue<List> dynamicValue =
parameterDescriptors.get("ISOBARIC").createValue();
dynamicValue.setValue(Collections.singletonList(85000.)); //85000 Pa
pressure level

GridCoverage2D grid = reader.read(coverageName, new GeneralParameterValue[]
{ timeValue, dynamicValue });
DirectPosition position = new
DirectPosition2D(reader.getCoordinateReferenceSystem(), 150, -34);
logger.info("Values: {}", grid.getDebugString(position));

and the resulting exception (thrown at the call to read()) is as follows:

WARNING: Unable to compute source area for URL file:/...
javax.imageio.IIOException: Can't read file file:/...
at
org.geotools.imageio.netcdf.NetCDFImageReader.netcdfFailure(NetCDFImageReader.java:520)
at
org.geotools.imageio.netcdf.NetCDFImageReader.readSection(NetCDFImageReader.java:835)
at
org.geotools.imageio.netcdf.NetCDFImageReader.read(NetCDFImageReader.java:739)
at org.geotools.coverage.io.ReadType$1.read(ReadType.java:81)
at
org.geotools.coverage.io.netcdf.NetCDFResponse.loadRaster(NetCDFResponse.java:646)
at
org.geotools.coverage.io.netcdf.NetCDFResponse.processRequest(NetCDFResponse.java:290)
at
org.geotools.coverage.io.netcdf.NetCDFResponse.createResponse(NetCDFResponse.java:147)
at org.geotools.coverage.io.netcdf.NetCDFSource.read(NetCDFSource.java:65)
at org.geotools.coverage.io.netcdf.NetCDFReader.read(NetCDFReader.java:489)
...
Caused by: ucar.ma2.InvalidRangeException: Illegal Range for dimension 0:
last requested 25 > max 0
at ucar.ma2.Section.fill(Section.java:179)
at ucar.nc2.Variable.read(Variable.java:709)
at
org.geotools.imageio.netcdf.NetCDFImageReader.readSection(NetCDFImageReader.java:833)
... 9 more

Referring to "Illegal Range for dimension 0: last requested 25 > max 0",
the 25 is the index of 85000 (Pa) in the list of 31 pressure levels, but
this index seems to be being applied to a different, single value,
dimension (e.g. time).

If I provide no parameters in the call to read, the value for 100 Pa (the
first and, presumably, default level) is successfully extracted.

Any hints regarding where I might be going wrong would be greatly
appreciated.

Regards,
Andrew



-- 
*Andrew Miskelly*
Senior Developer
*T *  +61 2 9965 9200
*E   *amiske...@weatherzone.com.au



www.weatherzone.com.au | business.weatherzone.com.au
supp...@weatherzone.com.au | sa...@weatherzone.com.au

<http://www.facebook.com/weatherzone>  <http://www.twitter.com/weatherzone>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
GeoTools-GT2-Users mailing list
GeoTools-GT2-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to