ucar.unidata.data.grid
Class GridUtil

java.lang.Object
  extended by ucar.unidata.data.grid.GridUtil

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 Summary
static int DEFAULT_ERROR_MODE
          Default error mode used for subsampling grids
static int DEFAULT_SAMPLING_MODE
          Default sampling mode used for subsampling grids
 
Constructor Summary
GridUtil()
          Default ctor
 
Method Summary
static boolean canSliceAtLevel(FieldImpl grid, Real level)
          Determine whether the grid in question can be sliced at the level specified (i.e., units or CS allows this)
static boolean canSliceAtLevel(SampledSet spatialSet, Real level)
          Determine whether the set in question can be sliced at the level specified (i.e., units or CS allows this)
 FieldImpl extractParam(FieldImpl grid, MathType paramType)
          Extract a single parameter from a grid of multiple parameters.
static FieldImpl extractParam(FieldImpl grid, ScalarType param)
          Extract the param from a sequence, it will be the range type of the individual elements.
static Range[] fieldMinMax(FlatField field)
          Find min and max of range data in any VisAD FlatField
static int[][] findContainedIndices(float[][] latlon, UnionSet map)
          Find the indices of the latlon values contained in the map
static int[][] findContainedIndices(GriddedSet domain, UnionSet map)
          Find the indices of the domain values contained in the map
static Real getAltitude(FieldImpl grid, Real level)
          Get the altitude corresponding to the level specified using the domain of the grid.
static LatLonPoint getCenterLatLonPoint(FieldImpl grid)
          Get the latitude/longitude point at the center of the grid.
static LatLonPoint getCenterLatLonPoint(SampledSet spatialDomain)
          Get the latitude/longitude point at the center of the domain.
static RealTuple getCenterPoint(FieldImpl grid)
          Method to get the center point of a grid's spatial domain as a RealTuple.
static RealTuple getCenterPoint(SampledSet spatialDomain)
          Method to get the center point of a spatial domain as a RealTuple.
static List getDateTimeList(FieldImpl grid)
          Get the list of DateTime objects from the domain of the given grid
static float[][] getEarthLocationPoints(GriddedSet domain)
          Convert the domain to the reference earth located points
static FieldImpl getGridAsPointObs(FieldImpl grid)
          Convert a grid to point obs
static float[][] getLatLon(GriddedSet domain)
          Convert the domain to the reference earth located points.
static Real getLevel(FieldImpl grid, Real altitude)
          Get the altitude corresponding to the level specified using the domain of the grid.
static Range[] getMinMax(FieldImpl fieldImpl)
          get max and min of all range values in the current active fieldImpl
static MapProjection getNavigation(FieldImpl grid)
          Get the navigation for this grid
static MapProjection getNavigation(SampledSet spatialSet)
          Get the navigation for this spatialDomain
static FieldImpl getParam(FieldImpl grid, int index)
          Extract the range MathType of the lowest element.
static FieldImpl getParam(FieldImpl grid, int index, boolean copy)
          Extract the range MathType of the lowest element.
static TupleType getParamType(FieldImpl grid)
          Get the range MathType of the lowest element.
static Unit[] getParamUnits(FieldImpl grid)
          Get the range MathType of the lowest element.
static FieldImpl getProfileAtLatLonPoint(FieldImpl grid, LatLonPoint point)
          Returns a vertical profile of a grid at a Lat/Lon point.
static FieldImpl getProfileAtLatLonPoint(FieldImpl grid, LatLonPoint point, int samplingMode)
          Returns a vertical profile of a grid at a Lat/Lon point.
static RealType getSequenceType(FieldImpl grid)
          Get the RealType of the sequence.
static SampledSet getSpatialDomain(FieldImpl grid)
          Get the spatial domain for this grid.
static SampledSet getSpatialDomain(FieldImpl grid, int timeIndex)
          Get the spatial domain for this grid at the specified time step.
static Set getTimeSet(FieldImpl grid)
          Get the time set from the grid.
static RealType getVerticalType(FieldImpl grid)
          Get the RealType of the vertical dimension of the spatial domain of the grid.
static RealType getVerticalType(SampledSet domainSet)
          Get the unit of the vertical dimension of the domain set.
static Unit getVerticalUnit(FieldImpl grid)
          Get the unit of the vertical dimension of the spatial domain of the grid.
static Unit getVerticalUnit(SampledSet domainSet)
          Get the unit of the vertical dimension of the domain.
static boolean is2D(FieldImpl grid)
          Check to see if this is a 2D grid
static boolean is2D(SampledSet domainSet)
          Check to see if this is a 2D domain
static boolean is3D(FieldImpl grid)
          Check to see if this is a 3D grid
static boolean is3D(SampledSet domainSet)
          Check to see if this is a 3D domain
static boolean isAllMissing(FieldImpl field)
          Check if all real values in a FieldImpl are missing.
static boolean isAllMissing(FieldImpl grid, boolean popupErrorMessage)
          Check if all real values in a FieldImpl are missing.
static boolean isConstantSpatialDomain(FieldImpl grid)
          See if the spatial domain of this grid is constant (ie: not time varying)
static boolean isGrid(FieldImpl field)
          Check to see if this field is a grid that can be handled by these methods
static boolean isLatLonOrder(FieldImpl grid)
          Check to see if this is a navigated grid (domain can be converted to lat/lon)
static boolean isLatLonOrder(SampledSet spatialSet)
          Check to see if this is a navigated domain (can be converted to lat/lon)
static boolean isNavigated(FieldImpl grid)
          Check to see if this is a navigated grid (domain can be converted to lat/lon)
static boolean isNavigated(SampledSet spatialSet)
          Check to see if this is a navigated domain (can be converted to lat/lon)
static boolean isSequence(FieldImpl grid)
          Check to see if this is a single grid or if it is a sequence of grids.
static boolean isSinglePointDomain(FieldImpl grid)
          See if the domain of the grid is a single point (only 1 x and y value).
static boolean isSinglePointDomain(SampledSet ss)
          See if the domain is a single point (only 1 x and y value).
static boolean isTimeSequence(FieldImpl grid)
          Check to see if this is a single grid or if it is a time sequence of grids.
static boolean isVolume(FieldImpl grid)
          Is the gievn field a volume.
static void main(String[] args)
          test
static FieldImpl make2DGridFromSlice(FieldImpl slice)
          Transform a 2D slice (3D grid with 2D manifold) into a 2D grid.
static FieldImpl make2DGridFromSlice(FieldImpl slice, boolean copy)
          Transform a 2D slice (3D grid with 2D manifold) into a 2D grid.
static MapProjection makeRadarMapProjection(CoordinateSystem radarCS)
          Return a MapProjection that relates to the Radar*DCoordinateSystem.
static String printModes(int samplingMode, int errorMode)
          Print out the sampling and error modes modes
static FieldImpl resampleGrid(FieldImpl grid, SampledSet subDomain)
          Resample the grid at the positions defined by a SampledSet using the default methods and error propagation.
static FieldImpl resampleGrid(FieldImpl grid, SampledSet subDomain, int samplingMode)
          Resample the grid at the positions defined by a SampledSet using the method specified and default error propagation.
static FieldImpl resampleGrid(FieldImpl grid, SampledSet subDomain, int samplingMode, int errorMode)
          Resample the grid at the positions defined by a SampledSet.
static FieldImpl sample(FieldImpl grid, EarthLocation location)
          Sample the grid at the position defined by the EarthLocation
static FieldImpl sample(FieldImpl grid, EarthLocation location, int samplingMode)
          Sample the grid at the position defined by the EarthLocation with the VisAD resampling method given.
static FieldImpl sample(FieldImpl grid, LatLonPoint point)
          Sample the grid at the position defined by the LatLonPoint
static FieldImpl sample(FieldImpl grid, LatLonPoint point, int samplingMode)
          Sample the grid at the position defined by the LatLonPoint
static Real sampleToReal(FieldImpl grid, EarthLocation el, Real animationValue)
          This samples the given grid in both time and space and trys to return a Real value
static FieldImpl setParamType(FieldImpl grid, RealType newParam)
          Set the range MathType of the lowest element.
static FieldImpl setParamType(FieldImpl grid, RealType newParam, boolean copy)
          Set the range MathType of the lowest element.
static FieldImpl setParamType(FieldImpl grid, String newName)
          Set the range MathType of the lowest element.
static FieldImpl setParamType(FieldImpl grid, String[] newNames, boolean copy)
          Set the range MathType of the lowest element.
static FieldImpl setParamType(FieldImpl grid, String newName, boolean copy)
          Set the range MathType of the lowest element.
static FieldImpl setParamType(FieldImpl grid, TupleType newParam)
          Set the range MathType of the lowest element.
static FieldImpl setParamType(FieldImpl grid, TupleType newParam, boolean copy)
          Set the range MathType of the lowest element.
static FieldImpl setSpatialDomain(FieldImpl grid, SampledSet newDomain)
          Change the spatial domain of a grid using the new one.
static FieldImpl setSpatialDomain(FieldImpl grid, SampledSet newDomain, boolean copy)
          Change the spatial domain of a grid using the new one.
static FieldImpl slice(FieldImpl grid, SampledSet slice)
          Slice the grid at the positions defined by a SampledSet.
static FieldImpl slice(FieldImpl grid, SampledSet slice, int samplingMode)
          Slice the grid at the positions defined by a SampledSet.
static FieldImpl sliceAlongLatLonLine(FieldImpl grid, LatLonPoint start, LatLonPoint end)
          Slice the grid along the line specified by the two LatLonPoint-s
static FieldImpl sliceAlongLatLonLine(FieldImpl grid, LatLonPoint start, LatLonPoint end, int samplingMode)
          Slice the grid along the line specified by the two LatLonPoint-s
static FieldImpl sliceAtLevel(FieldImpl grid, double levelValue)
          Slice the grid at the vertical level indictated.
static FieldImpl sliceAtLevel(FieldImpl grid, Real level)
          Slice the grid at the vertical level indictated.
static FieldImpl sliceAtLevel(FieldImpl grid, Real level, int samplingMode)
          Slice the grid at the vertical level indictated.
static FieldImpl subset(FieldImpl grid, int skip)
          Create a subset of the grid, skipping every nth point in the X and Y direction.
static FieldImpl subset(FieldImpl grid, int skipx, int skipy)
          Create a subset of the grid skipping every i'th x and j'th y point.
static FieldImpl subset(FieldImpl grid, int skipx, int skipy, int skipz)
          Create a subset of the grid skipping every i'th x and j'th y point and k'th z point
static void writeGridToXls(FieldImpl grid)
          Write grid out to an Excel spreadsheet
static void writeGridToXls(FieldImpl grid, String filename)
          Write grid out to an Excel spreadsheet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_SAMPLING_MODE

public static final int DEFAULT_SAMPLING_MODE
Default sampling mode used for subsampling grids

See Also:
Constant Field Values

DEFAULT_ERROR_MODE

public static final int DEFAULT_ERROR_MODE
Default error mode used for subsampling grids

See Also:
Constant Field Values
Constructor Detail

GridUtil

public GridUtil()
Default ctor

Method Detail

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

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:
isTimeSequence(FieldImpl)

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 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 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:
isSequence(FieldImpl)

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

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

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

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

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

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

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 - 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

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,
                               EarthLocation location,
                               int samplingMode)
                        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
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

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

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

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,