[ncl-talk] Division problem

Toni Klemm toni-klemm at tamu.edu
Fri Jan 25 06:26:43 MST 2019


Hi Jalal,

Are you dividing the average January rainfall by the rainfall of a single year to see how it compares? That’s how I understand your code. 

Then the problem might be that your individual year has zero rainfall in January, thus division by zero. I had a similar problem. Try to check if your data (jannontc) is zero, and replace zeros with missing values. That way NCL won’t divide. You might get a warning message but it should be okay. 

For example:
if (jannontc .eq. 0) then
  jannontc = prc at _FillValue
end if

I hope that helps. 

Best,
Toni


Toni Klemm, Ph.D.
Postdoctoral Research Associate
Department of Ecosystem Science and Management
College of Agriculture and Life Sciences
Texas A&M University, College Station, TX
Contributor to the Early Career Climate Forum
www.toni-klemm.de | @toniklemm


> On Jan 25, 2019, at 7:13 AM, Md. Jalal Uddin <dmjalal90 at gmail.com> wrote:
> 
> Hi all,
> 
> I can minus and multiply but cannot divide. NCL says, "divide by 0 cannot continue". Any suggestions?
> 
> ;January
>  f  = addfile("all_jan.nc", "r")
>  prc =f->pre(:,{65:110},{0:30})
>  prc_reorder = prc(time|:,latitude|:,longitude|:)
> 
> ; January TCs average rainfall
>  ntim = (/12,13,14,15,16,34,35,36,37/) 
>  tcjan = prc_reorder(ntim,:,:)
>  tcavgjan = dim_avg_n_Wrap(tcjan,0)
> 
> ; January contribution
> totjan = dim_sum_n_Wrap(prc_reorder,0)
> jantc = dim_sum_n_Wrap(tcjan,0)
> jannontc = totjan - jantc
> copy_VarMeta(totjan,jannontc)
> 
> jancont = jantc / jannontc    ; problem from there
> copy_VarMeta(jantc,jancont)
> 
> -- 
> 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/20190125/d1affef1/attachment.html>


More information about the ncl-talk mailing list