ucar.nc2.dataset
Class VariableDS

java.lang.Object
  extended by ucar.nc2.Variable
      extended by ucar.nc2.dataset.VariableDS
All Implemented Interfaces:
java.lang.Comparable, Enhancements, EnhanceScaleMissing, VariableEnhanced, VariableIF, VariableSimpleIF
Direct Known Subclasses:
AddeVariable, CoordinateAxis

public class VariableDS
extends Variable
implements VariableEnhanced

An "enhanced" Variable.

Version:
$Revision: 51 $ $Date: 2006-07-12 17:13:13Z $
Author:
John Caron

Nested Class Summary
 
Nested classes/interfaces inherited from class ucar.nc2.Variable
Variable.Cache
 
Field Summary
 
Fields inherited from class ucar.nc2.Variable
attributes, cache, dataType, debugCaching, defaultSizeToCache, dimensions, elementSize, group, isCoordinateAxis, isMetadata, isSection, isSlice, isVlen, ncfile, orgVar, parent, scalarIndex, sectionRanges, shape, shortName, sizeToCache, sliceDim, sliceRanges
 
Constructor Summary
VariableDS(Group g, Variable ncVar, boolean enhance)
          Wrap the given Variable, making it into an enhanced one.
VariableDS(NetcdfDataset ds, Group group, Structure parentStructure, java.lang.String shortName, DataType dataType, java.lang.String dims, java.lang.String units, java.lang.String desc)
          Constructor when theres no underlying variable.
 
Method Summary
protected  Array _read()
           
protected  Array _read(java.util.List section)
           
protected  Array _readMemberData(java.util.List section, boolean flatten)
           
 void addCoordinateSystem(CoordinateSystem p0)
          Add a CoordinateSystem to the dataset.
 int compareTo(java.lang.Object o)
          Implement Comparable
 double convertScaleOffsetMissing(byte value)
          Convert data if hasScaleOffset, using scale and offset.
 double convertScaleOffsetMissing(double value)
          Convert this double value using scale/offset/missing value if applicable
 double convertScaleOffsetMissing(int value)
          Convert this int value to a double, using scale/offset/missing value if applicable
 double convertScaleOffsetMissing(long value)
          Convert this long value to a double, using scale/offset/missing value if applicable
 double convertScaleOffsetMissing(short value)
          Convert this short value to a double, using scale/offset/missing value if applicable
 void enhance()
          recalc any enhancement info
 java.util.List getCoordinateSystems()
          Get the list of Coordinate Systems for this Variable.
 java.lang.String getDescription()
          Get the description of the Variable.
 DataType getOriginalDataType()
          When this wraps another Variable, get the original Variable's DataType.
 ProxyReader getProxyReader()
          Get the proxy reader, or null.
 java.lang.String getUnitsString()
          Get the Unit String for the Variable.
 java.lang.String getUnitString()
          Deprecated. use getUnitsString()
 double getValidMax()
          return the maximum value in the valid range
 double getValidMin()
          return the minimum value in the valid range
 boolean hasFillValue()
          true if Variable has _FillValue attribute
 boolean hasInvalidData()
          true if Variable has valid_range, valid_min or valid_max attributes
 boolean hasMissing()
          true if Variable has missing data values
 boolean hasMissingValue()
          true if Variable has missing_value attribute
 boolean hasScaleOffset()
          true if Variable data will be converted using scale and offet
 boolean isEnhanced()
          If this Variable has been "enhanced", ie processed for scale/offset/missing value
 boolean isFillValue(double p0)
          return true if val equals the _FillValue
 boolean isInvalidData(double p0)
          return true if val is outside the valid range
 boolean isMissing(double p0)
          true if val is a missing data value
 boolean isMissingValue(double p0)
          return true if val equals a missing_value
 void removeCoordinateSystem(CoordinateSystem p0)
          Remove a CoordinateSystem from the dataset.
 Variable section(java.util.List section)
          Create a new Variable that is a logical subsection of this Variable.
 void setFillValueIsMissing(boolean p0)
          set if _FillValue is considered isMissing(); better set in constructor if possible
 void setInvalidDataIsMissing(boolean p0)
          set if valid_range is considered isMissing(); better set in constructor if possible
 void setMissingDataIsMissing(boolean p0)
          set if missing_data is considered isMissing(); better set in constructor if possible
 void setProxyReader(ProxyReader agg)
          Set the proxy reader.
 void setUnitsString(java.lang.String units)
           
 void setUseNaNs(boolean useNaNs)
          set whether to use NaNs for missing values, for efficiency
 Variable slice(int dim, int value)
          Create a new Variable that is a logical slice of this Variable, by fixing the specified dimension at the specified index value.
 
Methods inherited from class ucar.nc2.Variable
addAttribute, attributes, calcIsCoordinateVariable, equals, extraInfo, findAttribute, findAttributeIgnoreCase, findDimensionIndex, getAttributes, getCoordinateDimension, getDataType, getDimension, getDimensions, getDimensionsAll, getDimensionsString, getElementSize, getIOVar, getName, getNameAndDimensions, getNameAndDimensions, getParentGroup, getParentStructure, getRanges, getRank, getSectionRanges, getShape, getShortName, getSize, getSizeToCache, getSPobject, hasCachedData, hashCode, invalidateCache, isCaching, isMemberOfStructure, isMetadata, isScalar, isSection, isUnknownLength, isUnlimited, isUnsigned, isVariableLength, makeSection, makeSectionAddParents, makeSectionRanges, makeSectionWithParents, makeSlice, makeSliceRanges, read, read, read, read, readAllStructures, readAllStructuresSpec, readScalarByte, readScalarDouble, readScalarFloat, readScalarInt, readScalarLong, readScalarShort, readScalarString, remove, replaceDimension, setCachedData, setCaching, setDataType, setDimension, setDimensions, setDimensions, setDimensionsAnonymous, setElementSize, setIOVar, setIsCoordinateAxis, setName, setParentGroup, setParentStructure, setSizeToCache, setSPobject, toString, toStringDebug, writeCDL
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ucar.nc2.VariableSimpleIF
findAttributeIgnoreCase, getAttributes, getDataType, getDimensions, getName, getRank, getShape, getShortName
 
Methods inherited from interface ucar.nc2.VariableIF
findAttribute, findAttributeIgnoreCase, findDimensionIndex, getAttributes, getCoordinateDimension, getDataType, getDimension, getDimensions, getDimensionsAll, getElementSize, getName, getNameAndDimensions, getParentGroup, getParentStructure, getRanges, getRank, getShape, getShortName, getSize, isMemberOfStructure, isMetadata, isScalar, isUnlimited, isUnsigned, isVariableLength, read, read, read, read, readAllStructures, readAllStructuresSpec, readScalarByte, readScalarDouble, readScalarFloat, readScalarInt, readScalarLong, readScalarShort, readScalarString, toStringDebug
 

Constructor Detail

VariableDS

public VariableDS(NetcdfDataset ds,
                  Group group,
                  Structure parentStructure,
                  java.lang.String shortName,
                  DataType dataType,
                  java.lang.String dims,
                  java.lang.String units,
                  java.lang.String desc)
Constructor when theres no underlying variable.


VariableDS

public VariableDS(Group g,
                  Variable ncVar,
                  boolean enhance)
Wrap the given Variable, making it into an enhanced one.

Parameters:
ncVar - the original Variable to wrap.
Method Detail

section

public Variable section(java.util.List section)
                 throws InvalidRangeException
Description copied from class: Variable
Create a new Variable that is a logical subsection of this Variable. No data is read until a read method is called on it.

Specified by:
section in interface VariableIF
Overrides:
section in class Variable
Parameters:
section - List of type ucar.ma2.Range, with size equal to getRank(). Each Range corresponds to a Dimension, and specifies the section of data to read in that Dimension. A Range object may be null, which means use the entire dimension.
Returns:
a new Variable which is a logical section of this Variable.
Throws:
InvalidRangeException

slice

public Variable slice(int dim,
                      int value)
               throws InvalidRangeException
Description copied from class: Variable
Create a new Variable that is a logical slice of this Variable, by fixing the specified dimension at the specified index value. This reduces rank by 1. No data is read until a read method is called on it.

Overrides:
slice in class Variable
Parameters:
dim - which dimension to fix
value - at what index value
Returns:
a new Variable which is a logical slice of this Variable.
Throws:
InvalidRangeException

enhance

public void enhance()
recalc any enhancement info


addCoordinateSystem

public void addCoordinateSystem(CoordinateSystem p0)
Description copied from interface: Enhancements
Add a CoordinateSystem to the dataset.

Specified by:
addCoordinateSystem in interface Enhancements

removeCoordinateSystem

public void removeCoordinateSystem(CoordinateSystem p0)
Description copied from interface: Enhancements
Remove a CoordinateSystem from the dataset.

Specified by:
removeCoordinateSystem in interface Enhancements

getCoordinateSystems

public java.util.List getCoordinateSystems()
Description copied from interface: Enhancements
Get the list of Coordinate Systems for this Variable.

Specified by:
getCoordinateSystems in interface Enhancements
Returns:
list of type CoordinateSystem; may be empty but not null.

getDescription

public java.lang.String getDescription()
Description copied from class: Variable
Get the description of the Variable. Default is to use "long_name" attribute value. If not exist, look for "description", "title", or "standard_name" attribute value (in that order).

Specified by:
getDescription in interface Enhancements
Specified by:
getDescription in interface VariableSimpleIF
Overrides:
getDescription in class Variable
Returns:
description, or null if not found.

getOriginalDataType

public DataType getOriginalDataType()
When this wraps another Variable, get the original Variable's DataType.


getUnitsString

public java.lang.String getUnitsString()
Description copied from class: Variable
Get the Unit String for the Variable. Default is to use "units" attribute value

Specified by:
getUnitsString in interface Enhancements
Specified by:
getUnitsString in interface VariableSimpleIF
Overrides:
getUnitsString in class Variable
Returns:
unit string, or null if not found.

setUnitsString

public void setUnitsString(java.lang.String units)

getUnitString

public java.lang.String getUnitString()
Deprecated. use getUnitsString()


getValidMax

public double getValidMax()
Description copied from interface: EnhanceScaleMissing
return the maximum value in the valid range

Specified by:
getValidMax in interface EnhanceScaleMissing

getValidMin

public double getValidMin()
Description copied from interface: EnhanceScaleMissing
return the minimum value in the valid range

Specified by:
getValidMin in interface EnhanceScaleMissing

hasFillValue

public boolean hasFillValue()
Description copied from interface: EnhanceScaleMissing
true if Variable has _FillValue attribute

Specified by:
hasFillValue in interface EnhanceScaleMissing

hasInvalidData

public boolean hasInvalidData()
Description copied from interface: EnhanceScaleMissing
true if Variable has valid_range, valid_min or valid_max attributes

Specified by:
hasInvalidData in interface EnhanceScaleMissing

hasMissing

public boolean hasMissing()
Description copied from interface: EnhanceScaleMissing
true if Variable has missing data values

Specified by:
hasMissing in interface EnhanceScaleMissing

hasMissingValue

public boolean hasMissingValue()
Description copied from interface: EnhanceScaleMissing
true if Variable has missing_value attribute

Specified by:
hasMissingValue in interface EnhanceScaleMissing

hasScaleOffset

public boolean hasScaleOffset()
Description copied from interface: EnhanceScaleMissing
true if Variable data will be converted using scale and offet

Specified by:
hasScaleOffset in interface EnhanceScaleMissing

isFillValue

public boolean isFillValue(double p0)
Description copied from interface: EnhanceScaleMissing
return true if val equals the _FillValue

Specified by:
isFillValue in interface EnhanceScaleMissing

isInvalidData

public boolean isInvalidData(double p0)
Description copied from interface: EnhanceScaleMissing
return true if val is outside the valid range

Specified by:
isInvalidData in interface EnhanceScaleMissing

isMissing

public boolean isMissing(double p0)
Description copied from interface: EnhanceScaleMissing
true if val is a missing data value

Specified by:
isMissing in interface EnhanceScaleMissing

isMissingValue

public boolean isMissingValue(double p0)
Description copied from interface: EnhanceScaleMissing
return true if val equals a missing_value

Specified by:
isMissingValue in interface EnhanceScaleMissing

setFillValueIsMissing

public void setFillValueIsMissing(boolean p0)
Description copied from interface: EnhanceScaleMissing
set if _FillValue is considered isMissing(); better set in constructor if possible

Specified by:
setFillValueIsMissing in interface EnhanceScaleMissing

setInvalidDataIsMissing

public void setInvalidDataIsMissing(boolean p0)
Description copied from interface: EnhanceScaleMissing
set if valid_range is considered isMissing(); better set in constructor if possible

Specified by:
setInvalidDataIsMissing in interface EnhanceScaleMissing

setMissingDataIsMissing

public void setMissingDataIsMissing(boolean p0)
Description copied from interface: EnhanceScaleMissing
set if missing_data is considered isMissing(); better set in constructor if possible

Specified by:
setMissingDataIsMissing in interface EnhanceScaleMissing

setUseNaNs

public void setUseNaNs(boolean useNaNs)
Description copied from interface: EnhanceScaleMissing
set whether to use NaNs for missing values, for efficiency

Specified by:
setUseNaNs in interface EnhanceScaleMissing

setProxyReader

public void setProxyReader(ProxyReader agg)
Set the proxy reader.


getProxyReader

public ProxyReader getProxyReader()
Get the proxy reader, or null.


isEnhanced

public boolean isEnhanced()
If this Variable has been "enhanced", ie processed for scale/offset/missing value


convertScaleOffsetMissing

public double convertScaleOffsetMissing(byte value)
Convert data if hasScaleOffset, using scale and offset. Also if useNaNs = true, return NaN if value is missing data.

Specified by:
convertScaleOffsetMissing in interface EnhanceScaleMissing
Specified by:
convertScaleOffsetMissing in interface VariableSimpleIF
Parameters:
value - data to convert
Returns:
converted data.

convertScaleOffsetMissing

public double convertScaleOffsetMissing(short value)
Description copied from interface: EnhanceScaleMissing
Convert this short value to a double, using scale/offset/missing value if applicable

Specified by:
convertScaleOffsetMissing in interface EnhanceScaleMissing
Specified by:
convertScaleOffsetMissing in interface VariableSimpleIF

convertScaleOffsetMissing

public double convertScaleOffsetMissing(int value)
Description copied from interface: EnhanceScaleMissing
Convert this int value to a double, using scale/offset/missing value if applicable

Specified by:
convertScaleOffsetMissing in interface EnhanceScaleMissing
Specified by:
convertScaleOffsetMissing in interface VariableSimpleIF

convertScaleOffsetMissing

public double convertScaleOffsetMissing(long value)
Description copied from interface: EnhanceScaleMissing
Convert this long value to a double, using scale/offset/missing value if applicable

Specified by:
convertScaleOffsetMissing in interface EnhanceScaleMissing
Specified by:
convertScaleOffsetMissing in interface VariableSimpleIF

convertScaleOffsetMissing

public double convertScaleOffsetMissing(double value)
Description copied from interface: EnhanceScaleMissing
Convert this double value using scale/offset/missing value if applicable

Specified by:
convertScaleOffsetMissing in interface EnhanceScaleMissing
Specified by:
convertScaleOffsetMissing in interface VariableSimpleIF

_read

protected Array _read()
               throws java.io.IOException
Overrides:
_read in class Variable
Throws:
java.io.IOException

_read

protected Array _read(java.util.List section)
               throws java.io.IOException,
                      InvalidRangeException
Overrides:
_read in class Variable
Throws:
java.io.IOException
InvalidRangeException

_readMemberData

protected Array _readMemberData(java.util.List section,
                                boolean flatten)
                         throws java.io.IOException,
                                InvalidRangeException
Overrides:
_readMemberData in class Variable
Throws:
java.io.IOException
InvalidRangeException

compareTo

public int compareTo(java.lang.Object o)
Implement Comparable

Specified by:
compareTo in interface java.lang.Comparable