def _fit_acf(acf):
    """
    Fit a parametric ACF to the given sample estimate."""

    def objf(p, *args):
        p = _get_acf_params(p)
        fitted_acf = _compute_parametric_acf(p, acf.shape[0], acf.shape[1])

        return (acf - fitted_acf).flatten()

    bounds = ((0.01, -np.inf, 0.1, 0.2), (10.0, np.inf, 10.0, 5.0))
    p_opt = opt.least_squares(
        objf,
        np.array((1.0, 0.0, 1.0, 1.0)),
        bounds=bounds,
        method="trf",
        ftol=1e-6,
        xtol=1e-4,
        gtol=1e-6,
    )

    return _compute_parametric_acf(_get_acf_params(p_opt.x), acf.shape[0], acf.shape[1])
Fit a parametric ACF to the given sample estimate.
pysteps/nowcasts/linda.py