<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
Hi Barry,<br>
<br>
the following two Python examples demonstrate how to set values in a
NumPy and an Xarray array to NaN using a condition.<br>
<br>
<font face="monospace">arr = np.arange(0., 10.)<br>
arr[arr >= 7.] = np.nan<br>
print(arr)</font><br>
<br>
-----> output: [ 0. 1. 2. 3. 4. 5. 6. nan nan nan]<br>
<br>
<font face="monospace">xarr = xr.DataArray(np.arange(10))<br>
xarr = xarr.where(xarr < 7, np.nan)<br>
print(xarr.values)</font><br>
<br>
-----> output: [ 0. 1. 2. 3. 4. 5. 6. nan nan nan]<br>
<br>
Regards,<br>
Karin<br>
<br>
<div class="moz-cite-prefix">Am 28.02.24 um 15:10 schrieb Barry Lynn
via ncl-talk:<br>
</div>
<blockquote type="cite"
cite="mid:CAN7Bv26-RF-DuqjWgRpUFGs=TZmNPLy0MxdM8oHLV9Wp=Y=Y6g@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
<div>Hi:</div>
<div><br>
</div>
<div>I know how to change an array value to fillvalue in NCL
using a where statement.</div>
<div><br>
</div>
<div>How do I do the same in python, please?</div>
<div><br>
</div>
<div>Barry</div>
<span class="gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="gmail_signature"
data-smartmail="gmail_signature">
<div dir="ltr">
<div>
<div dir="ltr"><br>
</div>
<div dir="ltr">Barry H. Lynn, Ph.D
<div>
<div>Senior <font color="#000000">Scientist,
Lecturer,</font></div>
<div>
<div><font color="#000000">The Institute of Earth
Sciences, <br>
The Hebrew University of Jerusalem, <br>
Givat Ram, Jerusalem 91904, Israel <br>
</font></div>
<font color="#000000">Tel: 972 547 231 170<br>
Fax: (972)-25662581</font></div>
</div>
<div><span style="color:rgb(136,136,136)"><br>
</span></div>
<div>Weather It Is, LTD<br>
Weather and Climate Focus<br>
<a href="http://weather-it-is.com" target="_blank"
moz-do-not-send="true">https://weather-it-is.com</a><br>
Jerusalem, Israel<br>
Local: 02 930 9525<br>
Cell: 054 7 231 170<br>
Int-IS: x972 2 930 9525<br>
<br>
</div>
</div>
</div>
</div>
</div>
</div>
<br>
<fieldset class="moz-mime-attachment-header"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
ncl-talk mailing list
<a class="moz-txt-link-abbreviated" href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a class="moz-txt-link-freetext" href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
</blockquote>
<br>
</body>
</html>