How to use the presto.Pgplot.plotxy function in presto

To help you get started, we’ve selected a few presto examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github scottransom / presto / python / presto / psr_utils.py View on Github external
Num.fmod(Num.argmax(profile) / float(len(profile)) + 0.5, 1.0),
                              min(profile)], args=(profile))
    if (output):
        phases = Num.arange(0.0, 1.0,
                            1.0 / len(profile)) + 0.5 / len(profile)
        Pgplot.plotxy(profile, phases, rangex=[0.0, 1.0],
                      labx='Pulse Phase', laby='Pulse Intensity')
    bestfit = yfunct(ret[0], len(profile))
    if (output):
        Pgplot.plotxy(bestfit, phases, color='red')
        Pgplot.closeplot()
    residuals = bestfit - profile
    resid_avg = residuals.mean()
    resid_std = residuals.std()
    if (output):
        Pgplot.plotxy(residuals, phases, rangex=[0.0, 1.0],
                      rangey=[min(residuals) - 2 * resid_std,
                              max(residuals) + 2 * resid_std],
                      labx='Pulse Phase', laby='Residuals',
                      line=None, symbol=3)
        ppgplot.pgerrb(6, phases, residuals,
                       Num.zeros(len(residuals), 'd') + \
                       resid_std, 2)
        Pgplot.plotxy([resid_avg, resid_avg], [0.0, 1.0], line=2)
        Pgplot.closeplot()
        print("")
        print("  Best-fit gaussian integrated 'flux'  = ", ret[0][0])
        print("               Best-fit gaussian FWHM  = ", ret[0][1])
        print("    Best-fit gaussian phase (0.0-1.0)  = ", ret[0][2])
        print("  Best-fit gaussian integrated 'flux'  = ", ret[0][3])
        print("               Best-fit gaussian FWHM  = ", ret[0][4])
        print("    Best-fit gaussian phase (0.0-1.0)  = ", ret[0][5])
github scottransom / presto / python / presto / psr_utils.py View on Github external
afpo[3] * gaussian_profile(n, afpo[5], afpo[4]) + afpo[6]

    def min_funct(afpo, profile):
        return yfunct(afpo, len(profile)) - profile

    ret = leastsq(min_funct, [max(profile) - min(profile),
                              0.05,
                              Num.argmax(profile) / float(len(profile)),
                              0.2 * max(profile) - min(profile),
                              0.1,
                              Num.fmod(Num.argmax(profile) / float(len(profile)) + 0.5, 1.0),
                              min(profile)], args=(profile))
    if (output):
        phases = Num.arange(0.0, 1.0,
                            1.0 / len(profile)) + 0.5 / len(profile)
        Pgplot.plotxy(profile, phases, rangex=[0.0, 1.0],
                      labx='Pulse Phase', laby='Pulse Intensity')
    bestfit = yfunct(ret[0], len(profile))
    if (output):
        Pgplot.plotxy(bestfit, phases, color='red')
        Pgplot.closeplot()
    residuals = bestfit - profile
    resid_avg = residuals.mean()
    resid_std = residuals.std()
    if (output):
        Pgplot.plotxy(residuals, phases, rangex=[0.0, 1.0],
                      rangey=[min(residuals) - 2 * resid_std,
                              max(residuals) + 2 * resid_std],
                      labx='Pulse Phase', laby='Residuals',
                      line=None, symbol=3)
        ppgplot.pgerrb(6, phases, residuals,
                       Num.zeros(len(residuals), 'd') + \
github scottransom / presto / python / presto / prepfold.py View on Github external
vars = []
        for sub in range(self.nsub):
            var = 0.0
            if sub in self.killed_subbands:
                vars.append(var)
                continue
            for part in range(self.npart):
                if part in self.killed_intervals:
                    continue
                var += self.stats[part][sub][5] # foldstats prof_var
            vars.append(var)
        chis = Num.zeros(self.nsub, dtype='f')
        for ii in range(self.nsub):
            chis[ii] = self.calc_redchi2(prof=profs[ii], avg=avgs[ii], var=vars[ii])
        # Now plot it
        Pgplot.plotxy(chis, labx="Subband Number", laby=r"Reduced-\gx\u2\d",
                      rangey=[0.0, max(chis)*1.1], device=device)
        return chis
github scottransom / presto / python / presto / psr_utils.py View on Github external
def bins_to_accel(z, T, f=[1.0, 1000.0], device="/XWIN"):
    """
    bins_to_accel(z, T, f=[1.0, 1000.0], device="/XWIN"):
        Make a plot showing the acceleration which corresponds
        to a certain number of Fourier bins drifted 'z' during
        an observation of length 'T'.
    """
    fs = span(Num.log10(f[0]), Num.log10(f[1]), 1000)
    accels = z_to_accel(z, T, 10.0 ** fs)
    if (device):
        Pgplot.plotxy(Num.log10(accels), fs, logx=1, logy=1,
                      labx="Frequency (Hz)",
                      laby=r"Acceleration (m/s\u2\d)", device=device)
        ppgplot.pgmtxt("T", -2.0, 0.75, 0.0, "T = %.0f sec" % T)
        ppgplot.pgmtxt("T", -3.5, 0.75, 0.0, r"r\B\u\.\d = %.1f bins" % z)
        if (device != '/XWIN'):
            Pgplot.closeplot()
    else:
        return accels
github scottransom / presto / python / presto / psr_utils.py View on Github external
if (output):
        Pgplot.plotxy(bestfit, phases, color='red')
        Pgplot.closeplot()
    residuals = bestfit - profile
    resid_avg = residuals.mean()
    resid_std = residuals.std()
    if (output):
        Pgplot.plotxy(residuals, phases, rangex=[0.0, 1.0],
                      rangey=[min(residuals) - 2 * resid_std,
                              max(residuals) + 2 * resid_std],
                      labx='Pulse Phase', laby='Residuals',
                      line=None, symbol=3)
        ppgplot.pgerrb(6, phases, residuals,
                       Num.zeros(len(residuals), 'd') + \
                       resid_std, 2)
        Pgplot.plotxy([resid_avg, resid_avg], [0.0, 1.0], line=2)
        Pgplot.closeplot()
        print("")
        print("  Best-fit gaussian integrated 'flux'  = ", ret[0][0])
        print("               Best-fit gaussian FWHM  = ", ret[0][1])
        print("    Best-fit gaussian phase (0.0-1.0)  = ", ret[0][2])
        print("        Baseline (i.e. noise) average  = ", ret[0][3])
        print("                    Residuals average  = ", resid_avg)
        print("         Residuals standard deviation  = ", resid_std)
        print("")
    return (ret[0][0], ret[0][1], ret[0][2], ret[0][3], resid_avg, resid_std)
github scottransom / presto / python / presto / psr_utils.py View on Github external
return afpo[0] * gaussian_profile(len(profile), afpo[2], afpo[1]) \
               + afpo[3] - profile

    ret = leastsq(funct, [profile.max() - profile.min(),
                          0.25, profile.argmax() / float(len(profile)),
                          profile.min()], args=(profile))
    if (output):
        phases = Num.arange(0.0, 1.0,
                            1.0 / len(profile)) + 0.5 / len(profile)
        Pgplot.plotxy(profile, phases, rangex=[0.0, 1.0],
                      labx='Pulse Phase', laby='Pulse Intensity')
    bestfit = ret[0][0] * gaussian_profile(len(profile),
                                           ret[0][2], ret[0][1]) \
              + ret[0][3]
    if (output):
        Pgplot.plotxy(bestfit, phases, color='red')
        Pgplot.closeplot()
    residuals = bestfit - profile
    resid_avg = residuals.mean()
    resid_std = residuals.std()
    if (output):
        Pgplot.plotxy(residuals, phases, rangex=[0.0, 1.0],
                      rangey=[min(residuals) - 2 * resid_std,
                              max(residuals) + 2 * resid_std],
                      labx='Pulse Phase', laby='Residuals',
                      line=None, symbol=3)
        ppgplot.pgerrb(6, phases, residuals,
                       Num.zeros(len(residuals), 'd') + \
                       resid_std, 2)
        Pgplot.plotxy([resid_avg, resid_avg], [0.0, 1.0], line=2)
        Pgplot.closeplot()
        print("")
github scottransom / presto / python / presto / psr_utils.py View on Github external
ppgplot.pgsch(0.8)
    ppgplot.pgmtxt("t", 1.5, 1.0 / 12.0, 0.5, r"\(2156)\dcenter\u = %gMHz" % freq)
    ppgplot.pgmtxt("t", 1.5, 3.0 / 12.0, 0.5, r"N\dchan\u = %d" % numchan)
    ppgplot.pgmtxt("t", 1.5, 5.0 / 12.0, 0.5, r"N\dsub\u = %d" % numsub)
    ppgplot.pgmtxt("t", 1.5, 7.0 / 12.0, 0.5, r"BW\dchan\u = %gMHz" % chanwidth)
    ppgplot.pgmtxt("t", 1.5, 9.0 / 12.0, 0.5, r"\gDDM = %g" % dmstep)
    ppgplot.pgmtxt("t", 1.5, 11.0 / 12.0, 0.5, r"\gDDM\dsub\u = %g" % subdmstep)
    ppgplot.pgsch(1.0)
    ppgplot.pgmtxt("b", -7.5, 0.95, 1.0, "Total")
    Pgplot.plotxy(Num.log10(dts), ldms, color="green",
                  logx=1, logy=1)
    ppgplot.pgmtxt("b", -6.0, 0.95, 1.0, "Sample Rate")
    Pgplot.plotxy(Num.log10(chan_smear), ldms, color="purple",
                  logx=1, logy=1)
    ppgplot.pgmtxt("b", -4.5, 0.95, 1.0, "Channel")
    Pgplot.plotxy(Num.log10(BW_smear), ldms, color="red",
                  logx=1, logy=1)
    ppgplot.pgmtxt("b", -3.0, 0.95, 1.0, "Full BW")
    Pgplot.plotxy(Num.log10(subband_smear), ldms, color="blue",
                  logx=1, logy=1)
    ppgplot.pgmtxt("b", -1.5, 0.95, 1.0, "Subband")
    ppgplot.pgsci(1)
github scottransom / presto / python / presto / psr_utils.py View on Github external
If 'output' is true, the fit will be plotted and
           the return values will be printed.
    """
    profile = Num.asarray(profile)

    def funct(afpo, profile):
        return afpo[0] * gaussian_profile(len(profile), afpo[2], afpo[1]) \
               + afpo[3] - profile

    ret = leastsq(funct, [profile.max() - profile.min(),
                          0.25, profile.argmax() / float(len(profile)),
                          profile.min()], args=(profile))
    if (output):
        phases = Num.arange(0.0, 1.0,
                            1.0 / len(profile)) + 0.5 / len(profile)
        Pgplot.plotxy(profile, phases, rangex=[0.0, 1.0],
                      labx='Pulse Phase', laby='Pulse Intensity')
    bestfit = ret[0][0] * gaussian_profile(len(profile),
                                           ret[0][2], ret[0][1]) \
              + ret[0][3]
    if (output):
        Pgplot.plotxy(bestfit, phases, color='red')
        Pgplot.closeplot()
    residuals = bestfit - profile
    resid_avg = residuals.mean()
    resid_std = residuals.std()
    if (output):
        Pgplot.plotxy(residuals, phases, rangex=[0.0, 1.0],
                      rangey=[min(residuals) - 2 * resid_std,
                              max(residuals) + 2 * resid_std],
                      labx='Pulse Phase', laby='Residuals',
                      line=None, symbol=3)
github scottransom / presto / python / presto / prepfold.py View on Github external
for jj in range(self.nsub):
                    profs[jj] = psr_utils.interp_rotate(sumprofs[jj], delaybins[jj],
                                                        zoomfact=interp_factor)
                # Note: Since the interpolation process slightly changes the values of the
                # profs, we need to re-calculate the average profile value
                avgprof = (profs/self.proflen).sum()
            else:
                new_subdelays_bins = Num.floor(delaybins+0.5)
                for jj in range(self.nsub):
                    profs[jj] = psr_utils.rotate(profs[jj], int(new_subdelays_bins[jj]))
                subdelays_bins += new_subdelays_bins
                avgprof = self.avgprof
            sumprof = profs.sum(0)
            chis[ii] = self.calc_redchi2(prof=sumprof, avg=avgprof)
        # Now plot it
        Pgplot.plotxy(chis, DMs, labx="DM", laby=r"Reduced-\gx\u2\d", device=device)
        return (chis, DMs)