Add test for 3D dataset
@@ -17,9 +17,13 @@ def crab_datasets_1d():
def PLmodel():
return PowerLawSpectralModel(amplitude="3e-11 cm-2s-1TeV-1", index=2.7)
+@pytest.fixture
+def crab_datasets_fermi():
+ return Datasets.read("$GAMMAPY_DATA/fermi-3fhl-crab/Fermi-LAT-3FHL_datasets.yaml",
+ "$GAMMAPY_DATA/fermi-3fhl-crab/Fermi-LAT-3FHL_models.yaml")
@requires_data()
-def test_parameter_estimator_simple(crab_datasets_1d, PLmodel):
+def test_parameter_estimator_1d(crab_datasets_1d, PLmodel):
datasets = crab_datasets_1d
for dataset in datasets:
dataset.models = SkyModel(spectral_model=PLmodel, name="Crab")
@@ -28,10 +32,21 @@ def test_parameter_estimator_simple(crab_datasets_1d, PLmodel):
result = estimator.run(PLmodel.amplitude, steps="all")
- # First make sure that parameters are correctly set on the dataset.models object
assert_allclose(result['value'], 5.142843823441639e-11, rtol=1e-4)
assert_allclose(result['err'], 6.42467002840316e-12, rtol=1e-4)
assert_allclose(result['delta_ts'], 353.2092043652601, rtol=1e-4)
assert_allclose(result['errp'], 6.703e-12, rtol=1e-3)
assert_allclose(result['errn'], 6.152e-12, rtol=1e-3)
# Add test for scan
+
+@requires_data()
+def test_parameter_estimator_3d(crab_datasets_fermi):
+ datasets = crab_datasets_fermi
+ parameter = datasets[0].models.parameters['amplitude']
+ estimator = ParameterEstimator(datasets)
+
+ result = estimator.run(parameter, steps="ts")
+ assert_allclose(result['value'], 0.3415434439879935, rtol=1e-4)
+ assert_allclose(result['err'], 0.094636191457666734, rtol=1e-4)
+ assert_allclose(result['delta_ts'], 13005.938752715907, rtol=1e-4)
+
