def log_prob_non_detected_galaxies(self, x): # controllo finitezza e theta(M-Mth) self.omega.h = x['h'] self.omega.om = x['om'] self.omega.ol = x['ol'] zgal = x['zgal'] mgal = x['mgal'] logP = 0.0 DL = lal.LuminosityDistance(self.omega, zgal) Mth = Mthreshold(DL) Mabsi = mabs(mgal, DL) if Mthreshold(DL) > Mabsi: return -np.inf else: # compute the allowed volume for the source gDL = 33.4 gdDL = 3.34 V = (4. / 3.) * np.pi * (gDL - gdDL)**3 # find the number density of galaxies from the low end of the Schecter # distribution n0 = 1. / normalise(self.omega, Mmax=Mth) K = np.int(V * n0) - len(self.catalog) if K <= 0.0: # no galaxies are missing return -np.inf logP += np.log(Schechter(Mabsi, self.omega)) logP += np.log(lal.ComovingVolumeElement(zgal, self.omega)) # norm = np.log(dblquad(normalise_integrand, self.bounds[0][0], self.bounds[0][1], # lambda x: mabs(mgal,lal.LuminosityDistance(self.omega, self.bounds[4][0])), # lambda x: mabs(mgal,lal.LuminosityDistance(self.omega, self.bounds[4][0])), # args = (self.omega, 1, ))[0]) # since for alpha < 0.0 the Schecter distribution diverges, approximate the integral with the # maximum of the integral norm = K * (np.log( Schechter( mabs(self.bounds[4][1], lal.LuminosityDistance( self.omega, self.bounds[0][1])), self.omega)) + np.log( lal.ComovingVolumeElement(self.bounds[0][1], self.omega))) return K * (logP - norm)
def log_prior(self, x): # controllo finitezza e theta(M-Mth) if not(np.isfinite(super(completeness, self).log_prior(x))): return -np.inf else: self.omega.h = x['h'] self.omega.om = x['om'] self.omega.ol = x['ol'] zgw = x['z'] logP = 0.0 for zi,mi in zip(self.catalog['z'],self.catalog['Bmag']): DL = lal.LuminosityDistance(self.omega, zi) Mabsi = mabs(mi,DL) if Mthreshold(DL) < Mabsi: return -np.inf else: # Update parametri cosmologici con simulazione # Calcolo prior. Ciascuna coordinata è pesata con le probabilità # delle coordinate ('banane') GW, così come z. # Temporaneamente, è assunta gaussiana intorno a un evento. logP += np.log(Schechter(Mabsi, self.omega)) #log_P_RA = np.log(gaussian(x['ra'],Gal.ra.rad,Gal.ra.rad/100.)) #log_P_DEC = np.log(gaussian(x['dec'],Gal.dec.rad,Gal.dec.rad/100.)) logP += np.log(lal.ComovingVolumeElement(zi, self.omega)) return logP
def log_prior(self, x): if not (np.isfinite(super(completeness, self).log_prior(x))): return -np.inf else: self.omega.h = x['h'] self.omega.om = x['om'] self.omega.ol = x['ol'] logP = np.log(lal.ComovingVolumeElement(x['redshift'], self.omega)) return logP
def log_prob_detected_galaxies(self, x): # controllo finitezza e theta(M-Mth) self.omega.h = x['h'] self.omega.om = x['om'] self.omega.ol = x['ol'] zgw = x['zgw'] logP = 0.0 Vmax = lal.ComovingVolume(self.omega, self.bounds[0][1]) for zi, mi in zip(self.catalog['z'], self.catalog['Bmag']): DL = lal.LuminosityDistance(self.omega, zi) Mabsi = mabs(mi, DL) if Mthreshold(DL) < Mabsi: return -np.inf else: logP += np.log(Schechter(Mabsi, self.omega)) logP += np.log( lal.ComovingVolumeElement(zi, self.omega) / Vmax) return logP
def log_prob_detected_galaxies(self, x): # controllo finitezza e theta(M-Mth) if not (np.isfinite(super(completeness, self).log_prior(x))): return -np.inf else: self.omega.h = x['h'] self.omega.om = x['om'] self.omega.ol = x['ol'] zgw = x['zgw'] logP = 0.0 for zi, mi in zip(self.catalog['z'], self.catalog['Bmag']): DL = lal.LuminosityDistance(self.omega, zi) Mabsi = mabs(mi, DL) if Mthreshold(DL) < Mabsi: return -np.inf else: logP += np.log(Schechter(Mabsi, self.omega)) logP += np.log(lal.ComovingVolumeElement(zi, self.omega)) return logP
def log_prob_non_detected_galaxies(self, x): # controllo finitezza e theta(M-Mth) if not (np.isfinite(super(completeness, self).log_prior(x))): return -np.inf else: self.omega.h = x['h'] self.omega.om = x['om'] self.omega.ol = x['ol'] zgal = x['zgal'] mgal = x['mgal'] logP = 0.0 K = 38 DL = lal.LuminosityDistance(self.omega, zgal) Mabsi = mabs(mgal, DL) if Mthreshold(DL) > Mabsi: print(Mthreshold(DL), Mabsi) return -np.inf else: logP += np.log(Schechter(Mabsi, self.omega)) logP += np.log(lal.ComovingVolumeElement(zgal, self.omega)) return K * logP
def log_prior(self, x): # controllo finitezza e theta(M-Mth) if not (np.isfinite(super(completeness, self).log_prior(x))): return -np.inf else: if x['M'] > Mthreshold(x['z'], self.omega): return -np.inf else: # Update parametri cosmologici con simulazione self.omega.h = x['h'] self.omega.om = x['om'] self.omega.ol = x['ol'] # Calcolo prior. Ciascuna coordinata è pesata con le probabilità # delle coordinate ('banane') GW, così come z. # Temporaneamente, è assunta gaussiana intorno a un evento. log_P_Z = np.log(gaussian(x['z'], Gal.z, Gal.z / 10.0)) log_P_S = np.log(Schechter(x['M'], self.omega)) log_P_RA = np.log( gaussian(x['ra'], Gal.ra.rad, Gal.ra.rad / 100.)) log_P_DEC = np.log( gaussian(x['dec'], Gal.dec.rad, Gal.dec.rad / 100.)) log_P_ComVol = np.log( lal.ComovingVolumeElement(x['z'], self.omega)) return log_P_S + log_P_Z + log_P_ComVol + log_P_RA + log_P_DEC
def normalise_integrand(M, z, omega, K): PS = Schechter(M, omega) PV = lal.ComovingVolumeElement(z, omega) # print(" ==== integrand ===",PS,PV,K,PS*PV,(PS*PV)**K) return (PS * PV)**K