visad
Class GriddedSet

java.lang.Object
  extended by visad.ThingImpl
      extended by visad.DataImpl
          extended by visad.Set
              extended by visad.SimpleSet
                  extended by visad.SampledSet
                      extended by visad.GriddedSet
All Implemented Interfaces:
Serializable, Cloneable, Data, GriddedSetIface, SampledSetIface, SetIface, SimpleSetIface, Thing
Direct Known Subclasses:
Gridded1DSet, Gridded2DSet, Gridded3DSet, LinearNDSet

public class GriddedSet
extends SampledSet
implements GriddedSetIface

GriddedSet is implemented by those Set sub-classes whose samples lie on a rectangular grid topology (but note the geometry need not be rectangular). It is a M-dimensional array of points in R^N where ManifoldDimension = M <= N = DomainDimension.

The order of the samples is the rasterization of the orders of the 1D components, with the first component increasing fastest. For more detail, see the example in Linear2DSet.java.

Grid coordinates are zero-based and in the range -0.5 to length-0.5 i.e., there are "length" intervals of length 1.0, the first centered on 0.0 and the last centered on length-1.0 points outside this range are indicated by the grid coordinate Double.NaN.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class visad.DataImpl
DataImpl.Syncher
 
Field Summary
 
Fields inherited from interface visad.Data
ABS, ACOS, ACOS_DEGREES, ADD, ASIN, ASIN_DEGREES, ATAN, ATAN_DEGREES, ATAN2, ATAN2_DEGREES, CEIL, COS, COS_DEGREES, DEGREES_TO_RADIANS, DEPENDENT, DIVIDE, EXP, FLOOR, INDEPENDENT, INV_ATAN2, INV_ATAN2_DEGREES, INV_DIVIDE, INV_POW, INV_REMAINDER, INV_SUBTRACT, LOG, MAX, MIN, MULTIPLY, NEAREST_NEIGHBOR, NEGATE, NO_ERRORS, NOP, POW, RADIANS_TO_DEGREES, REMAINDER, RINT, ROUND, SIN, SIN_DEGREES, SQRT, SUBTRACT, TAN, TAN_DEGREES, WEIGHTED_AVERAGE
 
Constructor Summary
GriddedSet(MathType type, float[][] samples, int[] lengths)
          construct a GriddedSet with samples
GriddedSet(MathType type, float[][] samples, int[] lengths, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors)
          construct a GriddedSet with samples and non-default CoordinateSystem
GriddedSet(MathType type, float[][] samples, int[] lengths, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors, boolean copy)
           
 
Method Summary
 Object cloneButType(MathType type)
          copy this Set, but give it a new MathType; this is safe, since constructor checks consistency of DomainCoordinateSystem and SetUnits with Type
static GriddedSet create(MathType type, float[][] samples, int[] lengths)
          Abreviated Factory method for creating the proper gridded set (Gridded1DSet, Gridded2DSet, etc.).
static GriddedSet create(MathType type, float[][] samples, int[] lengths, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors)
          General Factory method for creating the proper gridded set (Gridded1DSet, Gridded2DSet, etc.).
static GriddedSet create(MathType type, float[][] samples, int[] lengths, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors, boolean copy)
          General Factory method for creating the proper gridded set (Gridded1DSet, Gridded2DSet, etc.).
static GriddedSet create(MathType type, float[][] samples, int[] lengths, CoordinateSystem coord_sys, Unit[] units, ErrorEstimate[] errors, boolean copy, boolean test)
          General Factory method for creating the proper gridded set (Gridded1DSet, Gridded2DSet, etc.).
 boolean equals(Object set)
          test for equality
 int getLength(int i)
          Returns the number of grid points in a given dimension.
 int[] getLengths()
          Returns the number of grid points in all dimensions.
 int[][] getNeighbors(int manifoldIndex)
          Returns the indexes of the neighboring points along a manifold dimesion for every point in the set.
 void getNeighbors(int[][] neighbors)
          Returns the indexes of the neighboring points for every point in the set.
 int[] getWedge()
          returns a zig-zagging ennumeration of index values with good coherence
 float[][] gridToValue(float[][] grid)
          transform an array of non-integer grid coordinates to an array of values in R^DomainDimension
 int hashCode()
          Returns the hash code of this instance.
 float[][] indexToValue(int[] index)
          convert an array of 1-D indices to an array of values in R^DomainDimension
 String longString(String pre)
           
 Set makeSpatial(SetType type, float[][] samples)
           
 float[][] valueToGrid(float[][] value)
          transform an array of values in R^DomainDimension to an array of non-integer grid coordinates
 int[] valueToIndex(float[][] value)
          convert an array of values in R^DomainDimension to an array of 1-D indices
 void valueToInterp(float[][] value, int[][] indices, float[][] weights)
          for each of an array of values in R^DomainDimension, compute an array of 1-D indices and an array of weights, to be used for interpolation; indices[i] and weights[i] are null if i-th value is outside grid (i.e., if no interpolation is possible)
 
Methods inherited from class visad.SampledSet
clone, computeRanges, computeRanges, cram_missing, finalize, getHi, getLow, getMySamples, getNeighbors, getSamples, getSamples, isMissing, make1DGeometry, make3DGeometry, makePointGeometry, setCacheSizeThreshold, setGeometryArray, setGeometryArray, setMySamples
 
Methods inherited from class visad.SimpleSet
getManifoldDimension
 
Methods inherited from class visad.Set
__getitem__, __len__, addEqualsCache, addNotEqualsCache, copyDoubles, copyFloats, doubleToFloat, doubleToIndex, equalUnitAndCS, floatToDouble, getCoordinateSystem, getDimension, getDoubles, getDoubles, getLength, getSetErrors, getSetUnits, indexToDouble, longString, main, make2DGeometry, makeIsoLines, makeIsoSurface, merge1DSets, testEqualsCache, testNotEqualsCache, unary, unitAndCSHashCode
 
Methods inherited from class visad.DataImpl
__add__, __add__, __div__, __div__, __mod__, __mod__, __mul__, __mul__, __neg__, __pow__, __pow__, __radd__, __rdiv__, __rmod__, __rmul__, __rpow__, __rsub__, __sub__, __sub__, abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, adjustSamplingError, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, binary, binary, ceil, ceil, changeMathType, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, local, log, log, max, max, min, min, multiply, multiply, negate, negate, notifyReferences, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees, toString, unary
 
Methods inherited from class visad.ThingImpl
addReference, removeReference
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface visad.SampledSetIface
getHi, getLow
 
Methods inherited from interface visad.SetIface
cram_missing, doubleToIndex, equalUnitAndCS, getCoordinateSystem, getDimension, getDoubles, getDoubles, getLength, getManifoldDimension, getNeighbors, getSamples, getSamples, getSetErrors, getSetUnits, indexToDouble, make1DGeometry, make2DGeometry, make3DGeometry, makeIsoLines, makeIsoSurface, makePointGeometry, merge1DSets
 
Methods inherited from interface visad.Data
abs, abs, acos, acos, acosDegrees, acosDegrees, add, add, adjustSamplingError, asin, asin, asinDegrees, asinDegrees, atan, atan, atan2, atan2, atan2Degrees, atan2Degrees, atanDegrees, atanDegrees, binary, binary, ceil, ceil, changeMathType, computeRanges, computeRanges, computeRanges, cos, cos, cosDegrees, cosDegrees, dataClone, divide, divide, exp, exp, floor, floor, getType, isMissing, local, log, log, longString, max, max, min, min, multiply, multiply, negate, negate, pow, pow, remainder, remainder, rint, rint, round, round, sin, sin, sinDegrees, sinDegrees, sqrt, sqrt, subtract, subtract, tan, tan, tanDegrees, tanDegrees, unary, unary
 
Methods inherited from interface visad.Thing
addReference, removeReference
 

Constructor Detail

GriddedSet

public GriddedSet(MathType type,
                  float[][] samples,
                  int[] lengths)
           throws VisADException
construct a GriddedSet with samples

Throws:
VisADException

GriddedSet

public GriddedSet(MathType type,
                  float[][] samples,
                  int[] lengths,
                  CoordinateSystem coord_sys,
                  Unit[] units,
                  ErrorEstimate[] errors)
           throws VisADException
construct a GriddedSet with samples and non-default CoordinateSystem

Throws:
VisADException

GriddedSet

public GriddedSet(MathType type,
                  float[][] samples,
                  int[] lengths,
                  CoordinateSystem coord_sys,
                  Unit[] units,
                  ErrorEstimate[] errors,
                  boolean copy)
           throws VisADException
Throws:
VisADException
Method Detail

create

public static GriddedSet create(MathType type,
                                float[][] samples,
                                int[] lengths)
                         throws VisADException
Abreviated Factory method for creating the proper gridded set (Gridded1DSet, Gridded2DSet, etc.).

Parameters:
type - MathType for the returned set
samples - Set samples
lengths - The dimensionality of the manifold. lengths[i} contains the number of points in the manifold for dimension i.
Throws:
VisADException - problem creating the set

create

public static GriddedSet create(MathType type,
                                float[][] samples,
                                int[] lengths,
                                CoordinateSystem coord_sys,
                                Unit[] units,
                                ErrorEstimate[] errors)
                         throws VisADException
General Factory method for creating the proper gridded set (Gridded1DSet, Gridded2DSet, etc.).

Parameters:
type - MathType for the returned set
samples - Set samples
lengths - The dimensionality of the manifold. lengths[i} contains the number of points in the manifold for dimension i.
coord_sys - CoordinateSystem for the GriddedSet
units - Unit-s of the values in samples
errors - ErrorEstimate-s for the values
Throws:
VisADException - problem creating the set

create

public static GriddedSet create(MathType type,
                                float[][] samples,
                                int[] lengths,
                                CoordinateSystem coord_sys,
                                Unit[] units,
                                ErrorEstimate[] errors,
                                boolean copy)
                         throws VisADException
General Factory method for creating the proper gridded set (Gridded1DSet, Gridded2DSet, etc.).

Parameters:
type - MathType for the returned set
samples - Set samples
lengths - The dimensionality of the manifold. lengths[i} contains the number of points in the manifold for dimension i.
coord_sys - CoordinateSystem for the GriddedSet
units - Unit-s of the values in samples
errors - ErrorEstimate-s for the values
copy - make a copy of the samples
Throws:
VisADException - problem creating the set

create

public static GriddedSet create(MathType type,
                                float[][] samples,
                                int[] lengths,
                                CoordinateSystem coord_sys,
                                Unit[] units,
                                ErrorEstimate[] errors,
                                boolean copy,
                                boolean test)
                         throws VisADException
General Factory method for creating the proper gridded set (Gridded1DSet, Gridded2DSet, etc.).

Parameters:
type - MathType for the returned set
samples - Set samples
lengths - The dimensionality of the manifold. lengths[i} contains the number of points in the manifold for dimension i.
coord_sys - CoordinateSystem for the GriddedSet
units - Unit-s of the values in samples
errors - ErrorEstimate-s for the values
copy - make a copy of the samples
test - test to make sure samples are valid. Used for creating Gridded*DSets where the manifold dimension is equal to the domain dimension
Throws:
VisADException - problem creating the set

makeSpatial

public Set makeSpatial(SetType type,
                       float[][] samples)
                throws VisADException
Specified by:
makeSpatial in interface SetIface
Overrides:
makeSpatial in class Set
Throws:
VisADException

getLength

public int getLength(int i)
Description copied from interface: GriddedSetIface
Returns the number of grid points in a given dimension.

Specified by:
getLength in interface GriddedSetIface
Parameters:
i - The index of the dimension.
Returns:
The number of grid points in dimension i.

getLengths

public int[] getLengths()
Description copied from interface: GriddedSetIface
Returns the number of grid points in all dimensions.

Specified by:
getLengths in interface GriddedSetIface
Returns:
The number of grid points in all dimensions. Element [i] is the number of grid points in dimension i.

getWedge

public int[] getWedge()
returns a zig-zagging ennumeration of index values with good coherence

Specified by:
getWedge in interface SetIface
Overrides:
getWedge in class Set
Returns:
Indices of the samples of the set in a zig- zagging pattern with good coherence.

indexToValue

public float[][] indexToValue(int[] index)
                       throws VisADException
convert an array of 1-D indices to an array of values in R^DomainDimension

Specified by:
indexToValue in interface SetIface
Specified by:
indexToValue in class Set
Parameters:
index - array of integer indices
Returns:
float[domain_dimension][indices.length] array of Set values
Throws:
VisADException - a VisAD error occurred

valueToIndex

public int[] valueToIndex(float[][] value)
                   throws VisADException
convert an array of values in R^DomainDimension to an array of 1-D indices

Specified by:
valueToIndex in interface SetIface
Specified by:
valueToIndex in class Set
Parameters:
value - float[domain_dimension][number_of_values] array of Set values
Returns:
array of integer indices
Throws:
VisADException - a VisAD error occurred

gridToValue

public float[][] gridToValue(float[][] grid)
                      throws VisADException
transform an array of non-integer grid coordinates to an array of values in R^DomainDimension

Specified by:
gridToValue in interface GriddedSetIface
Parameters:
grid - The coordinates of the interpolation grid points for which interpolated sample values are desired. grid[i][j] is the i-th grid coordinate of the j-th interpolation point.
Returns:
The interpolated samples of the set. Element [i][j] is the i-th coordinate of the j-th interpolation point.
Throws:
VisADException - VisAD failure.

valueToGrid

public float[][] valueToGrid(float[][] value)
                      throws VisADException
transform an array of values in R^DomainDimension to an array of non-integer grid coordinates

Specified by:
valueToGrid in interface GriddedSetIface
Parameters:
value - The array of points for which non-integer grid coordinates are desired. value[i][j] is the i-th coordinate of the j-th point.
Returns:
The array of grid coordinates corresponding to the points. Element [i][j] is the i-th non-integer grid coordinate of the j-th point.
Throws:
VisADException - VisAD failure.

valueToInterp

public void valueToInterp(float[][] value,
                          int[][] indices,
                          float[][] weights)
                   throws VisADException
for each of an array of values in R^DomainDimension, compute an array of 1-D indices and an array of weights, to be used for interpolation; indices[i] and weights[i] are null if i-th value is outside grid (i.e., if no interpolation is possible)

Specified by:
valueToInterp in interface SimpleSetIface
Specified by:
valueToInterp in class SimpleSet
Parameters:
value - An array of points. value[i][j] is the i-th coordinate of the j-th points.
indices - Indices of the neighboring samples in the set. If the j-th points lies within the set, then returned element [i][j] is the index of the i-th neighboring sample in the set; otherwise, returned array [j] is null.
weights - Weights for interpolating the neighboring samples in the set. If the j-th points lies within the set, then returned element [i][j] is the weight of the i-th neighboring sample in the set; otherwise, returned array [j] is null.
Throws:
VisADException - VisAD failure.

getNeighbors

public void getNeighbors(int[][] neighbors)
                  throws VisADException
Returns the indexes of the neighboring points for every point in the set. neighbors.length should be at least getLength(). On return, neighbors[i][j] will be the index of the j -th neighboring point of point i. This method will allocate and set the array neighbors[i] for all i. For points in the interior of the set, the number of neighboring points is equal to 2*getManifoldDimension(). The number of neighboring points decreases, however, if the point in question is an exterior point on a hyperface, hyperedge, or hypercorner.

Specified by:
getNeighbors in interface SetIface
Overrides:
getNeighbors in class Set
Parameters:
neighbors - The array to contain the indexes of the neighboring points.
Throws:
NullPointerException - if the array is null.
ArrayIndexOutOfBoundsException - if neighbors.length < getLength() .
VisADException - if a VisAD failure occurs.

getNeighbors

public int[][] getNeighbors(int manifoldIndex)
Returns the indexes of the neighboring points along a manifold dimesion for every point in the set. Elements [i][0] and [i][1] of the returned array are the indexes of the neighboring sample points in the direction of decreasing and increasing manifold index, respectively, for sample point i. If a sample point doesn't have a neighboring point (because it is an exterior point, for example) then the value of the corresponding index will be -1.

Specified by:
getNeighbors in interface SetIface
Overrides:
getNeighbors in class Set
Parameters:
manifoldIndex - The index of the manifold dimension along which to return the neighboring points.
Throws:
ArrayIndexOutOfBoundsException - if manifoldIndex < 0 || manifoldIndex >= getManifoldDimension() .
See Also:
SimpleSet.getManifoldDimension()

equals

public boolean equals(Object set)
Description copied from class: Set
test for equality

Specified by:
equals in interface SetIface
Specified by:
equals in class Set

hashCode

public int hashCode()
Returns the hash code of this instance. Object.hashCode() should be overridden whenever Object.equals(Object) is.

Overrides:
hashCode in class Object
Returns:
The hash code of this instance (includes the values).

cloneButType

public Object cloneButType(MathType type)
                    throws VisADException
Description copied from class: Set
copy this Set, but give it a new MathType; this is safe, since constructor checks consistency of DomainCoordinateSystem and SetUnits with Type

Specified by:
cloneButType in interface SetIface
Specified by:
cloneButType in class Set
Parameters:
type - The MathType for the clone.
Returns:
A clone of this set with the new MathType.
Throws:
VisADException - VisAD failure.

longString

public String longString(String pre)
                  throws VisADException
Specified by:
longString in interface Data
Overrides:
longString in class Set
Parameters:
pre - String added to start of each line
Returns:
a longer String than returned by toString(), indented by pre (a string of blanks)
Throws:
VisADException