Package noaa.coastwatch.util.chunk
Class ExpressionFunction
java.lang.Object
noaa.coastwatch.util.chunk.ExpressionFunction
- All Implemented Interfaces:
ChunkFunction
The
ExpressionFunction
class implements the
ChunkFunction
interface to perform mathematical expression
calculations on chunk data.- Since:
- 3.4.0
- Author:
- Peter Hollemans
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Provides expression variable values for this function to run. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionapply
(ChunkPosition pos, List<DataChunk> inputChunks) Applies some function to a list of chunks.long
getMemory
(ChunkPosition pos, int chunks) Estimates the memory requirements for processing a chunk of data at the specified position, not including the input and output chunk internal data arrays.void
init
(ExpressionParser parser, DataChunk resultPrototype) Initializes this function with the specified parser that will be used to evaluate expression values.void
setSkipMissing
(boolean flag) Sets the skip missing flag (by default set to false).
-
Constructor Details
-
ExpressionFunction
public ExpressionFunction()
-
-
Method Details
-
setSkipMissing
public void setSkipMissing(boolean flag) Sets the skip missing flag (by default set to false).- Parameters:
flag
- the new flag value. When the skip missing flag is set to true, the expression is not evaluated at all if any of the input values are set to missing. This has the advantage of saving computation time. When the flag is set to false, the expression is always evaluated and any missing values are used in the computation. This is important in cases when the expression includes a test for missing values such as an isNaN test, or if the data contains missing values that should actually be used in a computation (in some cases, flag variables are assigned a missing value of zero when they shouldn't be). Essentially the skip missing flag acts as an optimization in certain cases.
-
init
Initializes this function with the specified parser that will be used to evaluate expression values. The parser should be initialized and the expression parsed before calling this method.- Parameters:
parser
- the initialized and parsed expression parser.resultPrototype
- the result chunk prototype. The prototype will be used to generate new results when theapply(noaa.coastwatch.util.chunk.ChunkPosition, java.util.List<noaa.coastwatch.util.chunk.DataChunk>)
method is called.
-
getMemory
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 interfaceChunkFunction
- 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
Description copied from interface:ChunkFunction
Applies some function to a list of chunks.- Specified by:
apply
in interfaceChunkFunction
- 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.
-