In [1]:
%matplotlib inline
%config InlineBackend.figure_format = "retina"
from salter import LightCurve
import matplotlib.pyplot as plt
In [2]:
# Specify a KIC number to get the light curve
# Here are some numbers to try: 4157325, 9651668, 9705459, 10386922
kic_number = 10815677#9651668
whole_lc = LightCurve.from_hdf5(kic_number)
# Plot the light curve (raw SAP flux)
whole_lc.plot()
Here's how you can quickly see what the transit parameters are:
In [3]:
for attr in dir(whole_lc.params):
if not attr.startswith('_'):
print("{0}: {1}".format(attr, getattr(whole_lc.params, attr)))
Mask the out-of-transit portions of the light curve, normalize each transit with the "subtract-add-divide" method.
In [4]:
from salter import subtract_add_divide
extra_oot_time = 2.0 # [durations]; Extra transit durations to keep before ingress/after egress
# Mask out-of-transit portions of light curves, chop into individual transits
near_transit = LightCurve(**whole_lc.mask_out_of_transit(oot_duration_fraction=extra_oot_time))
transits = near_transit.get_transit_light_curves()
# Normalize all transits with the subtract-add-divide method,
# using a second order polynomial
subtract_add_divide(whole_lc, transits)
In [5]:
10815677
Out[5]:
In [6]:
whole_lc.params.duration
Out[6]:
Plot the residuals from the transit model given the parameters from the KOI catalog.
In [7]:
from salter import concatenate_transit_light_curves
normed_transits = concatenate_transit_light_curves(transits)
plt.plot(normed_transits.phases(),
normed_transits.fluxes - normed_transits.transit_model(),
'k.', alpha=0.3)
plt.xlabel('Orbital phase')
plt.ylabel('Residuals')
Out[7]:
Solve for better $R_p/R_\star$, $u_1$, $u_2$ parameters:
In [8]:
from salter import concatenate_transit_light_curves
normed_transits = concatenate_transit_light_curves(transits)
# Solve for better parameters for: Rp/Rs, u1, u2
normed_transits.fit_lc_3param()
Store residuals in a Residuals
object, which has handy methods for statistical analysis.
In [9]:
from salter import Residuals
r = Residuals(normed_transits, normed_transits.params, buffer_duration=0.3)
r.plot()
Out[9]:
In [10]:
# Two sample KS test: are the distributions of the two samples the same?
print(r.ks(['out_of_transit', 'before_midtransit'],
['out_of_transit', 'after_midtransit']))
# k-sample Anderson test: are the distributions of the two samples the same?
print(r.anderson(['out_of_transit', 'before_midtransit'],
['out_of_transit', 'after_midtransit']))
# Independent sample T-test: are the means the two samples the same?
print(r.ttest(['out_of_transit', 'before_midtransit'],
['out_of_transit', 'after_midtransit']))
In [11]:
# Two sample KS test: are the distributions of the two samples the same?
print(r.ks(['in_transit', 'before_midtransit'],
['in_transit', 'after_midtransit']))
# k-sample Anderson test: are the distributions of the two samples the same?
print(r.anderson(['in_transit', 'before_midtransit'],
['in_transit', 'after_midtransit']))
# Independent sample T-test: are the means the two samples the same?
print(r.ttest(['in_transit', 'before_midtransit'],
['in_transit', 'after_midtransit']))
In [12]:
# Two sample KS test: are the distributions of the two samples the same?
print(r.ks('in_transit', 'out_of_transit'))
# k-sample Anderson test: are the distributions of the two samples the same?
print(r.anderson('in_transit', 'out_of_transit'))
# Independent sample T-test: are the means the two samples the same?
print(r.ttest('in_transit', 'out_of_transit'))
In [ ]: