[ncl-talk] Add new options for dim_cumsum
Dave Allured - NOAA Affiliate
dave.allured at noaa.gov
Fri Nov 24 14:38:19 MST 2017
NCL team,
I would like to suggest several new options for the dim_cumsum family of
four functions. The current three options are:
opt = 0 ; when _FillValue is encountered no additional summing will be
performed.
opt = 1 ; when _FillValue is encountered set element to _FillValue and
resume summing.
opt = 2 ; treat _FillValue as numeric zero when summing.
Frequently only the final array slice of the customized summing operation
is wanted. So I propose several new options:
opt = 4 ; when _FillValue is encountered, return _FillValue.
opt = 5 ; return sum only up to the first encountered _FillValue.
opt = 6 ; return sum only following the last encountered _FillValue.
opt = 7 ; treat _FillValue as numeric zero, and return only the final sum.
The first three existing options return an array of the same type and
dimensionality as *x*. These four new options would return an array of one
lesser rank than x; the summing dimension would be removed.
Options 4, 6, and 7 would return exactly the same result as taking the
"last" array slice on the summing dimension, of options 0, 1, and 2
respectively.
Option 5 would be special. Summing would end on the FIRST encountered
_FillValue, and that result would be returned. Option 5 would be exactly
the same as option 6 with reversed input ordering on the summing
dimension. Option 5 is included mainly for symmetry and completeness.
To be consistent with current option 1, _FillValue is explicitly returned
when:
opt = 5 and the first input element is _FillValue.
opt = 6 and the last input element is _FillValue.
These new options would simplify user code in some cases, such as Rashed's
case today. In large array applications, these options could also reduce
memory consumption and run time.
--Dave
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171124/155d79af/attachment.html>
More information about the ncl-talk
mailing list