Commit 02bb0e88 authored by LUSTIG Peter's avatar LUSTIG Peter

Purity and completness (completness not testet yet) for masked region

parent a239436a
This diff is collapsed.
......@@ -158,15 +158,22 @@ def purity_worker(shape, wcs, sources, max_threshold=2):
corresponding 2D :class:`numpy.ndarray`
"""
sources_snr = sources['SNR']
# As we are interested by the cumulative numbers, keep all inside the
# upper pixel
sources_snr[sources_snr > max_threshold] = max_threshold
xx, yy, zz = wcs.wcs_world2pix(sources['ra'], sources['dec'],
sources_snr, 0)
if sources is not None:
sources_snr = sources['SNR']
# As we are interested by the cumulative numbers, keep all inside the
# upper pixel
sources_snr[sources_snr > max_threshold] = max_threshold
xx, yy, zz = wcs.wcs_world2pix(sources['ra'], sources['dec'],
sources_snr, 0)
'''
print(zz.shape)
plt.plot(zz)
plt.show(block=True)
sys.exit()
'''
# Number of fake sources recovered
if 'fake_sources' in sources.keys():
if sources is not None and 'fake_sources' in sources.keys():
_purity, _ = np.histogramdd(np.asarray([xx, yy, zz]).T + 0.5,
bins=np.asarray(shape),
range=list(zip([0]*len(shape), shape)),
......@@ -176,11 +183,15 @@ def purity_worker(shape, wcs, sources, max_threshold=2):
_purity = np.cumsum(_purity[..., ::-1], axis=2)[..., ::-1]
else:
_purity = None
# Number of total detected sources at a given threshold
_norm_pur, _ = np.histogramdd(np.asarray([xx, yy, zz]).T + 0.5,
bins=np.asarray(shape),
range=list(zip([0]*len(shape), shape)))
_norm_pur = np.cumsum(_norm_pur[..., ::-1], axis=2)[..., ::-1]
if sources is not None:
# Number of total detected sources at a given threshold
_norm_pur, _ = np.histogramdd(np.asarray([xx, yy, zz]).T + 0.5,
bins=np.asarray(shape),
range=list(zip([0]*len(shape), shape)))
_norm_pur = np.cumsum(_norm_pur[..., ::-1], axis=2)[..., ::-1]
else:
_norm_pur = None
return _purity, _norm_pur
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment