<div dir="ltr"><div>Then I'd start checking the apcpsfc arrays in your individual files, because that might be the culprit.</div><div><br></div><div>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</div><div>if (R = 0) ...<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 22, 2021 at 3:19 PM Jeff Chabot <<a href="mailto:jsc219@gmail.com">jsc219@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Jeff,<br>
<br>
Thanks for the quick response.  I removed the const function.  I was<br>
using that part for my precip type equations, but as you said, I<br>
probably don't need it.<br>
<br>
As for what you mentioned, I couldn't get it to work.  I am trying to<br>
show a running total of precip accum every 3 hours even though it<br>
alternates between 3 and 6 hours precip.<br>
<br>
So, I came up with the following based on what you wrote:<br>
<br>
if (hh = 0 mod 6)<br>
  'display sum(apcpsfc/25.4,t=1,t-0,2)'<br>
 else<br>
  'display sum(apcpsfc/25.4,t=1,t-1,2) + apcpsfc/25.4'<br>
endif<br>
<br>
Where hh = forecast hour.<br>
<br>
Unfortunately, it is still resulting in overestimated values such as<br>
8-12 inches of total precip in 32 hours when it should be more like<br>
3-5 inches and I don't have precip accum until hour 6 (hour 3 I get no<br>
data).<br>
<br>
I am missing something, I just don't know what.<br>
<br>
Thanks again,<br>
<br>
Jeff Chabot<br>
<br>
<br>
On Tue, Jun 22, 2021 at 11:19 AM Jeff Duda <<a href="mailto:jeffduda319@gmail.com" target="_blank">jeffduda319@gmail.com</a>> wrote:<br>
><br>
> Jeff,<br>
> It seems you are overcomplicating this.<br>
><br>
> 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.<br>
><br>
> 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.<br>
><br>
> In essence, your display command really only needs to be<br>
><br>
> * if forecast hour = 0 mod 6<br>
> 'd sum(apcpsfc,t=1,t-0,2)'<br>
> * else<br>
> 'd sum(apcpsfc,t=1,t-1,2) + apcpsfc'<br>
><br>
> ...or something similar to that.<br>
><br>
> Jeff Duda<br>
><br>
> On Tue, Jun 22, 2021 at 8:43 AM Jeff Chabot <<a href="mailto:jsc219@gmail.com" target="_blank">jsc219@gmail.com</a>> wrote:<br>
>><br>
>> Hi GrADS Users,<br>
>><br>
>> I am having trouble with computing precip accum using just GFS_0p25<br>
>> from NCEP.  The source that I am using is the following:<br>
>><br>
>> <a href="http://nomads.ncep.noaa.gov:80/dods/gfs_0p25/gfs20210622/gfs_0p25_00z" rel="noreferrer" target="_blank">http://nomads.ncep.noaa.gov:80/dods/gfs_0p25/gfs20210622/gfs_0p25_00z</a><br>
>><br>
>> To compute precip, I'm using:<br>
>> 'define precip = const((apcpsfc/25.4),0,-u)'<br>
>><br>
>> I set the following variables:<br>
>> t=1<br>
>> t0=0<br>
>><br>
>> Then, in the while loop, I am using this equation to subtract 0-6<br>
>> hours from 0-3 hours (Please note, I only need to do this for GFS):<br>
>> 'define rain = const(precip(t='t') - precip(t='t0'),0,-u)'<br>
>><br>
>> This works well for a 3 hour interval of precip (every three hours up<br>
>> to 10 days).<br>
>><br>
>> Next, I am trying to apply a sum to it to get total accumulated precip totals:<br>
>> 'define accum = sum(rain,t=1,t='t')'<br>
>><br>
>> For other models like NAM, I use the following since I don't need the<br>
>> define rain:<br>
>> 'define accum = sum(precip,t=1,t='t')'<br>
>><br>
>> I then do the counter and then end my loop:<br>
>><br>
>> t = t+1<br>
>> t0 = t0+1<br>
>> endwhile<br>
>><br>
>> I have tried modifying the define accum equation with no luck.  If I<br>
>> use precip in the equation, then I get ridiculous precip totals of 24<br>
>> inches for 1/2 of the country in 10 days.  If I use rain, then I'm not<br>
>> getting total precipitation, instead I'm getting an interval.<br>
>><br>
>> Any suggestions would be greatly appreciated.  I suspect that I have<br>
>> an error in my equation. the correct accum equation.<br>
>><br>
>> Sincerely,<br>
>><br>
>> Jeff<br>
>> _______________________________________________<br>
>> gradsusr mailing list<br>
>> <a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
>> <a href="http://gradsusr.org/mailman/listinfo/gradsusr" rel="noreferrer" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
><br>
><br>
><br>
> --<br>
> Jeff Duda, Research Scientist<br>
> University of Colorado Boulder<br>
> Cooperative Institute for Research in Environmental Sciences<br>
> NOAA/OAR/ESRL/Global Systems Laboratory<br>
> Boulder, CO<br>
> _______________________________________________<br>
> gradsusr mailing list<br>
> <a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
> <a href="http://gradsusr.org/mailman/listinfo/gradsusr" rel="noreferrer" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
<br>
_______________________________________________<br>
gradsusr mailing list<br>
<a href="mailto:gradsusr@gradsusr.org" target="_blank">gradsusr@gradsusr.org</a><br>
<a href="http://gradsusr.org/mailman/listinfo/gradsusr" rel="noreferrer" target="_blank">http://gradsusr.org/mailman/listinfo/gradsusr</a><br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><font size="2"><span>Jeff Duda, Research Scientist</span></font></div><div dir="ltr"><font size="2"><span></span></font>University of Colorado Boulder</div><div dir="ltr"><font size="2"><span></span></font>Cooperative Institute for Research in Environmental Sciences</div><div dir="ltr">NOAA/OAR/ESRL/Global Systems Laboratory<br><font size="2"><span>

<span>Boulder, CO<br></span></span></font>



</div></div></div></div></div></div></div></div></div></div>