Package ucar.nc2
Class NetcdfFile
java.lang.Object
ucar.nc2.NetcdfFile
- All Implemented Interfaces:
Closeable,AutoCloseable,ucar.nc2.util.cache.FileCacheable
- Direct Known Subclasses:
NetcdfDataset,NetcdfFileSubclass
Read-only scientific datasets that are accessible through the netCDF API.
Immutable after setImmutable() is called. Reading data is not
thread-safe because of the use of RandomAccessFile.
Using this class's Builder scheme to create a NetcdfFile object could, for
example, be accomplished as follows, using a try/finally block to ensure that the
NetcdfFile is closed when done.
NetcdfFile ncfile = null;
try {
ncfile = NetcdfFile.builder().setLocation(fileName).build();
// do stuff
} finally {
if (ncfile != null) {
ncfile.close();
}
}
More conveniently, a NetcdfFile object may be created using one of the static methods
in NetcdfFiles:
NetcdfFile ncfile = null;
try {
ncfile = NetcdfFiles.open(fileName);
// do stuff
} finally {
if (ncfile != null) {
ncfile.close();
}
}
Or better yet, use try-with-resources:
try (NetcdfFile ncfile = NetcdfFiles.open(fileName)) {
// do stuff
}
Naming
Each object has a name (aka "full name") that is unique within the entire netcdf file, and a "short name" that is unique within the parent group. These coincide for objects in the root group, and so are backwards compatible with version 3 files.- Variable: group1/group2/varname
- Structure member Variable: group1/group2/varname.s1.s2
- Group Attribute: group1/group2@attName
- Variable Attribute: group1/group2/varName@attName
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classNetcdfFile.Builder<T extends NetcdfFile.Builder<T>>A builder of NetcdfFile objects. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNetcdfFile(String filename) Deprecated.use NetcdfFiles.open( location) or NetcdfDatasets.openFile( location)NetcdfFile(URL url) Deprecated.use NetcdfFiles.open( http:location) or NetcdfDatasets.openFile( http:location) -
Method Summary
Modifier and TypeMethodDescriptionaddAttribute(Group parent, String name, String value) Deprecated.Use NetcdfFile.builder()addAttribute(Group parent, Attribute att) Deprecated.Use NetcdfFile.builder()addDimension(Group parent, Dimension d) Deprecated.Use NetcdfFile.builder()Deprecated.Use NetcdfFile.builder()addStringVariable(Group g, String shortName, String dims, int strlen) Deprecated.Use NetcdfFile.builder()addVariable(Group g, String shortName, DataType dtype, String dims) Deprecated.Use NetcdfFile.builder()addVariable(Group g, Variable v) Deprecated.Use NetcdfFile.builder()addVariableAttribute(Variable v, Attribute att) Deprecated.Use NetcdfFile.builder()static NetcdfFile.Builder<?>builder()Get Builder for this class.static StringcanonicalizeUriString(String location) Deprecated.use NetcdfFiles.canonicalizeUriStringstatic booleanDeprecated.use NetcdfFiles.canOpenvoidclose()Close all resources (files, sockets, etc) associated with this file.voidempty()Deprecated.findAttribute(String fullNameEscaped) Find an attribute, with the specified (escaped full) name.findAttValueIgnoreCase(Variable v, String attName, String defaultValue) Deprecated.use getRootGroup() or Variable attributes().findAttributeString().findDimension(String fullName) Finds a Dimension with the specified full name.findGlobalAttribute(String attName) Look up an Attribute by (short) name in the root Group or nested Groups, exact match.Look up an Attribute by (short) name in the root Group or nested Groups, ignore case.Find a Group, with the specified (full) name.findVariable(String fullNameEscaped) Find a Variable, with the specified (escaped full) name.findVariable(Group g, String shortName) Deprecated.use g.findVariable(shortName)findVariableByAttribute(Group g, String attName, String attValue) Deprecated.use g.findVariableByAttribute(String attName, String attValue)voidfinish()Deprecated.Use NetcdfFile.builder()Deprecated.do not useShow debug / underlying implementation detailsvoidcom.google.common.collect.ImmutableList<Dimension>Deprecated.use ncfile.getRootGroup().getDimensions() for files without nested groups, or recurse through nested groups to get dimensions.Get a human-readable description for this file type.Get the file type id for the underlying data source.Get the version of this file type.com.google.common.collect.ImmutableList<Attribute>Returns the set of global attributes associated with this file, which are the attributes associated with the root group, or any subgroup.getId()Get the globally unique dataset identifier, if it exists.getIosp()Deprecated.do not use.longDeprecated.Get the NetcdfFile location.Get the root group.getTitle()Get the human-readable title, if it exists.Return the unlimited (record) dimension, or null if not exist.com.google.common.collect.ImmutableList<Variable>Get all of the variables in the file, in all groups.booleanReturn true if this file has one or more unlimited (record) dimension.static booleaniospDeRegister(Class iospClass) Deprecated.use NetcdfFiles.iospDeRegisterstatic booleaniospRegistered(Class iospClass) Deprecated.use NetcdfFiles.iospRegisteredstatic StringmakeNameUnescaped(String vname) Deprecated.use NetcdfFiles.makeNameUnescapedstatic StringmakeValidCDLName(String vname) Deprecated.use NetcdfFiles.makeValidCDLNamestatic StringmakeValidCdmObjectName(String shortName) Deprecated.use NetcdfFiles.makeValidCdmObjectNamestatic StringmakeValidPathName(String vname) Deprecated.use NetcdfFiles.makeValidPathNamestatic StringmakeValidSectionSpecName(String vname) Deprecated.use NetcdfFiles.makeValidSectionSpecNamestatic NetcdfFileDeprecated.use NetcdfFiles.openstatic NetcdfFileopen(String location, int buffer_size, CancelTask cancelTask) Deprecated.use NetcdfFiles.openstatic NetcdfFileopen(String location, int buffer_size, CancelTask cancelTask, Object iospMessage) Deprecated.use NetcdfFiles.openstatic NetcdfFileopen(String location, String iospClassName, int bufferSize, CancelTask cancelTask, Object iospMessage) Deprecated.use NetcdfFiles.openstatic NetcdfFileopen(String location, CancelTask cancelTask) Deprecated.use NetcdfFiles.openstatic NetcdfFileopen(RandomAccessFile raf, String location, CancelTask cancelTask, Object iospMessage) Deprecated.use NetcdfFiles.openstatic NetcdfFileopenInMemory(String filename) Deprecated.use NetcdfFiles.openInMemorystatic NetcdfFileopenInMemory(String name, byte[] data) Deprecated.use NetcdfFiles.openInMemorystatic NetcdfFileopenInMemory(String name, byte[] data, String iospClassName) Deprecated.use NetcdfFiles.openInMemorystatic NetcdfFileopenInMemory(URI uri) Deprecated.use NetcdfFiles.openInMemoryvoidDeprecated.do not useDeprecated.use readSection(), flatten=false no longer supportedreadArrays(List<Variable> variables) Deprecated.will be moved to DODSNetcdfFile in version 6.doublereadAttributeDouble(Variable v, String attName, double defValue) Deprecated.use use getRootGroup() or Variable attributes().findAttributeDoubleintreadAttributeInteger(Variable v, String attName, int defValue) Deprecated.use use getRootGroup() or Variable attributes().findAttributeIntegerreadSection(String variableSection) Read a variable using the given section specification.static voidregisterIOProvider(Class iospClass) Deprecated.use NetcdfFiles.registerIOProviderstatic voidregisterIOProvider(Class iospClass, boolean last) Deprecated.use NetcdfFiles.registerIOProviderstatic voidregisterIOProvider(String className) Deprecated.use NetcdfFiles.registerIOProviderstatic voidregisterIOProviderPreferred(Class iospClass, Class target) Deprecated.use NetcdfFiles.registerIOProvidervoidrelease()Deprecated.do not usebooleanremoveDimension(Group g, String dimName) Deprecated.Use NetcdfFile.builder()booleanremoveVariable(Group g, String varName) Deprecated.Use NetcdfFile.builder()sendIospMessage(Object message) Generic way to send a "message" to the underlying IOSP.static voidsetDebugFlags(DebugFlags debugFlag) Deprecated.do not usevoidsetFileCache(ucar.nc2.util.cache.FileCacheIF cache) Deprecated.do not usevoidDeprecated.Use NetcdfFile.builder()Deprecated.Use NetcdfFile.builder()voidsetLocation(String location) Deprecated.Use NetcdfFile.builder()static voidsetProperty(String name, String value) Deprecated.do not usevoidsetRootGroup(Group rootGroup) Deprecated.Use NetcdfFile.builder()voidDeprecated.Use NetcdfFile.builder()booleanDeprecated.do not useTurn into a mutable Builder.NcML representation of Netcdf header info, non stricttoString()CDL representation of Netcdf header info, non strictvoidwriteCDL(OutputStream out, boolean strict) Deprecated.use CDLWritervoidwriteCDL(PrintWriter pw, boolean strict) Deprecated.use CDLWritervoidwriteNcml(OutputStream os, String uri) Write the NcML representation: dont show coordinate valuesvoidWrite the NcML representation: dont show coordinate values
-
Field Details
-
IOSP_MESSAGE_ADD_RECORD_STRUCTURE
Deprecated.- See Also:
-
IOSP_MESSAGE_CONVERT_RECORD_STRUCTURE
Deprecated.- See Also:
-
IOSP_MESSAGE_REMOVE_RECORD_STRUCTURE
Deprecated.- See Also:
-
IOSP_MESSAGE_RANDOM_ACCESS_FILE
- See Also:
-
IOSP_MESSAGE_GET_NETCDF_FILE_FORMAT
- See Also:
-
-
Constructor Details
-
NetcdfFile
Deprecated.use NetcdfFiles.open( location) or NetcdfDatasets.openFile( location)This is can only be used for local netcdf-3 files.- Parameters:
filename- location- Throws:
IOException- if error
-
NetcdfFile
Deprecated.use NetcdfFiles.open( http:location) or NetcdfDatasets.openFile( http:location)This can only be used for netcdf-3 files served over HTTP- Parameters:
url- HTTP URL location- Throws:
IOException- if error
-
-
Method Details
-
setDebugFlags
Deprecated.do not use -
registerIOProvider
@Deprecated public static void registerIOProvider(String className) throws IllegalAccessException, InstantiationException, ClassNotFoundException Deprecated.use NetcdfFiles.registerIOProviderRegister an IOServiceProvider, using its class string name.- Parameters:
className- Class that implements IOServiceProvider.- Throws:
IllegalAccessException- if class is not accessible.InstantiationException- if class doesnt have a no-arg constructor.ClassNotFoundException- if class not found.
-
registerIOProvider
@Deprecated public static void registerIOProvider(Class iospClass) throws IllegalAccessException, InstantiationException Deprecated.use NetcdfFiles.registerIOProviderRegister an IOServiceProvider. A new instance will be created when one of its files is opened.- Parameters:
iospClass- Class that implements IOServiceProvider.- Throws:
IllegalAccessException- if class is not accessible.InstantiationException- if class doesnt have a no-arg constructor.ClassCastException- if class doesnt implement IOServiceProvider interface.
-
registerIOProvider
@Deprecated public static void registerIOProvider(Class iospClass, boolean last) throws IllegalAccessException, InstantiationException Deprecated.use NetcdfFiles.registerIOProviderRegister an IOServiceProvider. A new instance will be created when one of its files is opened.- Parameters:
iospClass- Class that implements IOServiceProvider.last- true=>insert at the end of the list; otherwise front- Throws:
IllegalAccessException- if class is not accessible.InstantiationException- if class doesnt have a no-arg constructor.ClassCastException- if class doesnt implement IOServiceProvider interface.
-
registerIOProviderPreferred
@Deprecated public static void registerIOProviderPreferred(Class iospClass, Class target) throws IllegalAccessException, InstantiationException Deprecated.use NetcdfFiles.registerIOProviderRegister an IOServiceProvider. A new instance will be created when one of its files is opened. This differs from the above in that it specifically locates the target iosp and inserts the new one in front of it in order to override the target. If the iospclass is already registered, remove it and reinsert. If the target class is not present, then insert at front of the registry- Parameters:
iospClass- Class that implements IOServiceProvider.target- Class to override- Throws:
IllegalAccessException- if class is not accessible.InstantiationException- if class doesnt have a no-arg constructor.ClassCastException- if class doesnt implement IOServiceProvider interface.
-
iospRegistered
Deprecated.use NetcdfFiles.iospRegisteredSee if a specific IOServiceProvider is registered- Parameters:
iospClass- Class for which to search
-
iospDeRegister
Deprecated.use NetcdfFiles.iospDeRegisterSee if a specific IOServiceProvider is registered and if so, remove it.- Parameters:
iospClass- Class for which to search and remove- Returns:
- true if class was present
-
setProperty
Deprecated.do not useSet properties. Currently recognized: "syncExtendOnly", "true" or "false" (default). if true, can only extend file on a sync.- Parameters:
name- name of propertyvalue- value of property
-
open
Deprecated.use NetcdfFiles.openOpen an existing netcdf file (read only).- Parameters:
location- location of file.- Returns:
- the NetcdfFile.
- Throws:
IOException- if error
-
open
@Deprecated public static NetcdfFile open(String location, CancelTask cancelTask) throws IOException Deprecated.use NetcdfFiles.openOpen an existing file (read only), with option of cancelling.- Parameters:
location- location of the file.cancelTask- allow task to be cancelled; may be null.- Returns:
- NetcdfFile object, or null if cant find IOServiceProver
- Throws:
IOException- if error
-
open
@Deprecated public static NetcdfFile open(String location, int buffer_size, CancelTask cancelTask) throws IOException Deprecated.use NetcdfFiles.openOpen an existing file (read only), with option of cancelling, setting the RandomAccessFile buffer size for efficiency.- Parameters:
location- location of file.buffer_size- RandomAccessFile buffer size, if <= 0, use default sizecancelTask- allow task to be cancelled; may be null.- Returns:
- NetcdfFile object, or null if cant find IOServiceProver
- Throws:
IOException- if error
-
open
@Deprecated public static NetcdfFile open(String location, int buffer_size, CancelTask cancelTask, Object iospMessage) throws IOException Deprecated.use NetcdfFiles.openOpen an existing file (read only), with option of cancelling, setting the RandomAccessFile buffer size for efficiency, with an optional special object for the iosp.- Parameters:
location- location of file. This may be a- local netcdf-3 filename (with a file: prefix or no prefix)
- remote netcdf-3 filename (with an http: prefix)
- local netcdf-4 filename (with a file: prefix or no prefix)
- local hdf-5 filename (with a file: prefix or no prefix)
- local iosp filename (with a file: prefix or no prefix)
buffer_size- RandomAccessFile buffer size, if <= 0, use default sizecancelTask- allow task to be cancelled; may be null.iospMessage- special iosp tweaking (sent before open is called), may be null- Returns:
- NetcdfFile object, or null if cant find IOServiceProver
- Throws:
IOException- if error
-
canOpen
Deprecated.use NetcdfFiles.canOpenFind out if the file can be opened, but dont actually open it. Experimental.- Parameters:
location- same as open- Returns:
- true if can be opened
- Throws:
IOException- on read error
-
open
@Deprecated public static NetcdfFile open(String location, String iospClassName, int bufferSize, CancelTask cancelTask, Object iospMessage) throws ClassNotFoundException, IllegalAccessException, InstantiationException, IOException Deprecated.use NetcdfFiles.openOpen an existing file (read only), specifying which IOSP is to be used.- Parameters:
location- location of fileiospClassName- fully qualified class name of the IOSP class to handle this filebufferSize- RandomAccessFile buffer size, if <= 0, use default sizecancelTask- allow task to be cancelled; may be null.iospMessage- special iosp tweaking (sent before open is called), may be null- Returns:
- NetcdfFile object, or null if cant find IOServiceProver
- Throws:
IOException- if read errorClassNotFoundException- cannat find iospClassName in thye class pathInstantiationException- if class cannot be instantiatedIllegalAccessException- if class is not accessible
-
canonicalizeUriString
Deprecated.use NetcdfFiles.canonicalizeUriStringRemoves the"file:"or"file://"prefix from the location, if necessary. Also replaces back slashes with forward slashes.- Parameters:
location- a URI string.- Returns:
- a canonical URI string.
-
openInMemory
@Deprecated public static NetcdfFile openInMemory(String name, byte[] data, String iospClassName) throws IOException, ClassNotFoundException, IllegalAccessException, InstantiationException Deprecated.use NetcdfFiles.openInMemoryOpen an in-memory netcdf file, with a specific iosp.- Parameters:
name- name of the dataset. Typically use the filename or URI.data- in-memory netcdf fileiospClassName- fully qualified class name of the IOSP class to handle this file- Returns:
- NetcdfFile object, or null if cant find IOServiceProver
- Throws:
IOException- if read errorClassNotFoundException- cannat find iospClassName in the class pathInstantiationException- if class cannot be instantiatedIllegalAccessException- if class is not accessible
-
openInMemory
Deprecated.use NetcdfFiles.openInMemoryOpen an in-memory netcdf file.- Parameters:
name- name of the dataset. Typically use the filename or URI.data- in-memory netcdf file- Returns:
- memory-resident NetcdfFile
- Throws:
IOException- if error
-
openInMemory
Deprecated.use NetcdfFiles.openInMemoryRead a local CDM file into memory. All reads are then done from memory.- Parameters:
filename- location of CDM file, must be a local file.- Returns:
- a NetcdfFile, which is completely in memory
- Throws:
IOException- if error reading file
-
openInMemory
Deprecated.use NetcdfFiles.openInMemoryRead a remote CDM file into memory. All reads are then done from memory.- Parameters:
uri- location of CDM file, must be accessible through url.toURL().openStream().- Returns:
- a NetcdfFile, which is completely in memory
- Throws:
IOException- if error reading file
-
open
@Deprecated public static NetcdfFile open(RandomAccessFile raf, String location, CancelTask cancelTask, Object iospMessage) throws IOException Deprecated.use NetcdfFiles.openOpen a RandomAccessFile as a NetcdfFile, if possible.- Parameters:
raf- The open raf, is not cloised by this method.location- human readable locatoin of this dataset.cancelTask- used to monitor user cancellation; may be null.iospMessage- send this message to iosp; may be null.- Returns:
- NetcdfFile or throw an Exception.
- Throws:
IOException- if cannot open as a CDM NetCDF.
-
close
Close all resources (files, sockets, etc) associated with this file. If the underlying file was acquired, it will be released, otherwise closed. if isClosed() already, nothing will happen- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceucar.nc2.util.cache.FileCacheable- Throws:
IOException- if error when closing
-
release
Deprecated.do not usePublic by accident. Release any resources like file handles- Specified by:
releasein interfaceucar.nc2.util.cache.FileCacheable- Throws:
IOException
-
reacquire
Deprecated.do not usePublic by accident. Reacquire any resources like file handles- Specified by:
reacquirein interfaceucar.nc2.util.cache.FileCacheable- Throws:
IOException
-
setFileCache
Deprecated.do not usePublic by accident. Optional file caching.- Specified by:
setFileCachein interfaceucar.nc2.util.cache.FileCacheable
-
getCacheName
Deprecated.do not usePublic by accident. Get the name used in the cache, if any.- Returns:
- name in the cache.
-
getLocation
Get the NetcdfFile location. This is a URL, or a file pathname.- Specified by:
getLocationin interfaceucar.nc2.util.cache.FileCacheable- Returns:
- location URL or file pathname.
-
getId
Get the globally unique dataset identifier, if it exists.- Returns:
- id, or null if none.
-
getTitle
Get the human-readable title, if it exists.- Returns:
- title, or null if none.
-
getRootGroup
Get the root group.- Returns:
- root group
-
findGroup
Find a Group, with the specified (full) name. A full name should start with a '/'. For backwards compatibility, we accept full names that omit the leading '/'. An embedded '/' separates subgroup names.- Parameters:
fullName- eg "/group/subgroup/wantGroup". Null or empty string returns the root group.- Returns:
- Group or null if not found.
-
findVariable
Deprecated.use g.findVariable(shortName)Find a Variable by short name, in the given group.- Parameters:
g- A group in this file. Null for root group.shortName- short name of the Variable.- Returns:
- Variable if found, else null.
-
findVariable
Find a Variable, with the specified (escaped full) name. It may possibly be nested in multiple groups and/or structures. An embedded "." is interpreted as structure.member. An embedded "/" is interpreted as group/variable. If the name actually has a ".", you must escape it (call NetcdfFiles.makeValidPathName(varname)) Any other chars may also be escaped, as they are removed before testing.- Parameters:
fullNameEscaped- eg "/group/subgroup/name1.name2.name".- Returns:
- Variable or null if not found.
-
findVariableByAttribute
@Deprecated @Nullable public Variable findVariableByAttribute(Group g, String attName, String attValue) Deprecated.use g.findVariableByAttribute(String attName, String attValue)Look in the given Group and in its nested Groups for a Variable with a String valued Attribute with the given name and value.- Parameters:
g- start with this Group, null for the root Group.attName- look for an Attribuite with this name.attValue- look for an Attribuite with this value.- Returns:
- the first Variable that matches, or null if none match.
-
findDimension
Finds a Dimension with the specified full name. It may be nested in multiple groups. An embedded "/" is interpreted as a group separator. A leading slash indicates the root group. That slash may be omitted, but thefullNamewill be treated as if it were there. In other words, the first name token infullNameis treated as the short name of a Group or Dimension, relative to the root group.- Parameters:
fullName- Dimension full name, e.g. "/group/subgroup/dim".- Returns:
- the Dimension or
nullif it wasn't found.
-
hasUnlimitedDimension
public boolean hasUnlimitedDimension()Return true if this file has one or more unlimited (record) dimension.- Returns:
- if this file has an unlimited Dimension(s)
-
getUnlimitedDimension
Return the unlimited (record) dimension, or null if not exist. If there are multiple unlimited dimensions, it will return the first one.- Returns:
- the unlimited Dimension, or null if none.
-
getDimensions
Deprecated.use ncfile.getRootGroup().getDimensions() for files without nested groups, or recurse through nested groups to get dimensions.Get the shared Dimensions used in this file.If the dimensions are in a group, the dimension name will have the group name, in order to disambiguate the dimensions. This means that a Variable's dimensions will not match Dimensions in this list. Therefore it is better to get the shared Dimensions directly from the Groups.
-
getVariables
Get all of the variables in the file, in all groups. Alternatively, use groups. -
getGlobalAttributes
Returns the set of global attributes associated with this file, which are the attributes associated with the root group, or any subgroup. Alternatively, use groups. -
findGlobalAttribute
Look up an Attribute by (short) name in the root Group or nested Groups, exact match.- Parameters:
attName- the name of the attribute- Returns:
- the first Group attribute with given name, or null if not found
-
findGlobalAttributeIgnoreCase
Look up an Attribute by (short) name in the root Group or nested Groups, ignore case.- Parameters:
name- the name of the attribute- Returns:
- the first group attribute with given Attribute name, ignoronmg case, or null if not found
-
findAttribute
Find an attribute, with the specified (escaped full) name. It may possibly be nested in multiple groups and/or structures. An embedded "." is interpreted as structure.member. An embedded "/" is interpreted as group/group or group/variable. An embedded "@" is interpreted as variable@attribute If the name actually has a ".", you must escape it (call NetcdfFiles.makeValidPathName(varname)) Any other chars may also be escaped, as they are removed before testing.- Parameters:
fullNameEscaped- eg "@attName", "/group/subgroup/@attName" or "/group/subgroup/varname.name2.name@attName"- Returns:
- Attribute or null if not found.
-
findAttValueIgnoreCase
Deprecated.use getRootGroup() or Variable attributes().findAttributeString().Find a String-valued global or variable Attribute by Attribute name (ignore case), return the Value of the Attribute. If not found return defaultValue- Parameters:
v- the variable or null to look in the root group.attName- the (full) name of the attribute, case insensitivedefaultValue- return this if attribute not found- Returns:
- the attribute value, or defaultValue if not found
-
readAttributeDouble
Deprecated.use use getRootGroup() or Variable attributes().findAttributeDouble -
readAttributeInteger
Deprecated.use use getRootGroup() or Variable attributes().findAttributeInteger -
toString
CDL representation of Netcdf header info, non strict -
toNcml
NcML representation of Netcdf header info, non strict -
writeNcml
Write the NcML representation: dont show coordinate values- Parameters:
os- : write to this OutputStream. Will be closed at end of the method.uri- use this for the url attribute; if null use getLocation(). // ??- Throws:
IOException- if error
-
writeNcml
Write the NcML representation: dont show coordinate values- Parameters:
writer- : write to this Writer, should have encoding of UTF-8. Will be closed at end of the method.uri- use this for the url attribute; if null use getLocation().- Throws:
IOException- if error
-
writeCDL
Deprecated.use CDLWriterWrite CDL representation to OutputStream.- Parameters:
out- write to this OutputStreamstrict- if true, make it stricly CDL, otherwise, add a little extra info
-
writeCDL
Deprecated.use CDLWriterWrite CDL representation to PrintWriter.- Parameters:
pw- write to this PrintWriterstrict- if true, make it stricly CDL, otherwise, add a little extra info
-
syncExtend
Deprecated.do not useExtend 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.- Returns:
- true if file was extended.
- Throws:
IOException- if error
-
getLastModified
Deprecated.- Specified by:
getLastModifiedin interfaceucar.nc2.util.cache.FileCacheable
-
addAttribute
Deprecated.Use NetcdfFile.builder()Add an attribute to a group.- Parameters:
parent- add to this group. If group is null, use root groupatt- add this attribute- Returns:
- the attribute that was added
-
addAttribute
Deprecated.Use NetcdfFile.builder()Add optional String attribute to a group.- Parameters:
parent- add to this group. If group is null, use root groupname- attribute name, may not be nullvalue- attribute value, may be null, in which case, do not addd- Returns:
- the attribute that was added
-
addGroup
Deprecated.Use NetcdfFile.builder()Add a group to the parent group.- Parameters:
parent- add to this group. If group is null, use root groupg- add this group- Returns:
- the group that was added
-
setRootGroup
Deprecated.Use NetcdfFile.builder()Public by accident. -
addDimension
Deprecated.Use NetcdfFile.builder()Add a shared Dimension to a Group.- Parameters:
parent- add to this group. If group is null, use root groupd- add this Dimension- Returns:
- the dimension that was added
-
removeDimension
Deprecated.Use NetcdfFile.builder()Remove a shared Dimension from a Group by name.- Parameters:
g- remove from this group. If group is null, use root groupdimName- name of Dimension to remove.- Returns:
- true if found and removed.
-
addVariable
Deprecated.Use NetcdfFile.builder()Add a Variable to the given group.- Parameters:
g- add to this group. If group is null, use root groupv- add this Variable- Returns:
- the variable that was added
-
addVariable
Deprecated.Use NetcdfFile.builder()Create a new Variable, and add to the given group.- Parameters:
g- add to this group. If group is null, use root groupshortName- short name of the Variabledtype- data type of the Variabledims- list of dimension names- Returns:
- the new Variable
-
addStringVariable
Deprecated.Use NetcdfFile.builder()Create a new Variable of type Datatype.CHAR, and add to the given group.- Parameters:
g- add to this group. If group is null, use root groupshortName- short name of the Variabledims- list of dimension namesstrlen- dimension length of the inner (fastest changing) dimension- Returns:
- the new Variable
-
removeVariable
Deprecated.Use NetcdfFile.builder()Remove a Variable from the given group by name.- Parameters:
g- remove from this group. If group is null, use root groupvarName- name of variable to remove.- Returns:
- true is variable found and removed
-
addVariableAttribute
Deprecated.Use NetcdfFile.builder()Add a variable attribute.- Parameters:
v- add to this Variable.att- add this attribute- Returns:
- the added Attribute
-
sendIospMessage
Generic way to send a "message" to the underlying IOSP. This message is sent after the file is open. To affect the creation of the file, use a factory method like NetcdfFile.open(). In ver6, IOSP_MESSAGE_ADD_RECORD_STRUCTURE, IOSP_MESSAGE_REMOVE_RECORD_STRUCTURE will not work here.- Parameters:
message- iosp specific message- Returns:
- iosp specific return, may be null
-
setId
Deprecated.Use NetcdfFile.builder()Set the globally unique dataset identifier.- Parameters:
id- the id
-
setTitle
Deprecated.Use NetcdfFile.builder()Set the dataset "human readable" title.- Parameters:
title- the title
-
setLocation
Deprecated.Use NetcdfFile.builder()Set the location, a URL or local filename.- Parameters:
location- the location
-
setImmutable
Deprecated.Use NetcdfFile.builder()Make this immutable.- Returns:
- this
-
empty
Deprecated.Completely empty the objects in the netcdf file. Used for rereading the file on a sync(). -
finish
Deprecated.Use NetcdfFile.builder()Finish constructing the object model. This construsts the "global" variables, attributes and dimensions. It also looks for coordinate variables. -
readSection
Read a variable using the given section specification. The result is always an array of the type of the innermost variable. Its shape is the accumulation of all the shapes of its parent structures.- Parameters:
variableSection- the constraint expression.- Returns:
- data requested
- Throws:
IOException- if errorInvalidRangeException- if variableSection is invalid- See Also:
-
readArrays
Deprecated.will be moved to DODSNetcdfFile in version 6.Do a bulk read on a list of Variables and return a corresponding list of Array that contains the results of a full read on each Variable. This is mostly here so DODSNetcdf can override it with one call to the server.- Parameters:
variables- List of type Variable- Returns:
- List of Array, one for each Variable in the input.
- Throws:
IOException- if read error
-
read
@Deprecated public Array read(String variableSection, boolean flatten) throws IOException, InvalidRangeException Deprecated.use readSection(), flatten=false no longer supportedRead a variable using the given section specification.- Parameters:
variableSection- the constraint expression.flatten- MUST BE TRUE- Returns:
- Array data read.
- Throws:
IOException- if errorInvalidRangeException- if variableSection is invalid- See Also:
-
getDetailInfo
Show debug / underlying implementation details -
getDetailInfo
-
getIosp
Deprecated.do not use. -
getFileTypeId
Get the file type id for the underlying data source.- Returns:
- registered id of the file type
- See Also:
-
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
getFileTypeDescription
Get a human-readable description for this file type.- Returns:
- description of the file type
- See Also:
-
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
getFileTypeVersion
Get the version of this file type.- Returns:
- version of the file type
- See Also:
-
- "https://www.unidata.ucar.edu/software/netcdf-java/formats/FileTypes.html"
-
makeValidCdmObjectName
Deprecated.use NetcdfFiles.makeValidCdmObjectNameCreate a valid CDM object name. Control chars (< 0x20) are not allowed. Trailing and leading blanks are not allowed and are stripped off. A space is converted into an underscore "_". A forward slash "/" is converted into an underscore "_".- Parameters:
shortName- from this name- Returns:
- valid CDM object name
-
makeValidCDLName
Deprecated.use NetcdfFiles.makeValidCDLNameEscape special characters in a netcdf short name when it is intended for use in CDL.- Parameters:
vname- the name- Returns:
- escaped version of it
-
makeValidPathName
Deprecated.use NetcdfFiles.makeValidPathNameEscape special characters in a netcdf short name when it is intended for use in a fullname- Parameters:
vname- the name- Returns:
- escaped version of it
-
makeValidSectionSpecName
Deprecated.use NetcdfFiles.makeValidSectionSpecNameEscape special characters in a netcdf short name when it is intended for use in a sectionSpec- Parameters:
vname- the name- Returns:
- escaped version of it
-
makeNameUnescaped
Deprecated.use NetcdfFiles.makeNameUnescapedUnescape any escaped characters in a name.- Parameters:
vname- the escaped name- Returns:
- unescaped version of it
-
toBuilder
Turn into a mutable Builder. Can use toBuilder().build() to copy. -
builder
Get Builder for this class. Allows subclassing.- See Also:
-
- "https://community.oracle.com/blogs/emcmanus/2010/10/24/using-builder-pattern-subclasses"
-