def lnlike(self, theta, parlist): param_vals = alter_fparams(self.fparams, parlist, theta) for key in self.fix_params: if key not in list(param_vals.keys()): param_vals[key] = self.fix_params[key] int_cc = ClusterCosmology( param_vals, self.constDict, clTTFixFile=self.clttfile) # internal HMF call int_HMF = Halo_MF(int_cc, self.mgrid, self.zgrid) # internal HMF call self.s8 = int_HMF.cc.s8 if np.nan_to_num(self.s8) < 0.1 or np.nan_to_num( self.s8) > 10. or not (np.isfinite(self.s8)): self.s8 = 0. dndm_int = int_HMF.inter_dndmLogm(200.) # delta = 200 cluster_prop = np.array( [self.clst_z, self.clst_zerr, 10**self.clst_m, self.clst_merr]) Ntot = self.Ntot_survey(int_HMF, self.fsky) print("Ntot comparion, and catalog") print(self.Ntot_survey_TEST(int_HMF, self.fsky), Ntot, len(self.clst_z)) Nind = 0 for i in range(len(self.clst_z)): N_per = self.Prob_per_cluster(int_HMF, cluster_prop[:, i], dndm_int) Nind = Nind + np.log(N_per) print("-NTOT, Nind, Total, As") print(-Ntot, Nind, -Ntot + Nind, theta) return -Ntot + Nind
def lnlike(self, theta, parlist): param_vals = alter_fparams(self.fparams, parlist, theta) for key in self.fix_params: if key not in list(param_vals.keys()): param_vals[key] = self.fix_params[key] print(param_vals) int_cc = ClusterCosmology( param_vals, self.constDict, clTTFixFile=self.clttfile) # internal HMF call int_HMF = Halo_MF(int_cc, self.mgrid, self.zgrid) # internal HMF call self.s8 = int_HMF.cc.s8 if np.nan_to_num(self.s8) < 0.1 or np.nan_to_num( self.s8) > 10. or not (np.isfinite(self.s8)): self.s8 = 0. # return -np.inf #dndm_int = int_HMF.inter_dndm(200.) # delta = 200 dndm_int = int_HMF.inter_dndmLogm(200.) # delta = 200 cluster_prop = np.array([ self.clst_z, self.clst_zerr, self.clst_y0 * 1e-4, self.clst_y0err * 1e-4 ]) if self.test: Ntot = 60. else: Ntot = 0. for i in range(len(self.frac_of_survey)): Ntot += self.Ntot_survey( int_HMF, self.area_rads * self.frac_of_survey[i], self.thresh_bin[i], param_vals) #print 'NTOT', Ntot Nind = 0 #Nind2 = 1. for i in range(len(self.clst_z)): N_per = self.Prob_per_cluster(int_HMF, cluster_prop[:, i], dndm_int, param_vals) #if (i < 3): #print np.log(N_per) Nind = Nind + np.log(N_per) #Nind2 *= N_per #print N_per print(-Ntot, Nind, -Ntot + Nind, theta) #, np.log(np.exp(-Ntot)*Nind2) return -Ntot + Nind
param_vals = lk.alter_fparams(fparams, parlist, parvals) cluster_props = np.array( [CL.clst_z, CL.clst_zerr, CL.clst_y0 * 1e-4, CL.clst_y0err * 1e-4]) start = time.time() int_cc = ClusterCosmology(param_vals, CL.constDict, clTTFixFile=CL.clttfile) print('CC', time.time() - start) start = time.time() int_HMF = Halo_MF(int_cc, CL.mgrid, CL.zgrid) print('HMF', time.time() - start) dn_dzdm_int = int_HMF.inter_dndmLogm(200.) zbins = 10 LgYa = np.outer(np.ones(len(int_HMF.M.copy())), CL.LgY) Y = 10**LgYa Ma = np.outer(int_HMF.M.copy(), np.ones(len(LgYa[0, :]))) clustind = 1 print(cluster_props[:, clustind]) print(parlist) print(parvals) print( "ln prob", np.log( CL.Prob_per_cluster(int_HMF, cluster_props[:, clustind], dn_dzdm_int, param_vals)))