Example #1
0
def plot_psf_king(chain='hd'):
    psf = load_psf(chain=chain)
    gamma = EnergyOffsetArray(energy=psf.energy, offset=psf.offset,
                              data=psf.gamma, data_units=psf.gamma.unit)
    sigma = EnergyOffsetArray(energy=psf.energy, offset=psf.offset,
                              data=psf.sigma, data_units=psf.sigma.unit)

    # For now, let's use Gammalib to compute containment radii
    gpsf = load_psf(chain=chain, tool='gammalib')
    r68 = containment_radius(gpsf, 0.68, psf.energy, psf.offset)
    r68 = EnergyOffsetArray(energy=psf.energy, offset=psf.offset,
                            data=r68, data_units='deg')

    import matplotlib.pyplot as plt
    fig, ax = plt.subplots(1, 3, figsize=(10, 3))
    gamma.plot_image(ax=ax[0])
    sigma.plot_image(ax=ax[1])
    r68.plot_image(ax=ax[2], vmin=0, vmax=0.3)
    # import IPython; IPython.embed()
    # ax[2].colorbar()
    fig.tight_layout()
    # fig.show()
    filename = 'test_psf_king_{}.png'.format(chain)
    print('Writing {}'.format(filename))
    fig.savefig(filename)
def make_counts_array():
    """Make an example counts array with energy and offset axes."""
    data_store = DataStore.from_dir(gammapy_extra.dir / 'datasets/hess-crab4')

    event_lists = data_store.load_all('events')
    ebounds = EnergyBounds.equal_log_spacing(0.1, 100, 100, 'TeV')
    offset = np.linspace(0, 2.5, 100)
    array = EnergyOffsetArray(ebounds, offset)
    array.fill_events(event_lists)

    return array
def make_counts_array():
    """Make an example counts array with energy and offset axes."""
    data_store = DataStore.from_dir('$GAMMAPY_EXTRA/datasets/hess-crab4-hd-hap-prod2')

    event_lists = data_store.load_all('events')
    ebounds = EnergyBounds.equal_log_spacing(0.1, 100, 100, 'TeV')
    offset = Angle(np.linspace(0, 2.5, 100), "deg")
    array = EnergyOffsetArray(ebounds, offset)
    array.fill_events(event_lists)

    return array
Example #4
0
def plot_psf_king(chain='hd'):
    psf = load_psf(chain=chain)
    gamma = EnergyOffsetArray(energy=psf.energy,
                              offset=psf.offset,
                              data=psf.gamma,
                              data_units=psf.gamma.unit)
    sigma = EnergyOffsetArray(energy=psf.energy,
                              offset=psf.offset,
                              data=psf.sigma,
                              data_units=psf.sigma.unit)

    # For now, let's use Gammalib to compute containment radii
    gpsf = load_psf(chain=chain, tool='gammalib')
    r68 = containment_radius(gpsf, 0.68, psf.energy, psf.offset)
    r68 = EnergyOffsetArray(energy=psf.energy,
                            offset=psf.offset,
                            data=r68,
                            data_units='deg')

    import matplotlib.pyplot as plt
    fig, ax = plt.subplots(1, 3, figsize=(10, 3))
    gamma.plot_image(ax=ax[0])
    sigma.plot_image(ax=ax[1])
    r68.plot_image(ax=ax[2], vmin=0, vmax=0.3)
    # import IPython; IPython.embed()
    # ax[2].colorbar()
    fig.tight_layout()
    # fig.show()
    filename = 'test_psf_king_{}.png'.format(chain)
    print('Writing {}'.format(filename))
    fig.savefig(filename)