0

I have light curve data consist of time (t) and flux (f) (4067 rows x 2 columns)

nx=4067
t=fltarr(nx)
f=fltarr(nx)

data=read_table('kplr4830001.dat')

;print,data(0,*) ;this is t
;print,data(1,*) ;this is f

window,0
plot,data(0,*)/data(0,0),data(1,*)/data(1,0),xrange=[1.045,1.13],yrange=[0.98,1.03],xstyle=1,ystyle=1

I managed to calculate the threshold (thr = 0.0067621339).

I want to calculate a specific time period (t_start) and (t_end).

t_start: The time at which the flux first exceeds the threshold (0.0067621339).
t_end: The time at which the flux first becom smaller than (3*exp(-9/2)).
This is how I did it:

;t_start
for i=0,nx-2 do begin
IF (data(1,i)/data(1,0) GT (thr)) THEN begin
print, data(1,i)/data(1,0)
endif
endfor

;t_end
for i=0,nx-2 do begin
IF (data(1,i)/data(1,0) LT (3*exp(-9/2))) THEN begin
print, data(0,i)/data(0,0)
endif
endfor

end

what I need is just the first value of data(0,i)/data(0,0) that met these conditions. How can I do it?

A.KT
  • 11
  • 4

1 Answers1

0

Some questions I have aside, here is some sample code to determine when the flux first exceeds the threshold, and then dips below the second threshold (assuming the data is ordered ascending in time):

thr1 = 0.0067621339
thr2 = 3.*exp(-9./2.)

time = data[*,0]
flux = data[*,1]


ind1 = where(flux gt thr1)
t_start = time[ind1[0]]

ind2 = where(flux[ind1[0]:*] lt thr2)
t_end = (time[ind1[0]:*])[ind2[0]]

A few additional notes: you have specified that you'd like your flux to exceed a threshold, thr, but in your code you have specified flux/flux[0] > thr. I will assume that you want to measure the relative flux of your object (but in that case, why divide by the first element of the light curve and not median(flux)? In your plot statement above you also seem to normalize your times (data[0,*]/data[0,0]) - is this what you intended to do?

In defining your second threshold of 3*exp(-9/2) be carful; in IDL 9/2 is an integer division, and gives an answer of 4, not 4.5. Instead use 3.*exp(-9./2.).

Finally, I'm assuming your data is noisy (rather than a noiseless simulation). Do you really want to find the very first data point that exceeds the threshold (which could be due to a particularly large positive outlier?) or rather when a running mean/median (or other smoothed version of your data) exceeds the threshold? You can median filter your fluxes using e.g. median(flux, boxwidth)

trillian
  • 81
  • 1
  • 8