Class NetCDFUtilities
Object
NetCDFUtilities
Set of NetCDF utility methods.
- Author:
- Alessio Fabiani, GeoSolutions SAS, Daniele Romagnoli, GeoSolutions SAS, Simone Giannecchini, GeoSolutions SAS
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Global attribute for coordinate coverageDescriptorsCache.static enum
static enum
static enum
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
static final String
static final String
static final String
static final String
static final String
static final boolean
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final double
static final Set<NetcdfDataset.Enhance>
static final String
static final String
static final String
static final String
static final String
static final String
static boolean
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Default parameter behavior properties TODO: better way of handling configuration settings, such as read parameters.static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final long
static final String
static final String
static final String
static final String
static final Boolean
When true, the stack trace that created a reader that wasn't closed is recorded and then printed out when warning the user about this.static final String
static final String
static final String
static final String
static final String
protected static final Map<URI,
NetCDFUtilities.FileFormat> static final TimeZone
static final String
static final String
static final String
static final Set<DataType>
The data type to accept in images.static final String
static final String
static final int
The dimension relative to the rank in#variable
to use as image width.static final String
static final String
static final String
static final int
The dimension relative to the rank in#variable
to use as image height.static final String
static final int
The default dimension relative to the rank in#variable
to use as Z dimension.static final String
-
Method Summary
Modifier and TypeMethodDescriptionstatic NetcdfDataset
acquireDataset
(URI uri) static NetcdfDataset
static void
addIgnoredDimension
(String dimensionName) Adds a dimension to the ignored dimensions set.static void
Clear all the internal caches.static SimpleFeatureType
createFeatureType
(String schemaName, String schemaDef, CoordinateReferenceSystem crs) static void
static void
static Array
getArray
(int[] dimensions, DataType varDataType) Get an Array of proper size and type.static Format
getAxisFormat
(AxisType type, String prototype) Returns a format to use for parsing values along the specified axis type.static NetCDFUtilities.CheckType
getCheckType
(NetcdfDataset dataset) Depending on the type of model/netcdf file, we will check for the presence of some coverageDescriptorsCache rather than some others.static NetcdfDataset
getDataset
(Object input) Returns aNetcdfDataset
given an input object the input object (usually aFile
, aString
or a {@code FileImageInputStreamExt). @return {@code NetcdfDataset} in case of success. if some error occur while opening the dataset. @throws {@link IllegalArgumentException} in case the specified input is a directorystatic DatasetUrl
getDatasetUrl
(String uriString) static int
getDimensionLength
(Variable var, int dimensionIndex) static File
Checks if the input is file based, and if yes, returns the file.static NetCDFUtilities.FileFormat
static DataType
getNetCDFDataType
(String classDataType) Return the propery NetCDF dataType for the input datatype classstatic FileCacheIF
static Number
getNodata
(Variable var) Utility method for getting NoData from an inputVariable
getParameterBehaviour
(String parameter) static FileCacheIF
static NumberRange
getRange
(Variable var) Utility method for getting Range from an inputVariable
static int
getRawDataType
(VariableSimpleIF variable) Returns the data type which most closely represents the "raw" internal data of the variable.static int
getZDimensionLength
(Variable var) Get Z Dimension Lenght for standard CF variablesstatic final boolean
Return true in case that dataType refers to something which need to be handled as a Time (TimeStamp, Date)static boolean
static boolean
static boolean
static boolean
static boolean
isVariableAccepted
(String name, NetCDFUtilities.CheckType checkType) NetCDF files may contain a wide set of coverageDescriptorsCache.static boolean
isVariableAccepted
(Variable var, NetCDFUtilities.CheckType checkType) NetCDF files may contains a wide set of coverageDescriptorsCache.static boolean
isVariableAccepted
(Variable var, NetCDFUtilities.CheckType checkType, NetcdfDataset dataset) NetCDF files may contains a wide set of coverageDescriptorsCache.static void
static DataType
transcodeImageDataType
(int dataType) Transcode a DataBuffer type into a NetCDF DataType .static int
transcodeNetCDFDataType
(DataType type, boolean unsigned) Transcode a NetCDF data type into a java2D DataBuffer type.static Number
transcodeNumber
(DataType type, Number value) Transcode a NetCDF Number into a proper Number instance.static boolean
useCache()
static boolean
-
Field Details
-
CHECK_COORDINATE_PLUGINS
public static final boolean CHECK_COORDINATE_PLUGINS -
CHECK_COORDINATE_PLUGINS_KEY
- See Also:
-
NETCDF4_MIMETYPE
- See Also:
-
NETCDF3_MIMETYPE
- See Also:
-
NETCDF
- See Also:
-
NETCDF4
- See Also:
-
NETCDF_4C
- See Also:
-
NETCDF_3
- See Also:
-
STANDARD_PARALLEL_1
-
STANDARD_PARALLEL_2
-
CENTRAL_MERIDIAN
-
LATITUDE_OF_ORIGIN
-
SCALE_FACTOR
-
FALSE_EASTING
-
FALSE_NORTHING
-
SEMI_MINOR
-
SEMI_MAJOR
-
INVERSE_FLATTENING
- See Also:
-
UNKNOWN
- See Also:
-
DEFAULT_EARTH_RADIUS
public static final double DEFAULT_EARTH_RADIUS- See Also:
-
TRACE_ENABLED
When true, the stack trace that created a reader that wasn't closed is recorded and then printed out when warning the user about this. -
DEFAULT_ENHANCE_MODE
-
EXTERNAL_DATA_DIR
-
NETCDF_DATA_DIR
- See Also:
-
NETCDF_DATA_DIR_TREE
- See Also:
-
NETCDF_ROOT
- See Also:
-
FILL_VALUE
- See Also:
-
MISSING_VALUE
- See Also:
-
ACTUAL_RANGE
- See Also:
-
VALID_RANGE
- See Also:
-
VALID_MIN
- See Also:
-
VALID_MAX
- See Also:
-
LOWER_LEFT_LONGITUDE
- See Also:
-
LOWER_LEFT_LATITUDE
- See Also:
-
UPPER_RIGHT_LONGITUDE
- See Also:
-
UPPER_RIGHT_LATITUDE
- See Also:
-
COORDSYS
- See Also:
-
Y
- See Also:
-
Y_COORD_PROJ
- See Also:
-
Y_PROJ_COORD
- See Also:
-
X
- See Also:
-
X_COORD_PROJ
- See Also:
-
X_PROJ_COORD
- See Also:
-
LATITUDE
- See Also:
-
LAT
- See Also:
-
LONGITUDE
- See Also:
-
LON
- See Also:
-
GRID_LATITUDE
- See Also:
-
RLAT
- See Also:
-
GRID_LONGITUDE
- See Also:
-
RLON
- See Also:
-
DEPTH
- See Also:
-
ZETA
- See Also:
-
BOUNDS
- See Also:
-
HEIGHT
- See Also:
-
TIME
- See Also:
-
POSITIVE
- See Also:
-
UNITS
- See Also:
-
NAME
- See Also:
-
LONG_NAME
- See Also:
-
ELEVATION_DIM
-
TIME_DIM
-
STANDARD_NAME
- See Also:
-
DESCRIPTION
- See Also:
-
M
- See Also:
-
BOUNDS_SUFFIX
- See Also:
-
LON_UNITS
- See Also:
-
LAT_UNITS
- See Also:
-
RLATLON_UNITS
- See Also:
-
NO_COORDS
- See Also:
-
TIME_ORIGIN
- See Also:
-
START_TIME
public static final long START_TIME -
BOUNDARY_DIMENSION
- See Also:
-
UTC
-
GRID_MAPPING
- See Also:
-
GRID_MAPPING_NAME
- See Also:
-
COORDINATE_AXIS_TYPE
- See Also:
-
CONVENTIONS
- See Also:
-
COORD_SYS_BUILDER
- See Also:
-
COORD_SYS_BUILDER_CONVENTION
- See Also:
-
COORDINATE_TRANSFORM_TYPE
- See Also:
-
COORDINATES
- See Also:
-
SPATIAL_REF
- See Also:
-
GEO_TRANSFORM
- See Also:
-
CERP_ESRI_PE_STRING
- See Also:
-
UNIQUE_TIME_ATTRIBUTE
- See Also:
-
ENHANCE_COORD_SYSTEMS
- See Also:
-
ENHANCE_SCALE_MISSING
- See Also:
-
ENHANCE_CONVERT_ENUMS
- See Also:
-
ENHANCE_SCALE_OFFSET
public static boolean ENHANCE_SCALE_OFFSET -
STORE_NAME
- See Also:
-
URI_FORMAT_CACHE
-
DATASET_URL_CACHE
-
X_DIMENSION
public static final int X_DIMENSIONThe dimension relative to the rank in#variable
to use as image width. The actual dimension isvariable.getRank() - X_DIMENSION
. Is hard-coded because the loop in theread
method expects this order.- See Also:
-
Y_DIMENSION
public static final int Y_DIMENSIONThe dimension relative to the rank in#variable
to use as image height. The actual dimension isvariable.getRank() - Y_DIMENSION
. Is hard-coded because the loop in theread
method expects this order.- See Also:
-
Z_DIMENSION
public static final int Z_DIMENSIONThe default dimension relative to the rank in#variable
to use as Z dimension. The actual dimension isvariable.getRank() - Z_DIMENSION
.- See Also:
-
VALID_TYPES
The data type to accept in images. Used for automatic detection of which coverageDescriptorsCache to assign to images. -
NC4_ERROR_MESSAGE
- See Also:
-
PARAMS_MAX_KEY
Default parameter behavior properties TODO: better way of handling configuration settings, such as read parameters.- See Also:
-
PARAMS_MIN_KEY
- See Also:
-
-
Method Details
-
useMemoryMapping
public static boolean useMemoryMapping() -
useCache
public static boolean useCache() -
getZDimensionLength
public static int getZDimensionLength(Variable var) Get Z Dimension Lenght for standard CF variables -
getDimensionLength
public static int getDimensionLength(Variable var, int dimensionIndex) -
getRawDataType
public static int getRawDataType(VariableSimpleIF variable) Returns the data type which most closely represents the "raw" internal data of the variable. This is the value returned by the default implementation ofNetcdfImageReader#getRawDataType
.- Parameters:
variable
- The variable.- Returns:
- The data type, or
DataBuffer.TYPE_UNDEFINED
if unknown. - See Also:
-
NetcdfImageReader#getRawDataType
-
transcodeNetCDFDataType
public static int transcodeNetCDFDataType(DataType type, boolean unsigned) Transcode a NetCDF data type into a java2D DataBuffer type.- Parameters:
type
- theDataType
to transcode.unsigned
- if the original data is unsigned or not- Returns:
- an int representing the correct DataBuffer type.
-
isVariableAccepted
NetCDF files may contains a wide set of coverageDescriptorsCache. Some of them are unuseful for our purposes. The method returnstrue
if the specified variable is accepted. -
isVariableAccepted
public static boolean isVariableAccepted(Variable var, NetCDFUtilities.CheckType checkType, NetcdfDataset dataset) NetCDF files may contains a wide set of coverageDescriptorsCache. Some of them are unuseful for our purposes. The method returnstrue
if the specified variable is accepted. -
isVariableAccepted
NetCDF files may contain a wide set of coverageDescriptorsCache. Some of them are unuseful for our purposes. The method returnstrue
if the specified variable is accepted. -
getFormat
- Throws:
IOException
-
getDatasetUrl
- Throws:
IOException
-
isFile
-
acquireFeatureCollection
- Throws:
IOException
-
acquireDataset
- Throws:
IOException
-
getDataset
Returns aNetcdfDataset
given an input object the input object (usually aFile
, aString
or a {@code FileImageInputStreamExt). @return {@code NetcdfDataset} in case of success. if some error occur while opening the dataset. @throws {@link IllegalArgumentException} in case the specified input is a directory- Throws:
IOException
-
getFile
Checks if the input is file based, and if yes, returns the file.- Parameters:
input
- the input to check.- Returns:
- the file or
null
if it is not file based. - Throws:
IOException
-
getAxisFormat
Returns a format to use for parsing values along the specified axis type. This method is invoked when parsing the date part of axis units like "days since 1990-01-01 00:00:00". Subclasses should override this method if the date part is formatted in a different way. The default implementation returns the following formats:- For time axis, a
DateFormat
using the"yyyy-MM-dd HH:mm:ss"
pattern in UTC timezone. - For all other kind of axis, a
NumberFormat
.
The English locale is used by default for most formats because it is relatively close to ISO (for example regarding days and months order in dates) while using the English symbols.
- Parameters:
type
- The type of the axis.prototype
- An example of the values to be parsed. Implementations may parse this prototype when the axis type alone is not sufficient. For example the time axis type should uses the"yyyy-MM-dd"
date pattern, but some files do not follow this convention and use the default local instead.- Returns:
- The format for parsing values along the axis.
- For time axis, a
-
getCheckType
Depending on the type of model/netcdf file, we will check for the presence of some coverageDescriptorsCache rather than some others. The method returns the type of check on which we need to leverage to restrict the set of interesting coverageDescriptorsCache. The method will check for some KEY/FLAGS/ATTRIBUTES within the input dataset in order to define the proper check type to be performed.- Parameters:
dataset
- the input dataset.- Returns:
- the proper
NetCDFUtilities.CheckType
to be performed on the specified dataset.
-
createFeatureType
public static SimpleFeatureType createFeatureType(String schemaName, String schemaDef, CoordinateReferenceSystem crs) -
isGribAvailable
public static boolean isGribAvailable()- Returns:
- true if the GRIB library is available
-
isNC4CAvailable
public static boolean isNC4CAvailable()- Returns:
- true if the C Native NetCDF 4 library is available
-
isCheckCoordinatePlugins
public static boolean isCheckCoordinatePlugins() -
getUnsupportedDimensions
- Returns:
- An unmodifiable Set of Unsupported Dimension names
-
getIgnoredDimensions
- Returns:
- an unmodifiable Set of the Dimensions to be ignored by the Coordinate parsing machinery
-
addIgnoredDimension
Adds a dimension to the ignored dimensions set. -
getNodata
Utility method for getting NoData from an inputVariable
- Parameters:
var
- Variable instance- Returns:
- a Number representing NoData
-
getRange
Utility method for getting Range from an inputVariable
- Parameters:
var
- Variable instance- Returns:
- a Range representing actual_range or valid_min/valid_max range or valid_range
-
getNetCDFDataType
Return the propery NetCDF dataType for the input datatype class -
transcodeImageDataType
public static DataType transcodeImageDataType(int dataType) Transcode a DataBuffer type into a NetCDF DataType .- Parameters:
dataType
- the beamProductData
type to transcode.- Returns:
- an NetCDF DataType type.
-
isATime
Return true in case that dataType refers to something which need to be handled as a Time (TimeStamp, Date) -
getArray
public static Array getArray(int[] dimensions, DataType varDataType) Get an Array of proper size and type.- Parameters:
dimensions
- the dimensionsvarDataType
- the DataType of the required array
-
transcodeNumber
Transcode a NetCDF Number into a proper Number instance.- Parameters:
type
- theDataType
to transcode.- Returns:
- the proper number instance
-
refreshParameterBehaviors
public static void refreshParameterBehaviors() -
getParameterBehaviour
-
disableNetCDFFileCaches
public static void disableNetCDFFileCaches() -
enableNetCDFFileCaches
public static void enableNetCDFFileCaches() -
clearCaches
public static void clearCaches()Clear all the internal caches. Call this method if the datastore config has been updated or the NetCDF XML file has been modified. -
getRafFileCache
public static FileCacheIF getRafFileCache() -
getNetCDFFileCache
public static FileCacheIF getNetCDFFileCache()
-