From c35e3318413589258d60059fd18141bcecf28741 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:12:20 +0200 Subject: [PATCH 01/36] Update pygrb_plotting_utils.py Adding the option to feed a pyplot figure object to ease debugging --- pycbc/results/pygrb_plotting_utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pycbc/results/pygrb_plotting_utils.py b/pycbc/results/pygrb_plotting_utils.py index f6848b5b623..75b72636c5b 100644 --- a/pycbc/results/pygrb_plotting_utils.py +++ b/pycbc/results/pygrb_plotting_utils.py @@ -188,12 +188,14 @@ def axis_min_value(trig_values, inj_values, inj_file): # ============================================================================= def pygrb_plotter(trigs, injs, xlabel, ylabel, opts, snr_vals=None, conts=None, shade_cont_value=None, - colors=None, vert_spike=False, cmd=None): + colors=None, vert_spike=False, cmd=None, fig=None): """Master function to plot PyGRB results""" from matplotlib import pyplot as plt # Set up plot - fig = plt.figure() + if fig is None: + fig = plt.figure() + cax = fig.gca() # Plot trigger-related and (if present) injection-related quantities cax_plotter = cax.loglog if opts.use_logs else cax.plot From 6acfa6c607fb5109d205fd23003f8d6d421a74dd Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:17:11 +0200 Subject: [PATCH 02/36] Update pygrb_postprocessing_utils.py load_triggers: Adding the capability to select triggers with certain slide_id --- pycbc/results/pygrb_postprocessing_utils.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index 1f86611cb89..672dd676b5e 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -172,6 +172,19 @@ def pygrb_add_bestnr_cut_opt(parser): "Default 0: all events are considered.") +# ============================================================================= +# Wrapper to pick triggers with certain slide_ids +# ============================================================================= +def slide_filter(File, data, slide_id=None): + """ """ + mask = numpy.where(File['network/slide_id'][:]==slide_id)[0] + + if slide_id is not None: + return data[mask] + else: + return data + + # ============================================================================= # Wrapper to read segments files # ============================================================================= @@ -356,7 +369,7 @@ def dataset_iterator(g, prefix=''): yield from dataset_iterator(item, path) -def load_triggers(input_file, ifos, vetoes, rw_snr_threshold=None): +def load_triggers(input_file, ifos, vetoes, rw_snr_threshold=None, slide_id=None): """Loads triggers from PyGRB output file, returning a dictionary""" trigs = h5py.File(input_file, 'r') @@ -407,6 +420,10 @@ def load_triggers(input_file, ifos, vetoes, rw_snr_threshold=None): else: trigs_dict[path] = dset[above_thresh] + if trigs_dict[path].size==trigs['network/slide_id'][:].size: + trigs_dict[path] = slide_filter(trigs,trigs_dict[path], + slide_id=slide_id) + return trigs_dict From 2550c13b0fd0e2fff9c5fa24350c01a14b9bf51d Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:21:49 +0200 Subject: [PATCH 03/36] Update pycbc_pygrb_plot_snr_timeseries pycbc_pygrb_plot_snr_timeseries: propagating the slide_id functionalities across plotting scripts. We only want to show slide_id=0 in this plots --- bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index 75b567d6483..992e528faee 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -44,13 +44,12 @@ __version__ = pycbc.version.git_verbose_msg __date__ = pycbc.version.date __program__ = "pycbc_pygrb_plot_snr_timeseries" - # ============================================================================= # Functions # ============================================================================= # Load trigger data def load_data(input_file, ifos, vetoes, rw_snr_threshold=None, - injections=False): + injections=False, slide_id=None): """Load data from a trigger/injection file""" trigs_or_injs = None @@ -60,13 +59,12 @@ def load_data(input_file, ifos, vetoes, rw_snr_threshold=None, # This will eventually become load_injections trigs_or_injs = \ ppu.load_triggers(input_file, ifos, vetoes, - rw_snr_threshold=rw_snr_threshold) + rw_snr_threshold=rw_snr_threshold,slide_id=slide_id) else: logging.info("Loading triggers...") trigs_or_injs = \ ppu.load_triggers(input_file, ifos, vetoes, - rw_snr_threshold=rw_snr_threshold) - + rw_snr_threshold=rw_snr_threshold,slide_id=slide_id) return trigs_or_injs @@ -137,21 +135,21 @@ ifos, vetoes = ppu.extract_ifos_and_vetoes(trig_file, opts.veto_files, # points to show the impact of the cut, otherwise remove points with # reweighted SNR below threshold if snr_type == 'reweighted': - trig_data = load_data(trig_file, ifos, vetoes) + trig_data = load_data(trig_file, ifos, vetoes, slide_id=0) trig_data['network/reweighted_snr'] = \ reweightedsnr_cut(trig_data['network/reweighted_snr'], opts.newsnr_threshold) - inj_data = load_data(inj_file, ifos, vetoes, injections=True) + inj_data = load_data(inj_file, ifos, vetoes, injections=True,slide_id=0) if inj_data is not None: inj_data['network/reweighted_snr'] = \ reweightedsnr_cut(inj_data['network/reweighted_snr'], opts.newsnr_threshold) else: trig_data = load_data(trig_file, ifos, vetoes, - rw_snr_threshold=opts.newsnr_threshold) + rw_snr_threshold=opts.newsnr_threshold, slide_id=0) inj_data = load_data(inj_file, ifos, vetoes, rw_snr_threshold=opts.newsnr_threshold, - injections=True) + injections=True, slide_id=0) # Specify HDF file keys for x quantity (time) and y quantity (SNR) if snr_type == 'single': @@ -166,8 +164,9 @@ trig_data_time = trig_data[x_key][:] inj_data_time = inj_data[x_key][:] if inj_file else None # Obtain SNRs + trig_data_snr = trig_data[y_key][:] -inj_data_snr = inj_data[y_key][:] if inj_file else None +inj_data_snr = inj_data[y_key][:] if inj_file else None # Determine the central time (t=0) for the plot central_time = opts.trigger_time @@ -203,7 +202,8 @@ xlims = [start, end] if opts.x_lims: xlims = opts.x_lims xlims = map(float, xlims.split(',')) + plu.pygrb_plotter([trig_data_time, trig_data_snr], [inj_data_time, inj_data_snr], "Time since %.3f (s)" % (central_time), y_label, - opts, cmd=' '.join(sys.argv)) + opts, cmd=' '.join(sys.argv), fig=plt.figure()) From 4908130120204b73118518b87e9f572a9d464e1f Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:28:23 +0200 Subject: [PATCH 04/36] Update pycbc_pygrb_plot_chisq_veto Update pycbc_pygrb_plot_chisq_veto: propagating slide_id functionalities across plotting scripts. Here we only want to display slide_id=0 --- bin/pygrb/pycbc_pygrb_plot_chisq_veto | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_chisq_veto b/bin/pygrb/pycbc_pygrb_plot_chisq_veto index 815a9792224..88bcfa384c7 100644 --- a/bin/pygrb/pycbc_pygrb_plot_chisq_veto +++ b/bin/pygrb/pycbc_pygrb_plot_chisq_veto @@ -49,7 +49,7 @@ __program__ = "pycbc_pygrb_plot_chisq_veto" # Functions # ============================================================================= # Function to load trigger data: includes applying cut in reweighted SNR -def load_data(input_file, ifos, vetoes, opts, injections=False): +def load_data(input_file, ifos, vetoes, opts, injections=False, slide_id=None): """Load data from a trigger/injection file""" snr_type = opts.snr_type @@ -71,12 +71,14 @@ def load_data(input_file, ifos, vetoes, opts, injections=False): # This will eventually become load_injections trigs_or_injs = \ ppu.load_triggers(input_file, ifos, vetoes, - rw_snr_threshold=rw_snr_threshold) + rw_snr_threshold=rw_snr_threshold, + slide_id=slide_id) else: logging.info("Loading triggers...") trigs_or_injs = \ ppu.load_triggers(input_file, ifos, vetoes, - rw_snr_threshold=rw_snr_threshold) + rw_snr_threshold=rw_snr_threshold, + slide_id=slide_id) # Count surviving points num_trigs_or_injs = len(trigs_or_injs['network/reweighted_snr']) @@ -194,6 +196,7 @@ init_logging(opts.verbose, format="%(asctime)s: %(levelname)s: %(message)s") # Check options trig_file = os.path.abspath(opts.trig_file) +print(trig_file) found_missed_file = os.path.abspath(opts.found_missed_file) \ if opts.found_missed_file else None zoom_in = opts.zoom_in @@ -250,10 +253,11 @@ if ifo and ifo not in ifos: raise RuntimeError(err_msg) # Extract trigger data -trig_data = load_data(trig_file, ifos, vetoes, opts) +trig_data = load_data(trig_file, ifos, vetoes, opts, slide_id=0) # Extract (or initialize) injection data -inj_data = load_data(found_missed_file, ifos, vetoes, opts, injections=True) +inj_data = load_data(found_missed_file, ifos, vetoes, opts, + injections=True, slide_id=0) # Sanity checks if trig_data[snr_type] is None and inj_data[snr_type] is None: @@ -315,3 +319,4 @@ plu.pygrb_plotter(trigs, injs, x_label, y_label, opts, snr_vals=snr_vals, conts=conts, colors=colors, shade_cont_value=cont_value, vert_spike=True, cmd=' '.join(sys.argv)) + 321,41 Bot From 45b13c20c72a28999d4a4556710bb956392a4103 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:34:02 +0200 Subject: [PATCH 05/36] Update pycbc_pygrb_plot_coh_ifosnr pycbc_pygrb_plot_coh_ifosnr: propagating slide_id functionalities, here we only want to display slide_id=0 --- bin/pygrb/pycbc_pygrb_plot_coh_ifosnr | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr b/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr index 4fa562fa9f0..50e0b12c81b 100644 --- a/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr +++ b/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr @@ -53,7 +53,7 @@ __program__ = "pycbc_pygrb_plot_coh_ifosnr" # Functions # ============================================================================= # Function to load trigger data -def load_data(input_file, ifos, vetoes, opts, injections=False): +def load_data(input_file, ifos, vetoes, opts, injections=False, slide_id=None): """Load data from a trigger/injection file""" # Initialize the dictionary @@ -74,6 +74,7 @@ def load_data(input_file, ifos, vetoes, opts, injections=False): ifos, vetoes, rw_snr_threshold=opts.newsnr_threshold, + slide_id=slide_id ) else: logging.info("Loading triggers...") @@ -82,6 +83,7 @@ def load_data(input_file, ifos, vetoes, opts, injections=False): ifos, vetoes, rw_snr_threshold=opts.newsnr_threshold, + slide_id=slide_id ) # Load SNR data @@ -233,10 +235,10 @@ ifos, vetoes = ppu.extract_ifos_and_vetoes( ) # Extract trigger data -trig_data = load_data(trig_file, ifos, vetoes, opts) +trig_data = load_data(trig_file, ifos, vetoes, opts, slide_id=0) # Extract (or initialize) injection data -inj_data = load_data(found_file, ifos, vetoes, opts, injections=True) +inj_data = load_data(found_file, ifos, vetoes, opts, injections=True, slide_id=0) # Generate plots logging.info("Plotting...") From 6f7cec5b7f4da1da25fea35c1eee21f6f04e6516 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Tue, 2 Jul 2024 14:36:40 +0200 Subject: [PATCH 06/36] Update pycbc_pygrb_plot_null_stats pycbc_pygrb_plot_null_stats: propagating slide_id information, here we only want to display slide_id=0 --- bin/pygrb/pycbc_pygrb_plot_null_stats | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_null_stats b/bin/pygrb/pycbc_pygrb_plot_null_stats index 5652ce8dab5..12d0434a06e 100644 --- a/bin/pygrb/pycbc_pygrb_plot_null_stats +++ b/bin/pygrb/pycbc_pygrb_plot_null_stats @@ -47,7 +47,7 @@ __program__ = "pycbc_pygrb_plot_null_stats" # Functions # ============================================================================= # Function to load trigger data -def load_data(input_file, ifos, vetoes, opts, injections=False): +def load_data(input_file, ifos, vetoes, opts, injections=False, slide_id=None): """Load data from a trigger/injection file""" null_stat_type = opts.y_variable @@ -63,12 +63,14 @@ def load_data(input_file, ifos, vetoes, opts, injections=False): # This will eventually become ppu.load_injections() trigs_or_injs = \ ppu.load_triggers(input_file, ifos, vetoes, - rw_snr_threshold=opts.newsnr_threshold) + rw_snr_threshold=opts.newsnr_threshold, + slide_id=slide_id) else: logging.info("Loading triggers...") trigs_or_injs = \ ppu.load_triggers(input_file, ifos, vetoes, - rw_snr_threshold=opts.newsnr_threshold) + rw_snr_threshold=opts.newsnr_threshold, + slide_id=slide_id) # Coherent SNR is always used data['coherent'] = trigs_or_injs['network/coherent_snr'] @@ -183,10 +185,11 @@ ifos, vetoes = ppu.extract_ifos_and_vetoes(trig_file, opts.veto_files, opts.veto_category) # Extract trigger data -trig_data = load_data(trig_file, ifos, vetoes, opts) +trig_data = load_data(trig_file, ifos, vetoes, opts, slide_id=0) # Extract (or initialize) injection data -inj_data = load_data(found_missed_file, ifos, vetoes, opts, injections=True) +inj_data = load_data(found_missed_file, ifos, vetoes, opts, + injections=True, slide_id=0) # Generate plots logging.info("Plotting...") From 5ce9fa3736a18370d3e2379a4b6bed8e08cd94ea Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 19 Jul 2024 15:56:38 +0200 Subject: [PATCH 07/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index 672dd676b5e..74b5e79c5ff 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -176,7 +176,10 @@ def pygrb_add_bestnr_cut_opt(parser): # Wrapper to pick triggers with certain slide_ids # ============================================================================= def slide_filter(File, data, slide_id=None): - """ """ + """ + This function adds the capability to select triggers with specific + slide_ids during the postprocessing stage of PyGRB. + """ mask = numpy.where(File['network/slide_id'][:]==slide_id)[0] if slide_id is not None: From 7b50899f9d11b4c04d723e1e6ca733526c8e3c37 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:05:39 +0200 Subject: [PATCH 08/36] Update pycbc_pygrb_plot_chisq_veto --- bin/pygrb/pycbc_pygrb_plot_chisq_veto | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_chisq_veto b/bin/pygrb/pycbc_pygrb_plot_chisq_veto index 88bcfa384c7..d4e49dbc106 100644 --- a/bin/pygrb/pycbc_pygrb_plot_chisq_veto +++ b/bin/pygrb/pycbc_pygrb_plot_chisq_veto @@ -196,7 +196,6 @@ init_logging(opts.verbose, format="%(asctime)s: %(levelname)s: %(message)s") # Check options trig_file = os.path.abspath(opts.trig_file) -print(trig_file) found_missed_file = os.path.abspath(opts.found_missed_file) \ if opts.found_missed_file else None zoom_in = opts.zoom_in From 152f167f8dc70efd70057451683ef304483ad533 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:06:49 +0200 Subject: [PATCH 09/36] Update pycbc_pygrb_plot_chisq_veto --- bin/pygrb/pycbc_pygrb_plot_chisq_veto | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_chisq_veto b/bin/pygrb/pycbc_pygrb_plot_chisq_veto index d4e49dbc106..08a1aba73a3 100644 --- a/bin/pygrb/pycbc_pygrb_plot_chisq_veto +++ b/bin/pygrb/pycbc_pygrb_plot_chisq_veto @@ -317,5 +317,4 @@ injs = [inj_data[snr_type], inj_data[veto_type]] plu.pygrb_plotter(trigs, injs, x_label, y_label, opts, snr_vals=snr_vals, conts=conts, colors=colors, shade_cont_value=cont_value, vert_spike=True, - cmd=' '.join(sys.argv)) - 321,41 Bot + cmd=' '.join(sys.argv)) 321,41 Bot From c9acf4359e992d73eb11d6041da34db0ae3f6379 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:08:01 +0200 Subject: [PATCH 10/36] Update pycbc_pygrb_plot_chisq_veto --- bin/pygrb/pycbc_pygrb_plot_chisq_veto | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_chisq_veto b/bin/pygrb/pycbc_pygrb_plot_chisq_veto index 08a1aba73a3..41a7e4ba42c 100644 --- a/bin/pygrb/pycbc_pygrb_plot_chisq_veto +++ b/bin/pygrb/pycbc_pygrb_plot_chisq_veto @@ -317,4 +317,4 @@ injs = [inj_data[snr_type], inj_data[veto_type]] plu.pygrb_plotter(trigs, injs, x_label, y_label, opts, snr_vals=snr_vals, conts=conts, colors=colors, shade_cont_value=cont_value, vert_spike=True, - cmd=' '.join(sys.argv)) 321,41 Bot + cmd=' '.join(sys.argv)) From ddfbe0929cf0f673829accf28535ea4a3f17a40b Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:09:14 +0200 Subject: [PATCH 11/36] Update pycbc_pygrb_plot_snr_timeseries --- bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index 992e528faee..61c1d079303 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -166,7 +166,7 @@ inj_data_time = inj_data[x_key][:] if inj_file else None # Obtain SNRs trig_data_snr = trig_data[y_key][:] -inj_data_snr = inj_data[y_key][:] if inj_file else None +inj_data_snr = inj_data[y_key][:] if inj_file else None # Determine the central time (t=0) for the plot central_time = opts.trigger_time From f124f98ec99a9035c106463635a258cbe4494490 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:34:27 +0200 Subject: [PATCH 12/36] Update pygrb_postprocessing_utils.py Minor fixes to satisfy codeclimate --- pycbc/results/pygrb_postprocessing_utils.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index 74b5e79c5ff..bfe5412268a 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -173,15 +173,14 @@ def pygrb_add_bestnr_cut_opt(parser): # ============================================================================= -# Wrapper to pick triggers with certain slide_ids +# Wrapper to pick triggers with certain slide_ids # ============================================================================= def slide_filter(File, data, slide_id=None): - """ - This function adds the capability to select triggers with specific + """ + This function adds the capability to select triggers with specific slide_ids during the postprocessing stage of PyGRB. """ - mask = numpy.where(File['network/slide_id'][:]==slide_id)[0] - + mask = numpy.where(File['network/slide_id'][:] == slide_id)[0] if slide_id is not None: return data[mask] else: @@ -372,7 +371,8 @@ def dataset_iterator(g, prefix=''): yield from dataset_iterator(item, path) -def load_triggers(input_file, ifos, vetoes, rw_snr_threshold=None, slide_id=None): +def load_triggers(input_file, ifos, vetoes, rw_snr_threshold=None, + slide_id=None): """Loads triggers from PyGRB output file, returning a dictionary""" trigs = h5py.File(input_file, 'r') @@ -423,8 +423,8 @@ def load_triggers(input_file, ifos, vetoes, rw_snr_threshold=None, slide_id=None else: trigs_dict[path] = dset[above_thresh] - if trigs_dict[path].size==trigs['network/slide_id'][:].size: - trigs_dict[path] = slide_filter(trigs,trigs_dict[path], + if trigs_dict[path].size == trigs['network/slide_id'][:].size: + trigs_dict[path] = slide_filter(trigs,trigs_dict[path], slide_id=slide_id) return trigs_dict From f81f073c8cc87a562b4cd9a53a8dafc52d5d00e8 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 19 Jul 2024 16:48:54 +0200 Subject: [PATCH 13/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index bfe5412268a..caf702630d1 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -181,10 +181,7 @@ def slide_filter(File, data, slide_id=None): slide_ids during the postprocessing stage of PyGRB. """ mask = numpy.where(File['network/slide_id'][:] == slide_id)[0] - if slide_id is not None: - return data[mask] - else: - return data + return data[mask] if slide_id is not None else data # ============================================================================= @@ -371,7 +368,7 @@ def dataset_iterator(g, prefix=''): yield from dataset_iterator(item, path) -def load_triggers(input_file, ifos, vetoes, rw_snr_threshold=None, +def load_triggers(input_file, ifos, vetoes, rw_snr_threshold=None, slide_id=None): """Loads triggers from PyGRB output file, returning a dictionary""" @@ -424,7 +421,7 @@ def load_triggers(input_file, ifos, vetoes, rw_snr_threshold=None, trigs_dict[path] = dset[above_thresh] if trigs_dict[path].size == trigs['network/slide_id'][:].size: - trigs_dict[path] = slide_filter(trigs,trigs_dict[path], + trigs_dict[path] = slide_filter(trigs, trigs_dict[path], slide_id=slide_id) return trigs_dict From ba5544fdf1fc4619fa43ca0d83003393cc02d755 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:05:56 +0200 Subject: [PATCH 14/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index caf702630d1..20b12a0f80c 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -175,13 +175,16 @@ def pygrb_add_bestnr_cut_opt(parser): # ============================================================================= # Wrapper to pick triggers with certain slide_ids # ============================================================================= -def slide_filter(File, data, slide_id=None): +def slide_filter(trig_file, data, slide_id=None): """ This function adds the capability to select triggers with specific slide_ids during the postprocessing stage of PyGRB. """ - mask = numpy.where(File['network/slide_id'][:] == slide_id)[0] - return data[mask] if slide_id is not None else data + if slide_id is None: + return data + else: + mask = numpy.where(trig_file['network/slide_id'][:] == slide_id)[0] + return data[mask] # ============================================================================= From d43b170f2da36ff9aae2348b60cf869846670596 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:26:19 +0200 Subject: [PATCH 15/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index 20b12a0f80c..48bb3182257 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -182,9 +182,8 @@ def slide_filter(trig_file, data, slide_id=None): """ if slide_id is None: return data - else: - mask = numpy.where(trig_file['network/slide_id'][:] == slide_id)[0] - return data[mask] + mask = numpy.where(trig_file['network/slide_id'][:] == slide_id)[0] + return data[mask] # ============================================================================= From b1ca9d4f3682c0bbb86a794976567aef02b59f49 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 19 Jul 2024 17:33:06 +0200 Subject: [PATCH 16/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index 48bb3182257..f8946a377f8 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -183,7 +183,7 @@ def slide_filter(trig_file, data, slide_id=None): if slide_id is None: return data mask = numpy.where(trig_file['network/slide_id'][:] == slide_id)[0] - return data[mask] + return data[mask] # ============================================================================= From ece6854d1bf0ea26cf0c72c96353a41df2da370d Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:08:01 +0200 Subject: [PATCH 17/36] Update pycbc_pygrb_plot_snr_timeseries --- bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index 61c1d079303..d23cbb09cf9 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -206,4 +206,4 @@ if opts.x_lims: plu.pygrb_plotter([trig_data_time, trig_data_snr], [inj_data_time, inj_data_snr], "Time since %.3f (s)" % (central_time), y_label, - opts, cmd=' '.join(sys.argv), fig=plt.figure()) + opts, cmd=' '.join(sys.argv)) From e46cdcd5e4e2dcd0c5a3c02c14798c6d43043515 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:10:36 +0200 Subject: [PATCH 18/36] Update pygrb_plotting_utils.py --- pycbc/results/pygrb_plotting_utils.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pycbc/results/pygrb_plotting_utils.py b/pycbc/results/pygrb_plotting_utils.py index 75b72636c5b..36d93e0321e 100644 --- a/pycbc/results/pygrb_plotting_utils.py +++ b/pycbc/results/pygrb_plotting_utils.py @@ -188,15 +188,14 @@ def axis_min_value(trig_values, inj_values, inj_file): # ============================================================================= def pygrb_plotter(trigs, injs, xlabel, ylabel, opts, snr_vals=None, conts=None, shade_cont_value=None, - colors=None, vert_spike=False, cmd=None, fig=None): + colors=None, vert_spike=False, cmd=None): """Master function to plot PyGRB results""" from matplotlib import pyplot as plt # Set up plot - if fig is None: - fig = plt.figure() - + fig = plt.figure() cax = fig.gca() + # Plot trigger-related and (if present) injection-related quantities cax_plotter = cax.loglog if opts.use_logs else cax.plot cax_plotter(trigs[0], trigs[1], 'bx') From 0829a269cf0e473cddcf8bc5531666ed0c73707a Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:17:54 +0200 Subject: [PATCH 19/36] Update pycbc_pygrb_plot_snr_timeseries --- bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index d23cbb09cf9..b187e8c17a9 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -59,12 +59,14 @@ def load_data(input_file, ifos, vetoes, rw_snr_threshold=None, # This will eventually become load_injections trigs_or_injs = \ ppu.load_triggers(input_file, ifos, vetoes, - rw_snr_threshold=rw_snr_threshold,slide_id=slide_id) + rw_snr_threshold=rw_snr_threshold, + slide_id=slide_id) else: logging.info("Loading triggers...") trigs_or_injs = \ ppu.load_triggers(input_file, ifos, vetoes, - rw_snr_threshold=rw_snr_threshold,slide_id=slide_id) + rw_snr_threshold=rw_snr_threshold, + slide_id=slide_id) return trigs_or_injs From c67a4a66078f88c6d9ad91e7a8691cbcf52be058 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:24:29 +0200 Subject: [PATCH 20/36] Update pygrb_plotting_utils.py --- pycbc/results/pygrb_plotting_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pycbc/results/pygrb_plotting_utils.py b/pycbc/results/pygrb_plotting_utils.py index 36d93e0321e..b9f518a6b26 100644 --- a/pycbc/results/pygrb_plotting_utils.py +++ b/pycbc/results/pygrb_plotting_utils.py @@ -194,8 +194,7 @@ def pygrb_plotter(trigs, injs, xlabel, ylabel, opts, # Set up plot fig = plt.figure() - cax = fig.gca() - + cax = fig.gca() # Plot trigger-related and (if present) injection-related quantities cax_plotter = cax.loglog if opts.use_logs else cax.plot cax_plotter(trigs[0], trigs[1], 'bx') From 65545969d1f63f6b3f0f1a373465226bdd5a47f2 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Mon, 22 Jul 2024 11:33:45 +0200 Subject: [PATCH 21/36] Update pygrb_plotting_utils.py --- pycbc/results/pygrb_plotting_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycbc/results/pygrb_plotting_utils.py b/pycbc/results/pygrb_plotting_utils.py index b9f518a6b26..f6848b5b623 100644 --- a/pycbc/results/pygrb_plotting_utils.py +++ b/pycbc/results/pygrb_plotting_utils.py @@ -194,7 +194,7 @@ def pygrb_plotter(trigs, injs, xlabel, ylabel, opts, # Set up plot fig = plt.figure() - cax = fig.gca() + cax = fig.gca() # Plot trigger-related and (if present) injection-related quantities cax_plotter = cax.loglog if opts.use_logs else cax.plot cax_plotter(trigs[0], trigs[1], 'bx') From 25e97261f69457d304054f70ba8abc1955f186aa Mon Sep 17 00:00:00 2001 From: sebastian GomezLopez Date: Mon, 22 Jul 2024 07:17:00 -0700 Subject: [PATCH 22/36] Propagating slide_id information to some pygrb plotting scripts --- bin/pygrb/pycbc_pygrb_plot_chisq_veto | 3 ++- bin/pygrb/pycbc_pygrb_plot_coh_ifosnr | 2 +- bin/pygrb/pycbc_pygrb_plot_null_stats | 3 ++- bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 11 +++++++---- pycbc/results/pygrb_postprocessing_utils.py | 4 +++- 5 files changed, 15 insertions(+), 8 deletions(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_chisq_veto b/bin/pygrb/pycbc_pygrb_plot_chisq_veto index 1b6adaa3ac4..a9a889d1a05 100644 --- a/bin/pygrb/pycbc_pygrb_plot_chisq_veto +++ b/bin/pygrb/pycbc_pygrb_plot_chisq_veto @@ -251,7 +251,8 @@ if ifo and ifo not in ifos: raise RuntimeError(err_msg) # Extract trigger data -trig_data = load_data(trig_file, ifos, vetoes, opts, slide_id=0) +trig_data = load_data(trig_file, ifos, vetoes, opts, + slide_id=opts.slide_id) # Extract (or initialize) injection data inj_data = load_data(found_missed_file, ifos, vetoes, opts, diff --git a/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr b/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr index 8adf9bdef0b..57432eb7ad8 100644 --- a/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr +++ b/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr @@ -234,7 +234,7 @@ ifos, vetoes = ppu.extract_ifos_and_vetoes( ) # Extract trigger data -trig_data = load_data(trig_file, ifos, vetoes, opts, slide_id=0) +trig_data = load_data(trig_file, ifos, vetoes, opts, slide_id=opts.slide_id) # Extract (or initialize) injection data inj_data = load_data(found_file, ifos, vetoes, opts, injections=True, slide_id=0) diff --git a/bin/pygrb/pycbc_pygrb_plot_null_stats b/bin/pygrb/pycbc_pygrb_plot_null_stats index 500239191a0..1b40b44e10c 100644 --- a/bin/pygrb/pycbc_pygrb_plot_null_stats +++ b/bin/pygrb/pycbc_pygrb_plot_null_stats @@ -184,7 +184,8 @@ ifos, vetoes = ppu.extract_ifos_and_vetoes(trig_file, opts.veto_files, opts.veto_category) # Extract trigger data -trig_data = load_data(trig_file, ifos, vetoes, opts, slide_id=0) +trig_data = load_data(trig_file, ifos, vetoes, opts, + slide_id=opts.slide_id) # Extract (or initialize) injection data inj_data = load_data(found_missed_file, ifos, vetoes, opts, diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index 7137b77a958..294c83f1f27 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -97,7 +97,7 @@ def reset_times(data_time, trig_time): # ============================================================================= parser = ppu.pygrb_initialize_plot_parser(description=__doc__) parser.add_argument("-t", "--trig-file", action="store", - default=None, required=True, + default=None, required=True, help="The location of the trigger file") parser.add_argument("--found-missed-file", help="The hdf injection results file", required=False) @@ -136,18 +136,21 @@ ifos, vetoes = ppu.extract_ifos_and_vetoes(trig_file, opts.veto_files, # points to show the impact of the cut, otherwise remove points with # reweighted SNR below threshold if snr_type == 'reweighted': - trig_data = load_data(trig_file, ifos, vetoes, slide_id=0) + trig_data = load_data(trig_file, ifos, vetoes, + slide_id=opts.slide_id) trig_data['network/reweighted_snr'] = \ reweightedsnr_cut(trig_data['network/reweighted_snr'], opts.newsnr_threshold) - inj_data = load_data(inj_file, ifos, vetoes, injections=True,slide_id=0) + inj_data = load_data(inj_file, ifos, vetoes, injections=True, + slide_id=0) if inj_data is not None: inj_data['network/reweighted_snr'] = \ reweightedsnr_cut(inj_data['network/reweighted_snr'], opts.newsnr_threshold) else: trig_data = load_data(trig_file, ifos, vetoes, - rw_snr_threshold=opts.newsnr_threshold, slide_id=0) + rw_snr_threshold=opts.newsnr_threshold, + slide_id=opts.slide_id) inj_data = load_data(inj_file, ifos, vetoes, rw_snr_threshold=opts.newsnr_threshold, injections=True, slide_id=0) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index 61f24201f8d..c774f5e43b1 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -92,7 +92,9 @@ def pygrb_initialize_plot_parser(description=None): parser.add_argument('--plot-caption', default=None, help="If provided, use the given string as the plot " + "caption") - + parser.add_argument("--slide-id", default=0, type=int, + help="If None, the plotting scripts will use triggers" + + "from all slides. Most plots only need the slide_id=0") return parser From 28c7278776e83ee3ad396086b757d7c6a053c11c Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Mon, 22 Jul 2024 16:26:44 +0200 Subject: [PATCH 23/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index c774f5e43b1..36a52628d44 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -93,8 +93,8 @@ def pygrb_initialize_plot_parser(description=None): help="If provided, use the given string as the plot " + "caption") parser.add_argument("--slide-id", default=0, type=int, - help="If None, the plotting scripts will use triggers" + - "from all slides. Most plots only need the slide_id=0") + help="If None, plotting scripts will use triggers" + + "from all short slides.") return parser From bb20dcc7ec20940ce02ace75e76c116a673e2cf3 Mon Sep 17 00:00:00 2001 From: sebastian GomezLopez Date: Wed, 24 Jul 2024 10:13:17 -0700 Subject: [PATCH 24/36] Modification to slides parser. Update to plotting scripts --- bin/pygrb/pycbc_pygrb_plot_chisq_veto | 2 ++ bin/pygrb/pycbc_pygrb_plot_coh_ifosnr | 2 ++ bin/pygrb/pycbc_pygrb_plot_null_stats | 2 ++ bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 3 +++ pycbc/results/pygrb_postprocessing_utils.py | 13 +++++++++++++ 5 files changed, 22 insertions(+) diff --git a/bin/pygrb/pycbc_pygrb_plot_chisq_veto b/bin/pygrb/pycbc_pygrb_plot_chisq_veto index a9a889d1a05..966798fc0f2 100644 --- a/bin/pygrb/pycbc_pygrb_plot_chisq_veto +++ b/bin/pygrb/pycbc_pygrb_plot_chisq_veto @@ -189,7 +189,9 @@ parser.add_argument("--snr-type", default='coherent', 'single'], help="SNR value to plot on x-axis.") ppu.pygrb_add_bestnr_cut_opt(parser) ppu.pygrb_add_bestnr_opts(parser) +ppu.pygrb_add_slide_opts(parser) opts = parser.parse_args() +ppu.slide_opts_helper(opts) init_logging(opts.verbose, format="%(asctime)s: %(levelname)s: %(message)s") diff --git a/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr b/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr index 57432eb7ad8..5a2b88321e2 100644 --- a/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr +++ b/bin/pygrb/pycbc_pygrb_plot_coh_ifosnr @@ -188,7 +188,9 @@ parser.add_argument( help="Output file a zoomed in version of the plot.", ) ppu.pygrb_add_bestnr_cut_opt(parser) +ppu.pygrb_add_slide_opts(parser) opts = parser.parse_args() +ppu.slide_opts_helper(opts) init_logging(opts.verbose, format="%(asctime)s: %(levelname)s: %(message)s") diff --git a/bin/pygrb/pycbc_pygrb_plot_null_stats b/bin/pygrb/pycbc_pygrb_plot_null_stats index 1b40b44e10c..2a3f1b95029 100644 --- a/bin/pygrb/pycbc_pygrb_plot_null_stats +++ b/bin/pygrb/pycbc_pygrb_plot_null_stats @@ -142,7 +142,9 @@ parser.add_argument("-y", "--y-variable", default=None, help="Quantity to plot on the vertical axis.") ppu.pygrb_add_null_snr_opts(parser) ppu.pygrb_add_bestnr_cut_opt(parser) +ppu.pygrb_add_slide_opts(parser) opts = parser.parse_args() +ppu.slide_opts_helper(opts) init_logging(opts.verbose, format="%(asctime)s: %(levelname)s: %(message)s") diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index 294c83f1f27..0cb7d31fb7b 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -96,6 +96,7 @@ def reset_times(data_time, trig_time): # Main script starts here # ============================================================================= parser = ppu.pygrb_initialize_plot_parser(description=__doc__) +pygrb_add_slide_opts(parser) parser.add_argument("-t", "--trig-file", action="store", default=None, required=True, help="The location of the trigger file") @@ -107,7 +108,9 @@ parser.add_argument("-y", "--y-variable", default=None, choices=['coherent', 'single', 'reweighted', 'null'], help="Quantity to plot on the vertical axis.") ppu.pygrb_add_bestnr_cut_opt(parser) +ppu.pygrb_add_slide_opts(parser) opts = parser.parse_args() +ppu.slide_opts_helper(opts) init_logging(opts.verbose, format="%(asctime)s: %(levelname)s: %(message)s") diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index c774f5e43b1..7a43519e802 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -97,6 +97,19 @@ def pygrb_initialize_plot_parser(description=None): "from all slides. Most plots only need the slide_id=0") return parser +def pygrb_add_slide_opts(parser): + """Add to parser object arguments related to short timeslides""" + parser.add_argument("--slide-id", type=str, default='0', + help="If all, the plotting scripts will use triggers" + + "from all short slides.") + +def slide_opts_helper(args): + if args.slide_id.isdigit(): + args.slide_id = int(args.slide_id) + elif args.slide_id.lower() == "all": + args.slide_id = None + else: + raise ValueError("--slide-id must be all or int") def pygrb_add_injmc_opts(parser): """Add to parser object the arguments used for Monte-Carlo on distance.""" From 3351184621e974ae9cecdb6147358d8f1815a2b8 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Wed, 24 Jul 2024 19:21:30 +0200 Subject: [PATCH 25/36] Update pycbc_pygrb_plot_snr_timeseries --- bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index 0cb7d31fb7b..2c0dd3debe3 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -44,6 +44,7 @@ __version__ = pycbc.version.git_verbose_msg __date__ = pycbc.version.date __program__ = "pycbc_pygrb_plot_snr_timeseries" + # ============================================================================= # Functions # ============================================================================= @@ -209,7 +210,6 @@ xlims = [start, end] if opts.x_lims: xlims = opts.x_lims xlims = map(float, xlims.split(',')) - plu.pygrb_plotter([trig_data_time, trig_data_snr], [inj_data_time, inj_data_snr], "Time since %.3f (s)" % (central_time), y_label, From 08db76f21768a1ce3ef523c1e03aad823e8651f8 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Wed, 24 Jul 2024 23:08:50 +0200 Subject: [PATCH 26/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index aee2bb09514..70c40dc4f23 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -96,20 +96,27 @@ def pygrb_initialize_plot_parser(description=None): help="If None, plotting scripts will use triggers" + "from all short slides.") return parser + def pygrb_add_slide_opts(parser): """Add to parser object arguments related to short timeslides""" parser.add_argument("--slide-id", type=str, default='0', help="If all, the plotting scripts will use triggers" + "from all short slides.") + def slide_opts_helper(args): + """ + This function overwrites the types of input slide_id information + when loading data in postprocessing scripts. + """ if args.slide_id.isdigit(): args.slide_id = int(args.slide_id) elif args.slide_id.lower() == "all": args.slide_id = None else: raise ValueError("--slide-id must be all or int") + def pygrb_add_injmc_opts(parser): """Add to parser object the arguments used for Monte-Carlo on distance.""" From 18ea7b138d7580b1b923f6b3633675b5725475f4 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Wed, 24 Jul 2024 23:18:59 +0200 Subject: [PATCH 27/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index 70c40dc4f23..2762f47d179 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -96,18 +96,18 @@ def pygrb_initialize_plot_parser(description=None): help="If None, plotting scripts will use triggers" + "from all short slides.") return parser - + def pygrb_add_slide_opts(parser): """Add to parser object arguments related to short timeslides""" parser.add_argument("--slide-id", type=str, default='0', help="If all, the plotting scripts will use triggers" + "from all short slides.") - + def slide_opts_helper(args): """ - This function overwrites the types of input slide_id information + This function overwrites the types of input slide_id information when loading data in postprocessing scripts. """ if args.slide_id.isdigit(): @@ -116,7 +116,7 @@ def slide_opts_helper(args): args.slide_id = None else: raise ValueError("--slide-id must be all or int") - + def pygrb_add_injmc_opts(parser): """Add to parser object the arguments used for Monte-Carlo on distance.""" From 55a43120c4962a824cafec8d01ff754b14f467ae Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Thu, 25 Jul 2024 09:17:56 +0200 Subject: [PATCH 28/36] Update pycbc_pygrb_plot_snr_timeseries --- bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index 2c0dd3debe3..4d77f45fec8 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -97,7 +97,6 @@ def reset_times(data_time, trig_time): # Main script starts here # ============================================================================= parser = ppu.pygrb_initialize_plot_parser(description=__doc__) -pygrb_add_slide_opts(parser) parser.add_argument("-t", "--trig-file", action="store", default=None, required=True, help="The location of the trigger file") From 368e14a0b58a650e16a4cb8111702da1a1a02c51 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:13:37 +0200 Subject: [PATCH 29/36] Update pycbc_pygrb_plot_snr_timeseries --- bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index 4d77f45fec8..e57b307c8df 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -98,7 +98,7 @@ def reset_times(data_time, trig_time): # ============================================================================= parser = ppu.pygrb_initialize_plot_parser(description=__doc__) parser.add_argument("-t", "--trig-file", action="store", - default=None, required=True, + default=None, required=True, help="The location of the trigger file") parser.add_argument("--found-missed-file", help="The hdf injection results file", required=False) From 229ca556497a8b42794d731620a0a29f3bfd7b00 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:14:29 +0200 Subject: [PATCH 30/36] Update pycbc_pygrb_plot_snr_timeseries --- bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 1 - 1 file changed, 1 deletion(-) diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index e57b307c8df..868b3ae6f94 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -171,7 +171,6 @@ trig_data_time = trig_data[x_key][:] inj_data_time = inj_data[x_key][:] if inj_file else None # Obtain SNRs - trig_data_snr = trig_data[y_key][:] inj_data_snr = inj_data[y_key][:] if inj_file else None From c991754669ed303473f0eca156554224ce7a35a0 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:20:25 +0200 Subject: [PATCH 31/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index 2762f47d179..81c3a33c70f 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -92,9 +92,6 @@ def pygrb_initialize_plot_parser(description=None): parser.add_argument('--plot-caption', default=None, help="If provided, use the given string as the plot " + "caption") - parser.add_argument("--slide-id", default=0, type=int, - help="If None, plotting scripts will use triggers" + - "from all short slides.") return parser From 678da8be6808d707ccf85a0085454432cb1ac018 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:27:11 +0200 Subject: [PATCH 32/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index 81c3a33c70f..ca81e179fe6 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -92,6 +92,7 @@ def pygrb_initialize_plot_parser(description=None): parser.add_argument('--plot-caption', default=None, help="If provided, use the given string as the plot " + "caption") + return parser From a7bfb0ffb6a23b14c267835dd1dd27479f1cf601 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:28:07 +0200 Subject: [PATCH 33/36] Update pycbc_pygrb_plot_snr_timeseries --- bin/pygrb/pycbc_pygrb_plot_snr_timeseries | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries index 868b3ae6f94..2f8266cca32 100644 --- a/bin/pygrb/pycbc_pygrb_plot_snr_timeseries +++ b/bin/pygrb/pycbc_pygrb_plot_snr_timeseries @@ -68,6 +68,7 @@ def load_data(input_file, ifos, vetoes, rw_snr_threshold=None, ppu.load_triggers(input_file, ifos, vetoes, rw_snr_threshold=rw_snr_threshold, slide_id=slide_id) + return trigs_or_injs From bc819799fed8b9b4f859a338bfffb5546baa0552 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:34:14 +0200 Subject: [PATCH 34/36] Update pygrb_postprocessing_utils.py From a53fef0013d0e15bd2efd3751a15958361eff04a Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:38:34 +0200 Subject: [PATCH 35/36] Update pygrb_postprocessing_utils.py --- pycbc/results/pygrb_postprocessing_utils.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index ca81e179fe6..81c3a33c70f 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -92,7 +92,6 @@ def pygrb_initialize_plot_parser(description=None): parser.add_argument('--plot-caption', default=None, help="If provided, use the given string as the plot " + "caption") - return parser From 2c7c177b372208a8db9b1a295f41d912b9e02227 Mon Sep 17 00:00:00 2001 From: segomezlo <92443572+sebastiangomezlopez@users.noreply.github.com> Date: Fri, 26 Jul 2024 08:57:33 +0200 Subject: [PATCH 36/36] Update pycbc/results/pygrb_postprocessing_utils.py Co-authored-by: Francesco Pannarale --- pycbc/results/pygrb_postprocessing_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycbc/results/pygrb_postprocessing_utils.py b/pycbc/results/pygrb_postprocessing_utils.py index 81c3a33c70f..99e562f1df5 100644 --- a/pycbc/results/pygrb_postprocessing_utils.py +++ b/pycbc/results/pygrb_postprocessing_utils.py @@ -112,7 +112,7 @@ def slide_opts_helper(args): elif args.slide_id.lower() == "all": args.slide_id = None else: - raise ValueError("--slide-id must be all or int") + raise ValueError("--slide-id must be the string all or an int") def pygrb_add_injmc_opts(parser):