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') plt.colorbar() plt.xlabel('Depth (unitless)') plt.ylabel('Width (days)') plt.title(r'$\Delta \ln L = \ln L_m - \ln L_f$') print t.clock() - t0
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]
#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) found_offset = time[index_max_like] print found_offset fig1 = plt.figure() sub1 = fig1.add_subplot(211) sub1.plot(time, flux, '.k') sub1.plot(time, f.push_box_model(found_offset,depth,width,time)) # sub1.vlines(inj_offset + 0.5*inj_width, flux.min(),flux.max(), 'r')
time -= np.median(time) # The following 5 lines of code create a fake transit signal inside the data. inj_period = 225.00 inj_offset = 0.0 inj_depth = 0.000336 * 3 inj_width = 0.54 flux = f.raw_injection(inj_period, inj_offset, inj_depth, inj_width, time, flux) flux = f.ma_filter(flux, 10) width = 0.54 depth = 0.000336 * 3 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) found_offset = time[index_max_like] print found_offset fig1 = plt.figure() sub1 = fig1.add_subplot(211) sub1.plot(time, flux, ',k') ylim_range = 0.001