# [gradsusr] GFS_0p25 and total precip accum

Jeff Chabot jsc219 at gmail.com
Thu Jun 24 01:43:39 EDT 2021

```Thanks guys, that's very helpful.  I figured out a different way to
get it to work using this equation:

'define accum = sum(const(apcpsfc/25.4,0,-u),t-1,t+0) -
sum(const(apcpsfc/25.4,0,-u),t-1,t-1)'

I am using the const to take t =1 into account where the entire precip
field is undefined at the initialization.  To be honest, I think it
works with or without that.

I spent many hours on it, but in the end the above equation worked really well.

Sincerely,

Jeff

On Thu, Jun 24, 2021 at 12:15 AM Jeff Duda <jeffduda319 at gmail.com> wrote:
>
> Oh yeah, I almost forgot...the default units of apcpsfc are kg/m^2 (equivalent to mm). If you want values in inches, you need to divide the final value by 25.4. That should really shave down your final values.
>
> Jeff
>
> On Wed, Jun 23, 2021 at 2:11 PM Bill Reilly <bill_reilly at compuserve.com> wrote:
>>
>> I don't know if this helps, but this is how I display 3hr precipitation:
>>
>> if (tstep="006" | tstep="012" | tstep="018" | tstep="024" | tstep="030"
>> | tstep="036" | tstep="042" | tstep="048" | tstep="054" | tstep="060" |
>> tstep="066" | tstep="072" | tstep="084" | tstep="096" | tstep="108" |
>> tstep="120" | tstep="132" | tstep="144" | tstep="156" | tstep="168" |
>> tstep="180")
>>     'd (apcp03-apcp03(t-1))*10'
>> else
>>     'd const(apcp03,0.001,-u)*10'
>> endif
>>
>> --
>>
>> Bill Reilly
>>
>> (+34) 686-110-748
>>
>> bill at passageweather.com
>> www.passageweather.com
>>
>> On 06/23/2021 20:49, Jeff Duda wrote:
>> > Then I'd start checking the apcpsfc arrays in your individual files,
>> > because that might be the culprit.
>> >
>> > By the way, your looping syntax is incorrect. In grads, you perform
>> > modular arithmetic using R = math_fmod(N,D) for remainder R, number N,
>> > and divisor D. So you would use
>> > if (R = 0) ...
>> >
>> > On Tue, Jun 22, 2021 at 3:19 PM Jeff Chabot <jsc219 at gmail.com
>> > <mailto:jsc219 at gmail.com>> wrote:
>> >
>> >     Hi Jeff,
>> >
>> >     Thanks for the quick response.  I removed the const function. I was
>> >     using that part for my precip type equations, but as you said, I
>> >     probably don't need it.
>> >
>> >     As for what you mentioned, I couldn't get it to work.  I am trying to
>> >     show a running total of precip accum every 3 hours even though it
>> >     alternates between 3 and 6 hours precip.
>> >
>> >     So, I came up with the following based on what you wrote:
>> >
>> >     if (hh = 0 mod 6)
>> >       'display sum(apcpsfc/25.4,t=1,t-0,2)'
>> >      else
>> >       'display sum(apcpsfc/25.4,t=1,t-1,2) + apcpsfc/25.4'
>> >     endif
>> >
>> >     Where hh = forecast hour.
>> >
>> >     Unfortunately, it is still resulting in overestimated values such as
>> >     8-12 inches of total precip in 32 hours when it should be more like
>> >     3-5 inches and I don't have precip accum until hour 6 (hour 3 I get no
>> >     data).
>> >
>> >     I am missing something, I just don't know what.
>> >
>> >     Thanks again,
>> >
>> >     Jeff Chabot
>> >
>> >
>> >     On Tue, Jun 22, 2021 at 11:19 AM Jeff Duda <jeffduda319 at gmail.com
>> >     <mailto:jeffduda319 at gmail.com>> wrote:
>> >     >
>> >     > Jeff,
>> >     > It seems you are overcomplicating this.
>> >     >
>> >     > First, why are you using the const function for your sum? There
>> >     should be no negative values nor any undefined values in the
>> >     apcpsfc field. If there are, then there are problems at the level
>> >     of the data processing upstream of you.
>> >     >
>> >     > Second, my understanding of the precip array in GFS output is
>> >     that it alternates between 3- and 6-hour accumulation. So at 0300,
>> >     0900, 1500, 2100, apcpsfc contains 3-hour precipitation, whereas
>> >     at 0000, 0600, 1200, and 1800 UTC, apcpsfc contains 6-hour
>> >     precipitation. That means that pairs of adjacent time stamp
>> >     apcpsfc arrays are not independent of each other; the 6-hour
>> >     accumulation field completely contains the 3-hour precipitation
>> >     field. Therefore, if you are looking for run-total precipitation,
>> >     you only need to sum the apcpsfc arrays every other time stamp up
>> >     to the time before the valid time (or the valid time itself, if
>> >     the forecast hour is divisible by 6). The simple function
>> >     math_fmod(t,6) will give you the ability to decide if you are
>> >     computing this for forecast hours divisible only by 3.
>> >     >
>> >     > In essence, your display command really only needs to be
>> >     >
>> >     > * if forecast hour = 0 mod 6
>> >     > 'd sum(apcpsfc,t=1,t-0,2)'
>> >     > * else
>> >     > 'd sum(apcpsfc,t=1,t-1,2) + apcpsfc'
>> >     >
>> >     > ...or something similar to that.
>> >     >
>> >     > Jeff Duda
>> >     >
>> >     > On Tue, Jun 22, 2021 at 8:43 AM Jeff Chabot <jsc219 at gmail.com
>> >     <mailto:jsc219 at gmail.com>> wrote:
>> >     >>
>> >     >> Hi GrADS Users,
>> >     >>
>> >     >> I am having trouble with computing precip accum using just GFS_0p25
>> >     >> from NCEP.  The source that I am using is the following:
>> >     >>
>> >     >>
>> >     >>
>> >     >> To compute precip, I'm using:
>> >     >> 'define precip = const((apcpsfc/25.4),0,-u)'
>> >     >>
>> >     >> I set the following variables:
>> >     >> t=1
>> >     >> t0=0
>> >     >>
>> >     >> Then, in the while loop, I am using this equation to subtract 0-6
>> >     >> hours from 0-3 hours (Please note, I only need to do this for GFS):
>> >     >> 'define rain = const(precip(t='t') - precip(t='t0'),0,-u)'
>> >     >>
>> >     >> This works well for a 3 hour interval of precip (every three
>> >     hours up
>> >     >> to 10 days).
>> >     >>
>> >     >> Next, I am trying to apply a sum to it to get total accumulated
>> >     precip totals:
>> >     >> 'define accum = sum(rain,t=1,t='t')'
>> >     >>
>> >     >> For other models like NAM, I use the following since I don't
>> >     need the
>> >     >> define rain:
>> >     >> 'define accum = sum(precip,t=1,t='t')'
>> >     >>
>> >     >> I then do the counter and then end my loop:
>> >     >>
>> >     >> t = t+1
>> >     >> t0 = t0+1
>> >     >> endwhile
>> >     >>
>> >     >> I have tried modifying the define accum equation with no luck.
>> >     If I
>> >     >> use precip in the equation, then I get ridiculous precip totals
>> >     of 24
>> >     >> inches for 1/2 of the country in 10 days.  If I use rain, then
>> >     I'm not
>> >     >> getting total precipitation, instead I'm getting an interval.
>> >     >>
>> >     >> Any suggestions would be greatly appreciated.  I suspect that I
>> >     have
>> >     >> an error in my equation. the correct accum equation.
>> >     >>
>> >     >> Sincerely,
>> >     >>
>> >     >> Jeff
>> >     >> _______________________________________________
>> >     >> gradsusr mailing list
>> >     >
>> >     >
>> >     >
>> >     > --
>> >     > Jeff Duda, Research Scientist
>> >     > University of Colorado Boulder
>> >     > Cooperative Institute for Research in Environmental Sciences
>> >     > NOAA/OAR/ESRL/Global Systems Laboratory
>> >     > Boulder, CO
>> >     > _______________________________________________
>> >     > gradsusr mailing list
>> >
>> >     _______________________________________________
>> >
>> >
>> >
>> > --
>> > Jeff Duda, Research Scientist
>> > University of Colorado Boulder
>> > Cooperative Institute for Research in Environmental Sciences
>> > NOAA/OAR/ESRL/Global Systems Laboratory
>> > Boulder, CO
>> >
>> > _______________________________________________
>>
>> _______________________________________________
>
>
>
> --
> Jeff Duda, Research Scientist