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

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellChunk
      extended by uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellDoubleChunk
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
Grid2DSquareCellDoubleChunk64CellMap, Grid2DSquareCellDoubleChunkArray, Grid2DSquareCellDoubleChunkJAI, Grid2DSquareCellDoubleChunkMap, Grid2DSquareCellDoubleChunkRAF

public abstract class AbstractGrid2DSquareCellDoubleChunk
extends AbstractGrid2DSquareCellChunk
implements java.io.Serializable

Provides general methods and controls what methods extended classes must implement acting as an interface.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellChunk
AbstractGrid2DSquareCellChunk.ChunkCellID
 
Field Summary
 
Fields inherited from class uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellChunk
_ChunkID, _Grid2DSquareCell, isSwapUpToDate
 
Constructor Summary
AbstractGrid2DSquareCellDoubleChunk()
           
 
Method Summary
protected abstract  void clearData()
          For clearing the data associated with this.
protected  java.math.BigDecimal getArithmeticMeanBigDecimal(int numberOfDecimalPlaces)
          Returns the Arithmetic Mean of all non _NoDataValues as a BigDecimal.
 java.math.BigDecimal getArithmeticMeanBigDecimal(int numberOfDecimalPlaces, boolean handleOutOfMemoryError)
          Returns the Arithmetic Mean of all non _NoDataValues as a BigDecimal.
protected  double getArithmeticMeanDouble()
          Returns the Arithmetic Mean of all non _NoDataValues as a double.
 double getArithmeticMeanDouble(boolean handleOutOfMemoryError)
          Returns the Arithmetic Mean of all non _NoDataValues as a double.
protected abstract  double getCell(int chunkCellRowIndex, int chunkCellColIndex, double _NoDataValue)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex, as a double.
 double getCell(int chunkCellRowIndex, int chunkCellColIndex, double noDataValue, boolean handleOutOfMemoryError)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex, as a double.
 double getCell(int chunkCellRowIndex, int chunkCellColIndex, double _NoDataValue, boolean handleOutOfMemoryError, AbstractGrid2DSquareCell.ChunkID _ChunkID)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex, as a double.
 java.math.BigDecimal getCellBigDecimal(int chunkCellRowIndex, int chunkCellColIndex, double _NoDataValue, boolean handleOutOfMemoryError)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex, as a BigDecimal.
protected  Grid2DSquareCellDouble getGrid2DSquareCellDouble()
           
 Grid2DSquareCellDouble getGrid2DSquareCellDouble(boolean handleOutOfMemoryError)
           
protected  double getMaxDouble()
          Returns the maximum of all non _NoDataValues as a double.
 double getMaxDouble(boolean handleOutOfMemoryError)
          Returns the maximum of all non _NoDataValues as a double.
protected  double getMedianDouble()
          Returns the median of all non _NoDataValues as a double.
 double getMedianDouble(boolean handleOutOfMemoryError)
          Returns the median of all non _NoDataValues as a double.
protected  double getMinDouble()
          Returns the minimum of all non _NoDataValues as a double.
 double getMinDouble(boolean handleOutOfMemoryError)
          Returns the minimum of all non _NoDataValues as a double.
protected  gnu.trove.TDoubleHashSet getModeTDoubleHashSet()
          Returns the mode of all non _NoDataValues as a TDoubleHashSet.
 gnu.trove.TDoubleHashSet getModeTDoubleHashSet(boolean handleOutOfMemoryError)
          Returns the mode of all non _NoDataValues as a TDoubleHashSet.
protected  java.math.BigInteger getNonNoDataValueCountBigInteger()
          Returns the number of cells with _NoDataValues as a BigInteger.
 java.math.BigInteger getNonNoDataValueCountBigInteger(boolean handleOutOfMemoryError)
          Returns the number of cells with _NoDataValues as a BigInteger.
protected  int getNonNoDataValueCountInt()
          Returns the number of cells with _NoDataValues as an int.
 int getNonNoDataValueCountInt(boolean handleOutOfMemoryError)
          Returns the number of cells with _NoDataValues as an int.
protected  double getStandardDeviationDouble()
          Returns the standard deviation of all non _NoDataValues as a double.
 double getStandardDeviationDouble(boolean handleOutOfMemoryError)
          Returns the standard deviation of all non _NoDataValues as a double.
protected  java.math.BigDecimal getSumBigDecimal()
          Returns the sum of all non _NoDataValues as a BigDecimal.
 java.math.BigDecimal getSumBigDecimal(boolean handleOutOfMemoryError)
          Returns the sum of all non _NoDataValues as a BigDecimal.
protected abstract  void initCell(int chunkCellRowIndex, int chunkCellColIndex, double valueToInitialise)
          Initialises the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex.
 void initCell(int chunkCellRowIndex, int chunkCellColIndex, double valueToInitialise, boolean handleOutOfMemoryError)
          Initialises the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex.
protected  void initCells(Grid2DSquareCellDoubleChunkRAF grid2DSquareCellDoubleChunkRAF)
          Initialises the value of this with those in the Grid2DSquareCellDoubleChunkRAF grid2DSquareCellDoubleChunkRAF.
protected  void initCells(Grid2DSquareCellDoubleChunkRAF grid2DSquareCellDoubleChunkRAF, boolean handleOutOfMemoryError)
          Initialises the value of this with those in the Grid2DSquareCellDoubleChunkRAF grid2DSquareCellDoubleChunkRAF.
protected abstract  void initData()
          For initialising the data associated with this.
protected abstract  double setCell(int chunkCellRowIndex, int chunkCellColIndex, double valueToSet, double _NoDataValue)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex and sets it to valueToSet
 double setCell(int chunkCellRowIndex, int chunkCellColIndex, double valueToSet, double _NoDataValue, boolean handleOutOfMemoryError)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex and sets it to valueToSet
protected  void sort1(double[] x, int off, int len)
          Sorts the specified sub-array of doubles into ascending order.
protected  double[] toArrayIncludingNoDataValues()
          Returns all the values in row major order as a double[].
 double[] toArrayIncludingNoDataValues(boolean handleOutOfMemoryError)
          Returns all the values in row major order as a double[].
protected  double[] toArrayNotIncludingNoDataValues()
          Returns all the values in row major order as a double[].
 double[] toArrayNotIncludingNoDataValues(boolean handleOutOfMemoryError)
          Returns all the values (not including _NoDataVAlues) in row major order as a double[].
 
Methods inherited from class uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellChunk
getChunkID, getChunkID, getDescription, getGrid2DSquareCell, getGrid2DSquareCell, getIsSwapUpToDate, getIsSwapUpToDate, getName, getName, inChunk, inChunk, initChunkID, initGrid2DSquareCell, iterator, iterator, setIsSwapUpToDate, setIsSwapUpToDate, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractGrid2DSquareCellDoubleChunk

public AbstractGrid2DSquareCellDoubleChunk()
Method Detail

getGrid2DSquareCellDouble

public Grid2DSquareCellDouble getGrid2DSquareCellDouble(boolean handleOutOfMemoryError)
Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.
Returns:
( Grid2DSquareCellDouble ) this._Grid2DSquareCell._Grids_Environment.

getGrid2DSquareCellDouble

protected Grid2DSquareCellDouble getGrid2DSquareCellDouble()
Returns:
( Grid2DSquareCellDouble ) this._Grid2DSquareCell._Grids_Environment.

getCell

public double getCell(int chunkCellRowIndex,
                      int chunkCellColIndex,
                      double noDataValue,
                      boolean handleOutOfMemoryError)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex, as a double.

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
noDataValue - the _NoDataValue of this.grid2DSquareCellDouble
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getCell

public double getCell(int chunkCellRowIndex,
                      int chunkCellColIndex,
                      double _NoDataValue,
                      boolean handleOutOfMemoryError,
                      AbstractGrid2DSquareCell.ChunkID _ChunkID)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex, as a double.

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
noDataValue - the _NoDataValue of this.grid2DSquareCellDouble
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.
_ChunkID - This is a ChunkID for those AbstractGrid2DSquareCells not to be swapped if possible when an OutOfMemoryError is encountered.

getCell

protected abstract double getCell(int chunkCellRowIndex,
                                  int chunkCellColIndex,
                                  double _NoDataValue)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex, as a double.

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
noDataValue - the _NoDataValue of this.grid2DSquareCellDouble

getCellBigDecimal

public java.math.BigDecimal getCellBigDecimal(int chunkCellRowIndex,
                                              int chunkCellColIndex,
                                              double _NoDataValue,
                                              boolean handleOutOfMemoryError)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex, as a BigDecimal. If the value is this._NoDataValue then null is returned!

Parameters:
chunkCellRowIndex - The row index of the cell w.r.t. the origin of this chunk.
chunkCellColIndex - The column index of the cell w.r.t. the origin of this chunk.
noDataValue - The _NoDataValue of this.grid2DSquareCellDouble.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

initCell

public void initCell(int chunkCellRowIndex,
                     int chunkCellColIndex,
                     double valueToInitialise,
                     boolean handleOutOfMemoryError)
Initialises the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex. Utility method for constructors of extending classes.

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
valueToInitialise - the value with which the cell is initialised
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

initCell

protected abstract void initCell(int chunkCellRowIndex,
                                 int chunkCellColIndex,
                                 double valueToInitialise)
Initialises the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex. Utility method for constructors of extending classes.

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
valueToInitialise - the value with which the cell is initialised

initCells

protected void initCells(Grid2DSquareCellDoubleChunkRAF grid2DSquareCellDoubleChunkRAF,
                         boolean handleOutOfMemoryError)
Initialises the value of this with those in the Grid2DSquareCellDoubleChunkRAF grid2DSquareCellDoubleChunkRAF.

Parameters:
grid2DSquareCellDoubleChunkRAF - The Grid2DSquareCellDoubleChunkRAF used to initialise this.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

initCells

protected void initCells(Grid2DSquareCellDoubleChunkRAF grid2DSquareCellDoubleChunkRAF)
Initialises the value of this with those in the Grid2DSquareCellDoubleChunkRAF grid2DSquareCellDoubleChunkRAF.

Parameters:
grid2DSquareCellDoubleChunkRAF - The Grid2DSquareCellDoubleChunkRAF used to initialise this.

setCell

public double setCell(int chunkCellRowIndex,
                      int chunkCellColIndex,
                      double valueToSet,
                      double _NoDataValue,
                      boolean handleOutOfMemoryError)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex and sets it to valueToSet

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
valueToSet - the value the cell is to be set to
noDataValue - the _NoDataValue of this.grid2DSquareCellDouble
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

setCell

protected abstract double setCell(int chunkCellRowIndex,
                                  int chunkCellColIndex,
                                  double valueToSet,
                                  double _NoDataValue)
Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex and sets it to valueToSet

Parameters:
chunkCellRowIndex - the row index of the cell w.r.t. the origin of this chunk
chunkCellColIndex - the column index of the cell w.r.t. the origin of this chunk
valueToSet - the value the cell is to be set to
noDataValue - the _NoDataValue of this.grid2DSquareCellDouble

clearData

protected abstract void clearData()
For clearing the data associated with this.

Specified by:
clearData in class AbstractGrid2DSquareCellChunk

initData

protected abstract void initData()
For initialising the data associated with this.

Specified by:
initData in class AbstractGrid2DSquareCellChunk

toArrayIncludingNoDataValues

public double[] toArrayIncludingNoDataValues(boolean handleOutOfMemoryError)
Returns all the values in row major order as a double[].

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

toArrayIncludingNoDataValues

protected double[] toArrayIncludingNoDataValues()
Returns all the values in row major order as a double[].


toArrayNotIncludingNoDataValues

public double[] toArrayNotIncludingNoDataValues(boolean handleOutOfMemoryError)
Returns all the values (not including _NoDataVAlues) in row major order as a double[].

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

toArrayNotIncludingNoDataValues

protected double[] toArrayNotIncludingNoDataValues()
Returns all the values in row major order as a double[].


getNonNoDataValueCountBigInteger

public java.math.BigInteger getNonNoDataValueCountBigInteger(boolean handleOutOfMemoryError)
Returns the number of cells with _NoDataValues as a BigInteger.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getNonNoDataValueCountBigInteger

protected java.math.BigInteger getNonNoDataValueCountBigInteger()
Returns the number of cells with _NoDataValues as a BigInteger.


getNonNoDataValueCountInt

public int getNonNoDataValueCountInt(boolean handleOutOfMemoryError)
Returns the number of cells with _NoDataValues as an int.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getNonNoDataValueCountInt

protected int getNonNoDataValueCountInt()
Returns the number of cells with _NoDataValues as an int.


getSumBigDecimal

public java.math.BigDecimal getSumBigDecimal(boolean handleOutOfMemoryError)
Returns the sum of all non _NoDataValues as a BigDecimal.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getSumBigDecimal

protected java.math.BigDecimal getSumBigDecimal()
Returns the sum of all non _NoDataValues as a BigDecimal.


getMinDouble

public double getMinDouble(boolean handleOutOfMemoryError)
Returns the minimum of all non _NoDataValues as a double.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getMinDouble

protected double getMinDouble()
Returns the minimum of all non _NoDataValues as a double.


getMaxDouble

public double getMaxDouble(boolean handleOutOfMemoryError)
Returns the maximum of all non _NoDataValues as a double.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getMaxDouble

protected double getMaxDouble()
Returns the maximum of all non _NoDataValues as a double.


getArithmeticMeanBigDecimal

public java.math.BigDecimal getArithmeticMeanBigDecimal(int numberOfDecimalPlaces,
                                                        boolean handleOutOfMemoryError)
Returns the Arithmetic Mean of all non _NoDataValues as a BigDecimal. If all cells are _NoDataValues, then null is returned.

Parameters:
numberOfDecimalPlaces - The number of decimal places to which the result is precise.
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getArithmeticMeanBigDecimal

protected java.math.BigDecimal getArithmeticMeanBigDecimal(int numberOfDecimalPlaces)
Returns the Arithmetic Mean of all non _NoDataValues as a BigDecimal. If all cells are _NoDataValues, then null is returned.

Parameters:
numberOfDecimalPlaces - The number of decimal places to which the result is precise.

getArithmeticMeanDouble

public double getArithmeticMeanDouble(boolean handleOutOfMemoryError)
Returns the Arithmetic Mean of all non _NoDataValues as a double. If all cells are _NoDataValues, then this.grid2DSquareCellDouble._NoDataValue is returned.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getArithmeticMeanDouble

protected double getArithmeticMeanDouble()
Returns the Arithmetic Mean of all non _NoDataValues as a double. If all cells are _NoDataValues, then this.grid2DSquareCellDouble._NoDataValue is returned. Using BigDecimal this should be as precise as possible with doubles.


getModeTDoubleHashSet

public gnu.trove.TDoubleHashSet getModeTDoubleHashSet(boolean handleOutOfMemoryError)
Returns the mode of all non _NoDataValues as a TDoubleHashSet.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getModeTDoubleHashSet

protected gnu.trove.TDoubleHashSet getModeTDoubleHashSet()
Returns the mode of all non _NoDataValues as a TDoubleHashSet. TODO: Better to use toArray and go through a sorted version?


getMedianDouble

public double getMedianDouble(boolean handleOutOfMemoryError)
Returns the median of all non _NoDataValues as a double.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getMedianDouble

protected double getMedianDouble()
Returns the median of all non _NoDataValues as a double. This method requires that all data in chunk can be stored as a new array.


sort1

protected void sort1(double[] x,
                     int off,
                     int len)
Sorts the specified sub-array of doubles into ascending order. Source copied from java.util.Arrays and method changed so not static for performance reasons.


getStandardDeviationDouble

public double getStandardDeviationDouble(boolean handleOutOfMemoryError)
Returns the standard deviation of all non _NoDataValues as a double.

Parameters:
handleOutOfMemoryError - If true then OutOfMemoryErrors are caught, swap operations are initiated, then the method is re-called. If false then OutOfMemoryErrors are caught and thrown.

getStandardDeviationDouble

protected double getStandardDeviationDouble()
Returns the standard deviation of all non _NoDataValues as a double.