topcmapply
Array
Return value
An array of the required TYPE, whose elements are the result of
the requested operation. Depending on the operation and number of
elements in the input array, the result may be vulnerable to
overflow or underflow.
Parameters
op
in
required
array
in
required
dimapply
in
optional
default: 1 (ie, first dimension)
Keywords
double
default: not set
type
functargs
nocatch
Examples
First example: Shows how CMAPPLY can be used to total the second dimension of the
array called IN. This is equivalent to OUT = TOTAL(IN, 2)
IDL> IN = INDGEN(5,5)
IDL> OUT = CMAPPLY('+', IN, [2])
IDL> HELP, OUT
OUT INT = Array[5]
Second example: Input is assumed to be an 5x100 array of 1's and
0's indicating the status of 5 detectors at 100 points in time.
The desired output is an array of 100 values, indicating whether
all 5 detectors are on (=1) at one time. Use the logical AND
operation.
IDL> IN = detector_status ; 5x100 array
IDL> OUT = CMAPPLY('AND', IN, [1]) ; collapses 1st dimension
IDL> HELP, OUT
OUT BYTE = Array[100]
(note that MIN could also have been used in this particular case,
although there would have been more loop iterations).
Third example: Shows sum over first and third dimensions in an
array with dimensions 4x4x4:
IDL> IN = INDGEN(4,4,4)
IDL> OUT = CMAPPLY('+', IN, [1,3])
IDL> PRINT, OUT
408 472 536 600
Fourth example: A user-function (MEDIAN) is used:
IDL> IN = RANDOMN(SEED,10,10,5)
IDL> OUT = CMAPPLY('USER:MEDIAN', IN, 3)
IDL> HELP, OUT
OUT FLOAT = Array[10, 10]
(OUT[i,j] is the median value of IN[i,j,*])
Version history
Version
$Id: cmapply.pro 136 2006-07-10 15:20:19Z pinsard $
History
Mar 1998, Written, CM
Changed usage message to not bomb, 24 Mar 2000, CM
Signficant rewrite for *, MIN and MAX (inspired by Todd Clements
); FOR loop indices are now type
LONG; copying terms are liberalized, CM, 22, Aug 2000
More efficient MAX/MIN (inspired by Alex Schuster), CM, 25 Jan
2002
Make new MAX/MIN actually work with 3d arrays, CM, 08 Feb 2002
Add user-defined functions, ON_ERROR, CM, 09 Feb 2002
Correct bug in MAX/MIN initialization of RESULT, CM, 05 Dec 2002
Author: Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770
craigm@lheamail.gsfc.nasa.gov