Package ucar.nc2.dods
Class DODSNetcdfFile
- java.lang.Object
-
- ucar.nc2.NetcdfFile
-
- ucar.nc2.dods.DODSNetcdfFile
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,FileCacheable
@NotThreadSafe public class DODSNetcdfFile extends NetcdfFile
Access to DODS datasets through the Netcdf API.- See Also:
NetcdfFile
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ucar.nc2.NetcdfFile
NetcdfFile.Builder<T extends NetcdfFile.Builder<T>>
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
debugAttributes
static boolean
debugCached
static boolean
debugCE
static boolean
debugCharArray
static boolean
debugConstruct
static boolean
debugConvertData
static boolean
debugDataResult
static boolean
debugOpenResult
static boolean
debugOpenTime
static boolean
debugPreload
static boolean
debugServerCall
static boolean
debugTime
static boolean
showNCfile
-
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 DODSNetcdfFile(String datasetURL)
Open a DODS file.DODSNetcdfFile(String datasetURL, CancelTask cancelTask)
Open a DODS file, allow user control over preloading string arrays and making structure data available through netcdf API.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String
canonicalURL(String urlName)
Create the canonical form of the URL.void
close()
Close all resources (files, sockets, etc) associated with this file.protected static Attribute
combineAxesAttrs(Attribute axis1, Attribute axis2)
Safely combine the multiple axis attributes without duplicationstatic int
convertToDODSType(DataType dataType)
Get the DODS data class corresponding to the Netcdf data type.static DataType
convertToNCType(int dodsDataType, boolean isUnsigned)
Get the Netcdf data type corresponding to the DODS data type.static DataType
convertToNCType(BaseType dtype, boolean isUnsigned)
Get the Netcdf data type corresponding to the DODS BaseType class.void
getDetailInfo(Formatter f)
static String
getDODSConstraintName(Variable var)
Return a variable name suitable for use in a DAP constraint expression.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
isUnsigned(BaseType dtype)
Get whether this is an unsigned type.protected int[]
makeShape(DArray dodsArray)
protected Array
readData(Variable v, Section section)
Do not call this directly, use Variable.read() !! Ranges must be filled (no nulls)Array
readSection(String variableSection)
Read a variable using the given section specification.long
readToByteChannel(Variable v, Section section, WritableByteChannel channel)
Read data from a top level Variable and send data to a WritableByteChannel.Array
readWithCE(Variable v, String CE)
protected void
reGroup()
Go thru the variables/structure-variables and their attributes and move to the proper groups.protected void
reGroupVariable(Group rootgroup, DODSVariable dodsv)
Deprecated.static void
setAllowCompression(boolean b)
Set whether to allow messages to be compressed.static void
setAllowDeflate(boolean b)
Deprecated.use setAllowCompressionstatic void
setAllowSessions(boolean b)
Set whether to allow sessions by allowing cookies.static void
setCoordinateVariablePreloadSize(int size)
If preloading, set maximum size of coordinate variables to be preloaded.static void
setDebugFlags(DebugFlags debugFlag)
Debugging flags.static void
setPreload(boolean b)
Set whether small variables are preloaded; only turn off for debugging.-
Methods inherited from class ucar.nc2.NetcdfFile
addAttribute, addAttribute, addDimension, addGroup, addLocalFieldsToBuilder, addStringVariable, addVariable, addVariable, addVariableAttribute, builder, canonicalizeUriString, canOpen, empty, findAttribute, findAttValueIgnoreCase, findDimension, findGlobalAttribute, findGlobalAttributeIgnoreCase, findGroup, findVariable, findVariable, findVariableByAttribute, finish, getCacheName, getDetailInfo, getDimensions, getFileTypeVersion, getGlobalAttributes, getId, getIosp, getLastModified, getLocation, getRootGroup, getStructureIterator, getTitle, getUnlimitedDimension, getVariables, hasUnlimitedDimension, iospDeRegister, iospRegistered, makeFullName, makeFullName, makeFullNameSectionSpec, makeFullNameWithString, makeNameUnescaped, makeRecordStructure, makeValidCDLName, makeValidCdmObjectName, makeValidPathName, makeValidSectionSpecName, open, open, open, open, open, open, openInMemory, openInMemory, openInMemory, openInMemory, reacquire, read, readArrays, readAttributeDouble, readAttributeInteger, readToOutputStream, registerIOProvider, registerIOProvider, registerIOProvider, registerIOProviderPreferred, release, removeDimension, removeRecordStructure, removeVariable, sendIospMessage, setCacheName, setFileCache, setId, setImmutable, setLocation, setProperty, setRootGroup, setTitle, showCached, showProxies, syncExtend, toBuilder, toNcml, toString, toStringDebug, writeCDL, writeCDL, writeCDL, writeNcml, writeNcml
-
-
-
-
Field Detail
-
debugCE
public static boolean debugCE
-
debugServerCall
public static boolean debugServerCall
-
debugOpenResult
public static boolean debugOpenResult
-
debugDataResult
public static boolean debugDataResult
-
debugCharArray
public static boolean debugCharArray
-
debugConvertData
public static boolean debugConvertData
-
debugConstruct
public static boolean debugConstruct
-
debugPreload
public static boolean debugPreload
-
debugTime
public static boolean debugTime
-
showNCfile
public static boolean showNCfile
-
debugAttributes
public static boolean debugAttributes
-
debugCached
public static boolean debugCached
-
debugOpenTime
public static boolean debugOpenTime
-
-
Constructor Detail
-
DODSNetcdfFile
public DODSNetcdfFile(String datasetURL) throws IOException
Open a DODS file.- Parameters:
datasetURL
- URL of the file. This should start with the protocol "dods:" It may also start with protocol "http:".- Throws:
IOException
- on io errorMalformedURLException
-
DODSNetcdfFile
public DODSNetcdfFile(String datasetURL, CancelTask cancelTask) throws IOException
Open a DODS file, allow user control over preloading string arrays and making structure data available through netcdf API.- Parameters:
datasetURL
- URL of the file. This should start with the protocol "dods:" or "http:".cancelTask
- check if task is cancelled. may be null.- Throws:
IOException
- on io errorMalformedURLException
-
-
Method Detail
-
setAllowSessions
public static void setAllowSessions(boolean b)
Set whether to allow sessions by allowing cookies. This only affects requests to the TDS. Setting this to true can eliminate consistency problems for datasets that are being updated.- Parameters:
b
- true or false. default is false.
-
setAllowDeflate
public static void setAllowDeflate(boolean b)
Deprecated.use setAllowCompressionSet whether to allow messages to be compressed.- Parameters:
b
- true or false.
-
setAllowCompression
public static void setAllowCompression(boolean b)
Set whether to allow messages to be compressed.- Parameters:
b
- true or false.
-
setDebugFlags
public static void setDebugFlags(DebugFlags debugFlag)
Debugging flags. This is a way to decouple setting flags from particular implementations.- Parameters:
debugFlag
- set of debug flags.
-
setPreload
public static void setPreload(boolean b)
Set whether small variables are preloaded; only turn off for debugging.- Parameters:
b
- true if small variables are preloaded (default true)
-
setCoordinateVariablePreloadSize
public static void setCoordinateVariablePreloadSize(int size)
If preloading, set maximum size of coordinate variables to be preloaded.- Parameters:
size
- maximum size of coordinate variables to be preloaded.
-
canonicalURL
public static String canonicalURL(String urlName)
Create the canonical form of the URL. If the urlName starts with "http:" or "https:", change it to start with "dods:", otherwise leave it alone.- Parameters:
urlName
- the url string- Returns:
- canonical form
-
close
public void close() throws IOException
Description copied from class:NetcdfFile
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:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceFileCacheable
- Overrides:
close
in classNetcdfFile
- Throws:
IOException
- if error when closing
-
reGroup
protected void reGroup() throws DAP2Exception
Go thru the variables/structure-variables and their attributes and move to the proper groups.- Throws:
DAP2Exception
-
reGroupVariable
@Deprecated protected void reGroupVariable(Group rootgroup, DODSVariable dodsv)
Deprecated.
-
combineAxesAttrs
protected static Attribute combineAxesAttrs(Attribute axis1, Attribute axis2)
Safely combine the multiple axis attributes without duplication- Parameters:
axis1
- axis attribute 1axis2
- axis attribute 2- Returns:
- the combined axis attribute
-
makeShape
protected int[] makeShape(DArray dodsArray)
-
getDODSConstraintName
public static String getDODSConstraintName(Variable var)
Return a variable name suitable for use in a DAP constraint expression. [Original code seemed wrong because structures can be nested and hence would have to use the full name just like non-structures]- Parameters:
var
- The variable whose name will appear in the CE- Returns:
- The name in a form suitable for use in a cE
-
convertToDODSType
public static int convertToDODSType(DataType dataType)
Get the DODS data class corresponding to the Netcdf data type. This is the inverse of convertToNCType().- Parameters:
dataType
- Netcdf data type.- Returns:
- the corresponding DODS type enum, from opendap.dap.Attribute.XXXX.
-
convertToNCType
public static DataType convertToNCType(int dodsDataType, boolean isUnsigned)
Get the Netcdf data type corresponding to the DODS data type. This is the inverse of convertToDODSType().- Parameters:
dodsDataType
- DODS type enum, from dods.dap.Attribute.XXXX.- Returns:
- the corresponding netcdf DataType.
- See Also:
isUnsigned(opendap.dap.BaseType)
-
convertToNCType
public static DataType convertToNCType(BaseType dtype, boolean isUnsigned)
Get the Netcdf data type corresponding to the DODS BaseType class. This is the inverse of convertToDODSType().- Parameters:
dtype
- DODS BaseType.- Returns:
- the corresponding netcdf DataType.
- See Also:
isUnsigned(opendap.dap.BaseType)
-
isUnsigned
public static boolean isUnsigned(BaseType dtype)
Get whether this is an unsigned type.- Parameters:
dtype
- DODS BaseType.- Returns:
- true if unsigned
-
readSection
public Array readSection(String variableSection) throws IOException, InvalidRangeException
Description copied from class:NetcdfFile
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.- Overrides:
readSection
in classNetcdfFile
- Parameters:
variableSection
- the constraint expression.- Returns:
- data requested
- Throws:
IOException
- if errorInvalidRangeException
- if variableSection is invalid- See Also:
- SectionSpecification
-
readData
protected Array readData(Variable v, Section section) throws IOException, InvalidRangeException
Description copied from class:NetcdfFile
Do not call this directly, use Variable.read() !! Ranges must be filled (no nulls)- Overrides:
readData
in classNetcdfFile
- Throws:
IOException
InvalidRangeException
-
readToByteChannel
public long readToByteChannel(Variable v, Section section, WritableByteChannel channel) throws IOException, InvalidRangeException
Description copied from class:NetcdfFile
Read data from a top level Variable and send data to a WritableByteChannel. Experimental.- Overrides:
readToByteChannel
in classNetcdfFile
- Parameters:
v
- a top-level Variablesection
- the section of data to read. There must be a Range for each Dimension in the variable, in order. Note: no nulls allowed. IOSP may not modify.channel
- write data to this WritableByteChannel- Returns:
- the number of bytes written to the channel
- Throws:
IOException
- if read errorInvalidRangeException
- if invalid section
-
readWithCE
public Array readWithCE(Variable v, String CE) throws IOException
- Throws:
IOException
-
getDetailInfo
public void getDetailInfo(Formatter f)
- Overrides:
getDetailInfo
in classNetcdfFile
-
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"
-
-