Class TLcdGRIBModelDecoder

java.lang.Object
com.luciad.format.grib.TLcdGRIBModelDecoder
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdModelDecoder

@Deprecated public class TLcdGRIBModelDecoder extends Object implements ILcdModelDecoder, ILcdInputStreamFactoryCapable
Deprecated.
TLcdNetCDFModelDecoder can be used instead.
This model decoder decodes rasters in the GRIB format. This is the preferred decoder for all GRIB 1 and GRIB 2 files.

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 a collection of models.
  • Depending on the 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;
    All models returned by this model decoder have a 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 the TLcdGRIB1ModelDecoder 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
    • Field Details

      • NORTH_WEST_CORNER

        public static final int NORTH_WEST_CORNER
        Deprecated.
        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_CORNER
        Deprecated.
        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_CORNER
        Deprecated.
        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_CORNER
        Deprecated.
        The sampling strategy that returns the South-East corner of each GRIB sample cell.
        See Also:
      • MINIMUM

        public static final int MINIMUM
        Deprecated.
        The sampling strategy that returns the minimum value of the corners of each GRIB sample cell.
        See Also:
      • MAXIMUM

        public static final int MAXIMUM
        Deprecated.
        The sampling strategy that returns the maximum value of the corners of each GRIB sample cell.
        See Also:
      • AVERAGE

        public static final int AVERAGE
        Deprecated.
        The sampling strategy that returns the average value of the corners of each GRIB sample cell.
        See Also:
      • BILINEAR

        public static final int BILINEAR
        Deprecated.
        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 new TLcdGRIBModelDecoder, with a globally shared buffer for caching tiles.
        See Also:
      • TLcdGRIBModelDecoder

        public TLcdGRIBModelDecoder(ILcdBuffer aBuffer)
        Deprecated.
        Creates a new TLcdGRIBModelDecoder.
        Parameters:
        aBuffer - the shared buffer that decoded models use.
    • Method Details

      • canDecodeSource

        public boolean canDecodeSource(String aSource)
        Deprecated.
        Description copied from interface: ILcdModelDecoder
        Checks whether this model decoder can decode the specified data source. It is acceptable for this method to return true for a source name while decode 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 interface ILcdModelDecoder
        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

        public ILcdModel decode(String aSource) throws IOException
        Deprecated.
        Description copied from interface: ILcdModelDecoder
        Creates a new model from the given data source.
        Specified by:
        decode in interface ILcdModelDecoder
        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

        public String getDisplayName()
        Deprecated.
        Description copied from interface: ILcdModelDecoder
        Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
        Specified by:
        getDisplayName in interface ILcdModelDecoder
        Returns:
        "grib".
      • isBulletinSupported

        public boolean isBulletinSupported()
        Deprecated.
        Returns true 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

        public TLcdGRIBModelDecoder.MultiValuedRasterCreation 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, or NONE
        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 of ALWAYS, AUTO, or NONE
        See Also:
      • setGRIBBulletinHeaderFilter

        public void setGRIBBulletinHeaderFilter(ILcdGRIBBulletinHeaderFilter aFilter)
        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 is null
        Parameters:
        aFilter - The filter for filtering based on the header of the GRIB messages.
        See Also:
      • getGRIBBulletinHeaderFilter

        public ILcdGRIBBulletinHeaderFilter 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

        public ILcdGRIBBulletinFilter 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

        public void setGRIBBulletinFilter(ILcdGRIBBulletinFilter aFilter)
        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 is null.
        Parameters:
        aFilter - The filter for filtering based on the contents of the GRIB messages.
        See Also:
      • addParameterTable

        public void addParameterTable(ILcdGRIBParameterTable aParameterTable)
        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

        public void addParameterTable(ILcdGRIBParameterTable aParameterTable, boolean aMatchCenter)
        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

        public void removeParameterTable(ILcdGRIBParameterTable aParameterTable)
        Deprecated.
        Removes a parameter table.
        Parameters:
        aParameterTable - the parameter table to remove.
      • setColorModel

        public void setColorModel(ColorModel aColorModel)
        Deprecated.
        Sets the color model that is attached by default to the decoded rasters. The default is null.
        Parameters:
        aColorModel - an 8-bit or 16-bit IndexColorModel that is compatible with the GRIB data to be decoded.
        See Also:
      • getColorModel

        public ColorModel 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 of NORTH_WEST_CORNER, SOUTH_WEST_CORNER, NORTH_EAST_CORNER, SOUTH_EAST_CORNER, MINIMUM, MAXIMUM, AVERAGE, or BILINEAR.
        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

        public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
        Deprecated.
        Sets the input stream factory that is used for creating input streams given source names.
        Specified by:
        setInputStreamFactory in interface ILcdInputStreamFactoryCapable
        Parameters:
        aInputStreamFactory - the input stream factory to be used.
        See Also:
      • getInputStreamFactory

        public ILcdInputStreamFactory getInputStreamFactory()
        Deprecated.
        Returns the input stream factory that is be used for creating input streams given source names.
        Specified by:
        getInputStreamFactory in interface ILcdInputStreamFactoryCapable
        Returns:
        the input stream factory that is used.
        See Also:
      • getDefaultExtension

        public String getDefaultExtension()
        Deprecated.
        Gets the default file extension of GRIB messages.
        Returns:
        "grb".