ucar.unidata.data.grid
Class GridMath

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

public class GridMath
extends Object

A class to handle grid math. This handles math between grids on different manifolds where possible.

Author:
IDV Development Team

Field Summary
static String AXIS_X
          axis identifier - X
static String AXIS_Y
          axis identifier - Y
static String FUNC_AVERAGE
          function for the applyFunctionOverTime routine
static String FUNC_DIFFERENCE
          function for the timeStepFunc routine
static String FUNC_MAX
          function for the applyFunctionOverTime routine
static String FUNC_MIN
          function for the applyFunctionOverTime routine
static String FUNC_MODE
          function for the applyFunctionOverTime routine
static String FUNC_PRCNTL
          function for the applyFunctionOverTime routine
static String FUNC_RNG
          function for the applyFunctionOverTime routine
static String FUNC_STDEV
          function for the applyFunctionOverTime routine
static String FUNC_SUM
          function for the applyFunctionOverTime routine
static String FUNC_UPROB
          function for the applyFunctionOverTime routine
static Real NEGATIVE_ONE
          negative one
static int OPT_CYCLIC
          cyclic option
static int OPT_MISSING
          missing option
static int OPT_SYMMETRIC
          symmetric option
 
Constructor Summary
GridMath()
           
 
Method Summary
static FieldImpl add(FieldImpl grid1, FieldImpl grid2)
          Add two grids together
static FieldImpl add(FieldImpl grid1, FieldImpl grid2, boolean useWA)
          Add two grids together
static FlatField applyFunctionOverGrids(FlatField[] grids, String function)
          Apply the function to the grids.
static FieldImpl applyFunctionOverLevels(FieldImpl grid, String function)
          Apply the function to the time steps of the given grid over the levels.
static FieldImpl applyFunctionOverMembers(FieldImpl grid, float statThreshold, float exptdLoBound, float exptdUpBound, String function)
          Apply the function to the ens members of the given grid.
static FieldImpl applyFunctionOverMembers(FieldImpl grid, String function)
          Apply the function to the ens members of the given grid.
static FieldImpl applyFunctionOverMembers(FieldImpl grid, String statThreshold, String exptdLoBoundIn, String exptdUpBoundIn, String function)
          Apply the function to the ens members of the given grid.
static FieldImpl applyFunctionOverTime(FieldImpl grid, String function, boolean makeTimes)
          Apply the function to the time steps of the given grid.
static FieldImpl applyFunctionOverTime(FieldImpl grid, String function, int startIdx, int idxStride, boolean makeTimes)
          Apply the function to the time steps of the given grid.
static FieldImpl applyFunctionToAxis(FieldImpl grid, String function, String axis)
          Apply the function to the x or y of the given grid at each level.
static FieldImpl applyFunctionToLevels(FieldImpl grid, String function)
          Apply the function to the time steps of the given grid at each level.
static FieldImpl atan2(FieldImpl grid1, FieldImpl grid2)
          Take the arctangent of two grids
static FieldImpl atan2(FieldImpl grid1, FieldImpl grid2, boolean useWA)
          Take the arctangent of two grids
static FieldImpl averageOverMembers(FieldImpl grid)
          Average the grid over member
static FieldImpl averageOverTime(FieldImpl grid, boolean makeTimes)
          Average the grid at each point over time
static FieldImpl ddx(FieldImpl grid)
          Take the partial derivative with respect to X of the given field.
static FieldImpl ddy(FieldImpl grid)
          Take the partial derivative with respect to Y of the given field.
static FieldImpl differenceFromBaseTime(FieldImpl grid)
          This creates a field where D(T) = D(T)-D(0) Any time steps up to the offset time are set to missing
static FieldImpl divide(FieldImpl grid1, FieldImpl grid2)
          Divide two grids
static FieldImpl divide(FieldImpl grid1, FieldImpl grid2, boolean useWA)
          Divide two grids
static FieldImpl ensembleHighestValues(FieldImpl grid)
          ensemble grid max values
static FieldImpl ensembleLowestValues(FieldImpl grid)
          ensemble grid min values
static FieldImpl ensembleModeValues(FieldImpl grid)
          ensemble grid min values
static FieldImpl ensemblePercentileValues(FieldImpl grid, int percent)
          ensemble grid min values
static FieldImpl ensemblePercentileValues(FieldImpl grid, String percent)
          ensemble grid min values
static FieldImpl ensembleRangeValues(FieldImpl grid)
          ensemble grid range values
static FieldImpl ensembleStandardDeviation(FieldImpl grid)
          ensemble Standard Deviation
static FieldImpl ensembleUProbabilityValues(FieldImpl grid, String logicalOp, float pValue, float exptdLoBound, float exptdUpBound)
          ensemble grid univariate probability
static FieldImpl ensembleUProbabilityValues(FieldImpl grid, String logicalOp, String pValue, String exptdLoBound, String exptdUpBound)
          ensemble grid univariate probability
static float evaluateMode(float[] data)
          evaluate mode value
static float evaluatePercentile(float[] values, int begin, int length, double p)
          evaluate percentile value
static float evaluateUProbability(float[] values, float pValue, int length)
          evaluate univariate probability of "variable with n ensemble values" < pValue code from $NAWIPS/gempak/source/diaglib/de/decprb.c used to make this function.
static FieldImpl maxOverTime(FieldImpl grid, boolean makeTimes)
          Take the max value at each grid point
static FieldImpl minOverTime(FieldImpl grid, boolean makeTimes)
          Take the min value at each grid point
static FieldImpl multiply(FieldImpl grid1, FieldImpl grid2)
          Multiply two grids
static FieldImpl multiply(FieldImpl grid1, FieldImpl grid2, boolean useWA)
          Multiply two grids
static FieldImpl partial(FieldImpl grid, int domainIndex)
          Take the partial derivative with respect variable at the domain index.
static FieldImpl standardDeviationOverTime(FieldImpl grid, boolean makeTimes)
          Compute the standard deviation of the grid at each point over time
static FieldImpl subtract(FieldImpl grid1, FieldImpl grid2)
          Subtract two grids
static FieldImpl subtract(FieldImpl grid1, FieldImpl grid2, boolean useWA)
          Subtract two grids
static FieldImpl sumFromBaseTime(FieldImpl grid)
          This creates a field where D(T) = D(0)+D(1)+...+D(T-1)+D(T)
static FieldImpl sumOverTime(FieldImpl grid, boolean makeTimes)
          Sum each grid point
static FieldImpl timeRunningAverage(FieldImpl grid, int nave, int opt)
          Create a running average across the time dimension.
static FieldImpl timeRunningAverage(FieldImpl grid, int nave, int opt, boolean skipMissing)
          Create a running average across the time dimension.
static FieldImpl timeStepDifference(FieldImpl grid, int offset)
          This creates a field where D(T) = D(T)-D(T+offset) Any time steps up to the offset time are set to missing
static FieldImpl timeStepFunc(FieldImpl grid, int offset, String func)
          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.
static FieldImpl timeStepSum(FieldImpl grid, int offset)
          This creates a field where D(T) = D(T)+D(T+offset) Any time steps up to the offset time are set to missing
static FieldImpl timeWeightedRunningAverage(FieldImpl grid, float[] wgts, int opt)
          Create a running average across the time dimension.
static FieldImpl timeWeightedRunningAverage(FieldImpl grid, float[] wgts, int opt, boolean skipMissing)
          Create a running average across the time dimension.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FUNC_AVERAGE

public static final String FUNC_AVERAGE
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_STDEV

public static final String FUNC_STDEV
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_PRCNTL

public static final String FUNC_PRCNTL
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_UPROB

public static final String FUNC_UPROB
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_SUM

public static final String FUNC_SUM
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_MAX

public static final String FUNC_MAX
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_MIN

public static final String FUNC_MIN
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_RNG

public static final String FUNC_RNG
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_MODE

public static final String FUNC_MODE
function for the applyFunctionOverTime routine

See Also:
Constant Field Values

FUNC_DIFFERENCE

public static final String FUNC_DIFFERENCE
function for the timeStepFunc routine

See Also:
Constant Field Values

OPT_CYCLIC

public static final int OPT_CYCLIC
cyclic option

See Also:
Constant Field Values

OPT_MISSING

public static final int OPT_MISSING
missing option

See Also:
Constant Field Values

OPT_SYMMETRIC

public static final int OPT_SYMMETRIC
symmetric option

See Also:
Constant Field Values

AXIS_X

public static final String AXIS_X
axis identifier - X

See Also:
Constant Field Values

AXIS_Y

public static final String AXIS_Y
axis identifier - Y

See Also:
Constant Field Values

NEGATIVE_ONE

public static final Real NEGATIVE_ONE
negative one

Constructor Detail

GridMath

public GridMath()
Method Detail

add

public static FieldImpl add(FieldImpl grid1,
                            FieldImpl grid2)
                     throws VisADException
Add two grids together

Parameters:
grid1 - first grid
grid2 - second grid
Returns:
the sum of the grids
Throws:
VisADException - problem doing the math

add

public static FieldImpl add(FieldImpl grid1,
                            FieldImpl grid2,
                            boolean useWA)
                     throws VisADException
Add two grids together

Parameters:
grid1 - first grid
grid2 - second grid
useWA - use WEIGHTED_AVERAGE for resampling
Returns:
the sum of the grids
Throws:
VisADException - problem doing the math

subtract

public static FieldImpl subtract(FieldImpl grid1,
                                 FieldImpl grid2)
                          throws VisADException
Subtract two grids

Parameters:
grid1 - first grid
grid2 - second grid
Returns:
the difference of the grids
Throws:
VisADException - problem doing the math

subtract

public static FieldImpl subtract(FieldImpl grid1,
                                 FieldImpl grid2,
                                 boolean useWA)
                          throws VisADException
Subtract two grids

Parameters:
grid1 - first grid
grid2 - second grid
useWA - _more_
Returns:
the difference of the grids
Throws:
VisADException - problem doing the math

multiply

public static FieldImpl multiply(FieldImpl grid1,
                                 FieldImpl grid2)
                          throws VisADException
Multiply two grids

Parameters:
grid1 - first grid
grid2 - second grid
Returns:
the product of the grids
Throws:
VisADException - problem doing the math

multiply

public static FieldImpl multiply(FieldImpl grid1,
                                 FieldImpl grid2,
                                 boolean useWA)
                          throws VisADException
Multiply two grids

Parameters:
grid1 - first grid
grid2 - second grid
useWA - _more_
Returns:
the product of the grids
Throws:
VisADException - problem doing the math

divide

public static FieldImpl divide(FieldImpl grid1,
                               FieldImpl grid2)
                        throws VisADException
Divide two grids

Parameters:
grid1 - first grid
grid2 - second grid
Returns:
the quotient of the grids
Throws:
VisADException - problem doing the math

divide

public static FieldImpl divide(FieldImpl grid1,
                               FieldImpl grid2,
                               boolean useWA)
                        throws VisADException
Divide two grids

Parameters:
grid1 - first grid
grid2 - second grid
useWA - _more_
Returns:
the quotient of the grids
Throws:
VisADException - problem doing the math

atan2

public static FieldImpl atan2(FieldImpl grid1,
                              FieldImpl grid2)
                       throws VisADException
Take the arctangent of two grids

Parameters:
grid1 - first grid
grid2 - second grid
Returns:
the arctangent of the grids
Throws:
VisADException - problem doing the math

atan2

public static FieldImpl atan2(FieldImpl grid1,
                              FieldImpl grid2,
                              boolean useWA)
                       throws VisADException
Take the arctangent of two grids

Parameters:
grid1 - first grid
grid2 - second grid
useWA - _more_
Returns:
the arctangent of the grids
Throws:
VisADException - problem doing the math

averageOverTime

public static FieldImpl averageOverTime(FieldImpl grid,
                                        boolean makeTimes)
                                 throws VisADException
Average the grid at each point 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

standardDeviationOverTime

public static FieldImpl standardDeviationOverTime(FieldImpl grid,
                                                  boolean makeTimes)
                                           throws VisADException
Compute the standard deviation of the grid at each point over time

Parameters:
grid - grid to compute std
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

averageOverMembers

public static FieldImpl averageOverMembers(FieldImpl grid)
                                    throws VisADException
Average the grid over member

Parameters:
grid - ensemble grid to average
Returns:
the new field
Throws:
VisADException - On badness

ensembleStandardDeviation

public static FieldImpl ensembleStandardDeviation(FieldImpl grid)
                                           throws VisADException
ensemble Standard Deviation

Parameters:
grid - ensemble grid
Returns:
the new field
Throws:
VisADException - On badness

ensembleLowestValues

public static FieldImpl ensembleLowestValues(FieldImpl grid)
                                      throws VisADException
ensemble grid min values

Parameters:
grid - ensemble grid
Returns:
the new field
Throws:
VisADException - On badness

ensembleHighestValues

public static FieldImpl ensembleHighestValues(FieldImpl grid)
                                       throws VisADException
ensemble grid max values

Parameters:
grid - ensemble grid
Returns:
the new field
Throws:
VisADException - On badness

ensembleRangeValues

public static FieldImpl ensembleRangeValues(FieldImpl grid)
                                     throws VisADException
ensemble grid range values

Parameters:
grid - ensemble grid
Returns:
the new field
Throws:
VisADException - On badness

ensemblePercentileValues

public static FieldImpl ensemblePercentileValues(FieldImpl grid,
                                                 String percent)
                                          throws VisADException
ensemble grid min values

Parameters:
grid - ensemble grid
percent - _more_
Returns:
the new field
Throws:
VisADException - On badness

ensemblePercentileValues

public static FieldImpl ensemblePercentileValues(FieldImpl grid,
                                                 int percent)
                                          throws VisADException
ensemble grid min values

Parameters:
grid - ensemble grid
percent - _more_
Returns:
the new field
Throws:
VisADException - On badness

ensembleUProbabilityValues

public static FieldImpl ensembleUProbabilityValues(FieldImpl grid,
                                                   String logicalOp,
                                                   float pValue,
                                                   float exptdLoBound,
                                                   float exptdUpBound)
                                            throws VisADException
ensemble grid univariate probability

Parameters:
grid - ensemble grid
logicalOp - gt or lt for P(X > | < pValue)
pValue - probability threshold value P(valueAtGridPoint < pValue)
exptdLoBound - _more_
exptdUpBound - _more_
Returns:
the new field
Throws:
VisADException - On badness

ensembleUProbabilityValues

public static FieldImpl ensembleUProbabilityValues(FieldImpl grid,
                                                   String logicalOp,
                                                   String pValue,
                                                   String exptdLoBound,
                                                   String exptdUpBound)
                                            throws VisADException
ensemble grid univariate probability

Parameters:
grid - ensemble grid
logicalOp - gt or lt for P(X > | < pValue)
pValue - probability threshold value P(valueAtGridPoint < pValue)
exptdLoBound - _more_
exptdUpBound - _more_
Returns:
the new field
Throws:
VisADException - On badness

ensembleModeValues

public static FieldImpl ensembleModeValues(FieldImpl grid)
                                    throws VisADException
ensemble grid min values

Parameters:
grid - ensemble grid
Returns:
the new field
Throws:
VisADException - On badness

timeStepDifference

public static FieldImpl timeStepDifference(FieldImpl grid,
                                           int offset)
                                    throws VisADException
This creates a field where D(T) = D(T)-D(T+offset) Any time steps up to the offset time are set to missing

Parameters:
grid - grid to average
offset - time step offset. e.g., offset=-1 results in D(T)=D(T)-D(T-1)
Returns:
the new field
Throws:
VisADException - On badness

timeStepSum

public static FieldImpl timeStepSum(FieldImpl grid,
                                    int offset)
                             throws VisADException
This creates a field where D(T) = D(T)+D(T+offset) Any time steps up to the offset time are set to missing

Parameters:
grid - grid to average
offset - time step offset. e.g., offset=-1 results in D(T)=D(T)+D(T-1)
Returns:
the new field
Throws:
VisADException - On badness

differenceFromBaseTime

public static FieldImpl differenceFromBaseTime(FieldImpl grid)
                                        throws VisADException
This creates a field where D(T) = D(T)-D(0) Any time steps up to the offset time are set to missing

Parameters:
grid - grid to average
Returns:
the new field
Throws:
VisADException - On badness

sumFromBaseTime

public static FieldImpl sumFromBaseTime(FieldImpl grid)
                                 throws VisADException
This creates a field where D(T) = D(0)+D(1)+...+D(T-1)+D(T)

Parameters:
grid - grid to sum
Returns:
the new field
Throws:
VisADException - On badness

timeStepFunc

public static FieldImpl timeStepFunc(FieldImpl grid,
                                     int offset,
                                     String func)
                              throws VisADException
This creates a field where is either D(T) = D(T)-D(T+offset) or D(T) = D(T)+D(T+offset) depending on the value of the func argument Any time steps up to the offset time are set to missing. If offset == 0 then we use D(0) as the fixed operand foreach operator, e.g.: D(T) = D(T) - D(0)

Parameters:
grid - grid to average
offset - time step offset.
func - which function to apply, SUM or DIFFERENCE
Returns:
the new field
Throws:
VisADException - On badness

timeWeightedRunningAverage

public static FieldImpl timeWeightedRunningAverage(FieldImpl grid,
                                                   float[] wgts,
                                                   int opt)
                                            throws VisADException
Create a running average across the time dimension.

Parameters:
grid - grid to average
wgts - weights per step (usually odd and add to 1)
opt - options for end points
     N = {last point in the series}
    xi = {input series}
    xo = {output series}
    nwgt = {number of wgts}

    opt < 0 : utilize cyclic conditions
          e.g., nwgt = 2
                 xo(0) = w(0) * xi(0) + w(1) * xi(1)
                 xo(N) = w(0) * xi(N) + w(1) * xi(0)
          e.g., nwgt = 3
                 xo(0) = w(0) * xi(N) + w(1) * xi(0) + w(2) * xi(1)
                 xo(N) = w(0) * xi(N - 1) + w(1) * xi(N) + w(2) * xi(0)
          e.g., nwgt = 4
                 xo(0) = w(0) * xi(N) + w(1) * xi(0) + w(2) * xi(1) + w(3) * xi(2)
                 xo(N) = w(0) * xi(N - 1) + w(1) * xi(N) + w(2) * xi(1) + w(3) * xi(2)

    opt = 0 : set unsmoothed beginning and end pts to x@_FillValue (most common)
          e.g., nwgt = 2
                 xo(0) = w(0) * xi(0) + w(1) * xi(1)
                 xo(N) = xi@_FillValue
          e.g., nwgt = 3
                 xo(0) = xi@_FillValue
                 xo(1) = w(0) * xi(0) + w(1) * xi(1) + w(2) * xi(2)
                 xi(N) = xi@_FillValue
          e.g., nwgt = 4
                 xo(0)     = xi@_FillValue
                 xo(1)     = w(0) * xi(0) + w(1) * xi(1) + w(2) * xi(2) + w(3) * xi(3)
                 xo(N - 2) = w(0) * xi(N - 3) + w(1) * xi(N - 2) + w(2) * xi(N - 1) + w(3) * xi(N)
                 xo(N - 1) = xi@_FillValue
                 xo(N)     = xi@_FillValue

    opt > 0 : utilize reflective (symmetric) conditions
          e.g., nwgt = 2
                 xo(0) = w(0) * xi(0) + w(1) * xi(1)
                 xo(N) = w(0) * xi(N) + w(0) * xi(0)
          e.g., nwgt = 3
                 xo(0) = w(0) * xi(1) + w(1) * xi(0) + w(2) * xi(1)
                 xo(N) = w(0) * xi(N - 1) + w(1) * xi(N) + w(2) * xi(N - 1)
          e.g., nwgt = 4
                 xo(0) = w(0) * xi(1) + w(1) * xi(0) + w(2) * xi(1) + w(3) * xi(2)
                 xo(N) = w(0) * xi(N - 1) + w(1) * xi(N) + w(2) * xi(0) + w(3) * xi(2)
 
Returns:
the new field
Throws:
VisADException - On badness

timeWeightedRunningAverage

public static FieldImpl timeWeightedRunningAverage(FieldImpl grid,
                                                   float[] wgts,
                                                   int opt,
                                                   boolean skipMissing)
                                            throws VisADException
Create a running average across the time dimension.

Parameters:
grid - grid to average
wgts - weights per step (usually odd and add to 1)
opt - options for end points
     N = {last point in the series}
    xi = {input series}
    xo = {output series}
    nwgt = {number of wgts}

    opt < 0 : utilize cyclic conditions
          e.g., nwgt = 2
                 xo(0) = w(0) * xi(0) + w(1) * xi(1)
                 xo(N) = w(0) * xi(N) + w(1) * xi(0)
          e.g., nwgt = 3
                 xo(0) = w(0) * xi(N) + w(1) * xi(0) + w(2) * xi(1)
                 xo(N) = w(0) * xi(N - 1) + w(1) * xi(N) + w(2) * xi(0)
          e.g., nwgt = 4
                 xo(0) = w(0) * xi(N) + w(1) * xi(0) + w(2) * xi(1) + w(3) * xi(2)
                 xo(N) = w(0) * xi(N - 1) + w(1) * xi(N) + w(2) * xi(1) + w(3) * xi(2)

    opt = 0 : set unsmoothed beginning and end pts to x@_FillValue (most common)
          e.g., nwgt = 2
                 xo(0) = w(0) * xi(0) + w(1) * xi(1)
                 xo(N) = xi@_FillValue
          e.g., nwgt = 3
                 xo(0) = xi@_FillValue
                 xo(1) = w(0) * xi(0) + w(1) * xi(1) + w(2) * xi(2)
                 xi(N) = xi@_FillValue
          e.g., nwgt = 4
                 xo(0)     = xi@_FillValue
                 xo(1)     = w(0) * xi(0) + w(1) * xi(1) + w(2) * xi(2) + w(3) * xi(3)
                 xo(N - 2) = w(0) * xi(N - 3) + w(1) * xi(N - 2) + w(2) * xi(N - 1) + w(3) * xi(N)
                 xo(N - 1) = xi@_FillValue
                 xo(N)     = xi@_FillValue

    opt > 0 : utilize reflective (symmetric) conditions
          e.g., nwgt = 2
                 xo(0) = w(0) * xi(0) + w(1) * xi(1)
                 xo(N) = w(0) * xi(N) + w(0) * xi(0)
          e.g., nwgt = 3
                 xo(0) = w(0) * xi(1) + w(1) * xi(0) + w(2) * xi(1)
                 xo(N) = w(0) * xi(N - 1) + w(1) * xi(N) + w(2) * xi(N - 1)
          e.g., nwgt = 4
                 xo(0) = w(0) * xi(1) + w(1) * xi(0) + w(2) * xi(1) + w(3) * xi(2)
                 xo(N) = w(0) * xi(N - 1) + w(1) * xi(N) + w(2) * xi(0) + w(3) * xi(2)
 
skipMissing - if true, missing timesteps will not be included in the average and the average will be done on the non-missing times
Returns:
the new field
Throws:
VisADException - On badness

timeRunningAverage

public static FieldImpl timeRunningAverage(FieldImpl grid,
                                           int nave,
                                           int opt)
                                    throws VisADException
Create a running average across the time dimension.

Parameters:
grid - grid to average
nave - number of steps to average
opt - options for end points
     In the following:

         N = {last point in the series, i.e. N = npts - 1}
         xi = {input series}
         xo = {output series}

     opt < 0 : utilize cyclic conditions
                e.g., nave = 2
                      xo(0) = (xi(0) + xi(1))/nave
                      xo(N) = (xi(N) + xi(0))/nave
                e.g., nave = 3
                      xo(0) = (xi(N) + xi(0) + xi(1)) / nave
                      xo(N) = (xi(N - 1) + xi(N) + xi(0)) / nave
                e.g., nave = 4
                      xo(0) = (xi(N) + xi(0) + xi(1) + xi(2)) / nave
                      xo(N) = (xi(N - 1) + xi(N) + xi(0) + xi(1)) / nave

     opt = 0 : set unsmoothed beginning and end pts to x@_FillValue [most common]
                e.g., nave = 2
                      xo(0) = (xi(0) + xi(1)) / nave
                      xo(N) = xi@_FillValue
                e.g., nave = 3
                      xo(0) = xi@_FillValue
                      xo(1) = (xi(0) + xi(1) + xi(2)) / nave
                      xi(N) = xi@_FillValue
                e.g., nave = 4
                      xo(0) = xi@_FillValue
                      xo(1) = (xi(0) + xi(1) + xi(2) + xi(3)) / nave
                      xo(N - 2) = (xi(N - 3) + xi(N - 2) + xi(N - 1) + xi(N)) / nave
                      xo(N - 1)= xi@_FillValue
                      xo(N)= xi@_FillValue

     opt > 0 : utilize reflective (symmetric) conditions
                e.g., nave = 2
                      xo(0) = (xi(0) + xi(1)) / nave
                      xo(N) = (xi(N) + xi(N-1)) / nave
                e.g., nave = 3
                      xo(0) = (xi(1) + xi(0) + xi(1)) / nave
                      xo(N) = (xi(N - 1) + xi(N) + xi(N-1)) / nave
                e.g., nave = 4
                      xo(0) = (xi(2) + xi(1) + xi(0) + xi(1)) / nave
                      xo(N) = (xi(N - 1) + xi(N) + xi(N - 1) + xi(N - 2)) / nave
 
Returns:
the new field
Throws:
VisADException - On badness

timeRunningAverage

public static FieldImpl timeRunningAverage(FieldImpl grid,
                                           int nave,
                                           int opt,
                                           boolean skipMissing)
                                    throws VisADException
Create a running average across the time dimension.

Parameters:
grid - grid to average
nave - number of steps to average
opt - options for end points
     In the following:

         N = {last point in the series, i.e. N = npts - 1}
         xi = {input series}
         xo = {output series}

     opt < 0 : utilize cyclic conditions
                e.g., nave = 2
                      xo(0) = (xi(0) + xi(1))/nave
                      xo(N) = (xi(N) + xi(0))/nave
                e.g., nave = 3
                      xo(0) = (xi(N) + xi(0) + xi(1)) / nave
                      xo(N) = (xi(N - 1) + xi(N) + xi(0)) / nave
                e.g., nave = 4
                      xo(0) = (xi(N) + xi(0) + xi(1) + xi(2)) / nave
                      xo(N) = (xi(N - 1) + xi(N) + xi(0) + xi(1)) / nave

     opt = 0 : set unsmoothed beginning and end pts to x@_FillValue [most common]
                e.g., nave = 2
                      xo(0) = (xi(0) + xi(1)) / nave
                      xo(N) = xi@_FillValue
                e.g., nave = 3
                      xo(0) = xi@_FillValue
                      xo(1) = (xi(0) + xi(1) + xi(2)) / nave
                      xi(N) = xi@_FillValue
                e.g., nave = 4
                      xo(0) = xi@_FillValue
                      xo(1) = (xi(0) + xi(1) + xi(2) + xi(3)) / nave
                      xo(N - 2) = (xi(N - 3) + xi(N - 2) + xi(N - 1) + xi(N)) / nave
                      xo(N - 1)= xi@_FillValue
                      xo(N)= xi@_FillValue

     opt > 0 : utilize reflective (symmetric) conditions
                e.g., nave = 2
                      xo(0) = (xi(0) + xi(1)) / nave
                      xo(N) = (xi(N) + xi(N-1)) / nave
                e.g., nave = 3
                      xo(0) = (xi(1) + xi(0) + xi(1)) / nave
                      xo(N) = (xi(N - 1) + xi(N) + xi(N-1)) / nave
                e.g., nave = 4
                      xo(0) = (xi(2) + xi(1) + xi(0) + xi(1)) / nave
                      xo(N) = (xi(N - 1) + xi(N) + xi(N - 1) + xi(N - 2)) / nave
 
skipMissing - if true, missing timesteps will not be included in the average and the average will be done on the non-missing times
Returns:
the new field
Throws:
VisADException - On badness

sumOverTime

public static FieldImpl sumOverTime(FieldImpl grid,
                                    boolean makeTimes)
                             throws VisADException
Sum each grid point

Parameters:
grid - grid to analyze
makeTimes - If true then make a time field with the range being the same computed value. If false then just return a single field of the computed values
Returns:
the new field
Throws:
VisADException - On badness

minOverTime

public static FieldImpl minOverTime(FieldImpl grid,
                                    boolean makeTimes)
                             throws VisADException
Take the min value at each grid point

Parameters:
grid - grid to analyze
makeTimes - If true then make a time field with the range being the same computed value. If false then just return a single field of the computed values
Returns:
the new field
Throws:
VisADException - On badness

maxOverTime

public static FieldImpl maxOverTime(FieldImpl grid,
                                    boolean makeTimes)
                             throws VisADException
Take the max value at each grid point

Parameters:
grid - grid to analyze
makeTimes - If true then make a time field with the range being the same computed value. If false then just return a single field of the computed values
Returns:
the new field
Throws:
VisADException - On badness

applyFunctionOverTime

public static FieldImpl applyFunctionOverTime(FieldImpl grid,
                                              String function,
                                              boolean makeTimes)
                                       throws VisADException
Apply the function to the time steps of the given grid. The function is one of the FUNC_ enums

Parameters:
grid - grid to average
function - One of the 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

applyFunctionOverTime

public static FieldImpl applyFunctionOverTime(FieldImpl grid,
                                              String function,
                                              int startIdx,
                                              int idxStride,
                                              boolean makeTimes)
                                       throws VisADException
Apply the function to the time steps of the given grid. The function is one of the FUNC_ enums

Parameters:
grid - grid to apply function to
function - One of the FUNC_ enums
startIdx - starting time index
idxStride - stride for time index
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

applyFunctionOverGrids

public static FlatField applyFunctionOverGrids(FlatField[] grids,
                                               String function)
                                        throws VisADException
Apply the function to the grids. Grids must have the same domains The function is one of the FUNC_ enums

Parameters:
grids - grids to apply function to
function - One of the FUNC_ enums
Returns:
the new field
Throws:
VisADException - On badness

applyFunctionOverMembers

public static FieldImpl applyFunctionOverMembers(FieldImpl grid,
                                                 String statThreshold,
                                                 String exptdLoBoundIn,
                                                 String exptdUpBoundIn,
                                                 String function)
                                          throws VisADException
Apply the function to the ens members of the given grid. The function is one of the FUNC_ enums

Parameters:
grid - grid to average
statThreshold - percent for FUNC_PRCNTL, probability threshold for FUNC_UPROB
exptdLoBoundIn - _more_
exptdUpBoundIn - _more_
function - One of the FUNC_ enums
Returns:
the new field
Throws:
VisADException - On badness

applyFunctionOverMembers

public static FieldImpl applyFunctionOverMembers(FieldImpl grid,
                                                 float statThreshold,
                                                 float exptdLoBound,
                                                 float exptdUpBound,
                                                 String function)
                                          throws VisADException
Apply the function to the ens members of the given grid. The function is one of the FUNC_ enums

Parameters:
grid - grid to average
statThreshold - percent for FUNC_PRCNTL, probability threshold for FUNC_UPROB
exptdLoBound - _more_
exptdUpBound - _more_
function - One of the FUNC_ enums
Returns:
the new field
Throws:
VisADException - On badness

applyFunctionOverMembers

public static FieldImpl applyFunctionOverMembers(FieldImpl grid,
                                                 String function)
                                          throws VisADException
Apply the function to the ens members of the given grid. The function is one of the FUNC_ enums

Parameters:
grid - grid to average
function - One of the FUNC_ enums
Returns:
the new field
Throws:
VisADException - On badness

applyFunctionOverLevels

public static FieldImpl applyFunctionOverLevels(FieldImpl grid,
                                                String function)
                                         throws VisADException
Apply the function to the time steps of the given grid over the levels. The function is one of the FUNC_ enums

Parameters:
grid - grid to average
function - One of the FUNC_ enums
Returns:
the new field with the function applied at each point over the levels.
Throws:
VisADException - On badness

applyFunctionToLevels

public static FieldImpl applyFunctionToLevels(FieldImpl grid,
                                              String function)
                                       throws VisADException
Apply the function to the time steps of the given grid at each level. The function is one of the FUNC_ enums

Parameters:
grid - grid to average
function - One of the FUNC_ enums
Returns:
the new field
Throws:
VisADException - On badness

applyFunctionToAxis

public static FieldImpl applyFunctionToAxis(FieldImpl grid,
                                            String function,
                                            String axis)
                                     throws VisADException
Apply the function to the x or y of the given grid at each level. The function is one of the FUNC_ enumerations

Parameters:
grid - grid to apply
function - One of the FUNC_ enumerations
axis - the axis to apply the function (AXIS_X or AXIS_Y)
Returns:
the new field
Throws:
VisADException - On badness

ddx

public static FieldImpl ddx(FieldImpl grid)
                     throws VisADException,
                            RemoteException
Take the partial derivative with respect to X of the given field.

Parameters:
grid - grid to parialize
Returns:
partialized grid
Throws:
RemoteException - Java RMI error
VisADException - VisAD Error

ddy

public static FieldImpl ddy(FieldImpl grid)
                     throws VisADException,
                            RemoteException
Take the partial derivative with respect to Y of the given field.

Parameters:
grid - grid to parialize
Returns:
partialized grid
Throws:
RemoteException - Java RMI error
VisADException - VisAD Error

partial

public static FieldImpl partial(FieldImpl grid,
                                int domainIndex)
                         throws VisADException,
                                RemoteException
Take the partial derivative with respect variable at the domain index.

Parameters:
grid - grid to parialize
domainIndex - index of variable to use for derivative
Returns:
partialized grid
Throws:
RemoteException - Java RMI error
VisADException - VisAD Error

evaluatePercentile

public static float evaluatePercentile(float[] values,
                                       int begin,
                                       int length,
                                       double p)
                                throws VisADException
evaluate percentile value

Parameters:
values - the values
begin - the starting index
length - number of points
p - the percentage
Returns:
the percentile
Throws:
VisADException - VisAD Error

evaluateMode

public static float evaluateMode(float[] data)
evaluate mode value

Parameters:
data - _more_
Returns:
the percentile

evaluateUProbability

public static float evaluateUProbability(float[] values,
                                         float pValue,
                                         int length)
                                  throws VisADException
evaluate univariate probability of "variable with n ensemble values" < pValue code from $NAWIPS/gempak/source/diaglib/de/decprb.c used to make this function.

Parameters:
values - the values, within the userspecified range, at a given grid point from an ensemble model run
pValue - the threshold used in the probability calculation - P(value < pValue)
length - number of ensemble members (might not be the same as values.length)
Returns:
prob the univariate probability that the value at the grid point is less than pValue
Throws:
VisADException - VisAD Error