Commit 33262fba authored by Vivien Raymond's avatar Vivien Raymond
Browse files

lalinference_pipe, skyarea node and psd.xml support for GraceDB follow-up

Original: a15e0837a08796ced09908b2c3c020613542dc27
parent 17f46a6f
......@@ -90,6 +90,9 @@ coherencetest=/home/albert.einstein/bin/lalapps_coherence_test
lalinferencenest=/home/albert.einstein/bin/lalinference_nest
lalinferencemcmc=/home/albert.einstein/bin/lalinference_mcmc
lalinferencebambi=/home/albert.einstein/bin/lalinference_bambi
# Skyareas code from https://github.com/farr/skyarea
# Disabled by default, uncomment line below to use it
# skyarea=/home/albert.einstein/bin/run_sky_area.py
# MPIrun only needed for MCMC, if not available use /bin/true
mpirun=/home/albert.einstein/bin/mpirun
......@@ -291,3 +294,12 @@ v1-analyze = V1:ITF_SCIENCEMODE:7
# Webdir is the output path for the PP check page
webdir=/home/albert.einstein/public_html/lalinference/review/PPcheck/
[skyarea]
# Optional arguments:
#maxpts=1000 # maximum number of posterior samples to use
#trials=50 # Maximum number of trials to build sky posterior
#noskyarea # Turn off sky area computation
#nside=512 # HEALPix resultion (default 512)
#seed=1234 # Random seed to use
......@@ -69,7 +69,7 @@ class Event():
dummyCacheNames=['LALLIGO','LALVirgo','LALAdLIGO','LALAdVirgo']
def readLValert(SNRthreshold=0,gid=None,flow=40.0,gracedb="gracedb"):
def readLValert(SNRthreshold=0,gid=None,flow=40.0,gracedb="gracedb",savepsdpath="./"):
"""
Parse LV alert file, continaing coinc, sngl, coinc_event_map.
and create a list of Events as input for pipeline
......@@ -104,6 +104,8 @@ def readLValert(SNRthreshold=0,gid=None,flow=40.0,gracedb="gracedb"):
# Parse PSD
srate_psdfile=16384
print "gracedb download %s psd.xml.gz" % gid
cwd=os.getcwd()
os.chdir(savepsdpath)
subprocess.call([gracedb,"download", gid ,"psd.xml.gz"])
psdasciidic=None
fhigh=None
......@@ -137,6 +139,7 @@ def readLValert(SNRthreshold=0,gid=None,flow=40.0,gracedb="gracedb"):
if(coinc.snr>SNRthreshold): output.append(ev)
print "Found %d coinc events in table." % len(coinc_events)
os.chdir(cwd)
return output
def open_pipedown_database(database_filename,tmp_space):
......@@ -476,6 +479,15 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
# Generate the DAG according to the config given
for event in self.events: self.add_full_analysis(event)
# Add skyarea jobs if the executable is given # Do one for each results page for now
if cp.has_option('condor','skyarea'):
self.skyareajob=SkyAreaJob(self.config,os.path.join(self.basepath,'skyarea.sub'),self.logpath,dax=self.is_dax())
respagenodes=filter(lambda x: isinstance(x,ResultsPageNode) ,self.get_nodes())
for p in respagenodes:
skyareanode=SkyAreaNode(self.skyareajob)
skyareanode.add_resultspage_parent(p)
self.add_node(skyareanode)
self.dagfilename="lalinference_%s-%s"%(self.config.get('input','gps-start-time'),self.config.get('input','gps-end-time'))
self.set_dag_file(self.dagfilename)
if self.is_dax():
......@@ -645,7 +657,7 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
flow=40.0
if self.config.has_option('lalinference','flow'):
flow=min(ast.literal_eval(self.config.get('lalinference','flow')).values())
events = readLValert(gid=gid,flow=flow,gracedb=self.config.get('condor','gracedb'))
events = readLValert(gid=gid,flow=flow,gracedb=self.config.get('condor','gracedb'),savepsdpath=self.basepath)
# pipedown-database
else: gid=None
if self.config.has_option('input','pipedown-db'):
......@@ -1520,6 +1532,8 @@ class ResultsPageNode(pipeline.CondorDAGNode):
pipeline.CondorDAGNode.__init__(self,results_page_job)
if outpath is not None:
self.set_output_path(path)
self.__event=0
self.injfile=None
def set_gzip_output(self,path):
self.add_file_opt('archive',path,file_is_output_file=True)
def set_output_path(self,path):
......@@ -1529,10 +1543,14 @@ class ResultsPageNode(pipeline.CondorDAGNode):
#self.add_file_opt('archive','results.tar.gz',file_is_output_file=True)
mkdirs(path)
self.posfile=os.path.join(path,'posterior_samples.dat')
def get_output_path(self):
return self.webpath
def set_injection(self,injfile,eventnumber):
self.injfile=injfile
self.add_file_opt('inj',injfile)
self.set_event_number(eventnumber)
def get_injection(self):
return self.injfile
def set_event_number(self,event):
"""
Set the event number in the injection XML.
......@@ -1541,6 +1559,8 @@ class ResultsPageNode(pipeline.CondorDAGNode):
self.__event=int(event)
self.add_var_arg('--eventnum '+str(event))
def get_event_number(self):
return self.__event
def set_psd_files(self,st):
if st is None:
return
......@@ -1767,3 +1787,48 @@ class ROMNode(pipeline.CondorDAGNode):
if self.__finalized:
return
self.__finalized=True
class SkyAreaNode(pipeline.CondorDAGNode):
"""
Node to run sky area code
"""
def __init__(self,skyarea_job,posfile=None,parent=None):
pipeline.CondorDAGNode.__init__(self,skyarea_job)
if parent:
self.add_parent(parent)
if posfile:
self.set_posterior_file(posfile)
def set_posterior_file(self,posfile):
self.add_file_opt('samples',posfile,file_is_output_file=False)
self.posfile=posfile
def set_outdir(self,outdir):
self.add_var_opt('outdir',outdir)
def set_injection(self,injfile,eventnum):
if injfile is not None:
self.add_file_opt('inj',injfile)
self.add_var_opt('eventnum',str(eventnum))
def set_objid(self,objid):
self.add_var_opt('objid',objid)
def add_resultspage_parent(self,resultspagenode):
self.set_posterior_file(resultspagenode.get_pos_file())
self.set_outdir(resultspagenode.get_output_path())
self.add_parent(resultspagenode)
self.set_injection(resultspagenode.get_injection(),resultspagenode.get_event_number())
class SkyAreaJob(pipeline.CondorDAGJob,pipeline.AnalysisJob):
"""
Class for Sky Area Jobs
"""
def __init__(self,cp,submitFile,logdir,dax=False):
exe=cp.get('condor','skyarea')
pipeline.CondorDAGJob.__init__(self,"vanilla",exe)
pipeline.AnalysisJob.__init__(self,cp,dax=dax)
self.set_sub_file(submitFile)
self.set_stdout_file(os.path.join(logdir,'skyarea-$(cluster)-$(process).out'))
self.set_stderr_file(os.path.join(logdir,'skyarea-$(cluster)-$(process).err'))
self.add_condor_cmd('getenv','True')
# Add user-specified options from ini file
self.add_ini_opts(cp,'skyarea')
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