# Re: DSI calculation

From: Debasish PaiMazumder <debasish_at_nyahnyahspammersnyahnyah>
Date: Thu, 13 Aug 2009 14:39:06 -0400

Hello,

I just want to inform you that I have solved the problem by using
"where" function.

sorry for the inconvenience

Thanks

Debasish

On 09-08-12, at 13:59, Debasish PaiMazumder wrote:

> Hello,
>
> I have an rainfall anomaly data prec(month,gridcell) where month =
> 252 and gridcell = 30960.
> I am trying to calculate three-month drought severity index (DSI3)
>
> The definition of DSI3
>
> Rainfall anomaly = Xt @ month=t
> If Xt < 0 and the rainfall in three-month period, Xt, Xt-1, Xt-2,
> is lower than its three monthly mean i.e. (Xt+Xt-1+Xt-2)< (1/3)(Xt
> +Xt-1+Xt-2)
> Then DSI3(t)=-Xt
>
> For time t+1, if it satisfies the previous conditions,
> Then DSI3(t+1)=-(Xt+Xt+1)
>
> But if rainfall anomaly is positive i.e. Xt+1> 0 and the rainfall
> in three-month period, Xt+1, Xt, Xt-1, is lower than its three
> monthly mean i.e. (Xt+1+Xt+Xt-1)< (1/3)(Xt+1+Xt+Xt-1), Then DSI3(t
> +1)= -(Xt-Xt+1)
>
> If, for time t+1, it does not stratify any previous conditions then
> DSI3(t+1)= 0
>
> I used do loops and if statements to calculate DSI but it took long
> time. I guess I need to use “where” or “ind” to make it faster.
>
> Any help to do these calculations using above mention function will
> be appreciated
>
> Thanks
>
> Debasish
>
>
> Debasish PaiMazumder, PhD
> Hydrology & Climate Science
> Postdoctoral Researcher at UQÀM/Ouranos
> 550, Sherbrooke west, 19th floor, west tower,
> Montréal, QC, Canada H3A 1B9
> Tel: (514) 282-6464-343
> (514) 937-0042 (R)
> email: debasish_at_sca.uqam.ca
>
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Debasish PaiMazumder, PhD
Hydrology & Climate Science
Postdoctoral Researcher at UQÀM/Ouranos
550, Sherbrooke west, 19th floor, west tower,