[ncl-talk] question: is there a built-in function for?

Dennis Shea shea at ucar.edu
Wed Jun 27 07:54:37 MDT 2018


Well, there can not be an NCL  function for 'everything' , you just have to
write one.

undef("steps_tf")
function steps_tf(x[*]:numeric)
local nx, foo, tf
begin
  nx  = dimsizes(x)
  foo = x(1:)-x(0:nx-2)
  tf    = where(foo.ge.0, 1, 0)
  return(tf)
end
;=============
;   test
;============

   x = (/ 1,2,3,2,-1,-1,2 /)
   tf= steps_tf(x)
   print(tf)

=======================================

%> ncl damjan.ncl

Variable: tf
Type: integer
Total Size: 24 bytes
            6 values
Number of Dimensions: 1
Dimensions and sizes:    [6]
Coordinates:
(0)    1
(1)    1
(2)    0
(3)    0
(4)    1
(5)    1


On Wed, Jun 27, 2018 at 4:39 AM, Damjan Jelic <dnjelic at gmail.com> wrote:

> Dear NCL support,
>
> is there any built-in function which can compare consecutive steps and
> assign true/false if difference is positive or negative? for example:
> input  :1,2,3,2,-1,-1,2
> output:1,1,0,0, 1, 1
>
> all the best!
> Damjan
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180627/e556113e/attachment.html>


More information about the ncl-talk mailing list