Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gstlal
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Duncan Macleod
gstlal
Commits
ec3859c1
Commit
ec3859c1
authored
6 years ago
by
Kipp Cannon
Browse files
Options
Downloads
Patches
Plain Diff
inspiral_lr: define NegInf symbol
- avoid evaluating float("-inf") in performance sensitive paths
parent
820ce854
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gstlal-inspiral/python/stats/inspiral_lr.py
+12
-7
12 additions, 7 deletions
gstlal-inspiral/python/stats/inspiral_lr.py
with
12 additions
and
7 deletions
gstlal-inspiral/python/stats/inspiral_lr.py
+
12
−
7
View file @
ec3859c1
...
...
@@ -26,6 +26,11 @@
#
try
:
from
fpconst
import
NegInf
except
ImportError
:
# not all machines have fpconst installed
NegInf
=
float
(
"
-inf
"
)
import
math
import
numpy
import
os
...
...
@@ -307,7 +312,7 @@ class LnSignalDensity(LnLRDensity):
def
__call__
(
self
,
segments
,
snrs
,
chi2s_over_snr2s
,
phase
,
dt
,
template_id
):
assert
frozenset
(
segments
)
==
self
.
instruments
if
len
(
snrs
)
<
self
.
min_instruments
:
return
float
(
"
-inf
"
)
return
NegInf
# use volume-weighted average horizon distance over
# duration of event to estimate sensitivity
...
...
@@ -335,7 +340,7 @@ class LnSignalDensity(LnLRDensity):
# denominator were both normalized properly.
horizon
=
sorted
(
horizons
.
values
())[
-
self
.
min_instruments
]
/
TYPICAL_HORIZON_DISTANCE
if
not
horizon
:
return
float
(
"
-inf
"
)
return
NegInf
lnP
=
3.
*
math
.
log
(
horizon
)
+
math
.
log
(
len
(
self
.
template_ids
))
# Add P(instruments | horizon distances)
...
...
@@ -343,14 +348,14 @@ class LnSignalDensity(LnLRDensity):
lnP
+=
math
.
log
(
self
.
InspiralExtrinsics
.
p_of_instruments_given_horizons
(
snrs
.
keys
(),
horizons
))
except
ValueError
:
# The code raises a value error when a needed horizon distance is zero
return
float
(
"
-inf
"
)
return
NegInf
# Evaluate dt, dphi, snr probability
try
:
lnP
+=
math
.
log
(
self
.
InspiralExtrinsics
.
time_phase_snr
(
dt
,
phase
,
snrs
,
horizons
))
# FIXME need to make sure this is really a math domain error
except
ValueError
:
return
float
(
"
-inf
"
)
return
NegInf
# evaluate population model
lnP
+=
self
.
population_model
.
lnP_template_signal
(
template_id
,
max
(
snrs
.
values
()))
...
...
@@ -567,14 +572,14 @@ class DatalessLnSignalDensity(LnSignalDensity):
lnP
+=
math
.
log
(
self
.
InspiralExtrinsics
.
p_of_instruments_given_horizons
(
snrs
.
keys
(),
horizons
))
except
ValueError
:
# The code raises a value error when a needed horizon distance is zero
return
float
(
"
-inf
"
)
return
NegInf
# Evaluate dt, dphi, snr probability
try
:
lnP
+=
math
.
log
(
self
.
InspiralExtrinsics
.
time_phase_snr
(
dt
,
phase
,
snrs
,
horizons
))
# FIXME need to make sure this is really a math domain error
except
ValueError
:
return
float
(
"
-inf
"
)
return
NegInf
# evaluate population model
lnP
+=
self
.
population_model
.
lnP_template_signal
(
template_id
,
max
(
snrs
.
values
()))
...
...
@@ -695,7 +700,7 @@ class LnNoiseDensity(LnLRDensity):
def
__call__
(
self
,
segments
,
snrs
,
chi2s_over_snr2s
,
phase
,
dt
,
template_id
):
assert
frozenset
(
segments
)
==
self
.
instruments
if
len
(
snrs
)
<
self
.
min_instruments
:
return
float
(
"
-inf
"
)
return
NegInf
# FIXME: the +/-3600 s window thing is a temporary hack to
# work around the problem of vetoes creating short segments
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment