Page 1 of 1

Posted: Mon Feb 06, 2017 10:28 am
Hi folks!

I have one problem in GRADS scripting.

I've defined variable:

Code: Select all

``'define gdd=((((TMP2m(t='i+6')-'kelvin')+(TMP2m(t='i+12')-'kelvin'))/2)-10)'``
and I need to set gdd = 0 if gdd < 0 but to do on the whole field so I can draw it.

I may put in drawings options to start to draw with 0, all below with the same color, but I have to make accumulated variable too:

Code: Select all

``gddsum = SUM(gdd(1),.., gdd(n)).``
I've tried with

Code: Select all

`` if(gdd < 0); gdd = 0; endif ``
in several variants (with or without quotes, partial quotes, semi quotes,....) but nothing gave any result. Sometimes I've got errors, sometimes it just pass over it without calculating...
I've tried with math_nint, nothing happened...

Do you have any idea how to solve this problem?

Nebojša

Posted: Mon Feb 06, 2017 8:56 pm
Well, a very simple solution of this problem got on my mind and it works.
Problem: I need only positive values of the variable and if it is negative it should be set on 0.
So, to achieve this, I used abs() function!

Code: Select all

``````'define gdd=((((TMP2m(t='i+6')-'kelvin')+(TMP2m(t='i+12')-'kelvin'))/2)-10)'
'define gddx = (gdd + abs(gdd))/2``````