def transform(self, maps): """ This function transforms from distance to redshift. Parameters ---------- maps : a mapping object Examples -------- Convert a dict of numpy.array: >>> import numpy >>> from pycbc import transforms >>> t = transforms.DistanceToRedshift() >>> t.transform({'distance': numpy.array([1000])}) {'distance': array([1000]), 'redshift': 0.19650987609144363} Returns ------- out : dict A dict with key as parameter name and value as numpy.array or float of transformed values. """ out = { parameters.redshift: cosmology.redshift(maps[parameters.distance]) } return self.format_output(maps, out)
def transform(self, maps): """ This function transforms from distance to redshift. Parameters ---------- maps : a mapping object Examples -------- Convert a dict of numpy.array: >>> import numpy >>> from pycbc import transforms >>> t = transforms.DistanceToRedshift() >>> t.transform({'distance': numpy.array([1000])}) {'distance': array([1000]), 'redshift': 0.19650987609144363} Returns ------- out : dict A dict with key as parameter name and value as numpy.array or float of transformed values. """ out = {parameters.redshift : cosmology.redshift( maps[parameters.distance])} return self.format_output(maps, out)
# eos=EOS_BPSwithPoly([baryon_density0,p1,baryon_density1,p2,baryon_density2,p3,baryon_density3]) # maxmass_result=Maxmass(Preset_Pressure_final,Preset_rtol,eos) # args=[eos,maxmass_result[1],maxmass_result[2]] # Lambda_list=[] # for mass_i in mass: # if(mass_i>args[2]): # Lambda_list.append(0) # else: # ofmass_result=Properity_ofmass(mass_i,Preset_pressure_center_low,args[1],MassRadius,Preset_Pressure_final,Preset_rtol,Preset_Pressure_final_index,args[0]) # Lambda_list.append(ofmass_result[5]) # return Lambda_list # ============================================================================= from pycbc import cosmology distance = 40.7 # in Mpc redshift = cosmology.redshift(distance) import h5py filename = 'uniform_mass_prior_common_eos_20hz_lowfreq_posteriors.hdf' fp = h5py.File(filename, "r") print fp.attrs['variable_args'] m1 = (fp['samples/mass1'][:100] / (1 + redshift)).flatten() m2 = (fp['samples/mass2'][:100] / (1 + redshift)).flatten() Lambdasym = (fp['samples/lambdasym'][:100]).flatten() q = m2 / m1 fp.close() Lambda1 = Lambdasym * (m2 / m1)**3 Lambda2 = Lambdasym * (m1 / m2)**3 array_mass = np.concatenate((m1, m2)) array_log10_Lambda = np.log10(np.concatenate((Lambda1, Lambda2))) array_mass = np.array([1.3, 1.4])