Commit a9da2520 authored by John Douglas Veitch's avatar John Douglas Veitch

LALInference Pipeline reads LValert triggers

Original: a31c71bc7be7aa64ec2faef7b9aca090ff5c1a84
parent 4e349275
......@@ -6,6 +6,7 @@
from lalapps import lalinference_pipe_utils as pipe_utils
import ConfigParser
from optparse import OptionParser,OptionValueError
import sys
usage=""" %prog [options] config.ini
Setup a Condor DAG file to run the LALInference pipeline based on
......@@ -24,6 +25,7 @@ parser.add_option("-r","--run-path",default=None,action="store",type="string",he
parser.add_option("-p","--daglog-path",default=None,action="store",type="string",help="Path to directory to contain DAG log file. SHOULD BE LOCAL TO SUBMIT NODE",metavar="LOGDIR")
parser.add_option("-g","--gps-time-file",action="store",type="string",default=None,help="Text file containing list of GPS times to analyse",metavar="TIMES.txt")
parser.add_option("-t","--single-triggers",action="store",type="string",default=None,help="SnglInspiralTable trigger list",metavar="SNGL_FILE.xml")
parser.add_option("-C","--coinc-triggers",action="store",type="string",default=None,help="CoinInspiralTable trigger list",metavar="COINC_FILE.xml")
parser.add_option("-I","--injections",action="store",type="string",default=None,help="List of injections to perform and analyse",metavar="INJFILE.xml")
parser.add_option("--condor-submit",action="store_true",default=False,help="Automatically submit the condor dag")
......@@ -33,8 +35,8 @@ parser.add_option("--condor-submit",action="store_true",default=False,help="Auto
(opts,args)=parser.parse_args()
if len(args)!=1:
print 'Error: must specify one ini file'
parser.print_help()
print 'Error: must specify one ini file'
sys.exit(1)
inifile=args[0]
......@@ -60,6 +62,9 @@ if opts.single_triggers is not None:
if opts.injections is not None:
cp.set('input','injection-file',opts.injections)
if opts.coinc_triggers is not None:
cp.set('input','coinc-inspiral-file',opts.coinc_triggers)
# Create the DAG from the configparser object
dag=pipe_utils.LALInferencePipelineDAG(cp)
dag.write_sub_files()
......
......@@ -10,6 +10,7 @@ import uuid
import ast
import pdb
import string
from math import floor,ceil
# We use the GLUE pipeline utilities to construct classes for each
# type of job. Each class has inputs and outputs, which are used to
......@@ -20,11 +21,13 @@ class Event():
Represents a unique event to run on
"""
new_id=itertools.count().next
def __init__(self,trig_time=None,SimInspiral=None,SnglInspiral=None,event_id=None,timeslide_dict=None):
def __init__(self,trig_time=None,SimInspiral=None,SnglInspiral=None,CoincInspiral=None,event_id=None,timeslide_dict=None,GID=None):
self.trig_time=trig_time
self.injection=SimInspiral
self.sngltrigger=SnglInspiral
self.timeslides=timeslide_dict
self.GID=GID
self.coinctrigger=CoincInspiral
if event_id is not None:
self.event_id=event_id
else:
......@@ -33,11 +36,30 @@ class Event():
self.trig_time=self.injection.get_end()
self.event_id=int(str(self.injection.simulation_id).split(':')[2])
if self.sngltrigger is not None:
self.trig_time=sngltrigger.get_end()
self.trig_time=self.sngltrigger.get_end()
self.event_id=int(str(self.sngltrigger.event_id).split(':')[2])
if self.coinctrigger is not None:
self.trig_time=self.coinctrigger.end_time + 1.0e-9 * self.coinctrigger.end_time_ns
if self.GID is not None:
self.event_id=int(''.join(i for i in self.GID if i.isdigit()))
dummyCacheNames=['LALLIGO','LALVirgo','LALAdLIGO','LALAdVirgo']
def readLValert(lvalertfile,SNRthreshold=0,GID=None):
"""
Parse LV alert file, continaing coinc, sngl, coinc_event_map.
and create a list of Events as input for pipeline
Based on Chris Pankow's script
"""
from glue.ligolw import utils
from glue.ligolw import lsctables
xmldoc=utils.load_filename(lvalertfile)
coinctable = lsctables.getTablesByType(xmldoc, lsctables.CoincInspiralTable)[0]
coinc_events = [event for event in coinctable]
print "Found %d coinc events in table." % len(coinc_events)
output=[Event(CoincInspiral=cevent,GID=GID) for cevent in coinc_events if cevent.snr>=SNRthreshold ]
return output
def mkdirs(path):
"""
Helper function. Make the given directory, creating intermediate
......@@ -135,9 +157,9 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
# Set up the segments
(mintime,maxtime)=self.get_required_data(self.times)
if not self.config.has_option('input','gps-start-time'):
self.config.set('input','gps-start-time',str(mintime))
self.config.set('input','gps-start-time',str(int(floor(mintime))))
if not self.config.has_option('input','gps-end-time'):
self.config.set('input','gps-end-time',str(maxtime))
self.config.set('input','gps-end-time',str(int(ceil(maxtime))))
self.add_science_segments()
# Save the final configuration that is being used
......@@ -178,7 +200,7 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
in the [input] section of the ini file.
And process the events found therein
"""
inputnames=['gps-time-file','injection-file','sngl-inspiral-file','coinc-inspiral-file','pipedown-database']
inputnames=['gps-time-file','injection-file','sngl-inspiral-file','coinc-inspiral-file','pipedown-database','lvalert-file']
if sum([ 1 if self.config.has_option('input',name) else 0 for name in inputnames])!=1:
print 'Plese specify only one input file'
sys.exit(1)
......@@ -196,6 +218,9 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
from pylal import SnglInspiralUtils
trigTable=SnglInspiralUtils.ReadSnglInspiralFromFiles([self.config.get('input','sngl-inspiral-file')])
events=[Event(SnglInspiral=trig) for trig in trigTable]
# CoincInspiral Table
if self.config.has_option('input','coinc-inspiral-file'):
events = readLValert(self.config.get('input','coinc-inspiral-file'))
# TODO: pipedown-database
# TODO: timeslides
return events
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment