In [4]:
from pangloss import BackgroundCatalog, ForegroundCatalog, \
TrueHaloMassDistribution, Kappamap, Shearmap
ITERATIONS = 4
RADIUS = 2.0
# initialize background and foreground
B = BackgroundCatalog(N=10.0, domain=[1.5, 1.4, -1.5, -1.4], field=[0, 0, 0, 0])
F = ForegroundCatalog.guo()
F.set_mass_prior(TrueHaloMassDistribution())
# initialize maps from Hilbert et al 2009
K = Kappamap.example()
S = Shearmap.example()
# run monte carlo samples
def pangloss_benchmark():
for _ in xrange(ITERATIONS):
F.draw_halo_masses()
B.drill_lightcones(radius=RADIUS, foreground=F, smooth_corr=False)
B.lens_by_map(K, S)
B.lens_by_halos(lookup_table=False, smooth_corr=False, relevance_lim=0)
B.halo_mass_log_likelihood()
import cProfile
cProfile.run('pangloss_benchmark()', filename='/Users/user/Desktop/pangloss_benchmark.pstats')
In [3]:
from massinference.angle import Angle
from massinference.catalog import SourceCatalogFactory, FastSampleHaloCatalogFactory, \
MutableHaloMassCatalog, SourceCatalog, HaloCatalog
from massinference.distribution import MassPrior
from massinference.inference import log_likelihood
from massinference.lenser import MapLenser
from massinference.lightcone import LightconeManager
from massinference.map import KappaMap, ShearMap
from massinference.plot import Limits
import cProfile
ITERATIONS = 4
RADIUS = 2.0
# run parameters
sigma_e = 0.2
random_seed = 1
source_density = 10.0
limits = Limits(Angle.from_degree(1.5), Angle.from_degree(1.4),
Angle.from_degree(-1.5), Angle.from_degree(-1.4))
limits_with_perimeter = limits.add_perimeter(Angle.from_arcmin(RADIUS))
# make a mock WL catalog, of observed, lensed, galaxy ellipticities:
source_factory = SourceCatalogFactory(limits, source_density, sigma_e)
source_catalog = source_factory.generate()
max_z = source_catalog.dataframe[SourceCatalog.Z].max()
e1, e2 = MapLenser(KappaMap.default(), ShearMap.default()).lens(source_catalog)
base_halo_catalog = MutableHaloMassCatalog.default(limits, max_z)
mass_prior = MassPrior(base_halo_catalog.dataframe[HaloCatalog.HALO_MASS].as_matrix())
halo_catalog_factory = FastSampleHaloCatalogFactory(base_halo_catalog,
mass_prior, random_seed)
lightcone_manager = LightconeManager(source_catalog, halo_catalog_factory, RADIUS)
def mass_inference_benchmark():
predictions = lightcone_manager.run(ITERATIONS)
log_likelihood(predictions, e1, e2, sigma_e)
cProfile.run('mass_inference_benchmark()', filename='/Users/user/Desktop/mass_inference_benchmark.pstats')
Next need to run:
In [10]:
from IPython.display import Image
Image('/Users/user/Desktop/pang_prof.png', width=1000)
Out[10]: