1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] SciPy curve_fit covariance of the parameters could not be estimated

Discussão em 'Python' iniciado por Stack, Setembro 27, 2024 às 19:33.

  1. Stack

    Stack Membro Participativo

    I am trying to estimate the Schott coefficients of a glass material given only its n_e and V_e, i.e., refraction index and Abbe number at 546.07nm.

    import numpy as np
    from scipy.optimize import curve_fit

    # Definition of the Schott function
    def _InvSchott(x, a0, a1, a2, a3, a4, a5):
    return np.sqrt(a0 + a1* x**2 + a2 * x**(-2) + a3 * x**(-4) + a4 * x**(-6) + a5 * x**(-8))

    # Sample input, material parameter from a Leica Summilux patent
    n = 1.7899
    V = 48

    # 6 wavelengths, Fraunhofer symbols are not used due to there is another version that uses n_d and V_d
    shorter = 479.99
    short = 486.13
    neighbor = 546.07
    middle = 587.56
    longc = 643.85
    longer = 656.27

    # Refraction index of the corresponding wavelengths.
    # The linear functions are acquired from external regressions from 2000 glass materials
    n_long = 0.984 * n + 0.0246 # n_C'
    n_shorter = ( (n-1) / V) + n_long # n_F', from the definition of Abbe number
    n_short = 1.02 * n -0.0272 # n_F
    n_neighbor = n # n_e
    n_mid = 1.013 * n - 0.0264 # n_d
    n_longer = 0.982 * n + 0.0268 # n_C

    # The /1000 is to convert the wavelength from nanometer to micrometers
    x_data = np.array([longer, longc, middle, neighbor, short, shorter]) / 1000.0
    y_data = np.array([n_longer, n_long, n_mid, n_neighbor, n_short, n_shorter])

    # Provided estimate are average value from the 2000 Schott glasses
    popt, pcov = curve_fit(_InvSchott, x_data, y_data, [2.75118, -0.01055, 0.02357, 0.00084, -0.00003, 0.00001])


    The x_data and y_data in this case are as follow:

    [0.65627 0.64385 0.58756 0.54607 0.48613 0.47999]
    [1.7844818 1.7858616 1.7867687 1.7899 1.798498 1.80231785]


    And then I got the warning OptimizeWarning: Covariance of the parameters could not be estimated.

    I know this question has been asked a lot but I have not found a solution that works in this case yet. 6 data point is certainly a bit poor but this does satisfy the minimum, and Schott function is continuous, so I cannot figure out which part went wrong.

    Continue reading...

Compartilhe esta Página