title: Python: float() argument must be a string or a number, not 'interp2d'
body: <p>this code returns the error "float() argument must be a string or a number, not 'interp2d'".  I'm attempting to learn how to interpolate values to fill an array given a few of the values in the array (sorry, bad phrasing).  Am I messing up the syntax for the interp2d function or what?</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from netCDF4 import Dataset
  import scipy as sp
  
  GCM_file = '/Users/Robert/Documents/Python Scripts/GCMfiles/ATM_echc0003_1979_2008.nc'
  fh = Dataset(GCM_file, mode = 'r')
  
  pressure = fh.variables['lev'][:]
  lats = fh.variables['lat'][:]
  temp = np.mean(fh.variables['t'][0,:,:,:,:], axis = (0, 3))
  potential_temp = np.zeros((np.size(temp,axis=0), np.size(temp,axis=1)))
  
  P0 = pressure[0] 
  #plt.figure(0)
  for j in range(0, 96):
      potential_temp[:,j] = temp[:, j] * (P0/ pressure[:]) ** .238
  
  
  potential_temp_view = potential_temp.view()
  
  temp_view = temp.view()
  
  combo_t_and_pt = np.dstack((potential_temp_view,temp_view))
  combo_view = combo_t_and_pt.view()
  
  pt_and_t_flat=np.reshape(combo_view, (26*96,2))
  t_flat = temp.flatten()
  pt_flat = potential_temp.flatten()
  
  temp_grid = np.zeros((2496,96))
  
  for j in range(0, 2496):
      if j &lt;= 95:
          temp_grid[j,j] = t_flat[j]
      else:
              temp_grid[j, j % 96] = t_flat[j]
  
  '''Now you have the un-interpolated grid of all your values of t as a function of potential temp and latitude, so you have to interpolate the rest somehow....?'''
  
  xlist = lats
  ylist = pt_flat
  
  X,Y = np.meshgrid(xlist,ylist)
  
  
  
  temp_cubic = sp.interpolate.interp2d(xlist,ylist, temp_grid, kind = 'cubic')
  #temp_linear= griddata(temp_grid, (X,Y), method = 'linear')
  #temp_quintic = griddata(temp_grid, (X,Y), method = 'cubic')
  
  plt.figure(0)
  plt.contourf(X,Y, temp_cubic, 20)
  </code></pre>
  
  <p>EDIT: The error with this was pointed out to me. I changed the code from the interpolating line down into this, and I'm still getting an error, which reads "ValueError: Invalid input data".  Here's the traceback: </p>
  
  <pre><code>runfile('C:/Users/Robert/Documents/Python Scripts/attempt at defining potential temperature.py', wdir='C:/Users/Robert/Documents/Python Scripts')
  Traceback (most recent call last):
    File "&lt;ipython-input-27-1ffd3fcc3aa1&gt;", line 1, in &lt;module&gt;
      runfile('C:/Users/Robert/Documents/Python Scripts/attempt at defining potential temperature.py', wdir='C:/Users/Robert/Documents/Python Scripts')
    File "C:\Users\Robert\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 699, in runfile
      execfile(filename, namespace)
    File "C:\Users\Robert\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 88, in execfile
      exec(compile(open(filename, 'rb').read(), filename, 'exec'), namespace)
    File "C:/Users/Robert/Documents/Python Scripts/attempt at defining potential temperature.py", line 62, in &lt;module&gt;
      Z = temp_cubic(xlist,ylist)
    File "C:\Users\Robert\Anaconda3\lib\site-packages\scipy\interpolate\interpolate.py", line 292, in __call__
      z = fitpack.bisplev(x, y, self.tck, dx, dy)
    File "C:\Users\Robert\Anaconda3\lib\site-packages\scipy\interpolate\fitpack.py", line 1048, in bisplev
      raise ValueError("Invalid input data")":
  
  temp_cubic = sp.interpolate.interp2d(xlist, ylist, temp_grid, kind = 'cubic')
  
  ylist = np.linspace(np.min(pt_flat), np.max(pt_flat), .01)
  
  X,Y = np.meshgrid(xlist,ylist)
  Z = temp_cubic(xlist,ylist)
  plt.contourf(X,Y, Z, 20)
  </code></pre>