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

Source Code for Module glue.ligolw.utils.search_summary

  1  # Copyright (C) 2012,2013,2015  Kipp Cannon 
  2  # 
  3  # This program is free software; you can redistribute it and/or modify it 
  4  # under the terms of the GNU General Public License as published by the 
  5  # Free Software Foundation; either version 2 of the License, or (at your 
  6  # option) any later version. 
  7  # 
  8  # This program is distributed in the hope that it will be useful, but 
  9  # WITHOUT ANY WARRANTY; without even the implied warranty of 
 10  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General 
 11  # Public License for more details. 
 12  # 
 13  # You should have received a copy of the GNU General Public License along 
 14  # with this program; if not, write to the Free Software Foundation, Inc., 
 15  # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. 
 16   
 17   
 18  # 
 19  # ============================================================================= 
 20  # 
 21  #                                   Preamble 
 22  # 
 23  # ============================================================================= 
 24  # 
 25   
 26   
 27  """ 
 28  A collection of utilities to assist applications in manipulating the 
 29  search_summary table in LIGO Light-Weight XML documents. 
 30  """ 
 31   
 32   
 33  from glue import git_version 
 34  from .. import lsctables 
 35   
 36   
 37  __author__ = "Kipp Cannon <kipp.cannon@ligo.org>" 
 38  __version__ = "git id %s" % git_version.id 
 39  __date__ = git_version.date 
 40   
 41   
 42  # 
 43  # ============================================================================= 
 44  # 
 45  #                           Search Summary Metadata 
 46  # 
 47  # ============================================================================= 
 48  # 
 49   
 50   
51 -def append_search_summary(xmldoc, process, shared_object = "standalone", lalwrapper_cvs_tag = "", lal_cvs_tag = "", comment = None, ifos = None, inseg = None, outseg = None, nevents = 0, nnodes = 1):
52 """ 53 Append search summary information associated with the given process 54 to the search summary table in xmldoc. Returns the newly-created 55 search_summary table row. 56 """ 57 row = lsctables.SearchSummary() 58 row.process_id = process.process_id 59 row.shared_object = shared_object 60 row.lalwrapper_cvs_tag = lalwrapper_cvs_tag 61 row.lal_cvs_tag = lal_cvs_tag 62 row.comment = comment or process.comment 63 row.instruments = ifos if ifos is not None else process.instruments 64 row.in_segment = inseg 65 row.out_segment = outseg 66 row.nevents = nevents 67 row.nnodes = nnodes 68 69 try: 70 tbl = lsctables.SearchSummaryTable.get_table(xmldoc) 71 except ValueError: 72 tbl = xmldoc.childNodes[0].appendChild(lsctables.New(lsctables.SearchSummaryTable)) 73 tbl.append(row) 74 75 return row
76 77
78 -def segmentlistdict_fromsearchsummary_in(xmldoc, program = None):
79 """ 80 Convenience wrapper for a common case usage of the segmentlistdict 81 class: searches the process table in xmldoc for occurances of a 82 program named program, then scans the search summary table for 83 matching process IDs and constructs a segmentlistdict object from 84 the in segments in those rows. 85 86 Note: the segmentlists in the segmentlistdict are not necessarily 87 coalesced, they contain the segments as they appear in the 88 search_summary table. 89 """ 90 stbl = lsctables.SearchSummaryTable.get_table(xmldoc) 91 ptbl = lsctables.ProcessTable.get_table(xmldoc) 92 return stbl.get_in_segmentlistdict(program and ptbl.get_ids_by_program(program))
93 94
95 -def segmentlistdict_fromsearchsummary_out(xmldoc, program = None):
96 """ 97 Convenience wrapper for a common case usage of the segmentlistdict 98 class: searches the process table in xmldoc for occurances of a 99 program named program, then scans the search summary table for 100 matching process IDs and constructs a segmentlistdict object from 101 the out segments in those rows. 102 103 Note: the segmentlists in the segmentlistdict are not necessarily 104 coalesced, they contain the segments as they appear in the 105 search_summary table. 106 """ 107 stbl = lsctables.SearchSummaryTable.get_table(xmldoc) 108 ptbl = lsctables.ProcessTable.get_table(xmldoc) 109 return stbl.get_out_segmentlistdict(program and ptbl.get_ids_by_program(program))
110 111 112 # FIXME: deprecate this 113 segmentlistdict_fromsearchsummary = segmentlistdict_fromsearchsummary_out 114