docs: def fit_curvefit(p0, datax, datay, function, **kwargs):
      """
      Fits the data to a function using scipy.optimise.curve_fit
  
      Parameters
      ----------
      p0 : array_like
          initial parameters to use for fitting
      datax : array_like
          x data to use for fitting
      datay : array_like
          y data to use for fitting
      function : function
          funcion to be fit to the data
      kwargs 
          keyword arguments to be passed to scipy.optimise.curve_fit
  
      Returns
      -------
      pfit_curvefit : array
          Optimal values for the parameters so that the sum of
          the squared residuals of ydata is minimized
      perr_curvefit : array
          One standard deviation errors in the optimal values for
          the parameters
      """
      pfit, pcov = \
          _curve_fit(function, datax, datay, p0=p0,
                     epsfcn=0.0001, **kwargs)
      error = []
      for i in range(len(pfit)):
          try:
              error.append(_np.absolute(pcov[i][i])**0.5)
          except:
              error.append(_np.NaN)
      pfit_curvefit = pfit
      perr_curvefit = _np.array(error)
      return pfit_curvefit, perr_curvefit