Skip to content

Commit 40cf61d

Browse files
Be more consistent with names, avoid breaking the API. Fix issue with best_f
1 parent 3d2b398 commit 40cf61d

1 file changed

Lines changed: 32 additions & 5 deletions

File tree

hendrics/efsearch.py

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,33 @@ def transient_search(
661661

662662

663663
def plot_transient_search(results, gif_name=None):
664+
"""Analyze and plot the results of a transient search.
665+
666+
Parameters
667+
----------
668+
results : TransientResults
669+
The results of the transient search.
670+
gif_name : str or None, default None
671+
The name of the gif file to save the plots to. If None, no gif is saved.
672+
"""
673+
674+
return _analyze_and_plot_transient_search(results, gif_name=gif_name, force_plotting=True)
675+
676+
677+
def _analyze_and_plot_transient_search(results, gif_name=None, force_plotting=False):
678+
"""Analyze and plot the results of a transient search.
679+
680+
By default, it will only plot if the results are smaller than 1e7 elements.
681+
682+
Parameters
683+
----------
684+
results : TransientResults
685+
The results of the transient search.
686+
gif_name : str or None, default None
687+
The name of the gif file to save the plots to. If None, no gif is saved.
688+
force_plotting : bool, default False
689+
Whether to force plotting even if the results are too large.
690+
"""
664691
import matplotlib as mpl
665692
import matplotlib.pyplot as plt
666693

@@ -677,7 +704,7 @@ def plot_transient_search(results, gif_name=None):
677704
all_images = []
678705
import tqdm
679706

680-
plot_results = results.stats.size < 1e7
707+
plot_results = (results.stats.size < 1e7) or force_plotting
681708
if not plot_results:
682709
log.info("Transient search results are too large to plot. Skipping plots.")
683710
else:
@@ -718,9 +745,9 @@ def plot_transient_search(results, gif_name=None):
718745
line = line / detl * 3
719746

720747
maxidx = np.argmax(mean_line)
721-
if line[maxidx] > maxline:
722-
best_f = f[maxidx]
723-
maxline = line[maxidx]
748+
# if line[maxidx] > maxline:
749+
best_f = f[maxidx]
750+
maxline = line[maxidx]
724751

725752
max_stats_rows.append({"step": i + 1, "nave": nave, "best_f": best_f, "max_stat": maxline})
726753

@@ -1824,7 +1851,7 @@ def _common_main(args, func):
18241851
oversample=oversample,
18251852
force_memmap=args.force_memmap,
18261853
)
1827-
plot_transient_search(results, out_fname + "_transient.gif")
1854+
_analyze_and_plot_transient_search(results, out_fname + "_transient.gif")
18281855
if not args.fast and not args.ffa:
18291856
continue
18301857

0 commit comments

Comments
 (0)