Commit 05c62339 authored by LUSTIG Peter's avatar LUSTIG Peter

added to not lose is 2 times

parent 100c85c8
import numpy as np
def Completness1D(sources, fake_sources, threshold_range, nbins,
fakesourcelocmask=None):
if fakesourcelocmask is None:
fakesourcelocmask = np.zeros(len(fake_sources), dtype=bool)
min_threshold, max_threshold = threshold_range
# get SNR for each fake source
fake_snr = np.ma.array(sources[fake_sources['find_peak']
.filled(0)]['SNR'],
mask=fake_sources['find_peak'].mask)
# SNR higher than max treshold is also detected...
fake_snr[fake_snr > max_threshold] = max_threshold
bin_edges = np.linspace(min_threshold, max_threshold, nbins)
# add right edge to last bin (width not important)
bin_edges = np.append(bin_edges, bin_edges[-1]+1)
# Number of sources that were detected and that are in region
compweights = (~np.array(fake_sources['find_peak'].mask
| fakesourcelocmask)).astype(int)
completness, _ = np.histogram(
fake_snr, bins=bin_edges,
weights=compweights)
completness = np.cumsum(completness[::-1], dtype=float)[::-1]
# just take number of sources in area for normalisation
norm_comp = float(len(fake_sources[~fakesourcelocmask]))
return completness, norm_comp
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