title: How can I find the critical points of a 2D array in python?
body: <p>I have a (960,960) array an I am trying to find the critical points so I can find the local extrema.</p>
  
  <p>I have tried using the np.diff and np.gradient, but I have run into some trouble and I am not sure which function to use.</p>
  
  <p>np.diff offers the option of calculating the second order diff, but the gradient doesn't.</p>
  
  <p>How should I go about getting the critical points?</p>
  
  <p>I've tried </p>
  
  <pre><code>diff = np.diff(storm, n=2)                    
  
  dxx = diff[0]                                                                                                                                  
  dyy = diff[1]                                                                                                                                  
  
  derivative = dyy/dxx 
  </code></pre>
  
  <p>I run into problems here because some of the values along the dxx are equal to zero.</p>
  
  <p>Then there's the option of </p>
  
  <pre><code>gradient = np.gradient(storm)
  g2 = np.gradient(gradient)
  </code></pre>
  
  <p>but will this give me what I'm looking for?</p>