1   
 2   
 3   
 4   
 5   
 6   
 7   
 8   
 9   
10   
11   
12   
13   
14   
15  from glue import offsetvector 
16  from pylal import git_version 
17   
18   
19  __version__ = "git id %s" % git_version.id 
20  __date__ = git_version.date 
21   
22   
24    """ 
25    Accepts a string in the format 
26    count:instrument=offset[,instrument=offset...] and returns the 
27    tuple (count, {instrument: offset, ...}) 
28    Example: 
29   
30    >>> parse_inspiral_num_slides_slidespec("3:H1=0,H2=5,L1=10") 
31    (3, {'H2': 5.0, 'H1': 0.0, 'L1': 10.0}) 
32    """ 
33    count, offsets = slidespec.strip().split(":") 
34    tokens = offsets.strip().split(",") 
35    offsetvect = offsetvector.offsetvector( (instrument.strip(), float(offset)) \ 
36        for instrument, offset in (token.strip().split("=") for token in tokens) ) 
37    return int(count), offsetvect 
 38   
39   
41    ''' 
42    This generator yields a sequence of time slide dictionaries in the 
43    style of lalapps_thinca's time slides.  Each resulting dictionary 
44    maps instrument to offset.  The input is a count of time slides (an 
45    integer), and a dictionary mapping instrument to offset.  The 
46    output dictionaries describe time slides that are integer multiples 
47    of the input time shifts. 
48    Example (formatted for clarity): 
49   
50    >>> list(Inspiral_Num_Slides_Iter(3, {"H1": 0.0, "H2": 5.0, "L1": 10.0})) 
51    [{'H2': -15.0, 'H1': -0.0, 'L1': -30.0}, 
52     {'H2': -10.0, 'H1': -0.0, 'L1': -20.0}, 
53     {'H2': -5.0, 'H1': -0.0, 'L1': -10.0}, 
54     {'H2': 0.0, 'H1': 0.0, 'L1': 0.0}, 
55     {'H2': 5.0, 'H1': 0.0, 'L1': 10.0}, 
56     {'H2': 10.0, 'H1': 0.0, 'L1': 20.0}, 
57     {'H2': 15.0, 'H1': 0.0, 'L1': 30.0}] 
58   
59    Output time slides are integer multiples of the input time shift  
60    vector in the range [-count, +count], including zero, and are  
61    returned in increasing order of multiplier. 
62    ''' 
63    for n in range(-count, +count + 1): 
64      yield offsetvector.offsetvector( (instrument, offset * n) \ 
65          for instrument, offset in offsets.items() ) 
 66