title: LinAlgError: SVD did not converge in Linear Least Squares when trying polyfit
body: <p>If I try to run the script below I get the error: <code>LinAlgError: SVD did not converge in Linear Least Squares</code>. I have used the exact same script on a similar dataset and there it works. I have tried to search for values in my dataset that Python might interpret as a NaN but I cannot find anything.</p>
  
  <p>My dataset is quite large and impossible to check by hand. (But I think my dataset is fine). I also checked the length of <code>stageheight_masked</code> and <code>discharge_masked</code> but they are the same. Does anyone know why there is an error in my script and what can I do about it?</p>
  
  <pre><code>import numpy as np
  import datetime
  import matplotlib.dates
  import matplotlib.pyplot as plt
  from scipy import polyfit, polyval
  
  kwargs = dict(delimiter = '\t',\
       skip_header = 0,\
       missing_values = 'NaN',\
       converters = {0:matplotlib.dates.strpdate2num('%d-%m-%Y %H:%M')},\
       dtype = float,\
       names = True,\
       )
  
  rating_curve_Gillisstraat = np.genfromtxt('G:\Discharge_and_stageheight_Gillisstraat.txt',**kwargs)
  
  discharge = rating_curve_Gillisstraat['discharge']   #change names of collumns
  stageheight = rating_curve_Gillisstraat['stage'] - 131.258
  
  #mask NaN
  discharge_masked = np.ma.masked_array(discharge,mask=np.isnan(discharge)).compressed()
  stageheight_masked = np.ma.masked_array(stageheight,mask=np.isnan(discharge)).compressed()
  
  #sort
  sort_ind = np.argsort(stageheight_masked)
  stageheight_masked = stageheight_masked[sort_ind]
  discharge_masked = discharge_masked[sort_ind]
  
  #regression
  a1,b1,c1 = polyfit(stageheight_masked, discharge_masked, 2)
  discharge_predicted = polyval([a1,b1,c1],stageheight_masked)
  
  print 'regression coefficients'
  print (a1,b1,c1)
  
  #create upper and lower uncertainty
  upper = discharge_predicted*1.15
  lower = discharge_predicted*0.85
  
  #create scatterplot
  
  plt.scatter(stageheight,discharge,color='b',label='Rating curve')
  plt.plot(stageheight_masked,discharge_predicted,'r-',label='regression line')
  plt.plot(stageheight_masked,upper,'r--',label='15% error')
  plt.plot(stageheight_masked,lower,'r--')
  plt.axhline(y=1.6,xmin=0,xmax=1,color='black',label='measuring range')
  plt.title('Rating curve Catsop')
  plt.ylabel('discharge')
  plt.ylim(0,2)
  plt.xlabel('stageheight[m]')
  plt.legend(loc='upper left', title='Legend')
  plt.grid(True)
  plt.show()
  </code></pre>