Processing Script for J0645+5158

Import statements and load notebook utilities

In [1]:
!git checkout master
!git branch
M	working/B1855+09/process.ipynb
M	working/B1937+21/B1937+21.working.par
M	working/B1937+21/B1937+21.working.tim
M	working/B1937+21/process.ipynb
M	working/B1953+29/process.ipynb
M	working/J0023+0923/process.ipynb
M	working/J0030+0451/process.ipynb
M	working/J0340+4130/process.ipynb
M	working/J0613-0200/process.ipynb
M	working/J0636+5128/process.ipynb
M	working/J0645+5158/process.ipynb
M	working/J0740+6620/process.ipynb
M	working/J0931-1902/process.ipynb
M	working/J1012+5307/process.ipynb
M	working/J1022+1001/J1022+1001.working.par
M	working/J1022+1001/J1022+1001.working.tim
M	working/J1022+1001/process.ipynb
M	working/J1024-0719/process.ipynb
M	working/J1125+7819/process.ipynb
M	working/J1453+1902/process.ipynb
M	working/J1455-3330/process.ipynb
M	working/J1600-3053/process.ipynb
M	working/J1614-2230/process.ipynb
M	working/J1640+2224/process.ipynb
M	working/J1643-1224/process.ipynb
M	working/J1713+0747/J1713+0747.working.par
M	working/J1713+0747/J1713+0747.working.tim
M	working/J1713+0747/process.ipynb
M	working/J1738+0333/process.ipynb
M	working/J1741+1351/process.ipynb
M	working/J1744-1134/process.ipynb
M	working/J1747-4036/process.ipynb
M	working/J1832-0836/process.ipynb
M	working/J1853+1303/process.ipynb
M	working/J1903+0327/process.ipynb
M	working/J1909-3744/process.ipynb
M	working/J1910+1256/process.ipynb
M	working/J1911+1347/J1911+1347.working.par
M	working/J1911+1347/J1911+1347.working.tim
M	working/J1911+1347/process.ipynb
M	working/J1918-0642/process.ipynb
M	working/J1923+2515/process.ipynb
M	working/J1944+0907/process.ipynb
M	working/J1946+3417/process.ipynb
M	working/J2010-1323/process.ipynb
M	working/J2017+0603/process.ipynb
M	working/J2033+1734/process.ipynb
M	working/J2043+1711/process.ipynb
M	working/J2145-0750/process.ipynb
M	working/J2214+3000/process.ipynb
M	working/J2229+2643/process.ipynb
M	working/J2234+0611/process.ipynb
M	working/J2234+0944/process.ipynb
M	working/J2302+4442/process.ipynb
M	working/J2317+1439/process.ipynb
M	working/J2322+2057/process.ipynb
Already on 'master'
Your branch is up-to-date with 'origin/master'.
* master
  recalibrate
In [2]:
import os
import sys
sys.path.append("/home/jovyan/work/shared/nanograv_timing_2017/util/")
from nanograv_utils import *
sys.path.append("/home/jovyan/work/shared/")
from pypulse.tim import Tim
%matplotlib inline
# Load the notebook utilities
nanoutils = NANOGravUtils()
tempoutils = TempoUtils()
pintutils = PINTUtils()
enterpriseutils = EnterpriseUtils()

User-defined constants here

In [3]:
FLAGS = "-G" # Use "-G" for Generalized least squares fit
NITER = 50000 #10000 # How many iterations to run PAL2 for

Set pulsar name, create working par and tim files, working directories

In [4]:
EXCISEPARFILE = "J0645+5158.excise.par"
EXCISETIMFILE = "J0645+5158.excise.tim"
PARFILE = "J0645+5158.working.par"
TIMFILE = "J0645+5158.working.tim"
# Copy initial par/tim files into working files
call("cp J0645+5158.dmx.par %s"%EXCISEPARFILE)
call("cp J0645+5158.dmx.tim %s"%EXCISETIMFILE)

Initial tempo run and residuals plot

In [5]:
tempoutils.tempo(EXCISEPARFILE,EXCISETIMFILE,c=True)
tempoutils.plot_resids()

TOA excision

In [6]:
# TOA excision from outlier analysis
outlierfilenames = np.loadtxt("outlier/J0645+5158.dmx-outliers.txt",unpack=True,usecols=(0,),dtype=np.str,ndmin=1)
outlierchans = np.loadtxt("outlier/J0645+5158.dmx-outliers.txt",unpack=True,usecols=(6,),dtype=np.int,ndmin=1)
outliersubints = np.loadtxt("outlier/J0645+5158.dmx-outliers.txt",unpack=True,usecols=(8,),dtype=np.int,ndmin=1)
outlierpouts = np.loadtxt("outlier/J0645+5158.dmx-outliers.txt",unpack=True,usecols=(12,),dtype=np.float,ndmin=1)

tim = Tim(EXCISETIMFILE)
for toa in tim.toas:
    filename,chan,subint = toa.getFilename(),int(toa.get('chan')),int(toa.get('subint'))
    for i,outlierfilename in enumerate(outlierfilenames):
        if outlierfilename == filename and outlierchans[i] == chan and outliersubints[i] == subint and outlierpouts[i] >= 0.10:
            toa.comment(cut="outlier10")
            break
tim.save(EXCISETIMFILE)
nanoutils.plot_multipage_pdf("outlier/J0645+5158.dmx-residuals.pdf")#,height=400)

Clean up the par file

In [7]:
# Ensure correct DMX binning, create PARFILE and TIMFILE
! ../../util/./dmx_fixer.py J0645+5158.excise.par J0645+5158.excise.tim excise
# Center the EPOCHs
! $TEMPO/util/center_epoch/center_epoch.py J0645+5158.excise.par J0645+5158.excise.tim J0645+5158.excise.par
Processing J0645+5158.excise.par J0645+5158.excise.tim
  read 8096 TOAs, 145 epochs
  running tempo for DMX
  solar-DM ranges:
  low-BW ranges:
  writing 8096 TOAs, 145 epochs
  Starting final tempo run (GLS)
 TEMPO v 13.000 Princeton/ATNF Pulsar Collaboration
 Data from J0645+5158.excise.tim,   Input parameters from J0645+5158.excise.par                                                                                                                                           

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

      1 55704.04401513   0.000000          0.000            1
     11 55704.04401516   0.000916          8.110            1
     21 55704.04401518   0.000585          5.183            1
     31 55704.04401521  -0.000074         -0.654            1
     41 55826.68707768   0.003693         32.699            1
     51 55826.68707772   0.000855          7.566            1
     61 55826.68707776   0.000320          2.829            1
     71 55828.68182711   0.000459          4.066            1
     81 55828.68182713   0.000381          3.373            1
     91 55828.68182715   0.000247          2.187            1
    101 55828.68182717   0.000432          3.821            1
    111 55828.68182719   0.000504          4.461            1
    121 55864.58351506   0.000219          1.943            1
    131 55864.58351512   0.000910          8.059            1
    141 55864.58351515  -0.000004         -0.034            1
    151 55865.58063405  -0.000551         -4.877            1
    161 55892.50687250  -0.000569         -5.041            1
    171 55892.50687252  -0.000003         -0.029            1
    181 55892.50687255   0.001302         11.527            1
    191 55893.50430364   0.001002          8.868            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

    201 55893.50430367   0.000474          4.196            1
    301 55919.43331403   0.000395          3.500            1
    401 55972.12953505   0.000834          7.383            1
    501 55972.27987201   0.000534          4.731            1
    601 56000.10828493   0.000344          3.047            1
    701 56034.01536457   0.000454          4.016            1
    801 56065.83801370   0.000043          0.378            1
    901 56130.67682263   0.000659          5.838            1
   1001 56151.60743737   0.000479          4.243            1
   1101 56192.41207474  -0.000793         -7.019            1
   1201 56208.49780269   0.000659          5.835            1
   1301 56229.31702800   0.000758          6.710            1
   1401 56266.24410380   0.000104          0.925            1
   1501 56268.25969688   0.000768          6.796            1
   1601 56312.08945261   0.000490          4.340            1
   1701 56331.16290577   0.001103          9.765            1
   1801 56332.09908909   0.001081          9.572            1
   1901 56351.01894025   0.000704          6.233            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   2001 56386.88884108   0.000416          3.686            1
   2101 56411.85934175   0.001383         12.246            1
   2201 56451.77669848   0.000938          8.304            1
   2301 56472.70385605   0.000051          0.453            1
   2401 56494.57709805   0.000824          7.299            1
   2501 56520.61881248   0.000343          3.033            1
   2601 56550.50469667   0.000313          2.773            1
   2701 56585.38167063   0.000513          4.542            1
   2801 56586.40102252   0.000360          3.183            1
   2901 56613.37782538   0.001144         10.126            1
   3001 56614.30646670   0.000519          4.598            1
   3101 56641.22430262   0.000370          3.274            1
   3201 56671.22191843   0.000477          4.219            1
   3301 56671.23348387   0.000499          4.418            1
   3401 56726.75438700   0.000541          4.790            1
   3501 56726.78820670   0.000037          0.325            1
   3601 56726.85613041  -0.000360         -3.186            1
   3701 56726.91945631   0.000089          0.790            1
   3801 56729.05649975   0.000289          2.562            1
   3901 56736.93761061  -0.000274         -2.425            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   4001 56736.97207531   0.000550          4.868            1
   4101 56763.90048946   0.000432          3.827            1
   4201 56791.88231999   0.000513          4.539            1
   4301 56823.76807790   0.000672          5.954            1
   4401 56849.70283911   0.002375         21.025            1
   4501 56921.55666486   0.001083          9.588            1
   4601 56943.44386591   0.000766          6.786            1
   4701 56978.29671849   0.000411          3.636            1
   4801 56979.32955162   0.000392          3.470            1
   4901 57035.25424496   0.000193          1.711            1
   5001 57036.17720510   0.000423          3.742            1
   5101 57072.06946840   0.000400          3.538            1
   5201 57104.04512768   0.000628          5.563            1
   5301 57130.97492890   0.000279          2.468            1
   5401 57193.80551127   0.000668          5.918            1
   5501 57194.72467274   0.000602          5.330            1
   5601 57221.66094881  -0.000070         -0.621            1
   5701 57248.81299795   0.000648          5.735            1
   5801 57272.40796019   0.000364          3.222            1
   5901 57273.42265151   0.000271          2.396            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   6001 57300.56463974   0.000488          4.324            1
   6101 57335.47860127   0.000837          7.411            1
   6201 57364.63727692   0.000663          5.868            1
   6301 57431.45858397   0.000363          3.209            1
   6401 57457.89557683   0.000623          5.518            1
   6501 57489.33499766   0.000279          2.469            1
   6601 57490.05487842   0.000856          7.579            1
   6701 57522.08594099   0.000582          5.151            1
   6801 57550.91707440   0.000369          3.267            1
   6901 57614.88610739  -0.000060         -0.531            1
   7001 57672.29256884   0.000369          3.271            1
   7101 57673.29397608   0.000541          4.790            1
   7201 57701.28382261   0.000610          5.400            1
   7301 57729.49638134   0.000102          0.902            1
   7401 57730.47071014   0.000359          3.181            1
   7501 57764.51245557   0.000267          2.363            1
   7601 57765.29420163   0.001234         10.928            1
   7701 57830.00285481  -0.000142         -1.254            1
   7801 57857.01210160   0.000819          7.251            1
   7901 57857.13785366   0.001054          9.330            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   8001 57914.04661243   0.000822          7.279            1
   8096 57914.05744033   0.000258          2.280            1

 Weighted RMS residual: pre-fit     0.803 us. Predicted post-fit     0.803 us.
 Chisqr/nfree:   7962.91/ 8006 =     0.994617963   pre/post:   1.00   Wmax:   77.4
 TEMPO v 13.000 Princeton/ATNF Pulsar Collaboration
 Data from J0645+5158.excise.tim,   Input parameters from _tmp.par_                                                                                                                                                       

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

      1 55704.04401513**************************            1
     11 55704.04401516**************************            1
     21 55704.04401518**************************            1
     31 55704.04401521**************************            1
     41 55826.68707768**************************            1
     51 55826.68707772**************************            1
     61 55826.68707776**************************            1
     71 55828.68182711**************************            1
     81 55828.68182713**************************            1
     91 55828.68182715**************************            1
    101 55828.68182717**************************            1
    111 55828.68182719**************************            1
    121 55864.58351506**************************            1
    131 55864.58351512**************************            1
    141 55864.58351515**************************            1
    151 55865.58063405**************************            1
    161 55892.50687250**************************            1
    171 55892.50687252**************************            1
    181 55892.50687255**************************            1
    191 55893.50430364**************************            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

    201 55893.50430367**************************            1
    301 55919.43331403**************************            1
    401 55972.12953505**************************            1
    501 55972.27987201**************************            1
    601 56000.10828493**************************            1
    701 56034.01536457**************************            1
    801 56065.83801370**************************            1
    901 56130.67682263**************************            1
   1001 56151.60743737**************************            1
   1101 56192.41207474**************************            1
   1201 56208.49780269**************************            1
   1301 56229.31702800**************************            1
   1401 56266.24410380**************************            1
   1501 56268.25969688**************************            1
   1601 56312.08945261**************************            1
   1701 56331.16290577**************************            1
   1801 56332.09908909**************************            1
   1901 56351.01894025**************************            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   2001 56386.88884108**************************            1
   2101 56411.85934175**************************            1
   2201 56451.77669848**************************            1
   2301 56472.70385605**************************            1
   2401 56494.57709805**************************            1
   2501 56520.61881248**************************            1
   2601 56550.50469667**************************            1
   2701 56585.38167063**************************            1
   2801 56586.40102252**************************            1
   2901 56613.37782538**************************            1
   3001 56614.30646670**************************            1
   3101 56641.22430262**************************            1
   3201 56671.22191843**************************            1
   3301 56671.23348387**************************            1
   3401 56726.75438700**************************            1
   3501 56726.78820670**************************            1
   3601 56726.85613041**************************            1
   3701 56726.91945631**************************            1
   3801 56729.05649975**************************            1
   3901 56736.93761061**************************            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   4001 56736.97207531**************************            1
   4101 56763.90048946**************************            1
   4201 56791.88231999**************************            1
   4301 56823.76807790**************************            1
   4401 56849.70283911**************************            1
   4501 56921.55666486**************************            1
   4601 56943.44386591**************************            1
   4701 56978.29671849**************************            1
   4801 56979.32955162**************************            1
   4901 57035.25424496**************************            1
   5001 57036.17720510**************************            1
   5101 57072.06946840**************************            1
   5201 57104.04512768**************************            1
   5301 57130.97492890**************************            1
   5401 57193.80551127**************************            1
   5501 57194.72467274**************************            1
   5601 57221.66094881**************************            1
   5701 57248.81299795**************************            1
   5801 57272.40796019**************************            1
   5901 57273.42265151**************************            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   6001 57300.56463974**************************            1
   6101 57335.47860127**************************            1
   6201 57364.63727692**************************            1
   6301 57431.45858397**************************            1
   6401 57457.89557683**************************            1
   6501 57489.33499766**************************            1
   6601 57490.05487842**************************            1
   6701 57522.08594099**************************            1
   6801 57550.91707440**************************            1
   6901 57614.88610739**************************            1
   7001 57672.29256884**************************            1
   7101 57673.29397608**************************            1
   7201 57701.28382261**************************            1
   7301 57729.49638134**************************            1
   7401 57730.47071014**************************            1
   7501 57764.51245557**************************            1
   7601 57765.29420163**************************            1
   7701 57830.00285481**************************            1
   7801 57857.01210160**************************            1
   7901 57857.13785366**************************            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   8001 57914.04661243**************************            1
   8096 57914.05744033**************************            1

 Weighted RMS residual: pre-fit       NaN us. Predicted post-fit     0.803 us.
 Chisqr/nfree:   7968.09/ 8006 =     0.995265364   pre/post:    NaN   Wmax:   77.4
 TEMPO v 13.000 Princeton/ATNF Pulsar Collaboration
 Data from J0645+5158.excise.tim,   Input parameters from J0645+5158.par                                                                                                                                                  

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

      1 55704.04401513   0.000000          0.000            1
     11 55704.04401516   0.000916          8.112            1
     21 55704.04401518   0.000585          5.182            1
     31 55704.04401521  -0.000074         -0.653            1
     41 55826.68707768   0.003692         32.687            1
     51 55826.68707772   0.000853          7.554            1
     61 55826.68707776   0.000318          2.817            1
     71 55828.68182711   0.000459          4.062            1
     81 55828.68182713   0.000381          3.372            1
     91 55828.68182715   0.000246          2.181            1
    101 55828.68182717   0.000431          3.819            1
    111 55828.68182719   0.000504          4.458            1
    121 55864.58351506   0.000219          1.942            1
    131 55864.58351512   0.000910          8.060            1
    141 55864.58351515  -0.000004         -0.034            1
    151 55865.58063405  -0.000551         -4.882            1
    161 55892.50687250  -0.000570         -5.044            1
    171 55892.50687252  -0.000004         -0.033            1
    181 55892.50687255   0.001302         11.523            1
    191 55893.50430364   0.001002          8.871            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

    201 55893.50430367   0.000474          4.199            1
    301 55919.43331403   0.000396          3.509            1
    401 55972.12953505   0.000833          7.376            1
    501 55972.27987201   0.000533          4.723            1
    601 56000.10828493   0.000343          3.040            1
    701 56034.01536457   0.000452          4.006            1
    801 56065.83801370   0.000043          0.377            1
    901 56130.67682263   0.000659          5.835            1
   1001 56151.60743737   0.000479          4.238            1
   1101 56192.41207474  -0.000793         -7.024            1
   1201 56208.49780269   0.000659          5.832            1
   1301 56229.31702800   0.000758          6.708            1
   1401 56266.24410380   0.000104          0.924            1
   1501 56268.25969688   0.000768          6.795            1
   1601 56312.08945261   0.000490          4.338            1
   1701 56331.16290577   0.001103          9.766            1
   1801 56332.09908909   0.001081          9.570            1
   1901 56351.01894025   0.000704          6.231            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   2001 56386.88884108   0.000416          3.682            1
   2101 56411.85934175   0.001382         12.237            1
   2201 56451.77669848   0.000938          8.304            1
   2301 56472.70385605   0.000051          0.454            1
   2401 56494.57709805   0.000824          7.294            1
   2501 56520.61881248   0.000342          3.027            1
   2601 56550.50469667   0.000313          2.770            1
   2701 56585.38167063   0.000513          4.543            1
   2801 56586.40102252   0.000359          3.181            1
   2901 56613.37782538   0.001144         10.126            1
   3001 56614.30646670   0.000519          4.597            1
   3101 56641.22430262   0.000369          3.271            1
   3201 56671.22191843   0.000476          4.215            1
   3301 56671.23348387   0.000498          4.412            1
   3401 56726.75438700   0.000540          4.785            1
   3501 56726.78820670   0.000036          0.320            1
   3601 56726.85613041  -0.000360         -3.189            1
   3701 56726.91945631   0.000089          0.787            1
   3801 56729.05649975   0.000289          2.559            1
   3901 56736.93761061  -0.000274         -2.429            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   4001 56736.97207531   0.000549          4.862            1
   4101 56763.90048946   0.000432          3.823            1
   4201 56791.88231999   0.000512          4.535            1
   4301 56823.76807790   0.000672          5.954            1
   4401 56849.70283911   0.002374         21.020            1
   4501 56921.55666486   0.001082          9.583            1
   4601 56943.44386591   0.000766          6.783            1
   4701 56978.29671849   0.000410          3.633            1
   4801 56979.32955162   0.000391          3.460            1
   4901 57035.25424496   0.000193          1.711            1
   5001 57036.17720510   0.000424          3.753            1
   5101 57072.06946840   0.000400          3.541            1
   5201 57104.04512768   0.000628          5.559            1
   5301 57130.97492890   0.000278          2.461            1
   5401 57193.80551127   0.000668          5.911            1
   5501 57194.72467274   0.000601          5.323            1
   5601 57221.66094881  -0.000071         -0.625            1
   5701 57248.81299795   0.000647          5.730            1
   5801 57272.40796019   0.000364          3.219            1
   5901 57273.42265151   0.000270          2.391            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   6001 57300.56463974   0.000487          4.316            1
   6101 57335.47860127   0.000836          7.397            1
   6201 57364.63727692   0.000661          5.856            1
   6301 57431.45858397   0.000362          3.201            1
   6401 57457.89557683   0.000622          5.511            1
   6501 57489.33499766   0.000279          2.468            1
   6601 57490.05487842   0.000856          7.579            1
   6701 57522.08594099   0.000581          5.145            1
   6801 57550.91707440   0.000368          3.260            1
   6901 57614.88610739  -0.000061         -0.539            1
   7001 57672.29256884   0.000369          3.263            1
   7101 57673.29397608   0.000540          4.782            1
   7201 57701.28382261   0.000609          5.389            1
   7301 57729.49638134   0.000101          0.890            1
   7401 57730.47071014   0.000359          3.174            1
   7501 57764.51245557   0.000267          2.360            1
   7601 57765.29420163   0.001233         10.915            1
   7701 57830.00285481  -0.000143         -1.262            1
   7801 57857.01210160   0.000818          7.239            1
   7901 57857.13785366   0.001052          9.311            1

    N       MJD       Residual (p)  Residual (us)  Iteration (of 1)

   8001 57914.04661243   0.000821          7.269            1
   8096 57914.05744033   0.000256          2.270            1

 Weighted RMS residual: pre-fit     0.803 us. Predicted post-fit     0.803 us.
 Chisqr/nfree:   7962.91/ 8006 =     0.994617303   pre/post:   1.00   Wmax:   77.4
In [8]:
# Noise parameter addition from outlier analysis
with open("outlier/J0645+5158.dmx-noise.txt",'r') as FILE:
    outlierlines = FILE.readlines()
with open(EXCISEPARFILE,'r') as FILE:
    lines = FILE.readlines()
    
output = ""
for line in lines:
    if "EFAC" in line or "EQUAD" in line or "ECORR" in line or "RNAMP" in line or "RNIDX" in line: #remove these parameters
        continue
    output += line
    
rnoutput = ""
for line in outlierlines: #add these parameters
    if "efac" in line:
        output += line.replace("efac-","T2EFAC -f ")
    elif "equad" in line:
        value = 10**(float(line.split()[-1].strip()))
        string = line.replace("equad-","T2EQUAD -f ")
        output += "%s %0.5f\n"%(" ".join(string.split()[:-1]),value)
    elif "jitter" in line:
        value = 10**(float(line.split()[-1]))
        string = line.replace("jitter-","ECORR -f ")
        output += "%s %0.5f\n"%(" ".join(string.split()[:-1]),value)
    elif "RN-Amplitude" in line:
        value = float(line.split()[1])
        RNAMP = tempoutils.convert_to_RNAMP(value)
        RNAMP = str("%0.4e"%RNAMP).replace('e','D')
        rnoutput += "RNAMP %s\n"%RNAMP
    elif "RN-spectral-index" in line:
        gamma = float(line.split()[1])
        rnoutput += "RNIDX %0.4f\n"%(-gamma)
if not (gamma < 1.0):
    output += rnoutput
    
with open(EXCISEPARFILE,'w') as FILE:
    FILE.write(output)
In [9]:
# Copy excise files to working files
call("cp %s %s"%(EXCISEPARFILE,PARFILE))
call("cp %s %s"%(EXCISETIMFILE,TIMFILE))

Run finalize_timing.py

In [10]:
! ../../util/./finalize_timing.py -G J0645+5158.working.par J0645+5158.working.tim
Testing: J0645+5158.working.par J0645+5158.working.tim
Using GLS fitting.
Testing par and tim file for errors:
    no errors found!

No bad DMX ranges found!
Making summary plots.
../../util/./finalize_timing.py:510: MatplotlibDeprecationWarning: pyplot.hold is deprecated.
    Future behavior will be consistent with the long-time default:
    plot commands add elements without first clearing the
    Axes and/or Figure.
  pylab.hold(True)
/opt/conda/envs/python2/lib/python2.7/site-packages/matplotlib/__init__.py:917: UserWarning: axes.hold is deprecated. Please remove it from your matplotlibrc and/or style files.
  warnings.warn(self.msg_depr_set % key)
/opt/conda/envs/python2/lib/python2.7/site-packages/matplotlib/rcsetup.py:152: UserWarning: axes.hold is deprecated, will be removed in 3.0
  warnings.warn("axes.hold is deprecated, will be removed in 3.0")
../../util/./finalize_timing.py:683: MatplotlibDeprecationWarning: pyplot.hold is deprecated.
    Future behavior will be consistent with the long-time default:
    plot commands add elements without first clearing the
    Axes and/or Figure.
  pylab.hold(True)
Testing additional parameters (*** = significant):
                                           RMS(us)      Chi2  NDOF Ftest
                                   initial   0.560   8922.82  8006 --
Testing removal of parameters:
                                   ('PX',)   0.561   8950.54  8007 6.26e-07 ***
Testing spin freq derivs
                                    ['F2']   0.560   8922.44  8005 0.559
Testing FD terms ( ['FD1', 'FD2'] enabled):
                         no FD  0.803  18336.96  8008
                                     no FD   0.803  18336.96  8008 --
                           FD1 through FD1   0.563   9004.09  8007 1.11e-16 ***
                           FD1 through FD2   0.560   8922.82  8006 1.11e-16 ***
                           FD1 through FD3   0.560   8912.60  8005 0.00246 ***
                           FD1 through FD4   0.560   8912.33  8004 0.622
                           FD1 through FD5   0.560   8912.24  8003 0.776
                           FD1 through FD6   0.560   8908.09  8002 0.0535
In [11]:
nanoutils.plot_multipage_pdf("J0645+5158.summary.pdf")

Setup noise model directory

In [12]:
NOISEDIR = "noisemodel/"
CHAINSDIR = "noisemodel/chains/J0645+5158/"
call("mkdir %s"%NOISEDIR)
call("mkdir noise_output")
#call("mkdir %s"%CHAINSDIR)
call("cp %s %s%s"%(TIMFILE,NOISEDIR,TIMFILE))
call("cp %s %s%s"%(PARFILE,NOISEDIR,PARFILE))
mkdir: cannot create directory ‘noisemodel/’: File exists

mkdir: cannot create directory ‘noise_output’: File exists

Edit par files to remove noise model terms

In [13]:
with open("%s%s"%(NOISEDIR,PARFILE),'r') as FILE:
    lines = FILE.readlines()
output = ""
for line in lines:
    write = True
    for param in ["T2EFAC","T2EQUAD","ECORR","RNAMP","RNIDX"]:
        if param in line:
            write = False
            continue
    if write:
        output += line
with open("%s%s"%(NOISEDIR,PARFILE),'w') as FILE:
    FILE.write(output)

Run noise analysis using ENTERPRISE (currently only supporting tempo)

In [14]:
enterpriseutils.setup_model(NOISEDIR+PARFILE,NOISEDIR+TIMFILE)
WARNING: Could not find pulsar distance for PSR J0645+5158. Setting value to 1 with 20% uncertainty.
In [15]:
enterpriseutils.setup_sampler(CHAINSDIR)
/home/jovyan/work/shared/nanograv_utils.py:404: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  ipars = np.array([p for p in pars if p not in gpars])
/home/jovyan/work/shared/nanograv_utils.py:421: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  ind = [params.index(p) for p in signal.param_names if p not in gpars]
In [16]:
enterpriseutils.run_sampler(N=NITER)
Finished 20.00 percent in 568.798471 s Acceptance rate = 0.3584Adding DE jump with weight 50
Finished 98.00 percent in 2711.938137 s Acceptance rate = 0.399816
Run Complete
In [17]:
enterpriseutils.process_noise('%s/chain_1.txt'%CHAINSDIR,"noise_output/t1_noise.txt") #need to add in T2 noise!
In [18]:
enterpriseutils.plot_corner('%s/chain_1.txt'%CHAINSDIR)

Copy the noise parameters into the par file

In [19]:
# No need to comment out low-spectral-index red noise as this is taken care of in EnterpriseUtils.process_noise() now
with open("noise_output/t1_noise.txt",'r') as FILE:
    noiselines = FILE.readlines()
with open("%s%s"%(NOISEDIR,PARFILE),'r') as FILE: #read in the noisemodel version
    lines = FILE.readlines()
output = ""
for line in lines:
    if "JUMP" in line:
        for noiseline in noiselines:
            output += noiseline
    output += line
with open("%s"%PARFILE,'w') as FILE: #write out to the main version
    FILE.write(output)

Re-run tempo with noise model

In [20]:
tempoutils.tempo(PARFILE,TIMFILE,G=True,c=True)
call("mv J0645+5158.par %s"%PARFILE)

Re-run finalize_timing.py

In [21]:
! ../../util/./finalize_timing.py -G J0645+5158.working.par J0645+5158.working.tim
Testing: J0645+5158.working.par J0645+5158.working.tim
Using GLS fitting.
Testing par and tim file for errors:
    no errors found!

No bad DMX ranges found!
Making summary plots.
../../util/./finalize_timing.py:510: MatplotlibDeprecationWarning: pyplot.hold is deprecated.
    Future behavior will be consistent with the long-time default:
    plot commands add elements without first clearing the
    Axes and/or Figure.
  pylab.hold(True)
/opt/conda/envs/python2/lib/python2.7/site-packages/matplotlib/__init__.py:917: UserWarning: axes.hold is deprecated. Please remove it from your matplotlibrc and/or style files.
  warnings.warn(self.msg_depr_set % key)
/opt/conda/envs/python2/lib/python2.7/site-packages/matplotlib/rcsetup.py:152: UserWarning: axes.hold is deprecated, will be removed in 3.0
  warnings.warn("axes.hold is deprecated, will be removed in 3.0")
../../util/./finalize_timing.py:683: MatplotlibDeprecationWarning: pyplot.hold is deprecated.
    Future behavior will be consistent with the long-time default:
    plot commands add elements without first clearing the
    Axes and/or Figure.
  pylab.hold(True)
Testing additional parameters (*** = significant):
                                           RMS(us)      Chi2  NDOF Ftest
                                   initial   0.794   8014.86  8006 --
Testing removal of parameters:
                                   ('PX',)   0.795   8036.71  8007 3.03e-06 ***
Testing spin freq derivs
                                    ['F2']   0.794   8014.41  8005 0.503
Testing FD terms ( ['FD1', 'FD2'] enabled):
                         no FD  1.145  16046.93  8008
                                     no FD   1.145  16046.93  8008 --
                           FD1 through FD1   0.796   8047.47  8007 1.11e-16 ***
                           FD1 through FD2   0.794   8014.86  8006 1.19e-08 ***
                           FD1 through FD3   0.794   8013.58  8005 0.258
                           FD1 through FD4   0.794   8013.57  8004 0.92
                           FD1 through FD5   0.794   8013.01  8003 0.455
                           FD1 through FD6   0.794   8007.77  8002 0.0221
In [22]:
nanoutils.plot_multipage_pdf("J0645+5158.summary.pdf")

Push to git

In [23]:
!git add J0645+5158.working.par J0645+5158.working.tim process.ipynb
!git commit -m "J0645+5158 run" J0645+5158.working.par J0645+5158.working.tim process.ipynb    
!git pull
!git push
[master 713f737] J0645+5158 run
 2 files changed, 179 insertions(+), 179 deletions(-)
Already up-to-date.
Counting objects: 6, done.
Delta compression using up to 40 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 2.37 KiB | 0 bytes/s, done.
Total 6 (delta 5), reused 0 (delta 0)
To workspace@git.nanograv.org:timing/nanograv_timing_2017
   5c1cc01..713f737  master -> master