[gradsusr] Finding max values at each index for several arrays

Jeff Duda jeffduda319 at gmail.com
Mon Apr 13 17:07:51 EDT 2020


Matt,
If you can group those arrays together using one of the dimensions (time,
height, ensemble etc.) then you can use one of the built-in functions. If
you can't do that, then you'd have to get creative and use a recursive
function to find maxes of increasingly complex pairs of arrays using nested
if() statements. For example:

Start with any pair of two fields.

'define maxfield = if(field1 > field2,field1,field2)'
'maxfield = if(field3 > maxfield,field3,maxfield)'
'maxfield = if(field4 > maxfield,field4,maxfield)'
...
...
...
'maxfieldfinal = if(field'n' > maxfield,field'n',maxfield)'

You can probably use a while loop to handle the intermediate steps there.

Jeff Duda

On Mon, Apr 13, 2020 at 2:06 PM Matt Bunkers - NWS Rapid City <
matthew.bunkers at noaa.gov> wrote:

> Hello,
>
> I am trying to fund a function (or otherwise straightforward way) to find
> the max value at each index (i, j) for several 2D arrays (e.g., input 8
> arrays and get 1 array that has the max value for each grid point). GrADS
> only seems to have functions to calculate the max over an individual
> array.  Does anyone know of a script to do this?
>
> Thanks,
>
> -- Matt
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>


-- 
Jeff Duda, Research Scientist
University of Colorado Boulder
Cooperative Institute for Research in Environmental Sciences
NOAA/OAR/ESRL/Global Systems Laboratory
Boulder, CO
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://gradsusr.org/pipermail/gradsusr/attachments/20200413/4d91d078/attachment.html>


More information about the gradsusr mailing list