Beispiel #1
0
def sampling_figure(prefix="plots"):
    matplotlib.rcParams["axes.labelsize"] = 40
    matplotlib.rcParams["xtick.labelsize"] = 26

    xmin = 0.
    radecs = []
    level = 0.
    fig = plt.figure(figsize=(15, 15))
    ax = fig.add_subplot(111)
    for ii in range(100):
        lightCurves = session.query(LightCurve).filter(
            func.array_length(LightCurve.mjd, 1) > 100).limit(100).all()

        if level >= 10: break
        for lc in lightCurves:
            if (max(lc.mjd) - min(lc.mjd)) > 365:
                next_lc = False
                for radec in radecs:
                    try:
                        sep = g.subtends(lc.ra,
                                         lc.dec,
                                         radec[0],
                                         radec[1],
                                         units="degrees")
                    except ValueError:
                        next_lc = True
                    if sep < 5.:
                        next_lc = True

                if next_lc: continue
                else: radecs.append((lc.ra, lc.dec))

                #ax.errorbar(lc.Rmjd, lc.Rmag, lc.Rerror, ls='none', marker='o', c='k', ecolor='0.7', capsize=0)
                ax.plot(lc.Rmjd, [level] * len(lc.Rmjd),
                        marker='o',
                        ms=20.0,
                        c='k',
                        ls='none',
                        alpha=0.3)

                if xmin == 0:
                    xmin = min(lc.Rmjd)
                    ax.set_xlim(xmin, xmin + 365)

                level += 1

    ymin, ymax = ax.get_ylim()
    ydel = ymax - ymin
    ax.set_ylim(ymin - ydel / 10., ymax + ydel / 10.)
    ax.set_xlabel("MJD")
    ax.set_yticklabels([])
    plt.savefig(os.path.join(prefix, "ptf_sampling_figure.pdf"))
Beispiel #2
0
def sampling_figure(prefix="plots"):
    matplotlib.rcParams["axes.labelsize"] = 40
    matplotlib.rcParams["xtick.labelsize"] = 26
    
    xmin = 0.
    radecs = []
    level = 0.
    fig = plt.figure(figsize=(15,15))
    ax = fig.add_subplot(111)
    for ii in range(100):
        lightCurves = session.query(LightCurve).filter(func.array_length(LightCurve.mjd, 1) > 100).limit(100).all()
        
        if level >= 10: break
        for lc in lightCurves:
            if (max(lc.mjd) - min(lc.mjd)) > 365:
                next_lc = False
                for radec in radecs:
                    try:
                        sep = g.subtends(lc.ra, lc.dec, radec[0], radec[1], units="degrees")
                    except ValueError:
                        next_lc = True
                    if sep < 5.:
                        next_lc = True
                
                if next_lc: continue
                else: radecs.append((lc.ra, lc.dec))
                    
                
                #ax.errorbar(lc.Rmjd, lc.Rmag, lc.Rerror, ls='none', marker='o', c='k', ecolor='0.7', capsize=0)
                ax.plot(lc.Rmjd, [level]*len(lc.Rmjd), marker='o', ms=20.0, c='k', ls='none', alpha=0.3)
                
                if xmin == 0:
                    xmin = min(lc.Rmjd)
                    ax.set_xlim(xmin, xmin+365)
                
                level += 1
    
    ymin, ymax = ax.get_ylim()
    ydel = ymax-ymin
    ax.set_ylim(ymin-ydel/10., ymax+ydel/10.)
    ax.set_xlabel("MJD")
    ax.set_yticklabels([])
    plt.savefig(os.path.join(prefix, "ptf_sampling_figure.pdf"))
Beispiel #3
0
def bad_data_figure(prefix="plots"):
    matplotlib.rcParams["axes.titlesize"] = 40
    matplotlib.rcParams["axes.labelsize"] = 40
    matplotlib.rcParams["xtick.labelsize"] = 20
    matplotlib.rcParams["ytick.labelsize"] = 20
    
    lightCurve1 = session.query(LightCurve).filter(LightCurve.objid == 14688560553413090141).one()
    lightCurve2 = session.query(LightCurve).filter(LightCurve.objid == 14688560553413090134).one()
    
    print "Distance between objects: {0}\"".format(g.subtends(lightCurve1.ra, lightCurve1.dec, lightCurve2.ra, lightCurve2.dec, units="degrees")*3600.)
    
    medMag1 = np.median(lightCurve1.mag)
    medMag2 = np.median(lightCurve2.mag)
    
    fig = plt.figure(figsize=(20,25))
    fig.subplots_adjust(hspace=0.2, left=0.1)
    ax1 = fig.add_subplot(211)
    ax1.errorbar(lightCurve1.mjd, lightCurve1.mag, lightCurve1.error, ls='none', marker='o', ecolor='0.7', capsize=0)
    ax2 = fig.add_subplot(212)
    ax2.errorbar(lightCurve2.mjd, lightCurve2.mag, lightCurve2.error, ls='none', marker='o', ecolor='0.7', capsize=0)
    
    ax1.set_ylim(medMag1-0.5,medMag1+0.5)
    ax1.set_ylim(ax1.get_ylim()[::-1])
    ax1.set_xlim(55000, 56000)
    ax1.set_ylabel(r"$R$")
    ax1.set_xticklabels([])
    ax1.set_title("objid: {0}".format(lightCurve1.objid))
    
    ax2.set_ylim(medMag2-0.5,medMag2+0.5)
    ax2.set_ylim(ax2.get_ylim()[::-1])
    ax2.set_xlim(55000, 56000)
    ax2.set_ylabel(r"$R$")
    ax2.set_xlabel("MJD")
    ax2.set_title("objid: {0}".format(lightCurve2.objid))
    
    plt.savefig(os.path.join(prefix, "bad_data_figure.pdf"))
    
    return
    
    # Code below is to search for light curves that are similar
    while True:
        lightCurve1 = session.query(LightCurve).filter(func.array_length(LightCurve.mjd, 1) > 200).order_by(func.random()).limit(1).one()
        lightCurve2 = session.query(LightCurve).filter(func.array_length(LightCurve.mjd, 1) > 200).\
                                                filter(func.q3c_radial_query(LightCurve.ra, LightCurve.dec, lightCurve1.ra, lightCurve1.dec, 60./3600.)).\
                                                order_by(func.random()).limit(1).one()
        
        medMag1 = np.median(lightCurve1.mag)
        medMag2 = np.median(lightCurve2.mag)
        if medMag1 > 17 or medMag2 > 17: continue
        
        fig = plt.figure(figsize=(20,25))
        fig.subplots_adjust(hspace=0.3, left=0.1)
        ax1 = fig.add_subplot(211)
        ax1.errorbar(lightCurve1.mjd, lightCurve1.mag, lightCurve1.error, ls='none', marker='o', ecolor='0.7', capsize=0)
        ax2 = fig.add_subplot(212)
        ax2.errorbar(lightCurve2.mjd, lightCurve2.mag, lightCurve2.error, ls='none', marker='o', ecolor='0.7', capsize=0)
        
        ax1.set_ylim(medMag1-0.5,medMag1+0.5)
        ax1.set_ylim(ax1.get_ylim()[::-1])
        ax1.set_xlim(55000, 56000)
        ax1.set_ylabel(r"$R$")
        ax1.set_xticklabels([])
        ax1.set_title("objid: {0}".format(lightCurve1.objid))
        
        ax2.set_ylim(medMag2-0.5,medMag2+0.5)
        ax2.set_ylim(ax2.get_ylim()[::-1])
        ax2.set_xlim(55000, 56000)
        ax2.set_ylabel(r"$R$")
        ax2.set_xlabel("MJD")
        ax2.set_title("objid: {0}".format(lightCurve2.objid))
        
        plt.show()
Beispiel #4
0
def bad_data_figure(prefix="plots"):
    matplotlib.rcParams["axes.titlesize"] = 40
    matplotlib.rcParams["axes.labelsize"] = 40
    matplotlib.rcParams["xtick.labelsize"] = 20
    matplotlib.rcParams["ytick.labelsize"] = 20

    lightCurve1 = session.query(LightCurve).filter(
        LightCurve.objid == 14688560553413090141).one()
    lightCurve2 = session.query(LightCurve).filter(
        LightCurve.objid == 14688560553413090134).one()

    print "Distance between objects: {0}\"".format(
        g.subtends(lightCurve1.ra,
                   lightCurve1.dec,
                   lightCurve2.ra,
                   lightCurve2.dec,
                   units="degrees") * 3600.)

    medMag1 = np.median(lightCurve1.mag)
    medMag2 = np.median(lightCurve2.mag)

    fig = plt.figure(figsize=(20, 25))
    fig.subplots_adjust(hspace=0.2, left=0.1)
    ax1 = fig.add_subplot(211)
    ax1.errorbar(lightCurve1.mjd,
                 lightCurve1.mag,
                 lightCurve1.error,
                 ls='none',
                 marker='o',
                 ecolor='0.7',
                 capsize=0)
    ax2 = fig.add_subplot(212)
    ax2.errorbar(lightCurve2.mjd,
                 lightCurve2.mag,
                 lightCurve2.error,
                 ls='none',
                 marker='o',
                 ecolor='0.7',
                 capsize=0)

    ax1.set_ylim(medMag1 - 0.5, medMag1 + 0.5)
    ax1.set_ylim(ax1.get_ylim()[::-1])
    ax1.set_xlim(55000, 56000)
    ax1.set_ylabel(r"$R$")
    ax1.set_xticklabels([])
    ax1.set_title("objid: {0}".format(lightCurve1.objid))

    ax2.set_ylim(medMag2 - 0.5, medMag2 + 0.5)
    ax2.set_ylim(ax2.get_ylim()[::-1])
    ax2.set_xlim(55000, 56000)
    ax2.set_ylabel(r"$R$")
    ax2.set_xlabel("MJD")
    ax2.set_title("objid: {0}".format(lightCurve2.objid))

    plt.savefig(os.path.join(prefix, "bad_data_figure.pdf"))

    return

    # Code below is to search for light curves that are similar
    while True:
        lightCurve1 = session.query(LightCurve).filter(
            func.array_length(LightCurve.mjd, 1) > 200).order_by(
                func.random()).limit(1).one()
        lightCurve2 = session.query(LightCurve).filter(func.array_length(LightCurve.mjd, 1) > 200).\
                                                filter(func.q3c_radial_query(LightCurve.ra, LightCurve.dec, lightCurve1.ra, lightCurve1.dec, 60./3600.)).\
                                                order_by(func.random()).limit(1).one()

        medMag1 = np.median(lightCurve1.mag)
        medMag2 = np.median(lightCurve2.mag)
        if medMag1 > 17 or medMag2 > 17: continue

        fig = plt.figure(figsize=(20, 25))
        fig.subplots_adjust(hspace=0.3, left=0.1)
        ax1 = fig.add_subplot(211)
        ax1.errorbar(lightCurve1.mjd,
                     lightCurve1.mag,
                     lightCurve1.error,
                     ls='none',
                     marker='o',
                     ecolor='0.7',
                     capsize=0)
        ax2 = fig.add_subplot(212)
        ax2.errorbar(lightCurve2.mjd,
                     lightCurve2.mag,
                     lightCurve2.error,
                     ls='none',
                     marker='o',
                     ecolor='0.7',
                     capsize=0)

        ax1.set_ylim(medMag1 - 0.5, medMag1 + 0.5)
        ax1.set_ylim(ax1.get_ylim()[::-1])
        ax1.set_xlim(55000, 56000)
        ax1.set_ylabel(r"$R$")
        ax1.set_xticklabels([])
        ax1.set_title("objid: {0}".format(lightCurve1.objid))

        ax2.set_ylim(medMag2 - 0.5, medMag2 + 0.5)
        ax2.set_ylim(ax2.get_ylim()[::-1])
        ax2.set_xlim(55000, 56000)
        ax2.set_ylabel(r"$R$")
        ax2.set_xlabel("MJD")
        ax2.set_title("objid: {0}".format(lightCurve2.objid))

        plt.show()