def test_plot_offset(self): with mpl_plot_check(): self.table_summary.plot_offset_distribution()
def test_plot_allsky(): m = WcsNDMap.create(binsz=10 * u.deg) with mpl_plot_check(): m.plot()
def test_plot_background_rate(self): with mpl_plot_check(): self.obs_summary.plot_background_rate()
def test_plot_bias(self): with mpl_plot_check(): self.edisp.plot_bias()
def test_plot_correlation(covariance_diagonal): with mpl_plot_check(): covariance_diagonal.plot_correlation()
def test_plot(self, flux_points): with mpl_plot_check(): flux_points.plot()
def test_plot_migration(self): with mpl_plot_check(): self.edisp.plot_migration()
def test_map_fit(sky_model, geom, geom_etrue): dataset_1 = get_map_dataset(geom, geom_etrue, name="test-1") dataset_2 = get_map_dataset(geom, geom_etrue, name="test-2") datasets = Datasets([dataset_1, dataset_2]) models = Models(datasets.models) models.insert(0, sky_model) models["test-1-bkg"].spectral_model.norm.value = 0.5 models["test-model"].spatial_model.sigma.frozen = True datasets.models = models dataset_2.counts = dataset_2.npred() dataset_1.counts = dataset_1.npred() models["test-1-bkg"].spectral_model.norm.value = 0.49 models["test-2-bkg"].spectral_model.norm.value = 0.99 fit = Fit(datasets) result = fit.run() assert result.success assert "minuit" in repr(result) npred = dataset_1.npred().data.sum() assert_allclose(npred, 7525.790688, rtol=1e-3) assert_allclose(result.total_stat, 21625.845714, rtol=1e-3) pars = result.parameters assert_allclose(pars["lon_0"].value, 0.2, rtol=1e-2) assert_allclose(pars["lon_0"].error, 0.002244, rtol=1e-2) assert_allclose(pars["index"].value, 3, rtol=1e-2) assert_allclose(pars["index"].error, 0.024277, rtol=1e-2) assert_allclose(pars["amplitude"].value, 1e-11, rtol=1e-2) assert_allclose(pars["amplitude"].error, 4.216154e-13, rtol=1e-2) # background norm 1 assert_allclose(pars[8].value, 0.5, rtol=1e-2) assert_allclose(pars[8].error, 0.015811, rtol=1e-2) # background norm 2 assert_allclose(pars[11].value, 1, rtol=1e-2) assert_allclose(pars[11].error, 0.02147, rtol=1e-2) # test mask_safe evaluation dataset_1.mask_safe = geom.energy_mask(energy_min=1 * u.TeV) dataset_2.mask_safe = geom.energy_mask(energy_min=1 * u.TeV) stat = fit.datasets.stat_sum() assert_allclose(stat, 14823.772744, rtol=1e-5) region = sky_model.spatial_model.to_region() initial_counts = dataset_1.counts.copy() with mpl_plot_check(): dataset_1.plot_residuals(kwargs_spectral=dict(region=region)) # check dataset has not changed assert initial_counts == dataset_1.counts # test model evaluation outside image dataset_1.models[0].spatial_model.lon_0.value = 150 dataset_1.npred() assert not dataset_1._evaluators["test-model"].contributes
def test_plot_constant_model(): time_range = [Time.now(), Time.now() + 1 * u.d] constant_model = ConstantTemporalModel(const=1) with mpl_plot_check(): constant_model.plot(time_range)
def test_plot_gamma_rate(self): with mpl_plot_check(): self.obs_summary.plot_gamma_rate()
def test_lightcurve_plot(lc): with mpl_plot_check(): lc.plot()
def test_plot_background(self): with mpl_plot_check(): self.obs_summary.plot_background_vs_livetime()
def test_plot_excess(self): with mpl_plot_check(): self.obs_summary.plot_excess_vs_livetime()
def test_plot_significance(self): with mpl_plot_check(): self.obs_summary.plot_significance_vs_livetime()
def test_plot_fit(self): dataset = self.dataset.copy() dataset.models = SkyModel(spectral_model=PowerLawSpectralModel()) with mpl_plot_check(): dataset.plot_fit()
def test_peek(self, psf): with mpl_plot_check(): psf.peek()
def test_plot_off_regions(self): from gammapy.visualization import plot_spectrum_datasets_off_regions with mpl_plot_check(): plot_spectrum_datasets_off_regions([self.dataset])
def test_psf_3d_plot_vs_rad(psf_3d): with mpl_plot_check(): psf_3d.plot_psf_vs_rad()
def test_plot_likelihood(self, flux_points_likelihood): with mpl_plot_check(): flux_points_likelihood.plot_ts_profiles()
def test_psf_3d_plot_containment(psf_3d): with mpl_plot_check(): psf_3d.plot_containment_radius()
def test_plot_matrix(self): with mpl_plot_check(): self.edisp.plot_matrix()
def test_psf_3d_peek(psf_3d): with mpl_plot_check(): psf_3d.peek()
def test_peek(self): with mpl_plot_check(): self.edisp.peek()
def test_plot_allsky(): axis = MapAxis([0, 1], node_type="edges") m = WcsNDMap.create(binsz=10 * u.deg, axes=[axis]) with mpl_plot_check(): m.plot()
def test_plot_grid(): axis = MapAxis([0, 1, 2], node_type="edges") m = WcsNDMap.create(binsz=0.1 * u.deg, width=1 * u.deg, axes=[axis]) with mpl_plot_check(): m.plot_grid()
def test_plot_grid(geom_true): spatial_model = MyCustomGaussianModel(frame="galactic") with mpl_plot_check(): spatial_model.plot_grid(geom=geom_true)
def test_plot_nan(): m = Map.create(width=10, binsz=1) m.data += np.nan with mpl_plot_check(): m.plot(add_cbar=False)
def test_fp_dataset_plot_fit(fit): fp_dataset = fit.datasets[0] with mpl_plot_check(): fp_dataset.plot_fit(kwargs_residuals=dict(method="diff/model"))
def test_plot_zenith(self): with mpl_plot_check(): self.table_summary.plot_zenith_distribution()
def test_fp_dataset_plot_fit(dataset): with mpl_plot_check(): dataset.plot_fit(kwargs_residuals=dict(method="diff/model"))