Maintenance will be performed on,,, and tomorrow, 2020/08/04, starting at approximately 9am PDT. It is expected to take around 15 minutes and there will be a short period of downtime towards the end of the maintenance window. Please direct any comments, questions or concerns to

Updating writeEMObservation for superevents

Making writeEMObservation work for superevents; required some
changes to the events part of the server API as well.
parent 1f79a257
......@@ -1211,7 +1211,7 @@ class GraceDb(GsiRest):
def writeEMObservation(self, object_id, group, raList, raWidthList,
decList, decWidthList, startTimeList, durationList, comment=None,
decList, decWidthList, startTimeList, durationList, comment="",
*args, **kwargs):
Write an EM observation entry.
......@@ -1221,28 +1221,38 @@ class GraceDb(GsiRest):
decList, decWidthList, startTimeList, durationList,
Required args: graceid, group, raList, decList, raWidthList,
decWidthList, startTimeList, durationList
The various lists arguments should contain Python lists or
comma-separated values (or a single value). Start times are
in ISO 8601 UTC. Durations are in seconds.
(Note that 'group' here is the name of the EM MOU group, not
the LVC data analysis group responsible for the original detection.)
object_id: event graceid or superevent id
group: name of EM MOU group making the observation
raList: list of right ascensions (deg.)
raWidthList: list of right ascension widths OR a single number
if all measurements have the same width (deg.)
decList: list of declinations (deg.)
decWidthList: list of declination widths OR a single number
if all measurements have the same width (deg.)
startTimeList: list of measurement start times (ISO 8601 UTC)
format example: 2018-05-25T16:30:12+00:00
durationList: list of exposure times OR a single number if all
measurements have the same exposure (seconds)
comment: comment on observation (optional)
# validate facility, waveband, eel_status, and obs_status
if not group in self.em_groups:
raise ValueError("group must be one of %s" % self.em_groups)
# NOTE: One could do validation of the various list inputs here
# rather than relying on the server.
# These arguments can consist of a single element, a python
# list, or a string. Transform the list args to csv (unless they
# already are)
raList, raWidthList, decList, decWidthList, startTimeList, durationList = list(map(
[raList, raWidthList, decList, decWidthList, startTimeList, durationList]))
# Argument checking
num_measurements = len(raList)
# convert any single number widths or durations into lists
raWidthList, decWidthList, durationList = \
[[l] * num_measurements if not isinstance(l, (list, tuple)) else l
for l in [raWidthList, decWidthList, durationList]]
# Compare all list lengths
all_lists = [raList, decList, startTimeList, raWidthList,
decWidthList, durationList]
if not all(map(lambda l: len(l) == num_measurements, all_lists)):
raise ValueError('raList, decList, startTimeList, raWidthList, '
'decWidthList, and durationList should be the same length')
is_superevent = kwargs.pop('is_superevent', False)
if is_superevent:
......@@ -1251,17 +1261,16 @@ class GraceDb(GsiRest):
template = self.templates['emobservation-list-template']
uri_kwargs = {'graceid': object_id}
uri = template.format(**uri_kwargs)
body = {
'group' : group,
'raList' : raList,
'raWidthList': raWidthList,
'decList' : decList,
'decWidthList': decWidthList,
'startTimeList': startTimeList,
'durationList': durationList,
'ra_list' : raList,
'ra_width_list': raWidthList,
'dec_list' : decList,
'dec_width_list': decWidthList,
'start_time_list': startTimeList,
'duration_list': durationList,
'comment': comment,
return, body=body)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment