files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import pytest
  import astropy.units as u
  from ....utils.testing import assert_quantity_allclose, requires_data, requires_dependency
  from ....maps import WcsGeom
  from .. import JFactory, DMFluxMapMaker, profiles, PrimaryFlux
  
  
  @pytest.fixture(scope="session")
  def geom():
      return WcsGeom.create(binsz=0.5, npix=10)
  
  
  @pytest.fixture(scope="session")
  def jfact():
      jfactory = JFactory(geom=geom(), profile=profiles.NFWProfile(), distance=8 * u.kpc)
      return jfactory.compute_jfactor()
  
  
  @pytest.fixture(scope="session")
  def prim_flux():
      return PrimaryFlux(mDM=1 * u.TeV, channel="W")
  
  
  @requires_dependency('scipy')
  @requires_data('gamm
  
  [... the rest is omitted ...]
files.new_path: gammapy/astro/darkmatter/tests/test_utils.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import pytest
  import astropy.units as u
  from ....utils.testing import assert_quantity_allclose, requires_data, requires_dependency
  from ....maps import WcsGeom
  from .. import JFactory, DMFluxMapMaker, profiles, PrimaryFlux
  
  
  @pytest.fixture(scope="session")
  def geom():
      return WcsGeom.create(binsz=0.5, npix=10)
  
  
  @pytest.fixture(scope="session")
  def jfact():
      jfactory = JFactory(ref_geom=geom(), profile=profiles.NFWProfile(), distance=8 * u.kpc)
      return jfactory.compute_jfactor()
  
  
  @pytest.fixture(scope="session")
  def prim_flux():
      return PrimaryFlux(mDM=1 * u.TeV, channel="W")
  
  
  @requires_dependency('scipy')
  @requires_data('g
  
  [... the rest is omitted ...]
files.old_path: gammapy/astro/darkmatter/tests/test_utils.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  Utilities to compute J-factor maps
  """
  from __future__ import absolute_import, division, print_function, unicode_literals
  import astropy.units as u
  import numpy as np
  
  __all__ = [
      'JFactory',
      'DMFluxMapMaker',
  ]
  
  
  class JFactory(object):
      """Compute J-Factor maps
  
      All J-Factors are computed for annihilation. The assumend dark matter
      profiles will be centered on the center of the map
  
      Parameters
      ----------
      geom : `~gammapy.maps.WcsGeom`
          Reference geometry
      profile : `~gammapy.astro.darkmatter.profiles.DMProfile`
          Dark matter profile
      distance : `~astropy.units.Quantity`
          Distance to convert angular scale of the map
      """
  
      def __init__(self, geom, profile, distance):
          self.geom = geom
          self.profile = profile
  
  [... the rest is omitted ...]
files.new_path: gammapy/astro/darkmatter/utils.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  """
  Utilities to compute J-factor maps
  """
  from __future__ import absolute_import, division, print_function, unicode_literals
  import astropy.units as u
  import numpy as np
  
  __all__ = [
      'JFactory',
      'DMFluxMapMaker',
  ]
  
  
  class JFactory(object):
      """Compute J-Factor maps
  
      All J-Factors are computed for annihilation. The assumend dark matter
      profiles will be centered on the center of the map
  
      Parameters
      ----------
      ref_geom : `~gammapy.maps.WcsGeom`
          Reference geometry
      profile : `~gammapy.astro.darkmatter.profiles.DMProfile`
          Dark matter profile
      distance : `~astropy.units.Quantity`
          Distance to convert angular scale of the map
      """
  
      def __init__(self, ref_geom, profile, distance):
          self.ref_geom = ref_geom
  
  [... the rest is omitted ...]
files.old_path: gammapy/astro/darkmatter/utils.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy as np
  from astropy.coordinates import Angle
  from astropy.units import Quantity
  from ..maps import WcsNDMap
  
  __all__ = [
      'make_map_background_irf',
      'make_map_background_fov',
  ]
  
  
  def make_map_background_irf(pointing, livetime, bkg, geom, offset_max, n_integration_bins=1):
      """Compute background map from background IRFs.
  
      TODO: Call a method on bkg that returns integral over energy bin directly
      Related: https://github.com/gammapy/gammapy/pull/1342
  
      Parameters
      ----------
      pointing : `~astropy.coordinates.SkyCoord`
          Pointing direction
      livetime : `~astropy.units.Quantity`
          Observation livetime
      bkg : `~gamm
  
  [... the rest is omitted ...]
files.new_path: gammapy/cube/background.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy as np
  from astropy.coordinates import Angle
  from astropy.units import Quantity
  from ..maps import WcsNDMap
  
  __all__ = [
      'make_map_background_irf',
      'make_map_background_fov',
  ]
  
  
  def make_map_background_irf(pointing, livetime, bkg, ref_geom, offset_max, n_integration_bins=1):
      """Compute background map from background IRFs.
  
      TODO: Call a method on bkg that returns integral over energy bin directly
      Related: https://github.com/gammapy/gammapy/pull/1342
  
      Parameters
      ----------
      pointing : `~astropy.coordinates.SkyCoord`
          Pointing direction
      livetime : `~astropy.units.Quantity`
          Observation livetime
      bkg : `~
  
  [... the rest is omitted ...]
files.old_path: gammapy/cube/background.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  from ..maps import WcsNDMap
  
  __all__ = [
      'fill_map_counts',
      'make_map_counts',
  ]
  
  
  def fill_map_counts(count_map, event_list):
      """Fill events into a counts map.
  
      The energy of the events is used for a non-spatial axis homogeneous to energy.
      The other non-spatial axis names should have an entry in the column names of the ``EventList``
  
      Parameters
      ----------
      count_map : `~gammapy.maps.Map`
          Map object, will be filled by this function.
      event_list : `~gammapy.data.EventList`
          Event list
      """
      geom = count_map.geom
  
      # Make a coordinate dictionary; skycoord is always added
      coord_dict = dict(skycoord=event_list.radec)
  
      # Now add one coordinate for each extra map
  
  [... the rest is omitted ...]
files.new_path: gammapy/cube/counts.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  from ..maps import WcsNDMap
  
  __all__ = [
      'fill_map_counts',
      'make_map_counts',
  ]
  
  
  def fill_map_counts(count_map, event_list):
      """Fill events into a counts map.
  
      The energy of the events is used for a non-spatial axis homogeneous to energy.
      The other non-spatial axis names should have an entry in the column names of the ``EventList``
  
      Parameters
      ----------
      count_map : `~gammapy.maps.Map`
          Map object, will be filled by this function.
      event_list : `~gammapy.data.EventList`
          Event list
      """
      geom = count_map.geom
  
      # Make a coordinate dictionary; skycoord is always added
      coord_dict = dict(skycoord=event_list.radec)
  
      # Now add one coordinate for each extra map
  
  [... the rest is omitted ...]
files.old_path: gammapy/cube/counts.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy as np
  from ..maps import WcsNDMap
  
  __all__ = [
      'make_map_exposure_true_energy',
  ]
  
  
  def make_map_exposure_true_energy(pointing, livetime, aeff, geom, offset_max):
      """Compute exposure WcsNDMap in true energy (i.e. not convolved by Edisp).
  
      Parameters
      ----------
      pointing : `~astropy.coordinates.SkyCoord`
          Pointing direction
      livetime : `~astropy.units.Quantity`
          Livetime
      aeff : `~gammapy.irf.EffectiveAreaTable2D`
          Effective area table
      geom : `~gammapy.maps.WcsGeom`
          Reference WcsGeom object used to define geometry (space - energy)
      offset_max : `~astropy.coordinates.A
  
  [... the rest is omitted ...]
files.new_path: gammapy/cube/exposure.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy as np
  from ..maps import WcsNDMap
  
  __all__ = [
      'make_map_exposure_true_energy',
  ]
  
  
  def make_map_exposure_true_energy(pointing, livetime, aeff, ref_geom, offset_max):
      """Compute exposure WcsNDMap in true energy (i.e. not convolved by Edisp).
  
      Parameters
      ----------
      pointing : `~astropy.coordinates.SkyCoord`
          Pointing direction
      livetime : `~astropy.units.Quantity`
          Livetime
      aeff : `~gammapy.irf.EffectiveAreaTable2D`
          Effective area table
      ref_geom : `~gammapy.maps.WcsGeom`
          Reference WcsGeom object used to define geometry (space - energy)
      offset_max : `~ast
  
  [... the rest is omitted ...]
files.old_path: gammapy/cube/exposure.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from astropy.utils.console import ProgressBar
  from astropy.nddata.utils import PartialOverlapError
  from astropy.coordinates import Angle
  from ..maps import WcsNDMap
  from .counts import make_map_counts
  from .exposure import make_map_exposure_true_energy
  from .background import make_map_background_irf, make_map_background_fov
  
  __all__ = [
      'MapMaker',
  ]
  
  log = logging.getLogger(__name__)
  
  
  class MapMaker(object):
      """Make all basic maps from observations.
  
      Parameters
      ----------
      geom : `~gammapy.maps.WcsGeom`
          Reference image geometry
      offset_max : `~astropy.coordinates.Angle`
          Maximum offset angle
      cutout_mode : {'trim', 'strict'}, optional
          Options for making cutouts, see
  
  [... the rest is omitted ...]
files.new_path: gammapy/cube/make.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import logging
  from astropy.utils.console import ProgressBar
  from astropy.nddata.utils import PartialOverlapError
  from astropy.coordinates import Angle
  from ..maps import WcsNDMap
  from .counts import make_map_counts
  from .exposure import make_map_exposure_true_energy
  from .background import make_map_background_irf, make_map_background_fov
  
  __all__ = [
      'MapMaker',
  ]
  
  log = logging.getLogger(__name__)
  
  
  class MapMaker(object):
      """Make all basic maps from observations.
  
      Parameters
      ----------
      ref_geom : `~gammapy.maps.WcsGeom`
          Reference image geometry
      offset_max : `~astropy.coordinates.Angle`
          Maximum offset angle
      cutout_mode : {'trim', 'strict'}, optional
          Options for making cutouts
  
  [... the rest is omitted ...]
files.old_path: gammapy/cube/make.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy as np
  import astropy.units as u
  from astropy.coordinates import Angle
  from ..irf import EnergyDependentTablePSF
  from ..maps import Map
  from ..cube import PSFKernel
  
  __all__ = [
      'make_psf_map',
      'PSFMap'
  ]
  
  
  def make_psf_map(psf, pointing, geom, max_offset):
      """Make a psf map for a single observation
  
      Expected axes : rad and true energy in this specific order
      The name of the rad MapAxis is expected to be 'rad'
  
      Parameters
      ----------
      psf : `~gammapy.irf.PSF3D`
          the PSF IRF
      pointing : `~astropy.coordinates.SkyCoord`
          the pointing direction
      geom : `~gammapy.maps
  
  [... the rest is omitted ...]
files.new_path: gammapy/cube/psf_map.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import numpy as np
  import astropy.units as u
  from astropy.coordinates import Angle
  from ..irf import EnergyDependentTablePSF
  from ..maps import Map
  from ..cube import PSFKernel
  
  __all__ = [
      'make_psf_map',
      'PSFMap'
  ]
  
  
  def make_psf_map(psf, pointing, ref_geom, max_offset):
      """Make a psf map for a single observation
  
      Expected axes : rad and true energy in this specific order
      The name of the rad MapAxis is expected to be 'rad'
  
      Parameters
      ----------
      psf : `~gammapy.irf.PSF3D`
          the PSF IRF
      pointing : `~astropy.coordinates.SkyCoord`
          the pointing direction
      ref_geom : `~gamm
  
  [... the rest is omitted ...]
files.old_path: gammapy/cube/psf_map.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import pytest
  import numpy as np
  from astropy.coordinates import SkyCoord, Angle
  from ...utils.testing import requires_data, assert_quantity_allclose
  from ...maps import Map
  from ...irf import EffectiveAreaTable2D
  from ..exposure import make_map_exposure_true_energy
  
  pytest.importorskip('scipy')
  
  
  @pytest.fixture(scope='session')
  def aeff():
      filename = '$GAMMAPY_EXTRA/datasets/hess-crab4-hd-hap-prod2/run023400-023599/run023523/hess_aeff_2d_023523.fits.gz'
      return EffectiveAreaTable2D.read(filename, hdu='AEFF_2D')
  
  
  @pytest.fixture(scope='session')
  def counts_cube():
      filename = '$GAMMAPY_EXTRA/datasets
  
  [... the rest is omitted ...]
files.new_path: gammapy/cube/tests/test_exposure.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import pytest
  import numpy as np
  from astropy.coordinates import SkyCoord, Angle
  from ...utils.testing import requires_data, assert_quantity_allclose
  from ...maps import Map
  from ...irf import EffectiveAreaTable2D
  from ..exposure import make_map_exposure_true_energy
  
  pytest.importorskip('scipy')
  
  
  @pytest.fixture(scope='session')
  def aeff():
      filename = '$GAMMAPY_EXTRA/datasets/hess-crab4-hd-hap-prod2/run023400-023599/run023523/hess_aeff_2d_023523.fits.gz'
      return EffectiveAreaTable2D.read(filename, hdu='AEFF_2D')
  
  
  @pytest.fixture(scope='session')
  def counts_cube():
      filename = '$GAMMAPY_EXTRA/datasets
  
  [... the rest is omitted ...]
files.old_path: gammapy/cube/tests/test_exposure.py
files.new_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import pytest
  import numpy as np
  from numpy.testing import assert_allclose
  import astropy.units as u
  from astropy.coordinates import SkyCoord
  from ...utils.testing import requires_data, requires_dependency
  from ...irf import EffectiveAreaTable2D, EnergyDependentMultiGaussPSF
  from ...irf.energy_dispersion import EnergyDispersion
  from ...maps import MapAxis, WcsGeom, WcsNDMap, Map
  from ...image.models import SkyGaussian
  from ...spectrum.models import PowerLaw
  from .. import (
      SkyModel,
      MapEvaluator,
      MapFit,
      make_map_exposure_true_energy,
      PSFKernel,
  )
  
  
  @pytest.fixture(scope='session')
  def geom():
      axis = MapAxis.from_edges(np.logspace(-1., 1., 3), name
  
  [... the rest is omitted ...]
files.new_path: gammapy/cube/tests/test_fit.py
files.old_contents: # Licensed under a 3-clause BSD style license - see LICENSE.rst
  from __future__ import absolute_import, division, print_function, unicode_literals
  import pytest
  import numpy as np
  from numpy.testing import assert_allclose
  import astropy.units as u
  from astropy.coordinates import SkyCoord
  from ...utils.testing import requires_data, requires_dependency
  from ...irf import EffectiveAreaTable2D, EnergyDependentMultiGaussPSF
  from ...irf.energy_dispersion import EnergyDispersion
  from ...maps import MapAxis, WcsGeom, WcsNDMap, Map
  from ...image.models import SkyGaussian
  from ...spectrum.models import PowerLaw
  from .. import (
      SkyModel,
      MapEvaluator,
      MapFit,
      make_map_exposure_true_energy,
      PSFKernel,
  )
  
  
  @pytest.fixture(scope='session')
  def geom():
      axis = MapAxis.from_edges(np.logspace(-1., 1., 3), name
  
  [... the rest is omitted ...]
files.old_path: gammapy/cube/tests/test_fit.py