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

iDQ based veto in PyCBC Live #4175

Merged
merged 28 commits into from
Nov 29, 2022
Merged

Conversation

maxtrevor
Copy link
Contributor

This PR adds the option to create vetoes by thresholding on a data quality timeseries.

maxtrevor and others added 23 commits May 27, 2020 20:43
Add support for dynesty's dynamic nested sampler (gwastro#3288)
Live combine fits missing bins bug (gwastro#3320)
Rebase from gwastro master
@maxtrevor
Copy link
Contributor Author

@titodalcanton

pycbc/frame/frame.py Outdated Show resolved Hide resolved
bin/pycbc_live Outdated Show resolved Hide resolved
bin/pycbc_live Outdated Show resolved Hide resolved
bin/pycbc_live Outdated Show resolved Hide resolved
bin/pycbc_live Outdated Show resolved Hide resolved
bin/pycbc_live Outdated
# for triggers with valid idq info, only keep those with
# idq FAP > threshold
valid_idx = numpy.where(idq_valid)[0]
valid_keep = data_reader[ifo].idq.indices_of_flag(
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit confused by what is being done here. What is the reasoning behind using at_times() for the iDQ status channel and indices_of_flag() for the iDQ FAP channel? Where are you actually checking that the iDQ FAP is above the given threshold?

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry I overlooked the code that answers the second question, but the first one stands.

@titodalcanton
Copy link
Contributor

@maxtrevor overall comment: I think there is a genuine bug, apart from that this should do what we want. I would like to propose an alternative implementation though. I do not particularly like the idea of having to carry around two StatusBuffer objects for iDQ and having to worry about that in the main pycbc_live script. Have you considered having a single iDQBuffer object that carries its two StatusBuffer objects as attributes, and knows how to properly treat them as a pair?

@maxtrevor
Copy link
Contributor Author

Ok I've addressed the obvious bug of using the wrong channel and the various one line changes you suggested. I will work on the logic for using both timeseries together and managing them with one object.

@titodalcanton
Copy link
Contributor

In light of @maxtrevor's comment about iDQ status channel type, and after more carefully reviewing the current code in pycbc.frame, I am now turning my previous comment into a stronger request, and I would prefer not merging until that change is made.

Note that the DataBuffer class has a dtype parameter. It defaults to float, but StatusBuffer changes it to integer when inheriting from DataBuffer. Given that iDQ channels are all float instead (let's ignore whether that is appropriate or not) then using two StatusBuffer objects to hold the iDQ data does not seem the correct approach to me. I think we really want a single iDQBuffer class that carries two float DataBuffer attributes for value and status, but does not inherit from DataBuffer itself. We are then free to implement whatever specific logic iDQ uses (based on floats or ints, one or two channels, etc) inside the iDQ-specific class, and StatusBuffer can continue to retain its current meaning as a simpler integer bitmask status information.

Does this make sense?

@maxtrevor
Copy link
Contributor Author

In light of @maxtrevor's comment about iDQ status channel type, and after more carefully reviewing the current code in pycbc.frame, I am now turning my previous comment into a stronger request, and I would prefer not merging until that change is made.

Note that the DataBuffer class has a dtype parameter. It defaults to float, but StatusBuffer changes it to integer when inheriting from DataBuffer. Given that iDQ channels are all float instead (let's ignore whether that is appropriate or not) then using two StatusBuffer objects to hold the iDQ data does not seem the correct approach to me. I think we really want a single iDQBuffer class that carries two float DataBuffer attributes for value and status, but does not inherit from DataBuffer itself. We are then free to implement whatever specific logic iDQ uses (based on floats or ints, one or two channels, etc) inside the iDQ-specific class, and StatusBuffer can continue to retain its current meaning as a simpler integer bitmask status information.

Does this make sense?

It does make sense. I think I am most of the way to having this working already.

One thing occurred to me though. The StatusBuffer object uses dtype int unless told otherwise. So why was it giving me an error unless I explicitly cast to int? It seems like it used a float anyways even though the default dtype was int. This is mostly irrelevant but it doesnt seem to make any sense.

@maxtrevor
Copy link
Contributor Author

@titodalcanton I think this now does everything we want

@maxtrevor
Copy link
Contributor Author

This should be ready to go at this point, I have an analysis that has been running for the last 24 hours and has vetoes active at expected times

@titodalcanton
Copy link
Contributor

This seems ok to be merged now. Just a minor final request: do you need to store the iDQ threshold as an attribute of the StrainBuffer? If not, please remove it.

@titodalcanton
Copy link
Contributor

…and same comment for the at_times() method of DataBuffer.

@titodalcanton titodalcanton enabled auto-merge (squash) November 29, 2022 16:16
@titodalcanton titodalcanton merged commit e3a7f69 into gwastro:master Nov 29, 2022
bhooshan-gadre pushed a commit to bhooshan-gadre/pycbc that referenced this pull request Jan 25, 2023
* Added veto based on iDQ false alarm probability

* Bugfix to use correct idq state channel, and address some of Tito's comments

* Changed iDQ buffer object to manage two DataBuffer objects

* Fixed stylistic issues

* Fixed frame read error

* Addressed Tito's comments
acorreia61201 pushed a commit to acorreia61201/pycbc that referenced this pull request Apr 4, 2024
* Added veto based on iDQ false alarm probability

* Bugfix to use correct idq state channel, and address some of Tito's comments

* Changed iDQ buffer object to manage two DataBuffer objects

* Fixed stylistic issues

* Fixed frame read error

* Addressed Tito's comments
@maxtrevor maxtrevor deleted the live_veto_dev branch May 1, 2024 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants