Examples of fixing convergence: Real and Matern Kernels


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
import seaborn as sns
%matplotlib notebook

In [2]:
#Create Kernels for Gaussian Process

#Real term parameter initialization
a = 1e-2
c = 1
#Matern term parameter initialization
sig = 1e-4
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 = celerite.terms.RealTerm(log_a = np.log(a), log_c = np.log(c), bounds=bounds)
Matern = celerite.terms.Matern32Term(log_sigma = np.log(sig), log_rho = np.log(rho))

Example 1: Supernovae 'Gaia14ado'


In [3]:
SN1 = Supernovae("../../../OSC_data/JSON_data/sne-2010-2014-master/Gaia14ado.json")
SN1.load_LightCurves()
SN1.load_fit_data()
SN1.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)
/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/numpy/lib/function_base.py:3858: RuntimeWarning: Invalid value encountered in median
  r = func(a, **kwargs)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:293: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(self.time, self.flux, degree, w=self.flux_err)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:293: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(self.time, self.flux, degree, w=self.flux_err)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:293: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(self.time, self.flux, degree, w=self.flux_err)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
Gaia14ado

In [9]:
'''Print the filter, summary statistics, number of good observations (anything with six or less should have been skipped),
 and the flux predictions array'''

for filt in SN1.Lightcurves:
    print("filter: " + filt + "\n")
    print("Summary Statistic: ", SN1.Lightcurves[filt].Rchi2 ,"\n" )
    print("Number of good observations: ", SN1.Lightcurves[filt].n_good_obs, "\n")
    print("Flux predictions: ", SN1.Lightcurves[filt].flux_predicts, "\n")
bad_filts = []
for filt in SN1.Lightcurves:
    if(SN1.Lightcurves[filt].Rchi2):
        bad_filts.append(filt)


filter: B_4,5

Summary Statistic:  {} 

Number of good observations:  5 

Flux predictions:  [] 

filter: R_4,5

Summary Statistic:  {} 

Number of good observations:  3 

Flux predictions:  [] 

filter: I_4,5

Summary Statistic:  {} 

Number of good observations:  6 

Flux predictions:  [] 

filter: V_4,5

Summary Statistic:  {'polynomial_4': 7.9902603574249431, 'polynomial_6': 7.998179752753658, 'polynomial_8': 7.9978910646877166, 'Kapernka': 8.0384324391157005, 'Bazin': 7.944716044317552, 'GP_Real': nan, 'GP_Matern': nan} 

Number of good observations:  109 

Flux predictions:  [ 0.18923322  0.18938498  0.18923493  0.18919233  0.18971568         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
  0.18877668] 

filter: r_4,5

Summary Statistic:  {'polynomial_4': 4884968.8619448543, 'polynomial_6': 4423345800.5890779, 'polynomial_8': 1492225190.6980026, 'Kapernka': 5.1979526007476009, 'Bazin': 5.4985235603792635, 'GP_Real': nan, 'GP_Matern': nan} 

Number of good observations:  9 

Flux predictions:  [ 0.85102475         nan         nan         nan         nan         nan
         nan         nan  0.85102475] 

filter: g_4,5

Summary Statistic:  {'polynomial_4': 205061053.4118512, 'polynomial_6': 146441098430193.5, 'polynomial_8': 2.8055660984815362e+19, 'Kapernka': 45.605891505035352, 'Bazin': 34.578073269699622, 'GP_Real': nan, 'GP_Matern': nan} 

Number of good observations:  14 

Flux predictions:  [ 0.97647362         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan  0.97647362] 

filter: i_4,5

Summary Statistic:  {'polynomial_4': 23.363293660898321, 'polynomial_6': 1625283.526939455, 'polynomial_8': 71950728.4742091, 'Kapernka': 4.6077547368978431, 'Bazin': 4.5888860048182138, 'GP_Real': nan, 'GP_Matern': nan} 

Number of good observations:  10 

Flux predictions:  [ 0.91072258         nan         nan         nan         nan         nan
         nan         nan         nan  0.91072258] 

Out[9]:
['V_4,5', 'r_4,5', 'g_4,5', 'i_4,5']

In [12]:
plt.figure()
for filt in bad_filts:
    time = SN1.Lightcurves[filt].time
    flux = SN1.Lightcurves[filt].flux
    plt.scatter(time,flux)



In [21]:
SN1.Lightcurves['V_4,5'].Gaussian_process(Real)


/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/numpy/lib/function_base.py:3858: RuntimeWarning: Invalid value encountered in median
  r = func(a, **kwargs)
Out[21]:
(nan,)

Example 2: Supernovae 'Gaia15abk'


In [14]:
SN2 = Supernovae("../../../OSC_data/JSON_data/sne-2010-2014-master/Gaia15abk.json")
SN2.load_LightCurves()
SN2.load_fit_data()


/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)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:293: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(self.time, self.flux, degree, w=self.flux_err)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
Gaia15abk
/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/numpy/lib/function_base.py:3858: RuntimeWarning: Invalid value encountered in median
  r = func(a, **kwargs)

In [23]:
'''Print the filter, summary statistics, number of good observations (anything with six or less should have been skipped),
 and the flux predictions array'''

for filt in SN2.Lightcurves:
    print("filter: " + filt + "\n")
    print("Summary Statistic: ", SN2.Lightcurves[filt].Rchi2 ,"\n" )
    print("Number of good observations: ", SN2.Lightcurves[filt].n_good_obs, "\n")
    print("Flux predictions: ", SN2.Lightcurves[filt].flux_predicts, "\n")
bad_filts_2 = []
for filt in SN2.Lightcurves:
    if(SN2.Lightcurves[filt].Rchi2):
        bad_filts_2.append(filt)


filter: g_3,4

Summary Statistic:  {'polynomial_4': 30.999470828314411, 'polynomial_6': 9586.1715584222075, 'polynomial_8': 11838.291183537127, 'Kapernka': 14.7915402331601, 'Bazin': 15.099140382748498, 'GP_Real': nan, 'GP_Matern': nan} 

Number of good observations:  8 

Flux predictions:  [ 0.68770089         nan         nan         nan         nan         nan
         nan  0.68770089] 

filter: B_3,4

Summary Statistic:  {} 

Number of good observations:  1 

Flux predictions:  [] 

filter: V_3,4

Summary Statistic:  {} 

Number of good observations:  1 

Flux predictions:  [] 

filter: r_3,4

Summary Statistic:  {} 

Number of good observations:  1 

Flux predictions:  [] 


In [24]:
plt.figure()
for filt in bad_filts_2:
    time = SN2.Lightcurves[filt].time
    flux = SN2.Lightcurves[filt].flux
    plt.scatter(time,flux)


Example 3: Supernovae 'OGLE-2014-SN-080'


In [25]:
SN3 = Supernovae("../../../OSC_data/JSON_data/sne-2010-2014-master/OGLE-2014-SN-080.json")
SN3.load_LightCurves()
SN3.load_fit_data()


OGLE-2014-SN-080
/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/numpy/lib/function_base.py:3858: RuntimeWarning: Invalid value encountered in median
  r = func(a, **kwargs)

In [25]:
'''Print the filter, summary statistics, number of good observations (anything with six or less should have been skipped),
 and the flux predictions array'''

for filt in SN3.Lightcurves:
    print("filter: " + filt + "\n")
    print("Summary Statistic: ", SN3.Lightcurves[filt].Rchi2 ,"\n" )
    print("Number of good observations: ", SN3.Lightcurves[filt].n_good_obs, "\n")
    print("Flux predictions: ", SN3.Lightcurves[filt].flux_predicts, "\n")


filter: I_1,3

Summary Statistic:  {'polynomial_4': 14.342619366923952, 'polynomial_6': 44.801541260213746, 'polynomial_8': 529.86861765552203, 'Kapernka': 2.3505121262970823, 'Bazin': 3.2284651715057762, 'GP_Real': nan, 'GP_Matern': nan} 

Number of good observations:  21 

Flux predictions:  [ 0.36045582         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
         nan         nan  0.36045582] 


In [30]:
plt.figure()

for filt in SN3.Lightcurves:
    if(SN3.Lightcurves[filt].Rchi2):
        bad_filts_3.append(filt)
print(bad_filts_3)
for filt in bad_filts_3:
    time = SN3.Lightcurves[filt].time
    flux = SN3.Lightcurves[filt].flux
    plt.scatter(time,flux)


['I_1,3']

Example 4: Supernovae 'OGLE-2014-SN-132'


In [34]:
SN4 = Supernovae("../../../OSC_data/JSON_data/sne-2010-2014-master/OGLE-2014-SN-132.json")
SN4.load_LightCurves()
SN4.load_fit_data()


/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/numpy/lib/function_base.py:3858: RuntimeWarning: Invalid value encountered in median
  r = func(a, **kwargs)
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-34-7f906115f842> in <module>()
      1 SN4 = Supernovae("../../../OSC_data/JSON_data/sne-2010-2014-master/OGLE-2014-SN-132.json")
      2 SN4.load_LightCurves()
----> 3 SN4.load_fit_data()

~/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py in load_fit_data(self)
    128 
    129                         self.Lightcurves[key].Gaussian_process(Real_Kernel, plot=False)
--> 130                         self.Lightcurves[key].Gaussian_process(Matern_Kernel, plot=False)
    131                 print(self.name)
    132 

~/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py in Gaussian_process(self, kernel, plot)
    382                 gp = celerite.GP(kernel, mean=mean)
    383 
--> 384                 gp.compute(self.time, self.flux_err)
    385 
    386                 initial_params = gp.get_parameter_vector()

~/anaconda/envs/NUREU17/lib/python3.6/site-packages/celerite/celerite.py in compute(self, t, yerr, check_sorted)
    129             alpha_complex_real, alpha_complex_imag,
    130             beta_complex_real, beta_complex_imag,
--> 131             t, self._yerr**2
    132         )
    133         self.dirty = False

RuntimeError: failed to factorize or solve matrix

In [35]:
'''Print the filter, summary statistics, number of good observations (anything with six or less should have been skipped),
 and the flux predictions array'''

for filt in SN4.Lightcurves:
    print("filter: " + filt + "\n")
    print("Summary Statistic: ", SN4.Lightcurves[filt].Rchi2 ,"\n" )
    print("Number of good observations: ", SN4.Lightcurves[filt].n_good_obs, "\n")
    print("Flux predictions: ", SN4.Lightcurves[filt].flux_predicts, "\n")


filter: I_1,3

Summary Statistic:  {'polynomial_4': 10.858259047376087, 'polynomial_6': 957.30098112392159, 'polynomial_8': 214429.74192860202, 'Kapernka': 2.5847078312576293, 'Bazin': 2.7900630365285717, 'GP_Real': nan} 

Number of good observations:  13 

Flux predictions:  [ 0.52557146         nan         nan         nan         nan         nan
         nan         nan         nan         nan         nan         nan
  0.52557146] 


In [40]:
plt.figure()
bad_filts_4 = []
for filt in SN4.Lightcurves:
    if(SN4.Lightcurves[filt].Rchi2):
        bad_filts_4.append(filt)

for filt in bad_filts_4:
    time = SN4.Lightcurves[filt].time
    flux = SN4.Lightcurves[filt].flux
    plt.scatter(time,flux)


Example 5: Supernovae ''


In [41]:
SN5 = Supernovae("../../../OSC_data/JSON_data/sne-2010-2014-master/PTF11bij.json")
SN5.load_LightCurves()
SN5.load_fit_data()


/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:293: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(self.time, self.flux, degree, w=self.flux_err)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/Documents/LSST/NUREU17/LSST/SuperNovaLightCurves/Lightcurve_class.py:204: RankWarning: Polyfit may be poorly conditioned
  Coeffs = np.polyfit(time_del, flux_del, degree, w=flux_err_del)
/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/scipy/optimize/minpack.py:779: OptimizeWarning: Covariance of the parameters could not be estimated
  category=OptimizeWarning)
PTF11bij
/Users/ethanmarx/anaconda/envs/NUREU17/lib/python3.6/site-packages/numpy/lib/function_base.py:3858: RuntimeWarning: Invalid value encountered in median
  r = func(a, **kwargs)

In [42]:
'''Print the filter, summary statistics, number of good observations (anything with six or less should have been skipped),
 and the flux predictions array'''

for filt in SN5.Lightcurves:
    print("filter: " + filt + "\n")
    print("Summary Statistic: ", SN5.Lightcurves[filt].Rchi2 ,"\n" )
    print("Number of good observations: ", SN5.Lightcurves[filt].n_good_obs, "\n")
    print("Flux predictions: ", SN5.Lightcurves[filt].flux_predicts, "\n")


filter: g_2

Summary Statistic:  {} 

Number of good observations:  4 

Flux predictions:  [] 

filter: r_2

Summary Statistic:  {'polynomial_4': 101148.09449976876, 'polynomial_6': 380137.44192828028, 'polynomial_8': 1708686.68678349, 'Kapernka': 2.2343819346462039, 'Bazin': 21.210296918519649, 'GP_Real': nan, 'GP_Matern': nan} 

Number of good observations:  7 

Flux predictions:  [ 0.71539517         nan         nan         nan         nan         nan
  0.71539517] 

filter: i_2

Summary Statistic:  {} 

Number of good observations:  3 

Flux predictions:  [] 


In [44]:
plt.figure()
bad_filts_5 = []
for filt in SN5.Lightcurves:
    if(SN5.Lightcurves[filt].Rchi2):
        bad_filts_5.append(filt)
        
for filt in bad_filts_5:
    time = SN5.Lightcurves[filt].time
    flux = SN5.Lightcurves[filt].flux
    plt.scatter(time,flux)



In [ ]:


In [ ]: