Pulsar timing

Scripts for pulse phases, profiles, templates and TOAs. See Pulsar timing for an overview.

photon_toa.py

Generate TOAs from photon event data.

Normally uses a multi-gaussian template as the reference, but can also compute TOAs from the phase of a Fourier analysis of the photon phases. You can select this mode by using ‘harmN’ for the template, where N is the harmonic number whose phase you want to measure (harm1 is the fundamental).

usage: photon_toa.py [-h] [--orbfile ORBFILE] [--phasecol PHASECOL]
                     [--ephem EPHEM] [--plot] [--plotfile PLOTFILE]
                     [--unbinned] [--tint TINT] [--maxint MAXINT]
                     [--minexp MINEXP] [--track] [--dice] [--grid GRID]
                     [--use_bipm] [--use_gps] [--topo] [--outfile OUTFILE]
                     [--gtiextname GTIEXTNAME] [--append]
                     eventname templatename parname

Positional Arguments

eventname

FITS file to read events from

templatename

Name of file to read template from, or ‘harmN’ for the Nth harmonic (e.g. harm1=fundamental)

parname

Timing model file name

Named Arguments

--orbfile

Name of orbit file

--phasecol

Name of a column in the event FITS file holding pre-computed pulse phases (values in [0,1)). If given, these phases are used directly instead of computing them from the timing model with modelin.phase(), which can be slow for large numbers of photons. The timing model (parname) is still loaded and used for everything else (e.g. barycentering and the local spin frequency used to form each TOA).

--ephem

Planetary ephemeris to use (default=DE421)

Default: 'DE421'

--plot

Show phaseogram plot.

Default: False

--plotfile

Output figure file name (default=None)

--unbinned

Fit position with unbinned likelihood. Don’t use for large data sets. (default=False)

Default: False

--tint

Integrate for tint seconds for each TOA, or until the total integration exceeds maxint. The algorithm is based on GTI, so the integration will slightly exceed tint (default None; see maxint.)

--maxint

Maximum time interval to accumulate exposure for a single TOA (default=2*86400s)

Default: 172800.0

--minexp

Minimum exposure (s) for which to include a TOA (default=0.0).

Default: 0.0

--track

Assume model is close to good and only search near 0 phase (to avoid getting TOAs off by 0.5 in double peaked pulsars)

Default: False

--dice

Dice up long GTIs into chunks of length <= tint

Default: False

--grid

Compute TOAs on a regular grid of <arg> days

Default: 0.0

--use_bipm

Use BIPM clock corrections

Default: False

--use_gps

Use GPS to UTC clock corrections

Default: False

--topo

Make topocentric TOAs; include the spacecraft ECI position on the TOA line

Default: False

--outfile

Name of file to save TOAs to (default is STDOUT)

--gtiextname

Name GTI extenstion to use (default is GTI)

Default: 'GTI'

--append

Append TOAs to output file instead of overwriting

Default: False

photon_fit.py

Perform a template fit using a stored phase column and print source and background properties.

usage: photon_fit.py [-h] [--phasecol PHASECOL] eventname templatename

Positional Arguments

eventname

FITS file to read events from

templatename

Name of file to read template from

Named Arguments

--phasecol

FITS column to use for pulse phase.

Default: 'PULSE_PHASE'

niphaseogram.py

Read a FITS event file containing a PULSE_PHASE column and make a 2-d phaseogram

usage: niphaseogram.py [-h] [-n NTOA] [-b NBINS] [-e EMIN] [-x EMAX]
                       [-o OUTFILE] [-r RADIO] [-B RADIOBINS] [-w WEIGHTS]
                       [-t TMIN] [-p] [-s]
                       evname

Positional Arguments

evname

Event FITS file with a PULSE_PHASE column

Named Arguments

-n, --ntoa

Number of TOAs to produce between TSTART and TSTOP.

Default: 60

-b, --nbins

Number of bins in each profile.

Default: 32

-e, --emin

Minimum energy to include.

Default: 0.25

-x, --emax

Maximum energy to include.

Default: 12.0

-o, --outfile

File name for plot file. Type comes from extension.

-r, --radio

Radio profile to overplot.

-B, --radiobins

Number of bins in each profile (default=128)

Default: 128

-w, --weights

FITS column to use as photon weight.

-t, --tmin

Minimum time to include (MJD)

Default: 0.0

-p, --profonly

Make only pulse profile plot.

Default: False

-s, --subtract_min

Subtract min from each row in the phaseogram.

Default: False

plotphist.py

Plot a binned light curve from a PULSE_PHASE column in a FITS file

usage: plotphist.py [-h] [--nbins NBINS] [--emin EMIN] [--emax EMAX]
                    [--outfile OUTFILE]
                    evtfile

Positional Arguments

evtfile

Input event file to process. Must have PULSE_PHASE column

Named Arguments

--nbins

Number of profile bins (default 32)

Default: 32

--emin

Minimum energy to include.

Default: 0.25

--emax

Maximum energy to include.

Default: 12.0

--outfile

Output file for plot (type determined by extension)

ni2dpulse.py

Read event file with PULSE_PHASE and PI columns and make 2-D plot

usage: ni2dpulse.py [-h] [--outfile OUTFILE] [--nbins NBINS] [--emin EMIN]
                    [--emax EMAX] [--nebins NEBINS] [--log] [--sqrt]
                    [--norm_mean] [--norm_effarea] [--arfile ARFILE]
                    evfile

Positional Arguments

evfile

Name of event files to process

Named Arguments

--outfile

Name of output file for plot

--nbins

Number of phase bins

Default: 32

--emin

Min energy to plot

Default: 0.3

--emax

Max energy to plot

Default: 2.0

--nebins

Number of energy bins

Default: 35

--log

Log scale histogram

Default: False

--sqrt

Log scale histogram

Default: False

--norm_mean

Normalized by mean cts per channel

Default: False

--norm_effarea

Normalized by effective area

Default: False

--arfile

ARF file for effective area normalization (default: Arf in CALDB)

nitemplate.py

Interactive: the fit is controlled with the mouse and keyboard in the plot window.

Read an FT1 file containing PULSE_PHASE info and interactively fit a template.

usage: nitemplate.py [-h] [--nhistbins NHISTBINS] [--nprofbins NPROFBINS] [-u]
                     [-a] [-w] [-c WEIGHTCOL] [-p PROF] [-m MIN_WEIGHT]
                     [-t TMIN] [-T TMAX] [-e]
                     ft1file

Positional Arguments

ft1file

FT1 (or event) FITS file with a PULSE_PHASE column.

Named Arguments

--nhistbins

Number of bins to use in phase histogram.

Default: 50

--nprofbins

Number of bins to use output tabular profile.

Default: 256

-u, --unbinned

Perform fit with unbinned likelihood.

Default: False

-a, --align

Align template such that peak falls at phase 0.

Default: False

-w, --weights

Use weighted light curve

Default: False

-c, --weightcol

Column in FITS file that holds the weight

Default: 'WEIGHT'

-p, --prof

Output name for products (default itemplate.*

-m, --min_weight

Minimum weight to include in fit.

Default: 0.01

-t, --tmin

Minimum time to include in fit.

Default: 0

-T, --tmax

Maximum time to include in fit.

Default: 999999999

-e, --errors

Compute errors on components.

Default: False

fix_template.py

Renormalize the profile in a template file (data after the META_STOP line) so that its minimum is zero and its mean is one, writing the result to fixed.tem.

usage: fix_template.py [-h] template

Positional Arguments

template

Input template file

fitharms.py

Fit a set of pulse phases to harmonics

usage: fitharms.py [-h] [--white] [--txt] [--showcomps] [--noplot]
                   [--output OUTPUT] [--numharm NUMHARM] [--numbins NUMBINS]
                   [--emin EMIN] [--emax EMAX]
                   evname

Positional Arguments

evname

Input event file (must have PULSE_PHASE column)

Named Arguments

--white

Replace phases with white random numbers, for testing

Default: False

--txt

Assume input file is .txt instead of FITS

Default: False

--showcomps

Show individual components of harmonic fit on plot

Default: False

--noplot

Don’t show any plots

Default: False

--output

Save figures with basename

--numharm

Max harmonic to use in analysis (1=Fundamental only)

Default: 4

--numbins

Number of bins for histograms

Default: 200

--emin

Minimum energy to include (keV)

Default: 0.25

--emax

Maximum energy to include (keV)

Default: 12.0

calcrms.py

Calc RMS fractional amplitude of a pulsation

usage: calcrms.py [-h] [-b NBINS] [--bkg BKG] [--random RANDOM] evname

Positional Arguments

evname

Event FITS file with a PULSE_PHASE column

Named Arguments

-b, --nbins

Number of bins in each profile.

Default: 32

--bkg

Background rate to subtract (in counts/second)

Default: 0.0

--random

Simulate white noise

Default: False

nioptcuts.py

Finds the energy range that maximizes the pulsation significance.

Read event file with phase and optimize cuts

usage: nioptcuts.py [-h] [--minlowE MINLOWE] [--maxlowE MAXLOWE]
                    [--minhighE MINHIGHE] [--maxhighE MAXHIGHE]
                    [--steplowE STEPLOWE] [--stephighE STEPHIGHE] [--noplot]
                    [--grid] [-n NBINS] [-m MAXHARM] [-z]
                    [--min_good_time MIN_GOOD_TIME]
                    evfiles [evfiles ...]

Positional Arguments

evfiles

Name of event files to process

Named Arguments

--minlowE

minimum E for the low cut.

Default: 0.25

--maxlowE

maximum E for the low cut.

Default: 4.0

--minhighE

minimum E for the high cut.

--maxhighE

maximum E for the high cut.

Default: 12.0

--steplowE

step in energy for the low cut.

Default: 0.05

--stephighE

step in energy for the high cut.

Default: 0.1

--noplot

Suppress plotting.

Default: False

--grid

Shows grid of H-test

Default: False

-n, --nbins

Number of bins of outout profiles

Default: 16

-m, --maxharm

Search up to harmonic m; [default=20, H-test]

Default: 20

-z, --ztest

Use Z-test rather than H-test; this searches with exactly the number of harmonics specified. m=1 is Rayleigh, m=2 is Z^2_2, etc.

Default: False

--min_good_time

Ignore files with GTI sum below specified value [default None; unit sec].

ni_Htest_sortgti.py

Read one or more event files to sort GTI by background rate and evaluate H-test

usage: ni_Htest_sortgti.py [-h] [--emin EMIN] [--emax EMAX]
                           [--maxemin MAXEMIN] [--minemax MINEMAX]
                           [--delta_emin DELTA_EMIN] [--delta_emax DELTA_EMAX]
                           [--gridsearch] [--minbw MINBW] [--minexp MINEXP]
                           [--mingti MINGTI] [--nopulsetest]
                           [--verbosity VERBOSITY] [--writegti]
                           [--writeevents] [--remote] [--save_profile]
                           [--save_rates] [--usez] [--nbins NBINS]
                           [--name NAME]
                           [--log-level {TRACE,DEBUG,INFO,WARNING,ERROR}]
                           infile [infile ...] outfile

Positional Arguments

infile

file or text file with list of event file

outfile

name for output files

Named Arguments

--emin

Minimum energy to include (keV, default=0.25)

Default: 0.25

--emax

Maximum energy to include (keV, default=2.00)

Default: 2.0

--maxemin

Maximum emin to use in grid search (keV, default=1.00)

Default: 1.0

--minemax

Minimum emax to use in grid search (keV, default=1.00)

Default: 1.0

--delta_emin

Step size of the lower bound of the search grid (keV, default=0.01)

Default: 0.01

--delta_emax

Step size of the lower bound of the search grid (keV, default=0.02)

Default: 0.02

--gridsearch

Search over energies to find max H-test

Default: False

--minbw

Minimum fractional bandwidth used during energy grid searching. E.g., --minbw=0.5 would allow a 1.0 to 1.5 (50%) keV energy range, but not a 2.0 to 2.2 (10%) range.

--minexp

Minimum exposure allowed for a candidate cut, expressed as a fraction of the total. E.g., --minexp=0.2 would allow a cut that throws away 80% of the GTI.

--mingti

Minimum GTI length to allow -- short GTIs don’t give a reliable count rate. (seconds, default=10.0)

Default: 10.0

--nopulsetest

Only use the predicted S/N to determine the GTIs to use.

Default: False

--verbosity

Verbosity (0=quiet,1=default,2=verbose,3=very verbose).

Default: 1

--writegti

Write out the GTI corresponding to the event selection.

Default: False

--writeevents

Write out the corresponding event file

Default: False

--remote

Disable interactive plotting backend

Default: False

--save_profile

export optimal profile as ascii file

Default: False

--save_rates

export count rates from optimal GTI selection (also saves a figure)

Default: False

--usez

Use Z^2_2 test instead of H test.

Default: False

--nbins

Number of bins for plotting pulse profile (default=16)

Default: 16

--name

Pulsar name for output figure

Default: ''

--log-level

Possible choices: TRACE, DEBUG, INFO, WARNING, ERROR

Logging level

Default: 'INFO'

toafilt.py

Read TOAs from a .tim file and filter out TOAs based on simple conditions, then write new .tim file

usage: toafilt.py [-h] [--outfile OUTFILE] [--clobber] [--minhtest MINHTEST]
                  [--minexp MINEXP] [--maxerr MAXERR]
                  timname

Positional Arguments

timname

.tim file to read TOAs from

Named Arguments

--outfile

Name of output file (default=STDOUT)

--clobber

Overwrite outfile if it already exists.

Default: False

--minhtest

Minimum value of H-test to keep (default=9)

Default: 9.0

--minexp

Minimum exposure keep (default=16 seconds)

Default: 16.0

--maxerr

Maximum TOA error to retain (unit=microsecons, default=25)

Default: 25.0

pardiff.py

Compare 2 par file

usage: pardiff.py [-h] [--verbose] par1 par2

Positional Arguments

par1

First par file

par2

Second par file

Named Arguments

--verbose

Print more details.

Default: False

jodrellcrabmonthly2par.py

Makes Crab pulsar timing models from the Jodrell Bank monthly ephemeris.

Write out Tempo2 par files based on Jodrell montly ephemeris

usage: jodrellcrabmonthly2par.py [-h] [--auto-download] MJD

Positional Arguments

MJD

MJD to extract ephemeris for

Named Arguments

--auto-download, -y

Automatically download crab2.txt without prompting if not found

Default: False

nicerfits2presto.py

Convert NICER events to PRESTO bin+inf files.

usage: nicerfits2presto.py [-h] [--dt DT] [--nbins NBINS] [--ra RA]
                           [--dec DEC] [--observer OBSERVER] [--force]
                           [--search] [--numharm NUMHARM] [--zmax ZMAX]
                           [--flo FLO]
                           evfile

Positional Arguments

evfile

Name of event file to convert (must be barycentered)

Named Arguments

--dt

Time series bin size

Default: 0.0078125

--nbins

Number of time series bins to write

Default: 0

--ra

RA in HH:MM:SS.s

Default: '00:00:00'

--dec

DEC in DD:MM:SS.s

Default: '00:00:00'

--observer

Name of person analyzing data

--force

Force processing even if not barycentered

Default: False

--search

Do an FFT and search the data after creating it

Default: False

--numharm

Number of harmonics to sum in search

Default: '2'

--zmax

Max z for acceleration search

Default: '50'

--flo

Lowest freq (of highest harmonic) to search

Default: '0.02'