title: gradient function that treats nan values like edges
body: <p>I am looking for a function like numpy.gradient, which has a built-in treatment for NaN values. It should recognize where a NaN value occurs and compute one-sided derivatives at those points.</p>
  <p>For example if f[x-epx], f[x], and f[x+epx] are all not NaN, I would like it to calculate a derivative like:</p>
  <pre><code>grad_f[x] = (f[x+epx] - f[x-epx])/(2*eps)
  </code></pre>
  <p>however, if f[x-eps] is Nan then I would like to obtain the following derivative:</p>
  <pre><code>grad_f[x] = (f[x+eps] - f[x])/eps
  </code></pre>
  <p>I am looking for a function that does this also in higher dimensions. Do you know any such function?
  Thanks a lot in advance.</p>