Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Final version of pycbc_pygrb_plot_chisq_veto and pycbc_pygrb_plot_coh_ifosnr #4950

Merged
merged 14 commits into from
Nov 23, 2024

Conversation

pannarale
Copy link
Contributor

This PR is the fifth in the series started in PR #4929. Much like PR #4947 did with pycbc_pygrb_plot_null_stats, this PR provides a version of pycbc_pygrb_plot_chisq_veto and pycbc_pygrb_plot_coh_ifosnr that uses veto and segments files, as well as the utilities introduced recently to streamline the PyGRB results scripts.

Standard information about the request (and the following ones that will be linked to this)

This is a: a new feature enabling veto definer file usage in PyGRB. Utilities and scripts in results production are being streamlined along the way.

This change affects: PyGRB

This change changes: result presentation / plotting and scientific output.

Should this change break the standard automated test running --help for PyGRB plotting scripts, I will add some workarounds to avoid this. If needed, these will likely be empty functions: the plotting scripts will be progressively renovated in the whole series of PRs.

Motivation

Now that the workflow generator passes the veto definer file to the jobs where needed, its usage in the PyGRB results scripts is possible.

Testing performed

The totality of the changes that will be broken down in multiple PRs was tested on GRB 170817A data by producing a full results webpage (see here).

  • The author of this pull request confirms they will adhere to the code of conduct

…e apply_vetoes_to_found_injs for the time being)
…e apply_vetoes_to_found_injs for the time being)
@pannarale pannarale added the PyGRB PyGRB development label Nov 20, 2024
@pannarale pannarale self-assigned this Nov 20, 2024
Comment on lines -250 to -253
# Exit gracefully if the requested IFO is not available
if ifo and ifo not in ifos:
err_msg = "The IFO selected with --ifo is unavailable in the data."
raise RuntimeError(err_msg)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in ppu.extract_ifos

Comment on lines +173 to +200
# Extract IFOs
ifos = ppu.extract_ifos(trig_file)

# Generate time-slides dictionary
slide_dict = ppu.load_time_slides(trig_file)

# Generate segments dictionary
segment_dict = ppu.load_segment_dict(trig_file)

# Construct trials removing vetoed times
trial_dict, total_trials = ppu.construct_trials(
opts.seg_files,
segment_dict,
ifos,
slide_dict,
opts.veto_file
)

# Load trigger and injections data: ensure that newtwork power chi-square plots
# show all the data to see the impact of the reweighted SNR cut, otherwise remove
# points with reweighted SNR below threshold
rw_snr_threshold = None if veto_type == 'network' else opts.newsnr_threshold
trig_data = ppu.load_data(trig_file, ifos, data_tag='trigs',
rw_snr_threshold=rw_snr_threshold,
slide_id=opts.slide_id)
inj_data = ppu.load_data(found_missed_file, ifos, data_tag='injs',
rw_snr_threshold=rw_snr_threshold,
slide_id=0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is equivalent to what is now in pycbc_pygrb_plot_null_stats.

Comment on lines +221 to +243
# Extract needed trigger properties and store them as dictionaries
# Based on trial_dict: if vetoes were applied, trig_* are the veto survivors
found_trigs_slides = ppu.extract_trig_properties(
trial_dict,
trig_data,
slide_dict,
segment_dict,
keys
)
found_trigs = {}
for key in keys:
found_trigs[key] = numpy.concatenate(
[found_trigs_slides[key][slide_id][:] for slide_id in slide_dict]
)

# Gather injections found surviving vetoes
found_injs, *_ = ppu.apply_vetoes_to_found_injs(
opts.found_missed_file,
inj_data,
ifos,
veto_file=opts.veto_file,
keys=keys
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is equivalent to what is now in pycbc_pygrb_plot_null_stats.

Comment on lines +144 to +159
# Extract IFOs
ifos = ppu.extract_ifos(trig_file)

# Generate time-slides dictionary
slide_dict = ppu.load_time_slides(trig_file)

# Generate segments dictionary
segment_dict = ppu.load_segment_dict(trig_file)

# Construct trials removing vetoed times
trial_dict, total_trials = ppu.construct_trials(
opts.seg_files,
segment_dict,
ifos,
slide_dict,
opts.veto_file
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is equivalent to what is now in pycbc_pygrb_plot_null_stats.

Comment on lines +162 to +168
# Load triggers/injections (apply reweighted SNR cut, not vetoes)
trig_data = ppu.load_data(trig_file, ifos, data_tag='trigs',
rw_snr_threshold=opts.newsnr_threshold,
slide_id=opts.slide_id)
inj_data = ppu.load_data(found_missed_file, ifos, data_tag='injs',
rw_snr_threshold=opts.newsnr_threshold,
slide_id=0)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is equivalent to what is now in pycbc_pygrb_plot_null_stats.

Comment on lines +184 to +190
found_trigs_slides = ppu.extract_trig_properties(
trial_dict,
trig_data,
slide_dict,
segment_dict,
keys
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is equivalent to what is now in pycbc_pygrb_plot_null_stats.

Copy link
Contributor

@MarcoCusinato MarcoCusinato left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with @titodalcanton on the chi square == 0. Also minor comment, would it be possible to rename the variable senstvty and ifo_senstvty to sensitivity in pycbc_pygrb_plot_coh_ifosnr?

bin/pygrb/pycbc_pygrb_plot_chisq_veto Show resolved Hide resolved
Copy link
Contributor

@titodalcanton titodalcanton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No further comments from me.

@pannarale pannarale merged commit b7cb8bc into gwastro:master Nov 23, 2024
29 checks passed
@pannarale pannarale deleted the pygrb_vetoes branch November 23, 2024 00:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PyGRB PyGRB development
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants