<div dir="ltr"><div class="gmail_default" style="font-size:small">I want to add that NCL cannot handle NaN values, and you will get undefined behavior if you try to use them in an NCL script.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">We have two functions explicitly for dealing with NaN values:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/isnan_ieee.shtml">isnan_ieee</a> - returns True for every element of an array that is a NaN, and False otherwise</div><div class="gmail_default" style="font-size:small"><a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/replace_ieeenan.shtml">replace_ieeenan</a> - replaces all NaN values with a valid value</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">This piece of code will replace all your NaN&#39;s using a _FillValue:</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small"><pre><font face="monospace, monospace">  if (<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/any.shtml">any</a>(<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/isnan_ieee.shtml">isnan_ieee</a>(x))) then
      if(.not.isatt(x,&quot;_FillValue&quot;)) then
        x@_FillValue = default_fillvalue(typeof(x))
      end if
      replace_ieeenan (x, x@_FillValue, 0)
</font><span style="font-family:monospace,monospace">  end if</span></pre></div><div class="gmail_default" style="">--Mary</div><div class="gmail_default" style=""><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jun 12, 2016 at 4:26 AM, Guido Cioni <span dir="ltr">&lt;<a href="mailto:guidocioni@gmail.com" target="_blank">guidocioni@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Kunal,<div>you can easily achieve that with the <b><font face="Courier">where</font></b> function <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml" target="_blank">http://www.ncl.ucar.edu/Document/Functions/Built-in/where.shtml</a>.</div><div>Assuming that <font face="Courier">var</font> is your variable and <font face="Courier">var_mod</font> the new one, you can do this (<font face="Courier">var</font> need an attribute <font face="Courier">_FillValue</font>, which is equivalent to <font face="Courier">NaN</font>):</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px;padding:0px;font-size:13.3333px;line-height:16px;font-family:courier;border-style:solid;border-width:0px 0px 15px;border-color:transparent;background-color:rgb(255,255,255)">   var_mod = <strong style="margin:0px;padding:0px">where</strong>(var.le.0, <span style="font-size:13.3333px">var@_FillValue, var)</span></pre></div><div><div>There’s a method to do the same in CDO and NCO but it is more complicated. If you just need the variable in NCL I would suggest you to use the where function, while if you need to write another file you can try to load it in NCL with the “w” option. If that doesn’t work then you will have to use CDO and NCO, but that would be a question not relevant to ncl-talk :) </div><div><br></div><div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">Guido Cioni</div><div style="color:rgb(0,0,0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><a href="http://guidocioni.altervista.org" target="_blank">http://guidocioni.altervista.org</a> </div>

</div>
<br><div><blockquote type="cite"><div><div class="h5"><div>On 12 Jun 2016, at 11:16, Kunal Bali &lt;<a href="mailto:kunal.bali9@gmail.com" target="_blank">kunal.bali9@gmail.com</a>&gt; wrote:</div><br></div></div><div><div><div class="h5"><div dir="ltr"><div><div>Dear NCL users<br><br></div>I have a file having zero and negative values. I need to replace it with NaN values.<br></div>Could anyone let me know how to do it ?<br><div><div><br></div><div>Regards<br clear="all"></div><div><div><div><div data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Kunal Bali<br></div><br></div></div></div></div></div>
</div></div></div></div></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" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br></div></blockquote></div><br></div></div><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>