it.geosolutions.imageio.plugins.netcdf
Class NetCDFUtilities

Object
  extended by NetCDFUtilities

public class NetCDFUtilities
extends Object

Set of NetCDF utility methods.

Author:
Alessio Fabiani, GeoSolutions, Daniele Romagnoli, GeoSolutions

Nested Class Summary
static class NetCDFUtilities.CheckType
           
static class NetCDFUtilities.DatasetAttribs
           
static class NetCDFUtilities.KeyValuePair
           
static class NetCDFUtilities.ProjAttribs
           
 
Field Summary
static String COORDINATE_AXIS_TYPE
           
static String COORDSYS
           
static String DEPTH
           
static String HEIGHT
           
static String LAT
           
static String LATITUDE
           
static String LON
           
static String LONG_NAME
           
static String LONGITUDE
           
static String LOWER_LEFT_LATITUDE
           
static String LOWER_LEFT_LONGITUDE
           
static String NAME
           
static String POSITIVE
           
static String TIME
           
static String UNITS
           
static String UPPER_RIGHT_LATITUDE
           
static String UPPER_RIGHT_LONGITUDE
           
static Set<DataType> VALID_TYPES
          The data type to accept in images.
static int X_DIMENSION
          The dimension relative to the rank in #variable to use as image width.
static int Y_DIMENSION
          The dimension relative to the rank in #variable to use as image height.
static int Z_DIMENSION
          The default dimension relative to the rank in #variable to use as Z dimension.
static String ZETA
           
 
Method Summary
static NetCDFUtilities.KeyValuePair getAttribute(Variable var, int attributeIndex)
           
static Number getAttributesAsNumber(Variable var, String attributeName)
           
static String getAttributesAsString(Attribute attr)
           
static String getAttributesAsString(Attribute attr, boolean isUnsigned)
          Return the value of a NetCDF Attribute instance as a String.
static String getAttributesAsString(Variable var, String attributeName)
           
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 variables rather than some others.
static NetcdfDataset getDataset(Object input)
          Returns a NetcdfDataset given an input object
static NetCDFUtilities.KeyValuePair getGlobalAttribute(NetcdfDataset dataset, int attributeIndex)
           
static String getGlobalAttributeAsString(NetcdfDataset dataset, String attributeName)
          Return a global attribute as a String.
static int getRawDataType(VariableIF variable)
          Returns the data type which most closely represents the "raw" internal data of the variable.
static int getTIndex(Variable var, Range range, int imageIndex)
          Utility method to retrieve the t-index of a Variable descriptor stored on NetCDFImageReader NetCDF Flat Reader HashMap indexMap.
static int getZIndex(Variable var, Range range, int imageIndex)
          Utility method to retrieve the z-index of a Variable descriptor stored on NetCDFImageReader NetCDF Flat Reader HashMap indexMap.
static boolean isVariableAccepted(Variable var, NetCDFUtilities.CheckType checkType)
          NetCDF files may contains a wide set of variables.
static String trimFractionalPart(String value)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOWER_LEFT_LONGITUDE

public static final String LOWER_LEFT_LONGITUDE
See Also:
Constant Field Values

LOWER_LEFT_LATITUDE

public static final String LOWER_LEFT_LATITUDE
See Also:
Constant Field Values

UPPER_RIGHT_LONGITUDE

public static final String UPPER_RIGHT_LONGITUDE
See Also:
Constant Field Values

UPPER_RIGHT_LATITUDE

public static final String UPPER_RIGHT_LATITUDE
See Also:
Constant Field Values

COORDSYS

public static final String COORDSYS
See Also:
Constant Field Values

LATITUDE

public static final String LATITUDE
See Also:
Constant Field Values

LAT

public static final String LAT
See Also:
Constant Field Values

LONGITUDE

public static final String LONGITUDE
See Also:
Constant Field Values

LON

public static final String LON
See Also:
Constant Field Values

DEPTH

public static final String DEPTH
See Also:
Constant Field Values

ZETA

public static final String ZETA
See Also:
Constant Field Values

HEIGHT

public static final String HEIGHT
See Also:
Constant Field Values

TIME

public static final String TIME
See Also:
Constant Field Values

COORDINATE_AXIS_TYPE

public static final String COORDINATE_AXIS_TYPE
See Also:
Constant Field Values

POSITIVE

public static final String POSITIVE
See Also:
Constant Field Values

UNITS

public static final String UNITS
See Also:
Constant Field Values

NAME

public static final String NAME
See Also:
Constant Field Values

LONG_NAME

public static final String LONG_NAME
See Also:
Constant Field Values

X_DIMENSION

public static final int X_DIMENSION
The dimension relative to the rank in #variable to use as image width. The actual dimension is variable.getRank() - X_DIMENSION. Is hard-coded because the loop in the read method expects this order.

See Also:
Constant Field Values

Y_DIMENSION

public static final int Y_DIMENSION
The dimension relative to the rank in #variable to use as image height. The actual dimension is variable.getRank() - Y_DIMENSION. Is hard-coded because the loop in the read method expects this order.

See Also:
Constant Field Values

Z_DIMENSION

public static final int Z_DIMENSION
The default dimension relative to the rank in #variable to use as Z dimension. The actual dimension is variable.getRank() - Z_DIMENSION.

See Also:
Constant Field Values

VALID_TYPES

public static final Set<DataType> VALID_TYPES
The data type to accept in images. Used for automatic detection of which variables to assign to images.

Method Detail

getTIndex

public static int getTIndex(Variable var,
                            Range range,
                            int imageIndex)
Utility method to retrieve the t-index of a Variable descriptor stored on NetCDFImageReader NetCDF Flat Reader HashMap indexMap.

Parameters:
var - Variable
range - Range
imageIndex - int
Returns:
t-index int -1 if variable rank > 4

getZIndex

public static int getZIndex(Variable var,
                            Range range,
                            int imageIndex)
Utility method to retrieve the z-index of a Variable descriptor stored on NetCDFImageReader NetCDF Flat Reader HashMap indexMap.

Parameters:
var - Variable
range - Range
imageIndex - int
Returns:
z-index int -1 if variable rank < 3

getRawDataType

public static int getRawDataType(VariableIF 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 of NetcdfImageReader#getRawDataType.

Parameters:
variable - The variable.
Returns:
The data type, or DataBuffer.TYPE_UNDEFINED if unknown.
See Also:
NetcdfImageReader#getRawDataType

getAttributesAsString

public static String getAttributesAsString(Attribute attr)

getAttributesAsString

public static String getAttributesAsString(Variable var,
                                           String attributeName)

getAttributesAsNumber

public static Number getAttributesAsNumber(Variable var,
                                           String attributeName)

getAttributesAsString

public static String getAttributesAsString(Attribute attr,
                                           boolean isUnsigned)
Return the value of a NetCDF Attribute instance as a String. The isUnsigned parameter allow to handle byte attributes as unsigned, in order to represent values in the range [0,255].


isVariableAccepted

public static boolean isVariableAccepted(Variable var,
                                         NetCDFUtilities.CheckType checkType)
NetCDF files may contains a wide set of variables. Some of them are unuseful for our purposes. The method returns true if the specified variable is accepted.


trimFractionalPart

public static String trimFractionalPart(String value)
Parameters:
value -
Returns:

getDataset

public static NetcdfDataset getDataset(Object input)
                                throws IOException
Returns a NetcdfDataset given an input object

Parameters:
input - the input object (usually a File, a String or a {@code FileImageInputStreamExt).
Returns:
NetcdfDataset in case of success.
Throws:
IOException - if some error occur while opening the dataset.
{@link - IllegalArgumentException} in case the specified input is a directory

getAxisFormat

public static Format getAxisFormat(AxisType type,
                                   String prototype)
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:

The Canada 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.

getCheckType

public static NetCDFUtilities.CheckType getCheckType(NetcdfDataset dataset)
Depending on the type of model/netcdf file, we will check for the presence of some variables rather than some others. The method returns the type of check on which we need to leverage to restrict the set of interesting variables. 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.

getGlobalAttributeAsString

public static String getGlobalAttributeAsString(NetcdfDataset dataset,
                                                String attributeName)
Return a global attribute as a String. The required global attribute is specified by name

Parameters:
attributeName - the name of the required attribute.
Returns:
the value of the required attribute. Returns an empty String in case the required attribute is not found.

getGlobalAttribute

public static NetCDFUtilities.KeyValuePair getGlobalAttribute(NetcdfDataset dataset,
                                                              int attributeIndex)
                                                       throws IOException
Throws:
IOException

getAttribute

public static NetCDFUtilities.KeyValuePair getAttribute(Variable var,
                                                        int attributeIndex)


Copyright © 2006-2010 GeoSolutions. All Rights Reserved.