def aband(x,y,z,antal,frekmin,frekmax,btype,fmin,fmax=None): #highpass if btype==1: [frek,p,a,b]=aft.aft(x,y,z,frekmin,frekmax,antal) [c,d]=bins.bins(frek,fmin) wp=awindow.awindow(x,z,frek) for j in range(len(y)): for i in range(d): y[j]=y[j]-(a[i]*sin(2*pi*frek[i]*x[j])+b[i]*cos(2*pi*frek[i]*x[j]))/(wp) return [y] #lowpass elif btype==2: [frek,p,a,b]=aft.aft(x,y,z,frekmin,frekmax,antal) [c,d]=bins.bins(frek,fmin) wp=awindow.awindow(x,z,frek) for j in range(len(y)): u=0 for i in range(c): u+=a[i]*sin(2*pi*frek[i]*x[j])+b[i]*cos(2*pi*frek[i]*x[j]) y[j]=u/(wp) return [y] #bandpass else: [frek,p,a,b]=aft.aft(x,y,z,frekmin,frekmax,antal) [c,d]=bins.bins(frek,fmin) [e,f]=bins.bins(frek,fmax) wp=awindow.awindow(x,z,frek) for j in range(len(y)): u=0 for i in range(c,f): u+=a[i]*sin(2*pi*frek[i]*x[j])+b[i]*cos(2*pi*frek[i]*x[j]) y[j]=u/float(wp) return [y]
def awindow(x,z,f): dx=abs(x[1]-x[0]) dfrek=(f[1]-f[0]) fnykvist=float(1)/(2*dx) fx=multiply(0.5*fnykvist,x) ysin=sin(2*pi*fx) ycos=cos(2*pi*fx) total=float(fnykvist)/dfrek num=int(round(0.90*total)) a=float(0.5*fnykvist-total*dfrek*0.45) b=float(0.5*fnykvist+total*dfrek*0.45) [f,psin,ee,rr]=aft.aft(x,ysin,None,a,b,num) [f,pcos,a,b]=aft.aft(x,ycos,None,a,b,num) rr=add(psin,pcos) rk=rr.sum() return 0.5*rk
def aclean(x,y,z=None,fmin=None,fmax=None,antal=None,cantal=None,fclean=None): if cantal==None: cantal=1 if fclean==None: fclean=[] pclean=[] while cantal > 0: q=0 ii=0 [f,p,a,b]=aft.aft(x,y,z,fmin,fmax,antal) for i in range(len(p)): if p[i] > q: q=p[i] ii=i fclean.append(f[ii]) pclean.append(p[ii]) y=subtract(y,(multiply(a[ii],sin(multiply(2*pi*f[ii],x)))+multiply(b[ii],cos(multiply(2*pi*f[ii],x))))) cantal=cantal-1 return [y,fclean,pclean]
num=5000 #da="centauriA1.dat" #da="kepler1.dat" #da="data0.dat" [x,y,z]=opendata.opendata(data=da) y=submean.submean(y) for i in range(len(x)): y[i]=float(y[i]) x[i]=float(x[i])#*(3600) # z[i]=1/float(z[i])**2 z=None nykvist=1/(2*(x[2]-x[1])) print nykvist #[y,f]=aband.aband(x,y,1000,z,0.0001,0.0021,3,0.0005,0.0015) [y]=aband.aband(x,y,z,num,0.1*nykvist,nykvist,2,0.4*nykvist,0.4*nykvist) [f,p,a,b]=aft.aft(x,y,z,0.1*nykvist,nykvist,num) f=multiply(1000,f) subplot(3,3,1) qq=[] uu=[] for i in range(10,len(f)/10): qq.append(auto.auto(f,p,i)) uu.append(i*(f[2]-f[1])) plot(p,f) ylabel('correlation') title('Low-pass 0.1-0.4 $f_{nykvist}$ Sun') legend()