Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
Michael William Coughlin
GraceDB Server
Commits
339f1b9c
Commit
339f1b9c
authored
5 years ago
by
Tanner Prestegard
Committed by
GraceDB
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: public alerts view for handling case where a superevent doesn't have any VOEvents
parent
8e5979d1
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
gracedb/superevents/views.py
+32
-30
32 additions, 30 deletions
gracedb/superevents/views.py
with
32 additions
and
30 deletions
gracedb/superevents/views.py
+
32
−
30
View file @
339f1b9c
...
...
@@ -141,23 +141,25 @@ class SupereventPublic(DisplayFarMixin, ListView):
.
prefetch_related
(
'
voevent_set
'
,
'
log_set
'
)
return
qs
def
get_skymap_image
(
self
,
superevent
):
def
get_skymap_image
(
self
,
superevent
,
voevent
=
None
):
skymap_image
=
None
public_logs
=
superevent
.
log_set
.
filter
(
tags__name
=
'
public
'
)
# Try to get skymap from latest non-retraction VOEvent
voevent
=
superevent
.
voevent_set
.
exclude
(
voevent_type
=
VOEvent
.
VOEVENT_TYPE_RETRACTION
).
order_by
(
'
-N
'
).
first
()
voevent_skymap
=
voevent
.
skymap_filename
if
voevent_skymap
is
not
None
:
if
voevent
is
not
None
and
voevent
.
skymap_filename
is
not
None
:
# Assume filename is the same, with a different suffix.
voevent_skymap_image
=
voevent_skymap
.
replace
(
'
fits.gz
'
,
'
png
'
)
# See if a public log exists with that filename
public_logs
=
superevent
.
log_set
.
filter
(
tags__name
=
'
public
'
)
if
public_logs
.
filter
(
filename
=
voevent_skymap_image
).
exists
():
skymap_image
=
voevent_skymap_image
elif
public_logs
.
filter
(
filename
=
self
.
default_skymap_filename
).
exists
():
voevent_skymap_image
=
voevent
.
skymap_filename
.
replace
(
'
fits.gz
'
,
'
png
'
)
# See if a public log exists with that filename
if
public_logs
.
filter
(
filename
=
voevent_skymap_image
).
exists
():
skymap_image
=
voevent_skymap_image
# If skymap_image is None, we didn't find an image based on the
# skymap file in the VOEvent, so try the default.
if
(
skymap_image
is
None
and
public_logs
.
filter
(
filename
=
self
.
default_skymap_filename
).
exists
()):
skymap_image
=
self
.
default_skymap_filename
if
skymap_image
:
# Add version to image name to be safe
log
=
public_logs
.
filter
(
filename
=
skymap_image
)
\
...
...
@@ -179,9 +181,6 @@ class SupereventPublic(DisplayFarMixin, ListView):
candidates
=
0
for
se
in
self
.
object_list
:
# Get skymap image (if a public one exists)
se
.
skymap_image
=
self
.
get_skymap_image
(
se
)
# External links to GCN notice and circular
se
.
noticeurl
=
self
.
noticeurl_template
.
format
(
s_id
=
se
.
default_superevent_id
)
...
...
@@ -199,6 +198,9 @@ class SupereventPublic(DisplayFarMixin, ListView):
voe
=
se
.
voevent_set
.
exclude
(
voevent_type
=
VOEvent
.
VOEVENT_TYPE_RETRACTION
).
order_by
(
'
-N
'
).
first
()
# Get skymap image (if a public one exists)
se
.
skymap_image
=
self
.
get_skymap_image
(
se
,
voe
)
# Was the candidate retracted?
se
.
retract
=
se
.
voevent_set
.
filter
(
voevent_type
=
VOEvent
.
VOEVENT_TYPE_RETRACTION
).
exists
()
...
...
@@ -225,21 +227,21 @@ class SupereventPublic(DisplayFarMixin, ListView):
'
comment
'
,
flat
=
True
)))
# Get p_astro probabilities
pastro_values
=
[(
"
BNS
"
,
voe
.
prob_bns
),
(
"
NS
BH
"
,
voe
.
prob_ns
bh
),
(
"
B
BH
"
,
voe
.
prob_
b
bh
),
(
"
Terrestrial
"
,
voe
.
prob_
terrestrial
),
(
"
MassGap
"
,
voe
.
prob_mass_gap
)]
pastro_values
.
sort
(
reverse
=
True
,
key
=
lambda
(
a
,
b
):
b
)
sourcelist
=
[]
for
key
,
value
in
pastro_values
:
if
value
>
0.01
:
prob
=
int
(
round
(
100
*
value
))
if
prob
==
100
:
prob
=
'
>99
'
sourcestr
=
"
{0} ({1}%)
"
.
format
(
key
,
prob
)
source
list
.
append
(
sourcestr
)
se
.
sourcetypes
=
'
,
'
.
join
(
source
li
st
)
se
.
N
=
voe
.
N
if
voe
is
not
None
:
pastro_values
=
[
(
"
B
NS
"
,
voe
.
prob_
b
ns
),
(
"
NS
BH
"
,
voe
.
prob_
ns
bh
),
(
"
BBH
"
,
voe
.
prob_
bbh
),
(
"
Terrestrial
"
,
voe
.
prob_terrestrial
),
(
"
MassGap
"
,
voe
.
prob_mass_gap
)]
pastro_values
.
sort
(
reverse
=
True
,
key
=
lambda
(
a
,
b
):
b
)
sourcelist
=
[]
for
key
,
value
in
pastro_values
:
if
value
>
0.01
:
prob
=
int
(
round
(
100
*
value
))
if
prob
==
100
:
prob
=
'
>99
'
source
str
=
"
{0} ({1}%)
"
.
format
(
key
,
prob
)
sourcelist
.
append
(
sourcest
r
)
se
.
sourcetypes
=
'
,
'
.
join
(
sourcelist
)
# Number of non-retracted candidate events
context
[
'
candidates
'
]
=
candidates
...
...
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