Class TLcdGRIBModelDecoder
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdModelDecoder
Each GRIB file contains the values of meteorological parameters (e.g., temperature, pressure...) at different grid points.
Input files
File | Required | Entry point | Description |
---|---|---|---|
*.grb *.grib *.dat *.grib2 *.grb2 |
x | x | GRIB file containing one or more meteorological rasters |
Supported file transfer protocols
- This model decoder supports all transfer protocols that are supported by
the
inputStreamFactory
of this decoder.
Model structure
Depending on the number of decoded datasets, a single model is returned, or acollection of models
.
set behavior
, each model contains
either a single ILcdRaster instance or a single ILcdMultiValuedRaster instance.
A raster is a single tile with unsigned shorts that represent the internal values of
the parameter (or parameters). The GRIB format uses these internal values to eliminate redundancy
and negative or broken values. The actual value of a parameter can be calculated with the formula
Y * 10D = R + (X*2E)
where
- Y = actual or unpacked value;
- D = decimal scale factor;
- R = reference value;
- X = internal value;
- E = binary scalefactor;
TLcdGRIBModelDescriptor
or
TLcdGRIBBulletinModelDescriptor
. These descriptors can be used to
convert
the internal values to the actual values.
The type name of the model descriptor is the display name of this
decoder. The model references either implement ILcdGeodeticReference or ILcdGridReference.
Useful settings
- This decoder allows to
override
the default 16-bits index color model that is attached to the decoded rasters, since GRIB files don't contain any color information. Note that the indexing must be based on the internal GRIB values, not on the actual values. - Use
setBulletinSupported(true)
to decode all messages of GRIB bulletin files. By default, this decoder will only decode the first message of a GRIB bulletin file.
More information
This decoder delegates the actual decoding to theTLcdGRIB1ModelDecoder
or the TLcdGRIB2ModelDecoder
depending on the grib version. Take a look into the documentation for more information on the specific model descriptors,
the known limitations, and code examples.- Since:
- 6.5
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Deprecated.Determines when a multivalued raster should be created. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Deprecated.The sampling strategy that returns the average value of the corners of each GRIB sample cell.static final int
Deprecated.The sampling strategy that returns a bilinear interpolation of the values of the corners of each GRIB sample cell.static final int
Deprecated.The sampling strategy that returns the maximum value of the corners of each GRIB sample cell.static final int
Deprecated.The sampling strategy that returns the minimum value of the corners of each GRIB sample cell.static final int
Deprecated.The sampling strategy that returns the North-East corner of each GRIB sample cell.static final int
Deprecated.The sampling strategy that returns the North-West corner of each GRIB sample cell.static final int
Deprecated.The sampling strategy that returns the South-East corner of each GRIB sample cell.static final int
Deprecated.The sampling strategy that returns the South-West corner of each GRIB sample cell. -
Constructor Summary
ConstructorDescriptionDeprecated.Creates a newTLcdGRIBModelDecoder
, with a globally shared buffer for caching tiles.TLcdGRIBModelDecoder
(ILcdBuffer aBuffer) Deprecated.Creates a newTLcdGRIBModelDecoder
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addParameterTable
(ILcdGRIBParameterTable aParameterTable) Deprecated.Adds a parameter table.void
addParameterTable
(ILcdGRIBParameterTable aParameterTable, boolean aMatchCenter) Deprecated.Adds a parameter table.boolean
canDecodeSource
(String aSource) Deprecated.Checks whether this model decoder can decode the specified data source.Deprecated.Creates a new model from the given data source.Deprecated.Returns the color model that is attached by default to the decoded rasters.Deprecated.Gets the default file extension of GRIB messages.Deprecated.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.Deprecated.Returns the filter that is used for filtering data based on the contents of the GRIB messages.Deprecated.Returns the filter that is used for for filtering based on the GRIB bulletin headers.Deprecated.Returns the input stream factory that is be used for creating input streams given source names.Deprecated.Returns when multi-valued rasters are created.int
Deprecated.Returns the sampling strategy that is used for displaying raster data.boolean
Deprecated.Returnstrue
if all messages of bulletin files will be decoded.void
removeParameterTable
(ILcdGRIBParameterTable aParameterTable) Deprecated.Removes a parameter table.void
setBulletinSupported
(boolean aBulletinSupported) Deprecated.Enable or disable decoding of all messages in a GRIB bulletin file.void
setColorModel
(ColorModel aColorModel) Deprecated.Sets the color model that is attached by default to the decoded rasters.void
Deprecated.Enables GRIB bulletin decoding with the given filter for filtering based on the contents of the GRIB messages.void
Deprecated.Enables GRIB bulletin decoding with the given filter for filtering based on the GRIB bulletin headers.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Deprecated.Sets the input stream factory that is used for creating input streams given source names.void
setMultiValuedRasterCreation
(TLcdGRIBModelDecoder.MultiValuedRasterCreation aMultiValuedRasterCreation) Deprecated.Configures the creation of multi-valued rasters.void
setSampleStrategy
(int aSampleStrategy) Deprecated.Sets the sampling strategy that is used for displaying raster data.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Field Details
-
NORTH_WEST_CORNER
public static final int NORTH_WEST_CORNERDeprecated.The sampling strategy that returns the North-West corner of each GRIB sample cell.- See Also:
-
SOUTH_WEST_CORNER
public static final int SOUTH_WEST_CORNERDeprecated.The sampling strategy that returns the South-West corner of each GRIB sample cell.- See Also:
-
NORTH_EAST_CORNER
public static final int NORTH_EAST_CORNERDeprecated.The sampling strategy that returns the North-East corner of each GRIB sample cell.- See Also:
-
SOUTH_EAST_CORNER
public static final int SOUTH_EAST_CORNERDeprecated.The sampling strategy that returns the South-East corner of each GRIB sample cell.- See Also:
-
MINIMUM
public static final int MINIMUMDeprecated.The sampling strategy that returns the minimum value of the corners of each GRIB sample cell.- See Also:
-
MAXIMUM
public static final int MAXIMUMDeprecated.The sampling strategy that returns the maximum value of the corners of each GRIB sample cell.- See Also:
-
AVERAGE
public static final int AVERAGEDeprecated.The sampling strategy that returns the average value of the corners of each GRIB sample cell.- See Also:
-
BILINEAR
public static final int BILINEARDeprecated.The sampling strategy that returns a bilinear interpolation of the values of the corners of each GRIB sample cell.- See Also:
-
-
Constructor Details
-
TLcdGRIBModelDecoder
public TLcdGRIBModelDecoder()Deprecated.Creates a newTLcdGRIBModelDecoder
, with a globally shared buffer for caching tiles.- See Also:
-
TLcdGRIBModelDecoder
Deprecated.Creates a newTLcdGRIBModelDecoder
.- Parameters:
aBuffer
- the shared buffer that decoded models use.
-
-
Method Details
-
canDecodeSource
Deprecated.Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the specified data source. It is acceptable for this method to returntrue
for a source name whiledecode
throws an exception for that same source name.For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSource
- the data source to be verified; typically a file name or a URL.- Returns:
true
if the given file name has extension "grb", "grib", "dat", "grib2", or "grb2" (possibly extended with ".gz" or ".zip").- See Also:
-
decode
Deprecated.Description copied from interface:ILcdModelDecoder
Creates a new model from the given data source.- Specified by:
decode
in interfaceILcdModelDecoder
- Parameters:
aSource
- the data source to be decoded; typically a file name or a URL.- Returns:
- A model containing the decoded data. While
null
is allowed, implementors are advised to throw an error instead. - Throws:
IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException, IllegalArgumentException, ...) on unexpected places, implementations are advised to catch RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated in the code snippet below.public ILcdModel decode( String aSourceName ) throws IOException { try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) { // Perform decoding ... } catch (RuntimeException e) { throw new IOException(e); } }
- See Also:
-
getDisplayName
Deprecated.Description copied from interface:ILcdModelDecoder
Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Returns:
- "grib".
-
isBulletinSupported
public boolean isBulletinSupported()Deprecated.Returnstrue
if all messages of bulletin files will be decoded. If bulletins are supported, the bulletin decoder is used to decode all messages. If bulletins are not supported, the grib1 or grib2 decoder is used to decode the first message of the file.- Returns:
true
if all messages of bulletin files will be decoded- See Also:
-
setBulletinSupported
public void setBulletinSupported(boolean aBulletinSupported) Deprecated.Enable or disable decoding of all messages in a GRIB bulletin file.- Parameters:
aBulletinSupported
-true
to enable decoding of all messages in GRIB bulletins,false
to disable decoding of all messages in GRIB bulletins.
-
getMultiValuedRasterCreation
Deprecated.Returns when multi-valued rasters are created. Multi-valued rasters combine related models, such as the direction and speed of a wind measurement. They are typically visualized with a grid of icons.- Returns:
- one of
ALWAYS
,AUTO
, orNONE
- See Also:
-
setMultiValuedRasterCreation
public void setMultiValuedRasterCreation(TLcdGRIBModelDecoder.MultiValuedRasterCreation aMultiValuedRasterCreation) Deprecated.Configures the creation of multi-valued rasters. Multi-valued rasters combine related datasets, such as the direction and the speed of a wind measurement. They are typically visualized with a grid of icons.- Parameters:
aMultiValuedRasterCreation
- one ofALWAYS
,AUTO
, orNONE
- See Also:
-
setGRIBBulletinHeaderFilter
Deprecated.Enables GRIB bulletin decoding with the given filter for filtering based on the GRIB bulletin headers. Only GRIB messages that are accepted are added to the decoded model. The default isnull
- Parameters:
aFilter
- The filter for filtering based on the header of the GRIB messages.- See Also:
-
getGRIBBulletinHeaderFilter
Deprecated.Returns the filter that is used for for filtering based on the GRIB bulletin headers.- Returns:
- The filter for filtering based on the contents of the GRIB messages.
- See Also:
-
getGRIBBulletinFilter
Deprecated.Returns the filter that is used for filtering data based on the contents of the GRIB messages.- Returns:
- The filter for filtering based on the contents of the GRIB messages.
- See Also:
-
setGRIBBulletinFilter
Deprecated.Enables GRIB bulletin decoding with the given filter for filtering based on the contents of the GRIB messages. Only GRIB messages that are accepted are added to the decoded model. The default isnull
.- Parameters:
aFilter
- The filter for filtering based on the contents of the GRIB messages.- See Also:
-
addParameterTable
Deprecated.Adds a parameter table. If a table with the same version, center ID, and subcenter ID already exists, it is replaced.The decoder first tries to use the parameter table with a matching table version, center ID, and subcenter ID. If it can't find it, the decoder falls back on the parameter table that only matches the table version.
- Parameters:
aParameterTable
- the parameter table to add.- See Also:
-
addParameterTable
Deprecated.Adds a parameter table. If a table with the same version, center ID, and subcenter ID already exists, it is replaced.The decoder first tries to use the parameter table with a matching table version, center ID, and subcenter ID. If it can't find it, the decoder falls back on the parameter table that only matches the table version, if non-exact matches are allowed.
- Parameters:
aParameterTable
- the parameter table to add.aMatchCenter
- a boolean flag that indicates if the center ID and subcenter ID have to match in order for this table to be used.
-
removeParameterTable
Deprecated.Removes a parameter table.- Parameters:
aParameterTable
- the parameter table to remove.
-
setColorModel
Deprecated.Sets the color model that is attached by default to the decoded rasters. The default isnull
.- Parameters:
aColorModel
- an 8-bit or 16-bit IndexColorModel that is compatible with the GRIB data to be decoded.- See Also:
-
getColorModel
Deprecated.Returns the color model that is attached by default to the decoded rasters.- Returns:
- The default color model.
- See Also:
-
setSampleStrategy
public void setSampleStrategy(int aSampleStrategy) Deprecated.Sets the sampling strategy that is used for displaying raster data.- Parameters:
aSampleStrategy
- one ofNORTH_WEST_CORNER
,SOUTH_WEST_CORNER
,NORTH_EAST_CORNER
,SOUTH_EAST_CORNER
,MINIMUM
,MAXIMUM
,AVERAGE
, orBILINEAR
.- See Also:
-
getSampleStrategy
public int getSampleStrategy()Deprecated.Returns the sampling strategy that is used for displaying raster data.- Returns:
- The sampling strategy that is used for displaying raster data.
- See Also:
-
setInputStreamFactory
Deprecated.Sets the input stream factory that is used for creating input streams given source names.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the input stream factory to be used.- See Also:
-
getInputStreamFactory
Deprecated.Returns the input stream factory that is be used for creating input streams given source names.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the input stream factory that is used.
- See Also:
-
getDefaultExtension
Deprecated.Gets the default file extension of GRIB messages.- Returns:
- "grb".
-