Tutorial 2:
Least-squares fitting of data including a periodic time shift


This tutorial provides a basic introduction in how to find a multiple frequency solution to a data set, taking into account a periodic time shift. Such a periodic time shift could be the result of orbital light-time effects.

1. Start Period04.


2. Import the data file.


To read in the data set press the button 'Import time string'. A file-selector dialog will be opened. Navigate to the directory that contains the tutorial time strings and select the file 'Tutorial2.dat'.

In the next dialog we are going to specify the properties of the columns in the data file. The first column of our data file denotes time, whereas the second column denotes the observed magnitudes. Period04 should already have assumed that, so just click on 'OK'.

Now press 'Display graph' and examine the time string. You will observe that a strong beating is present, which could be the result of two close frequencies.

3. Extract the first frequency.


Click on the 'Fourier' tab. In the 'Fourier Calculation Settings' panel, enter a title for the new Fourier spectrum. As you can see, the Nyquist frequency of this time string is 139.806 cycles/day. Extend the upper limit of the frequency range to the lower integer part of this value (139). Before you start the calculation, make sure that the option Original data is selected.
Now press 'Calculate'.

A dialog will show up asking whether the zero point should be subtracted. Press 'Yes'. After the calculation has finished, the highest peak of the new spectrum is reported. Click on 'Yes' to copy the values of the frequency peak into the Fit module.

In the 'Fourier' tab, press 'Display graph' to inspect the plot of the Fourier spectrum.

4. Calculate a first fit.


Switch to the 'Fit' tab. You will notice that the new found frequency has not yet been selected. Select the frequency (F1) and press 'Calculate' to improve amplitude and phase. Then, to improve all parameters press 'Improve all'.

To check how good this solution fits the data, move to the 'Time string' tab and press 'Display graph'. As you see there is still some work to do.

5. Find and fit further frequencies.


Switch back to the 'Fourier' tab and calculate the next spectrum. From now on the Fourier calculations should be based on Residuals at original, so make sure that this option is selected.

In the Fit module, select the newly found frequency and press 'Calculate'. Then click on 'Improve all' to find the best least-squares solution.

To detect further frequencies proceed as stated above. Extract two more frequencies. The residuals will continue to decrease. This is what you should get:

6. Examining the data


Finally, after extraction of four frequencies the least-squares solution fits quite well. Maximize the plot window and examine each night carefully. You will notice that during the first and the last nights of the time string the data points are shifted slightly to the right of the fit, whereas for the nights in the middle of the data set the points are situated slightly left of the fit. This may indicate that a periodic time shift is present with a period that is approximately equal to the total length of the data set in time, about 100 days. That corresponds to a frequency of 0.01 cycles/day.

Well, let's see if we can find any further frequencies. Switch to the Fourier module and extract the next frequency:
Frequency = 8.23515582 cycles/day and Amplitude = 0.00092585 magnitudes.
This is quite interesting, isn't it? This frequency is quite close to the first detected frequency (F1). The difference is only 0.010095 c/d which is roughly the value for the frequency of the periodic time shift estimated by visual inspection. It seems likely that the new frequency is an artefact caused by a periodic time shift.

Now let's check whether our suspicion, viz. the presence of a periodic time shift, can be confirmed. Leave the new frequency (F5) unselected and do not change your four-frequency solution.

7. Activate the periodic time shift mode.


Fitting a periodic time shift can only be done if Period04 runs in expert mode. To activate the expert mode, set the option 'Expert mode' in the File menu selected. A new menu entry, Options, will appear on the menu bar. This menu contains the entry Set fitting function which provides the alternative 'Standard formula with periodic time shift'. Select this option. Now the program is enabled for calculating least-squares fits including a periodic time shift. You will notice that the fit module has slightly changed:

8. Determining the periodic time shift parameters.


For non-linear fitting, good starting values are essential. In general, initial values for the periodic time shift parameters can be estimated from visual inspection of the data, as we did before. Period04 also provides a tool to search for starting values within a user-defined range of frequencies and amplitudes by means of Monte Carlo shots. Press the button 'Search PTS start values' to use this option.

The lower frequency limit is calculated from the time base of the data set. You should not search for frequencies with lower values. The reason is that for such frequencies the time base of the data is too short to allow a reliable determination of the periodic time shift.
The number of shots refers to the number of initial parameter values that are being tested. We will keep the default values. However, we will deselect 'Use system time to initialize random generator' in order to allow the user to compare his results with the results given here. Press 'Ok' to start the calculation.

After the calculation has finished, the best set of starting values for the periodic time shift parameters will be displayed (Frequency = 0.00975 cycles/day, Amplitude = 0.00104 days). Now let us improve these parameters by clicking on 'Improve PTS'.

Finally, improve all frequencies together with the periodic time shift parameters by clicking on 'Improve all'. Do not use 'Calculate', as for a proper fit of a periodic time shift, the frequencies also have to be redetermined!

9. Extraction of further frequencies


Switch to the Fourier tab and calculate a new Fourier spectrum. Press 'Display graph' and have a look at the plot. It is obvious that the detected frequency peak is not significant. Therefore, our analysis will stop at this point.

Please note:
Let's suppose you would have found a significant frequency. In this case you should use 'Improve all' to obtain a new least-squares solution. Furthermore, you do not have to use the 'Search PTS start values' tool again, as you already have good starting values for the periodic time shift which can be improved.

10. The final solution


Your final fit using the four extracted frequencies and including a periodic time shift should be:

The residual noise is 0.000999 magnitudes.

Click on the 'Time string' tab and press the button 'Display graph'. You will notice that the solution fits the data very well. After having applied the periodic time shift, the data points are distributed uniformly on both sides of the fit.

Now let us compare the final parameters to the values that had been used to generate this time string:
#       Frequency	 Amplitude	 Phase
------------------------------------------------------
PTSF	0.01		 0.001		 0.5
F1	8.24559		 0.036872 	 0.19192 
F2	8.86632		 0.031595 	 0.20128 
F3	8.51414		 0.009952 	 0.81182 
F4	7.42476		 0.008187 	 0.76091 
------------------------------------------------------
Desired residual noise: 0.001

Note the good agreement. The deviation from the initial values is caused by noise.