5 day precipitation

Ben Burford benb at RESTEC.OR.JP
Fri Feb 10 05:11:00 EST 2006


Hi Arindam,

Again, thanks very much for your help.

Sorry if my last email was not clear - my meaning was that I didn't think yo
ur version of the algorithm was working correctly.  After receiving your ema
il I studied the documentation to understand your original version.  My unde
rstanding of the documentation was that, in the case of the simpler (my) ver
sion:
'count = sum(  const(  const(  maskout(prec,sum(prec,t+0,t+4)-tenpanave)  ,1
)  ,0,-u)  ,t=1,t=2918)'
for:
maskout(prec,sum(prec,t+0,t+4)-tenpanave)

if sum(prec,t+0,t+4) is greater than tenpanave, then no change;
if sum(prec,t+0,t+4) is less than tenpanave, then change the value of prec (
at the current value of t) to "missing value";

in your original verion of maskout(sum(prec,t+0,t+4),sum(prec,t+0,t+4)-tenpa
nave)
I don't know what its doing.  In the case of:
if sum(prec,t+0,t+4) is less than tenpanave, then change the value of sum(pr
ec,t+0,t+4) to "missing value";
Where is "sum(prec,t+0,t+4)" such that it can be changed to missing value?
Is it in the array prec, in an array representing "sum(prec,t+0,t+4)", in th
e array "count"?  I don't understand what Grads is doing internally, so this
 version didn't make any sense to me, and I thought there was an error.

After I applied your original version I was pretty surprised at the results
I got, so I doubted that your version was working correctly.  However, after
 I went home and was able to apply both versions (yours and mine) I found th
at the results were the same!  So now I'm both confused by how Grads execute
s your version (and surprised with (confused about) the results from my data
). . . . .


In any case, I'd really appreciate your help with one additional item.  I wo
uld like to apply a mask, to mask out ocean and only apply the algorithm to
land data.  Can you show me how to apply a land only mask (if possible) with
in your complex nesting process?

Thanks very much,

Ben





At 11:12 2006/02/09 -0500, you wrote:
> hi Ben,
>         your modified expression is correct if you want 'prec' to be
> undefined rather than 'sum(prec,t+0,t+4)'. But both of these are going
> to give the same result if you do not have undefined values in the
> original data (prec) since at last we are not taking the value of the
> variable to calculate anything but the number of time points it is
> defined (i.e., greater than or equal to tenpanave).
>         Why do you feel that the results are very close but not exact?
>
> regards,
>
> arindam
> ----------------------------
>  ARINDAM CHAKRABORTY
>  Department of Meteorology
>  Florida State University
>  Tallahassee, FL-32306, USA
>  Tel: +001-850-6443524 (Off)
>       +001-850-5758550 (Res)
>  Fax: +001-850-6449642
> ____________________________
>
> On Thu, 9 Feb 2006, Ben Burford wrote:
>
> > Hello Arindam,
> >
> > This is amazing!  Thank you very much.
> >
> > I've been working on figuring out the functions and the logic, and I thi
nk t
> > here is a mistake in your answer (but its very close).  I'd appreciate i
t if
> >  you would check this.
> >
> > In the innermost part you have:
> > maskout(sum(prec,t+0,t+4),sum(prec,t+0,t+4)-tenpanave)
> >
> > I think this means: "if the sum (of the 5 days of prec) is not greater t
han
> > tenpanave, then change 'sum(prec,t+0,t+4)' to missing value".
> >
> > I think the logic should be "if the sum (of the 5 days of prec) is not g
reat
> > er than tenpanave, then change 'prec' to missing value".
> >
> > So I think the innermost part should be:
> > maskout(prec,sum(prec,t+0,t+4)-tenpanave)
> >
> >
> > and the overall function would be:
> > 'count = sum(  const(  const(  maskout(prec,sum(prec,t+0,t+4)-tenpanave)
  ,1
> > )  ,0,-u)  ,t=1,t=2918)'
> >
> >
> > Is this right (or perhaps wrong)?
> >
> > Thank you very much,
> >
> > Ben
> >
> >
> >
> >
> > At 15:21 2006/02/07 -0500, you wrote:
> > > hi Ben,
> > >         you have an interesting problem to solve in grads. Probably
> > > it is possible to get the count and I'm giving the expression below,
> > > although I've not checked the answer thoroughly for my own data.
> > > You may try it out and see if it makes sense.
> > >
> > > If the threshold precipitation value is 'tenpanave' (you can
> > > define it the way you want before the expression to calculate
> > > the count, the way you showed the example in your mail).
> > > Then, the count is nothing but
> > > 'count = sum(const(const(maskout(sum(prec,t+0,t+4),sum(prec,t+0,t+4)-t
enpa
> > nave),1),0,-u),t=1,t=2918)'
> > > ...
> > >
> > >
> > > Hope this helps,
> > > ----------------------------
> > >  ARINDAM CHAKRABORTY
> > >  Department of Meteorology
> > >  Florida State University
> > >  Tallahassee, FL-32306, USA
> > >  Tel: +001-850-6443524 (Off)
> > >       +001-850-5758550 (Res)
> > >  Fax: +001-850-6449642
> > > ____________________________
> > >
> > > On Tue, 7 Feb 2006, Ben Burford wrote:
> > >
> > > > Hello All,
> > > >
> > > > I'm trying to implement a script.  I studied functions (e.g. tloop)
and
> > look
> > > > ed in the archives for help, but so far its over my head as a beginn
er,
> > I'm
> > > > not even sure if Grads can do this.
> > > >
> > > > I have an 8 year (t=1,2922) global gridded daily precipitation data
set.
> >   Fo
> > > > r each grid cell I want to go through the time series and check each
 fiv
> > e da
> > > > y period (2918 possible 5 day periods) to see if the total of the pr
ecip
> > itat
> > > > ion for the five days is greater than a certain level, if it is I wa
nt t
> > o in
> > > > crement a counter.  The result will be a single value (total count)
for
> > each
> > > >  grid cell (global grid of a single value per grid cell).
> > > >
> > > > The value that I want to check the five day total against is "10% of
 the
> >  ann
> > > > ual average rainfall" (tenpanave) which I'm calculating as follows (
add
> > up a
> > > > ll the daily values for 8 years, divide by 8 to get the annual avera
ge,
> > then
> > > >  take 10% of that):
> > > > tenpanave = 0.1*((sum(prec,t=1,t=2922))/8)
> > > >
> > > > A flow chart for the script might look like:
> > > > * Calculate "10% of the annual average rainfall" (tenpanave)
> > > > tenpanave = 0.1*((sum(prec,t=1,t=2922))/8)
> > > >
> > > > * calculate the precipitation over 5 days (5dayprec), if that 5 day
tota
> > l is
> > > >  greater than or equal to ten percent of the annual average precipit
atio
> > n (t
> > > > enpanave) for that grid cell, then increment the counter for that gr
id c
> > ell.
> > > >   Perform this process for all grid cells, over the full time period
 of
> > 2922
> > > >  days (x from 1 to 2918).
> > > > x=1
> > > > 5dayprec=sum(prec,t=x,t=x+4)
> > > > if 5dayprec is greater than or equal to tenpanave then count=count+1
> > > > x=x+1
> > > > if x=2919 then quit, else go up three steps and calculate the next 5
 day
> >  win
> > > > dow (5dayp)
> > > >
> > > > * Display results
> > > > d count
> > > >
> > > >
> > > > As I say, I don't know if this can be done with Grads.  Any help wou
ld b
> > e gr
> > > > eatly appreciated.
> > > >
> > > > Thank you,
> > > >
> > > > Ben
> > > >
> > >
> >
> >
>



More information about the gradsusr mailing list