def test_flux_estimator_norm_range_template(): energy = MapAxis.from_energy_bounds(0.1, 10, 3.0, unit="TeV", name="energy_true") template = WcsNDMap.create(npix=10, axes=[energy], unit="cm-2 s-1 sr-1 TeV-1") spatial = TemplateSpatialModel(template, normalize=False) spectral = PowerLawNormSpectralModel() model = SkyModel(spectral_model=spectral, spatial_model=spatial, name="test") model.spectral_model.norm.max = 10 model.spectral_model.norm.min = 0 estimator = FluxEstimator(source="test", selection_optional=[], reoptimize=True) scale_model = estimator.get_scale_model(Models([model])) assert_allclose(scale_model.norm.min, 0) assert_allclose(scale_model.norm.max, 10) assert scale_model.norm.interp == "log"
def test_flux_estimator_norm_range(): model = SkyModel.create("pl", "gauss", name="test") model.spectral_model.amplitude.min = 1e-15 model.spectral_model.amplitude.max = 1e-10 estimator = FluxEstimator(source="test", selection_optional=[], reoptimize=True) scale_model = estimator.get_scale_model(Models([model])) assert_allclose(scale_model.norm.min, 1e-3) assert_allclose(scale_model.norm.max, 1e2) assert scale_model.norm.interp == "log"
def test_flux_estimator_naima_model(): import naima ECPL = naima.models.ExponentialCutoffPowerLaw(1e36 * u.Unit("1/eV"), 1 * u.TeV, 2.1, 13 * u.TeV) IC = naima.models.InverseCompton(ECPL, seed_photon_fields=["CMB"]) naima_model = NaimaSpectralModel(IC) model = SkyModel(spectral_model=naima_model, name="test") estimator = FluxEstimator(source="test", selection_optional=[], reoptimize=True) scale_model = estimator.get_scale_model(Models([model])) assert_allclose(scale_model.norm.min, np.nan) assert_allclose(scale_model.norm.max, np.nan)
def test_flux_estimator_compound_model(): pl = PowerLawSpectralModel() pl.amplitude.min = 1e-15 pl.amplitude.max = 1e-10 pln = PowerLawNormSpectralModel() pln.norm.value = 0.1 spectral_model = pl * pln model = SkyModel(spectral_model=spectral_model, name="test") estimator = FluxEstimator(source="test", selection_optional=[], reoptimize=True) scale_model = estimator.get_scale_model(Models([model])) assert_allclose(scale_model.norm.min, 1e-3) assert_allclose(scale_model.norm.max, 1e2)