CONAN._classes.load_lightcurves.add_spline#

CONAN._classes.load_lightcurves.add_spline(lc_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 polynomial of defined degree 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 lc file in lc_list.

Parameters:
  • lc_list (list, str, optional) – list of lc files to fit a spline to. set to “all” to use spline for all lc files. Default is None for no splines.

  • par (str,tuple,list, optional) – column of input data to which to fit the spline. must be one/two of [“col0”,”col3”,”col4”,”col5”,”col6”,”col7”,”col8”]. Default is None. Give list of columns if different for each lc file. e.g. [“col0”,”col3”] for spline in col0 for lc1.dat and col3 for lc2.dat. For 2D spline for an lc file, use tuple of length 2. e.g. (“col0”,”col3”) for simultaneous spline fit to col0 and col3.

  • degree (int, tuple, list optional) – Degree of the smoothing spline. Must be 1 <= degree <= 5. Default is 3 for a cubic spline.

  • knot_spacing (float, tuple, list) – distance between knots of the spline, in units of the desired column array. E.g 15 degrees for roll angle in CHEOPS data. If ‘r’ is given, the full range of the array is fit by a single spline of the specified order. this is useful if the range of the array varies for different datasets

  • plot_knots (int) – whether to make plot of each lc in lc_list showing the location of the knots. if 0, plot is not shown; 1 or 2 shows the location of the knots for the 1st or 2nd dimension.

  • verbose (bool, optional) – print output. Default is True.

_lcspline#

dictionary of spline configuration for each lc file. Default is None for no splines. keys: lc filenames, values: SimpleNamespace with Attributes name, dim, par, use, deg, knots_loc, conf

Type:

dict

Examples

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

>>> lc_obj.add_spline(  lc_list  = ["lc1.dat","lc2.dat"],
>>>                         par  = [("col3","col4"),"col4"],
>>>                     degree   = [(3,3),2],
>>>                 knot_spacing = [(5,3),2])

For same spline configuration for all loaded lc files

>>> lc_obj.add_spline(lc_list="all", par="col3", degree=3, knot_spacing=5)

For sade 2D spline configuration for all loaded lc files where the a single 2nd degree polynomial is fit to the second dimension

>>> lc_obj.add_spline(lc_list="all", par=("col3","col5"), degree=(3,2),
>>>                     knot_spacing=(5,'r'), plot_knots=1)

The created spline configuration can be accessed from the lc_obj._lcspline dictionary attribute. To modify the location of the knots for an lc file, use lc_obj._lcspline[lc].knots_loc = knots where knots is a numpy array of the desired knot locations. for a 2d spline, knot locations for the 2 dims should be given as a list e.g. lc_obj._lcspline[lc].knots_loc = [knots1, knots2]