In [1]:
#import necessary python libraries
import json
import matplotlib.pyplot as plt
import numpy as np
from scipy.optimize import curve_fit, minimize
import pandas as pd
import math
from JSON_to_DF import JSON_to_DataFrame
from Lightcurve_class import *
import celerite
import pickle
%matplotlib notebook

In [2]:
SN = deserialize('../../../OSC_data/pickled_data/SN2011fe.pickle')
SN.Lightcurves['B_10'].Kapernka_fit_plot()


Out[2]:
9.2363405212793914

Supernovae SN2011fe


In [2]:
#create new supernovae object and load meta and Lightcurve data
SN2011fe = Supernovae('../../../OSC_data/JSON_data/SN2011fe.json')
SN2011fe.load_LightCurves()
SN2011fe.meta_data()
SN2011fe.serialize()


/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/pandas/core/generic.py:1299: PerformanceWarning: 
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->mixed,key->block1_values] [items->['band', 'source', 'telescope']]

  return pytables.to_hdf(path_or_buf, key, self, **kwargs)

In [4]:
#Create Kernels for Gaussian Process

#Real term parameter initialization
a = 1e-5
c = 1
#Matern term parameter initialization
sig = 1e-5
rho = 100

#Bounds on parameters 
bounds = dict(log_a = (-15,15), log_c = (-15,15))
bounds = dict(log_sigma = (-15, 15), log_rho = (-15, 15))

#Create Kernels
Real_Kernel = celerite.terms.RealTerm(log_a = np.log(a), log_c = np.log(c), bounds=bounds)
Matern_Kernel = celerite.terms.Matern32Term(log_sigma = np.log(sig), log_rho = np.log(rho))

In [7]:
#Matern_Kernel fit
plt.figure()
SN2011fe.Lightcurves['V_10'].Gaussian_process(Matern_Kernel, plot=True)


Out[7]:
{'GP': 1.2447961035641013}

In [25]:
plt.figure()
SN2011fe.Lightcurves['V_10'].Gaussian_process(Real_Kernel, plot=True)


Out[25]:
1.4071382456682968

In [26]:
plt.figure()
SN2011fe.Lightcurves['V_10'].Kapernka_fit_plot(plot=True)


Out[26]:
8.4052962691613136

In [60]:
plt.figure()
SN2011fe.Lightcurves['V_10'].polynomial_fit_plot(6, plot=True)


Out[60]:
80.376483492032946

In [61]:
plt.figure()
SN2011fe.Lightcurves['V_10'].polynomial_fit_plot(8, plot=True)


Out[61]:
59.358258660495324

In [63]:
plt.figure()
SN2011fe.Lightcurves['V_10'].Bazin_fit_plot(plot=True)


Out[63]:
8.2476021464714364

In [64]:
SN2011fe.Lightcurves['V_10'].Rchi2


Out[64]:
{'Bazin': 8.2476021464714364,
 'GP': 1.4071382456682968,
 'Kapernka': 8.4052962691613136,
 'polynomial_6': 80.376483492032946,
 'polynomial_8': 59.358258660495324}

Supernovae SN2008es


In [66]:
#create new supernovae object and load meta and Lightcurve data
SN2008es = Supernovae('../../../OSC_data/JSON_data/SN2008es.json')
SN2008es.load_LightCurves()
SN2008es.meta_data()
SN2008es.serialize()


/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/pandas/core/generic.py:1299: PerformanceWarning: 
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->mixed,key->block1_values] [items->['band', 'source', 'telescope']]

  return pytables.to_hdf(path_or_buf, key, self, **kwargs)

In [ ]:
SN2008es = deserialize("../../../OSC_data/pickled_data/SN2008es.pickle")

In [68]:
#Matern_Kernel fit
plt.figure()
SN2008es.Lightcurves['B_2'].Gaussian_process(Matern_Kernel, plot=True)


Out[68]:
10.412150799183538

In [69]:
plt.figure()
SN2008es.Lightcurves['B_2'].Gaussian_process(Real_Kernel, plot=True)


Out[69]:
8.1946270825979912

In [71]:
plt.figure()
SN2008es.Lightcurves['B_2'].Kapernka_fit_plot(plot=True)


Out[71]:
1.7368095546096145

In [72]:
plt.figure()
SN2008es.Lightcurves['B_2'].polynomial_fit_plot(6, plot=True)


Out[72]:
1604.2742933956702

In [73]:
plt.figure()
SN2008es.Lightcurves['B_2'].polynomial_fit_plot(8, plot=True)


Out[73]:
55828.308501091487

In [74]:
SN2008es.Lightcurves['B_2'].Rchi2


Out[74]:
{'GP': 8.1946270825979912,
 'Kapernka': 1.7368095546096145,
 'polynomial_6': 1604.2742933956702,
 'polynomial_8': 55828.308501091487}

Supernovae SN2009ip


In [75]:
#create new supernovae object and load meta and Lightcurve data
#create new supernovae object and load meta and Lightcurve data
SN2009ip = Supernovae('../../../OSC_data/JSON_data/SN2009ip.json')
SN2009ip.load_LightCurves()
SN2009ip.meta_data()
SN2009ip.serialize()



SN2009ip = deserialize("../../../OSC_data/pickled_data/SN2009ip.pickle")


/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/pandas/core/generic.py:1299: PerformanceWarning: 
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->mixed,key->block1_values] [items->['band', 'source', 'telescope']]

  return pytables.to_hdf(path_or_buf, key, self, **kwargs)

In [76]:
SN2009ip = deserialize("../../../OSC_data/pickled_data/SN2009ip.pickle")

In [78]:
plt.figure()
SN2009ip.Lightcurves['B_7'].Gaussian_process(Matern_Kernel, plot=True)


Out[78]:
12.957286132717321

In [79]:
plt.figure()
SN2009ip.Lightcurves['B_7'].Gaussian_process(Real_Kernel, plot=True)


Out[79]:
15.914480686894366

In [80]:
plt.figure()
SN2009ip.Lightcurves['B_7'].polynomial_fit_plot(6, plot=True)


Out[80]:
350.50405090098383

In [81]:
plt.figure()
SN2009ip.Lightcurves['B_7'].polynomial_fit_plot(8, plot=True)


Out[81]:
168.30276544907997

In [82]:
SN2009ip.Lightcurves['B_7'].Rchi2


Out[82]:
{'GP': 15.914480686894366,
 'polynomial_6': 350.50405090098383,
 'polynomial_8': 168.30276544907997}

Supernovae SN1999em


In [2]:
#create new supernovae object and load meta and Lightcurve data
SN1999em = Supernovae('../../../OSC_data/JSON_data/SN1999em.json')
SN1999em.load_LightCurves()
SN1999em.meta_data()
SN1999em.serialize()


/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/pandas/core/generic.py:1299: PerformanceWarning: 
your performance may suffer as PyTables will pickle object types that it cannot
map directly to c-types [inferred_type->mixed,key->block1_values] [items->['band', 'source', 'telescope']]

  return pytables.to_hdf(path_or_buf, key, self, **kwargs)

In [3]:
SN1999em = deserialize("../../../OSC_data/pickled_data/SN1999em.pickle")

In [86]:
plt.figure()
SN1999em.Lightcurves['B_1'].Gaussian_process(Matern_Kernel, plot=True)


Out[86]:
147.03106460370762

In [87]:
plt.figure()
SN1999em.Lightcurves['B_1'].Gaussian_process(Real_Kernel, plot=True)


/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/matplotlib/pyplot.py:524: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)
Out[87]:
35.155403947089951

In [88]:
plt.figure()
SN1999em.Lightcurves['B_1'].Kapernka_fit_plot(plot = True)


/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/matplotlib/pyplot.py:524: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)
Out[88]:
25.955431298979633

In [89]:
plt.figure()
SN1999em.Lightcurves['B_1'].polynomial_fit_plot(6, plot=True)


/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/matplotlib/pyplot.py:524: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)
Out[89]:
12958.730072279166

In [90]:
plt.figure()
SN1999em.Lightcurves['B_1'].polynomial_fit_plot(8, plot=True)


/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/matplotlib/pyplot.py:524: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`).
  max_open_warning, RuntimeWarning)
Out[90]:
15987.022116534446

In [91]:
SN1999em.Lightcurves['B_1'].Rchi2


Out[91]:
{'GP': 35.155403947089951,
 'Kapernka': 25.955431298979633,
 'polynomial_6': 12958.730072279166,
 'polynomial_8': 15987.022116534446}

Code Errors


In [3]:
SN2016fzm  = deserialize('../../../OSC_data/pickled_data/SN2017uq.pickle')

In [26]:



Out[26]:
array([  2.88084571e-08,   2.85259423e-08,   2.73652865e-08,
         2.66097013e-08,   2.78048144e-08,   2.75372140e-08,
         2.77792170e-08,   2.73451305e-08,   2.46286156e-09,
         1.99177373e-09])

In [ ]: