Class NetcdfDataset
- java.lang.Object
-
- ucar.nc2.NetcdfFile
-
- ucar.nc2.dataset.NetcdfDataset
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,FileCacheable
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. ANetcdfDataset
wraps aNetcdfFile
, 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:
- ConvertEnums: convert enum values to their corresponding Strings. If you want to do this manually, you can call Variable.lookupEnumString().
- ConvertUnsigned: reinterpret the bit patterns of any negative values as unsigned.
- ApplyScaleOffset: process scale/offset attributes, and automatically convert the data.
- ConvertMissing: replace missing data with NaNs, for efficiency.
- CoordSystems: extract CoordinateSystem using the CoordSysBuilder plug-in mechanism.
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.- See Also:
NetcdfFile
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
NetcdfDataset.Builder<T extends NetcdfDataset.Builder<T>>
static class
NetcdfDataset.Enhance
Possible enhancements for a NetcdfDataset
-
Field Summary
Fields Modifier and Type Field Description protected static boolean
fillValueIsMissing
protected static boolean
invalidDataIsMissing
protected static boolean
missingDataIsMissing
-
Fields inherited from class ucar.nc2.NetcdfFile
cache, dimensions, gattributes, id, iosp, 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, location, rootGroup, title, variables
-
-
Constructor Summary
Constructors Constructor Description NetcdfDataset()
Deprecated.Use NetcdfDataset.builder()NetcdfDataset(NetcdfFile ncfile)
Deprecated.Use NetcdfDataset.builder()NetcdfDataset(NetcdfFile.Builder<?> builder)
Deprecated.Use NetcdfDataset.builder()NetcdfDataset(NetcdfFile ncfile, boolean enhance)
Deprecated.Use NetcdfDataset.builder()NetcdfDataset(NetcdfFile ncfile, Set<NetcdfDataset.Enhance> mode)
Deprecated.Use NetcdfDataset.builder()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static NetcdfDataset
acquireDataset(DatasetUrl location, boolean enhanceMode, CancelTask cancelTask)
Deprecated.use NetcdfDatasets.acquireDatasetstatic NetcdfDataset
acquireDataset(DatasetUrl location, Set<NetcdfDataset.Enhance> enhanceMode, CancelTask cancelTask)
Deprecated.use NetcdfDatasets.acquireDatasetstatic NetcdfDataset
acquireDataset(DatasetUrl location, CancelTask cancelTask)
Deprecated.use NetcdfDatasets.acquireDatasetstatic NetcdfDataset
acquireDataset(FileFactory fac, DatasetUrl durl, Set<NetcdfDataset.Enhance> enhanceMode, int buffer_size, CancelTask cancelTask, Object iospMessage)
Deprecated.use NetcdfDatasets.acquireDatasetstatic NetcdfFile
acquireFile(DatasetUrl location, CancelTask cancelTask)
Deprecated.use NetcdfDatasets.acquireFilestatic NetcdfFile
acquireFile(FileFactory factory, Object hashKey, DatasetUrl location, int buffer_size, CancelTask cancelTask, Object spiObject)
Deprecated.use NetcdfDatasets.acquireFileCoordinateAxis
addCoordinateAxis(VariableDS v)
Deprecated.Use NetcdfDataset.builder()void
addCoordinateSystem(CoordinateSystem cs)
Deprecated.Use NetcdfDataset.builder()void
addCoordinateTransform(CoordinateTransform ct)
Deprecated.Use NetcdfDataset.builder()Variable
addVariable(Group g, Variable v)
Deprecated.Use NetcdfDataset.builder()static NetcdfDataset.Builder<?>
builder()
Get Builder for this class that allows subclassing.static NetcdfDataset.Builder
builder(NetcdfFile from)
void
check(Formatter f)
Deprecated.do not usevoid
clearCoordinateSystems()
Deprecated.Use NetcdfDataset.builder()void
close()
Close all resources (files, sockets, etc) associated with this dataset.static void
debugDump(PrintWriter out, NetcdfDataset ncd)
Deprecated.do not usestatic void
disableNetcdfFileCache()
Deprecated.use NetcdfDatasets.disableNetcdfFileCachevoid
empty()
Deprecated.Use NetcdfDataset.builder()CoordSysBuilderIF
enhance()
Deprecated.Use NetcdfDataset.builder()void
enhance(Set<NetcdfDataset.Enhance> mode)
Deprecated.Use NetcdfDataset.builder()boolean
enhanceNeeded(Set<NetcdfDataset.Enhance> want)
Deprecated.Do not use.CoordinateAxis
findCoordinateAxis(String fullName)
Retrieve the CoordinateAxis with the specified type.CoordinateAxis
findCoordinateAxis(AxisType type)
Retrieve the CoordinateAxis with the specified Axis Type.CoordinateSystem
findCoordinateSystem(String name)
Retrieve the CoordinateSystem with the specified name.CoordinateTransform
findCoordinateTransform(String name)
Retrieve the CoordinateTransform with the specified name.AggregationIF
getAggregation()
Deprecated.Do not use.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 Set<NetcdfDataset.Enhance>
getDefaultEnhanceMode()
void
getDetailInfo(Formatter f)
Show debug / underlying implementation detailsstatic Set<NetcdfDataset.Enhance>
getEnhanceAll()
Set<NetcdfDataset.Enhance>
getEnhanceMode()
Get the current state of dataset enhancement.static Set<NetcdfDataset.Enhance>
getEnhanceNone()
String
getFileTypeDescription()
Get a human-readable description for this file type.String
getFileTypeId()
Get the file type id for the underlying data source.static boolean
getFillValueIsMissing()
Deprecated.do not usestatic boolean
getInvalidDataIsMissing()
Deprecated.do not useIOServiceProvider
getIosp()
Deprecated.do not uselong
getLastModified()
Returns the time that the underlying file(s) were last modified.static boolean
getMissingDataIsMissing()
Deprecated.do not usestatic FileCacheIF
getNetcdfFileCache()
Deprecated.use NetcdfDatasets.getNetcdfFileCacheNetcdfFile
getReferencedFile()
Deprecated.Do not usestatic void
initNetcdfFileCache(int minElementsInMemory, int maxElementsInMemory, int period)
Deprecated.use NetcdfDatasets.initNetcdfFileCachestatic void
initNetcdfFileCache(int minElementsInMemory, int maxElementsInMemory, int hardLimit, int period)
Deprecated.use NetcdfDatasets.initNetcdfFileCachestatic void
main(String[] arg)
Deprecated.use ucar.nc2.writer.Nccopystatic Array
makeArray(DataType dtype, List<String> stringValues)
Deprecated.use Array#makeArray directlyprotected Boolean
makeRecordStructure()
Deprecated.Use NetcdfDatasets.open() with IOSP_MESSAGE_ADD_RECORD_STRUCTUREstatic NetcdfDataset
openDataset(String location)
Deprecated.use NetcdfDatasets.openDatasetstatic NetcdfDataset
openDataset(String location, boolean enhance, int buffer_size, CancelTask cancelTask, Object spiObject)
Deprecated.use NetcdfDatasets.openDatasetstatic NetcdfDataset
openDataset(String location, boolean enhance, CancelTask cancelTask)
Deprecated.use NetcdfDatasets.openDatasetstatic NetcdfDataset
openDataset(DatasetUrl location, Set<NetcdfDataset.Enhance> enhanceMode, int buffer_size, CancelTask cancelTask, Object spiObject)
Deprecated.use NetcdfDatasets.openDatasetstatic NetcdfFile
openFile(String location, CancelTask cancelTask)
Deprecated.use NetcdfDatasets.openFilestatic NetcdfFile
openFile(DatasetUrl location, int buffer_size, CancelTask cancelTask, Object spiObject)
Deprecated.use NetcdfDatasets.openFilestatic Set<NetcdfDataset.Enhance>
parseEnhanceMode(String enhanceMode)
Deprecated.this is moving to Ncml packagevoid
reacquire()
Deprecated.do not usevoid
release()
Deprecated.do not usevoid
setAggregation(AggregationIF agg)
Deprecated.Use NetcdfDataset.builder()static void
setDefaultEnhanceMode(Set<NetcdfDataset.Enhance> mode)
Set the default set of Enhancements to do for all subsequent dataset opens and acquires.static void
setFillValueIsMissing(boolean b)
Deprecated.do not usestatic void
setInvalidDataIsMissing(boolean b)
Deprecated.do not usestatic void
setMissingDataIsMissing(boolean b)
Deprecated.do not usevoid
setReferencedFile(NetcdfFile ncfile)
Deprecated.Use NetcdfDataset.builder()void
setValues(Variable v, int npts, double start, double incr)
Deprecated.use Variable.setValues()void
setValues(Variable v, List<String> values)
Deprecated.use Variable.setValues()static void
shutdown()
Deprecated.use NetcdfDatasets.shutdownvoid
sort()
Deprecated.Use NetcdfDataset.builder()boolean
syncExtend()
Deprecated.do not useNetcdfDataset.Builder<?>
toBuilder()
Turn into a mutable Builder.protected String
toStringDebug(Object o)
Access to iosp debugging info.static NetcdfDataset
wrap(NetcdfFile ncfile, Set<NetcdfDataset.Enhance> mode)
Deprecated.use NetcdfDatasets.wrap-
Methods inherited from class ucar.nc2.NetcdfFile
addAttribute, addAttribute, addDimension, addGroup, addLocalFieldsToBuilder, addStringVariable, addVariable, addVariableAttribute, canonicalizeUriString, canOpen, findAttribute, findAttValueIgnoreCase, findDimension, findGlobalAttribute, findGlobalAttributeIgnoreCase, findGroup, findVariable, findVariable, findVariableByAttribute, finish, getCacheName, getDetailInfo, getDimensions, getFileTypeVersion, getGlobalAttributes, getId, getLocation, getRootGroup, getStructureIterator, getTitle, getUnlimitedDimension, getVariables, hasUnlimitedDimension, iospDeRegister, iospRegistered, makeFullName, makeFullName, makeFullNameSectionSpec, makeFullNameWithString, makeNameUnescaped, makeValidCDLName, makeValidCdmObjectName, makeValidPathName, makeValidSectionSpecName, open, open, open, open, open, open, openInMemory, openInMemory, openInMemory, openInMemory, read, readArrays, readAttributeDouble, readAttributeInteger, readData, readSection, readToByteChannel, readToOutputStream, registerIOProvider, registerIOProvider, registerIOProvider, registerIOProviderPreferred, removeDimension, removeRecordStructure, removeVariable, sendIospMessage, setCacheName, setDebugFlags, setFileCache, setId, setImmutable, setLocation, setProperty, setRootGroup, setTitle, showCached, showProxies, toNcml, toString, writeCDL, writeCDL, writeCDL, writeNcml, writeNcml
-
-
-
-
Constructor Detail
-
NetcdfDataset
@Deprecated public NetcdfDataset(NetcdfFile ncfile) throws IOException
Deprecated.Use NetcdfDataset.builder()Transform a NetcdfFile into a NetcdfDataset, with default enhancement. You must not use the underlying NetcdfFile after this call, because it gets modified. Therefore you should not use this with a cached file.- Parameters:
ncfile
- NetcdfFile to transform.- Throws:
IOException
- on read error
-
NetcdfDataset
@Deprecated public NetcdfDataset(NetcdfFile ncfile, boolean enhance) throws IOException
Deprecated.Use NetcdfDataset.builder()Transform a NetcdfFile into a NetcdfDataset, optionally enhance it. You must not use the original NetcdfFile after this call.- Parameters:
ncfile
- NetcdfFile to transform, do not use independently after this.enhance
- if true, enhance with defaultEnhanceMode- Throws:
IOException
- on read error
-
NetcdfDataset
@Deprecated public NetcdfDataset(NetcdfFile ncfile, Set<NetcdfDataset.Enhance> mode) throws IOException
Deprecated.Use NetcdfDataset.builder()Transform a NetcdfFile into a NetcdfDataset, optionally enhance it. You must not use the original NetcdfFile after this call.- Parameters:
ncfile
- NetcdfFile to transform, do not use independently after this.mode
- set of enhance modes. If null, then none- Throws:
IOException
- on read error
-
NetcdfDataset
@Deprecated public NetcdfDataset()
Deprecated.Use NetcdfDataset.builder()No-arg Constructor
-
NetcdfDataset
@Deprecated public NetcdfDataset(NetcdfFile.Builder<?> builder)
Deprecated.Use NetcdfDataset.builder()
-
-
Method Detail
-
getEnhanceAll
public static Set<NetcdfDataset.Enhance> getEnhanceAll()
-
getEnhanceNone
public static Set<NetcdfDataset.Enhance> getEnhanceNone()
-
getDefaultEnhanceMode
public static Set<NetcdfDataset.Enhance> getDefaultEnhanceMode()
-
setDefaultEnhanceMode
public static void setDefaultEnhanceMode(Set<NetcdfDataset.Enhance> mode)
Set the default set of Enhancements to do for all subsequent dataset opens and acquires.- Parameters:
mode
- the default set of Enhancements for open and acquire factory methods
-
parseEnhanceMode
@Deprecated public static Set<NetcdfDataset.Enhance> parseEnhanceMode(String enhanceMode)
Deprecated.this is moving to Ncml packageRetrieve the set of Enhancements that is associated with the given string.String Enhancements All ConvertEnums, ConvertUnsigned, ApplyScaleOffset, ConvertMissing, CoordSystems None <empty> ConvertEnums ConvertEnums ConvertUnsigned ConvertUnsigned ApplyScaleOffset ApplyScaleOffset ConvertMissing ConvertMissing CoordSystems CoordSystems IncompleteCoordSystems CoordSystems true Alias for "All" ScaleMissingDefer Alias for "None" AllDefer ConvertEnums, CoordSystems ScaleMissing ConvertUnsigned, ApplyScaleOffset, ConvertMissing - Parameters:
enhanceMode
- a string from the above table.- Returns:
- the set corresponding to
enhanceMode
, ornull
if there is no correspondence.
-
setFillValueIsMissing
@Deprecated public static void setFillValueIsMissing(boolean b)
Deprecated.do not useSet if _FillValue attribute is considered isMissing()- Parameters:
b
- true if _FillValue are missing (default true)
-
getFillValueIsMissing
@Deprecated public static boolean getFillValueIsMissing()
Deprecated.do not useGet if _FillValue attribute is considered isMissing()- Returns:
- if _FillValue attribute is considered isMissing()
-
setInvalidDataIsMissing
@Deprecated public static void setInvalidDataIsMissing(boolean b)
Deprecated.do not useSet if valid_range attribute is considered isMissing()- Parameters:
b
- true if valid_range are missing (default true)
-
getInvalidDataIsMissing
@Deprecated public static boolean getInvalidDataIsMissing()
Deprecated.do not useGet if valid_range attribute is considered isMissing()- Returns:
- if valid_range attribute is considered isMissing()
-
setMissingDataIsMissing
@Deprecated public static void setMissingDataIsMissing(boolean b)
Deprecated.do not useSet if missing_data attribute is considered isMissing()- Parameters:
b
- true if missing_data are missing (default true)
-
getMissingDataIsMissing
@Deprecated public static boolean getMissingDataIsMissing()
Deprecated.do not useGet if missing_data attribute is considered isMissing()- Returns:
- if missing_data attribute is considered isMissing()
-
initNetcdfFileCache
@Deprecated public static void initNetcdfFileCache(int minElementsInMemory, int maxElementsInMemory, int period)
Deprecated.use NetcdfDatasets.initNetcdfFileCacheEnable file caching. call this before calling acquireFile(). When application terminates, call NetcdfDataset.shutdown().- Parameters:
minElementsInMemory
- keep this number in the cachemaxElementsInMemory
- trigger a cleanup if it goes over this number.period
- (secs) do periodic cleanups every this number of seconds. set to < 0 to not cleanup
-
initNetcdfFileCache
@Deprecated public static void initNetcdfFileCache(int minElementsInMemory, int maxElementsInMemory, int hardLimit, int period)
Deprecated.use NetcdfDatasets.initNetcdfFileCacheEnable file caching. call this before calling acquireFile(). When application terminates, call NetcdfDataset.shutdown().- Parameters:
minElementsInMemory
- keep this number in the cachemaxElementsInMemory
- trigger a cleanup if it goes over this number.hardLimit
- if > 0, never allow more than this many elements. This causes a cleanup to be done in the calling thread.period
- (secs) do periodic cleanups every this number of seconds.
-
disableNetcdfFileCache
@Deprecated public static void disableNetcdfFileCache()
Deprecated.use NetcdfDatasets.disableNetcdfFileCache
-
shutdown
@Deprecated public static void shutdown()
Deprecated.use NetcdfDatasets.shutdownCall when application exits, if you have previously called initNetcdfFileCache. This shuts down any background threads in order to get a clean process shutdown.
-
getNetcdfFileCache
@Deprecated public static FileCacheIF getNetcdfFileCache()
Deprecated.use NetcdfDatasets.getNetcdfFileCacheGet the File Cache- Returns:
- File Cache or null if not enabled.
-
wrap
@Deprecated public static NetcdfDataset wrap(NetcdfFile ncfile, Set<NetcdfDataset.Enhance> mode) throws IOException
Deprecated.use NetcdfDatasets.wrapMake NetcdfFile into NetcdfDataset with given enhance mode- Parameters:
ncfile
- wrap thismode
- using this enhance mode (may be null, meaning no enhance)- Returns:
- NetcdfDataset wrapping the given ncfile
- Throws:
IOException
- on io error
-
openDataset
@Deprecated public static NetcdfDataset openDataset(String location) throws IOException
Deprecated.use NetcdfDatasets.openDatasetFactory method for opening a dataset through the netCDF API, and identifying its coordinate variables.- Parameters:
location
- location of file- Returns:
- NetcdfDataset object
- Throws:
IOException
- on read error
-
openDataset
@Deprecated public static NetcdfDataset openDataset(String location, boolean enhance, CancelTask cancelTask) throws IOException
Deprecated.use NetcdfDatasets.openDatasetFactory method for opening a dataset through the netCDF API, and identifying its coordinate variables.- Parameters:
location
- location of fileenhance
- if true, use defaultEnhanceMode, else no enhancementscancelTask
- allow task to be cancelled; may be null.- Returns:
- NetcdfDataset object
- Throws:
IOException
- on read error
-
openDataset
@Deprecated public static NetcdfDataset openDataset(String location, boolean enhance, int buffer_size, CancelTask cancelTask, Object spiObject) throws IOException
Deprecated.use NetcdfDatasets.openDatasetFactory method for opening a dataset through the netCDF API, and identifying its coordinate variables.- Parameters:
location
- location of fileenhance
- if true, use defaultEnhanceMode, else no enhancementsbuffer_size
- RandomAccessFile buffer size, if <= 0, use default sizecancelTask
- allow task to be cancelled; may be null.spiObject
- sent to iosp.setSpecial() if not null- Returns:
- NetcdfDataset object
- Throws:
IOException
- on read error
-
openDataset
@Deprecated public static NetcdfDataset openDataset(DatasetUrl location, Set<NetcdfDataset.Enhance> enhanceMode, int buffer_size, CancelTask cancelTask, Object spiObject) throws IOException
Deprecated.use NetcdfDatasets.openDatasetFactory method for opening a dataset through the netCDF API, and identifying its coordinate variables.- Parameters:
location
- location of fileenhanceMode
- set of enhancements. If null, then nonebuffer_size
- RandomAccessFile buffer size, if <= 0, use default sizecancelTask
- allow task to be cancelled; may be null.spiObject
- sent to iosp.setSpecial() if not null- Returns:
- NetcdfDataset object
- Throws:
IOException
- on read error
-
acquireDataset
@Deprecated public static NetcdfDataset acquireDataset(DatasetUrl location, CancelTask cancelTask) throws IOException
Deprecated.use NetcdfDatasets.acquireDatasetSame as openDataset, but file is acquired through the File Cache, with defaultEnhanceMode, without the need of setting the enhanceMode via the signature. You still close with NetcdfDataset.close(), the release is handled automatically. You must first call initNetcdfFileCache() for caching to actually take place.- Parameters:
location
- location of file, passed to FileFactorycancelTask
- allow task to be cancelled; may be null.- Returns:
- NetcdfDataset object
- Throws:
IOException
- on read error
-
acquireDataset
@Deprecated public static NetcdfDataset acquireDataset(DatasetUrl location, boolean enhanceMode, CancelTask cancelTask) throws IOException
Deprecated.use NetcdfDatasets.acquireDatasetSame as openDataset, but file is acquired through the File Cache, with defaultEnhanceMode. You still close with NetcdfDataset.close(), the release is handled automatically. You must first call initNetcdfFileCache() for caching to actually take place.- Parameters:
location
- location of file, passed to FileFactoryenhanceMode
- how to enhance. if null, then no enhancementcancelTask
- allow task to be cancelled; may be null.- Returns:
- NetcdfDataset object
- Throws:
IOException
- on read error
-
acquireDataset
@Deprecated public static NetcdfDataset acquireDataset(DatasetUrl location, Set<NetcdfDataset.Enhance> enhanceMode, CancelTask cancelTask) throws IOException
Deprecated.use NetcdfDatasets.acquireDatasetSame as openDataset, but file is acquired through the File Cache, with specified enhancements. You still close with NetcdfDataset.close(), the release is handled automatically. You must first call initNetcdfFileCache() for caching to actually take place.- Parameters:
location
- location of file, passed to FileFactoryenhanceMode
- how to enhance. if null, then no enhancementcancelTask
- allow task to be cancelled; may be null.- Returns:
- NetcdfDataset object
- Throws:
IOException
- on read error
-
acquireDataset
@Deprecated public static NetcdfDataset acquireDataset(FileFactory fac, DatasetUrl durl, Set<NetcdfDataset.Enhance> enhanceMode, int buffer_size, CancelTask cancelTask, Object iospMessage) throws IOException
Deprecated.use NetcdfDatasets.acquireDatasetSame as openDataset, but file is acquired through the File Cache. You must first call initNetcdfFileCache() for caching to actually take place. You still close with NetcdfDataset.close(), the release is handled automatically.- Parameters:
fac
- if not null, use this factory if the file is not in the cache. If null, use the default factory.durl
- location of file, passed to FileFactoryenhanceMode
- how to enhance. if null, then no enhancementbuffer_size
- RandomAccessFile buffer size, if <= 0, use default sizecancelTask
- allow task to be cancelled; may be null.iospMessage
- sent to iosp.setSpecial() if not null- Returns:
- NetcdfDataset or throw Exception
- Throws:
IOException
-
openFile
@Deprecated public static NetcdfFile openFile(String location, CancelTask cancelTask) throws IOException
Deprecated.use NetcdfDatasets.openFileFactory method for opening a NetcdfFile through the netCDF API.- Parameters:
location
- location of dataset.cancelTask
- use to allow task to be cancelled; may be null.- Returns:
- NetcdfFile object
- Throws:
IOException
- on read error
-
openFile
@Deprecated public static NetcdfFile openFile(DatasetUrl location, int buffer_size, CancelTask cancelTask, Object spiObject) throws IOException
Deprecated.use NetcdfDatasets.openFileFactory method for opening a NetcdfFile through the netCDF API. May be any kind of file that can be read through the netCDF API, including OpenDAP and NcML.This does not necessarily return a NetcdfDataset, or enhance the dataset; use NetcdfDatasets.openDataset() method for that.
- Parameters:
location
- location of dataset. This may be a- local filename (with a file: prefix or no prefix) for netCDF (version 3), hdf5 files, or any file type registered with NetcdfFile.registerIOProvider().
- OpenDAP dataset URL (with a dods:, dap4:, or http: prefix).
- NcML file or URL if the location ends with ".xml" or ".ncml"
- NetCDF file through an HTTP server (http: prefix)
- thredds dataset (thredds: prefix), see DataFactory.openDataset(String location, ...));
buffer_size
- RandomAccessFile buffer size, if <= 0, use default sizecancelTask
- allow task to be cancelled; may be null.spiObject
- sent to iosp.setSpecial() if not null- Returns:
- NetcdfFile object
- Throws:
IOException
- on read error
-
acquireFile
@Deprecated public static NetcdfFile acquireFile(DatasetUrl location, CancelTask cancelTask) throws IOException
Deprecated.use NetcdfDatasets.acquireFileSame as openFile, but file is acquired through the File Cache. You still close with NetcdfFile.close(), the release is handled automatically. You must first call initNetcdfFileCache() for caching to actually take place.- Parameters:
location
- location of file, passed to FileFactorycancelTask
- allow task to be cancelled; may be null.- Returns:
- NetcdfFile object
- Throws:
IOException
- on read error
-
acquireFile
@Deprecated public static NetcdfFile acquireFile(FileFactory factory, Object hashKey, DatasetUrl location, int buffer_size, CancelTask cancelTask, Object spiObject) throws IOException
Deprecated.use NetcdfDatasets.acquireFileSame as openFile, but file is acquired through the File Cache. You still close with NetcdfFile.close(), the release is handled automatically. You must first call initNetcdfFileCache() for caching to actually take place.- Parameters:
factory
- if not null, use this factory to read the file. If null, use the default factory.hashKey
- if not null, use as the cache key, else use the locationlocation
- location of file, passed to FileFactorybuffer_size
- RandomAccessFile buffer size, if <= 0, use default sizecancelTask
- allow task to be cancelled; may be null.spiObject
- sent to iosp.setSpecial(); may be null- Returns:
- NetcdfFile object
- Throws:
IOException
- on read error
-
getAggregation
@Deprecated public AggregationIF getAggregation()
Deprecated.Do not use.If its an NcML aggregation, it has an Aggregation object associated. This is public for use by NcmlWriter.- Returns:
- Aggregation or null
-
setAggregation
@Deprecated public void setAggregation(AggregationIF agg)
Deprecated.Use NetcdfDataset.builder()Set the Aggregation object associated with this NcML dataset- Parameters:
agg
- the Aggregation object
-
getCoordinateSystems
public com.google.common.collect.ImmutableList<CoordinateSystem> getCoordinateSystems()
Get the list of all CoordinateSystem objects used by this dataset.- Returns:
- list of type CoordinateSystem; may be empty, not null.
-
getConventionUsed
public String getConventionUsed()
Get conventions used to analyse coordinate systems.- Returns:
- conventions used to analyse coordinate systems
-
getEnhanceMode
public Set<NetcdfDataset.Enhance> getEnhanceMode()
Get the current state of dataset enhancement.- Returns:
- the current state of dataset enhancement.
-
getCoordinateTransforms
public com.google.common.collect.ImmutableList<CoordinateTransform> getCoordinateTransforms()
Get the list of all CoordinateTransform objects used by this dataset.- Returns:
- list of type CoordinateTransform; may be empty, not null.
-
getCoordinateAxes
public com.google.common.collect.ImmutableList<CoordinateAxis> getCoordinateAxes()
Get the list of all CoordinateAxis objects used by this dataset.- Returns:
- list of type CoordinateAxis; may be empty, not null.
-
clearCoordinateSystems
@Deprecated public void clearCoordinateSystems()
Deprecated.Use NetcdfDataset.builder()Clear Coordinate System metadata, to allow them to be redone
-
findCoordinateAxis
public CoordinateAxis findCoordinateAxis(AxisType type)
Retrieve the CoordinateAxis with the specified Axis Type.- Parameters:
type
- axis type- Returns:
- the first CoordinateAxis that has that type, or null if not found
-
findCoordinateAxis
public CoordinateAxis findCoordinateAxis(String fullName)
Retrieve the CoordinateAxis with the specified type.- Parameters:
fullName
- full escaped name of the coordinate axis- Returns:
- the CoordinateAxis, or null if not found
-
findCoordinateSystem
public CoordinateSystem findCoordinateSystem(String name)
Retrieve the CoordinateSystem with the specified name.- Parameters:
name
- String which identifies the desired CoordinateSystem- Returns:
- the CoordinateSystem, or null if not found
-
findCoordinateTransform
public CoordinateTransform findCoordinateTransform(String name)
Retrieve the CoordinateTransform with the specified name.- Parameters:
name
- String which identifies the desired CoordinateSystem- Returns:
- the CoordinateSystem, or null if not found
-
close
public void close() throws IOException
Close all resources (files, sockets, etc) associated with this dataset. If the underlying file was acquired, it will be released, otherwise closed.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFileCacheable
- Overrides:
close
in classNetcdfFile
- Throws:
IOException
- if error when closing
-
release
@Deprecated public void release() throws IOException
Deprecated.do not useDescription copied from class:NetcdfFile
Public by accident. Release any resources like file handles- Specified by:
release
in interfaceFileCacheable
- Overrides:
release
in classNetcdfFile
- Throws:
IOException
-
reacquire
@Deprecated public void reacquire() throws IOException
Deprecated.do not useDescription copied from class:NetcdfFile
Public by accident. Reacquire any resources like file handles- Specified by:
reacquire
in interfaceFileCacheable
- Overrides:
reacquire
in classNetcdfFile
- Throws:
IOException
-
getLastModified
public long getLastModified()
Description copied from interface:FileCacheable
Returns the time that the underlying file(s) were last modified. If they've changed since they were stored in the cache, they will be closed and reopened withFileFactory
.- Specified by:
getLastModified
in interfaceFileCacheable
- Overrides:
getLastModified
in classNetcdfFile
- Returns:
- a
long
value representing the time the file(s) were last modified or0L
if the last-modified time couldn't be determined for any reason.
-
empty
@Deprecated public void empty()
Deprecated.Use NetcdfDataset.builder()Description copied from class:NetcdfFile
Completely empty the objects in the netcdf file. Used for rereading the file on a sync().- Overrides:
empty
in classNetcdfFile
-
syncExtend
@Deprecated public boolean syncExtend() throws IOException
Deprecated.do not useDescription copied from class:NetcdfFile
Extend the file if needed, in a way that is compatible with the current metadata, that is, does not invalidate structural metadata held by the application. For example, ok if dimension lengths, data has changed. All previous object references (variables, dimensions, etc) remain valid.- Overrides:
syncExtend
in classNetcdfFile
- Returns:
- true if file was extended.
- Throws:
IOException
- if error
-
makeRecordStructure
@Deprecated protected Boolean makeRecordStructure()
Deprecated.Use NetcdfDatasets.open() with IOSP_MESSAGE_ADD_RECORD_STRUCTUREDescription copied from class:NetcdfFile
If there is an unlimited dimension, make all variables that use it into a Structure. A Variable called "record" is added. You can then access these through the record structure.- Overrides:
makeRecordStructure
in classNetcdfFile
- Returns:
- true if it has a Nectdf-3 record structure
-
sort
@Deprecated public void sort()
Deprecated.Use NetcdfDataset.builder()Sort Variables, CoordAxes by name.
-
getReferencedFile
@Deprecated public NetcdfFile getReferencedFile()
Deprecated.Do not useA NetcdfDataset usually wraps a NetcdfFile, where the actual I/O happens. This is called the "referenced file". CAUTION : this may have been modified in ways that make it unsuitable for general use.- Returns:
- underlying NetcdfFile, or null if none.
-
getIosp
@Deprecated public IOServiceProvider getIosp()
Deprecated.do not use- Overrides:
getIosp
in classNetcdfFile
-
setReferencedFile
@Deprecated public void setReferencedFile(NetcdfFile ncfile)
Deprecated.Use NetcdfDataset.builder()Set underlying file. CAUTION - normally only done through the constructor.- Parameters:
ncfile
- underlying "referenced file"
-
toStringDebug
protected String toStringDebug(Object o)
Description copied from class:NetcdfFile
Access to iosp debugging info.- Overrides:
toStringDebug
in classNetcdfFile
- Parameters:
o
- must be a Variable, Dimension, Attribute, or Group- Returns:
- debug info for this object.
-
addCoordinateSystem
@Deprecated public void addCoordinateSystem(CoordinateSystem cs)
Deprecated.Use NetcdfDataset.builder()Add a CoordinateSystem to the dataset.- Parameters:
cs
- add this CoordinateSystem to the dataset
-
addCoordinateTransform
@Deprecated public void addCoordinateTransform(CoordinateTransform ct)
Deprecated.Use NetcdfDataset.builder()Add a CoordinateTransform to the dataset.- Parameters:
ct
- add this CoordinateTransform to the dataset
-
addCoordinateAxis
@Deprecated public CoordinateAxis addCoordinateAxis(VariableDS v)
Deprecated.Use NetcdfDataset.builder()Add a CoordinateAxis to the dataset, by turning the VariableDS into a CoordinateAxis (if needed). Also adds it to the list of variables. Replaces any existing Variable and CoordinateAxis with the same name.- Parameters:
v
- make this VariableDS into a CoordinateAxis- Returns:
- the CoordinateAxis
-
addVariable
@Deprecated public Variable addVariable(Group g, Variable v)
Deprecated.Use NetcdfDataset.builder()Description copied from class:NetcdfFile
Add a Variable to the given group.- Overrides:
addVariable
in classNetcdfFile
- Parameters:
g
- add to this group. If group is null, use root groupv
- add this Variable- Returns:
- the variable that was added
-
enhance
@Deprecated public CoordSysBuilderIF enhance() throws IOException
Deprecated.Use NetcdfDataset.builder()recalc enhancement info - use default enhance mode- Returns:
- the CoordSysBuilder used, for debugging. do not modify or retain a reference
- Throws:
IOException
- on error
-
enhance
@Deprecated public void enhance(Set<NetcdfDataset.Enhance> mode) throws IOException
Deprecated.Use NetcdfDataset.builder()recalc enhancement info- Parameters:
mode
- how to enhance- Throws:
IOException
- on error
-
enhanceNeeded
@Deprecated public boolean enhanceNeeded(Set<NetcdfDataset.Enhance> want)
Deprecated.Do not use.is this enhancement already done ?- Parameters:
want
- enhancements wanted- Returns:
- true if wanted enhancement is not done
-
setValues
@Deprecated public void setValues(Variable v, int npts, double start, double incr)
Deprecated.use Variable.setValues()Generate the list of values from a starting value and an increment. Will reshape to variable if needed.- Parameters:
v
- for this variablenpts
- number of values, must = v.getSize()start
- starting valueincr
- increment
-
setValues
@Deprecated public void setValues(Variable v, List<String> values) throws IllegalArgumentException
Deprecated.use Variable.setValues()Set the data values from a list of Strings.- Parameters:
v
- for this variablevalues
- list of Strings- Throws:
IllegalArgumentException
- if values array not correct size, or values wont parse to the correct type
-
makeArray
@Deprecated public static Array makeArray(DataType dtype, List<String> stringValues) throws NumberFormatException
Deprecated.use Array#makeArray directlyMake a 1D array from a list of strings.- Parameters:
dtype
- data type of the array.stringValues
- list of strings.- Returns:
- resulting 1D array.
- Throws:
NumberFormatException
- if string values not parssable to specified data type
-
getDetailInfo
public void getDetailInfo(Formatter f)
Show debug / underlying implementation details- Overrides:
getDetailInfo
in classNetcdfFile
-
debugDump
@Deprecated public static void debugDump(PrintWriter out, NetcdfDataset ncd)
Deprecated.do not useDebugging- Parameters:
out
- write herencd
- info about this
-
getFileTypeId
public String getFileTypeId()
Description copied from class:NetcdfFile
Get the file type id for the underlying data source.- Overrides:
getFileTypeId
in classNetcdfFile
- Returns:
- registered id of the file type
- See Also:
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
getFileTypeDescription
public String getFileTypeDescription()
Description copied from class:NetcdfFile
Get a human-readable description for this file type.- Overrides:
getFileTypeDescription
in classNetcdfFile
- Returns:
- description of the file type
- See Also:
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
check
@Deprecated public void check(Formatter f)
Deprecated.do not use
-
toBuilder
public NetcdfDataset.Builder<?> toBuilder()
Description copied from class:NetcdfFile
Turn into a mutable Builder. Can use toBuilder().build() to copy.- Overrides:
toBuilder
in classNetcdfFile
-
builder
public static NetcdfDataset.Builder<?> builder()
Get Builder for this class that allows subclassing.- See Also:
- "https://community.oracle.com/blogs/emcmanus/2010/10/24/using-builder-pattern-subclasses"
-
builder
public static NetcdfDataset.Builder builder(NetcdfFile from)
-
main
@Deprecated public static void main(String[] arg) throws IOException
Deprecated.use ucar.nc2.writer.NccopyMain program - cover to ucar.nc2.FileWriter, for all files that can be read by NetcdfDataset.openFile()ucar.nc2.dataset.NetcdfDataset -in fileIn -out fileOut
where:
- fileIn : path of any CDM readable file
- fileOut: local pathname where netdf-3 file will be written
- Parameters:
arg
- -in-out [-isLargeFile] [-netcdf4] - Throws:
IOException
- on read or write error
-
-