Skip to content

Extended source and astromodel : To normalized or not to normalized ? #438

@GallegoSav

Description

@GallegoSav

I see from the line here

get_integrated_extended_model is normalizing the spatial shape to sr^-1 but astromodel is actually already expecting the spatial model to have units of deg⁻2 , so to be already normalized. When declaring the model it will otherwise raise a warning like :

16:58:39 WARNING   2D template read from                                                        [functions_2D.py](file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_israel/Pyenv_israelcosipy/lib/python3.11/site-packages/astromodels/functions/functions_2D.py):[749](file:///uni-mainz.de/homes/sgallego/software/COSItools/cosipy_israel/Pyenv_israelcosipy/lib/python3.11/site-packages/astromodels/functions/functions_2D.py#749)
                  /localscratch/sgallego/linkToXauron/MC/Response/BalloonResponse/1_809MeV/COSI                    
                  _DC2_26Al_R5000_z1000_M60_3deg_normalized.fits is normalized to                                  
                  0.0027415567780803775 (expected: 1)

For my case I am using a SpatialTemplate_2D for the spatial shape, using a fits file and I take care to normalized the image so that sum(pixel)*domega = 1 (what astromodel is expecting) .

#normalise the spatial distribution of the fits file to deg²⁻1 (asked by astromodels)
hdul = fits.open('/localscratch/sgallego/linkToXauron/MC/Response/BalloonResponse/1_809MeV/COSI_DC2_26Al_R5000_z1000_M60_3deg.fits', mode='update')
WCS = wcs.WCS(hdul[0].header)
area = wcs.utils.proj_plane_pixel_area(WCS)
dOmega = (area * u.deg * u.deg).to(u.sr).value

#normalize
hdul[0].data = hdul[0].data/(np.sum(hdul[0].data)* dOmega) 

This is removing the warning from astromodel when loading the model actually. And I think the spatial shape using predefined astromodel function like Gaussian_on_sphere give already the correct units of deg^-2.

All of this to say that I think we should remove the / u.sr in normalized_map = extendedmodel.spatial_shape(coords.l.deg, coords.b.deg) / u.sr.

What do you think @israelmcmc and @hiyoneda ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions