Update ring_background_estimate function
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import absolute_import, division, print_function, unicode_literals
+from regions import CircleSkyRegion
from .ring import ring_area_factor
__all__ = [
@@ -67,14 +68,34 @@ def ring_background_estimate(pos, on_radius, inner_radius, outer_radius, events)
----------
pos : `~astropy.coordinates.SkyCoord`
On region radius
+ on_radius : `~astropy.coordinates.Angle`
+ On region radius
inner_radius, outer_radius : `~astropy.coordinates.Angle`
Inner and outer ring radius
events : `~gammapy.data.EventList`
- Events
+ Event list
+
+ Returns
+ -------
+ bkg : `~gammapy.data.BackgroundEstimate`
+ Background estimate
"""
- off_events = events.select_sky_ring(pos, inner_radius, outer_radius)
+ on_region = CircleSkyRegion(center=pos, radius=on_radius)
+ on_events = events.select_circular_region(on_region)
+
off_region = dict(inner=inner_radius, outer=outer_radius)
+ off_events = events.select_sky_ring(pos, inner_radius, outer_radius)
+
+ # TODO: change to region areas here (e.g. in steratian?)
a_on = 1
a_off = ring_area_factor(on_radius, inner_radius, outer_radius).value
- return BackgroundEstimate(off_region, off_events, a_on, a_off, tag='ring')
+ return BackgroundEstimate(
+ on_region=on_region,
+ on_events=on_events,
+ off_region=off_region,
+ off_events=off_events,
+ a_on=a_on,
+ a_off=a_off,
+ method='ring',
+ )
