[ncl-talk] Percent calculation

Dennis Shea shea at ucar.edu
Thu Mar 7 13:05:55 MST 2019


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

 do n=0,dimsizes(pre(:,0,0))-1
      plot = gsn_csm_contour_map(wks, pcp_ratio(n,:,:), res)
 end do

In NCL, pcp_ratio(n,:,:) looks like (::)  ==> 2-dimensional

On Thu, Mar 7, 2019 at 4:38 AM Md. Jalal Uddin <dmjalal90 at gmail.com> wrote:

> Hi, sir (Rashed),
>
> pcp_ratio  is now 3 dimensions (ntim, lat, lon). Now, I want to produce a
> spatial map that needs 2 dimensions (lat, lon). How can I use do loop over
> time instead of using dim_sum_n_Wrap or dim_avg_n_Wrap? Could you suggest
> to me?
>
> Best regards,
> Jalal
>
> On Mon, Mar 4, 2019 at 7:40 PM Md. Jalal Uddin <dmjalal90 at gmail.com>
> wrote:
>
>> Thanks a lot. It works.
>>
>> On Sun, Mar 3, 2019 at 8:37 PM Rashed Mahmood <rashidcomsis at gmail.com>
>> wrote:
>>
>>> 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
>>>>
>>>
>>
>> --
>> *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
>>
>
>
> --
> *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/20190307/164fa8bd/attachment.html>


More information about the ncl-talk mailing list