Commit 8d4cb5b5 authored by John Douglas Veitch's avatar John Douglas Veitch

Wrapper script 1st version

Original: bccccbbb812cc75e5684ec6aace8fee7f0d46815
parent a91dfc87
......@@ -7,8 +7,9 @@ from lalapps import lalinference_pipe_utils as pipe_utils
import ConfigParser
from optparse import OptionParser,OptionValueError
usage=""" %prog [options]
Setup a Condor DAG file to run the LALInference pipeline
usage=""" %prog [options] config.ini
Setup a Condor DAG file to run the LALInference pipeline based on
the config.ini file.
The user must specify either an injection file to analyse, with the --inj option,
a list of SnglInspiralTable or CoincInspiralTable triggers with the --<x>-triggers options,
......@@ -19,16 +20,25 @@ The user must also specify and ini file which will contain the main analysis con
"""
parser=OptionParser(usage)
parser.add_option("-i","--ini-file",default=None,action="store",type="string",help="ini-file for pipeline",metavar="CONFIG.ini")
parser.add_option("-r","--run-path",default=None,action="store",type="string",help="Directory to run pipeline in (default: $PWD)",metavar="RUNDIR")
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("-I","--injections",action="store",type="string",default=None,help="List of injections to perform and analyse",metavar="INJFILE.xml")
(opts,args)=parser.parse_args()
if len(args)!=1:
print 'Error: must specify one ini file'
parser.print_help()
sys.exit(1)
inifile=args[0]
cp=ConfigParser.ConfigParser()
cp.readfp(open(opts.ini_file))
cp.readfp(open(inifile))
if opts.run_path is not None:
cp.set('paths','basedir',opts.run_path)
......@@ -38,9 +48,15 @@ if opts.daglog_path is not None:
else:
cp.set('paths','daglogdir',opts.run_path)
if opts.gps_time_file is not None:
cp.set('input','gps-time-file',opts.gps_time_file)
if opts.single_triggers is not None:
cp.set('input','sngl-inspiral-file',opts.single_triggers)
if opts.injections is not None:
cp.set('input','injection-file')
# Create the DAG from the configparser object
dag=pipe_utils.LALInferencePipelineDAG(cp)
......@@ -19,6 +19,22 @@ def chooseEngineNode(name):
return LALInferenceMCMCNode
return EngineNode
def scan_timefile(self,timefile):
import re
p=re.compile('[\d.]+')
times=[]
timefilehandle=open(timefile,'r')
for time in timefilehandle:
if not p.match(time):
continue
if float(time) in times:
print 'Skipping duplicate time %s'%(time)
continue
print 'Read time %s'%(time)
times.append(float(time))
timefilehandle.close()
return times
class LALInferencePipelineDAG(pipeline.CondorDAG):
def __init__(self,cp,dax=False):
self.subfiles=[]
......@@ -61,7 +77,7 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
# Process the input to build list of analyses to do
self.times=[]
if cp.has_option('input','gps-time-file'):
times=self.scan_timefile(cp.get('input','gps-time-file'))
times=scan_timefile(cp.get('input','gps-time-file'))
for time in times:
self.times.append(time)
# SimInspiral Table
......@@ -79,6 +95,9 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
# Pipedown database
# Sanity checking
if len(self.times)==0:
print 'No input times found, please check your config. Generating an empty DAG'
# Set up the segments
if not self.config.has_option('input','gps-start-time'):
......@@ -87,22 +106,13 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
self.config.set('input','gps-end-time',str(max(self.times)))
self.add_science_segments()
def scan_timefile(self,timefile):
import re
p=re.compile('[\d.]+')
times=[]
timefilehandle=open(timefile,'r')
for time in timefilehandle:
if not p.match(time):
continue
if float(time) in times:
print 'Skipping duplicate time %s'%(time)
continue
print 'Read time %s'%(time)
times.append(float(time))
timefilehandle.close()
return times
# Save the final configuration that is being used
conffilename=os.path.join(self.basepath,'config.ini')
with open(conffilename,'wb') as conffile:
self.cp.write(conffile)
# Generate the DAG according to the config given
def setup_from_times(self,times):
"""
......
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