示例#1
0
def bary_to_topo(pb, pbd, pbdd, infofilenm, ephem="DE200"):
    """
    bary_to_topo(pb, pbd, pbdd, infofilenm, ephem="DE200"):
       Use least squares to calculate topocentric period
       period derivative, and period second derivative
       for the corresponding barycentric values.  The data
       for the observation must be found in the info file.
    """
    from numpy.linalg.old import linear_least_squares
    if infofilenm[-4:] == ".inf": infofilenm = infofilenm[:-4]
    obs = read_inffile(infofilenm)
    T = obs.N * obs.dt
    dt = 10.0
    tto = obs.mjd_i + obs.mjd_f
    tts = np.arange(tto, tto + (T + dt) / SECPERDAY, dt / SECPERDAY)
    nn = len(tts)
    bts = np.zeros(nn, 'd')
    vel = np.zeros(nn, 'd')
    ra = psr_utils.coord_to_string(obs.ra_h, obs.ra_m, obs.ra_s)
    dec = psr_utils.coord_to_string(obs.dec_d, obs.dec_m, obs.dec_s)
    if (obs.telescope == 'Parkes'):
        tel = 'PK'
    elif (obs.telescope == 'Effelsberg'):
        tel = 'EB'
    elif (obs.telescope == 'Arecibo'):
        tel = 'AO'
    elif (obs.telescope == 'MMT'):
        tel = 'MT'
    else:
        print("Telescope not recognized.")
        return 0
    barycenter(tts, bts, vel, nn, ra, dec, tel, ephem)
    print("Topocentric start time = %17.11f" % tts[0])
    print("Barycentric start time = %17.11f" % bts[0])
    avgvel = np.add.reduce(vel) / nn
    print("Average Earth velocity = %10.5e c" % (avgvel))
    tts = np.arange(nn, dtype='d') * dt
    bts = (bts - bts[0]) * SECPERDAY
    [fb, fbd, fbdd] = p_to_f(pb, pbd, pbdd)
    b = fb * bts + fbd * bts**2.0 / 2.0 + fbdd * bts**3.0 / 6.0
    a = np.transpose(np.asarray([tts, tts**2.0, tts**3.0]))
    [ft, ftd, ftdd], residuals, rank, sv = linear_least_squares(a, b)
    [pt, ptd, ptdd] = p_to_f(ft, ftd, ftdd)
    print("    Topocentric period = %15.12f" % pt)
    print("     Topocentric p-dot = %15.9e" % ptd)
    print("  Topocentric p-dotdot = %15.9e" % ptdd)
    print("     Quick Topo period = %15.12f" % (pb * (1.0 + avgvel)))
    print("      Quick Topo p-dot = %15.9e" % (pbd * (1.0 + avgvel)))
    print("   Quick Topo p-dotdot = %15.9e" % (pbdd * (1.0 + avgvel)))
    return [pt, ptd, ptdd]
示例#2
0
def bary_to_topo(pb, pbd, pbdd, infofilenm, ephem="DE200"):
   """
   bary_to_topo(pb, pbd, pbdd, infofilenm, ephem="DE200"):
      Use least squares to calculate topocentric period
      period derivative, and period second derivative
      for the corresponding barycentric values.  The data
      for the observation must be found in the info file.
   """
   from numpy.linalg.old import linear_least_squares
   if infofilenm[-4:]==".inf":  infofilenm = infofilenm[:-4]
   obs = read_inffile(infofilenm)
   T = obs.N * obs.dt
   dt = 10.0
   tto = obs.mjd_i + obs.mjd_f
   tts = np.arange(tto, tto + (T + dt) / SECPERDAY, dt / SECPERDAY)
   nn = len(tts)
   bts = np.zeros(nn, 'd')
   vel = np.zeros(nn, 'd')
   ra = psr_utils.coord_to_string(obs.ra_h, obs.ra_m, obs.ra_s)
   dec = psr_utils.coord_to_string(obs.dec_d, obs.dec_m, obs.dec_s)
   if (obs.telescope == 'Parkes'):  tel = 'PK'
   elif (obs.telescope == 'Effelsberg'):  tel = 'EB'
   elif (obs.telescope == 'Arecibo'):  tel = 'AO'
   elif (obs.telescope == 'MMT'):  tel = 'MT'
   else:
      print "Telescope not recognized."
      return 0
   barycenter(tts, bts, vel, nn, ra, dec, tel, ephem)
   print "Topocentric start time = %17.11f" % tts[0]
   print "Barycentric start time = %17.11f" % bts[0]
   avgvel = np.add.reduce(vel) / nn
   print "Average Earth velocity = %10.5e c" % (avgvel)
   tts = np.arange(nn, dtype='d') * dt
   bts = (bts - bts[0]) * SECPERDAY
   [fb, fbd, fbdd] = p_to_f(pb, pbd, pbdd)
   b = fb * bts + fbd * bts**2.0 / 2.0 + fbdd * bts**3.0 / 6.0
   a = np.transpose(np.asarray([tts, tts**2.0, tts**3.0]))
   [ft, ftd, ftdd], residuals, rank, sv = linear_least_squares(a,b)
   [pt, ptd, ptdd] = p_to_f(ft, ftd, ftdd)
   print "    Topocentric period = %15.12f" % pt
   print "     Topocentric p-dot = %15.9e" % ptd
   print "  Topocentric p-dotdot = %15.9e" % ptdd
   print "     Quick Topo period = %15.12f" % (pb * (1.0 + avgvel))
   print "      Quick Topo p-dot = %15.9e" % (pbd * (1.0 + avgvel))
   print "   Quick Topo p-dotdot = %15.9e" % (pbdd * (1.0 + avgvel))
   return [pt, ptd, ptdd]