Class GridUtil

java.lang.Object
ucar.unidata.data.grid.GridUtil
Direct Known Subclasses:
WrfUtil

public class GridUtil extends Object
Set of static methods for messing with grids. A grid is defined as a FieldImpl which has one of the following MathTypes structures:
   (x,y) -> (parm)
   (x,y) -> (parm1, ..., parmN)
   (x,y,z) -> (parm)
   (x,y,z) -> (parm1, ..., parmN)
   (t -> (x,y) -> (parm))
   (t -> (x,y) -> (parm1, ..., parmN))
   (t -> (x,y,z) -> (parm))
   (t -> (x,y,z) -> (parm1, ..., parmN))
   (t -> (index -> (x,y) -> (parm)))
   (t -> (index -> (x,y) -> (parm1, ..., parmN)))
   (t -> (index -> (x,y,z) -> (parm)))
   (t -> (index -> (x,y,z) -> (parm1, ..., parmN)))
 
In general, t is a time variable, but it might also be just an index.
Version:
$Revision: 1.112 $
Author:
Don Murray
  • Field Details

    • WEIGHTED_AVERAGE

      public static final int WEIGHTED_AVERAGE
      Weighted average sampling mode
      See Also:
    • NEAREST_NEIGHBOR

      public static final int NEAREST_NEIGHBOR
      Nearest Neighbor sampling mode
      See Also:
    • NO_ERRORS

      public static final int NO_ERRORS
      No error mode
      See Also:
    • DEPENDENT_ERRORS

      public static final int DEPENDENT_ERRORS
      Dependent error mode
      See Also:
    • INDEPENDENT_ERRORS

      public static final int INDEPENDENT_ERRORS
      Independent error mode
      See Also:
    • DEFAULT_SAMPLING_MODE

      public static final int DEFAULT_SAMPLING_MODE
      Default sampling mode used for subsampling grids
      See Also:
    • DEFAULT_ERROR_MODE

      public static final int DEFAULT_ERROR_MODE
      Default error mode used for subsampling grids
      See Also:
    • FUNC_AVERAGE

      public static final String FUNC_AVERAGE
      function for the applyFunctionOverTime routine deprecated use GridMath.FUNC_AVERAGE
      See Also:
    • FUNC_SUM

      public static final String FUNC_SUM
      function for the applyFunctionOverTime routine deprecated use GridMath.FUNC_SUM
      See Also:
    • FUNC_MAX

      public static final String FUNC_MAX
      function for the applyFunctionOverTime routine deprecated use GridMath.FUNC_MAX
      See Also:
    • FUNC_MIN

      public static final String FUNC_MIN
      function for the applyFunctionOverTime routine deprecated use GridMath.FUNC_MIN
      See Also:
    • FUNC_DIFFERENCE

      public static final String FUNC_DIFFERENCE
      function for the timeStepFunc routine deprecated use GridMath.FUNC_DIFFERENCE
      See Also:
    • SMOOTH_5POINT

      public static final String SMOOTH_5POINT
      Five point smoother identifier
      See Also:
    • SMOOTH_9POINT

      public static final String SMOOTH_9POINT
      Nine point smoother identifier
      See Also:
    • SMOOTH_GAUSSIAN

      public static final String SMOOTH_GAUSSIAN
      Gaussian smoother identifier
      See Also:
    • SMOOTH_CRESSMAN

      public static final String SMOOTH_CRESSMAN
      Cressman smoother identifier
      See Also:
    • SMOOTH_CIRCULAR

      public static final String SMOOTH_CIRCULAR
      Barnes circular smoother identifier
      See Also:
    • SMOOTH_RECTANGULAR

      public static final String SMOOTH_RECTANGULAR
      Barnes circular smoother identifier
      See Also:
    • ENSEMBLE_TYPE

      public static final RealType ENSEMBLE_TYPE
      ensemble RealType
  • Constructor Details

    • GridUtil

      public GridUtil()
      Default ctor
  • Method Details

    • isGrid

      public static boolean isGrid(FieldImpl field)
      Check to see if this field is a grid that can be handled by these methods
      Parameters:
      field - fieldImpl to check
      Returns:
      true if the MathType of the grid is compatible with the ones this class can deal with
    • isConstantSpatialDomain

      public static boolean isConstantSpatialDomain(FieldImpl grid) throws VisADException
      See if the spatial domain of this grid is constant (ie: not time varying)
      Parameters:
      grid - grid to check
      Returns:
      true if the spatial domain is constant
      Throws:
      VisADException - problem getting Data object
    • getSpatialDomain

      public static SampledSet getSpatialDomain(FieldImpl grid) throws VisADException
      Get the spatial domain for this grid.
      Parameters:
      grid - grid to check
      Returns:
      the spatial domain of the grid. If this is a time series it is the spatial domain of the first grid in the series
      Throws:
      VisADException - problem getting domain set
    • getWholeSpatialDomain

      public static SampledSet getWholeSpatialDomain(FieldImpl grid) throws VisADException
      Get the spatial domain for this grid. If the grid is time sequence, this will check the domain in the sequence and find the largest domain , this is very useful in point data observation when returning the first time step spatial domain is not big enough to cover the later time step.
      Parameters:
      grid - grid to check
      Returns:
      the spatial domain of the grid. If this is a time series it is the spatial domain of the first grid in the series
      Throws:
      VisADException - problem getting domain set
    • getSpatialDomain

      public static SampledSet getSpatialDomain(FieldImpl grid, int timeIndex) throws VisADException
      Get the spatial domain for this grid at the specified time step.
      Parameters:
      grid - grid to check
      timeIndex - timestep to check
      Returns:
      the spatial domain of the grid at the time step. If this is not a time series, timeIndex is ignored
      Throws:
      VisADException - problem getting domain set
    • setSpatialDomain

      public static FieldImpl setSpatialDomain(FieldImpl grid, SampledSet newDomain) throws VisADException
      Change the spatial domain of a grid using the new one. Range values are not copied.
      Parameters:
      grid - grid to change.
      newDomain - Must have same length as current spatial domain of grid
      Returns:
      new grid with new domain
      Throws:
      VisADException - wrong domain length or VisAD problem.
    • setSpatialDomain

      public static FieldImpl setSpatialDomain(FieldImpl grid, SampledSet newDomain, boolean copy) throws VisADException
      Change the spatial domain of a grid using the new one.
      Parameters:
      grid - grid to change.
      newDomain - Must have same length as current spatial domain of grid
      copy - copy values
      Returns:
      new grid with new domain
      Throws:
      VisADException - wrong domain length or VisAD problem.
    • isSinglePointDomain

      public static boolean isSinglePointDomain(FieldImpl grid) throws VisADException
      See if the domain of the grid is a single point (only 1 x and y value). May have multiple vertical values at that one point.
      Parameters:
      grid - grid to check
      Returns:
      true if only one x,y value.
      Throws:
      VisADException - problem accessing grid
    • isSinglePointDomain

      public static boolean isSinglePointDomain(SampledSet ss) throws VisADException
      See if the domain is a single point (only 1 x and y value). May have multiple vertical values at that one point
      Parameters:
      ss - domain set of the grid
      Returns:
      true if only one x,y value.
      Throws:
      VisADException - problem accessing grid
    • isSequence

      public static boolean isSequence(FieldImpl grid)
      Check to see if this is a single grid or if it is a sequence of grids.
      Parameters:
      grid - grid to check
      Returns:
      true if the domain of the grid is 1 dimensional. It is not automatically a time sequence, though.
      See Also:
    • hasEnsemble

      public static boolean hasEnsemble(FieldImpl grid) throws VisADException
      Check to see if this is an ensemble grid
      Parameters:
      grid - grid to check
      Returns:
      true if the domain of the grid is 1 dimensional and the type is convertible with ENSEMBLE_TYPE or a sequence and the inner type has a domain of ENSEMBLE_TYPE;
      Throws:
      VisADException - problem determining this
    • getEnsembleType

      public static RealType getEnsembleType(FieldImpl grid) throws VisADException
      Get the RealType of the ensemble.
      Parameters:
      grid - grid to check
      Returns:
      RealType of ensemble paramter
      Throws:
      VisADException - unable to get the information
      See Also:
    • getEnsembleSet

      public static Gridded1DSet getEnsembleSet(FieldImpl ensGrid) throws VisADException
      Return the ensemble set for the field
      Parameters:
      ensGrid - the ensemble grid
      Returns:
      the set or null if not an ensemble
      Throws:
      VisADException - problems reading data
    • isTimeSequence

      public static boolean isTimeSequence(FieldImpl grid) throws VisADException
      Check to see if this is a single grid or if it is a time sequence of grids.
      Parameters:
      grid - grid to check
      Returns:
      true if the domain of the grid is 1 dimensional and the type is convertible with RealType.Time
      Throws:
      VisADException - problem determining this
    • getTimeSet

      public static Set getTimeSet(FieldImpl grid) throws VisADException
      Get the time set from the grid.
      Parameters:
      grid - grid to check
      Returns:
      set of times or null if no times.
      Throws:
      VisADException - problem determining this
    • getDateTimeList

      public static List<DateTime> getDateTimeList(FieldImpl grid) throws VisADException
      Get the list of DateTime objects from the domain of the given grid
      Parameters:
      grid - grid to check
      Returns:
      list of times or null list if no times.
      Throws:
      VisADException - problem determining this
    • isNavigated

      public static boolean isNavigated(FieldImpl grid) throws VisADException
      Check to see if this is a navigated grid (domain can be converted to lat/lon)
      Parameters:
      grid - grid to check
      Returns:
      true if the domain of the grid is in or has a reference to Latitude/Longitude
      Throws:
      VisADException - can't create VisAD object
    • isNavigated

      public static boolean isNavigated(SampledSet spatialSet) throws VisADException
      Check to see if this is a navigated domain (can be converted to lat/lon)
      Parameters:
      spatialSet - spatial domain of grid to check
      Returns:
      true if the domain of the grid is in or has a reference to Latitude/Longitude
      Throws:
      VisADException - can't create VisAD object
    • getNavigation

      public static MapProjection getNavigation(FieldImpl grid) throws VisADException
      Get the navigation for this grid
      Parameters:
      grid - grid to use
      Returns:
      MapProjection for grid
      Throws:
      VisADException - no navigation or some other error
    • getNavigation

      public static MapProjection getNavigation(SampledSet spatialSet) throws VisADException
      Get the navigation for this spatialDomain
      Parameters:
      spatialSet - spatial set for grid
      Returns:
      MapProjection for grid
      Throws:
      VisADException - no navigation or some other error
    • isLatLonOrder

      public static boolean isLatLonOrder(FieldImpl grid) throws VisADException
      Check to see if this is a navigated grid (domain can be converted to lat/lon)
      Parameters:
      grid - grid to check
      Returns:
      true if the domain of the grid is in or has a reference to Latitude/Longitude
      Throws:
      VisADException - can't get at VisAD objects
    • isLatLonOrder

      public static boolean isLatLonOrder(SampledSet spatialSet) throws VisADException
      Check to see if this is a navigated domain (can be converted to lat/lon)
      Parameters:
      spatialSet - spatial domain of the grid
      Returns:
      true if the domain of the grid is in or has a reference to Latitude/Longitude
      Throws:
      VisADException - can't get at VisAD objects
    • getSequenceType

      public static RealType getSequenceType(FieldImpl grid) throws VisADException
      Get the RealType of the sequence.
      Parameters:
      grid - grid to check
      Returns:
      RealType of sequence paramter
      Throws:
      VisADException - unable to get the information
      See Also:
    • is3D

      public static boolean is3D(FieldImpl grid) throws VisADException
      Check to see if this is a 3D grid
      Parameters:
      grid - grid to check
      Returns:
      true if the spatial domain is 3 dimensional (i.e, (x,y,z))
      Throws:
      VisADException - unable to get the information
    • isVolume

      public static boolean isVolume(FieldImpl grid) throws VisADException
      Is the gievn field a volume. It is a volume if it is a 3d grid and if the manifold dimension is 3.
      Parameters:
      grid - The grid
      Returns:
      Is it a volume
      Throws:
      VisADException - On badness
    • sampleToRealTuple

      public static RealTuple sampleToRealTuple(FieldImpl grid, EarthLocation el, Real animationValue, int samplingMode) throws VisADException, RemoteException
      This samples the given grid in both time and space and trys to return a Real value
      Parameters:
      grid - The grid
      el - Location
      animationValue - The time to sample at. If null then we just sample at the location
      samplingMode - mode to use
      Returns:
      Real at the given location and time
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleToRealTuple

      public static RealTuple sampleToRealTuple(FieldImpl grid, EarthLocation el, Real animationValue, int samplingMode, int errorMode) throws VisADException, RemoteException
      This samples the given grid in both time and space and trys to return a Real value
      Parameters:
      grid - The grid
      el - Location
      animationValue - The time to sample at. If null then we just sample at the location
      samplingMode - sampling mode to use
      errorMode - error mode to use
      Returns:
      Real at the given location and time
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleToReal

      public static Real sampleToReal(FieldImpl grid, EarthLocation el, Real animationValue) throws VisADException, RemoteException
      This samples the given grid in both time and space and trys to return a Real value
      Parameters:
      grid - The grid
      el - Location
      animationValue - Time
      Returns:
      Real at the given location and time
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleToReal

      public static Real sampleToReal(FieldImpl grid, EarthLocation el, Real animationValue, int samplingMode) throws VisADException, RemoteException
      This samples the given grid in both time and space and trys to return a Real value
      Parameters:
      grid - The grid
      el - Location
      animationValue - The time to sample at. If null then we just sample at the location
      samplingMode - mode to use
      Returns:
      Real at the given location and time
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sampleToReal

      public static Real sampleToReal(FieldImpl grid, EarthLocation el, Real animationValue, int samplingMode, int errorMode) throws VisADException, RemoteException
      This samples the given grid in both time and space and trys to return a Real value
      Parameters:
      grid - The grid
      el - Location
      animationValue - The time to sample at. If null then we just sample at the location
      samplingMode - sampling mode to use
      errorMode - error mode to use
      Returns:
      Real at the given location and time
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • is3D

      public static boolean is3D(SampledSet domainSet) throws VisADException
      Check to see if this is a 3D domain
      Parameters:
      domainSet - spatial domain of the grid
      Returns:
      true if the spatial domain is 3 dimensional (i.e, (x,y,z))
      Throws:
      VisADException - unable to get the information
    • is2D

      public static boolean is2D(FieldImpl grid) throws VisADException
      Check to see if this is a 2D grid
      Parameters:
      grid - grid to check
      Returns:
      true if the spatial domain is 2 dimensional (i.e, (x,y))
      Throws:
      VisADException - unable to get the information
    • is2D

      public static boolean is2D(SampledSet domainSet) throws VisADException
      Check to see if this is a 2D domain
      Parameters:
      domainSet - spatial domain to check
      Returns:
      true if the spatial domain is 2 dimensional (i.e, (x,y))
      Throws:
      VisADException - unable to get the information
    • subset

      public static FieldImpl subset(FieldImpl grid, int skip) throws VisADException
      Create a subset of the grid, skipping every nth point in the X and Y direction.
      Parameters:
      grid - grid to subset
      skip - x and y skip factor
      Returns:
      subsampled grid
      Throws:
      VisADException - unable to subset the grid
    • subset

      public static FieldImpl subset(FieldImpl grid, int skipx, int skipy) throws VisADException
      Create a subset of the grid skipping every i'th x and j'th y point.
      Parameters:
      grid - grid to subsample
      skipx - x skip factor
      skipy - y skip factor
      Returns:
      subsampled grid
      Throws:
      VisADException - unable to subsample grid
    • subset

      public static FieldImpl subset(FieldImpl grid, int skipx, int skipy, int skipz) throws VisADException
      Create a subset of the grid skipping every i'th x and j'th y point and k'th z point
      Parameters:
      grid - grid to subsample
      skipx - x skip factor
      skipy - y skip factor
      skipz - z skip factor
      Returns:
      subsampled grid
      Throws:
      VisADException - unable to subsample grid
    • subsetDomain

      public static GriddedSet subsetDomain(GriddedSet domainSet, int skipx, int skipy, int skipz) throws VisADException
      Create a subset of the domainset skipping every i'th x and j'th y point.
      Parameters:
      domainSet - domain to subsample
      skipx - x skip factor
      skipy - y skip factor
      skipz - z skip factor
      Returns:
      subsampled grid
      Throws:
      VisADException - unable to subsample grid
    • sliceAtLevel

      public static FieldImpl sliceAtLevel(FieldImpl grid, Real level) throws VisADException
      Slice the grid at the vertical level indictated.
      Parameters:
      grid - grid to slice (must be a valid 3D grid)
      level - level to slice at. level must have units convertible with the vertial coordinate of the spatial domain or it's reference if there is a CoordinateSystem associated with the domain.
      Returns:
      spatial slice at level. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • sliceAtLevel

      public static FieldImpl sliceAtLevel(FieldImpl grid, Real level, int samplingMode) throws VisADException
      Slice the grid at the vertical level indictated.
      Parameters:
      grid - grid to slice (must be a valid 3D grid)
      level - level to slice at. level must have units convertible with the vertial coordinate of the spatial domain or it's reference if there is a CoordinateSystem associated with the domain.
      samplingMode - Data.WEIGHTED_AVERAGE or Data.NEAREST_NEIGHBOR
      Returns:
      spatial slice at level. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • sliceAtLevel

      public static FieldImpl sliceAtLevel(FieldImpl grid, Real level, int samplingMode, int errorMode) throws VisADException
      Slice the grid at the vertical level indictated.
      Parameters:
      grid - grid to slice (must be a valid 3D grid)
      level - level to slice at. level must have units convertible with the vertial coordinate of the spatial domain or it's reference if there is a CoordinateSystem associated with the domain.
      samplingMode - Data.WEIGHTED_AVERAGE or Data.NEAREST_NEIGHBOR
      errorMode - Data.NO_ERRORS, Data.DEPENDENT, Data.INDEPENDENT
      Returns:
      spatial slice at level. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • isAllMissing

      public static boolean isAllMissing(FieldImpl field) throws VisADException
      Check if all real values in a FieldImpl are missing.
      Parameters:
      field - fieldImpl to check
      Returns:
      true if all values are missing
      Throws:
      VisADException - unable to open VisAD object
    • isAllMissing

      public static boolean isAllMissing(FieldImpl grid, boolean popupErrorMessage) throws VisADException
      Check if all real values in a FieldImpl are missing.
      Parameters:
      grid - grid to check
      popupErrorMessage - pop up a JOptionDialog box is all are missing
      Returns:
      true if all values are missing
      Throws:
      VisADException - unable to open VisAD object
    • isAnyMissing

      public static boolean isAnyMissing(FieldImpl grid) throws VisADException
      Check if any of the real values in a FieldImpl are missing.
      Parameters:
      grid - grid to check
      Returns:
      true if all values are missing
      Throws:
      VisADException - unable to open VisAD object
    • averageOverTime

      public static FieldImpl averageOverTime(FieldImpl grid, boolean makeTimes) throws VisADException
      Average the grid over time
      Parameters:
      grid - grid to average
      makeTimes - If true then make a time field with the range being the same computed value If false then just return a single field of the computed values
      Returns:
      the new field
      Throws:
      VisADException - On badness deprecated use GridMath.averageOverTime(FieldImpl, boolean)
    • timeStepDifference

      public static FieldImpl timeStepDifference(FieldImpl grid, int offset) throws VisADException
      This creates a field where D(T) = D(T)-D(T+offset) Any time steps up to the offset time are set to missing
      Parameters:
      grid - grid to average
      offset - time step offset. e.g., offset=-1 results in D(T)=D(T)-D(T-1)
      Returns:
      the new field
      Throws:
      VisADException - On badness deprecated use GridMath.timeStepDifference(FieldImpl, int)
    • timeStepSum

      public static FieldImpl timeStepSum(FieldImpl grid, int offset) throws VisADException
      This creates a field where D(T) = D(T)+D(T+offset) Any time steps up to the offset time are set to missing
      Parameters:
      grid - grid to average
      offset - time step offset. e.g., offset=-1 results in D(T)=D(T)+D(T-1)
      Returns:
      the new field
      Throws:
      VisADException - On badness deprecated use GridMath.timeStepSum(FieldImpl, int)
    • differenceFromBaseTime

      public static FieldImpl differenceFromBaseTime(FieldImpl grid) throws VisADException
      This creates a field where D(T) = D(T)-D(0) Any time steps up to the offset time are set to missing
      Parameters:
      grid - grid to average
      Returns:
      the new field
      Throws:
      VisADException - On badness deprecated use GridMath.differenceFromBaseTime(FieldImpl)
    • sumFromBaseTime

      public static FieldImpl sumFromBaseTime(FieldImpl grid) throws VisADException
      This creates a field where D(T) = D(T)+D(0) Any time steps up to the offset time are set to missing
      Parameters:
      grid - grid to average
      Returns:
      the new field
      Throws:
      VisADException - On badness deprecated use GridMath.sumFromBaseTime(FieldImpl)
    • timeStepFunc

      public static FieldImpl timeStepFunc(FieldImpl grid, int offset, String func) throws VisADException
      This creates a field where is either D(T) = D(T)-D(T+offset) or D(T) = D(T)+D(T+offset) depending on the value of the func argument Any time steps up to the offset time are set to missing. If offset == 0 then we use D(0) as the fixed operand foreach operator, e.g.: D(T) = D(T) - D(0)
      Parameters:
      grid - grid to average
      offset - time step offset.
      func - which function to apply, SUM or DIFFERENCE
      Returns:
      the new field
      Throws:
      VisADException - On badness deprecated use GridMath.timeStepFunc(FieldImpl, int, String)
    • sumOverTime

      public static FieldImpl sumOverTime(FieldImpl grid, boolean makeTimes) throws VisADException
      Sum each grid point
      Parameters:
      grid - grid to analyze
      makeTimes - If true then make a time field with the range being the same computed value. If false then just return a single field of the computed values
      Returns:
      the new field
      Throws:
      VisADException - On badness deprecated use GridMath.sumOverTime(FieldImpl, boolean)
    • minOverTime

      public static FieldImpl minOverTime(FieldImpl grid, boolean makeTimes) throws VisADException
      Take the min value at each grid point
      Parameters:
      grid - grid to analyze
      makeTimes - If true then make a time field with the range being the same computed value. If false then just return a single field of the computed values
      Returns:
      the new field
      Throws:
      VisADException - On badness deprecated use GridMath.minOverTime
    • maxOverTime

      public static FieldImpl maxOverTime(FieldImpl grid, boolean makeTimes) throws VisADException
      Take the max value at each grid point
      Parameters:
      grid - grid to analyze
      makeTimes - If true then make a time field with the range being the same computed value. If false then just return a single field of the computed values
      Returns:
      the new field
      Throws:
      VisADException - On badness deprecated use GridMath.maxOverTime(FieldImpl, boolean)
    • applyFunctionOverTime

      public static FieldImpl applyFunctionOverTime(FieldImpl grid, String function, boolean makeTimes) throws VisADException
      Apply the function to the time steps of the given grid. The function is one of the GridMath.FUNC_ enums
      Parameters:
      grid - grid to average
      function - One of the GridMath.FUNC_ enums
      makeTimes - If true then make a time field with the range being the same computed value. If false then just return a single field of the computed values
      Returns:
      the new field
      Throws:
      VisADException - On badness deprecated use GridMath.applyFunctionOverTime(FieldImpl, String, boolean)
    • makeDomain2D

      public static Gridded2DSet makeDomain2D(GriddedSet domainSet) throws VisADException
      Transform a (possibly) 3D set into a 2D set (removing the Z dimension)
      Parameters:
      domainSet - the 2 or 3D domain
      Returns:
      a 2D version with Z values removed
      Throws:
      VisADException - unable to create 2D slice
    • addLevelToGrid

      public static FieldImpl addLevelToGrid(FieldImpl grid, double levelValue, String levelUnit) throws VisADException
      Add a level to a 2D grid
      Parameters:
      grid - the grid
      levelValue - the level value
      levelUnit - the level unit
      Returns:
      new grid
      Throws:
      VisADException - for bad
    • makeNewParamType

      public static TupleType makeNewParamType(TupleType oldParamType, String newSuffix) throws VisADException
      Make a new type for the field by appending the suffix to the exiting RealTypes in the range
      Parameters:
      oldParamType - old parameter type containing only real components
      newSuffix - the new suffix for Range RealTypes
      Returns:
      the new Range type
      Throws:
      VisADException - problem creating new types
    • makeGrid2D

      public static GridUtil.Grid2D makeGrid2D(FieldImpl grid) throws VisADException, RemoteException
      rectangulrize the given field, making a grid2d out of its spatial domain and values
      Parameters:
      grid - the grid
      Returns:
      the grid2d
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • testIt

      public static void testIt(FieldImpl grid) throws VisADException, RemoteException
      test
      Parameters:
      grid - test
      Throws:
      RemoteException - On badness
      VisADException - On badness
    • sliceAtLevel

      public static FieldImpl sliceAtLevel(FieldImpl grid, double levelValue) throws VisADException
      Slice the grid at the vertical level indictated. Value is assumed to be in the units of the domain set.
      Parameters:
      grid - grid to slice (must be a valid 3D grid)
      levelValue - level value to slice at. Value is assumed to be in the units of the vertical coordinate of the spatial domain of the FieldImpl
      Returns:
      spatial slice at level. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • getProfileAtLatLonPoint

      public static FieldImpl getProfileAtLatLonPoint(FieldImpl grid, LatLonPoint point) throws VisADException
      Returns a vertical profile of a grid at a Lat/Lon point. Returns null if no such profile could be created.
      Parameters:
      grid - grid to slice (must be a valid 3D grid)
      point - LatLonPoint to sample at.
      Returns:
      vertical slice at point or null. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • getProfileAtLatLonPoint

      public static FieldImpl getProfileAtLatLonPoint(FieldImpl grid, LatLonPoint point, int samplingMode) throws VisADException
      Returns a vertical profile of a grid at a Lat/Lon point. Returns null if no such profile could be created.
      Parameters:
      grid - grid to slice (must be a valid 3D grid)
      point - LatLonPoint to sample at.
      samplingMode - Data.WEIGHTED_AVERAGE or NEAREST_NEIGHBOR
      Returns:
      vertical slice at point or null. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • getProfileAtLatLonPoint

      public static FieldImpl getProfileAtLatLonPoint(FieldImpl grid, LatLonPoint point, int samplingMode, int errorMode) throws VisADException
      Returns a vertical profile of a grid at a Lat/Lon point. Returns null if no such profile could be created.
      Parameters:
      grid - grid to slice (must be a valid 3D grid)
      point - LatLonPoint to sample at.
      samplingMode - Data.WEIGHTED_AVERAGE or NEAREST_NEIGHBOR
      errorMode - Data.NO_ERRORS, Data.DEPENDENT, Data.INDEPENDENT
      Returns:
      vertical slice at point or null. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • sliceAlongLatLonLine

      public static FieldImpl sliceAlongLatLonLine(FieldImpl grid, LatLonPoint start, LatLonPoint end) throws VisADException
      Slice the grid along the line specified by the two LatLonPoint-s
      Parameters:
      grid - grid to slice (must be a valid 2D or 3D grid)
      start - starting LatLonPoint of the line
      end - starting LatLonPoint of the line
      Returns:
      spatial slice along the line. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • sliceAlongLatLonLine

      public static FieldImpl sliceAlongLatLonLine(FieldImpl grid, LatLonPoint start, LatLonPoint end, int samplingMode) throws VisADException
      Slice the grid along the line specified by the two LatLonPoint-s
      Parameters:
      grid - grid to slice (must be a valid 2D or 3D grid)
      start - starting LatLonPoint of the line
      end - starting LatLonPoint of the line
      samplingMode - Data.WEIGHTED_AVERAGE or NEAREST_NEIGHBOR
      Returns:
      spatial slice along the line. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • sliceAlongLatLonLine

      public static FieldImpl sliceAlongLatLonLine(FieldImpl grid, List<LatLonPoint> points, int samplingMode) throws VisADException
      Slice the grid along the line specified by the two LatLonPoint-s
      Parameters:
      grid - grid to slice (must be a valid 2D or 3D grid)
      points - list of points along the line
      samplingMode - mode for sampling
      Returns:
      spatial slice along the line. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • sliceAlongLatLonLine

      public static FieldImpl sliceAlongLatLonLine(FieldImpl grid, List<LatLonPoint> points, int samplingMode, int errorMode) throws VisADException
      Slice the grid along the line specified by the two LatLonPoint-s
      Parameters:
      grid - grid to slice (must be a valid 2D or 3D grid)
      points - list of points along the line
      samplingMode - mode for sampling
      errorMode - Data.NO_ERRORS, Data.DEPENDENT, Data.INDEPENDENT
      Returns:
      spatial slice along the line. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • sliceAlongLatLonLine

      public static FieldImpl sliceAlongLatLonLine(FieldImpl grid, LatLonPoint start, LatLonPoint end, int samplingMode, int errorMode) throws VisADException
      Slice the grid along the line specified by the two LatLonPoint-s
      Parameters:
      grid - grid to slice (must be a valid 2D or 3D grid)
      start - starting LatLonPoint of the line
      end - starting LatLonPoint of the line
      samplingMode - mode for sampling
      errorMode - Data.NO_ERRORS, Data.DEPENDENT, Data.INDEPENDENT
      Returns:
      spatial slice along the line. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - problem in resampling
    • sample

      public static FieldImpl sample(FieldImpl grid, EarthLocation location) throws VisADException
      Sample the grid at the position defined by the EarthLocation
      Parameters:
      grid - grid to sample (must be a valid 3D grid)
      location - EarthLocation to sample at.
      Returns:
      grid representing the values of the original grid at the point defined by location. If this is a sequence of grids it will be a sequence of the values.
      Throws:
      VisADException - invalid point or some other problem
    • sample

      public static FieldImpl sample(FieldImpl grid, float lat, float lon) throws VisADException, RemoteException
      Sample the grid at the position defined by the EarthLocation
      Parameters:
      grid - grid to sample (must be a valid 3D grid)
      lat - EarthLocation to sample at.
      lon - EarthLocation to sample at.
      Returns:
      grid representing the values of the original grid at the point defined by location. If this is a sequence of grids it will be a sequence of the values.
      Throws:
      VisADException - invalid point or some other problem
      RemoteException
    • sample

      public static FieldImpl sample(FieldImpl grid, EarthLocation location, int samplingMode) throws VisADException
      Sample the grid at the position defined by the EarthLocation
      Parameters:
      grid - grid to sample (must be a valid 3D grid)
      location - EarthLocation to sample at.
      samplingMode - Data.WEIGHTED_AVERAGE or NEAREST_NEIGHBOR
      Returns:
      grid representing the values of the original grid at the point defined by location. If this is a sequence of grids it will be a sequence of the values.
      Throws:
      VisADException - invalid point or some other problem
    • sample

      public static FieldImpl sample(FieldImpl grid, EarthLocation location, int samplingMode, int errorMode) throws VisADException
      Sample the grid at the position defined by the EarthLocation with the VisAD resampling method given.
      Parameters:
      grid - grid to sample (must be a valid 3D grid)
      location - EarthLocation to sample at.
      samplingMode - Data.WEIGHTED_AVERAGE or NEAREST_NEIGHBOR
      errorMode - Data.NO_ERRORS, Data.DEPENDENT, Data.INDEPENDENT
      Returns:
      grid representing the values of the original grid at the point defined by location. If this is a sequence of grids it will be a sequence of the values.
      Throws:
      VisADException - invalid point or some other problem
    • sample

      public static FieldImpl sample(FieldImpl grid, LatLonPoint point) throws VisADException
      Sample the grid at the position defined by the LatLonPoint
      Parameters:
      grid - grid to sample (must be a valid 3D grid)
      point - LatLonPoint to sample at.
      Returns:
      grid representing the values of the original grid at the point defined by point. If this is a sequence of grids it will be a sequence of the values.
      Throws:
      VisADException - invalid point or some other problem
    • sample

      public static FieldImpl sample(FieldImpl grid, LatLonPoint point, int samplingMode) throws VisADException
      Sample the grid at the position defined by the LatLonPoint
      Parameters:
      grid - grid to sample (must be a valid 3D grid)
      point - LatLonPoint to sample at.
      samplingMode - Data.WEIGHTED_AVERAGE or NEAREST_NEIGHBOR
      Returns:
      grid representing the values of the original grid at the point defined by point. If this is a sequence of grids it will be a sequence of the values.
      Throws:
      VisADException - invalid point or some other problem
    • sample

      public static FieldImpl sample(FieldImpl grid, LatLonPoint point, int samplingMode, int errorMode) throws VisADException
      Sample the grid at the position defined by the LatLonPoint
      Parameters:
      grid - grid to sample (must be a valid 3D grid)
      point - LatLonPoint to sample at.
      samplingMode - Data.WEIGHTED_AVERAGE or NEAREST_NEIGHBOR
      errorMode - Data.NO_ERRORS, Data.DEPENDENT, Data.INDEPENDENT
      Returns:
      grid representing the values of the original grid at the point defined by point. If this is a sequence of grids it will be a sequence of the values.
      Throws:
      VisADException - invalid point or some other problem
    • slice

      public static FieldImpl slice(FieldImpl grid, SampledSet slice) throws VisADException
      Slice the grid at the positions defined by a SampledSet.
      Parameters:
      grid - grid to slice (must be a valid 3D grid)
      slice - set of points to sample on. It must be compatible with the spatial domain of the grid.
      Returns:
      a FieldImpl the grid representing the values of the original grid at the points defined by slice. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - invalid slice or some other problem
    • slice

      public static FieldImpl slice(FieldImpl grid, SampledSet slice, int samplingMode) throws VisADException
      Slice the grid at the positions defined by a SampledSet.
      Parameters:
      grid - grid to slice (must be a valid 3D grid)
      slice - set of points to sample on. It must be compatible with the spatial domain of the grid.
      samplingMode - Data.WEIGHTED_AVERAGE or NEAREST_NEIGHBOR
      Returns:
      a FieldImpl the grid representing the values of the original grid at the points defined by slice. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - invalid slice or some other problem
    • slice

      public static FieldImpl slice(FieldImpl grid, SampledSet slice, int samplingMode, int errorMode) throws VisADException
      Slice the grid at the positions defined by a SampledSet.
      Parameters:
      grid - grid to slice (must be a valid 3D grid)
      slice - set of points to sample on. It must be compatible with the spatial domain of the grid.
      samplingMode - Data.WEIGHTED_AVERAGE or NEAREST_NEIGHBOR
      errorMode - Data.NO_ERRORS, Data.DEPENDENT, Data.INDEPENDENT
      Returns:
      a FieldImpl the grid representing the values of the original grid at the points defined by slice. If this is a sequence of grids it will be a sequence of the slices.
      Throws:
      VisADException - invalid slice or some other problem
    • make2DGridFromSlice

      public static FieldImpl make2DGridFromSlice(FieldImpl slice) throws VisADException
      Transform a 2D slice (3D grid with 2D manifold) into a 2D grid.
      Parameters:
      slice - slice to transform
      Returns:
      slice as a 2D grid
      Throws:
      VisADException - unable to create 2D slice
    • make2DGridFromSlice

      public static FieldImpl make2DGridFromSlice(FieldImpl slice, boolean copy) throws VisADException
      Transform a 2D slice (3D grid with 2D manifold) into a 2D grid.
      Parameters:
      slice - slice to transform
      copy - true to copy data
      Returns:
      slice as a 2D grid
      Throws:
      VisADException - unable to create 2D slice
    • getParamUnits

      public static Unit[] getParamUnits(FieldImpl grid) throws VisADException
      Get the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range
      Parameters:
      grid - grid to check
      Returns:
      TupleType of lowest element
      Throws:
      VisADException - unable to get at data types
    • printit

      public static String printit(FieldImpl field) throws VisADException, RemoteException
      Print the type of the sample of a data object
      Parameters:
      field - the field
      Returns:
      the data type
      Throws:
      RemoteException - java RMI problem
      VisADException - unable to get at data types
    • getParamType

      public static TupleType getParamType(FieldImpl grid) throws VisADException
      Get the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range
      Parameters:
      grid - grid to check
      Returns:
      TupleType of lowest element
      Throws:
      VisADException - unable to get at data types
    • getParam

      public static FieldImpl getParam(FieldImpl grid, int index) throws VisADException
      Extract the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range
      Parameters:
      grid - grid to check
      index - parameter index
      Returns:
      TupleType of lowest element
      Throws:
      VisADException - unable to get at data types
    • getParam

      public static FieldImpl getParam(FieldImpl grid, int index, boolean copy) throws VisADException
      Extract the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range
      Parameters:
      grid - grid to check
      index - parameter index
      copy - true to make a copy
      Returns:
      TupleType of lowest element
      Throws:
      VisADException - unable to get at data types
    • setParamType

      public static FieldImpl setParamType(FieldImpl grid, String newName) throws VisADException
      Set the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range. Data is replicated.
      Parameters:
      grid - grid to change
      newName - name of new parameter
      Returns:
      a new FieldImpl with the new parameter type
      Throws:
      VisADException - problem setting new parameter
    • setParamType

      public static FieldImpl setParamType(FieldImpl grid, String newName, boolean copy) throws VisADException
      Set the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range. Data is replicated.
      Parameters:
      grid - grid to change
      newName - name of new parameter
      copy - true to make a copy
      Returns:
      a new FieldImpl with the new parameter type
      Throws:
      VisADException - problem setting new parameter
    • setParamType

      public static FieldImpl setParamType(FieldImpl grid, String[] newNames, boolean copy) throws VisADException
      Set the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range. Data is replicated.
      Parameters:
      grid - grid to change
      newNames - names of new parameters
      copy - true to make a copy
      Returns:
      a new FieldImpl with the new parameter type
      Throws:
      VisADException - problem setting new parameter
    • setParamType

      public static FieldImpl setParamType(FieldImpl grid, RealType newParam) throws VisADException
      Set the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range. Data is replicated.
      Parameters:
      grid - grid to change
      newParam - MathType of new parameter
      Returns:
      a new FieldImpl with the new parameter type
      Throws:
      VisADException - problem setting new parameter
    • setParamType

      public static FieldImpl setParamType(FieldImpl grid, RealType newParam, boolean copy) throws VisADException
      Set the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range.
      Parameters:
      grid - grid to change
      newParam - RealType of new parameter
      copy - true to copy data
      Returns:
      a new FieldImpl with the new parameter type
      Throws:
      VisADException - problem setting new parameter
    • setParamType

      public static FieldImpl setParamType(FieldImpl grid, TupleType newParam) throws VisADException
      Set the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range. Data is replicated.
      Parameters:
      grid - grid to change
      newParam - MathType of new parameter
      Returns:
      a new FieldImpl with the new parameter type
      Throws:
      VisADException - problem setting new parameter
    • setParamType

      public static FieldImpl setParamType(FieldImpl grid, TupleType newParam, boolean copy) throws VisADException
      Set the range MathType of the lowest element. If this is a sequence, it will be the range type of the individual elements. If not, it will be the range.
      Parameters:
      grid - grid to change
      newParam - MathType of new parameter
      copy - true to copy the data
      Returns:
      a new FieldImpl with the new parameter type
      Throws:
      VisADException - problem setting new parameter
    • extractParam

      public static FieldImpl extractParam(FieldImpl grid, ScalarType param) throws VisADException
      Extract the param from a sequence, it will be the range type of the individual elements. If not, it will be the range.
      Parameters:
      grid - grid to change
      param - MathType of new parameter
      Returns:
      grid with just param in it
      Throws:
      VisADException - problem setting new parameter
    • extractParam

      public FieldImpl extractParam(FieldImpl grid, MathType paramType) throws VisADException
      Extract a single parameter from a grid of multiple parameters.
      Parameters:
      grid - to extract from
      paramType - param to extract
      Returns:
      grid with just that param in it
      Throws:
      VisADException - some problem occured (like the param isn't in the grid)
    • normalizeLongitude

      public static Real normalizeLongitude(SampledSet domain, Real lon) throws VisADException
      Make sure a longitude value for use in a spatial domain Set with Longitude in the spatial domain is inside the spatial domain's longitude range. If not, then adjust so that it is. If domain not of such coordinates, do nothing and return input value.
      Parameters:
      domain - domain set of value for normalization
      lon - longitude
      Returns:
      normalized longitude
      Throws:
      VisADException - problem accessing set
    • normalizeLongitude

      public static double normalizeLongitude(SampledSet domain, double lon) throws VisADException
      Make sure a longitude value for use in a spatial domain Set with Longitude in the spatial domain is inside the spatial domain's longitude range. If not, then adjust so that it is. If domain not of such coordinates, do nothing and return input value.
      Parameters:
      domain - domain set of value for normalization
      lon - longitude values
      Returns:
      normalized longitude
      Throws:
      VisADException - problem accessing set
    • normalizeLongitude

      public static double normalizeLongitude(SampledSet domain, double lon, Unit lonUnit) throws VisADException
      Make sure a longitude value for use in a spatial domain Set with Longitude in the spatial domain is inside the spatial domain's longitude range. If not, then adjust so that it is. If domain not of such coordinates, do nothing and return input value.
      Parameters:
      domain - domain set of value for normalization
      lon - longitude values
      lonUnit - longitude unit
      Returns:
      normalized longitude
      Throws:
      VisADException - problem accessing set
    • makeRadarMapProjection

      public static MapProjection makeRadarMapProjection(CoordinateSystem radarCS) throws VisADException
      Return a MapProjection that relates to the Radar*DCoordinateSystem.
      Parameters:
      radarCS - radar coordinate system (Radar2DCoordinateSystem or Radar3DCoordinateSystem)
      Returns:
      MapProjection corresponding to the radar CS
      Throws:
      VisADException - problem creating MapProjection.
    • resampleGrid

      public static FieldImpl resampleGrid(FieldImpl grid, SampledSet subDomain) throws VisADException
      Resample the grid at the positions defined by a SampledSet using the default methods and error propagation.
      Parameters:
      grid - grid to resample (must be a valid 3D grid)
      subDomain - set of points to sample on. It must be compatible with the spatial domain of the grid.
      Returns:
      a FieldImpl the grid representing the values of the original grid at the points defined by subDomain. If this is a sequence of grids it will be a sequence of the resamples.
      Throws:
      VisADException - invalid subDomain or some other problem
    • resampleGrid

      public static FieldImpl resampleGrid(FieldImpl grid, SampledSet subDomain, int samplingMode) throws VisADException
      Resample the grid at the positions defined by a SampledSet using the method specified and default error propagation.
      Parameters:
      grid - grid to resample (must be a valid 3D grid)
      subDomain - set of points to sample on. It must be compatible with the spatial domain of the grid.
      samplingMode - sampling method to use for slicing
      Returns:
      a FieldImpl the grid representing the values of the original grid at the points defined by sampling set. If this is a sequence of grids it will be a sequence of the subsamples.
      Throws:
      VisADException - invalid subDomain or some other problem
    • getCenterPoint

      public static RealTuple getCenterPoint(FieldImpl grid) throws VisADException
      Method to get the center point of a grid's spatial domain as a RealTuple.
      Parameters:
      grid - grid to evaluate
      Returns:
      center point (x,y,z) of the grid in native coordinates. If the domain has a CoordinateSystem (e.g.,  (x,y,z) -> (lat,lon,alt)  that will be included in the returned tuple.
      Throws:
      VisADException - problem accessing the data
    • getCenterPoint

      public static RealTuple getCenterPoint(SampledSet spatialDomain) throws VisADException
      Method to get the center point of a spatial domain as a RealTuple.
      Parameters:
      spatialDomain - domain to evaluate
      Returns:
      center point (x,y,z) of the domain in native coordinates. If the domain has a CoordinateSystem (e.g.,  (x,y,z) -> (lat,lon,alt)  that will be included in the returned tuple.
      Throws:
      VisADException - problem accessing the data
    • getCenterLatLonPoint

      public static LatLonPoint getCenterLatLonPoint(FieldImpl grid) throws VisADException
      Get the latitude/longitude point at the center of the grid.
      Parameters:
      grid - grid to evaluate
      Returns:
      center lat/lon or null if not navigated
      Throws:
      VisADException - problem accessing the data
    • getCenterLatLonPoint

      public static LatLonPoint getCenterLatLonPoint(SampledSet spatialDomain) throws VisADException
      Get the latitude/longitude point at the center of the domain.
      Parameters:
      spatialDomain - domain to evaluate
      Returns:
      center lat/lon or null if not navigated
      Throws:
      VisADException - problem accessing the data
    • resampleGrid

      public static FieldImpl resampleGrid(FieldImpl grid, SampledSet subDomain, int samplingMode, int errorMode) throws VisADException
      Resample the grid at the positions defined by a SampledSet.
      Parameters:
      grid - grid to resample (must be a valid 3D grid)
      subDomain - set of points to sample on. It must be compatible with the spatial domain of the grid.
      samplingMode - sampling method to use for slicing
      errorMode - error method to use for error propagation
      Returns:
      a FieldImpl the grid representing the values of the original grid at the points defined by subDomain. If this is a sequence of grids it will be a sequence of the subsets.
      Throws:
      VisADException - invalid subDomain or some other problem
    • getLevel

      public static Real getLevel(FieldImpl grid, Real altitude) throws VisADException
      Get the altitude corresponding to the level specified using the domain of the grid.
      Parameters:
      grid - grid to use
      altitude - altitude to convert.
      Returns:
      corresponding value of the vertical dimension of the grid. May be missing if conversion can't happen.
      Throws:
      VisADException - for bad
    • getAltitude

      public static Real getAltitude(FieldImpl grid, Real level) throws VisADException
      Get the altitude corresponding to the level specified using the domain of the grid.
      Parameters:
      grid - grid to use
      level - must be compatible (unit wise) with vertical coordinate of the grid
      Returns:
      altitude (in m) corresponding to level using coordinate system of the grid's domain. May be missing if conversion can't happen.
      Throws:
      VisADException - VisAD error
    • getAltitude

      public static Real getAltitude(SampledSet domainSet, Real level) throws VisADException
      Get the altitude corresponding to the level specified using the domain of the grid.
      Parameters:
      domainSet - sampledSet to use
      level - must be compatible (unit wise) with vertical coordinate of the grid
      Returns:
      altitude (in m) corresponding to level using coordinate system of the grid's domain. May be missing if conversion can't happen.
      Throws:
      VisADException - VisAD error
    • getVerticalType

      public static RealType getVerticalType(FieldImpl grid) throws VisADException
      Get the RealType of the vertical dimension of the spatial domain of the grid.
      Parameters:
      grid - grid to check
      Returns:
      RealType of the vertical dimension of the grid's spatial domain
      Throws:
      VisADException - problem getting the type
    • getVerticalType

      public static RealType getVerticalType(SampledSet domainSet) throws VisADException
      Get the unit of the vertical dimension of the domain set.
      Parameters:
      domainSet - domainSet to check
      Returns:
      RealType of the vertical dimension domainSet
      Throws:
      VisADException - problem getting the type
    • getVerticalUnit

      public static Unit getVerticalUnit(FieldImpl grid) throws VisADException
      Get the unit of the vertical dimension of the spatial domain of the grid.
      Parameters:
      grid - domain to check
      Returns:
      unit of the raw vertical data in the grid's domain set.
      Throws:
      VisADException - problem getting the unit
    • getVerticalUnit

      public static Unit getVerticalUnit(SampledSet domainSet) throws VisADException
      Get the unit of the vertical dimension of the domain.
      Parameters:
      domainSet - domain to check
      Returns:
      unit of the raw data in the domainSet
      Throws:
      VisADException - problem getting the unit
    • canSliceAtLevel

      public static boolean canSliceAtLevel(FieldImpl grid, Real level) throws VisADException
      Determine whether the grid in question can be sliced at the level specified (i.e., units or CS allows this)
      Parameters:
      grid - grid in question
      level - level in question
      Returns:
      true if the level is compatible with the grid.
      Throws:
      VisADException - problem creating VisAD object
    • canSliceAtLevel

      public static boolean canSliceAtLevel(SampledSet spatialSet, Real level) throws VisADException
      Determine whether the set in question can be sliced at the level specified (i.e., units or CS allows this)
      Parameters:
      spatialSet - domain set to check
      level - level in question
      Returns:
      true if the level is compatible with the grid.
      Throws:
      VisADException - problem creating VisAD object
    • fieldMinMax

      public static Range[] fieldMinMax(FlatField field) throws VisADException, RemoteException
      Find min and max of range data in any VisAD FlatField
      Parameters:
      field - a VisAD FlatField. Cannot be null
      Returns:
      the range of the data. Dimension is the number of parameters in the range of the flat field
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD Error
    • makeRange

      public static Range makeRange(DataRange range)
      Make a range from a VisAD data range
      Parameters:
      range - the data range
      Returns:
      range
    • makeRanges

      public static Range[] makeRanges(DataRange[] range)
      Make an array of Ranges from an array of DataRanges
      Parameters:
      range - the DataRanges
      Returns:
      the Ranges
    • makeDataRange

      public static DataRange makeDataRange(Range range)
      Make a DataRange from a Range
      Parameters:
      range - the Range
      Returns:
      the DataRange
    • makeDataRanges

      public static DataRange[] makeDataRanges(Range[] range)
      Make an array of DataRanges from an array of Ranges
      Parameters:
      range - the Ranges
      Returns:
      DataRanges
    • getMinMax

      public static Range[] getMinMax(FieldImpl fieldImpl) throws VisADException, RemoteException
      get max and min of all range values in the current active fieldImpl
      Parameters:
      fieldImpl - input field with outer dimension of time
      Returns:
      range of all parameters in the field
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD Error
    • printModes

      public static String printModes(int samplingMode, int errorMode)
      Print out the sampling and error modes modes
      Parameters:
      samplingMode - sampling mode
      errorMode - error mode
      Returns:
      String for these modes
    • getGridAsPointObs

      public static FieldImpl getGridAsPointObs(FieldImpl grid) throws VisADException
      Convert a grid to point obs
      Parameters:
      grid - grid to convert
      Returns:
      Field of point observations for each point
      Throws:
      VisADException - problem getting data
    • getEarthLocationPoints

      public static float[][] getEarthLocationPoints(GriddedSet domain) throws VisADException
      Convert the domain to the reference earth located points
      Parameters:
      domain - the domain set
      Returns:
      the lat/lon/(alt) points
      Throws:
      VisADException - problem converting points
    • findContainedIndices

      public static int[][] findContainedIndices(GriddedSet domain, UnionSet map) throws VisADException
      Find the indices of the domain values contained in the map
      Parameters:
      domain - domain to use
      map - the map lines containing bounding polygons
      Returns:
      indices in the domain
      Throws:
      VisADException - problem sampling
    • findContainedIndices

      public static int[][] findContainedIndices(float[][] latlon, UnionSet map) throws VisADException
      Find the indices of the latlon values contained in the map
      Parameters:
      latlon - set of lat/lon values
      map - the map lines containing bounding polygons
      Returns:
      indices in the domain
      Throws:
      VisADException - problem sampling
    • findNotContainedIndices

      public static int[][] findNotContainedIndices(GriddedSet domain, UnionSet map) throws VisADException
      find the indices not contained in the map domian
      Parameters:
      domain - grid domain
      map - map of values
      Returns:
      array of indicies
      Throws:
      VisADException - problem getting at the data
    • findNotContainedIndices

      public static int[][] findNotContainedIndices(float[][] latlon, UnionSet map) throws VisADException
      Find the indices of the latlon values contained in the map
      Parameters:
      latlon - set of lat/lon values
      map - the map lines containing bounding polygons
      Returns:
      indices in the domain
      Throws:
      VisADException - problem sampling
    • getLatLons

      public static float[][][] getLatLons(GriddedSet domain, int[][] indices) throws VisADException
      Find the lat/lon values in the given spatial domain for the given indices
      Parameters:
      domain - domain to use
      indices - index array we get from findContainedIndices methods. i.e., indices[numPolygons][numIndices]
      Returns:
      the lat lons of the form:
       float[numPolygonPoints][2][numPoints]
      Throws:
      VisADException - problem sampling
    • getLatLons

      public static float[][][] getLatLons(float[][] latlons, int[][] indices) throws VisADException
      Find the lat/lon values in the given spatial domain for the given indices
      Parameters:
      latlons - lat/lons from the spatial domain
      indices - index array we get from findContainedIndices methods. i.e., indices[numPolygons][numIndices]
      Returns:
      the lat lons of the form:
       float[numPolygonPoints][2][numPoints]
      Throws:
      VisADException - problem sampling
    • findContainedLatLons

      public static float[][][] findContainedLatLons(GriddedSet domain, UnionSet maps) throws VisADException
      Find the lat/lon values in the given spatial domain contained by the polygons in the given map set
      Parameters:
      domain - domain to use
      maps - The maps
      Returns:
      the lat lons of the form:
       float[numPolygonPoints][2][numPoints]
      Throws:
      VisADException - problem sampling
    • findContainedLatLons

      public static float[][][] findContainedLatLons(float[][] latlons, UnionSet maps) throws VisADException
      Find the lat/lon values in the given spatial domain contained by the polygons in the given map set
      Parameters:
      latlons - the lat/lons from the domain
      maps - The maps
      Returns:
      the lat lons of the form:
       float[numPolygonPoints][2][numPoints]
      Throws:
      VisADException - problem sampling
    • findIndicesInsideRange

      public static int[][] findIndicesInsideRange(float[][] values, float min, float max) throws VisADException
      Finds the indices of the values array whose value is in the given range
      Parameters:
      values - values
      min - min value
      max - max value
      Returns:
      indices
      Throws:
      VisADException - On badness
    • findIndicesOutsideRange

      public static int[][] findIndicesOutsideRange(float[][] values, float min, float max) throws VisADException
      Finds the indices of the values array whose value is not in the given range
      Parameters:
      values - values
      min - min value
      max - max value
      Returns:
      indices
      Throws:
      VisADException - On badness
    • getLatLon

      public static float[][] getLatLon(GriddedSet domain) throws VisADException
      Convert the domain to the reference earth located points. If the domain is not in lat/lon order then reset the order so that result[0] is the latitudes, result[1] is the longitudes
      Parameters:
      domain - the domain set
      Returns:
      the lat/lon/(alt) points
      Throws:
      VisADException - problem converting points
    • getLatLonRect

      public static ucar.unidata.geoloc.LatLonRect getLatLonRect(GriddedSet domain) throws VisADException
      Convert the domain to the latlonRect
      Parameters:
      domain - the domain set
      Returns:
      the latlonrect
      Throws:
      VisADException - problem converting points
    • max

      public static float max(float[] array)
    • min

      public static float min(float[] array)
    • main

      public static void main(String[] args) throws Exception
      test
      Parameters:
      args - args
      Throws:
      Exception - On badness
    • writeGridToXls

      public static void writeGridToXls(FieldImpl grid) throws Exception
      Write grid out to an Excel spreadsheet
      Parameters:
      grid - grid to write
      Throws:
      Exception - problem writing grid
    • writeGridToXls

      public static void writeGridToXls(FieldImpl grid, String filename) throws Exception
      Write grid out to an Excel spreadsheet
      Parameters:
      grid - grid to write
      filename - filename
      Throws:
      Exception - problem writing grid
    • writeGridAtPolygonToXls

      public static void writeGridAtPolygonToXls(FieldImpl grid, String filename, String fxgrfName) throws Exception
      extract grid along polygon and write out to an Excel spreadsheet
      Parameters:
      grid - grid to write
      filename - filename
      fxgrfName - xgrf filename
      Throws:
      Exception - problem writing grid
    • writeGridToCsv

      public static void writeGridToCsv(FieldImpl grid, String filename) throws Exception
      Write grid out to a CSV ascii file
      Parameters:
      grid - grid to write
      filename - filename
      Throws:
      Exception - problem writing grid
    • exportGridToNetcdf

      public static void exportGridToNetcdf(FieldImpl grid) throws Exception
      Write grid out to a netCDF CF compliant file
      Parameters:
      grid - grid to write
      Throws:
      Exception - problem writing grid
    • exportGridToNetcdf

      public static void exportGridToNetcdf(FieldImpl grid, String filename) throws Exception
      Write grid out to a netCDF CF compliant file
      Parameters:
      grid - grid to write
      filename - filename
      Throws:
      Exception - problem writing grid
    • setPressureValues

      public static FieldImpl setPressureValues(FieldImpl grid, float[] pressValues) throws VisADException
      Set the pressure values for a grid
      Parameters:
      grid - grid to change
      pressValues - pressure values. Must match number of levels in the grid. Units are millibars.
      Returns:
      a grid with vertical levels in pressure
      Throws:
      VisADException - problem setting the values
    • setAltitudeValues

      public static FieldImpl setAltitudeValues(FieldImpl grid, float[] altValues) throws VisADException
      Set the altitude values for a grid
      Parameters:
      grid - grid to change
      altValues - altitude values. Must match number of levels in the grid. Units are meters.
      Returns:
      a grid with vertical levels in meters
      Throws:
      VisADException - problem setting the values
    • setVerticalValues

      public static FieldImpl setVerticalValues(FieldImpl grid, float[] newValues, RealType vertType, Unit vertUnit) throws VisADException
      Set the vertical values
      Parameters:
      grid - the grid to change
      newValues - the new vertical values. Must match the number of vertical levels in the grid.
      vertType - the type of the data
      vertUnit - the unit of newValues
      Returns:
      modified grid
      Throws:
      VisADException - problem setting the values
    • findMinMaxAverage

      public static List<FieldStats> findMinMaxAverage(FieldImpl field, UnionSet mapSets) throws VisADException, RemoteException
      Find the min/max and average of a file inside the mapsets
      Parameters:
      field - the field
      mapSets - The map sets
      Returns:
      the list of FieldStats
      Throws:
      RemoteException - Java RMI problem
      VisADException - problem getting the values
    • findMinMaxAverageFromRange

      public static FieldStats findMinMaxAverageFromRange(FlatField field, UnionSet mapSets) throws VisADException, RemoteException
      Find the min, max and average from the range
      Parameters:
      field - the field
      mapSets - the mapsets
      Returns:
      the stats
      Throws:
      RemoteException - Java RMI error
      VisADException - VisAD Data error
    • canSwapLatLon

      public static boolean canSwapLatLon(FieldImpl grid) throws VisADException
      Can the lat/lons be swapped?
      Parameters:
      grid - to check
      Returns:
      true if 2D and no CS and either lat/lon or lon/lat
      Throws:
      VisADException - problem determining if we can swap
    • swapLatLon

      public static FieldImpl swapLatLon(FieldImpl grid) throws VisADException
      Swap the lat/lon coordinates of the grid. Grid must be 2D and have no coordinate system
      Parameters:
      grid - grid to swap
      Returns:
      lat/lon swapped grid
      Throws:
      VisADException - VisAD problem
    • smooth

      public static FieldImpl smooth(FieldImpl slice, String type) throws VisADException
      Smooth a 2D field
      Parameters:
      slice - the 2D slice
      type - the type of smoothing (SMOOTH_5POINT, etc)
      Returns:
      the smoothed grid or null
      Throws:
      VisADException - VisAD Error
    • smooth

      public static FieldImpl smooth(FieldImpl slice, String type, int filterLevel) throws VisADException
      Smooth a 2D field
      Parameters:
      slice - the 2D slice
      type - the type of smoothing (SMOOTH_5POINT, etc)
      filterLevel - level of filtering (used for SMOOTH_GAUSSIAN only)
      Returns:
      the smoothed grid or null
      Throws:
      VisADException - VisAD Error
    • makeGrid

      public static float[][] makeGrid(float[][] grid2D, int numCols, int numRows, float missingValue)
      Make a grid structure
      Parameters:
      grid2D - the values
      numCols - number of columns
      numRows - number of rows
      missingValue - the missing value
      Returns:
      the grid structure
    • makeGrid

      public static float[][] makeGrid(float[][][] grid2D, int numCols, int numRows, float missingValue)
      Make a grid structure
      Parameters:
      grid2D - the values
      numCols - number of columns
      numRows - number of rows
      missingValue - the missing value
      Returns:
      the grid structure
    • fillMissing

      public static void fillMissing(float[][] grid2D, float missingValue)
      Fill a structure with missing values with nearby grid values
      Parameters:
      grid2D - grid structure
      missingValue - missing value
    • lonFlip

      public static FieldImpl lonFlip(FieldImpl grid) throws VisADException, RemoteException
      Flip the grid along the central longitude. Useful for converting 0-360 to -180 to 180 or vice-versa.
      Parameters:
      grid - the grid to flip
      Returns:
      the flipped grid
      Throws:
      RemoteException - Java RMI problem
      VisADException - VisAD problem reading data
    • isLonCyclic

      public static boolean isLonCyclic(double first, double last)
      Check to see if the longitude values are cyclic within the default epsilon (i.e., last == first+360 +- 0.0005)
      Parameters:
      first - first value
      last - last value
      Returns:
      true if they are cyclic
    • isLonCyclic

      public static boolean isLonCyclic(double first, double last, double epsilon)
      Check to see if the longitude values are cyclic (i.e., last == first+360 within esplion)
      Parameters:
      first - first value
      last - last value
      epsilon - last value
      Returns:
      true if they are cyclic
    • read

      public static List<DrawingGlyph> read(String filename)
      respond to the read data call and return list of Glyph
      Parameters:
      filename - input file name
      Returns:
      list of drawinglyph
    • parseXml

      public static List parseXml(Element root, boolean initialXml) throws VisADException, RemoteException
      Process the glyph xml with only polygon glyph.
      Parameters:
      root - Root of the xml dom
      initialXml - Did this come from the data choice or from an import
      Returns:
      list of glyph
      Throws:
      RemoteException - When bad things happen
      VisADException - When bad things happen
    • glyphsToMap

      public static UnionSet glyphsToMap(GriddedSet domainSet, List glyphs) throws Exception
      Process the glyph to Unionset.
      Parameters:
      domainSet - domain set
      glyphs - list of polygon glyph
      Returns:
      unionset
      Throws:
      Exception - for bad
    • medianFilter

      public static FieldImpl medianFilter(FieldImpl field, int window_lenx, int window_leny) throws VisADException, RemoteException, CloneNotSupportedException
      Process medianFilter mean filtering is simply to replace each pixel value in an image with the mean (average) value of its neighbors, including itself
      Parameters:
      field - input
      window_lenx - default value is 10
      window_leny - default value is 10
      Returns:
      the filtered field
      Throws:
      VisADException - for bad
      RemoteException - for bad
      CloneNotSupportedException - for bad
    • medianFilter

      public static FlatField medianFilter(FlatField fltFld, int window_lenx, int window_leny) throws VisADException, RemoteException
      Process medianFilter
      Parameters:
      fltFld - input ff
      window_lenx - default value is 10
      window_leny - default value is 10
      Returns:
      the median filtered flatfield
      Throws:
      VisADException - for bad
      RemoteException - for bad
    • medianFilter

      public static float[] medianFilter(float[] A, int lenx, int leny, int window_lenx, int window_leny) throws VisADException
      Process medianFilter
      Parameters:
      A - array of float
      lenx - x dimension
      leny - y dimension
      window_lenx - x dimension length
      window_leny - y dimension length
      Returns:
      float array
      Throws:
      VisADException - for bad
    • medianFilterOrg

      public static float[] medianFilterOrg(float[] A, int lenx, int leny, int window_lenx, int window_leny) throws VisADException
      Throws:
      VisADException
    • classifier

      public static FieldImpl classifier(FieldImpl field, String classifierStr, String outFileName) throws Exception
      A classifier in machine learning is an algorithm that automatically orders or categorizes data into one or more of a set of “classes.”
      Parameters:
      field - the input field
      classifierStr - input string of classifier
      outFileName - output file name
      Returns:
      the classifier fieldimpl
      Throws:
      Exception - for bad
    • replaceRangeValues

      public static FieldImpl replaceRangeValues(FieldImpl grid, float low, float high, float newValue) throws VisADException, RemoteException
      Process for classifier
      Parameters:
      grid - the input field
      low - lower range
      high - higher range
      newValue - replace value
      Returns:
      the field with new values
      Throws:
      VisADException - for bad
      RemoteException - for bad
    • yeoJohnsonTransform

      public static double[] yeoJohnsonTransform(double[] data, double lambda)
    • yeoJohnsonTransform

      public static float[] yeoJohnsonTransform(float[] data, double lambda)
    • findOptimalLambda

      public static double findOptimalLambda(double[] data, double minLambda, double maxLambda, double stepSize)
    • findOptimalLambda

      public static double findOptimalLambda(float[] data, double minLambda, double maxLambda, double stepSize)
    • logLikelihood

      public static double logLikelihood(double[] data, double lambda)
    • mean

      public static double mean(double[] data)