<div dir="ltr">Offhand, it seems like you want to use the where() function, rather than an if/else coupled with any():<br><br><a href="http://ncl.ucar.edu/Document/Functions/Built-in/where.shtml">http://ncl.ucar.edu/Document/Functions/Built-in/where.shtml</a><br><br><div class="gmail_extra"><br></div><div class="gmail_extra">Something like (untested):<br> <br></div><div class="gmail_extra">output = where((any(b(:,:,:).eq.0)) .or. (any(d(:,:,:).eq.0)), d-b, d/b)<br></div><div class="gmail_extra"><br><br></div><div class="gmail_extra"><div class="gmail_quote">On Tue, Jan 5, 2016 at 4:10 PM, amit timilsina <span dir="ltr"><<a href="mailto:timilsinaamit87@huskers.unl.edu" target="_blank">timilsinaamit87@huskers.unl.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Respected all,<br>
<br>
I would like to take ratio and differences of variable precipitation(pr) in such way that if both the values for particular day is positive or greater than zero, I want to take ratio. If one of the values, either denominator or numerator, is zero, then I would like to take differences. Here is my code:<br>
ncl 0> a=addfile("pr_day_MRI-CGCM3_decadal2005_r1i1p1_20060101-20351231.nc","r")<br>
ncl 1> b=a->pr<br>
ncl 2> c=addfile("pr_day_MRI-CGCM3_rcp45_r1i1p1_20060101-20351231.nc","r")<br>
ncl 3> d=a->pr<br>
ncl 4> if (any(b(:,:,:).eq.0)) .or. (any(d(:,:,:).eq.0)) then<br>
ncl 5> output = (d-b)<br>
ncl 6> else<br>
ncl 7> ouput = d/b<br>
ncl 8> end if<br>
<br>
This output gives me only differences, not a combination of both. Is it possible to put any flag to know whether we have considered differences or ratio at each grid level? I have attached printVarSummary for further information.<br>
<br>
Thank you in advance<br>
<br>
<br>
<br>
Amit Prasad Timilsina<br>
PhD student<br>
School of Natural Resources,UNL<br>
<br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div></div>