Package pylal :: Module cbc_timeslides
[hide private]
[frames] | no frames]

Source Code for Module pylal.cbc_timeslides

 1  # This program is free software; you can redistribute it and/or modify it 
 2  # under the terms of the GNU General Public License as published by the 
 3  # Free Software Foundation; either version 2 of the License, or (at your 
 4  # option) any later version. 
 5  # 
 6  # This program is distributed in the hope that it will be useful, but 
 7  # WITHOUT ANY WARRANTY; without even the implied warranty of 
 8  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
 9  # Public License for more details. 
10  # 
11  # You should have received a copy of the GNU General Public License along 
12  # with this program; if not, write to the Free Software Foundation, Inc., 
13  # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
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   
23 -def parse_lalapps_thinca_slidespec(slidespec):
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
40 -def Inspiral_Num_Slides_Iter(count, offsets):
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