Exemple #1
0
def test_generalized_gaussian_io():
    model = GeneralizedGaussianSpatialModel()

    assert isinstance(model.to_region(), EllipseSkyRegion)
    new_model = GeneralizedGaussianSpatialModel.from_dict(model.to_dict())

    assert isinstance(new_model, GeneralizedGaussianSpatialModel)
Exemple #2
0
def test_generalized_gaussian(eta, r_0, e):
    reval = 6
    dr = 0.01
    geom = WcsGeom.create(
        skydir=(0, 0),
        binsz=dr,
        width=(2 * reval, 2 * reval),
        frame="galactic",
    )

    # check normalization is robust for a large set of values
    model = GeneralizedGaussianSpatialModel(eta=eta,
                                            r_0=r_0 * u.deg,
                                            e=e,
                                            frame="galactic")

    eval_geom = model.evaluate_geom(geom)
    integ_geom = model.integrate_geom(geom)
    assert eval_geom.unit.is_equivalent("sr-1")
    assert integ_geom.unit.is_equivalent("")
    assert_allclose(integ_geom.data.sum(), 1.0, atol=3e-2)
    assert isinstance(model.to_region(), EllipseSkyRegion)
    new_model = GeneralizedGaussianSpatialModel.from_dict(model.to_dict())
    assert isinstance(new_model, GeneralizedGaussianSpatialModel)
    assert_allclose(
        new_model.integrate_geom(geom).data.sum(), integ_geom.data.sum())
Exemple #3
0
def test_generalized_gaussian_io():
    model = GeneralizedGaussianSpatialModel(e=0.5)

    reg = model.to_region()
    assert isinstance(reg, EllipseSkyRegion)
    assert_allclose(reg.width.value, 1.73205, rtol=1e-5)

    new_model = GeneralizedGaussianSpatialModel.from_dict(model.to_dict())
    assert isinstance(new_model, GeneralizedGaussianSpatialModel)