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

Handling empty table in PyGRB #5026

Merged
merged 6 commits into from
Jan 30, 2025
Merged

Conversation

pannarale
Copy link
Contributor

@pannarale pannarale commented Jan 30, 2025

This PR enables the production of tables, within PyGRB, when the table needs to be empty.

Standard information about the request

This is a: new feature

This change affects: PyGRB

This change changes: result presentation

Motivation

The current version of pycbc_pygrb_page_tables (designed to handle missed/vetoed injections and loudest events) will not work when there is no injection/trigger to be displayed.

Contents

This PR fixes this issue. The script no longer assumes there are injections to be displayed; further, it checks whether there is an onsource trigger to be reported: if there is not, the h5 file will be empty, where as the html file will say "There are no events" in the first column and report "-" in the remaining columns, to leave a human readable message.

Testing performed

The functioning of this can be checked in sections 3.01, 3.03, and 6 of this webpage.

Additional notes

The code to handle the case in which the offsource yields no triggers is along the lines of the one implemented for the injections, but admittedly it is not tested in this run.

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

@pannarale pannarale added the PyGRB PyGRB development label Jan 30, 2025
@pannarale pannarale self-assigned this Jan 30, 2025
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.

Looks good, but I have some suggestions that may make this code better.

Comment on lines 502 to 504
loud_on_bestnr_trigs, loud_on_bestnr = \
(on_trigs['network/event_id'][bestNR_event],
on_trigs_bestnrs[bestNR_event])
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this assignment is more readable in two lines.

bin/pygrb/pycbc_pygrb_page_tables Outdated Show resolved Hide resolved
@@ -646,6 +657,10 @@ if found_missed_file is not None:
len(td))
td = list(zip(*td))

# Handle the case in which there is no data to be placed in the table
if not td:
td = [[] for i in np.arange(len(th))]
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment on similar block above.

# When len(offsource_trigs) == 0, the loop above leaves td = [] unchanged
# and this case needs to be handled adequately prior to moving on
if not td:
td = [[] for i in np.arange(len(th))]
Copy link
Contributor

Choose a reason for hiding this comment

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

See comment on similar block below.

bin/pygrb/pycbc_pygrb_page_tables Outdated Show resolved Hide resolved
pannarale and others added 4 commits January 30, 2025 06:06
Co-authored-by: Tito Dal Canton <tito@dalcanton.it>
Co-authored-by: Tito Dal Canton <tito@dalcanton.it>
@pannarale pannarale merged commit bf5ff50 into gwastro:master Jan 30, 2025
30 of 31 checks passed
@pannarale pannarale deleted the handle_empty_tables branch January 30, 2025 17:47
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.

2 participants