diff options
author | Aaron LI <aaronly.me@outlook.com> | 2016-04-22 16:10:00 +0800 |
---|---|---|
committer | Aaron LI <aaronly.me@outlook.com> | 2016-04-22 16:10:00 +0800 |
commit | 3d2fcb004a444724cd9b14b9c71b033bc985cda8 (patch) | |
tree | 7cd5583202c73044db25353b9ba4069c1af4dbba /python/msvst_starlet.py | |
parent | eb3ec4582284b6717f96e874c93d9b89ca839eeb (diff) | |
download | atoolbox-3d2fcb004a444724cd9b14b9c71b033bc985cda8.tar.bz2 |
msvst_starlet.py: fix a bug abount p_cutoff
Diffstat (limited to 'python/msvst_starlet.py')
-rwxr-xr-x | python/msvst_starlet.py | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/python/msvst_starlet.py b/python/msvst_starlet.py index 909cfac..7ca42bd 100755 --- a/python/msvst_starlet.py +++ b/python/msvst_starlet.py @@ -16,6 +16,7 @@ # ChangeLog: # 2016-04-22: # * Show more verbose information/details +# * Fix a bug about "p_cutoff" when "comp" contains ALL False's # 2016-04-20: # * Add argparse and main() for scripting # @@ -27,7 +28,7 @@ And multi-scale variance stabling transform (MS-VST), which can be used to effectively remove the Poisson noises. """ -__version__ = "0.2.1" +__version__ = "0.2.2" __date__ = "2016-04-22" @@ -406,12 +407,17 @@ class IUWT_VST(IUWT): # {{{ cn = np.sum(1.0 / np.arange(1, N+1)) p_comp = fdr * np.arange(N) / (N * cn) comp = (p_sorted < p_comp) - # cutoff p-value after FDR control/correction - p_cutoff = np.max(p_sorted[comp]) + if np.sum(comp) == 0: + # `comp' contains ALL False + p_cutoff = 0.0 + else: + # cutoff p-value after FDR control/correction + p_cutoff = np.max(p_sorted[comp]) + sig = (pvalues <= p_cutoff) if verbose: print("std/sigma: %g, p_cutoff: %g" % (std, p_cutoff), flush=True, file=sys.stderr) - return (pvalues <= p_cutoff, p_cutoff) + return (sig, p_cutoff) def denoise(self, fdr=0.1, fdr_independent=False, start_scale=1, verbose=False): @@ -595,7 +601,7 @@ def main(): print("level: %s" % args.level, file=sys.stderr) print("fdr: %s" % args.fdr, file=sys.stderr) print("fdr_independent: %s" % args.fdr_independent, file=sys.stderr) - print("niter: %s\n" % args.niter, file=sys.stderr) + print("niter: %s\n" % args.niter, flush=True, file=sys.stderr) imgfits = fits.open(args.infile) img = imgfits[0].data |