SpatialTemplate_2D uses proj_plane_pixel_area to check that the image is properly normalized:
|
# test if the map is normalized as expected |
|
area = wcs.utils.proj_plane_pixel_area(self._wcs) |
|
dOmega = (area * u.deg * u.deg).to(u.sr).value |
|
total = self._map.sum() * dOmega |
|
|
|
if not np.isclose(total, 1, rtol=1e-2): |
|
log.warning( |
|
"2D template read from {} is normalized to {} (expected: 1)".format( |
|
self._fitsfile, total |
|
) |
|
) |
|
|
However, this function only gives you the area for a pixel at the center of the image (a single number). For a very large extended source (e.g. covering all the sky) the pixels near the pole have quite a different area than the ones at the center (i.e. doesn't take into account the cos(theta) dependency). This mean that the normalization is currently only well-approximated for relatively "small" extended sources.
For context, I saw this when trying to hunt down a normalization issue seen by @GallegoSav when fitting a whole-sky template in COSI.
One possible workaround would be to keep SpatialTemplate_2D for relatively small sources, and develop an equivalent function using HEALPix maps which have equal area (SpatialTemplate_2D uses the PRIMARY FITS image).
SpatialTemplate_2D uses proj_plane_pixel_area to check that the image is properly normalized:
astromodels/astromodels/functions/functions_2D.py
Lines 743 to 754 in 1c215d7
However, this function only gives you the area for a pixel at the center of the image (a single number). For a very large extended source (e.g. covering all the sky) the pixels near the pole have quite a different area than the ones at the center (i.e. doesn't take into account the cos(theta) dependency). This mean that the normalization is currently only well-approximated for relatively "small" extended sources.
For context, I saw this when trying to hunt down a normalization issue seen by @GallegoSav when fitting a whole-sky template in COSI.
One possible workaround would be to keep SpatialTemplate_2D for relatively small sources, and develop an equivalent function using HEALPix maps which have equal area (SpatialTemplate_2D uses the PRIMARY FITS image).