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

Nested Class Summary
static class GridUtil.Grid2D
          Class Grid2D holds a 2d lat/lon and value array
 
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
static int DEPENDENT_ERRORS
          Dependent error mode
static RealType ENSEMBLE_TYPE
          ensemble RealType
static String FUNC_AVERAGE
          Deprecated. use GridMath.FUNC_AVERAGE
static String FUNC_DIFFERENCE
          Deprecated. use GridMath.FUNC_DIFFERENCE
static String FUNC_MAX
          Deprecated. use GridMath.FUNC_MAX
static String FUNC_MIN
          Deprecated. use GridMath.FUNC_MIN
static String FUNC_SUM
          Deprecated. use GridMath.FUNC_SUM
static int INDEPENDENT_ERRORS
          Independent error mode
static int NEAREST_NEIGHBOR
          Nearest Neighbor sampling mode
static int NO_ERRORS
          No error mode
static String SMOOTH_5POINT
          Five point smoother identifier
static String SMOOTH_9POINT
          Nine point smoother identifier
static String SMOOTH_CIRCULAR
          Barnes circular smoother identifier
static String SMOOTH_CRESSMAN
          Cressman smoother identifier
static String SMOOTH_GAUSSIAN
          Gaussian smoother identifier
static String SMOOTH_RECTANGULAR
          Barnes circular smoother identifier
static int WEIGHTED_AVERAGE
          Weighted average sampling mode
 
Constructor Summary
GridUtil()
          Default ctor
 
Method Summary
static FieldImpl applyFunctionOverTime(FieldImpl grid, String function, boolean makeTimes)
          Deprecated. use GridMath.applyFunctionOverTime(FieldImpl, String, boolean)
static FieldImpl averageOverTime(FieldImpl grid, boolean makeTimes)
          Deprecated. use GridMath.averageOverTime(FieldImpl, boolean)
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)
static boolean canSwapLatLon(FieldImpl grid)
          Can the lat/lons be swapped?
static FieldImpl differenceFromBaseTime(FieldImpl grid)
          Deprecated. use GridMath.differenceFromBaseTime(FieldImpl)
static void exportGridToNetcdf(FieldImpl grid)
          Write grid out to a netCDF CF compliant file
static void exportGridToNetcdf(FieldImpl grid, String filename)
          Write grid out to a netCDF CF compliant file
 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 void fillMissing(float[][] grid2D, float missingValue)
          Fill a structure with missing values with nearby grid values
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 float[][][] findContainedLatLons(float[][] latlons, UnionSet maps)
          Find the lat/lon values in the given spatial domain contained by the polygons in the given map set
static float[][][] findContainedLatLons(GriddedSet domain, UnionSet maps)
          Find the lat/lon values in the given spatial domain contained by the polygons in the given map set
static int[][] findIndicesInsideRange(float[][] values, float min, float max)
          Finds the indices of the values array whose value is in the given range
static int[][] findIndicesOutsideRange(float[][] values, float min, float max)
          Finds the indices of the values array whose value is not in the given range
static List<FieldStats> findMinMaxAverage(FieldImpl field, UnionSet mapSets)
          Find the min/max and average of a file inside the mapsets
static FieldStats findMinMaxAverageFromRange(FlatField field, UnionSet mapSets)
          Find the min, max and average from the range
static int[][] findNotContainedIndices(float[][] latlon, UnionSet map)
          Find the indices of the latlon values contained in the map
static int[][] findNotContainedIndices(GriddedSet domain, UnionSet map)
          find the indices not contained in the map domian
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<DateTime> 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 Gridded1DSet getEnsembleSet(FieldImpl ensGrid)
          Return the ensemble set for the field
static RealType getEnsembleType(FieldImpl grid)
          Get the RealType of the ensemble.
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 float[][][] getLatLons(float[][] latlons, int[][] indices)
          Find the lat/lon values in the given spatial domain for the given indices
static float[][][] getLatLons(GriddedSet domain, int[][] indices)
          Find the lat/lon values in the given spatial domain for the given indices
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 FieldImpl getProfileAtLatLonPoint(FieldImpl grid, LatLonPoint point, int samplingMode, int errorMode)
          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 SampledSet getWholeSpatialDomain(FieldImpl grid)
          Get the spatial domain for this grid.
static boolean hasEnsemble(FieldImpl grid)
          Check to see if this is an ensemble grid
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 isAnyMissing(FieldImpl grid)
          Check if any of the 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 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)
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)
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 FieldImpl lonFlip(FieldImpl grid)
          Flip the grid along the central longitude.
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 DataRange makeDataRange(Range range)
          Make a DataRange from a Range
static DataRange[] makeDataRanges(Range[] range)
          Make an array of DataRanges from an array of Ranges
static Gridded2DSet makeDomain2D(GriddedSet domainSet)
          Transform a (possibly) 3D set into a 2D set (removing the Z dimension)
static float[][] makeGrid(float[][][] grid2D, int numCols, int numRows, float missingValue)
          Make a grid structure
static float[][] makeGrid(float[][] grid2D, int numCols, int numRows, float missingValue)
          Make a grid structure
static GridUtil.Grid2D makeGrid2D(FieldImpl grid)
          rectangulrize the given field, making a grid2d out of its spatial domain and values
static TupleType makeNewParamType(TupleType oldParamType, String newSuffix)
          Make a new type for the field by appending the suffix to the exiting RealTypes in the range
static MapProjection makeRadarMapProjection(CoordinateSystem radarCS)
          Return a MapProjection that relates to the Radar*DCoordinateSystem.
static Range makeRange(DataRange range)
          Make a range from a VisAD data range
static Range[] makeRanges(DataRange[] range)
          Make an array of Ranges from an array of DataRanges
static FieldImpl maxOverTime(FieldImpl grid, boolean makeTimes)
          Deprecated. use GridMath.maxOverTime(FieldImpl, boolean)
static FieldImpl minOverTime(FieldImpl grid, boolean makeTimes)
          Deprecated. use GridMath.minOverTime
static String printit(FieldImpl field)
          Print the type of the sample of a data object
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
static FieldImpl sample(FieldImpl grid, EarthLocation location, int samplingMode, int errorMode)
          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 FieldImpl sample(FieldImpl grid, LatLonPoint point, int samplingMode, int errorMode)
          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 Real sampleToReal(FieldImpl grid, EarthLocation el, Real animationValue, int samplingMode)
          This samples the given grid in both time and space and trys to return a Real value
static Real sampleToReal(FieldImpl grid, EarthLocation el, Real animationValue, int samplingMode, int errorMode)
          This samples the given grid in both time and space and trys to return a Real value
static RealTuple sampleToRealTuple(FieldImpl grid, EarthLocation el, Real animationValue, int samplingMode)
          This samples the given grid in both time and space and trys to return a Real value
static RealTuple sampleToRealTuple(FieldImpl grid, EarthLocation el, Real animationValue, int samplingMode, int errorMode)
          This samples the given grid in both time and space and trys to return a Real value
static FieldImpl setAltitudeValues(FieldImpl grid, float[] altValues)
          Set the altitude values for a grid
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 setPressureValues(FieldImpl grid, float[] pressValues)
          Set the pressure values for a grid
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 setVerticalValues(FieldImpl grid, float[] newValues, RealType vertType, Unit vertUnit)
          Set the vertical values
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 slice(FieldImpl grid, SampledSet slice, int samplingMode, int errorMode)
          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 sliceAlongLatLonLine(FieldImpl grid, LatLonPoint start, LatLonPoint end, int samplingMode, int errorMode)
          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 sliceAtLevel(FieldImpl grid, Real level, int samplingMode, int errorMode)
          Slice the grid at the vertical level indictated.
static FieldImpl smooth(FieldImpl slice, String type)
          Smooth a 2D field
static FieldImpl smooth(FieldImpl slice, String type, int filterLevel)
          Smooth a 2D field
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 FieldImpl sumFromBaseTime(FieldImpl grid)
          Deprecated. use GridMath.sumFromBaseTime(FieldImpl)
static FieldImpl sumOverTime(FieldImpl grid, boolean makeTimes)
          Deprecated. use GridMath.sumOverTime(FieldImpl, boolean)
static FieldImpl swapLatLon(FieldImpl grid)
          Swap the lat/lon coordinates of the grid.
static void testIt(FieldImpl grid)
          test
static FieldImpl timeStepDifference(FieldImpl grid, int offset)
          Deprecated. use GridMath.timeStepDifference(FieldImpl, int)
static FieldImpl timeStepFunc(FieldImpl grid, int offset, String func)
          Deprecated. use GridMath.timeStepFunc(FieldImpl, int, String)
static FieldImpl timeStepSum(FieldImpl grid, int offset)
          Deprecated. use GridMath.timeStepSum(FieldImpl, int)
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

WEIGHTED_AVERAGE

public static final int WEIGHTED_AVERAGE
Weighted average sampling mode

See Also:
Constant Field Values

NEAREST_NEIGHBOR

public static final int NEAREST_NEIGHBOR
Nearest Neighbor sampling mode

See Also:
Constant Field Values

NO_ERRORS

public static final int NO_ERRORS
No error mode

See Also:
Constant Field Values

DEPENDENT_ERRORS

public static final int DEPENDENT_ERRORS
Dependent error mode

See Also:
Constant Field Values

INDEPENDENT_ERRORS

public static final int INDEPENDENT_ERRORS
Independent error mode

See Also:
Constant Field Values

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

FUNC_AVERAGE

public static final String FUNC_AVERAGE
Deprecated. use GridMath.FUNC_AVERAGE
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_SUM

public static final String FUNC_SUM
Deprecated. use GridMath.FUNC_SUM
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_MAX

public static final String FUNC_MAX
Deprecated. use GridMath.FUNC_MAX
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_MIN

public static final String FUNC_MIN
Deprecated. use GridMath.FUNC_MIN
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_DIFFERENCE

public static final String FUNC_DIFFERENCE
Deprecated. use GridMath.FUNC_DIFFERENCE
function for the timeStepFunc routine

See Also:
Constant Field Values

SMOOTH_5POINT

public static final String SMOOTH_5POINT
Five point smoother identifier

See Also:
Constant Field Values

SMOOTH_9POINT

public static final String SMOOTH_9POINT
Nine point smoother identifier

See Also:
Constant Field Values

SMOOTH_GAUSSIAN

public static final String SMOOTH_GAUSSIAN
Gaussian smoother identifier

See Also:
Constant Field Values

SMOOTH_CRESSMAN

public static final String SMOOTH_CRESSMAN
Cressman smoother identifier

See Also:
Constant Field Values

SMOOTH_CIRCULAR

public static final String SMOOTH_CIRCULAR
Barnes circular smoother identifier

See Also:
Constant Field Values

SMOOTH_RECTANGULAR

public static final String SMOOTH_RECTANGULAR
Barnes circular smoother identifier

See Also:
Constant Field Values

ENSEMBLE_TYPE

public static final RealType ENSEMBLE_TYPE
ensemble RealType

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

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

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

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

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

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
Deprecated. use GridMath.averageOverTime(FieldImpl, boolean)

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

timeStepDifference

public static FieldImpl timeStepDifference(FieldImpl grid,
                                           int offset)
                                    throws VisADException
Deprecated. use GridMath.timeStepDifference(FieldImpl, int)

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

timeStepSum

public static FieldImpl timeStepSum(FieldImpl grid,
                                    int offset)
                             throws VisADException
Deprecated. use GridMath.timeStepSum(FieldImpl, int)

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

differenceFromBaseTime

public static FieldImpl differenceFromBaseTime(FieldImpl grid)
                                        throws VisADException
Deprecated. use GridMath.differenceFromBaseTime(FieldImpl)

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

sumFromBaseTime

public static FieldImpl sumFromBaseTime(FieldImpl grid)
                                 throws VisADException
Deprecated. use GridMath.sumFromBaseTime(FieldImpl)

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

timeStepFunc

public static FieldImpl timeStepFunc(FieldImpl grid,
                                     int offset,
                                     String func)
                              throws VisADException
Deprecated. use GridMath.timeStepFunc(FieldImpl, int, String)

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

sumOverTime

public static FieldImpl sumOverTime(FieldImpl grid,
                                    boolean makeTimes)
                             throws VisADException
Deprecated. use GridMath.sumOverTime(FieldImpl, boolean)

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

minOverTime

public static FieldImpl minOverTime(FieldImpl grid,
                                    boolean makeTimes)
                             throws VisADException
Deprecated. use GridMath.minOverTime

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

maxOverTime

public static FieldImpl maxOverTime(FieldImpl grid,
                                    boolean makeTimes)
                             throws VisADException
Deprecated. use GridMath.maxOverTime(FieldImpl, boolean)

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

applyFunctionOverTime

public static FieldImpl applyFunctionOverTime(FieldImpl grid,
                                              String function,
                                              boolean makeTimes)
                                       throws VisADException
Deprecated. use GridMath.applyFunctionOverTime(FieldImpl, String, boolean)

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

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

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

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

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

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:
indices - index array we get from findContainedIndices methods. i.e., indices[numPolygons][numIndices]
domain - domain to use
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:
indices - index array we get from findContainedIndices methods. i.e., indices[numPolygons][numIndices]
latlons - lat/lons from the spatial domain
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

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

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