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

Multiifo ranking statistic #2689

Merged
merged 16 commits into from
Jun 12, 2019

Conversation

GarethCabournDavies
Copy link
Contributor

Multiifo ranking statistic:

Currently calculates the expected rate of coincidences at a given snr value, and subtracts this from a mean coincidence rate (this is a rate for all coincidences, not including the snr infromation) in that detector combination

pycbc/events/stat.py Outdated Show resolved Hide resolved
pycbc/events/stat.py Outdated Show resolved Hide resolved
pycbc/events/stat.py Outdated Show resolved Hide resolved
pycbc/events/stat.py Outdated Show resolved Hide resolved
pycbc/events/stat.py Outdated Show resolved Hide resolved
@tdent
Copy link
Contributor

tdent commented May 13, 2019

@GarethDaviesGW in general, you should not be repeating code blocks from existing classes. You can inherit their methods by making the new class a subclass/child class of them, or (less preferable) by explicitly calling a method of an existing class.

pycbc/events/stat.py Outdated Show resolved Hide resolved
@GarethCabournDavies GarethCabournDavies force-pushed the multiifo_ranking_statistic branch from d2bebb2 to 8a6d72d Compare May 22, 2019 16:30
pycbc/events/coinc_rate.py Outdated Show resolved Hide resolved
@GarethCabournDavies GarethCabournDavies force-pushed the multiifo_ranking_statistic branch from ea757e4 to 06b0e38 Compare May 29, 2019 09:39
Copy link
Contributor

@tdent tdent left a comment

Choose a reason for hiding this comment

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

See comments. How is the testing / comparison with exp_fit_sg_csnr ?

pycbc/events/coinc_rate.py Outdated Show resolved Hide resolved
pycbc/events/stat.py Outdated Show resolved Hide resolved
pycbc/events/stat.py Outdated Show resolved Hide resolved
pycbc/events/stat.py Show resolved Hide resolved
pycbc/events/stat.py Outdated Show resolved Hide resolved
pycbc/events/stat.py Outdated Show resolved Hide resolved
@GarethCabournDavies
Copy link
Contributor Author

Scatter vs exp_fit_sg_csnr:
image

histograms of the two statistics:
image

@GarethCabournDavies GarethCabournDavies force-pushed the multiifo_ranking_statistic branch from 7a715f4 to 87d5527 Compare June 11, 2019 16:42

# if more than one possible coincidence type exists,
# calculate coincidence for subsets through recursion
if len(ifos) > 2:
ifos = numpy.array(sorted(rates.keys()))
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason why they need to be sorted?

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 line is not actually needed, as it is just repeating line 39

In that case, it is needed to ensure consistency for the ordering of the ifostring dict key. Otherwise I think the ordering is not stable

The conversion to a numpy array however is not needed and is removed

pycbc/events/stat.py Outdated Show resolved Hide resolved
Value is expected coincidence rate in the combination, units Hz
"""
# extract ifo list and rates vectors from the dictionary
ifos = numpy.array(rates.keys())
Copy link
Contributor

Choose a reason for hiding this comment

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

does ifos have to be a numpy array? the noise coincident area function says it takes a list of ifos.

similarly, does it work to just use rates.values() for the rate vectors?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, ifos doesn't have to be a numpy array

Aslo, rates.values() works and I have updated

Testing this on my laptop rather than the cluster (by accident) has shown that the behaviour of dictionary.keys() and dictionary.values() will change in python 3; in python 3 they give specific dict_keys and dict_values objects (tagging @spxiwh in this as he has been working on python 3 updates)

As such, for future-proofing, I have included a list() wrapper around the .keys() call, which does nothing in python 2 but changes them back to being a list in python 3
The dictionary.values() being a dict_values object rather than list doesn't matter in this case as it is being looped over and acts in exactly the same way

I have done the same on line 39 to convert the keys to a list

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. It looks like list(mydict) would be the same as list(mydict.keys()) so that's one less pair of brackets. I'll edit this in the browser and then I think we're finished for this iteration

@gwastro gwastro deleted a comment from GarethCabournDavies Jun 12, 2019
@tdent
Copy link
Contributor

tdent commented Jun 12, 2019

will merge assuming that 'final' tests work out.

@tdent tdent merged commit 0adb7f0 into gwastro:master Jun 12, 2019
@GarethCabournDavies GarethCabournDavies deleted the multiifo_ranking_statistic branch November 28, 2019 16:10
OliverEdy pushed a commit to OliverEdy/pycbc that referenced this pull request Apr 3, 2023
* initial commit of coinc_rate stat

* update to an actual working statistic

* codeclimate changes, change to use SG veto in coinc_rate statistic

* some reworking of statistic, a bit of housekeeping with coinc_rate calculation

* some changes for clening up code - some print statements may be in place for testing. Ignore these and they will be removed

* some tidying up

* commit for changing branch

* use count above thresh as that is how fitting calculates

* accidentally copied some slack chat into the code

* codeclimate again

* some changes to master not integrated to branch

* updates to comments, some casting to arrays not needed. Small future-proofing for python 3

* be more numpy-y, add minor comment
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