<div dir="ltr"><div><div>Hi Amit,<br><br></div>As was pointed out to me by one of my colleagues, you want to remove the calls to &quot;any()&quot; in the where statement I gave previously; otherwise, you&#39;ll still get differences everywhere.<br><br></div>Rick<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jan 5, 2016 at 4:20 PM, Rick Brownrigg <span dir="ltr">&lt;<a href="mailto:brownrig@ucar.edu" target="_blank">brownrig@ucar.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><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" target="_blank">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"><div><div class="h5">On Tue, Jan 5, 2016 at 4:10 PM, amit timilsina <span dir="ltr">&lt;<a href="mailto:timilsinaamit87@huskers.unl.edu" target="_blank">timilsinaamit87@huskers.unl.edu</a>&gt;</span> wrote:<br></div></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><div class="h5">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&gt; a=addfile(&quot;pr_day_MRI-CGCM3_decadal2005_r1i1p1_20060101-20351231.nc&quot;,&quot;r&quot;)<br>
ncl 1&gt; b=a-&gt;pr<br>
ncl 2&gt; c=addfile(&quot;pr_day_MRI-CGCM3_rcp45_r1i1p1_20060101-20351231.nc&quot;,&quot;r&quot;)<br>
ncl 3&gt; d=a-&gt;pr<br>
ncl 4&gt; if (any(b(:,:,:).eq.0)) .or. (any(d(:,:,:).eq.0)) then<br>
ncl 5&gt; output = (d-b)<br>
ncl 6&gt; else<br>
ncl 7&gt; ouput = d/b<br>
ncl 8&gt; 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></div></div>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">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>
</blockquote></div><br></div>