[ncl-talk] Percent calculation

Rashed Mahmood rashidcomsis at gmail.com
Sun Mar 3 05:37:10 MST 2019


Hi Jalal,
It could be done through a single do loop, something like:

pcp_ratio = pre
pcp_ratio = pre at _FillValue

do n=0,dimsizes(pre(:,0,0))-1
    pcp_ratio(n,:,:) = (pre(n,:,:)/sumpre)*100
end do

Note that if you have 0 value(s) in sumpre, it would give you division by
zero error. You would need to decide how deal with zero values...NCL's
"where" function is very efficient in performing such tasks.

Cheers,
Rashed










On Sun, Mar 3, 2019 at 2:18 AM Md. Jalal Uddin <dmjalal90 at gmail.com> wrote:

> Hi all,
>
> I have precipitation data pre (ntim, nlat, nlon). I want to calculate the
> percentage like (pre / sumpre) * 100, here sumpre is two dimension but pre
> is 3 dimension. How can I calculate? Is there any function in NCl?
>
> Best Regards,
> Jalal
>
> --
> *Md. Jalal Uddin*
> MSc in Applied Meteorology (English Language)
> Nanjing University of Information, Science and Technology, China
> B.Sc. in Disaster Management (Hons.)
> Patuakhali Science and Technology University, Bangladesh.
> Cell: +8613260859092, +8801792052662
> Web: www.dmjalal90.weebly.com
> Facebook: jalal.hossen.39
> LinkedIn: https://bd.linkedin.com/in/md-jalal-uddin-80a026b0
> Twitter: dmjalal90
> Skype: dmjalal90
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190303/f5b0087e/attachment.html>


More information about the ncl-talk mailing list