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 Coughlin
GraceDB Server
Commits
0647bde0
Commit
0647bde0
authored
11 years ago
by
Branson Stephens
Browse files
Options
Downloads
Plain Diff
Merge branch 'inf_bug' to fix issue #1171
parents
d83dff72
6697c54f
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/translator.py
+25
-3
25 additions, 3 deletions
gracedb/translator.py
with
25 additions
and
3 deletions
gracedb/translator.py
+
25
−
3
View file @
0647bde0
...
...
@@ -16,6 +16,28 @@ from VOEventLib.Vutil import parse, getWhereWhen
from
utils
import
isoToGps
from
utils.vfile
import
VersionedFile
# This function checks for 'inf' in a float field, asks the database
# what's the maximum value it can accept for that field, and returns
# that value. Since the database query will introduce some overhead,
# I'm not going to use this to check all fields.
from
django.db
import
connection
def
cleanData
(
val
,
field_name
,
table_name
=
'
gracedb_event
'
):
if
val
is
None
:
return
val
elif
isinstance
(
val
,
float
):
if
abs
(
val
)
==
float
(
'
inf
'
):
cursor
=
connection
.
cursor
()
cursor
.
execute
(
'
SELECT MAX(%s) from %s
'
%
(
field_name
,
table_name
))
maxval
=
cursor
.
fetchone
()[
0
]
return
maxval
else
:
return
val
elif
isinstance
(
val
,
basestring
):
raise
ValueError
(
"
Unrecognized string in the %s column
"
%
field_name
)
else
:
raise
ValueError
(
"
Unrecognized value in column %s
"
%
field_name
)
def
handle_uploaded_data
(
event
,
datafilename
,
log_filename
=
'
event.log
'
,
coinc_table_filename
=
'
coinc.xml
'
):
...
...
@@ -111,7 +133,7 @@ def handle_uploaded_data(event, datafilename,
coinc_table
=
coinc_table
[
0
]
event
.
instruments
=
coinc_table
[
0
].
instruments
event
.
nevents
=
coinc_table
[
0
].
nevents
event
.
likelihood
=
coinc_table
[
0
].
likelihood
event
.
likelihood
=
cleanData
(
coinc_table
[
0
].
likelihood
,
'
likelihood
'
)
event
.
ifos
=
ifos
event
.
end_time
=
end_time
[
0
]
...
...
@@ -236,7 +258,7 @@ def handle_uploaded_data(event, datafilename,
coinc_table
=
coinc_table
[
0
]
event
.
instruments
=
coinc_table
[
0
].
instruments
event
.
nevents
=
coinc_table
[
0
].
nevents
event
.
likelihood
=
coinc_table
[
0
].
likelihood
event
.
likelihood
=
cleanData
(
coinc_table
[
0
].
likelihood
,
'
likelihood
'
)
# extended attributes
coinc_inspiral_table
=
glue
.
ligolw
.
table
.
getTablesByName
(
...
...
@@ -306,7 +328,7 @@ def handle_uploaded_data(event, datafilename,
coinc_table
=
coinc_table
[
0
]
event
.
instruments
=
coinc_table
[
0
].
instruments
event
.
nevents
=
coinc_table
[
0
].
nevents
event
.
likelihood
=
coinc_table
[
0
].
likelihood
event
.
likelihood
=
cleanData
(
coinc_table
[
0
].
likelihood
,
'
likelihood
'
)
# XXX xml_filename unused.
#xml_filename = os.path.join(output_dir, coinc_table_filename)
...
...
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