public class NetcdfDataset extends NetcdfFile
NetcdfDataset
extends the netCDF API, adding standard attribute parsing such as
scale and offset, and explicit support for Coordinate Systems.
A NetcdfDataset
wraps a NetcdfFile
, or is defined by an NcML document.
Be sure to close the dataset when done.
Using statics in NetcdfDatets
, best practice is to use try-with-resource:
try (NetcdfDataset ncd = NetcdfDatasets.openDataset(fileName)) { ... }
By default @code NetcdfDataset} is opened with all enhancements turned on. The default "enhance mode" can be set through setDefaultEnhanceMode(). One can also explicitly set the enhancements you want in the dataset factory methods. The enhancements are:
Automatic scale/offset processing has some overhead that you may not want to incur up-front. If so, open the
NetcdfDataset without ApplyScaleOffset
. The VariableDS data type is not promoted and the data is not
converted on a read, but you can call the convertScaleOffset() routines to do the conversion later.
NetcdfFile
Modifier and Type | Class and Description |
---|---|
static class |
NetcdfDataset.Builder<T extends NetcdfDataset.Builder<T>> |
static class |
NetcdfDataset.Enhance
Possible enhancements for a NetcdfDataset
|
IOSP_MESSAGE_ADD_RECORD_STRUCTURE, IOSP_MESSAGE_CONVERT_RECORD_STRUCTURE, IOSP_MESSAGE_GET_NETCDF_FILE_FORMAT, IOSP_MESSAGE_RANDOM_ACCESS_FILE, IOSP_MESSAGE_REMOVE_RECORD_STRUCTURE
Modifier and Type | Method and Description |
---|---|
static NetcdfDataset.Builder<?> |
builder()
Get Builder for this class that allows subclassing.
|
static NetcdfDataset.Builder |
builder(NetcdfFile from) |
void |
close()
Close all resources (files, sockets, etc) associated with this dataset.
|
CoordinateAxis |
findCoordinateAxis(AxisType type)
Retrieve the CoordinateAxis with the specified Axis Type.
|
CoordinateAxis |
findCoordinateAxis(java.lang.String fullName)
Retrieve the CoordinateAxis with the specified type.
|
CoordinateSystem |
findCoordinateSystem(java.lang.String name)
Retrieve the CoordinateSystem with the specified name.
|
CoordinateTransform |
findCoordinateTransform(java.lang.String name)
Retrieve the CoordinateTransform with the specified name.
|
java.lang.String |
getConventionUsed()
Get conventions used to analyse coordinate systems.
|
com.google.common.collect.ImmutableList<CoordinateAxis> |
getCoordinateAxes()
Get the list of all CoordinateAxis objects used by this dataset.
|
com.google.common.collect.ImmutableList<CoordinateSystem> |
getCoordinateSystems()
Get the list of all CoordinateSystem objects used by this dataset.
|
com.google.common.collect.ImmutableList<CoordinateTransform> |
getCoordinateTransforms()
Get the list of all CoordinateTransform objects used by this dataset.
|
static java.util.Set<NetcdfDataset.Enhance> |
getDefaultEnhanceMode() |
void |
getDetailInfo(java.util.Formatter f)
Show debug / underlying implementation details
|
static java.util.Set<NetcdfDataset.Enhance> |
getEnhanceAll() |
java.util.Set<NetcdfDataset.Enhance> |
getEnhanceMode()
Get the current state of dataset enhancement.
|
static java.util.Set<NetcdfDataset.Enhance> |
getEnhanceNone() |
java.lang.String |
getFileTypeDescription()
Get a human-readable description for this file type.
|
java.lang.String |
getFileTypeId()
Get the file type id for the underlying data source.
|
long |
getLastModified() |
static void |
setDefaultEnhanceMode(java.util.Set<NetcdfDataset.Enhance> mode)
Set the default set of Enhancements to do for all subsequent dataset opens and acquires.
|
NetcdfDataset.Builder<?> |
toBuilder()
Turn into a mutable Builder.
|
findAttribute, findDimension, findGlobalAttribute, findGlobalAttributeIgnoreCase, findGroup, findVariable, getDetailInfo, getFileTypeVersion, getGlobalAttributes, getId, getLocation, getRootGroup, getTitle, getUnlimitedDimension, getVariables, hasUnlimitedDimension, readSection, sendIospMessage, toNcml, toString, writeNcml, writeNcml
public static NetcdfDataset.Builder<?> builder()
public static NetcdfDataset.Builder builder(NetcdfFile from)
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface ucar.nc2.util.cache.FileCacheable
close
in class NetcdfFile
java.io.IOException
- if error when closingpublic CoordinateAxis findCoordinateAxis(AxisType type)
type
- axis typepublic CoordinateAxis findCoordinateAxis(java.lang.String fullName)
fullName
- full escaped name of the coordinate axispublic CoordinateSystem findCoordinateSystem(java.lang.String name)
name
- String which identifies the desired CoordinateSystempublic CoordinateTransform findCoordinateTransform(java.lang.String name)
name
- String which identifies the desired CoordinateSystempublic java.lang.String getConventionUsed()
public com.google.common.collect.ImmutableList<CoordinateAxis> getCoordinateAxes()
public com.google.common.collect.ImmutableList<CoordinateSystem> getCoordinateSystems()
public com.google.common.collect.ImmutableList<CoordinateTransform> getCoordinateTransforms()
public static java.util.Set<NetcdfDataset.Enhance> getDefaultEnhanceMode()
public void getDetailInfo(java.util.Formatter f)
getDetailInfo
in class NetcdfFile
public static java.util.Set<NetcdfDataset.Enhance> getEnhanceAll()
public java.util.Set<NetcdfDataset.Enhance> getEnhanceMode()
public static java.util.Set<NetcdfDataset.Enhance> getEnhanceNone()
public java.lang.String getFileTypeDescription()
NetcdfFile
getFileTypeDescription
in class NetcdfFile
public java.lang.String getFileTypeId()
NetcdfFile
getFileTypeId
in class NetcdfFile
public long getLastModified()
getLastModified
in interface ucar.nc2.util.cache.FileCacheable
getLastModified
in class NetcdfFile
public static void setDefaultEnhanceMode(java.util.Set<NetcdfDataset.Enhance> mode)
mode
- the default set of Enhancements for open and acquire factory methodspublic NetcdfDataset.Builder<?> toBuilder()
NetcdfFile
toBuilder
in class NetcdfFile