Package noaa.coastwatch.io
Class EarthDataReader
java.lang.Object
noaa.coastwatch.io.EarthDataReader
- Direct Known Subclasses:
HDFReader
,NCReader
,NOAA1bFileReader
,NOAA1bReader
,OpendapReader
An
EarthDataReader
obtains earth data from a data source and
provides it to the user in a consistent format. A reader
should do the following:
- Construct from some type of file or data stream
- Read global information into a
EarthDataInfo
object - Report the number of
DataVariable
objects - Read a "preview" of a
DataVariable
, which consists of all attributes but no actual data values - Read a
DataVariable
object with data - Close the source when no longer needed
info
and
variables
variables and fills the rawMetadataMap
map.- Since:
- 3.1.0
- Author:
- Peter Hollemans
-
Field Summary
Modifier and TypeFieldDescriptionprotected static boolean
The data projection flag, true if reading explicit lat/lon data should return aDataProjection
rather than aSwathProjection
.protected EarthDataInfo
Earth data info object.protected Map
The raw metadata map.protected String[]
Earth data variable names. -
Constructor Summary
ModifierConstructorDescriptionprotected
EarthDataReader
(String source) Creates a new earth data reader. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Determines the ability of the file format to have its navigation updated.abstract void
close()
Closes the reader and frees any resources.boolean
containsVariable
(String name) Determines if a variable exists in the reader.protected void
finalize()
Closes the resources associated with the data source.Gets a list of all 2D grid variable names in this reader.Gets a list of all variable names in this reader.getChunkProducer
(String name) Creates a chunk producer for the specified variable.List<ucar.nc2.dataset.CoordinateSystem>
Gets the NetCDF CDM style coordinate systems accessed by this reader.abstract String
Gets the data format description.int
Retrieves a variable index based on the name.getInfo()
Gets the earth data info object.getName
(int index) Gets the variable name at the specified index.getPreview
(int index) Creates a data variable preview.getPreview
(String name) Creates a data variable preview.protected abstract DataVariable
getPreviewImpl
(int index) Implementation for the subclass.Gets the detailed raw metadata.getRawMetadata
(int index) Gets the detailed raw metadata for a variable.Gets the scene time based on the first grid variable.Get the earth data source.getStatistics
(String name) Gets the statistics data stored for the specified variable name.Gets the list of all variable names that have associated statistics.abstract DataVariable
getVariable
(int index) Creates a data variable object.getVariable
(String name) Creates a data variable object.int
Gets the total count of data variables.getVariablesForSystem
(ucar.nc2.dataset.CoordinateSystem system) Gets the variable names for the specified NetCDF CDM style coordinate systems accessed by this reader.void
putStatistics
(String name, Statistics stats) Associates statistics with the specified variable name.static void
setDataProjection
(boolean flag) Sets the data projection flag.static void
setUnitsMap
(Map map) Sets the variable name to units map.void
updateNavigation
(List variableNames, AffineTransform affine) Updates the navigation transform for the specified list of variables (optional operation).
-
Field Details
-
info
Earth data info object. -
variables
Earth data variable names. -
dataProjection
protected static boolean dataProjectionThe data projection flag, true if reading explicit lat/lon data should return aDataProjection
rather than aSwathProjection
. -
rawMetadataMap
The raw metadata map.
-
-
Constructor Details
-
EarthDataReader
Creates a new earth data reader.- Parameters:
source
- the data source.
-
-
Method Details
-
setUnitsMap
Sets the variable name to units map. If set, data variables accessed viagetPreview(int)
andgetVariable(int)
will automatically have their units converted to the new units before being passed to the caller.- Parameters:
map
- the new map of variable name to units string.
-
setDataProjection
public static void setDataProjection(boolean flag) Sets the data projection flag. This is only applicable to readers that deal with earth transforms stored as explicit earth location data. When true, the data projection flag forces the reader to return aDataProjection
object for the earth transform when reading explicit latitude and longitude data, rather than interpolating the data and returning aSwathProjection
. The main difference is that aDataProjection
cannot be used to transform anEarthLocation
object into aDataLocation
object. Generally, setting this flag is only desirable if there are inherent problems with interpolating the earth location data. By default, the reader is set to return aSwathProjection
.- Parameters:
flag
- the data projection flag.
-
getStatisticsVariables
Gets the list of all variable names that have associated statistics.- Returns:
- the list of variable names.
-
getStatistics
Gets the statistics data stored for the specified variable name.- Parameters:
name
- the variable name.- Returns:
- the statistics, or null if the variable name has no associated statistics data.
- See Also:
-
putStatistics
Associates statistics with the specified variable name.- Parameters:
name
- the variable name.stats
- the statistics data.
-
getInfo
Gets the earth data info object. -
getVariables
public int getVariables()Gets the total count of data variables. -
getName
Gets the variable name at the specified index. -
getDataFormat
Gets the data format description. -
getSource
Get the earth data source. -
getSceneTime
Gets the scene time based on the first grid variable.- Returns:
- the scene time or
unknown
if the scene time cannot be determined.
-
containsVariable
Determines if a variable exists in the reader.- Parameters:
name
- the variable name to search for.- Returns:
- true if the variable exists or false if not.
- Since:
- 3.5.0
-
getIndex
Retrieves a variable index based on the name.- Parameters:
name
- the variable name to search for.- Returns:
- the variable index, or -1 if the variable could not be found.
-
getPreview
Creates a data variable preview. A preview contains all metadata but no data value array. The preview can be used in a filtering loop to determine if the reading of the variable data is desired, as I/O can be a time-intensive operation.- Parameters:
index
- the index of the variable to preview. Indexing starts at 0.- Returns:
- a data variable object with data value array of length 1.
- Throws:
IOException
- if the data source had I/O errors.- See Also:
-
getPreviewImpl
Implementation for the subclass.- Throws:
IOException
- See Also:
-
getChunkProducer
Creates a chunk producer for the specified variable.- Parameters:
name
- the variable name.- Returns:
- a chunk producer for the specified variable.
- Throws:
IOException
- Since:
- 3.5.0
-
getPreview
Creates a data variable preview. A preview contains all metadata but no data value array. The preview can be used in a filtering loop to determine if the reading of the variable data is desired, as I/O can be a time-intensive operation.- Parameters:
name
- the name of the variable to get.- Returns:
- a data variable object with data value array of length 1.
- Throws:
IOException
- if the data source had I/O errors, or the variable was not found.- See Also:
-
getVariable
Creates a data variable object. The full data is read into the object.- Parameters:
index
- the index of the variable to get. Indexing starts at 0.- Returns:
- a data variable object with full data value array.
- Throws:
IOException
- if the data source had I/O errors.- See Also:
-
getVariable
Creates a data variable object. The full data is read into the object.- Parameters:
name
- the name of the variable to get.- Returns:
- a data variable object with full data value array.
- Throws:
IOException
- if the data source had I/O errors, or the variable was not found.- See Also:
-
close
Closes the reader and frees any resources.- Throws:
IOException
- if the data source had I/O errors.
-
finalize
Closes the resources associated with the data source. -
getAllGrids
Gets a list of all 2D grid variable names in this reader.- Returns:
- the list of grid variable names.
- Throws:
IOException
- if an error occurred getting the list of grids.
-
getAllVariables
Gets a list of all variable names in this reader.- Returns:
- the list of variable names.
-
getRawMetadata
Gets the detailed raw metadata. Each key is an attribute name and each value the corresponding wrapped primitive, primitive array, or string value. -
getRawMetadata
Gets the detailed raw metadata for a variable.- Parameters:
index
- the index of the variable for raw metadata.- Returns:
- the map of attribute name to attribute value.
- Throws:
IOException
- if the data source had I/O errors.- Since:
- 3.7.1
- See Also:
-
getCoordinateSystems
Gets the NetCDF CDM style coordinate systems accessed by this reader.- Returns:
- the list of coordinate systems, possibly empty.
-
getVariablesForSystem
Gets the variable names for the specified NetCDF CDM style coordinate systems accessed by this reader.- Returns:
- the list of variable names, possibly empty.
-