The gammapy.astro.population package contains some simple Galactic source population models.
Here we provide some Python code to compute observable parameter distributions for Galactic gamma-ray source populations.
References:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import astropy.units as u
from gammapy.utils.random import sample_powerlaw
from gammapy.astro import population
# Spatial distribution using Lorimer (2006) model
n_sources = int(1e5)
table = population.make_base_catalog_galactic(
n_sources=n_sources,
rad_dis="L06",
vel_dis="F06B",
max_age=1e6 * u.yr,
spiralarms=True,
)
Several source population models, e.g. the 1FHL paper or Strong (2007), use power-law luminosity functions.
Here we implement the "reference model" from the 1FHL catalog paper section 6.2.
# Source luminosity (ph s^-1)
luminosity = sample_powerlaw(x_min=1e34, x_max=1e37, gamma=1.5, size=n_sources)
table["luminosity"] = luminosity
table = population.add_observed_parameters(table)
table.info()
The simulation is done, you could save the simulated catalog to a file.
Here we just plot a few distributions to check if the results look OK.
plt.scatter(table["x"][:1000], table["y"][:1000]);
plt.hist(table["GLON"], bins=100);
plt.hist(table["GLAT"], bins=100, log=True);
plt.scatter(table["GLON"][:1000], table["GLAT"][:1000]);
plt.hist(table["distance"], bins=100, log=True);
plt.hist(np.log10(table["luminosity"]), bins=100, log=True);
plt.hist(np.log10(table["flux"]), bins=100, log=True);
# TODO: plot GLON, GLAT, FLUX distribution
TODO
# Start exercises here
TODO: summarise what was done here briefly.
TODO: add some pointers to other documentation.