Fourier Fit of Lightcurve ------------------------- 1 - look at example program 'polyfit.f' doing a parabola fit using a generalized least squares routine. there is also a gnuplot command file to view the result (type -- load "test.gplot" -- at the gnuplot prompt) to compile (using multiple files without using makefile) - g77 -o polyfit polyfit.f glsfit.f fpoly.f things to note and think about how to modify for fitting your data - - it reads data from file - it uses glsfit.f subroutine for the least squares fit - fpoly.f is the subroutine that defines the basis functions that define the nature of the fit. for the parabola case, these are 1, x, and x^2 i.e., it is fitting the data as y = a1*1 + a2*x + a3*x^2, where a1,a2, etc are the returned fit parameters. glsfit.f is nothing but a few NR routines that I combined. to see the gory details, look at http://lib-www.lanl.gov/numerical/bookfpdf/f15-4.pdf . the first few paragraphs(up to eq 15.4.3) describing the method and page 674 on how to write the subroutines for the basis functions are really the only parts that you need to understand. 2 - after you get a handle on what glsfit.f does, think about how to use it in a program to model your single night lightcurves with a Fourier series. I put a slide from my talk (composite.jpg) in the indstudy web directory. in this case, fpoly.f will be replaced by a subroutine that defines the sine and cosine functions for various l's instead of x^n's. first - try to write a program that does the fit with the period as input by the user (put the period in a common block so that the it is shared by all routines). 3 - then, modify your program so that it scans a range of different periods - doing a fit and printing out the chi-squared for each. the 'good' period is the one the one that has the lowest chi-squared. redo the fit with this period and then create the output in the same form to load into gnuplot as the polyfit program did. you should be able to most of this with a few simple, but strategic, modifications to the polyfit program and the fpoly subroutine.