2222###################################################################################################
2323
2424@check_dependency (plt , 'matplotlib' )
25- def save_report_fm (fm , file_name , file_path = None , plt_log = True , ** plot_kwargs ):
25+ def save_report_fm (fm , file_name , file_path = None , plt_log = False , add_settings = True , ** plot_kwargs ):
2626 """Generate and save out a PDF report for a power spectrum model fit.
2727
2828 Parameters
@@ -35,41 +35,46 @@ def save_report_fm(fm, file_name, file_path=None, plt_log=True, **plot_kwargs):
3535 Path to directory to save to. If None, saves to current directory.
3636 plt_log : bool, optional, default: False
3737 Whether or not to plot the frequency axis in log space.
38+ add_settings : bool, optional, default: True
39+ Whether to add a print out of the model settings to the end of the report.
3840 plot_kwargs : keyword arguments
3941 Keyword arguments to pass into the plot method.
4042 """
4143
44+ # Define grid settings based on what is to be plotted
45+ n_rows = 3 if add_settings else 2
46+ height_ratios = [0.5 , 1.0 , 0.25 ] if add_settings else [0.45 , 1.0 ]
47+
4248 # Set up outline figure, using gridspec
4349 _ = plt .figure (figsize = REPORT_FIGSIZE )
44- grid = gridspec .GridSpec (3 , 1 , height_ratios = [ 0.45 , 1.0 , 0.25 ] )
50+ grid = gridspec .GridSpec (n_rows , 1 , hspace = 0.25 , height_ratios = height_ratios )
4551
4652 # First - text results
4753 ax0 = plt .subplot (grid [0 ])
4854 results_str = gen_results_fm_str (fm )
4955 ax0 .text (0.5 , 0.7 , results_str , REPORT_FONT , ha = 'center' , va = 'center' )
5056 ax0 .set_frame_on (False )
51- ax0 .set_xticks ([])
52- ax0 .set_yticks ([])
57+ ax0 .set (xticks = [], yticks = [])
5358
5459 # Second - data plot
5560 ax1 = plt .subplot (grid [1 ])
5661 fm .plot (plt_log = plt_log , ax = ax1 , ** plot_kwargs )
5762
5863 # Third - FOOOF settings
59- ax2 = plt . subplot ( grid [ 2 ])
60- settings_str = gen_settings_str ( fm , False )
61- ax2 . text ( 0.5 , 0.1 , settings_str , REPORT_FONT , ha = 'center' , va = 'center' )
62- ax2 .set_frame_on ( False )
63- ax2 .set_xticks ([] )
64- ax2 .set_yticks ( [])
64+ if add_settings :
65+ ax2 = plt . subplot ( grid [ 2 ] )
66+ settings_str = gen_settings_str ( fm , False )
67+ ax2 .text ( 0.5 , 0.1 , settings_str , REPORT_FONT , ha = 'center' , va = 'center' )
68+ ax2 .set_frame_on ( False )
69+ ax2 .set ( xticks = [], yticks = [])
6570
6671 # Save out the report
6772 plt .savefig (fpath (file_path , fname (file_name , SAVE_FORMAT )))
6873 plt .close ()
6974
7075
7176@check_dependency (plt , 'matplotlib' )
72- def save_report_fg (fg , file_name , file_path = None ):
77+ def save_report_fg (fg , file_name , file_path = None , add_settings = True ):
7378 """Generate and save out a PDF report for a group of power spectrum models.
7479
7580 Parameters
@@ -80,19 +85,26 @@ def save_report_fg(fg, file_name, file_path=None):
8085 Name to give the saved out file.
8186 file_path : str, optional
8287 Path to directory to save to. If None, saves to current directory.
88+ add_settings : bool, optional, default: True
89+ Whether to add a print out of the model settings to the end of the report.
8390 """
8491
92+ # Define grid settings based on what is to be plotted
93+ n_rows = 4 if add_settings else 3
94+ height_ratios = [1.0 , 1.0 , 1.0 , 0.5 ] if add_settings else [0.8 , 1.0 , 1.0 ]
95+
8596 # Initialize figure
8697 _ = plt .figure (figsize = REPORT_FIGSIZE )
87- grid = gridspec .GridSpec (3 , 2 , wspace = 0.4 , hspace = 0.25 , height_ratios = [ 0.8 , 1.0 , 1.0 ] )
98+ grid = gridspec .GridSpec (n_rows , 2 , wspace = 0.4 , hspace = 0.25 , height_ratios = height_ratios )
8899
89100 # First / top: text results
90101 ax0 = plt .subplot (grid [0 , :])
91102 results_str = gen_results_fg_str (fg )
92103 ax0 .text (0.5 , 0.7 , results_str , REPORT_FONT , ha = 'center' , va = 'center' )
93104 ax0 .set_frame_on (False )
94- ax0 .set_xticks ([])
95- ax0 .set_yticks ([])
105+ ax0 .set (xticks = [], yticks = [])
106+
107+ # Second - data plots
96108
97109 # Aperiodic parameters plot
98110 ax1 = plt .subplot (grid [1 , 0 ])
@@ -106,6 +118,14 @@ def save_report_fg(fg, file_name, file_path=None):
106118 ax3 = plt .subplot (grid [2 , :])
107119 plot_fg_peak_cens (fg , ax3 )
108120
121+ # Third - Model settings
122+ if add_settings :
123+ ax4 = plt .subplot (grid [3 , :])
124+ settings_str = gen_settings_str (fg , False )
125+ ax4 .text (0.5 , 0.1 , settings_str , REPORT_FONT , ha = 'center' , va = 'center' )
126+ ax4 .set_frame_on (False )
127+ ax4 .set (xticks = [], yticks = [])
128+
109129 # Save out the report
110130 plt .savefig (fpath (file_path , fname (file_name , SAVE_FORMAT )))
111131 plt .close ()
0 commit comments