Ejemplo n.º 1
0
"""Produces an image from 1FHL catalog point sources.
"""
from gammapy.datasets import FermiGalacticCenter
from gammapy.image import make_empty_image, catalog_image

# Create image of defined size
reference = make_empty_image(nxpix=3600, nypix=1800, binsz=0.1)
psf_file = FermiGalacticCenter.psf()

# Create image
image = catalog_image(reference,
                      psf,
                      catalog='1FHL',
                      source_type='point',
                      total_flux='True')
hdu = image.to_fits()[0]
hdu.writeto('Image_1FHL.fits', clobber=True)
Ejemplo n.º 2
0
"""Produces an image from 1FHL catalog point sources.
"""
from gammapy.datasets import FermiGalacticCenter
from gammapy.image import make_empty_image, catalog_image

# Create image of defined size
reference = make_empty_image(nxpix=3600, nypix=1800, binsz=0.1)
psf_file = FermiGalacticCenter.psf()

# Create image
image = catalog_image(reference, psf, catalog='1FHL', source_type='point',
                  total_flux='True')
hdu = image.to_fits()[0]
hdu.writeto('Image_1FHL.fits', clobber=True)

Ejemplo n.º 3
0
# Minimum source luminosity (ph s^-1)
luminosity_min = 4e34
# Maximum source luminosity (ph s^-1)
luminosity_max = 4e37
# Luminosity function differential power-law index
luminosity_index = 1.5

# Assigns luminosities to sources
luminosity = sample_powerlaw(luminosity_min, luminosity_max, luminosity_index,
                             n_sources, random_state=0)
table['luminosity'] = luminosity

# Adds parameters to table: distance, glon, glat, flux, angular_extension
table = population.add_observed_parameters(table)
table.meta['Energy Bins'] = np.array([10, 500]) * u.GeV
# Create image
image = catalog_image(reference, psf, catalog='simulation', source_type='point',
                      total_flux=True, sim_table=table)

# Plot
fig = FITSFigure(image.to_fits()[0], figsize=(15, 5))
fig.show_colorscale(interpolation='bicubic', cmap='afmhot', stretch='log', vmin=1E30, vmax=1E35)
fig.tick_labels.set_xformat('ddd')
fig.tick_labels.set_yformat('dd')
ticks = np.logspace(30, 35, 6)
fig.add_colorbar(ticks=ticks, axis_label_text='Flux (ph s^-1)')
fig.colorbar._colorbar_axes.set_yticklabels(['{:.0e}'.format(_) for _ in ticks])
plt.tight_layout()
plt.show()
Ejemplo n.º 4
0
# Assigns luminosities to sources
luminosity = sample_powerlaw(luminosity_min,
                             luminosity_max,
                             luminosity_index,
                             n_sources,
                             random_state=0)
table['luminosity'] = luminosity

# Adds parameters to table: distance, glon, glat, flux, angular_extension
table = population.add_observed_parameters(table)
table.meta['Energy Bins'] = np.array([10, 500]) * u.GeV
# Create image
image = catalog_image(reference,
                      psf,
                      catalog='simulation',
                      source_type='point',
                      total_flux=True,
                      sim_table=table)

# Plot
fig = FITSFigure(image.to_fits()[0], figsize=(15, 5))
fig.show_colorscale(interpolation='bicubic',
                    cmap='afmhot',
                    stretch='log',
                    vmin=1E30,
                    vmax=1E35)
fig.tick_labels.set_xformat('ddd')
fig.tick_labels.set_yformat('dd')
ticks = np.logspace(30, 35, 6)
fig.add_colorbar(ticks=ticks, axis_label_text='Flux (ph s^-1)')
fig.colorbar._colorbar_axes.set_yticklabels(
Ejemplo n.º 5
0
    n_sources=n_sources, rad_dis=rad_dis, vel_dis=vel_dis, max_age=1e6, spiralarms=spiralarms, random_state=0
)

# Minimum source luminosity (ph s^-1)
luminosity_min = 4e34
# Maximum source luminosity (ph s^-1)
luminosity_max = 4e37
# Luminosity function differential power-law index
luminosity_index = 1.5

# Assigns luminosities to sources
luminosity = sample_powerlaw(luminosity_min, luminosity_max, luminosity_index, n_sources, random_state=0)
table["luminosity"] = luminosity

# Adds parameters to table: distance, glon, glat, flux, angular_extension
table = population.add_observed_parameters(table)
table.meta["Energy Bins"] = np.array([10, 500]) * u.GeV
# Create image
image = catalog_image(reference, psf, catalog="simulation", source_type="point", total_flux=True, sim_table=table)

# Plot
fig = FITSFigure(image.to_fits(format="fermi-background")[0], figsize=(15, 5))
fig.show_colorscale(interpolation="bicubic", cmap="afmhot", stretch="log", vmin=1e30, vmax=1e35)
fig.tick_labels.set_xformat("ddd")
fig.tick_labels.set_yformat("dd")
ticks = np.logspace(30, 35, 6)
fig.add_colorbar(ticks=ticks, axis_label_text="Flux (ph s^-1)")
fig.colorbar._colorbar_axes.set_yticklabels(["{:.0e}".format(_) for _ in ticks])
plt.tight_layout()
plt.show()