<div dir="ltr">Karen:<div><br></div><div>Thank you. I think you need the additional line so that the "invalid" values will be masked out.</div><div><br></div><div>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;font-kerning:auto;font-feature-settings:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>threshold = </span><span class="gmail-s2" style="font-variant-ligatures:no-common-ligatures;color:rgb(180,36,25)">1.</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;font-kerning:auto;font-feature-settings:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>radar_max = np.</span><span class="gmail-s3" style="font-variant-ligatures:no-common-ligatures;background-color:rgb(224,228,9)">where</span><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures">(radar_max < threshold, np.nan, radar_max)</span></p>
<p class="gmail-p1" style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-variant-alternates:normal;font-kerning:auto;font-feature-settings:normal;font-stretch:normal;font-size:14px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span class="gmail-s1" style="font-variant-ligatures:no-common-ligatures"><span class="gmail-Apple-converted-space"> </span>radar_max = np.ma.masked_invalid(radar_max)</span></p></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 28, 2024 at 5:12 PM Karin Meier-Fleischer via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><u></u>
<div>
NCL:<br>
<br>
<font face="monospace"> xsqrt = <strong>where</strong>(arr .gt.
0,<a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/sqrt.shtml" target="_blank"><strong>
sqrt</strong></a>(arr), arr@_FillValue)</font>
<pre>Python:
</pre>
<font face="monospace"> xsqrt = np.where(arr > 0,
np.sqrt(arr), np.nan)</font><br>
<br>
<br>
<br>
<div>Am 28.02.24 um 16:02 schrieb Karin
Meier-Fleischer via ncl-talk:<br>
</div>
<blockquote type="cite">
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>Am 28.02.24 um 15:10 schrieb Barry
Lynn via ncl-talk:<br>
</div>
<blockquote type="cite">
<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">
<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">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></fieldset>
<pre>_______________________________________________
ncl-talk mailing list
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
</blockquote>
<br>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
ncl-talk mailing list
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>
List instructions, subscriber options, unsubscribe:
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
</blockquote>
<br>
</div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="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">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>