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

java.lang.Object
  extended by uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellChunk
      extended by uk.ac.leeds.ccg.andyt.grids.core.AbstractGrid2DSquareCellDoubleChunk
          extended by uk.ac.leeds.ccg.andyt.grids.core.Grid2DSquareCellDoubleChunk64CellMap
All Implemented Interfaces:
java.io.Serializable

public class Grid2DSquareCellDoubleChunk64CellMap
extends AbstractGrid2DSquareCellDoubleChunk
implements java.io.Serializable

AbstractGrid2DSquareCellDoubleChunk extension that stores cell values in a TDoubleLongHashMap. The maximum size of this AbstractGrid2DSquareCellDoubleChunk is 64 cells. TODO: Adjudicate when this is useful. What type of data?

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
  Grid2DSquareCellDoubleChunk64CellMap()
          Creates a new Grid2DSquareCellDoubleChunk64CellMap.
protected Grid2DSquareCellDoubleChunk64CellMap(AbstractGrid2DSquareCellDoubleChunk grid2DSquareCellDoubleChunk, AbstractGrid2DSquareCell.ChunkID _ChunkID)
          Creates a new Grid2DSquareCellDoubleChunk64CellMap.
protected Grid2DSquareCellDoubleChunk64CellMap(Grid2DSquareCellDouble grid2DSquareCellDouble, AbstractGrid2DSquareCell.ChunkID _ChunkID)
          Creates a new Grid2DSquareCellDoubleChunk64CellMap.
 
Method Summary
protected  void clearData()
          Clears the data associated with this.
protected  java.math.BigDecimal getArithmeticMeanBigDecimal(int numberOfDecimalPlaces)
          For returning the Arithmetic Mean of all non _NoDataValues as a BigDecimal.
protected  double getArithmeticMeanDouble()
          For returning the Arithmetic Mean of all non _NoDataValues as a double.
protected  double getCell(int chunkCellRowIndex, int chunkCellColIndex, double _NoDataValue)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell row chunkCellColIndex.
protected  gnu.trove.TDoubleLongHashMap getData()
          Returns this.data TODO: This could be made public if a copy is returned!
protected  java.math.BigInteger getDiversity()
          For returning the number of different values.
protected  double getGeometricMeanDouble()
          For returning the Geometric Mean of all non _NoDataValues as a double Warning! This is imprecise and it can happen that Math.pow does not return what might be expected! (For example, negative powers in the range (0,1) for negative numbers.) TODO: Develop a pow function such as com.ibm.icu.math.BigDecimal.pow This resource is not used here due to licensing, but it could be...
protected  double getHarmonicMeanDouble()
          Returns the Harmonic Mean of all non _NoDataValues as a double.
protected  double getMaxDouble()
          For returning the maximum of all non _NoDataValues as a double
protected  double getMedianDouble()
          For returning the median of all non _NoDataValues as a double
protected  double getMinDouble()
          For returning the minimum of all non _NoDataValues as a double
protected  gnu.trove.TDoubleHashSet getModeTDoubleHashSet()
          For returning the mode of all non _NoDataValues as a TDoubleHashSet
protected  java.math.BigInteger getNonNoDataValueCountBigInteger()
          Returns the number of cells with _NoDataValues as a BigInteger
protected  int getNonNoDataValueCountInt()
          Returns the number of cells with _NoDataValues as an int
protected  double getStandardDeviationDouble()
          For returning the standard deviation of all non _NoDataValues as a double
protected  java.math.BigDecimal getSumBigDecimal()
          For returning the sum of all non _NoDataValues as a BigDecimal
protected  void initCell(int chunkCellRowIndex, int chunkCellColIndex, double valueToInitialise)
          Initialises the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex.
protected  void initData()
          Initialises the data associated with this.
protected  AbstractIterator iterator()
          Returns a Grid2DSquareCellDoubleChunk64CellMapIterator for iterating over the cells in this.
protected  long powerOf2(int value)
          Returns 2 raised to the power of value as a long.
 long powerOf2(int value, boolean handleOutOfMemoryError)
          Returns 2 raised to the power of value as a long.
protected  double setCell(int chunkCellRowIndex, int chunkCellColIndex, double valueToSet, double _NoDataValue)
          Returns the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex and sets it to valueToSet
protected  double[] toArrayIncludingNoDataValues()
          Returns all the values in row major order as a double[].
protected  double[] toArrayNotIncludingNoDataValues()
          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.AbstractGrid2DSquareCellDoubleChunk
getArithmeticMeanBigDecimal, getArithmeticMeanDouble, getCell, getCell, getCellBigDecimal, getGrid2DSquareCellDouble, getGrid2DSquareCellDouble, getMaxDouble, getMedianDouble, getMinDouble, getModeTDoubleHashSet, getNonNoDataValueCountBigInteger, getNonNoDataValueCountInt, getStandardDeviationDouble, getSumBigDecimal, initCell, initCells, initCells, setCell, sort1, toArrayIncludingNoDataValues, toArrayNotIncludingNoDataValues
 
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, setIsSwapUpToDate, setIsSwapUpToDate, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Grid2DSquareCellDoubleChunk64CellMap

public Grid2DSquareCellDoubleChunk64CellMap()
Creates a new Grid2DSquareCellDoubleChunk64CellMap.


Grid2DSquareCellDoubleChunk64CellMap

protected Grid2DSquareCellDoubleChunk64CellMap(Grid2DSquareCellDouble grid2DSquareCellDouble,
                                               AbstractGrid2DSquareCell.ChunkID _ChunkID)
Creates a new Grid2DSquareCellDoubleChunk64CellMap.

Parameters:
grid2DSquareCellDouble - The Grid2DSquareCellDouble this is a chunk of.
_ChunkID - The ChunkID this will have. TODO: deal with case: ( grid2DSquareCellDouble.getChunkNrows() * grid2DSquareCellDouble.getChunkNcols() > 64 )

Grid2DSquareCellDoubleChunk64CellMap

protected Grid2DSquareCellDoubleChunk64CellMap(AbstractGrid2DSquareCellDoubleChunk grid2DSquareCellDoubleChunk,
                                               AbstractGrid2DSquareCell.ChunkID _ChunkID)
Creates a new Grid2DSquareCellDoubleChunk64CellMap.

Parameters:
grid2DSquareCellDoubleChunk - The AbstractGrid2DSquareCellDoubleChunkk this is constructed from.
_ChunkID - The ChunkID this will have.
Method Detail

initData

protected void initData()
Initialises the data associated with this.

Specified by:
initData in class AbstractGrid2DSquareCellDoubleChunk

clearData

protected void clearData()
Clears the data associated with this.

Specified by:
clearData in class AbstractGrid2DSquareCellDoubleChunk

getData

protected gnu.trove.TDoubleLongHashMap getData()
Returns this.data TODO: This could be made public if a copy is returned!


toArrayIncludingNoDataValues

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

Overrides:
toArrayIncludingNoDataValues in class AbstractGrid2DSquareCellDoubleChunk

toArrayNotIncludingNoDataValues

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

Overrides:
toArrayNotIncludingNoDataValues in class AbstractGrid2DSquareCellDoubleChunk

getCell

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

Specified by:
getCell in class AbstractGrid2DSquareCellDoubleChunk
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.

initCell

protected void initCell(int chunkCellRowIndex,
                        int chunkCellColIndex,
                        double valueToInitialise)
Initialises the value at position given by: chunk cell row chunkCellRowIndex; chunk cell column chunkCellColIndex.

Specified by:
initCell in class AbstractGrid2DSquareCellDoubleChunk
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.

setCell

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

Specified by:
setCell in class AbstractGrid2DSquareCellDoubleChunk
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

powerOf2

public long powerOf2(int value,
                     boolean handleOutOfMemoryError)
Returns 2 raised to the power of value as a long.

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.

powerOf2

protected long powerOf2(int value)
Returns 2 raised to the power of value as a long.


getNonNoDataValueCountBigInteger

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

Overrides:
getNonNoDataValueCountBigInteger in class AbstractGrid2DSquareCellDoubleChunk

getNonNoDataValueCountInt

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

Overrides:
getNonNoDataValueCountInt in class AbstractGrid2DSquareCellDoubleChunk

getSumBigDecimal

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

Overrides:
getSumBigDecimal in class AbstractGrid2DSquareCellDoubleChunk

getMinDouble

protected double getMinDouble()
For returning the minimum of all non _NoDataValues as a double

Overrides:
getMinDouble in class AbstractGrid2DSquareCellDoubleChunk

getMaxDouble

protected double getMaxDouble()
For returning the maximum of all non _NoDataValues as a double

Overrides:
getMaxDouble in class AbstractGrid2DSquareCellDoubleChunk

getArithmeticMeanBigDecimal

protected java.math.BigDecimal getArithmeticMeanBigDecimal(int numberOfDecimalPlaces)
For returning the Arithmetic Mean of all non _NoDataValues as a BigDecimal. Using BigDecimal this should be as precise as possible with doubles.

Overrides:
getArithmeticMeanBigDecimal in class AbstractGrid2DSquareCellDoubleChunk
Parameters:
numberOfDecimalPlaces - The number of decimal places for precision.

getArithmeticMeanDouble

protected double getArithmeticMeanDouble()
For returning the Arithmetic Mean of all non _NoDataValues as a double. Using BigDecimal this should be as precise as possible with doubles.

Overrides:
getArithmeticMeanDouble in class AbstractGrid2DSquareCellDoubleChunk

getGeometricMeanDouble

protected double getGeometricMeanDouble()
For returning the Geometric Mean of all non _NoDataValues as a double Warning! This is imprecise and it can happen that Math.pow does not return what might be expected! (For example, negative powers in the range (0,1) for negative numbers.) TODO: Develop a pow function such as com.ibm.icu.math.BigDecimal.pow This resource is not used here due to licensing, but it could be...


getHarmonicMeanDouble

protected double getHarmonicMeanDouble()
Returns the Harmonic Mean of all non _NoDataValues as a double. Zero values are ignored in the calculation.


getModeTDoubleHashSet

protected gnu.trove.TDoubleHashSet getModeTDoubleHashSet()
For returning the mode of all non _NoDataValues as a TDoubleHashSet

Overrides:
getModeTDoubleHashSet in class AbstractGrid2DSquareCellDoubleChunk

getMedianDouble

protected double getMedianDouble()
For returning the median of all non _NoDataValues as a double

Overrides:
getMedianDouble in class AbstractGrid2DSquareCellDoubleChunk

getStandardDeviationDouble

protected double getStandardDeviationDouble()
For returning the standard deviation of all non _NoDataValues as a double

Overrides:
getStandardDeviationDouble in class AbstractGrid2DSquareCellDoubleChunk

getDiversity

protected java.math.BigInteger getDiversity()
For returning the number of different values.


iterator

protected AbstractIterator iterator()
Returns a Grid2DSquareCellDoubleChunk64CellMapIterator for iterating over the cells in this.

Specified by:
iterator in class AbstractGrid2DSquareCellChunk