#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')
Exemplo n.º 2
0
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
Exemplo n.º 3
0
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]
Exemplo n.º 4
0
        time, flux, ferr = functions.fix_data(hdu_data)
        time_list.append(time)
        flux_list.append(flux)
        median = functions.median_filter(flux, filter_size)
        ferr_list.append((ferr / median)**2)
        med_flux_list.append(flux / median)

time = np.concatenate(time_list)
flux = np.concatenate(flux_list)
med_flux = np.concatenate(med_flux_list)

depth = 0.003
width = 0.1

#Run the search
ln_like_perfect = np.asarray([functions.pre_ln_like(med_flux, functions.push_box_model(o, depth, width, time)) for o in time])
ln_like_flat = functions.pre_ln_like(med_flux, functions.flat_model(time))

#Subtract off teh ln_like_flat as it is just a constant.
ln_like_array = ln_like_perfect - ln_like_flat
# index_maxi_like = np.argmax(ln_like_array)


fig1 = plt.figure()
sub1 = fig1.add_subplot(211)
sub1.plot(time, flux, ',k')
sub1.set_xlabel("Days")
sub1.set_ylabel("Raw Flux")

sub2 = fig1.add_subplot(212)
sub2.plot(time, med_flux, ',k')
Exemplo n.º 5
0
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
kplr_id = '002973073'
kplr_file = 'kplr002973073-2013011073258_llc.fits'

jdadj, obsobject, lightdata = f.openfile(kplr_id, kplr_file)
time, flux, flux_err = f.fix_data(lightdata)
time -= np.median(time)

flux, variance = f.rescale(flux, flux_err)

width = 1.0
depth = 0.000236

# 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))
Exemplo n.º 7
0
# print time.shape
# assert 0
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
ylim_limits = [1-ylim_range,1+ylim_range]
sub1.set_ylim(ylim_limits[0],ylim_limits[-1])