Syntax:

-splinedetrend
	detrendvec1:<"spline":knotspacing:order|"poly":order|"harm":nharm>[:"groupbygap":gapsize][,detrendvec2:<"spline":knotspacing:order|"poly":order|"harm":nharm>[:"groupbygap":gapsize],...]
	["sigmaclip" <"fix" value | "list" | "fixcolumn" <colname | colnum> | "expr" expr>]
	["omodel" outdir ["nameformat" format]]
	["omodelcoeffs" outdir ["nameformat" format]]
	["omodelvariable" outvarname1[:inputvarsignal1[,outvarname2:inputvarsignal2...]]]
Example 1.
$ vartools -i EXAMPLES/6479535620075955328_llc.fits \
	-inputlcformat \
		t:TMID_BJD,mag:IRM1,err:IRE1,x:XIC,y:YIC,temp:CCDTEMP \
	-expr magorig=mag \
	-splinedetrend \
		t:spline:1.0:3:groupbygap:0.5,x:poly:1,y:poly:1,temp:poly:1 \
		sigmaclip fix 3.0 \
		omodel EXAMPLES/OUTDIR1/ \
		omodelcoeffs EXAMPLES/OUTDIR1/ \
		omodelvariable \
			tmod:t,xmod:x,ymod:y,tempmod:temp \
	-o EXAMPLES/OUTDIR1/6479535620075955328.splinedetrend.lc.txt \
		columnformat t,magorig,mag,err,x,y,temp,tmod,xmod,ymod,tempmod \
	-rms -oneline

Name                            = ./6479535620075955328_llc.fits
Splinedetrend_MedianMagnitude_1 = 10.33609
Splinedetrend_NOutliers_1       = 0
Splinedetrend_NDataGroups_1     = 3
Splinedetrend_NFitParamsTotal_1 = 44
Mean_Mag_3                      =  10.33609
RMS_3                           =   0.00137
Expected_RMS_3                  =   0.00566
Npoints_3                       =  1149

Use the -splinedetrend command to detrend the TESS sector one light curve for the star GAIA DR2 6479535620075955328. First we read the time, magnitude, uncertainty, x and y pixel position, and CCD temperature from the light curve. We then save the original magnitude values in the variable 'magorig.' We use the -splinedetrend command to perform the detrending. We detrend against the t, x, y, and temp variables. For t we use a third-order Basis spline, with a knot-spacing of 1.0 days. We split the fit into time groups at any gaps in time that are greater than 0.5 days. For x, y and temp we use a simple linear polynomial. We apply 3 sigma clipping to the light curve before performing the fit. The best-fit model will be output to the file EXAMPLES/OUTDIR1/6479535620075955328_llc.fits.splinedetrend_model, and the optimized coefficients of the fit will be output to the file EXAMPLES/OUTDIR1/6479535620075955328_llc.fits.splinedetrend_modelcoeffs. The contribution of the t variable to the best-fit model will be stored in the variable tmod, the contribution from x will be stored in the xmod variable, from y in the ymod variable, and from temp in the tempmod variable. The detrended light curve will be output to the file EXAMPLES/OUTDIR1/6479535620075955328.splinedetrend.lc.txt, with the output including the time, the original magnitude, the detrended magnitude, the magnitude uncertainty, the x position, the y position, the CCD temperature, and the time, x, y and temperature contributions to the best-fit model. The four parameters given as output from the -splinedetrend command include: Splinedetrend_MedianMagnitude_1 - this is the median magnitude of the input light curve which is added back to the detrended magnitudes, after subtracted the best-fit detrending mode; Splinedetrend_NOutliers_1 - the number of outliers excluded from the fit; Splinedetrend_NDataGroups_1 - the number of separate fitting groups that the light curve is split to (as a result of the groupbygap option); Splinedetrend_NFitParamsTotal_1 - the total number of free parameters in the model that is fit to the light curve.