<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    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"><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 class="moz-cite-prefix">Am 28.02.24 um 16:02 schrieb Karin
      Meier-Fleischer via ncl-talk:<br>
    </div>
    <blockquote type="cite"
      cite="mid:b506f4fa-9cf5-4217-bef6-3c027c6249b1@dkrz.de">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      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 moz-txt-link-freetext"
        href="mailto:ncl-talk@mailman.ucar.edu" moz-do-not-send="true">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"
        moz-do-not-send="true">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a>
</pre>
      </blockquote>
      <br>
      <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>