コード例 #1
0
ファイル: fermi_psf_study.py プロジェクト: olaurino/gammapy
def get_psf_table(psf, emin, emax, bins):
    """Returns a table of energy and containment radius
    from an EnergyDependentTablePSF object."""

    # Container for data
    data = []

    # Loop over energies and determine PSF containment radius
    ebounds = EnergyBounds.equal_log_spacing(emin, emax, bins, 'MeV')
    for energy in ebounds:
        energy_psf = psf.table_psf_at_energy(energy)

        containment_68 = energy_psf.containment_radius(0.68)
        containment_95 = energy_psf.containment_radius(0.95)

        row = dict(ENERGY=energy.value,
                   CONT_68=containment_68.value,
                   CONT_95=containment_95.value)

        data.append(row)

    # Construct table and add correct units to columns
    table = Table(data)
    table['ENERGY'].units = energy.unit
    table['CONT_68'].units = containment_68.unit
    table['CONT_95'].units = containment_95.unit

    return table
コード例 #2
0
def get_psf_table(psf, emin, emax, bins):
    """Returns a table of energy and containment radius
    from an EnergyDependentTablePSF object."""

    # Container for data
    data = []

    # Loop over energies and determine PSF containment radius
    ebounds = EnergyBounds.equal_log_spacing(emin, emax, bins, 'MeV')
    for energy in ebounds:
        energy_psf = psf.table_psf_at_energy(energy)

        containment_68 = energy_psf.containment_radius(0.68)
        containment_95 = energy_psf.containment_radius(0.95)

        row = dict(ENERGY=energy.value,
                   CONT_68=containment_68.value,
                   CONT_95=containment_95.value)

        data.append(row)

    # Construct table and add correct units to columns
    table = Table(data)
    table['ENERGY'].units = energy.unit
    table['CONT_68'].units = containment_68.unit
    table['CONT_95'].units = containment_95.unit

    return table
コード例 #3
0
"""Plot energy dispersion example."""
import numpy as np
import matplotlib.pyplot as plt
from gammapy.irf import EnergyDispersion
from gammapy.spectrum import EnergyBounds

ebounds = EnergyBounds.equal_log_spacing(0.1, 100, 100, 'TeV')
energy_dispersion = EnergyDispersion.from_gauss(ebounds, sigma=0.3)

energy_dispersion.plot(type='matrix')
plt.show()