import time as t t0 = t.clock() kplr_id = '002973073' kplr_file = 'kplr002973073-2009166043257_llc.fits' jdadj, obsobject, lightdata = f.openfile(kplr_id, kplr_file) time, flux, flux_err = f.fix_data(lightdata) time -= np.median(time) inj_period = 300.00 inj_offset = -12.0 inj_depth = 0.000336 inj_width = 0.54 flux = f.raw_injection(inj_period,inj_offset,inj_depth,inj_width,time,flux) flux, variance = f.rescale(flux, flux_err) depth_interval = np.linspace(0.00,0.001, 200) width_interval = np.linspace(0.40,0.70, 200) ln_like_grid = [[f.ln_like(flux, f.push_box_model(inj_offset, d, w, time), variance) for d in depth_interval] for w in width_interval] ln_like_flat = f.ln_like(flux, f.flat_model(time), variance) ln_like_grid -= ln_like_flat #The following two lines would net negatiev likelihood values to NaN # negative = ln_like_grid < 0 # ln_like_grid[negative] = np.nan plt.imshow(ln_like_grid, cmap= 'spectral', aspect = 'auto', extent = [depth_interval[0], depth_interval[-1], width_interval[0], width_interval[-1]], origin = 'lower', interpolation = 'nearest')
import functions as f kplr_id = '006116605' kplr_file = 'kplr006116605-2009259160929_llc.fits' jdadj, obsobject, lightdata = f.openfile(kplr_id, kplr_file) time, flux, flux_err = f.fix_data(lightdata) flux, variance = f.rescale(flux, flux_err) time -= np.median(time) period = 300.00 offset = 20.0 depth = 0.008 width = 0.09 flux = f.raw_injection(period, offset, depth, width, time, flux) offset_interval = np.arange(0.00, 30.00, 0.01) chi2 = [ f.sum_chi_squared(flux, f.box(period, o, depth, 0.09, time), variance) for o in offset_interval ] best_offset = offset_interval[np.argmin(chi2)] fig1 = plt.figure() sub1 = fig1.add_subplot(121) sub1.plot(time, flux, color="black", marker=",", linestyle='None') sub1.plot(time, f.box(period, best_offset, depth, 0.9, time), 'r') xlab = "Time (days, Kepler Barycentric Julian date - %s)" % jdadj sub1.set_xlabel(xlab) sub1.set_ylabel("Relative Brightness (electron flux)")
import time as t t0 = t.clock() kplr_id = '002973073' kplr_file = 'kplr002973073-2009166043257_llc.fits' jdadj, obsobject, lightdata = f.openfile(kplr_id, kplr_file) time, flux, flux_err = f.fix_data(lightdata) time -= np.median(time) #The following 5 lines of code create a fake transit signal inside the data. inj_period = 100.00 inj_offset = -12.0 inj_depth = 0.000336 inj_width = 0.54 flux = f.raw_injection(inj_period,inj_offset,inj_depth,inj_width,time,flux) flux, variance = f.rescale(flux, flux_err) width = 1.5 depth = 0.000336 # offset_interval = np.linspace(time[0], time[-1], 10000) ln_like_perfect = np.asarray([f.ln_like(flux, f.push_box_model(o, depth, width, time), variance) for o in time]) ln_like_flat = f.ln_like(flux, f.flat_model(time), variance) #subtract the flat model likelihood from the ln_likelihood array ln_like_array = ln_like_perfect - ln_like_flat index_max_like = np.argmax(ln_like_array)
import functions as f kplr_id = '006116605' kplr_file = 'kplr006116605-2009259160929_llc.fits' jdadj, obsobject, lightdata = f.openfile(kplr_id, kplr_file) time, flux, flux_err = f.fix_data(lightdata) flux, variance = f.rescale(flux, flux_err) time -= np.median(time) period = 300.00 offset = 20.0 depth = 0.008 width = 0.09 flux = f.raw_injection(period,offset,depth,width,time,flux) offset_interval = np.arange(0.00, 30.00, 0.01) chi2 = [f.sum_chi_squared(flux, f.box(period, o, depth, 0.09, time), variance) for o in offset_interval] best_offset = offset_interval[np.argmin(chi2)] fig1 = plt.figure() sub1 = fig1.add_subplot(121) sub1.plot(time ,flux, color="black", marker=",", linestyle = 'None') sub1.plot(time , f.box(period, best_offset, depth, 0.9, time), 'r') xlab = "Time (days, Kepler Barycentric Julian date - %s)"%jdadj sub1.set_xlabel(xlab) sub1.set_ylabel("Relative Brightness (electron flux)") plottitle="Light Curve for %s"%obsobject sub1.set_title(plottitle)