title: Create a mask from a matrix
body: <p>Hi there i got a Matrix like this</p>
  
  <pre><code>A=[[nan, 4, nan],[3 , 7 , 8],[nan, 23, nan]]
  </code></pre>
  
  <p>and I would like to get a mask from the the Matrix A, that is as follows</p>
  
  <pre><code>mask=[[nan, 0, nan],[0, 0, 0],[nan, 0, nan]]
  </code></pre>
  
  <p>for that I have tried:</p>
  
  <pre><code>import numpy as np
  A=[[nan, 4, nan],[3 , 7 , 8],[nan, 23, nan]]
  mask=A
  mask[np.isfinite(A)]=0
  </code></pre>
  
  <p>But this also deletes the numerical values of the Matrix A.</p>