CONAN._classes.load_rvs.add_spline
==================================

.. py:method:: CONAN._classes.load_rvs.add_spline(rv_list=None, par=None, degree=3, knot_spacing=None, plot_knots=0, verbose=True)

   add spline to fit correlation along 1 or 2 columns of the data. This splits the data at
   the defined knots interval and fits a spline to each section. scipy's LSQUnivariateSpline()
   and LSQBivariateSpline() functions are used for 1D spline and 2D splines respectively.
   All arguments can be given as a list to specify config for each rv file in rv_list.

   Note: using spline on a lc sets fit_offset="n" for that lc. users can turn it back on for each lc
   from the ._fit_offset list attribute. e.g. lc_obj._fit_offset = ["y","y","y"]

   :param rv_list: list of rv files to fit a spline to. set to "all" to use spline for all rv files.
                   Default is None for no splines.
   :type rv_list: list, str, optional
   :param par: column of input data to which to fit the spline. must be one/two of
               ["col0","col3","col4","col5"]. Default is None. Give list of columns if different
               for each rv file. e.g. ["col0","col3"] for spline in col0 for rv1.dat and col3 for
               rv2.dat. For 2D spline for an rv file, use tuple of length 2. e.g. ("col0","col3")
               for simultaneous spline fit to col0 and col3.
   :type par: str,tuple,list, optional
   :param degree: Degree of the smoothing spline. Must be 1 <= degree <= 5. Default is 3 for a cubic spline.
   :type degree: int, tuple, list optional
   :param knot_spacing: distance between knots of the spline, by default 15 degrees for cheops data roll-angle
   :type knot_spacing: float, tuple, list
   :param verbose: print output. Default is True.
   :type verbose: bool, optional

   .. attribute:: _rvspline

      dictionary of spline configuration for each rv file
      keys: rv_names, values: SimpleNamespace with Attributes name, dim, par, use, deg, knots_loc, conf

      :type: dict

   .. rubric:: Examples

   To use different spline configuration for 2 rv files: 2D spline for the first file and 1D for the second.

   >>> rv_obj.add_spline(rv_list=["rv1.dat","rv2.dat"], par=[("col3","col4"),"col4"],
   >>>                     degree=[(3,3),2], knot_spacing=[(5,3),2])

   For same spline configuration for all loaded RV files

   >>> rv_obj.add_spline(rv_list="all", par="col3", degree=3, knot_spacing=5)

