2525
2626from astropy import log
2727from astropy .logger import AstropyUserWarning
28- from astropy .table import Table
28+ from astropy .table import Table , vstack
2929from astropy .utils .introspection import minversion
3030
3131from .base import (
@@ -630,10 +630,16 @@ def plot_transient_search(results, gif_name=None):
630630 import matplotlib as mpl
631631 import matplotlib .pyplot as plt
632632
633+ if not HAS_IMAGEIO :
634+ warnings .warn ("imageio needed to save the transient search results into a gif image." )
635+ return []
636+
633637 mpl .use ("Agg" )
634638 if gif_name is None :
635639 gif_name = "transients.gif"
636640
641+ result_name = gif_name .replace (".gif" , ".csv" )
642+ max_stats_rows = []
637643 all_images = []
638644 for i , (ima , nave ) in enumerate (zip (results .stats , results .nave )):
639645 f = results .freqs
@@ -692,7 +698,6 @@ def plot_transient_search(results, gif_name=None):
692698 )
693699 elif maxline >= 5 and i_f == 0 : # pragma: no cover
694700 print (f"{ gif_name } : Candidate at step { i } : { best_f } Hz (~{ maxline :.1f} sigma)" )
695-
696701 axf .plot (f , mean_line , lw = 1 , c = "k" , zorder = 10 , label = "mean" , ls = "-" )
697702
698703 axima .set_xlabel ("Frequency" )
@@ -703,6 +708,9 @@ def plot_transient_search(results, gif_name=None):
703708 xmin = max (best_f - df , results .f0 )
704709 xmax = min (best_f + df , results .f1 )
705710 if i_f == 0 :
711+ max_stats_rows .append (
712+ {"step" : i + 1 , "nave" : nave , "best_f" : best_f , "max_stat" : maxline }
713+ )
706714 axf .set_xlim ([results .f0 , results .f1 ])
707715 axf .axvline (xmin , ls = "--" , c = "b" , lw = 2 )
708716 axf .axvline (xmax , ls = "--" , c = "b" , lw = 2 )
@@ -715,11 +723,9 @@ def plot_transient_search(results, gif_name=None):
715723
716724 plt .close (fig )
717725 all_images .append (image )
726+ vstack (max_stats_rows ).write (result_name , overwrite = True )
718727
719- if HAS_IMAGEIO :
720- imageio .v3 .imwrite (gif_name , all_images , duration = 1000.0 )
721- else :
722- warnings .warn ("imageio needed to save the transient search results " "into a gif image." )
728+ imageio .v3 .imwrite (gif_name , all_images , duration = 1000.0 )
723729
724730 return all_images
725731
@@ -1722,7 +1728,8 @@ def _common_main(args, func):
17221728 oversample = oversample ,
17231729 )
17241730 plot_transient_search (results , out_fname + "_transient.gif" )
1725- continue
1731+ if not args .fast and not args .ffa :
1732+ continue
17261733
17271734 if not args .fast and not args .ffa :
17281735 fdotmin = args .fdotmin if args .fdotmin is not None else 0
@@ -1782,6 +1789,7 @@ def _common_main(args, func):
17821789 M = length // segment_size
17831790
17841791 fdots = 0
1792+
17851793 if len (results ) == 4 :
17861794 frequencies , stats , step , length = results
17871795 elif len (results ) == 6 :
0 commit comments