public abstract class NCReader extends EarthDataReader implements GridSubsetReader, NCSD
NCReader
class is the base class for readers that
use the Java NetCDF API to read and parse metadata. Supported file
formats include NetCDF 3/4, HDF5, and OPeNDAP network connections.Modifier and Type | Field and Description |
---|---|
protected ucar.nc2.dataset.NetcdfDataset |
dataset
The NetCDF dataset for accessing data.
|
dataProjection, info, rawMetadataMap, variables
Modifier | Constructor and Description |
---|---|
protected |
NCReader(java.lang.String name)
Creates a new reader using the dataset at the specified location.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the reader.
|
protected abstract DataVariable |
getActualVariable(int index)
Gets the actual variable with data.
|
static java.lang.Object |
getAttribute(ucar.nc2.NetcdfFile file,
java.lang.String name)
Gets a NetCDF global file attribute and converts it to a Java
string, primitive array, or wrapped primitive.
|
java.lang.Object |
getAttribute(java.lang.String name)
Gets a NetCDF global file attribute from this reader and converts
it to a Java string, primitive array, or wrapped primitive.
|
static java.lang.Object |
getAttribute(ucar.nc2.Variable var,
java.lang.String name)
Gets a NetCDF variable attribute and converts it to a Java
string, primitive array, or wrapped primitive.
|
static java.lang.Object |
getAttributeAsArray(ucar.nc2.NetcdfFile file,
java.lang.String name)
Gets a NetCDF global file attribute and converts it to a
primitive array.
|
java.lang.Object |
getAttributeAsArray(java.lang.String name)
Gets a NetCDF global file attribute from this reader and converts
it to a primitive array.
|
static java.lang.Object |
getAttributeAsArray(ucar.nc2.Variable var,
java.lang.String name)
Gets a NetCDF variable attribute and converts it to a primitive
array.
|
java.util.List<ucar.nc2.dataset.CoordinateSystem> |
getCoordinateSystems()
Gets the NetCDF CDM style coordinate systems accessed by
this reader.
|
ucar.nc2.dataset.NetcdfDataset |
getDataset()
Gets the NetCDF scientific dataset.
|
java.lang.String |
getFilename()
Gets the NetCDF scientific dataset file name.
|
Grid |
getGridSubset(java.lang.String varName,
int[] start,
int[] stride,
int[] length)
Reads a subset of a data grid.
|
DataVariable |
getVariable(int index)
Creates a data variable object.
|
java.util.List<java.lang.String> |
getVariablesForSystem(ucar.nc2.dataset.CoordinateSystem system)
Gets the variable names for the specified NetCDF CDM style
coordinate systems accessed by this reader.
|
protected void |
initializeReader()
Performs reader initialization after the dataset has been opened.
|
boolean |
isNetwork()
Returns true if this reader is network-connected.
|
canUpdateNavigation, finalize, getAllGrids, getAllVariables, getDataFormat, getIndex, getInfo, getName, getPreview, getPreview, getPreviewImpl, getRawMetadata, getSceneTime, getSource, getStatistics, getStatisticsVariables, getVariable, getVariables, putStatistics, setDataProjection, setUnitsMap, updateNavigation
protected ucar.nc2.dataset.NetcdfDataset dataset
protected NCReader(java.lang.String name) throws java.io.IOException
name
- the file or network location.java.io.IOException
- if an error occurred accessing the dataset.public ucar.nc2.dataset.NetcdfDataset getDataset()
NCSD
getDataset
in interface NCSD
public java.lang.String getFilename()
NCSD
getFilename
in interface NCSD
protected void initializeReader() throws java.io.IOException
java.io.IOException
- if an error occurred on initialization.public java.lang.Object getAttribute(java.lang.String name)
name
- the name of the attribute.public java.lang.Object getAttributeAsArray(java.lang.String name)
name
- the name of the attribute.public static java.lang.Object getAttribute(ucar.nc2.NetcdfFile file, java.lang.String name)
file
- the NetCDF file to access.name
- the name of the attribute.public static java.lang.Object getAttributeAsArray(ucar.nc2.NetcdfFile file, java.lang.String name)
file
- the NetCDF file to access.name
- the name of the attribute.public static java.lang.Object getAttribute(ucar.nc2.Variable var, java.lang.String name)
var
- the variable to access.name
- the name of the attribute.public static java.lang.Object getAttributeAsArray(ucar.nc2.Variable var, java.lang.String name)
var
- the variable to access.name
- the name of the attribute.public boolean isNetwork()
protected abstract DataVariable getActualVariable(int index) throws java.io.IOException
getVariable(int)
for the
required behaviour.java.io.IOException
public DataVariable getVariable(int index) throws java.io.IOException
EarthDataReader
getVariable
in class EarthDataReader
index
- the index of the variable to get. Indexing
starts at 0.java.io.IOException
- if the data source had I/O errors.EarthDataReader.getPreview(int)
public void close() throws java.io.IOException
close
in class EarthDataReader
java.io.IOException
- if the data source had I/O errors.public Grid getGridSubset(java.lang.String varName, int[] start, int[] stride, int[] length) throws java.io.IOException
GridSubsetReader
EarthDataReader.getVariable(String)
method except that it reads
only grid variables and is capable of returning just a subset of
the data values. In some cases, such as across a network
connection, it may be more efficient to access only a subset or
subsampling of data in a variable.getGridSubset
in interface GridSubsetReader
varName
- the variable name to access.start
- the 2D starting data coordinates.stride
- the 2D data stride.length
- the total number of values to read in each dimension.java.io.IOException
- if the data source had I/O errors.public java.util.List<ucar.nc2.dataset.CoordinateSystem> getCoordinateSystems()
EarthDataReader
getCoordinateSystems
in class EarthDataReader
public java.util.List<java.lang.String> getVariablesForSystem(ucar.nc2.dataset.CoordinateSystem system)
EarthDataReader
getVariablesForSystem
in class EarthDataReader