Class GridMath

java.lang.Object
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 Details

  • Constructor Details

    • GridMath

      public GridMath()
  • Method Details

    • 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 - true to use weighted average
      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 - true to use WEIGHTED_AVERAGE
      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 - true to use WEIGHTED_AVERAGE
      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 - true to use WEIGHTED_AVERAGE
      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 - the percent
      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 - the percent
      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 > | invalid input: '<' pValue)
      pValue - probability threshold value P(valueAtGridPoint invalid input: '<' pValue)
      exptdLoBound - expected lo bound
      exptdUpBound - expected hi bound
      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 > | invalid input: '<' pValue)
      pValue - probability threshold value P(valueAtGridPoint invalid input: '<' pValue)
      exptdLoBound - expected lo bound
      exptdUpBound - expected hi bound
      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 invalid input: '<' 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 invalid input: '<' 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 invalid input: '<' 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 invalid input: '<' 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
    • applyFunctionOverGrids0

      public static FlatField applyFunctionOverGrids0(FlatField[] grids, String function) throws VisADException
      Throws:
      VisADException
    • 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 - expected lo bound
      exptdUpBoundIn - expected hi bound
      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 - expected lo bound
      exptdUpBound - expected hi bound
      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
    • applyFunctionOverGrid2D

      public static FieldImpl applyFunctionOverGrid2D(FieldImpl grid, String function, String statThreshold) throws VisADException
      Apply the function to the 2D grid. The function is one of the FUNC_ enums
      Parameters:
      grid - grid to average
      function - One of the FUNC_ enums
      statThreshold - percent for FUNC_PRCNTL, probability threshold for FUNC_UPROB
      Returns:
      the new time series point field
      Throws:
      VisADException - On badness
    • applyFunctionOverGrid2D

      public static FieldImpl applyFunctionOverGrid2D(FieldImpl grid) throws VisADException
      Throws:
      VisADException
    • applyFunctionOverGrid2D

      public static FieldImpl applyFunctionOverGrid2D(FieldImpl grid, String function, FieldImpl grid1, String function1, float percentile) throws VisADException
      Evaluate the function of the grid and the function1 to the grid1.
      Parameters:
      grid - 2d grid to apply function (max, min, average)
      function - One of the FUNC_ enums
      grid1 - 2d grid to apply function1 (percentile)
      function1 - another function name
      Returns:
      the new time series point field
      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
    • partial

      public static FieldImpl partial(FieldImpl grid) throws VisADException, RemoteException
      Throws:
      VisADException
      RemoteException
    • 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
    • removeNaNFromArray

      public static float[] removeNaNFromArray(float[] inputArray)
    • evaluatePercentile

      public static float evaluatePercentile(float[][] values, double p) throws VisADException
      Throws:
      VisADException
    • evaluatePercentile

      public static float evaluatePercentile(float[] values, double p) throws VisADException
      Throws:
      VisADException
    • twoDConvert

      public static float[] twoDConvert(float[][] nums)
    • evaluateMode

      public static float evaluateMode(float[] data)
      evaluate mode value
      Parameters:
      data - the data
      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" smaller than 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 smaller than 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
    • applyFunctionOverGridsExt

      public static FieldImpl applyFunctionOverGridsExt(FieldImpl field, String function) throws VisADException
      Throws:
      VisADException
    • calculateHelicity

      public static FieldImpl calculateHelicity(FieldImpl gridu, FieldImpl gridv, float bottom, float top, float ux, float vy) throws VisADException
      Calculate Helicity to the time steps of the given grid at each level.
      Parameters:
      gridu - u component grid
      gridv - v component grid
      bottom - in meter
      top - in meter
      ux - average u wind
      vy - average v wind
      Returns:
      the new field
      Throws:
      VisADException - On badness
    • subtractExt

      public static FieldImpl subtractExt(FieldImpl grid, FieldImpl grid2d) throws VisADException, RemoteException
      substractExt subtract a grid2d from each level of the 3d grid
      Parameters:
      grid - 3d grid
      grid2d - 2d grid
      Returns:
      the new 3d grid
      Throws:
      VisADException - On badness
      RemoteException - for bad
    • replaceNegativeValue

      public static FieldImpl replaceNegativeValue(FieldImpl grid, float newValue) throws VisADException, RemoteException
      Throws:
      VisADException
      RemoteException
    • replacePositiveValue

      public static FieldImpl replacePositiveValue(FieldImpl grid, float newValue) throws VisADException, RemoteException
      Throws:
      VisADException
      RemoteException
    • statisticsFF

      public static edu.wisc.ssec.mcidasv.data.hydra.Statistics statisticsFF(FlatField grid) throws VisADException
      Throws:
      VisADException
    • quantileTransformerFF

      public static FlatField quantileTransformerFF(FlatField grid) throws VisADException
      Throws:
      VisADException
    • powerTransformerFF

      public static FlatField powerTransformerFF(FlatField grid, String lambda) throws VisADException
      Throws:
      VisADException
    • powerTransformerFF

      public static FlatField powerTransformerFF(FlatField grid, double lambda) throws VisADException
      Throws:
      VisADException
    • robustScalerFF

      public static FlatField robustScalerFF(FlatField grid) throws VisADException
      Throws:
      VisADException
    • calculateL2Norm

      public static float calculateL2Norm(float[] vector)
    • calculateL1Norm

      public static float calculateL1Norm(float[] vector)