# Pulsars and neutron stars/Tutorials and worksheets

## Pulsar timing tutorials[edit | edit source]

### Timing practice: step-by-step[edit | edit source]

This tutorial was given by G. Hobbs, M. Yu and S. Dai at the Kunming SKA summer school (2015).

Does tempo2 basically work and are the plugins available:

tempo2 –h

#### Parameter determination for easy data set[edit | edit source]

Have a simulated data set (data1.par and data1.tim). The data only contains white noise. What are the pulsar parameters?

- Look at data1.par and data1.tim files
- tempo2 -f data1.par data1.tim
- tempo2 –gr plk -f data1.par data1.tim
- Press ‘h’ to see some “help” information
- First check for phase jumps (see later) – check that the -0.5 < residual phase is < 0.5
- Click on postfit for the y-axis
- Select to fit for F0
- Click on RE-FIT
- Compare pre-fit with post-fit
- Look at the text output for the new parameter and its uncertainty (and check the reduced chisq value)
- Now fit for F0 and F1 simultaneously (select F1, select post-fit, click on RE-FIT)
- Check the parameter output and uncertainties
- Now also fit for RAJ and DECJ (along with F0 and F1)
- Now also fit for PMRA and PMDEC
- Now select to plot “day of year” on the x-axis and “post-fit” on the y-axis.
- Now fit for PX and plot with date on x-axis and post-fit on y-axis (also check with day-of-year on the x-axis)
- Check the final parameter output and uncertainties and reduced chisq value?
- Save your results by clicking “New par” enter the new name (data1_final.par)
- Quit by clicking on “Quit”
- tempo2 –gr plk –f data1_final.par data1.tim

(also can try with a different realization of the white noise: data2.par data2.tim)

#### Visualizing the residuals[edit | edit source]

- tempo2 –gr plk –f data4.par data4.tim
- Click with the left mouse button on a point to see information about that point. If profiles exist (not for this data) then click the middle mouse button to see the profile
- Can use the right mouse button to delete a single point (or press ‘d’)
- Can use shift-z to delete a region of points
- Can save a new arrival time file by clicking on “New Tim” – select “tempo2” format and then type in a new file name “good.tim”. Quit
- tempo2 –gr plk –f data4.par good.tim
- Select plotting “frequency” on the x-axis – note the colour scheme for different frequencies (red = 700 MHz data, green = 1400 MHz data, blue = 3100 MHz data).
- Click on some green points and note the “-or pks1” (this is a flag in the arrival time file). Note “-or pks2” for the blue points and “-or pks3”, “-or pks4” and “-or pks5” for the red points.
- Plot “date” on x-axis and press “ctrl-i” then type –or. This colours the points by the “-or” flag. Press “ctrl-i” again to return to default colours.
- There are clearly some offsets between the different systems. Open the parameter file (data4.par) and add in:

```
JUMP –or pks1 0 1
JUMP –or pks3 0 1
```

- tempo2 –gr plk –f data4.par good.tim (notice that the offsets are changing).
- Also add in:

```
JUMP –or pks4 0 1
JUMP –or pks5 0 1
```

- tempo2 –gr plk –f data4.par good.tim
- Why haven’t we put a jump on “-or pks2” ?
- Now fit the other parameters and produce a good set of parameters. Save as good.par and good.tim.

#### Dispersion measure variations[edit | edit source]

- tempo2 –gr plk –f data7.par data7.tim
- Find the MJD of the earliest observation and the latest observation (click with the left mouse button)
- Add into data7.par:

```
DMMODEL DM 1
CONSTRAIN DMMODEL
```

- seq 52960 100 56060 | awk ‘{print “DMOFF”,$1,0,0}’ >> data7.par
- tempo2 –gr plk –f data7.par data7.tim
- Look at the post-fit residuals

gnuplot

plot “J1744-1134.dm” using 1:2:3 w yerr

#### EFACs and EQUADs[edit | edit source]

- tempo2 –gr plk –f data5.par data5.tim
- Plot “TOA error” on the x-axis. Note that the error bars are clearly wrong. Must correct the errors somehow.

e’ = (e2 + EQUAD2)1/2 x EFAC (note that this has no physical meaning)

- Let’s guess an EQUAD (in microseconds). Add

EQUAD 5

at the top (after FORMAT 1) of the data5.tim file

- tempo2 –gr plk –f data5.par data5.tim (look at the reduced chisq value)
- Now change EQUAD 5 to EFAC 10. Check the reduced chisq value
- Now remove EFAC and EQUAD from the arrival time file
- tempo2 –gr efacEquad –f data5.par data5.tim –flag –or –plot (press ‘q’ to quit)
- Copy efacEquad_output.dat into data5.par file.
- tempo2 –gr plk –f data5.par data5.tim (look at the reduced chisq value)

#### Parameter determination with a red noise model[edit | edit source]

- tempo2 –gr plk –f data3.par data3.tim
- Follow the same process as for data1.par and data1.tim until you have fitted for all the parameters. Check the fit results and the reduced chisq (>> 1). Notice that the post-fit residuals are not white.
- Save our best parameters: “New Par” and save as try1.par. Quit
- tempo2 –gr spectralModel –f try1.par data3.tim –npsr 1
- Type 30 and then type 0
- Press ‘2’
- Guess 0.1, 5, 5, press ‘0’
- Press ‘1’
- Notice excess power at 1/1yr. We need to improve our fit for position before getting a good red noise model
- Check for J1744-1134.model file on your disk
- tempo2 –gr plk –f try1.par data3.tim –dcf J1744-1134.model
- Look at pre-fit and post-fit and the resulting parameters (look at PX)
- Write out a new parameter file (try2.par) and quit
- tempo2 –gr spectralModel –f try2.par data3.tim –npsr 1 –nofit –fit f0 –fit f1
- Type “30” then “0” then “2”, “0.1”, “5.5”, “8”, “0”, “1”
- Re-run tempo2 –gr plk …. and iterate until the parameters stop changing

Is the noise model good enough? Does it whiten and normalise the residuals?

- Save as good.par
- gnuplot
- plot “cholWhiteRes.dat” using 1:2
- Check that these points are “white” and Gaussianly distributed with a standard deviation of 1.

Do you believe the red noise model parameters? Can you get similarly good parameters, but with a different red noise model parameters?

#### Phase wraps and pulse numbering[edit | edit source]

- tempo2 –gr plk –f data6.par data6.tim

(There are quite a few ways to solve this … here’s one …)

- Add the following into data6.par:

```
F2 0
F3 0
F4 0
F5 0
F6 0
```

- tempo2 –gr plk –f data6.par data6.tim
- Choose post-fit plotting on the y-axis. Select a region without a phase jump (use ‘z’). Press ‘y’. Click on “RE-FIT” (that only fits in that small region)
- Unzoom ‘u’ and repeat as much as possible
- When it is not possible to go further, turn on fitting for F2 and repeat.
- Repeat with F3, F4 etc. Note that this works well until MJD 55400
- For now let’s delete the data after MJD 55400. Press ‘n’. This produces a new file “withpn.tim”.
- cp withpn.tim start.tim
- Note that it contains pulse numbers
- Now do the same for the data from 55400 onwards (but ensure that one observation overlaps). Press ‘n’ and copy the new withpn.tim to end.tim
- We now have to join the files (but ensure that the observation at 55400 has the same pulse number)
- In start.tim it has pulse number 50891778739
- In end.tim it has pulse number 50891778672 (so must add 67 to all the pulse numbers in end.tim)
- awk ‘{print $1,$2,$3,$4,$5,$6,$7+67}’ end.tim >> start.tim
- Tell tempo2 to use the pulse numbering scheme. In data6.par add:

TRACK -2

- tempo2 –gr plk –f data6.par start.tim
- Note the timing noise and the glitch!

Also look at the “splk”, “plotMany”, “publish”, “glitch”, “general”, “general2” plugins. See [1] for more usage instructions.