Detail of the spectralModel plugin
The algorithms implemented into the spectralModel plugin are detailed in Coles et al. (in preparation).
Command line inputs
tempo2 -gr spectralModel -f mypar.par mytim.tim
By default the plugin produces a text file (covarFunc.dat) that contains the data covariance function. This can be used in the tempo2 fit using the
-dcf covarFunc.dat command line input for tempo2 and the plk plugin.
Step 1: Obtaining a smooth model of the residuals and the high frequency component
- Step 1a: the postfit timing residuals are obtained. Note that this plugin requires that the timing residuals be sorted in time order.
- Step 1b: a mean is removed from the residuals and the time of the arrival times is centred on zero. Note that the residuals are measured in seconds and the times in days. The TOA uncertainties are in seconds.
- Step 1c: a cubic polynomial is fitted (using an unweighted least-squares-fit) and removed from the residuals
- Step 1d: the difference between the actual data and the cubic polynomial is obtained. These differences are smoothed using a weighted exponential smoothing function. This smooth function is added to the cubic polynomial to provide a smooth curve that models the low-frequency component of the timing residuals. The default smoothing time is 20d, but this can be set by the user.
- Step 1e: the high-pass filtered timing residuals are obtained by subtracted the actual residuals from the smooth model.
- Step 1f: the covariance function of the normalised high frequency (HF) residuals are obtained by removing an unweighted mean from the HF residuals. The HF residuals are divided by their corresponding error bars to obtain normalised residuals. The covariance function as a function of time lag is obtained by binning the time lags in one day intervals. Data points that are exactly simultaneous are used separately to obtain the zero lag normalised covariance.
- Step 1g: the original residuals, the cubic fit, the smoothed curve, the HF residuals and the normalised covariance are plotted.
Step 2: Obtain spectra of the timing residuals to determine whether pre-whitening/post-darkening is required
- Step 2a: Calculate a weighted DFT of the original residuals without any pre-whitening.
- Step 2b: Interpolate the smoothed curve obtained in Step 1d using a weighted, exponential interpolation routine onto a regular grid with 14 day spacing.
- Step 2c: Calculate the DFT of the interpolated data without any pre-whitening
- Step 2d: As above, but with first order pre-whitening/post-darkening (the pre-whitening is carried out by differencing the interpolated data)
- Step 2e: As above, but with second order pre-whitening/post-darkening
- Step 2f: Obtain a weighted DFT of the HF residuals.
- Step 2g: Make a plot containing all these spectra and ask the user the select the amount of pre-whitening required (0, 1, 2) or whether the data are "white-enough" to allow the covariance function to be estimated directly from the original timing residuals (-1).
Step 3: Obtaining the covariance function by modelling the spectra
- Step 3a: Allow the user to select the amount of pre-whitening required (0, 1, 2)
- Step 3b: Plot the spectra and allow the user to fit a simple model to the spectra. The form of the model is P(f) = A/(1+(f/fc)^20^alpha/2 where there user specifies a corner frequency fc, a spectral exponent (alpha) and the number of channels in the spectrum to be fitted. A weighted least-squares-fit is then used to calculate the amplitude A. The weighting for each channel is taken as the model value squared. The model is overplotted on the spectra and the procedure iterated until the user has obtained a good model.
Step 3: Obtaining the covariance function directly from the timing residuals
- Step 3a: The covariance function of the original timing residuals (in daily bins) is obtained.
- Step 3b: The best fit exponential function to the covariance function is obtained by searching for a minimum in chisq using a grid search in the exponential time scale.
Step 4: Obtaining a data covariance matrix
- Step 4a: If a model of the spectrum has been obtained then this is converted to a covariance function by calculating the Fourier transform of the spectral model. The covariance function is first normalised so that the first point equals 1 and then scaled by a factor of 0.6 (to take into account the initial removal of a quadratic polynomial) and then by fitted variance.
- Step 4b: A whitening matrix is obtained by carrying out a Cholesky decomposition of the data covariance matrix (obtained from the time difference between each observation and the covariance function previously measured).
- Step 4c: 'white timing residuals' are obtained by pre-multiplying the timing residuals by the whitening matrix.
- Step 4d: The covariance function of the white timing residuals are obtained.
- Step 4e: The original timing residuals, the whitened timing residuals and the covariance function of the white timing residuals are plotted.
Step 5: Improving the spectral model
- Step 5a: A spectrum is obtained by whitening both the data and the model (harmonically related sinuosoids) with the whitening matrix.
- Step 5b: The spectral model is re-fitted to the new estimate of the spectrum
- Step 5c: The original pre-whitening/post-darkened spectrum, HF residual spectrum and the new spectrum are overplotted for comparison.
Step 6: Output the covariance function
- Step 6a: The covariance function is recorded on disk.