Commit d32d69a1 authored by Vivien Raymond's avatar Vivien Raymond
Browse files

lalinference_pipe update for automatic gracedb follow-ups

Original: 181683c045305cb9c2ce5297ba16b86cd6a26f45
parent d534e1f2
...@@ -5,6 +5,7 @@ import itertools ...@@ -5,6 +5,7 @@ import itertools
import glue import glue
from glue import pipeline,segmentsUtils,segments from glue import pipeline,segmentsUtils,segments
import os import os
import socket
from lalapps import inspiralutils from lalapps import inspiralutils
import uuid import uuid
import ast import ast
...@@ -87,6 +88,8 @@ def readLValert(SNRthreshold=0,gid=None,flow=40.0): ...@@ -87,6 +88,8 @@ def readLValert(SNRthreshold=0,gid=None,flow=40.0):
ifos = coinc_table[0].instruments.split(",") ifos = coinc_table[0].instruments.split(",")
trigSNR = coinctable[0].snr trigSNR = coinctable[0].snr
# Parse PSD # Parse PSD
print "gracedb download %s psd.xml.gz" % gid
subprocess.call(["gracedb","download", gid ,"psd.xml.gz"])
if os.path.exists("psd.xml.gz"): if os.path.exists("psd.xml.gz"):
xmlpsd = utils.load_filename("psd.xml.gz") xmlpsd = utils.load_filename("psd.xml.gz")
psddict = dict((param.get_pyvalue(elem, u"instrument"), lalseries.parse_REAL8FrequencySeries(elem)) for elem in xmlpsd.getElementsByTagName(ligolw.LIGO_LW.tagName) if elem.hasAttribute(u"Name") and elem.getAttribute(u"Name") == u"REAL8FrequencySeries") psddict = dict((param.get_pyvalue(elem, u"instrument"), lalseries.parse_REAL8FrequencySeries(elem)) for elem in xmlpsd.getElementsByTagName(ligolw.LIGO_LW.tagName) if elem.hasAttribute(u"Name") and elem.getAttribute(u"Name") == u"REAL8FrequencySeries")
...@@ -96,7 +99,8 @@ def readLValert(SNRthreshold=0,gid=None,flow=40.0): ...@@ -96,7 +99,8 @@ def readLValert(SNRthreshold=0,gid=None,flow=40.0):
combine.append([psd.f0+i*psd.deltaF,np.sqrt(p)]) combine.append([psd.f0+i*psd.deltaF,np.sqrt(p)])
np.savetxt(instrument+'psd.txt',combine) np.savetxt(instrument+'psd.txt',combine)
srate = combine[-1][0] srate = combine[-1][0]
else:
print "Failed to gracedb download %s psd.xml.gz" % gid
# Logic for template duration and sample rate disabled # Logic for template duration and sample rate disabled
coinc_map = lsctables.getTablesByType(xmldoc, lsctables.CoincMapTable)[0] coinc_map = lsctables.getTablesByType(xmldoc, lsctables.CoincMapTable)[0]
for coinc in coinc_events: for coinc in coinc_events:
...@@ -351,11 +355,17 @@ class LALInferencePipelineDAG(pipeline.CondorDAG): ...@@ -351,11 +355,17 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
padding=self.config.getint('input','padding') padding=self.config.getint('input','padding')
if self.config.has_option('lalinference','seglen'): if self.config.has_option('lalinference','seglen'):
seglen = self.config.getint('lalinference','seglen') seglen = self.config.getint('lalinference','seglen')
psdlength = 32*seglen if os.path.exists("psd.xml.gz"):
psdlength = 0
else:
psdlength = 32*seglen
else: else:
seglen = max(e.duration for e in self.events) seglen = max(e.duration for e in self.events)
psdlength = 32*seglen if os.path.exists("psd.xml.gz"):
# Assume that the data interval is (end_time - seglen -padding , end_time + psdlength +padding ) psdlength = 0
else:
psdlength = 32*seglen
# Assume that the data interval is (end_time - seglen -padding , end_time + psdlength +padding )
# -> change to (trig_time - seglen - padding - psdlength + 2 , trig_time + padding + 2) to estimate the psd before the trigger for online follow-up. # -> change to (trig_time - seglen - padding - psdlength + 2 , trig_time + padding + 2) to estimate the psd before the trigger for online follow-up.
# Also require padding before start time # Also require padding before start time
return (min(times)-padding-seglen-psdlength+2,max(times)+padding+2) return (min(times)-padding-seglen-psdlength+2,max(times)+padding+2)
...@@ -720,9 +730,15 @@ class EngineJob(pipeline.CondorDAGJob): ...@@ -720,9 +730,15 @@ class EngineJob(pipeline.CondorDAGJob):
machine_count=cp.get('mpi','machine-count') machine_count=cp.get('mpi','machine-count')
#self.add_condor_cmd('machine_count',machine_count) #self.add_condor_cmd('machine_count',machine_count)
#self.add_condor_cmd('environment','CONDOR_MPI_PATH=%s'%(openmpipath)) #self.add_condor_cmd('environment','CONDOR_MPI_PATH=%s'%(openmpipath))
self.add_condor_cmd('Requirements','CAN_RUN_MULTICORE') try:
self.add_condor_cmd('+RequiresMultipleCores','True') hostname=socket.gethostbyaddr(socket.gethostname())[0]
except:
hostname='Unknown'
if hostname=='pcdev1.phys.uwm.edu':
self.add_condor_cmd('Requirements','CAN_RUN_MULTICORE')
self.add_condor_cmd('+RequiresMultipleCores','True')
self.add_condor_cmd('request_cpus',machine_count) self.add_condor_cmd('request_cpus',machine_count)
self.add_condor_cmd('request_memory',machine_count*1024)
self.add_condor_cmd('getenv','true') self.add_condor_cmd('getenv','true')
self.add_ini_opts(cp,self.engine) self.add_ini_opts(cp,self.engine)
...@@ -857,6 +873,7 @@ class EngineNode(pipeline.CondorDAGNode): ...@@ -857,6 +873,7 @@ class EngineNode(pipeline.CondorDAGNode):
ifostring='[' ifostring='['
cachestring='[' cachestring='['
psdstring='[' psdstring='['
psdstring_gracedb='['
flowstring='[' flowstring='['
channelstring='[' channelstring='['
slidestring='[' slidestring='['
...@@ -869,12 +886,14 @@ class EngineNode(pipeline.CondorDAGNode): ...@@ -869,12 +886,14 @@ class EngineNode(pipeline.CondorDAGNode):
ifostring=ifostring+delim+ifo ifostring=ifostring+delim+ifo
cachestring=cachestring+delim+self.cachefiles[ifo] cachestring=cachestring+delim+self.cachefiles[ifo]
if self.psds: psdstring=psdstring+delim+self.psds[ifo] if self.psds: psdstring=psdstring+delim+self.psds[ifo]
if os.path.exists(ifo+'psd.txt'): psdstring_gracedb=psdstring_gracedb+delim+ifo+'psd.txt'
if self.flows: flowstring=flowstring+delim+self.flows[ifo] if self.flows: flowstring=flowstring+delim+self.flows[ifo]
channelstring=channelstring+delim+self.channels[ifo] channelstring=channelstring+delim+self.channels[ifo]
slidestring=slidestring+delim+str(self.timeslides[ifo]) slidestring=slidestring+delim+str(self.timeslides[ifo])
ifostring=ifostring+']' ifostring=ifostring+']'
cachestring=cachestring+']' cachestring=cachestring+']'
psdstring=psdstring+']' psdstring=psdstring+']'
psdstring_gracedb=psdstring_gracedb+']'
flowstring=flowstring+']' flowstring=flowstring+']'
channelstring=channelstring+']' channelstring=channelstring+']'
slidestring=slidestring+']' slidestring=slidestring+']'
...@@ -882,6 +901,7 @@ class EngineNode(pipeline.CondorDAGNode): ...@@ -882,6 +901,7 @@ class EngineNode(pipeline.CondorDAGNode):
self.add_var_opt('channel',channelstring) self.add_var_opt('channel',channelstring)
self.add_var_opt('cache',cachestring) self.add_var_opt('cache',cachestring)
if self.psds: self.add_var_opt('psd',psdstring) if self.psds: self.add_var_opt('psd',psdstring)
elif psdstring_gracedb!='[]': self.add_var_opt('psd',psdstring_gracedb)
if self.flows: self.add_var_opt('flow',flowstring) if self.flows: self.add_var_opt('flow',flowstring)
if any(self.timeslides): if any(self.timeslides):
self.add_var_opt('timeslide',slidestring) self.add_var_opt('timeslide',slidestring)
...@@ -1008,7 +1028,9 @@ class ResultsPageNode(pipeline.CondorDAGNode): ...@@ -1008,7 +1028,9 @@ class ResultsPageNode(pipeline.CondorDAGNode):
if node.snrpath is not None: if node.snrpath is not None:
self.set_snr_file(node.get_snr_file()) self.set_snr_file(node.get_snr_file())
if isinstance(node,LALInferenceMCMCNode): if isinstance(node,LALInferenceMCMCNode):
self.add_var_opt('lalinfmcmc','') self.add_var_opt('lalinfmcmc','')
if os.path.exists("psd.xml.gz"):
self.add_var_opt('trig','coinc.xml')
def get_pos_file(self): return self.posfile def get_pos_file(self): return self.posfile
def set_bayes_coherent_incoherent(self,bcifile): def set_bayes_coherent_incoherent(self,bcifile):
self.add_var_arg('--bci '+bcifile) self.add_var_arg('--bci '+bcifile)
......
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