I have a data consist of time and flux (4117 rows x 2 columns) I want to calculate and plot the number distribution of brightness variation between all pairs of two consecutive data points same as the picture distribution of brightness variation
This is the code I used in idl
nx=4117
t=fltarr(nx)
f=fltarr(nx)
df=fltarr(nx-1)
dt=fltarr(nx-1)
n=4116
dff=fltarr(n)
dc=fltarr(n-1)
data=read_table('data.dat')
;print,data(0,*) ;this is t (time)
;print,data(1,*) ;this is f (flux)
; Plot the light curve
window,0
plot,data(0,*)/data(0,0),data(1,*)/data(1,0),yrange=[0.93,1.1],ystyle=1
; calculate the flux difference (dff)
for i=0,nx-2 do begin
df(i)=data(1,i+1)/data(1,0) - data(1,i)/data(1,0)
dt(i)=data(0,i+1)/data(0,0) - data(0,i)/data(0,0)
endfor
for i=0,n-1 do dff(i)=min(df)+i*(max(df)-min(df))/float(n-1.0)
print,dff
; calculate the number distribution (dc), I want the counter to reset to zero after every point and start to count again
for i=0,n-2 do begin
c=0.0
for j=0,nx-2 do begin
IF (df(j) < dff(i+1)) or (df(j) > dff(i)) THEN begin
c=c+1
dc(i)=c
endif
endfor
print, dc(i)
endfor
end
when I run the code all the value of dc is 4116 . I think the way I calculated dc is wrong. Any suggestion to do this in proper way?