## GRADS calculating problem

All other topics about postprocessing model data (GrADS and other software), about other numerical weather prediction software (including WRF-NMM and WRF-ARW discussion unrelated to UEMS/WRF EMS), and general meteorology talk go in this forum.
nebojsa
Posts: 133
Joined: Sun Mar 21, 2010 3:40 pm

### GRADS calculating problem

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

nebojsa
Posts: 133
Joined: Sun Mar 21, 2010 3:40 pm

### Re: GRADS calculating problem

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``````

dominic
Posts: 336
Joined: Thu Jun 14, 2012 7:19 am

### Re: GRADS calculating problem

I did not understand what you're getting with this formula