Package pylal :: Module ligolw_sstinca :: Class sngl_inspiral_coincs
[hide private]
[frames] | no frames]

Class sngl_inspiral_coincs

source code

object --+
         |
        sngl_inspiral_coincs

Dictionary-like device to extract XML document trees containing individual sngl_inspiral coincs from a source XML document tree containing several.

An instance of the class is initialized with an XML document tree. The coinc event ID of a sngl_inspiral<-->sngl_inspiral coinc in the document can then be used like a dictionary key to retrieve a newly-constructed XML document containing that coinc by itself. The output document trees are complete, self-describing, documents with all metadata about the event from the source document preserved.

Example:

>>> coincs = sngl_inspiral_coincs(xmldoc)
>>> print(coincs.coinc_def_id)
coinc_definer:coinc_def_id:0
>>> coincs.keys()
[<glue.ligolw.ilwd.cached_ilwdchar_class object at 0x41a4328>]
>>> coinc_id = coincs.keys()[0]
>>> print(coinc_id)
coinc_event:coinc_event_id:83763
>>> coincs[coinc_id].write()
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE LIGO_LW SYSTEM "http://ldas-sw.ligo.caltech.edu/doc/ligolwAPI/html/ligolw_dtd.txt">
<LIGO_LW>
        <Table Name="process:table">
                <Column Type="lstring" Name="process:comment"/>
                <Column Type="lstring" Name="process:node"/>
...

The XML documents returned from this class share references to the row objects in the original document. Modifications to the row objects in the tables returned by this class will affect both the original document and all other documents returned by this class. However, each retrieval constructs a new document from scratch, they are not cached nor re-used, therefore this operation can be time consuming if it needs to be performed repeatedly but the table objects and document trees can be edited without affecting each other.

If the source document is modified after this class has been instantiated, the behaviour is undefined.

To assist with memory clean-up, it is helpful to invoke the .unlink() method on the XML trees returned by this class when they are no longer needed.

Instance Methods [hide private]
 
__init__(self, xmldoc)
Initialize an instance of the class.
source code
 
coinc_def_id(self)
The coinc_def_id of the sngl_inspiral<-->sngl_inspiral coincs in the source XML document.
source code
 
sngl_inspirals(self, coinc_event_id)
Return a list of the sngl_inspiral rows that participated in the coincidence given by coinc_event_id.
source code
 
offset_vector(self, time_slide_id)
Return the offsetvector given by time_slide_id.
source code
 
__getitem__(self, coinc_event_id)
Construct and return an XML document containing the sngl_inspiral<-->sngl_inspiral coinc carrying the given coinc_event_id.
source code
 
__iter__(self)
Iterate over the coinc_event_id's in the source document.
source code
 
__nonzero__(self) source code
 
keys(self)
A list of the coinc_event_id's of the sngl_inspiral<-->sngl_inspiral coincs available in the source XML document.
source code
 
items(self)
Yield a sequence of (coinc_event_id, XML tree) tuples, one for each sngl_inspiral<-->sngl_inspiral coinc in the source document.
source code
 
iteritems(self)
Yield a sequence of (coinc_event_id, XML tree) tuples, one for each sngl_inspiral<-->sngl_inspiral coinc in the source document.
source code
 
column_index(self, table_name, column_name)
Return a dictionary mapping coinc_event_id to the values in the given column in the given table.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, xmldoc)
(Constructor)

source code 

Initialize an instance of the class. xmldoc is the source XML document tree from which the sngl_inspiral<-->sngl_inspiral coincs will be extracted.

Overrides: object.__init__

coinc_def_id(self)

source code 

The coinc_def_id of the sngl_inspiral<-->sngl_inspiral coincs in the source XML document.

Decorators:
  • @property

items(self)

source code 

Yield a sequence of (coinc_event_id, XML tree) tuples, one for each sngl_inspiral<-->sngl_inspiral coinc in the source document.

NOTE: to allow this to work more easily with very large documents, instead of returning the complete sequence as a pre-constructed list this method is implemented as a generator.

iteritems(self)

source code 

Yield a sequence of (coinc_event_id, XML tree) tuples, one for each sngl_inspiral<-->sngl_inspiral coinc in the source document.

NOTE: to allow this to work more easily with very large documents, instead of returning the complete sequence as a pre-constructed list this method is implemented as a generator.

column_index(self, table_name, column_name)

source code 

Return a dictionary mapping coinc_event_id to the values in the given column in the given table.

Example:

>>> print(coincs.column_index("coinc_event", "likelihood"))

Only columns in the coinc_event and coinc_inspiral tables can be retrieved this way.