You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
760 B
Python
44 lines
760 B
Python
import numpy as np
|
|
|
|
|
|
|
|
def power_aver(kf,scales,pot,datadir):
|
|
|
|
|
|
keff=np.zeros((len(scales),2))
|
|
|
|
for s in range(len(scales)):
|
|
l=scales[s]
|
|
lz=scales[s]
|
|
|
|
nbx, nby, nbz= kf.shape[0]//l, kf.shape[1]//l,kf.shape[2]//l,
|
|
if nbz==0:
|
|
nbz=1
|
|
lz=1
|
|
|
|
res=np.zeros((nbx,nby,nbz))
|
|
|
|
for i in range(nbx):
|
|
for j in range(nby):
|
|
for k in range(nbz):
|
|
|
|
res[i,j,k]=np.mean(kf[i*l:(i+1)*l,j*l:(j+1)*l,k*lz:(k+1)*lz]**(1.0/pot))**(pot)
|
|
|
|
keff[s,0]=np.exp(np.mean(np.log(res)))
|
|
keff[s,01]=np.var(np.log(res))
|
|
np.save(datadir+'KpostProcess/Kpo'+str(scales[s])+'.npy',res)
|
|
return keff
|
|
|
|
|
|
rdir='./data/'
|
|
|
|
|
|
|
|
scales=np.array([4,8,16,32,64,128,256,512])
|
|
|
|
for i in range(3):
|
|
|
|
kf=np.load(rdir+str(i)+'/k.npy')
|
|
kpower=power_aver(kf,scales,3,rdir+str(i)+'/')
|
|
|