Lv2_bestprof2par.py
def bestprof2par(bestprof,parfile):
    """
    Converts the .bestprof text file into a .par file

    bestprof - path to the bestprof file
    parfile - path to the parfile
    """
    contents = open(bestprof,'r').read().split('\n')

    for line in contents:
        if line.startswith('# Epoch_bary'):
            pepoch = float(line.split()[4])
        if line.startswith('# P_bary'):
            p0 = float(line.split()[4])/1000.0
        if line.startswith("# P'_bary"):
            p1 = float(line.split()[4])
        if line.startswith("# P''_bary"):
            p2 = float(line.split()[4])

    f0 = 1/p0
    f1 = -p1/p0**2
    f2 = (2*p1**2-p0*p2)/p0**3

    par_write = open(parfile,'w')
    par_write.write("PEPOCH " + str(pepoch) + '\n')
    par_write.write("F0 " + repr(f0) + " 1" + '\n')
    par_write.write("F1 " + repr(f1) + " 1" + '\n')
    par_write.write("F2 " + repr(f2))

    par_write.close()

    return

    Converts the .bestprof text file into a .par file

    bestprof - path to the bestprof file
    parfile - path to the parfile
    
Converts the .bestprof text file into a .par file
bestprof - path to the bestprof file
parfile - path to the parfile
Converts the . bestprof text file into a . par file bestprof - path to the bestprof file parfile - path to the parfile
def bestprof2par(bestprof,parfile):
    contents = open(bestprof,'r').read().split('\n')
    for line in contents:
        if line.startswith('# Epoch_bary'):
            pepoch = float(line.split()[4])
        if line.startswith('# P_bary'):
            p0 = float(line.split()[4])/1000.0
        if line.startswith("# P'_bary"):
            p1 = float(line.split()[4])
        if line.startswith("# P''_bary"):
            p2 = float(line.split()[4])
    f0 = 1/p0
    f1 = -p1/p0**2
    f2 = (2*p1**2-p0*p2)/p0**3
    par_write = open(parfile,'w')
    par_write.write("PEPOCH " + str(pepoch) + '\n')
    par_write.write("F0 " + repr(f0) + " 1" + '\n')
    par_write.write("F1 " + repr(f1) + " 1" + '\n')
    par_write.write("F2 " + repr(f2))
    par_write.close()
    return
def bestprof2par ( bestprof , parfile ) : contents = open ( bestprof , 'r' ) . read ( ) . split ( '\n' ) for line in contents : if line . startswith ( '# Epoch_bary' ) : pepoch = float ( line . split ( ) [ 4 ] ) if line . startswith ( '# P_bary' ) : p0 = float ( line . split ( ) [ 4 ] ) / 1000.0 if line . startswith ( "# P'_bary" ) : p1 = float ( line . split ( ) [ 4 ] ) if line . startswith ( "# P''_bary" ) : p2 = float ( line . split ( ) [ 4 ] ) f0 = 1 / p0 f1 = - p1 / p0 ** 2 f2 = ( 2 * p1 ** 2 - p0 * p2 ) / p0 ** 3 par_write = open ( parfile , 'w' ) par_write . write ( "PEPOCH " + str ( pepoch ) + '\n' ) par_write . write ( "F0 " + repr ( f0 ) + " 1" + '\n' ) par_write . write ( "F1 " + repr ( f1 ) + " 1" + '\n' ) par_write . write ( "F2 " + repr ( f2 ) ) par_write . close ( ) return
Converts the .bestprof text file into a .par file
bestprof - path to the bestprof file
parfile - path to the parfile
Converts the . bestprof text file into a . par file bestprof - path to the bestprof file parfile - path to the parfile
"""
    Converts the .bestprof text file into a .par file

    bestprof - path to the bestprof file
    parfile - path to the parfile
    """
bestprof
parfile