Pulsar timing software

Timing residuals PSD using Lomb-Scargle method
Libstempo installation
Enterprise installation

[!!!] When following these instructions, find-and-replace "boris.goncharov" with you username on OzStar.

Timing residuals PSD using Lomb-Scargle method

To produce a spectrum (periodogram) of timing residuals we need to use a Lomb-Scargle method, as it deals with unevenly-sampled data. PSD is trivially obtained by dividing a spectrum by a square root of frequencies. There are different ways to do it:

  1. Python: Astropy's LombScargle. This module allows to include TOA errors.
    • Normalization by 'psd' is required
    • Normalization automatically changes when ToA errors are included
    • In my case, conversion of data to float64 was required to avoid an error
    • "Unreasonable" frequencies below 1/Tobs and above fsamp are included in the output, they should be excluded
    Example of using with libstempo's tempopulsar object "psr":
    ls_psr = LombScargle(psr.toas().astype('float64')*day, \
        psr.residuals().astype('float64'), \
    psr_f, psr_pow = ls_psr.autopower()
    psr_psd = psr_pow/np.sqrt(psr_f)
  2. MATLAB: plomb
    This method, I believe, can not deal with TOA errors
  3. Tempo2: CholSpectra plugin
    Usage: tempo2 -gr cholSpectra -f pulsar_name.par pulsar_name.tim
    Caveat: pulsar_name.model file, containing pulsar red noise parameters, is requred in the same directory as .par and .tim files. Example:
    MODEL T2
    MODEL T2PowerLaw 3.5 2e-25 0.06
    Numbers in the second line are parameters of Lorenzian powerlaw: spectral index, amplitude [yr^3] and cornder frequency [year^-1]. They can be inferred by running parameter estimation (Enterprise), or the whole file can be generated by running tempo2's autoSpectralFit plugin.


Tempo2 installation on MacOS

First, we need meet some requirements. Let's install them using HomeBrew.

After that follow other instructions below.

Tempo2 installation with PSRSoft (with pgplot)

  1. Install gfortran of the version 7 with brew: brew install gcc@7. The new versions are actually not compatible with pgplot and tempo2. If you are using OzStar, instead of brew you can just load the right versions of gcc and gcccore: module load gcc/7.3.0 gcccore/7.3.0.
  2. Download PSRsoft by downloading and unpacking this file to the directory where you would like PSRSoft to be installed: http://pulsarastronomy.net/psrsoft/psrsoft.tar.gz. Go to the psrsoft directory.
  3. As mentioned in PSRSoft installation instructions, cp config/profile.example profile.
  4. Make sure you actually have gfortran, gcc and g++ of version 7. Run man -k g++ gcc gfortran to see the names of the code. Brew installs gfortran 7 with the executable name "gfortran-7", and similarly for gcc and g++. Check version of all of these executables by e.g. gfortran --version.
  5. From the main PSRSoft directory, run ./bin/psrsoft tempo2, and follow the instructions. In case of errors, perhaps the installation still goes on with other gfortran versions. Then, for gfortran, gcc and g++, run in the command line alias gcc="gcc-7".
  6. Repeat ./bin/psrsoft tempo2, but this time choose to install tempo2 plug-ins.
  7. Add to your .basrhc or .bash_profile or .zprofile, depending on your system,
    export TEMPO2=psrsoft_directory/usr/share/tempo2/ and
    alias tempo2='psrsoft_directory/usr/bin/tempo2'.

Tempo2 installation from git (without pgplot)

Start in your home directory (cd ~):

  1. mkdir tempo2_runtime
  2. git clone https://bitbucket.org/psrsoft/tempo2.git
  3. cd tempo2
  4. ./bootstrap
  5. cp -r T2runtime /home/boris.goncharov/tempo2_runtime/
  6. export TEMPO2=/home/boris.goncharov/tempo2_runtime/
  7. Make sure to create a folder "plugins" in tempo2 runtime directory listed in .bashrc.
  8. ./configure
  9. make && make install
  10. make plugins && make plugins-install

The pgplot can then be installed separately.

Tempo2 usage

In my case, the tempo2 command is not globally recognized, so I only run tempo2 from tempo2_runtime/bin: ./tempo2

Libstempo installation

Libstempo requires tempo2 installed. Then follow these steps:

  1. git clone https://github.com/vallis/libstempo.git
  2. cd libstempo
  3. python setup.py install --user --with-tempo2=/home/boris.goncharov/tempo2_runtime/

[!!!] On OzStar whatever is installed with "pip install --user" is not available in Jupyter notebook, that is run with sbatch on localhost. This way libstempo will not be available in Jupyter.

Enterprise installation

Enterprise requires tempo2 and libstempo installed. It requires an MCMC sampler, i.e. PTMCMCSampler. I think installing this sampler crashed my enterprise because it installed other version of numpy. Uninstalling numpy, and making sure numpy 1.14.0 is installed, helped. Then follow these steps:

  1. cd ~
  2. pip install --user numpy
  3. git clone https://github.com/nanograv/enterprise.git
  4. cd enterprise
  5. Try running pip install -r requirements.txt
    If it doesn't work, in another window open the requirements file:
    vim ~/enterprise/requirements.txt
    And for each requirement run:
    pip install --user ***requirement_module_name***
  6. python setup.py install --user
  7. We might have confusing directories, let's do following to avoid future errors in Enterprise:
    cd /home/boris.goncharov/tempo2_runtime
    and cp -r T2runtime share/tempo2.

Recent Work