Пример #1
0
from astropy.coordinates import SkyCoord
from astropy.table import Table
from fermipy.tests.utils import requires_dependency, requires_file
from fermipy import spectrum
from fermipy.ltcube import LTCube
from fermipy.skymap import Map

from fermipy.tests.utils import requires_st_version
try:
    from fermipy.scripts import flux_sensitivity
    from fermipy.sensitivity import SensitivityCalc
except ImportError:
    pass

# Skip tests in this file if Fermi ST aren't up to date
pytestmark = requires_st_version('01-03-00')

galdiff_path = os.path.join(os.path.expandvars('$FERMI_DIFFUSE_DIR'),
                            'gll_iem_v07.fits')


@requires_file(galdiff_path)
def test_calc_diff_flux_sensitivity():

    ltc = LTCube.create_from_obs_time(3.1536E8)
    c = SkyCoord(10.0, 10.0, unit='deg', frame='galactic')
    ebins = 10**np.linspace(2.0, 5.0, 8 * 3 + 1)

    gdiff = Map.create_from_fits(galdiff_path)
    iso = np.loadtxt(
        os.path.expandvars('$FERMI_DIFFUSE_DIR/iso_P8R3_SOURCE_V3_v1.txt'),
Пример #2
0
import os
import numpy as np
from numpy.testing import assert_allclose
from astropy.tests.helper import pytest
from astropy.table import Table
from fermipy.tests.utils import requires_dependency,\
    requires_st_version, requires_git_version
from fermipy import spectrum

try:
    from fermipy import gtanalysis
except ImportError:
    pass

# Skip tests in this file if Fermi ST aren't available
pytestmark = requires_st_version('01-00-07')


@pytest.fixture(scope='module')
def create_draco_analysis(request, tmpdir_factory):
    path = tmpdir_factory.mktemp('draco')
    url = 'https://raw.githubusercontent.com/fermiPy/fermipy-extras/master/data/fermipy_test_draco.tar.gz'
    outfile = path.join('fermipy_test_draco.tar.gz')
    dirname = path.join()
    os.system('curl -o %s -OL %s' % (outfile, url))
    os.system('cd %s;tar xzf %s' % (dirname, outfile))

    request.addfinalizer(lambda: path.remove(rec=1))

    cfgfile = path.join('fermipy_test_draco', 'config.yaml')
    if not os.path.isfile(str(cfgfile)):
Пример #3
0
import os
import numpy as np
from numpy.testing import assert_allclose
from astropy.tests.helper import pytest
from astropy.table import Table
from fermipy.tests.utils import requires_dependency,\
    requires_st_version, requires_git_version, create_diffuse_dir
from fermipy import spectrum

try:
    from fermipy import gtanalysis
except ImportError:
    pass

# Skip tests in this file if Fermi ST aren't available
pytestmark = requires_st_version('02-00-00')


@pytest.fixture(scope='module')
def create_draco_analysis(request, tmpdir_factory):
    path = tmpdir_factory.mktemp('draco')
    url = 'https://raw.githubusercontent.com/fermiPy/fermipy-extras/master/data/fermipy_test_draco.tar.gz'
    outfile = path.join('fermipy_test_draco.tar.gz')
    dirname = path.join()
    os.system('curl -o %s -OL %s' % (outfile, url))
    os.system('cd %s;tar xzf %s' % (dirname, outfile))

    request.addfinalizer(lambda: path.remove(rec=1))

    cfgfile = path.join('fermipy_test_draco', 'config.yaml')
    if not os.path.isfile(str(cfgfile)):