visad
Class EmpiricalCoordinateSystem

java.lang.Object
  extended by visad.CoordinateSystem
      extended by visad.EmpiricalCoordinateSystem
All Implemented Interfaces:
Serializable

public final class EmpiricalCoordinateSystem
extends CoordinateSystem
implements Serializable

Provides support for empirically-defined CoordinateSystem-s. This is useful for data-dependent coordinate transformations that must be determined empirically rather than analytically (e.g. pressure <-> height).

Coordinates in this system are termed "world" coordinates and coordinates in the reference coordinate system are termed "reference" coordinates.

Instances of this class are immutable.

Author:
Steven R. Emmerson
See Also:
Serialized Form

Constructor Summary
EmpiricalCoordinateSystem(GriddedSet world, GriddedSet reference)
          Constructs from two GriddedSet-s.
EmpiricalCoordinateSystem(GriddedSet world, GriddedSet reference, boolean copy, boolean check)
          Constructs from two GriddedSet-s.
 
Method Summary
static EmpiricalCoordinateSystem create(Field field)
          Constructs an EmpiricalCoordinateSystem from a Field.
protected static GriddedSet ensureNoCoordinateSystem(GriddedSet griddedSet)
          Ensures that a GriddedSet doesn't have a default CoordinateSystem.
protected static GriddedSet ensureNoCoordinateSystem(GriddedSet griddedSet, boolean copy, boolean check)
          Ensures that a GriddedSet doesn't have a default CoordinateSystem.
 boolean equals(Object object)
          Indicates if this coordinate system is semantically identical to an object.
 double[][] fromReference(double[][] values)
          Converts reference coordinates to world coordinates.
 float[][] fromReference(float[][] values)
          Converts reference coordinates to world coordinates.
 GriddedSet getReferenceSet()
          Returns the Set of reference coordinates.
 GriddedSet getWorldSet()
          Returns the Set of world coordinates.
static EmpiricalCoordinateSystem inverseCreate(Field field)
          Constructs an EmpiricalCoordinateSystem from a Field.
 double[][] toReference(double[][] values)
          Convert world coordinates to reference coordinates.
 float[][] toReference(float[][] values)
          Convert world coordinates to reference coordinates.
 
Methods inherited from class visad.CoordinateSystem
canConvert, fromReference, fromReference, getCoordinateSystemUnits, getDimension, getReference, getReferenceUnits, toReference, toReference, transformCoordinates, transformCoordinates, transformCoordinates, transformCoordinates, transformCoordinatesFreeUnits, transformCoordinatesFreeUnits
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EmpiricalCoordinateSystem

public EmpiricalCoordinateSystem(GriddedSet world,
                                 GriddedSet reference)
                          throws VisADException
Constructs from two GriddedSet-s. The dimensionality (i.e. rank and lengths) of the two sets must be identical. The RealTupleType of the reference will be that of the reference set. The units of the world coordinates will be the actual units of the world set.

Parameters:
world - A set of world coordinates. world.getLengths() shall equal reference.getLengths(). Determines the default units of world coordinates: the default units will be those of world.getSetUnits().
reference - A set of reference coordinates. Determines the reference RealTupleType.
Throws:
VisADException - Couldn't create necessary VisAD object.

EmpiricalCoordinateSystem

public EmpiricalCoordinateSystem(GriddedSet world,
                                 GriddedSet reference,
                                 boolean copy,
                                 boolean check)
                          throws VisADException
Constructs from two GriddedSet-s. The dimensionality (i.e. rank and lengths) of the two sets must be identical. The RealTupleType of the reference will be that of the reference set. The units of the world coordinates will be the actual units of the world set.

Parameters:
world - A set of world coordinates. world.getLengths() shall equal reference.getLengths(). Determines the default units of world coordinates: the default units will be those of world.getSetUnits().
reference - A set of reference coordinates. Determines the reference RealTupleType.
copy - copy samples if clone is made
check - check whether samples form a valid grid
Throws:
VisADException - Couldn't create necessary VisAD object.
Method Detail

ensureNoCoordinateSystem

protected static GriddedSet ensureNoCoordinateSystem(GriddedSet griddedSet)
                                              throws VisADException
Ensures that a GriddedSet doesn't have a default CoordinateSystem.

Parameters:
griddedSet - The GriddedSet to not have a CoordinateSystem.
Returns:
The GriddedSet without a CoordinateSystem. May be the original GriddedSet.
Throws:
VisADException - Couldn't create necessary VisAD object.

ensureNoCoordinateSystem

protected static GriddedSet ensureNoCoordinateSystem(GriddedSet griddedSet,
                                                     boolean copy,
                                                     boolean check)
                                              throws VisADException
Ensures that a GriddedSet doesn't have a default CoordinateSystem.

Parameters:
griddedSet - The GriddedSet to not have a CoordinateSystem.
Returns:
The GriddedSet without a CoordinateSystem. May be the original GriddedSet.
Throws:
VisADException - Couldn't create necessary VisAD object.

create

public static EmpiricalCoordinateSystem create(Field field)
                                        throws SetException,
                                               VisADException,
                                               RemoteException
Constructs an EmpiricalCoordinateSystem from a Field. The toReference() method of the resulting CoordinateSystem will transform numeric values in actual units of the domain of the field to numeric values in default units of the range of the field. Similarly, the fromReference() method will transform numeric values in default units of the range of the field to numeric values in the actual units of the domain of the field.

Parameters:
field - The FlatField comprising a coordinate system transformation from the domain to the range. The rank of the domain and range shall be the same. The domain set of the field shall be a GriddedSet.
Throws:
SetException - The field's domain set isn't a GriddedSet.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.

inverseCreate

public static EmpiricalCoordinateSystem inverseCreate(Field field)
                                               throws SetException,
                                                      VisADException,
                                                      RemoteException
Constructs an EmpiricalCoordinateSystem from a Field. The toReference() method of the resulting CoordinateSystem will transform numeric values in actual units of the range of the field to numeric values in default units of the domain of the field. Similarly, the fromReference() method will transform numeric values in default units of the domain of the field to numeric values in the actual units of the range of the field. The coordinate system transformation created by this method is the inverse of that created by create(Field).

Parameters:
field - The FlatField comprising a coordinate system transformation from the range to the domain. The rank of the domain and range shall be the same. The domain set of the field shall be a GriddedSet.
Throws:
SetException - The field's domain set isn't a GriddedSet.
VisADException - Couldn't create necessary VisAD object.
RemoteException - Java RMI failure.

getWorldSet

public GriddedSet getWorldSet()
Returns the Set of world coordinates.

Returns:
The Set of world coordinates.

getReferenceSet

public GriddedSet getReferenceSet()
Returns the Set of reference coordinates.

Returns:
The Set of reference coordinates.

fromReference

public double[][] fromReference(double[][] values)
                         throws SetException,
                                VisADException
Converts reference coordinates to world coordinates.

Specified by:
fromReference in class CoordinateSystem
Parameters:
values - Numeric reference coordinates in default units of the reference RealTupleType to be converted to numeric world coordinates. values.length shall equal getDimension() and values[i].length shall be the same for all i.
Returns:
values which now contains world coordinates. Values which could not be converted will have the value Double.NaN.
Throws:
SetException - Mismatch between input values and field domain.
VisADException - Couldn't create necessary VisAD object.

toReference

public double[][] toReference(double[][] values)
                       throws SetException,
                              VisADException
Convert world coordinates to reference coordinates.

Specified by:
toReference in class CoordinateSystem
Parameters:
values - Numeric world coordinates to be converted to numeric reference coordinates in default units of the reference RealTupleType. values.length shall equal getDimension() and values[i].length shall be the same for all i.
Returns:
values which now contains world coordinates. Values which could not be converted will have the value Double.NaN.
Throws:
SetException - Mismatch between input values and field domain.
VisADException - Couldn't create necessary VisAD object.

fromReference

public float[][] fromReference(float[][] values)
                        throws SetException,
                               VisADException
Converts reference coordinates to world coordinates.

Overrides:
fromReference in class CoordinateSystem
Parameters:
values - Numeric reference coordinates in default units of the reference RealTupleType to be converted to numeric world coordinates. values.length shall equal getDimension() and values[i].length shall be the same for all i.
Returns:
values which now contains world coordinates. Values which could not be converted will have the value Double.NaN.
Throws:
SetException - Mismatch between input values and field domain.
VisADException - Couldn't create necessary VisAD object.

toReference

public float[][] toReference(float[][] values)
                      throws SetException,
                             VisADException
Convert world coordinates to reference coordinates.

Overrides:
toReference in class CoordinateSystem
Parameters:
values - Numeric world coordinates to be converted to numeric reference coordinates in default units of the reference RealTupleType. values.length shall equal getDimension() and values[i].length shall be the same for all i.
Returns:
values which now contains world coordinates. Values which could not be converted will have the value Double.NaN.
Throws:
SetException - Mismatch between input values and field domain.
VisADException - Couldn't create necessary VisAD object.

equals

public boolean equals(Object object)
Indicates if this coordinate system is semantically identical to an object.

Specified by:
equals in class CoordinateSystem
Parameters:
object - The object in question.
Returns:
true if and only if this coordinate system is semantically identical to object.