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

Enforce pygrb_efficiency subsections #4909

Merged
merged 3 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/pygrb/pycbc_pygrb_efficiency
Original file line number Diff line number Diff line change
Expand Up @@ -573,7 +573,7 @@ if opts.background_output_file:
ax.legend()
ax.grid()
ax.set_ylim([0, 1])
ax.set_xlim(0, 2.*upper_dist - lower_dist)
ax.set_xlim(0, 1.3*upper_dist)
ax.set_ylabel("Fraction of injections found louder than loudest background")
ax.set_xlabel("Distance (Mpc)")
plot_title = "Detection efficiency - "+inj_set_name
Expand Down Expand Up @@ -655,13 +655,13 @@ if opts.onsource_output_file:
ax.get_legend().get_frame().set_alpha(0.5)
ax.grid()
ax.set_ylim([0, 1])
ax.set_xlim(0, 2.*upper_dist - lower_dist)
ax.set_xlim(0, 1.3*upper_dist)
ax.set_ylabel("Fraction of injections found louder than " +
"loudest foreground")
ax.set_xlabel("Distance (Mpc)")
ax.plot([excl_dist], [0.9], 'gx')
ax.set_ylim([0, 1])
ax.set_xlim(0, 2.*upper_dist - lower_dist)
ax.set_xlim(0, 1.3*upper_dist)
plot_title = "Exclusion distance - "+inj_set_name
plot_caption = "Injection recovery efficiency using "
plot_caption += "BestNR as detection statistic. "
Expand Down
10 changes: 9 additions & 1 deletion bin/pygrb/pycbc_pygrb_results_workflow
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,15 @@ logging.info("Offtrials: %s", [f.storage_path for f in offtrial_files])
bank_file = os.path.join(start_rundir, args.bank_file)
bank_file = _workflow.resolve_url_to_file(bank_file)

# File instances of the input injection files
# Sanity check and File instances of the input injection files
inj_sets = wflow.cp.get_subsections('injections')
eff_secs = wflow.cp.get_subsections('pygrb_efficiency')
if not set(inj_sets).issubset(eff_secs):
err_msg = "Each [injections] subsection requires at "
err_msg += "least one dedicated [pygrb_efficiency] subsection. "
err_msg += "[injections] subsections found: %s. "
err_msg += "[pygrb_efficiency] subsections found: %s. "
logging.error(err_msg, inj_sets, eff_secs)
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, there might be use cases where these subsections wouldn't be needed (e.g. running only one injection set, or just running a NS injection set ... maybe some new theory proves next year that NSBH GRBs definitely don't exist), but if it's better to enforce this, I won't object

Enforcing the two lists be equal is possibly not what you want, there could be other subsections in efficiency that are not injection names. I think you really want to check that inj_sets is a subset of eff_secs.

if set(inj_sets).issubset(eff_secs):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, I see your point. I may want to make more efficiency plot versions, so I need at least enough eff_secs to cover the inj_sets. I will make this change shortly.

inj_sets = [i.upper() for i in inj_sets]
inj_files = labels_in_files_metadata(inj_sets, start_rundir, args.inj_files)

Expand Down Expand Up @@ -532,6 +539,7 @@ for stat in stats:
out_dir,
trig_file=offsource_file,
inj_file=inj_file,
seg_files=seg_files,
tags=[stat],
)
plotting_nodes.append(plot_node)
Expand Down
Loading