diff --git a/rfinder/main.py b/rfinder/main.py index a2dfc9c..528a1dc 100644 --- a/rfinder/main.py +++ b/rfinder/main.py @@ -296,7 +296,7 @@ def setArgs(self,args): self.cfg_par['rfi']['chunks']['spw_enable'] = True if args.no_movies == True : - self.cfg_par['plots']['movies']['movies_in_report'] = False + self.cfg_par['plots']['plot_details']['movies']['movies_in_report'] = False if args.no_cleanup==True: self.cfg_par['general']['cleanup_enable'] = False @@ -631,7 +631,7 @@ def main (self,argv): self.parser.print_help() print("""\nRun a command. This can be:\n \nrfinder \nrfinder -c path_to_config_file.yml -rfinder -i -fl -tel \n""") + rfinder -i -fl -tel \n""") sys.exit(0) diff --git a/rfinder/rfinder_default.yml b/rfinder/rfinder_default.yml index ca7d2f7..eacc681 100644 --- a/rfinder/rfinder_default.yml +++ b/rfinder/rfinder_default.yml @@ -21,7 +21,7 @@ rfi: rfi_enable: false #if True this module is enabled else only obs info will logged polarization: 'q' #xx, yy, xy, yx, q (also in CAPS) bad_antenna: '[]' #list of bad antennas: for no antennas try '[]' - RFInder_mode: 'use_flags' #uses RFI clip method or simply reads the FLAG column 'use_flags' / 'rms_clip' + RFInder_mode: 'rms_clip' #uses RFI clip method or simply reads the FLAG column 'use_flags' / 'rms_clip' rms_clip: 5 #Threshold for RFI identification noise_measure_edges: [1.400e9, 1.420e9] #min frequency and maximum frequency where to measure average std of visibilities baseline_cut: 200 #Cutoff baseline lenght: < = Short, > = Long (615m midpoint of baselines of WSRT) @@ -39,6 +39,7 @@ plots: enable: false plot_noise: 'rfi' #choose to plot % of RFI, 'rfi', or noise, 'noise', or factor of noise increase, 'noise_factor' in 1D plots plot_long_short: true #plot all baselines, or only the short and the long + plot_eps: true #also generate eps plots. If false only pngs/movies movies: __helpstr: make movies of output plots 2d_gif: true diff --git a/rfinder/rfinder_files.py b/rfinder/rfinder_files.py index 8a72ba9..b3bd3af 100644 --- a/rfinder/rfinder_files.py +++ b/rfinder/rfinder_files.py @@ -294,7 +294,7 @@ def write_html_fullreport(cfg_par): if os.path.exists(video_name3): video_encoded3 = base64.b64encode(open(video_name3, "rb").read()) - if cfg_par['plots']['movies']['movies_in_report'] == True: + if cfg_par['plots']['plot_details']['movies']['movies_in_report'] == True: template = env.get_template('full_template.html') with open(cfg_par['general']['rfidir']+'full_report.html', "w") as f: lenghts = np.array([cfg_par['rfi']['baseline_lenghts']])+0. @@ -325,7 +325,7 @@ def write_html_fullreport(cfg_par): video_tag3 = ''.format(video_encoded3.decode()) )) - elif cfg_par['plots']['movies']['movies_in_report'] == False: + elif cfg_par['plots']['plot_details']['movies']['movies_in_report'] == False: template = env.get_template('fullshort_template.html') with open(cfg_par['general']['rfidir']+'full_report.html', "w") as f: lenghts = np.array([cfg_par['rfi']['baseline_lenghts']])+0. @@ -389,7 +389,7 @@ def write_html_timereport(cfg_par): else: video_encoded3 = None - if cfg_par['plots']['movies']['movies_in_report'] == True: + if cfg_par['plots']['plot_details']['movies']['movies_in_report'] == True: with open(cfg_par['general']['rfidir']+'time_report.html', "w") as f: lenghts = np.array([cfg_par['rfi']['baseline_lenghts']])+0. @@ -417,7 +417,7 @@ def write_html_timereport(cfg_par): #video_tag4 = ''.format(video_encoded3.decode()) )) - elif cfg_par['plots']['movies']['movies_in_report'] == False: + elif cfg_par['plots']['plot_details']['movies']['movies_in_report'] == False: logger.info('\t ERROR: movies in report must be set to TRUE\n') diff --git a/rfinder/rfinder_plots.py b/rfinder/rfinder_plots.py index bde6929..03cb8b7 100644 --- a/rfinder/rfinder_plots.py +++ b/rfinder/rfinder_plots.py @@ -166,11 +166,11 @@ def plot_rfi_imshow(self,cfg_par,time_step=-1): params = {'font.family' :' serif', 'font.style' : 'normal', 'font.weight' : 'book', - 'font.size' : 18.0, + 'font.size' : 24.0, 'axes.linewidth' : 1, 'lines.linewidth' : 1, - 'xtick.labelsize' : 16, - 'ytick.labelsize' : 16, + 'xtick.labelsize' : 18, + 'ytick.labelsize' : 18, 'xtick.direction' :'in', 'ytick.direction' :'in', #'xtick.top' : True, # draw ticks on the top side @@ -191,7 +191,7 @@ def plot_rfi_imshow(self,cfg_par,time_step=-1): plt.rcParams.update(params) # Format axes nullfmt = NullFormatter() - left, width = 0.05, 0.9 #|These determine where the subplots go + left, width = 0.06, 0.89 #|These determine where the subplots go bottom, height = 0.1, 0.85 #left_h = left+width+0.015 #bottom_h = left+height+0.015 @@ -221,7 +221,7 @@ def plot_rfi_imshow(self,cfg_par,time_step=-1): ax.set_yticklabels(input_baselines) ax.set_xlabel('Frequency [MHz]') - ax.set_ylabel('Baseline lenght [m]') + ax.set_ylabel('Baseline length [m]') # colorbar @@ -263,8 +263,10 @@ def plot_rfi_imshow(self,cfg_par,time_step=-1): ax.set_title(title_plot) plt.savefig(rfi_freq_base_plot,format='png') + if cfg_par['plots']['plot_details']['plot_eps']: + plt.savefig(rfi_freq_base_plot.replace('png', 'eps'), format='eps') plt.close(fig) - self.logger.info("\t ... RFI per baseline lenght and frequency plotted ... \n\n") + self.logger.info("\t ... RFI per baseline length and frequency plotted ... \n\n") def plot_noise_frequency(self,cfg_par,time_step=-1): ''' @@ -313,7 +315,6 @@ def plot_noise_frequency(self,cfg_par,time_step=-1): #open file if os.path.exists(rfi_table) == False: - print(rfi_table) self.logger.error('### Table of RFI results does not exist ###') else: @@ -355,11 +356,12 @@ def plot_noise_frequency(self,cfg_par,time_step=-1): params = {'font.family' :' serif', 'font.style' : 'normal', 'font.weight' : 'book', - 'font.size' : 18.0, + #'font.size' : 18.0, + 'font.size' : 26.0, 'axes.linewidth' : 1, 'lines.linewidth' : 1, - 'xtick.labelsize' : 16, - 'ytick.labelsize' : 16, + 'xtick.labelsize' : 18, + 'ytick.labelsize' : 18, 'xtick.direction' :'in', 'ytick.direction' :'in', #'xtick.top' : True, # draw ticks on the top side @@ -382,7 +384,7 @@ def plot_noise_frequency(self,cfg_par,time_step=-1): # Format axes nullfmt = NullFormatter() - left, width = 0.05, 0.9 #|These determine where the subplots go + left, width = 0.06, 0.89 #|These determine where the subplots go bottom, height = 0.1, 0.85 #left_h = left+width+0.015 #bottom_h = left+height+0.015 @@ -391,6 +393,7 @@ def plot_noise_frequency(self,cfg_par,time_step=-1): # initialize figure fig = plt.figure(1, figsize=(18,8)) + plt.rc('xtick', labelsize=20) # Initialize subplots @@ -507,6 +510,8 @@ def plot_noise_frequency(self,cfg_par,time_step=-1): rfi_freq_plot = out_plot+'_rfi.png' plt.savefig(rfi_freq_plot,format='png') + if cfg_par['plots']['plot_details']['plot_eps']: + plt.savefig(rfi_freq_plot.replace('png', 'eps'), format='eps') plt.close(fig) self.logger.info("\t ... RFI in 1D plotted ...\n\n") @@ -520,7 +525,6 @@ def plot_altaz(self,cfg_par,number_chunks): self.logger.info("\t ... Plotting Alt/Az for binned dataset ... \n") if os.path.exists(cfg_par['general']['timetabledir']) == False: - print(cfg_par['general']['timetabledir']) self.logger.error("\t Folder with time subsets missing") table_tmp = str.split(cfg_par['general']['msname'][0],'.MS') @@ -565,7 +569,6 @@ def plot_altaz(self,cfg_par,number_chunks): #open file if os.path.exists(rfi_table) == False: - print(rfi_table) self.logger.error('### Table of RFI results does not exist ###') continue else: @@ -601,11 +604,11 @@ def plot_altaz(self,cfg_par,number_chunks): params = {'font.family' :' serif', 'font.style' : 'normal', 'font.weight' : 'book', - 'font.size' : 18.0, + 'font.size' : 20.0, 'axes.linewidth' : 1, 'lines.linewidth' : 1, - 'xtick.labelsize' : 16, - 'ytick.labelsize' : 16, + 'xtick.labelsize' : 17, + 'ytick.labelsize' : 17, 'xtick.direction' :'in', 'ytick.direction' :'in', #'xtick.top' : True, # draw ticks on the top side @@ -804,8 +807,8 @@ def plot_altaz_short(self,cfg_par): 'font.size' : 18.0, 'axes.linewidth' : 1, 'lines.linewidth' : 1, - 'xtick.labelsize' : 16, - 'ytick.labelsize' : 16, + 'xtick.labelsize' : 18, + 'ytick.labelsize' : 18, 'xtick.direction' :'in', 'ytick.direction' :'in', 'xtick.major.size' : 4, @@ -890,11 +893,12 @@ def plot_summary_stats(self, flag_stats, cfg_par, key='corr'): params = {'font.family' :' serif', 'font.style' : 'normal', 'font.weight' : 'book', - 'font.size' : 20.0, + #'font.size' : 20.0, + 'font.size' : 26.0, 'axes.linewidth' : 1, 'lines.linewidth' : 1, - 'xtick.labelsize' : 16, - 'ytick.labelsize' : 16, + 'xtick.labelsize' : 18, + 'ytick.labelsize' : 18, 'xtick.direction' :'in', 'ytick.direction' :'in', 'xtick.major.size' : 4, @@ -909,6 +913,7 @@ def plot_summary_stats(self, flag_stats, cfg_par, key='corr'): } plt.rcParams.update(params) fig, ax = plt.subplots(figsize=(16,9)) + fig.subplots_adjust(bottom=0.2) plt.ylim(0, 100.0) antenna_plot = ax.bar(flag_stats.keys(), flag_stats.values(), color="orange", ec="red", align='center') @@ -920,17 +925,23 @@ def plot_summary_stats(self, flag_stats, cfg_par, key='corr'): if len(flag_stats.keys()) > 30: plt.xticks(rotation=90) plt.savefig(summaryplot) + if cfg_par['plots']['plot_details']['plot_eps']: + plt.savefig(summaryplot.replace('png', 'eps'), format='eps') elif key in ["scan"]: plt.title("Scan flags") plt.xlabel("Scan Number") plt.ylabel("% flagged visibilities") plt.savefig(summaryplot) + if cfg_par['plots']['plot_details']['plot_eps']: + plt.savefig(summaryplot.replace('png', 'eps'), format='eps') elif key in ["correlation", "corr"]: plt.title("Correlation flags") plt.xlabel("Correlation") plt.ylabel("Flagged percentage (%)") plt.ylabel("% flagged visibilities") plt.savefig(summaryplot) + if cfg_par['plots']['plot_details']['plot_eps']: + plt.savefig(summaryplot.replace('png', 'eps'), format='eps') elif key in ["frequency", "freq"]: plt.title("Frequency flags") plt.xlabel("Frequency (Hz)") @@ -939,6 +950,8 @@ def plot_summary_stats(self, flag_stats, cfg_par, key='corr'): ax2.set_xlabel("Channel Bin") ax2.bar(list(range(len(flag_stats.keys()))), flag_stats.values(), color="orange", ec="orange", align='center') plt.savefig(summaryplot) + if cfg_par['plots']['plot_details']['plot_eps']: + plt.savefig(summaryplot.replace('png', 'eps'), format='eps') self.logger.info(f" ------ Saving: {summaryplot} ------\n") plt.close()