def update_poly_wlcalib(coeff_ini, coeff_residuals, naxis1_ini, debugplot):
    """Update wavelength calibration polynomial using the residuals fit.

    The idea is to repeat the original fit using the information
    previously computed with the function check_wlcalib_sp() in this
    module.

    Parameters
    ----------
    coeff_ini : array like (floats)
        Coefficients corresponding to the initial wavelength
        calibration.
    coeff_residuals: array like (floats)
        Coefficients corresponding to the fit performed by the
        function check_wlcalib_sp() in this module.
    naxis1_ini : int
        NAXIS1 in original spectrum employed to fit the initial
        wavelength calibration.
    debugplot : int
        Debugging level for messages and plots. For details see
        'numina.array.display.pause_debugplot.py'.

    Returns
    -------
    coeff_end : numpy array (floats)
        Updated coefficients.

    """

    # define initial wavelength calibration polynomial (use generic
    # code valid for lists of numpy.arrays)
    coeff = []
    for fdum in coeff_ini:
        coeff.append(fdum)
    poly_ini = np.polynomial.Polynomial(coeff)
    poldeg_wlcalib = len(coeff) - 1

    # return initial polynomial when there is no need to compute an
    # updated version
    if len(coeff_residuals) == 0:
        return poly_ini.coef
    else:
        if np.count_nonzero(poly_ini.coef) == 0:
            return poly_ini.coef

    # define polynomial corresponding to the residuals fit carried
    # out by check_wlcalib_sp()
    coeff = []
    for fdum in coeff_residuals:
        coeff.append(fdum)
    poly_residuals = np.polynomial.Polynomial(coeff)

    # define new points to be fitted
    xfit = np.zeros(naxis1_ini)
    yfit = np.zeros(naxis1_ini)
    for i in range(naxis1_ini):
        xfit[i] = float(i + 1)
        wv_tmp = poly_ini(xfit[i])
        yfit[i] = wv_tmp + poly_residuals(wv_tmp)

    # fit to get the updated polynomial
    if len(xfit) > poldeg_wlcalib:
        poldeg_effective = poldeg_wlcalib
    else:
        poldeg_effective = len(xfit) - 1
    poly_updated, ydum = polfit_residuals(
        x=xfit,
        y=yfit,
        deg=poldeg_effective,
        debugplot=debugplot
    )

    # return coefficients of updated polynomial
    return poly_updated.coef
def update_poly_wlcalib ( coeff_ini , coeff_residuals , naxis1_ini , debugplot ) : coeff = [ ] for fdum in coeff_ini : coeff . append ( fdum ) poly_ini = np . polynomial . Polynomial ( coeff ) poldeg_wlcalib = len ( coeff ) - 1 if len ( coeff_residuals ) == 0 : return poly_ini . coef else : if np . count_nonzero ( poly_ini . coef ) == 0 : return poly_ini . coef coeff = [ ] for fdum in coeff_residuals : coeff . append ( fdum ) poly_residuals = np . polynomial . Polynomial ( coeff ) xfit = np . zeros ( naxis1_ini ) yfit = np . zeros ( naxis1_ini ) for i in range ( naxis1_ini ) : xfit [ i ] = float ( i + 1 ) wv_tmp = poly_ini ( xfit [ i ] ) yfit [ i ] = wv_tmp + poly_residuals ( wv_tmp ) if len ( xfit ) > poldeg_wlcalib : poldeg_effective = poldeg_wlcalib else : poldeg_effective = len ( xfit ) - 1 poly_updated , ydum = polfit_residuals ( x = xfit , y = yfit , deg = poldeg_effective , debugplot = debugplot ) return poly_updated . coef
Update wavelength calibration polynomial using the residuals fit.

    The idea is to repeat the original fit using the information
    previously computed with the function check_wlcalib_sp() in this
    module.

    Parameters
    ----------
    coeff_ini : array like (floats)
        Coefficients corresponding to the initial wavelength
        calibration.
    coeff_residuals: array like (floats)
        Coefficients corresponding to the fit performed by the
        function check_wlcalib_sp() in this module.
    naxis1_ini : int
        NAXIS1 in original spectrum employed to fit the initial
        wavelength calibration.
    debugplot : int
        Debugging level for messages and plots. For details see
        'numina.array.display.pause_debugplot.py'.

    Returns
    -------
    coeff_end : numpy array (floats)
        Updated coefficients.