In [1]:
import json
import pickle
import os, sys
sys.path.append('../gen_lightcurves')

des_file = "../gen_lightcurves/des_sn.p"

with open(des_file, 'rb') as f:
    des_data = pickle.load(f)

In [7]:
lightcurve = des_data[198253]
#lightcurve = des_data[85500]
#lightcurve = des_data[184770]
#lightcurve = des_data[28155]
print(lightcurve["g"].keys())


dict_keys(['hostzerr', 'mjd', 'modelmag', 'modelerr', 'modeldate', 'type', 'goodstatus', 'hostz', 'kernel', 'dmag', 'confirm_type', 'mag', 'bsplinemag'])

In [8]:
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import numpy as np

In [9]:
gs = gridspec.GridSpec(2,2)
fig = plt.figure(figsize=(8,6))
SIZE = 5
MEDIUM_SIZE = 8
BIGGER_SIZE = 10

plt.rc('font', size=SIZE)                # controls default text sizes
plt.rc('axes', titlesize=BIGGER_SIZE)           # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE)    # fontsize of the x and y labels
plt.rc('xtick', labelsize=MEDIUM_SIZE)          # fontsize of the tick labels
plt.rc('ytick', labelsize=MEDIUM_SIZE)          # fontsize of the tick labels
plt.rc('legend', fontsize=SIZE)          # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title

left  = 0.125  # the left side of the subplots of the figure
right = 0.9    # the right side of the subplots of the figure
bottom = 0.1   # the bottom of the subplots of the figure
top = 0.9      # the top of the subplots of the figure
wspace = 0.2   # the amount of width reserved for blank space between subplots
hspace = 0.2

plt.subplots_adjust(hspace = 0.4)

for i, filt in enumerate(lightcurve):
    filt_data = lightcurve[filt]
    mag = np.array(filt_data["mag"])
    magerr = np.array(filt_data["dmag"])
    date = np.array(filt_data["mjd"]) - min(filt_data["mjd"])
    
    modelmag = filt_data["modelmag"]
    modeldate = np.array(filt_data["modeldate"]) - min(filt_data["modeldate"])
    
    bsplinemag = filt_data["bsplinemag"]
    #print(mag - magerr)
    sntype = filt_data["type"]
    
    if filt == 'g':
        ax = fig.add_subplot(gs[0])
    elif filt == 'r':
        ax = fig.add_subplot(gs[1])
    elif filt == 'i':
        ax = fig.add_subplot(gs[2])
    elif filt == 'z':
        ax = fig.add_subplot(gs[3])
    ax.errorbar(date, mag, fmt='o', ecolor='k', yerr=magerr,label='Original', alpha=1, color='k', markersize=2,capsize=2)
    #ax.plot(modeldate, modelmag, '-r', label='GP', alpha = 0.7)
    ax.set_ylabel("flux")
    ax.set_xlabel("days")
    #Color mapping
    if filt == 'z':
        color='black'
    elif filt=='g':
        color='green'
    elif filt=='r':
        color='red'
    elif filt=='i':
        color='orange'
    ax.plot(modeldate, modelmag, color=color, label='BSpline', alpha=0.8)
    
    ax.set_title(filt.lower())
#plt.show()
#plt.savefig('DES_4FiltersGP_Ia.png')
plt.savefig('DES_4band_gp.png')

In [ ]: