Beispiel #1
0
def estimate_rz(psr, T, show=0, device='/XWIN'):
    """
    estimate_rz(psr, T, show=0, device='/XWIN'):
        Return estimates of a pulsar's average Fourier freq ('r')
        relative to its nominal Fourier freq as well as its
        Fourier f-dot ('z') in bins, of a pulsar.
           'psr' is a psrparams structure describing the pulsar.
           'T' is the length of the observation in sec.
           'show' if true, displays plots of 'r' and 'z'.
           'device' if the device to plot to if 'show' is true.
    """
    startE = keplers_eqn(psr.orb.t, psr.orb.p, psr.orb.e, 1.0E-15)
    numorbpts = int(T / psr.orb.p + 1.0) * 1024 + 1
    dt = T / (numorbpts - 1)
    E = dorbint(startE, numorbpts, dt, psr.orb)
    z = z_from_e(E, psr, T)
    r = T / p_from_e(E, psr) - T / psr.p
    if show:
        times = np.arange(numorbpts) * dt
        Pgplot.plotxy(r, times, labx='Time', \
                      laby='Fourier Frequency (r)', device=device)
        if device == '/XWIN':
            print('Press enter to continue:')
            try:
                i = raw_input()
            except NameError:
                i = input()
        Pgplot.nextplotpage()
        Pgplot.plotxy(z,
                      times,
                      labx='Time',
                      laby='Fourier Frequency Derivative (z)',
                      device=device)
        Pgplot.closeplot()
    return r.mean(), z.mean()
Beispiel #2
0
        shapiro_measurable(R, S, MJD):
            Return the predicted _measurable_ Shapiro delay (in us) for a
                variety of barycentric MJDs, given the R and S parameters.  
                This is eqn 28 in Freire & Wex 2010 and is only valid in 
                the low eccentricity limit.
        """
        ma, ea, ta = self.calc_anoms(MJD)
        ws = self.calc_omega(MJD)
        Phi = ma + ws
        cbar = Num.sqrt(1.0 - S**2.0)
        zeta = S / (1.0 + cbar)
        h3 = R * zeta**3.0
        sPhi = Num.sin(Phi)
        delay = -2.0e6 * h3 * (
            Num.log(1.0 + zeta * zeta - 2.0 * zeta * sPhi) / zeta**3.0 +
            2.0 * sPhi / zeta**2.0 - Num.cos(2.0 * Phi) / zeta)
        return delay


if __name__ == '__main__':
    import presto.Pgplot as pg

    # The following reproduces the RV plot in Hulse & Taylor, 1975
    psrA = binary_psr("B1913+16.par")
    T0 = 42320.933  # From Hulse & Taylor, 1975
    times = psr_utils.span(0.0, psrA.par.PB, 1000) + T0
    rv = psrA.radial_velocity(times)
    pg.plotxy(rv, (times-T0)*24, \
        labx="Hours since Periastron", laby="Radial Velocity (km.s)")
    pg.closeplot()
Beispiel #3
0
    template -= min(template)
    template /= max(template)
    # Rotate it so that it becomes a "true" template according to FFTFIT
    shift, eshift, snr, esnr, b, errb, ngood = measure_phase(
        template, template)
    template = psr_utils.fft_rotate(template, shift)

    # Determine the off-pulse bins
    if bkgd_vals is not None:
        Pgplot.plotxy(template, labx="Phase bins")
        Pgplot.plotxy(template[bkgd_vals],
                      Num.arange(numbins)[bkgd_vals],
                      line=None,
                      symbol=2,
                      color='red')
        Pgplot.closeplot()
        offpulse_inds = bkgd_vals
        onpulse_inds = set(Num.arange(numbins)) - set(bkgd_vals)
    else:
        offpulse_inds = Num.compress(template <= bkgd_cutoff,
                                     Num.arange(numbins))
        onpulse_inds = Num.compress(template > bkgd_cutoff,
                                    Num.arange(numbins))
        Pgplot.plotxy(template)
        Pgplot.plotxy([bkgd_cutoff, bkgd_cutoff], [0.0, numbins], color='red')
        Pgplot.closeplot()
    # If the number of bins in the offpulse section is < 10% of the total
    # use the statistics in the .pfd file to set the RMS
    if (len(offpulse_inds) < 0.1 * numbins):
        print(
            "Number of off-pulse bins to use for RMS is too low.  Using .pfd stats."