예제 #1
0
def hkfunc(par, kmin, kmax, Nk):
  d, rho, A = par[0], par[1], par[2]
  d0 = 1.0
  y = np.pi * rho * d0**3 / 6.0

  xmin = 1.0 / kmax
  xmax = 1.0 / kmin

  fcx = lambda x : cxfunc(y, x)
  k, ck = xicalc(fcx, int(Nk), xmin, xmax, kmin)

  hk = 8 * np.pi**3 * ck / (1 - 24 * y * ck * 2 * np.pi**2)
  k /= d
  hk *= A

  return [k, hk]
예제 #2
0
from FFTlog import xicalc
from params import *
from fitfunc import *
path = "/hpcstorage/zhaoc/share/ting/powspec_fitting/HSfit_4/input/mocks_ori"
files = os.listdir(path)
files.sort()
for i in range(0, len(files)):
    name = files[i]
    file_k, file_pk, file_var = np.loadtxt(
        "/hpcstorage/zhaoc/share/ting/powspec_fitting/HSfit_4/input/mocks_ori/%s"
        % name,
        usecols=(0, 1, 2),
        unpack=True)
    fk = interp1d(file_k, file_pk, kind='cubic')
    fhk = lambda k: fk(k)
    r, chi = xicalc(fhk, int(model_Nk), np.min(file_k), np.max(file_k), 0.01)
    np.savetxt(
        "/hpcstorage/zhaoc/share/ting/2PCF_disjoint_voids/powspec_correlation_function_auto_disjoint_16/%s"
        % name,
        np.transpose([r, chi]),
        fmt='%g')
#kk = fk()
#plt.figure(figsize=(20,20))
#plt.plot(k_test,P_test, label = "power - spectrum - test")
#plt.plot(k_lin,P_lin, label = "power - spectrum - lin_nw")
#plt.plot(kb,Pb, label = "power - spectrum - auto - correlation - model")
#plt.errorbar(kd,Pkd, yerr=Variance_1, label = "power - spectrum - voids - original")
#plt.fill_between(kd, Pkd - Variance_1, Pkd + Variance_1, color='red', alpha=0.2)

#plt.errorbar(kd_PACHY,Pkd_PACHY, yerr=Variance_1_PACHY, label = "power - spectrum - voids - PACHY")
#plt.fill_between(kd_PACHY, Pkd_PACHY - Variance_1_PACHY, Pkd_PACHY + Variance_1_PACHY, color='red', alpha=0.2)
예제 #3
0
k_test, P_test = hkfunc([33.2, 0.32, 43000], model_kmin, model_kmax, model_Nk)
fk = interp1d(k_test, P_test, kind='cubic')

#for i in range(len(k_test)):
#  if k_test[i]>0.6:
#    P_test[i]=0
#fk = interp1d(k_test, P_test, kind='cubic')
#k_test = k_test[0.00001<k_test]
#P_test = fk(k_test)

#P_test = fk(kd)
#k_test = kd
fhk = lambda k: fk(k)
#print(np.min(k_test),np.max(k_test))
r, chi = xicalc(fhk, int(model_Nk), np.min(k_test), np.max(k_test), 0.01)
np.savetxt("correlation function.dat", np.transpose([r, chi]), fmt='%g')
fk_1 = interp1d(kd, Pkd, kind='cubic')
fhk_1 = lambda k: fk_1(k)
#print(np.min(k_test),np.max(k_test))
r_1, chi_1 = xicalc(fhk_1, int(model_Nk), np.min(kd), np.max(kd), 0.01)

fk_2 = interp1d(kd_PACHY, Pkd_PACHY, kind='cubic')
fhk_2 = lambda k: fk_2(k)
#print(np.min(k_test),np.max(k_test))
r_2, chi_2 = xicalc(fhk_2, int(model_Nk), np.min(kd_PACHY), np.max(kd_PACHY),
                    0.01)

x = np.linspace(0.5, 195.5, 100)
#kk = fk()
plt.figure(figsize=(20, 20))