Class CompositeMapFunction

java.lang.Object
noaa.coastwatch.util.chunk.CompositeMapFunction
All Implemented Interfaces:
ChunkFunction

public class CompositeMapFunction extends Object implements ChunkFunction

The CompositeMapFunction class outputs an integer composite map using a list of input chunks. The output map contains the integer chunk index from the list that each data value in the composite should come from. Note that this function does not apply the integer map, it only creates it. This is useful to selectively assemble data values from a time series or spatial series of partially overlapping data.

The function uses two methods to select chunk index values:

  • Optimization variable data chunks. The data values in the optimization chunks are used with a comparator to determine which chunk index at each data location the composite should come from. The optimization chunk with the maximum value according to the comparator is the one selected to provide the final composite integer value.
  • Priority variable data chunks. The data values in the priority chunks are checked for valid data. In the absence of optimization, the last chunk with a valid value is used to provide the final composite integer value. With optimization, the chunk with maximum comparator value is used. If no chunk has valid data in the first priority variable chunks, the next variable is checked, and so on until a chunk can be selected for the integer map.

In both cases above, if no chunk can be found with valid priority or optimization data, then a value of -1 is written to the output map. Otherwise, the index of the input chunk is written. Input data chunks to this function should be combined into a list as follows:

  • Optimization variable chunks fist, if applicable
  • Priority variable chunks, one variable at a time, if applicable

Output chunks from this method are ShortChunk objects with the missing value set to Short.MIN_VALUE.

Since:
3.8.1
Author:
Peter Hollemans
  • Constructor Details

    • CompositeMapFunction

      public CompositeMapFunction(int chunkCount, Comparator<Double> optComparator, int priorityVars)
      Creates a new integer composite map function.
      Parameters:
      chunkCount - the number of chunks that are being composited together.
      optComparator - the comparator to use to determine which chunk data value is optimal, or null to not perform an optimization.
      priorityVars - the count of priority variables to use, or zero for none.
  • Method Details

    • getMemory

      public long getMemory(ChunkPosition pos, int chunks)
      Description copied from interface: ChunkFunction
      Estimates the memory requirements for processing a chunk of data at the specified position, not including the input and output chunk internal data arrays.
      Specified by:
      getMemory in interface ChunkFunction
      Parameters:
      pos - the position to estimate the memory usage.
      chunks - the number of input chunks that will be processed at once.
      Returns:
      the memory in bytes.
    • apply

      public DataChunk apply(ChunkPosition pos, List<DataChunk> inputChunks)
      Description copied from interface: ChunkFunction
      Applies some function to a list of chunks.
      Specified by:
      apply in interface ChunkFunction
      Parameters:
      pos - the position to perform the function.
      inputChunks - the list of chunks as input to the function.
      Returns:
      the output chunk of the function, or null if no valid output chunk could be computed.
    • main

      public static void main(String[] argv) throws Exception
      Tests this class.
      Parameters:
      argv - the array of command line parameters.
      Throws:
      Exception