transits = LightCurve(**whole_lc.mask_out_of_transit(kepler17_params) ).get_transit_light_curves(kepler17_params) # The short cadence data begin after the 137th transit, so ignore all transits before then: transits = transits[137:] plots = True delta_chi2 = {}#np.zeros(len(transits)) with ProgressBar(len(transits)) as bar: for i, lc in enumerate(transits): #lc.plot() # Remove linear out-of-transit trend from transit lc.remove_linear_baseline(kepler17_params) residuals = lc.fluxes - generate_lc_depth(lc.times_jd, depth, kepler17_params) best_fit_params = peak_finder(lc.times.jd, residuals, lc.errors, kepler17_params) transit_model = generate_lc_depth(lc.times_jd, depth, kepler17_params) chi2_transit = np.sum((lc.fluxes - transit_model)**2/lc.errors**2)/len(lc.fluxes) gaussian_model = summed_gaussians(lc.times.jd, best_fit_params) if best_fit_params is not None: split_input_parameters = np.split(np.array(best_fit_params), len(best_fit_params)/3) delta_chi2[i] = [] for amplitude, t0, sigma in split_input_parameters: model_i = gaussian(lc.times.jd, amplitude, t0, sigma) chi2_bumps = np.sum((lc.fluxes - transit_model - model_i)**2/lc.errors**2)/len(lc.fluxes)
jd_minus_bjdref, flux, error = np.loadtxt(light_curve_path, unpack=True) jd = jd_minus_bjdref + BJDREF # construct light curve object from those data whole_lc = LightCurve(times=jd, fluxes=flux, errors=error) transits = LightCurve(**whole_lc.mask_out_of_transit()).get_transit_light_curves() # The short cadence data begin after the 137th transit, so ignore all transits before then: transits = transits[137:] lc = transits[104] # Remove linear out-of-transit trend from transit lc.remove_linear_baseline() depth = 0.13413993**2 residuals = lc.fluxes - generate_lc_depth(lc.times_jd, depth) # Fit the transit model residuals for n_peaks gaussians sampler, samples = run_emcee(lc.times.jd, residuals, lc.errors, n_peaks=4) # Plot the results import corner corner.corner(samples) median_params = np.median(samples, axis=0) transit_model = generate_lc_depth(lc.times_jd, depth) gaussian_model = summed_gaussians(lc.times.jd, median_params) fig, ax = plt.subplots(3, 1, figsize=(8, 14), sharex=True) ax[0].errorbar(lc.times.jd, lc.fluxes, lc.errors, fmt='.', color='k')