title: How to best perform a surface integral over 2D point data?
body: <p>I have a data set of 363 x- by 190 y-points with an associated functional value that I would to integrate over multiple different subregions..  I've tried to create a SciPy <code>interp2d</code> function to integrate; however, <strong>creating that function even with linear interpolation has taken over 2 hours (and is not yet done)</strong>.  </p>
  
  <p>What is a better approach to perform this task?</p>
  
  <p>Some snippets below...</p>
  
  <p>In the <code>convert_RT_to_XY</code> function below, imb/jmb are the r,theta mesh boundaries that I convert to Cartesian boundaries.</p>
  
  <p>Later, in my code, I convert the mesh boundaries (imb/jmb) to mesh-center values (imm,jmm), convert to vectors (iX, iY), convert my function a vector (iZ), and then attempt to make my interpolation function.</p>
  
  <hr>
  
  <pre><code># Convert R, T mesh vectors to X, Y mesh arrays.                                                                       
  def convert_RT_to_XY(imb, jmb):                                                                                        
      R, T = np.meshgrid(imb,jmb)                                                                                        
      X = R * np.cos(np.radians(T*360))                                                                                  
      Y = R * np.sin(np.radians(T*360))                                                                                  
      return(X, Y) 
  </code></pre>
  
  <p>...</p>
  
  <pre><code>imm = imb[:-1]+np.divide(np.diff(imb),2)                                                                       
  jmm = jmb[:-1]+np.divide(np.diff(jmb),2) 
  iX, iY =  convert_RT_to_XY(imm, jmm)   
  iX = np.ndarray.flatten(iX)                                                                                    
  iY = np.ndarray.flatten(iY)                                                                                    
  iZ = np.ndarray.flatten(plot_function)                                                                         
  f = interpolate.interp2d(iX, iY, iZ, kind='linear') 
  </code></pre>
  
  <p>Ultimately, I want to perform:</p>
  
  <pre><code>result = dblquad(f, 10, 30,
      lambda x: 10,
      lambda x: 30))
  </code></pre>