【发布时间】:2018-06-12 12:27:43
【问题描述】:
我有一个由时间和通量组成的数据(4117 行 x 2 列)我想计算并绘制与图片相同的两个连续数据点对之间亮度变化的数量分布distribution of brightness variation
这是我在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
当我运行代码时, dc 的所有值都是 4116 。我认为我计算 dc 的方式是错误的。任何建议以正确的方式做到这一点?
【问题讨论】: