Package noaa.coastwatch.io
Class HDFCachedGrid
java.lang.Object
noaa.coastwatch.util.MetadataContainer
noaa.coastwatch.util.DataVariable
noaa.coastwatch.util.Grid
noaa.coastwatch.io.CachedGrid
noaa.coastwatch.io.HDFCachedGrid
- All Implemented Interfaces:
Cloneable
,ValueSource
The HDF cached grid class is a cached grid that understands how to
read variable data from HDF files.
- Since:
- 3.1.0
- Author:
- Peter Hollemans
-
Nested Class Summary
Nested classes/interfaces inherited from class noaa.coastwatch.util.DataVariable
DataVariable.AccessType
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Default cache size in bytes.static final int
Default tile size in bytes.Fields inherited from class noaa.coastwatch.io.CachedGrid
accessMode, DEFAULT_MAX_TILES, DEFAULT_TILE_DIMS, READ_ONLY, READ_WRITE, tiling
Fields inherited from class noaa.coastwatch.util.DataVariable
data, dims, isUnsigned, lookup, unsignedType
-
Constructor Summary
ConstructorDescriptionHDFCachedGrid
(Grid grid, HDFReader reader) Constructs a new read-only HDF cached grid with the specified properties.HDFCachedGrid
(Grid grid, HDFWriter writer) Constructs a new read-write HDF cached grid with the specified properties. -
Method Summary
Modifier and TypeMethodDescriptionGets the data class.Gets the cache data stream as an object.protected TilingScheme.Tile
Reads the specified tile.void
setTileDims
(int[] dims) Creates a new cache where each tile has the specified dimensions.protected void
writeTile
(TilingScheme.Tile tile) Writes the specified tile.Methods inherited from class noaa.coastwatch.io.CachedGrid
clearCache, flush, getData, getData, getMaxTiles, getTileDims, getTileSize, getTilingScheme, getValue, getValue, main, resetCache, setAccessType, setCacheSize, setData, setData, setDynamic, setMaxTiles, setOptimizedCacheSize, setTileSize, setValue, setValue, timeAccess
Methods inherited from class noaa.coastwatch.util.Grid
arraycopy, checkSubset, getNavigation, getSubset, getValue, interpolate, navigate, setNavigation, setValue
Methods inherited from class noaa.coastwatch.util.DataVariable
convertUnits, dispose, format, format, format, getClassBits, getDecimals, getDimensions, getFormat, getLongName, getMissing, getName, getOptimalStride, getRank, getScaling, getStatistics, getStatistics, getStatistics, getStatistics, getUnits, getUnsigned, getValue, getValues, setAccessHint, setFormat, setLongName, setLookup, setMissing, setName, setUnits, setUnsigned, setValue, toString
Methods inherited from class noaa.coastwatch.util.MetadataContainer
clone, getMetadataMap
-
Field Details
-
DEFAULT_TILE_SIZE
public static final int DEFAULT_TILE_SIZEDefault tile size in bytes.- See Also:
-
DEFAULT_CACHE_SIZE
public static final int DEFAULT_CACHE_SIZEDefault cache size in bytes.- See Also:
-
-
Constructor Details
-
HDFCachedGrid
Constructs a new read-only HDF cached grid with the specified properties. Unchunked HDF variables will be given the default tile size, otherwise the tile size is determined from the file.- Parameters:
grid
- the grid to use for attributes.reader
- the HDF reader data source.- Throws:
IOException
- if a problem occurred accessing the HDF file.
-
HDFCachedGrid
Constructs a new read-write HDF cached grid with the specified properties. Unchunked HDF files will be cached using the default tile size, otherwise the tile size is determined from the file.- Parameters:
grid
- the grid to use for attributes.writer
- the HDF writer data destination.- Throws:
IOException
- if a problem occurred accessing the HDF file.
-
-
Method Details
-
getDataClass
Gets the data class. This method overrides the parent because the data class for an HDF cached grid is not available from the data array when needed in some cases.- Overrides:
getDataClass
in classDataVariable
- Returns:
- the Java class of the data array.
-
getDataStream
Description copied from class:CachedGrid
Gets the cache data stream as an object. This is useful for classes that read and write cached grids.- Specified by:
getDataStream
in classCachedGrid
- Returns:
- the data stream used for reading and writing data.
-
setTileDims
public void setTileDims(int[] dims) Creates a new cache where each tile has the specified dimensions. Only unchunked HDF variables may have the tile dimensions set. For chunked variables, the method has no effect.- Overrides:
setTileDims
in classCachedGrid
- Parameters:
dims
- the tile dimensions as [rows, columns].
-
readTile
Description copied from class:CachedGrid
Reads the specified tile.- Specified by:
readTile
in classCachedGrid
- Parameters:
pos
- the tile position to read.- Returns:
- the tile at the specified position.
- Throws:
IOException
- if an error occurred reading the tile data.
-
writeTile
Description copied from class:CachedGrid
Writes the specified tile. The implementation of this method must set the tile to be not dirty upon successfully writing it, or throw an error.- Specified by:
writeTile
in classCachedGrid
- Parameters:
tile
- the tile to write.- Throws:
IOException
- if an error occurred writing the tile data.
-