Package glue :: Package ligolw :: Package utils :: Module time_slide
[hide private]
[frames] | no frames]

Module time_slide

source code


Version: git id 8cbd1b7187ce3ed9a825d6ed11cc432f3cfde9a5

Date: 2017-12-05 15:29:36 +0000

Author: Kipp Cannon <kipp.cannon@ligo.org>

Functions [hide private]
 
get_time_slide_id(xmldoc, time_slide, create_new=None, superset_ok=False, nonunique_ok=False)
Return the time_slide_id corresponding to the offset vector described by time_slide, a dictionary of instrument/offset pairs.
source code
 
time_slide_list_merge(slides1, slides2)
Merges two lists of offset dictionaries into a single list with no duplicate (equivalent) time slides.
source code
 
time_slides_vacuum(time_slides, verbose=False)
Given a dictionary mapping time slide IDs to instrument-->offset mappings, for example as returned by the as_dict() method of the TimeSlideTable class in glue.ligolw.lsctables or by the load_time_slides() function in this module, construct and return a mapping indicating time slide equivalences.
source code
Variables [hide private]
  __package__ = 'glue.ligolw.utils'
Function Details [hide private]

get_time_slide_id(xmldoc, time_slide, create_new=None, superset_ok=False, nonunique_ok=False)

source code 

Return the time_slide_id corresponding to the offset vector described by time_slide, a dictionary of instrument/offset pairs.

Example:

>>> get_time_slide_id(xmldoc, {"H1": 0, "L1": 0})
'time_slide:time_slide_id:10'

This function is a wrapper around the .get_time_slide_id() method of the glue.ligolw.lsctables.TimeSlideTable class. See the documentation for that class for the meaning of the create_new, superset_ok and nonunique_ok keyword arguments.

This function requires the document to contain exactly one time_slide table. If the document does not contain exactly one time_slide table then ValueError is raised, unless the optional create_new argument is not None. In that case a new table is created. This effect of the create_new argument is in addition to the affects described by the TimeSlideTable class.

time_slides_vacuum(time_slides, verbose=False)

source code 

Given a dictionary mapping time slide IDs to instrument-->offset mappings, for example as returned by the as_dict() method of the TimeSlideTable class in glue.ligolw.lsctables or by the load_time_slides() function in this module, construct and return a mapping indicating time slide equivalences. This can be used to delete redundant time slides from a time slide table, and then also used via the applyKeyMapping() method of glue.ligolw.table.Table instances to update cross references (for example in the coinc_event table).

Example:

>>> slides = {"time_slide_id:0": {"H1": 0, "H2": 0},
"time_slide_id:1": {"H1": 10, "H2": 10}, "time_slide_id:2": {"H1":
0, "H2": 10}}
>>> time_slides_vacuum(slides)
{'time_slide_id:1': 'time_slide_id:0'}

indicating that time_slide_id:1 describes a time slide that is equivalent to time_slide_id:0. The calling code could use this information to delete time_slide_id:1 from the time_slide table, and replace references to that ID in other tables with references to time_slide_id:0.