found error in the estimation of the energy index for energy interpolation; added script to estimate likelihood for specified location

This commit is contained in:
2025-07-22 13:42:28 +03:00
parent 54febb8bbf
commit 23abdd884f
3 changed files with 252 additions and 24 deletions

View File

@@ -71,10 +71,10 @@ def make_srccount_and_detmap(emap, evt, h, wcs=None):
x, y = evt["x"], evt["y"]
else:
ewcs = read_wcs(h)
x, y = wcs.all_world2pix(ewcs.all_pix2world(np.array([x, y]).T, 0), 0).T
x, y = wcs.all_world2pix(ewcs.all_pix2world(np.array([evt["x"], evt["y"]]).T, 0), 0).T
eidx = np.searchsorted(psfe*1e3, evt["ENERGY"])
eidx = np.maximum((evt["ENERGY"]/1000. - psfe[eidx])/(psfe[eidx + 1] - psfe[eidx]), 0.)
eidx = np.maximum(np.searchsorted(psfe*1e3, evt["ENERGY"]) - 1, 0)
eidx = np.maximum((evt["ENERGY"]/1000. - psfe[eidx])/(psfe[eidx + 1] - psfe[eidx]), 0.) + eidx
sizex, sizey = select_xychunksize(wcs)
iidx, xyu, cts = create_neighboring_blocks(x, y, sizex, sizey)
cc = np.zeros(cts.size + 1, int)
@@ -115,8 +115,10 @@ def make_srccount_and_detmap(emap, evt, h, wcs=None):
if __name__ == "__main__":
p1 = fits.open("test.fits")
#emap = fits.getdata("exp.map.gz") #np.full((8192, 8192), 10000.)
emap = fits.getdata("eR_spec_asp_0.fits.gz") #np.full((8192, 8192), 10000.)
emapf = fits.open("eR_spec_asp_0.fits.gz") #np.full((8192, 8192), 10000.)
emap = emapf[0].data
w = WCS(emapf[0].header)
wcs, cmap, pmap = make_srccount_and_detmap(emap, p1[1].data, p1[1].header)
fits.HDUList([fits.PrimaryHDU(), fits.ImageHDU(pmap - cmap, header=p1[1].header), fits.ImageHDU(cmap, header=p1[1].header)]).writeto("tmap4.fits.gz", overwrite=True)
wcs, cmap, pmap = make_srccount_and_detmap(emap, p1[1].data, p1[1].header, wcs=w)
fits.HDUList([fits.PrimaryHDU(), fits.ImageHDU(pmap - cmap, header=p1[1].header), fits.ImageHDU(cmap, header=p1[1].header)]).writeto("tmap5.fits.gz", overwrite=True)
#fits.ImageHDU(data=pmap, header=wcs.to_header()).writeto("tmap4.fits.gz", overwrite=True)