1

I use a script to work on a number of big .csv files one after another. However, since yesterday I get an error which I neither can explain nor resolve, though I haven't changed anything in the python script.

I have a simplified version of the script. It runs when I don't try to plot the data, remove the savgol filter or decrease the number of data points. In the as is version provided below, it stops in the second loop with this error:

** On entry to DLASCLS parameter number 4 had an illegal value
** On entry to DLASCLS parameter number 4 had an illegal value
Traceback (most recent call last):
File "simplified_problem.py", line 29, in
ysmooth = savgol_filter(y,51,5)
File "C:\Programs\Python\Python37\lib\site-packages\scipy\signal_savitzky_golay.py",
line 337, in savgol_filter
coeffs = savgol_coeffs(window_length, polyorder, deriv=deriv, delta=delta)
File "C:\Programs\Python\Python37\lib\site-packages\scipy\signal_savitzky_golay.py", line 139, in savgol_coeffs
coeffs, _, _, _ = lstsq(A, y)
File "C:\Programs\Python\Python37\lib\site-packages\scipy\linalg\basic.py", line 1218, in lstsq
raise LinAlgError("SVD did not converge in Linear Least Squares")
numpy.linalg.LinAlgError: SVD did not converge in Linear Least Squares

I suspect the error has nothing to do with the script itself, since it only appeared after a major window update (currently version 10.0.19041).

Has anybody an idea what exactly causes the problem and how it can be solved? Please let me know if any additional information is needed. Your help would be much appreciated.

import numpy as np
import matplotlib.pyplot as plt
from scipy.signal import savgol_filter
import pandas as pd
from pathlib import Path
    
def curve(x, E, A, xmin):
    '''Function describing a curve
    
    x   -- independent variable
    E   -- trap energy. expected values between 0-1 eV
    A   -- pre-exponential factor. positive for peaks with positive current
           and negative for peaks with negative current
    xmin -- position of the peak extremum. value in Kelvin
    k   -- Boltzmannfactor in eV/K
    '''
    k = 8.617333262145E-5 #eV/K
    return  A*np.exp(-(E/(k*x))-((np.exp((E/(k*xmin)))*(E/(k*xmin))**(9/2))/((E/(k*xmin))+3.5))*np.exp(-(E/(k*x)))*(E/(k*x))**(-7/2))


for i in range(3):
    print(i)
    x = np.arange(50,1051)
    noise = np.random.normal(0,1,len(x))*3e-10
    y = curve(x,0.35,-1e-4,500)+noise
    
    #smooth data
    ysmooth = savgol_filter(y,51,5)

    #create (sub)plots
    fig = plt.figure(constrained_layout=True,figsize=(8,4))
    gs = fig.add_gridspec(2, 4)
    ax11 = fig.add_subplot(gs[0:2, 0:2])
    ax11.plot(x,y)
    ax11.plot(x,ysmooth)
    plt.show()
Hextia
  • 13
  • 1
  • 5

1 Answers1

0

You can find the answer to your question here. You are right related to Windows Update, and ultimately related to OpenBlas, which is used by numpy to perform linear algebra computations. Sadly the "solutions" are not really satisfactory: you must either wait for Microsoft to fix it in the next (hopefully!) Windows update, or install numpy through conda, which is using Intel MKL as backend instead of OpenBlas.

milembar
  • 919
  • 13
  • 17