gstlal
1.13.0
Toggle main menu visibility
Loading...
Searching...
No Matches
python
simulation.py
1
#
2
# Copyright (C) 2010
3
# Chad Hanna <chad.hanna@ligo.org>
4
#
5
# This program is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by the
7
# Free Software Foundation; either version 2 of the License, or (at your
8
# option) any later version.
9
#
10
# This program is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
13
# Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License along
16
# with this program; if not, write to the Free Software Foundation, Inc.,
17
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
#
19
20
21
from
ligo
import
segments
22
from
ligo.lw
import
ligolw
23
from
ligo.lw
import
lsctables
24
from
ligo.lw
import
utils
as
ligolw_utils
25
from
lal
import
LIGOTimeGPS
26
import
math
27
28
__doc__ =
"""
29
30
**Review status**
31
32
+---------------------------------------+------------------------------------------+------------+
33
| Names | Hash | Date |
34
+=======================================+==========================================+============+
35
| Sathya, Duncan Me, Jolien, Kipp, Chad | 7536db9d496be9a014559f4e273e1e856047bf71 | 2014-05-02 |
36
+---------------------------------------+------------------------------------------+------------+
37
38
"""
39
40
41
43
44
class
ContentHandler
(ligolw.LIGOLWContentHandler):
45
pass
46
lsctables.use_in(ContentHandler)
47
48
49
#
50
# open ligolw_xml file containing sim_inspiral and create a segment list
51
#
52
53
54
def
sim_inspiral_to_segment_list
(fname, pad=1, verbose=False):
55
"""
56
Given an xml file create a segment list that marks the time of an
57
injection with padding
58
59
- fname: the xml file name
60
- pad: duration in seconds to pad the coalescence time when producing a segment, e.g., [tc-pad, tc+pad)
61
"""
62
63
# initialization
64
65
seglist = segments.segmentlist()
66
67
# Parse the XML file
68
69
xmldoc = ligolw_utils.load_filename(fname, contenthandler=ContentHandler, verbose=verbose)
70
71
# extract the padded geocentric end times into segment lists
72
73
for
row
in
lsctables.SimInspiralTable.get_table(xmldoc):
74
t = row.time_geocent
75
seglist.append(segments.segment(LIGOTimeGPS(math.floor(t-pad)), LIGOTimeGPS(math.ceil(t+pad))))
76
77
# help the garbage collector
78
79
xmldoc.unlink()
80
81
return
seglist.coalesce()
python.simulation.ContentHandler
Definition
simulation.py:44
python.simulation.sim_inspiral_to_segment_list
sim_inspiral_to_segment_list(fname, pad=1, verbose=False)
Turn a file containing a sim inspiral into a segment list.
Definition
simulation.py:54
Generated by
1.17.0