Package ucar.visad

Class VisADMath

java.lang.Object
ucar.visad.VisADMath

public final class VisADMath extends Object
Utility class: provides support for mathematical operations on VisAD data objects.
Author:
Steven R. Emmerson $Id: VisADMath.java,v 1.15 2005/05/13 18:34:06 jeffmc Exp $
  • Method Details

    • negate

      public static Data negate(Data data) throws VisADException, RemoteException
      Negates a data object.
      Parameters:
      data - The data object to be negated.
      Returns:
      The result of negating the data object.
      Throws:
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • invert

      public static Data invert(Data data) throws VisADException, RemoteException
      Inverts a data object by forming the reciprocal.
      Parameters:
      data - The data object to be inverted.
      Returns:
      The result of inverting the data object.
      Throws:
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • exp

      public static Data exp(Data data) throws VisADException, RemoteException
      Exponentiates a data object.
      Parameters:
      data - The data object to be exponentiated.
      Returns:
      The result of exponentiating the data object.
      Throws:
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • log

      public static Data log(Data data) throws VisADException, RemoteException
      Takes the natural logarithm of a data object.
      Parameters:
      data - The data object to have the natural logarithm taken.
      Returns:
      The result of taking the natural logarithm of the data object.
      Throws:
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • add

      Adds two data objects together. The computational modes are Data.WEIGHTED_AVERAGE and Data.NO_ERRORS.
      Parameters:
      data1 - The first data object.
      data2 - The second data object.
      Returns:
      The result of adding the two data objects together.
      Throws:
      UnimplementedException - Operation not yet implemented.
      TypeException - MathTypes are incompatible.
      ArithmeticException - Invalid operation between types.
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • subtract

      Subtracts one data object from another.
      Parameters:
      data1 - The first data object.
      data2 - The second data object.
      Returns:
      The result of subtracting the second data object from the first data object.
      Throws:
      UnimplementedException - Operation not yet implemented.
      TypeException - MathTypes are incompatible.
      ArithmeticException - Invalid operation between types.
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • multiply

      Multiplies two data objects together. The computational modes are Data.WEIGHTED_AVERAGE and Data.NO_ERRORS.
      Parameters:
      data1 - The first data object.
      data2 - The second data object.
      Returns:
      The result of multiplying the first data object by the second data object.
      Throws:
      UnimplementedException - Operation not yet implemented.
      TypeException - MathTypes are incompatible.
      ArithmeticException - Invalid operation between types.
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • divide

      Divides one data object by another.
      Parameters:
      data1 - The first data object.
      data2 - The second data object.
      Returns:
      The result of dividing the first data object by the second data object.
      Throws:
      UnimplementedException - Operation not yet implemented.
      TypeException - MathTypes are incompatible.
      ArithmeticException - Invalid operation between types.
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • pow

      Raises one data object to the power of another.
      Parameters:
      base - The data object to be raised by a power.
      exponent - The exponent by which to raise the base.
      Returns:
      The result of raising the base data object by the power of the exponent data object.
      Throws:
      UnimplementedException - Operation not yet implemented.
      TypeException - MathTypes are incompatible.
      ArithmeticException - Invalid operation between types.
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • fromReference

      public static Data fromReference(MathType type, Data data) throws TypeException, VisADException, RemoteException
      Transforms a data object from a reference CoordinateSystem. When the data object is a FlatField, then the transformation applies to its range and not its domain.
      Parameters:
      type - The VisAD MathType of the returned data object. It shall be a RealTupleType, SetType, or FunctionType and shall have a CoordinateSystem, which shall be used in the transformation.
      data - The data object to be transformed. The object shall be a Real, RealTuple, SampledSet, or FlatField.
      Returns:
      The transformed data object. Its VisAD MathType shall be type.
      Throws:
      TypeException - Data object has illegal type.
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • fromReference

      public static RealTuple fromReference(RealTupleType type, RealTuple data) throws VisADException, RemoteException
      Transforms a RealTuple object from a reference CoordinateSystem.
      Parameters:
      type - The MathType of the returned data object. It shall have a CoordinateSystem, which shall be used in the transformation.
      data - The RealTuple object to be transformed.
      Returns:
      The transformed data object.
      Throws:
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • fromReference

      public static IrregularSet fromReference(SetType type, SampledSet data) throws VisADException
      Transforms a SampledSet object from a reference CoordinateSystem.
      Parameters:
      type - The MathType of the returned data object.It shall have a CoordinateSystem, which shall be used in the transformation.
      data - The SampledSet object to be transformed.
      Returns:
      The transformed data object.
      Throws:
      VisADException - Couldn't create necessary VisAD object.
    • fromReference

      public static FlatField fromReference(FunctionType type, FlatField data) throws VisADException, RemoteException
      Transforms a FlatField object from a reference CoordinateSystem.
      Parameters:
      type - The MathType of the returned data object.It shall have a CoordinateSystem, which shall be used in the transformation.
      data - The data object to be transformed.
      Returns:
      The transformed data object.
      Throws:
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • curveIntegralOfGradient

      public static FlatField curveIntegralOfGradient(Field field) throws FieldException, VisADException, RemoteException
      Returns the indefinite curve integral of a Field, which is assumed to be the gradient of a function. This method can handle any Field whose range is one of the following:
      
         Scalar derivative       dy/dx
      
         RealTuple of partial
         derivatives             (du/dx, du/dy, ...)
      
         Tuple of RealTuple-s
         of partial derivatives
         (one set of partial
         derivatives for each
         component of the
         resulting FlatField)    ((du/dx, du/dy, ...), (dv/dx, dv/dy, ...), ...)
       

      The domain points of the returned FlatField will be the same as the Field's. The type of the range of the returned FlatField will depend on the type of the range of the Field. The value of the range at the first domain point of the returned FlatField shall be arbitrarily set to (possibly vector) zero.
      Parameters:
      field - The Field whose indefinite curve integral is to be computed.
      Returns:
      The indefinite curve integral of the Field.
      Throws:
      FieldException - The Field has a non-flat range or range dimension of Field != domain dimension of Field.
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • newFlatField

      public static FlatField newFlatField(SampledSet set) throws VisADException, RemoteException
      Creates a FlatField from a SampledSet. This method should, perhaps, become a method in visad.Set or a constructor in FlatField.
      Parameters:
      set - The SampledSet.
      Returns:
      The SampledSet promoted to a FlatField. The MathType of the domain and range will be the RealTupleType of the set (i.e. ((SetType)set.getType()).getDomain(). The CoordinateSystem of the range will be that of the set (i.e. set.getCoordinateSystem()).
      Throws:
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • newFlatField

      public static FlatField newFlatField(SampledSet domain, SampledSet range) throws VisADException, RemoteException
      Creates a FlatField from two SampledSet-s. This method should, perhaps, become a method in visad.Set or a constructor in FlatField.
      Parameters:
      domain - The domain of the FlatField.
      range - The range of the FlatField.
      Returns:
      The SampledSet promoted to a FlatField. The MathType of the domain and range will be the RealTupleType of the set (i.e. ((SetType)set.getType()).getDomain(). The CoordinateSystem of the range will be that of the set (i.e. set.getCoordinateSystem()).
      Throws:
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • newFlatField

      public static FlatField newFlatField(SampledSet set, MathType rangeType, CoordinateSystem rangeCoordinateSystem) throws VisADException, RemoteException
      Creates a FlatField from a SampledSet, a MathType for the range, and a CoordinateSystem for the range. This method should, perhaps, become a method in visad.Set or a constructor in FlatField.
      Parameters:
      set - The SampledSet.
      rangeType - The MathType of the range for the returned FlatField.
      rangeCoordinateSystem - The CoordinateSystem for the range of the returned FlatField. May be null.
      Returns:
      The SampledSet promoted to a FlatField. The MathType of the domain will be the RealTupleType of the set (i.e. ((SetType)set.getType()).getDomain().
      Throws:
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • newFlatField

      public static FlatField newFlatField(SampledSet domain, SampledSet range, MathType rangeType, CoordinateSystem rangeCoordinateSystem) throws VisADException, RemoteException
      Creates a FlatField from a domain SampledSet, a range SampledSet, and a CoordinateSystem for the range. This method should, perhaps, become a method in visad.Set or a constructor in FlatField.
      Parameters:
      domain - The domain SampledSet.
      range - The range SampledSet.
      rangeType - The MathType of the range for the returned FlatField.
      rangeCoordinateSystem - The CoordinateSystem for the range of the returned FlatField. May be null.
      Returns:
      The SampledSet promoted to a FlatField. The MathType of the domain will be the RealTupleType of the set (i.e. ((SetType)set.getType()).getDomain().
      Throws:
      VisADException - Couldn't create necessary VisAD object.
      RemoteException - Java RMI failure.
    • main

      public static void main(String[] args) throws VisADException, RemoteException
      Tests this class.
      Parameters:
      args - Ignored.
      Throws:
      VisADException - if a core VisAD failure occurs.
      RemoteException - if a Java RMI failure occurs.