2222###################################################################################################
2323
2424@check_dependency (plt , 'matplotlib' )
25- def save_report_fm (fm , file_name , file_path = None , plt_log = False ):
25+ def save_report_fm (fm , file_name , file_path = None , plt_log = False , add_settings = True ):
2626 """Generate and save out a PDF report for a power spectrum model fit.
2727
2828 Parameters
@@ -35,39 +35,44 @@ def save_report_fm(fm, file_name, file_path=None, plt_log=False):
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 """
3941
42+ # Define grid settings based on what is to be plotted
43+ n_rows = 3 if add_settings else 2
44+ height_ratios = [0.5 , 1.0 , 0.25 ] if add_settings else [0.45 , 1.0 ]
45+
4046 # Set up outline figure, using gridspec
4147 _ = plt .figure (figsize = REPORT_FIGSIZE )
42- grid = gridspec .GridSpec (3 , 1 , height_ratios = [ 0.45 , 1.0 , 0.25 ] )
48+ grid = gridspec .GridSpec (n_rows , 1 , hspace = 0.25 , height_ratios = height_ratios )
4349
4450 # First - text results
4551 ax0 = plt .subplot (grid [0 ])
4652 results_str = gen_results_fm_str (fm )
4753 ax0 .text (0.5 , 0.7 , results_str , REPORT_FONT , ha = 'center' , va = 'center' )
4854 ax0 .set_frame_on (False )
49- ax0 .set_xticks ([])
50- ax0 .set_yticks ([])
55+ ax0 .set (xticks = [], yticks = [])
5156
5257 # Second - data plot
5358 ax1 = plt .subplot (grid [1 ])
5459 fm .plot (plt_log = plt_log , ax = ax1 )
5560
5661 # Third - FOOOF settings
57- ax2 = plt . subplot ( grid [ 2 ])
58- settings_str = gen_settings_str ( fm , False )
59- ax2 . text ( 0.5 , 0.1 , settings_str , REPORT_FONT , ha = 'center' , va = 'center' )
60- ax2 .set_frame_on ( False )
61- ax2 .set_xticks ([] )
62- ax2 .set_yticks ( [])
62+ if add_settings :
63+ ax2 = plt . subplot ( grid [ 2 ] )
64+ settings_str = gen_settings_str ( fm , False )
65+ ax2 .text ( 0.5 , 0.1 , settings_str , REPORT_FONT , ha = 'center' , va = 'center' )
66+ ax2 .set_frame_on ( False )
67+ ax2 .set ( xticks = [], yticks = [])
6368
6469 # Save out the report
6570 plt .savefig (fpath (file_path , fname (file_name , SAVE_FORMAT )))
6671 plt .close ()
6772
6873
6974@check_dependency (plt , 'matplotlib' )
70- def save_report_fg (fg , file_name , file_path = None ):
75+ def save_report_fg (fg , file_name , file_path = None , add_settings = True ):
7176 """Generate and save out a PDF report for a group of power spectrum models.
7277
7378 Parameters
@@ -78,19 +83,26 @@ def save_report_fg(fg, file_name, file_path=None):
7883 Name to give the saved out file.
7984 file_path : str, optional
8085 Path to directory to save to. If None, saves to current directory.
86+ add_settings : bool, optional, default: True
87+ Whether to add a print out of the model settings to the end of the report.
8188 """
8289
90+ # Define grid settings based on what is to be plotted
91+ n_rows = 4 if add_settings else 3
92+ height_ratios = [1.0 , 1.0 , 1.0 , 0.5 ] if add_settings else [0.8 , 1.0 , 1.0 ]
93+
8394 # Initialize figure
8495 _ = plt .figure (figsize = REPORT_FIGSIZE )
85- grid = gridspec .GridSpec (3 , 2 , wspace = 0.4 , hspace = 0.25 , height_ratios = [ 0.8 , 1.0 , 1.0 ] )
96+ grid = gridspec .GridSpec (n_rows , 2 , wspace = 0.4 , hspace = 0.25 , height_ratios = height_ratios )
8697
8798 # First / top: text results
8899 ax0 = plt .subplot (grid [0 , :])
89100 results_str = gen_results_fg_str (fg )
90101 ax0 .text (0.5 , 0.7 , results_str , REPORT_FONT , ha = 'center' , va = 'center' )
91102 ax0 .set_frame_on (False )
92- ax0 .set_xticks ([])
93- ax0 .set_yticks ([])
103+ ax0 .set (xticks = [], yticks = [])
104+
105+ # Second - data plots
94106
95107 # Aperiodic parameters plot
96108 ax1 = plt .subplot (grid [1 , 0 ])
@@ -104,6 +116,14 @@ def save_report_fg(fg, file_name, file_path=None):
104116 ax3 = plt .subplot (grid [2 , :])
105117 plot_fg_peak_cens (fg , ax3 )
106118
119+ # Third - Model settings
120+ if add_settings :
121+ ax4 = plt .subplot (grid [3 , :])
122+ settings_str = gen_settings_str (fg , False )
123+ ax4 .text (0.5 , 0.1 , settings_str , REPORT_FONT , ha = 'center' , va = 'center' )
124+ ax4 .set_frame_on (False )
125+ ax4 .set (xticks = [], yticks = [])
126+
107127 # Save out the report
108128 plt .savefig (fpath (file_path , fname (file_name , SAVE_FORMAT )))
109129 plt .close ()
0 commit comments