NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.

To learn about what's going on, see About the Archive Site.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[IDV #KZD-153013]: (No Subject)



Hi Muhammad-

> I found that in the Grid diagnostic function
> def add(S1,S2):
> """ Addition
> <div class=jython>
> ADD  (S1, S2) = S1 + S2
> </div>
> """
> return GridMath.add(S1,S2)
> 
> It only allows for two variables, S1 and S2.
> 
> I've tried to add more variables but then an error exist.
> 
> Is it possible to modifiy the function so we could use more than 2 variables?


add, sub, mult, etc are meant to be low level routines between
two paramaters.  You can always string together multiple adds:

add(add(s1,s2),s3)

or create a multi-add function (madd):

def madd(a):
   sum = 0
   for i in range(len(a)):
      if i == 0:
         sum = a[i]
      else:
         sum = add(sum, a[i])
   return sum

and call it with:

madd(a[multiple=true])

Don Murray


Ticket Details
===================
Ticket ID: KZD-153013
Department: Support IDV
Priority: Normal
Status: Open