uk.ac.leeds.ccg.andyt.grids.core
Class GridStatisticsAbstract

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.grids.utilities.ErrorHandler
      extended by uk.ac.leeds.ccg.andyt.grids.core.GridStatisticsAbstract
All Implemented Interfaces:
java.io.Serializable, GridStatisticsInterface
Direct Known Subclasses:
GridStatistics0, GridStatistics1

public abstract class GridStatisticsAbstract
extends ErrorHandler
implements java.io.Serializable, GridStatisticsInterface

TODO: docs

See Also:
Serialized Form

Field Summary
protected  Grid2DSquareCellAbstract grid2DSquareCell
          A reference to the Grid2DSquareCellAbstract this is for.
protected  java.math.BigDecimal maxBigDecimal
          For storing the maximum of all non noDataValues as a BigDecimal.
protected  java.math.BigInteger maxCountBigInteger
          For storing the number of max values as a BigInteger.
protected  java.math.BigDecimal minBigDecimal
          For storing the minimum of all non noDataValues as a BigDecimal.
protected  java.math.BigInteger minCountBigInteger
          For storing the number of min values as a BigInteger.
protected  java.math.BigInteger nonNoDataValueCountBigInteger
          For storing the number of cells with non noDataValues.
protected  java.math.BigDecimal sumBigDecimal
          For storing the sum of all non noDataValues as a BigDecimal.
 
Fields inherited from class uk.ac.leeds.ccg.andyt.grids.utilities.ErrorHandler
handleOutOfMemoryErrorFalse, handleOutOfMemoryErrorTrue, memoryReserve
 
Constructor Summary
GridStatisticsAbstract()
           
 
Method Summary
static long count(Grid2DSquareCellDouble grid2DSquareCellDouble, long row, long col, long nrows, long ncols, double value)
          Counts the remaining number of values in grid2DSquareCellDouble equal to value from cell given by row p and column q counting in row major order.
static long count(Grid2DSquareCellInt grid2DSquareCellInt, long row, long col, long nrows, long ncols, int value)
          Counts the remaining number of values in grid2DSquareCellInt equal to value from cell given by row p and column q counting in row major order.
 java.math.BigInteger getMaxBigInteger()
          For returning the maximum of all non noDataValues as a BigInteger
 double getMaxDouble()
          For returning the maximum of all non noDataValues as a double If this.minBigDecimal is to big/small to represent as a double then an Arithmetic Exception is thrown and Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY are returned as appropriate.
 int getMaxInt()
          For returning the minimum of all non noDataValues as a int
 long getMaxLong()
          For returning the minimum of all non noDataValues as a long
 java.math.BigInteger getMinBigInteger()
          For returning the minimum of all non noDataValues as a BigInteger
 double getMinDouble()
          For returning the minimum of all non noDataValues as a double If this.minBigDecimal is to big/small to represent as a double then an Arithmetic Exception is thrown and Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY are returned as appropriate.
 int getMinInt()
          For returning the minimum of all non noDataValues as a int
 long getMinLong()
          For returning the minimum of all non noDataValues as a long
 java.lang.Object getMode()
          For returning the mode of all non noDataValues either as a TDoubleHashSet or as a TIntHashSet respectively depending on if ( this.grid2DSquareCell.getClass() == Grid2DSquareCellInt.class ) or if ( this.grid2DSquareCell.getClass() == Grid2DSquareCellDouble.class ).
abstract  java.lang.String getName()
          Returns the name of this instasnced
 int getNonNoDataValueCountInt()
          For returning the number of cells with noDataValues as a int
 long getNonNoDataValueCountLong()
          For returning the number of cells with noDataValues as a long
 java.math.BigDecimal getStandardDeviationBigDecimal(int numberOfDecimalPlaces)
          Returns the standard deviation of all non noDataValues as a double.
 java.math.BigInteger getSumBigInteger()
          For returning the sum of all non noDataValues as a BigInteger
 double getSumDouble()
          For returning the sum of all non noDataValues as a double.
 int getSumInt()
          For returning the sum of all non noDataValues as a int
 long getSumLong()
          For returning the sum of all non noDataValues as a long
protected  void init()
          For intitialisation
protected  void init(Grid2DSquareCellAbstract grid2DSquareCell)
          For intitialisation
 java.lang.String toString()
          Returns a string describing this instance
abstract  void update()
          Updates fields (statistics) by going through all values in this.grid2DSquareCellAbstract if they might not be up to date.
protected  void update(GridStatisticsAbstract gridStatistics)
          Updates fields from gridStatistics except this.grid2DSquareCell
protected  void update(long nrows, long ncols)
          Updates fields (statistics) by going through all values in this.grid2DSquareCellAbstract if they might not be up to date.
 
Methods inherited from class uk.ac.leeds.ccg.andyt.grids.utilities.ErrorHandler
clearMemoryReserve, initMemoryReserve, initMemoryReserve
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface uk.ac.leeds.ccg.andyt.grids.core.GridStatisticsInterface
getArithmeticMeanBigDecimal, getMaxBigDecimal, getMinBigDecimal, getNonNoDataValueCountBigInteger, getSumBigDecimal
 

Field Detail

grid2DSquareCell

protected Grid2DSquareCellAbstract grid2DSquareCell
A reference to the Grid2DSquareCellAbstract this is for.


nonNoDataValueCountBigInteger

protected java.math.BigInteger nonNoDataValueCountBigInteger
For storing the number of cells with non noDataValues.


sumBigDecimal

protected java.math.BigDecimal sumBigDecimal
For storing the sum of all non noDataValues as a BigDecimal.


minBigDecimal

protected java.math.BigDecimal minBigDecimal
For storing the minimum of all non noDataValues as a BigDecimal.


minCountBigInteger

protected java.math.BigInteger minCountBigInteger
For storing the number of min values as a BigInteger.


maxBigDecimal

protected java.math.BigDecimal maxBigDecimal
For storing the maximum of all non noDataValues as a BigDecimal.


maxCountBigInteger

protected java.math.BigInteger maxCountBigInteger
For storing the number of max values as a BigInteger.

Constructor Detail

GridStatisticsAbstract

public GridStatisticsAbstract()
Method Detail

init

protected void init()
For intitialisation


init

protected void init(Grid2DSquareCellAbstract grid2DSquareCell)
For intitialisation


update

protected void update(GridStatisticsAbstract gridStatistics)
Updates fields from gridStatistics except this.grid2DSquareCell

Parameters:
gridStatistics - the gridStatistics instance which fields are used to update this.

update

public abstract void update()
Updates fields (statistics) by going through all values in this.grid2DSquareCellAbstract if they might not be up to date. (NB. After calling this it is inexpensive to convert to GridStatistics0.)


update

protected void update(long nrows,
                      long ncols)
Updates fields (statistics) by going through all values in this.grid2DSquareCellAbstract if they might not be up to date. (NB. After calling this it is inexpensive to convert to GridStatistics0.) This is called from extending classes activated via update. It is here to avoid duplication in the code. The parameters are specified in order to distinguish this method from update().

Parameters:
nrows - The number of rows in the grid.
ncols - The number of columns in the grid.

getName

public abstract java.lang.String getName()
Returns the name of this instasnced


toString

public java.lang.String toString()
Returns a string describing this instance

Overrides:
toString in class java.lang.Object

getNonNoDataValueCountLong

public final long getNonNoDataValueCountLong()
For returning the number of cells with noDataValues as a long

Specified by:
getNonNoDataValueCountLong in interface GridStatisticsInterface

getNonNoDataValueCountInt

public final int getNonNoDataValueCountInt()
For returning the number of cells with noDataValues as a int

Specified by:
getNonNoDataValueCountInt in interface GridStatisticsInterface

getSumBigInteger

public final java.math.BigInteger getSumBigInteger()
For returning the sum of all non noDataValues as a BigInteger

Specified by:
getSumBigInteger in interface GridStatisticsInterface

getSumDouble

public final double getSumDouble()
For returning the sum of all non noDataValues as a double. If this.sumBigDecimal is to big/small to represent as a double then an Arithmetic Exception is thrown and Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY are returned as appropriate.

Specified by:
getSumDouble in interface GridStatisticsInterface

getSumLong

public final long getSumLong()
For returning the sum of all non noDataValues as a long

Specified by:
getSumLong in interface GridStatisticsInterface

getSumInt

public int getSumInt()
For returning the sum of all non noDataValues as a int

Specified by:
getSumInt in interface GridStatisticsInterface

getMinBigInteger

public final java.math.BigInteger getMinBigInteger()
For returning the minimum of all non noDataValues as a BigInteger

Specified by:
getMinBigInteger in interface GridStatisticsInterface

getMinDouble

public final double getMinDouble()
For returning the minimum of all non noDataValues as a double If this.minBigDecimal is to big/small to represent as a double then an Arithmetic Exception is thrown and Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY are returned as appropriate.

Specified by:
getMinDouble in interface GridStatisticsInterface

getMinLong

public final long getMinLong()
For returning the minimum of all non noDataValues as a long

Specified by:
getMinLong in interface GridStatisticsInterface

getMinInt

public final int getMinInt()
For returning the minimum of all non noDataValues as a int

Specified by:
getMinInt in interface GridStatisticsInterface

getMaxBigInteger

public final java.math.BigInteger getMaxBigInteger()
For returning the maximum of all non noDataValues as a BigInteger

Specified by:
getMaxBigInteger in interface GridStatisticsInterface

getMaxDouble

public final double getMaxDouble()
For returning the maximum of all non noDataValues as a double If this.minBigDecimal is to big/small to represent as a double then an Arithmetic Exception is thrown and Double.POSITIVE_INFINITY or Double.NEGATIVE_INFINITY are returned as appropriate.

Specified by:
getMaxDouble in interface GridStatisticsInterface

getMaxLong

public final long getMaxLong()
For returning the minimum of all non noDataValues as a long

Specified by:
getMaxLong in interface GridStatisticsInterface

getMaxInt

public final int getMaxInt()
For returning the minimum of all non noDataValues as a int

Specified by:
getMaxInt in interface GridStatisticsInterface

getMode

public java.lang.Object getMode()
For returning the mode of all non noDataValues either as a TDoubleHashSet or as a TIntHashSet respectively depending on if ( this.grid2DSquareCell.getClass() == Grid2DSquareCellInt.class ) or if ( this.grid2DSquareCell.getClass() == Grid2DSquareCellDouble.class ). TODO: Change for loops so as to look through each chunk in turn. Is it better to use toArray and go through a sorted version?


count

public static long count(Grid2DSquareCellInt grid2DSquareCellInt,
                         long row,
                         long col,
                         long nrows,
                         long ncols,
                         int value)
Counts the remaining number of values in grid2DSquareCellInt equal to value from cell given by row p and column q counting in row major order.

Parameters:
row - The row index of the cell from which counting starts
col - The column index of the cell from which counting starts
nrows - The number of rows in grid2DSquareCellInt.
ncols - The number of columns in grid2DSquareCellInt.
value - The value to be counted.

count

public static long count(Grid2DSquareCellDouble grid2DSquareCellDouble,
                         long row,
                         long col,
                         long nrows,
                         long ncols,
                         double value)
Counts the remaining number of values in grid2DSquareCellDouble equal to value from cell given by row p and column q counting in row major order.

Parameters:
row - The row index of the cell from which counting starts
col - The column index of the cell from which counting starts
nrows - The number of rows in grid2DSquareCellInt.
ncols - The number of columns in grid2DSquareCellInt.
value - The value to be counted.

getStandardDeviationBigDecimal

public java.math.BigDecimal getStandardDeviationBigDecimal(int numberOfDecimalPlaces)
Returns the standard deviation of all non noDataValues as a double.

Parameters:
numberOfDecimalPlaces - The number of places for which the standard deviation will be correct. TODO: test