Skip to content
Snippets Groups Projects
Commit 611fb083 authored by Francesco Pannarale's avatar Francesco Pannarale
Browse files

Condor postprocessing setup can now hanle right ascenscion and declination of injected signals

git-svn-id: https://svn.ligo.caltech.edu/svn/bayeswave/trunk@106 c56465c9-8126-4a4f-9d7d-ac845eff4865
parent cb0609bf
No related branches found
No related tags found
No related merge requests found
......@@ -3,22 +3,35 @@ This script sets up the serial postprocessing of all BayesWaveBurst run results
launched. It assumes that the individual run directories are labelled job_*. Once the script is done, the
postprocessing may be completed by submitting the dagfile it produces to condor.
This script takes the optional boolean flag radec_flag. This enables the search for the injected right ascension
and declination values to be plotted in the skymap. These are obtained from an xml injection file, assuming the
naming convention m1_m2.xml. radec_flag=False by default
This script was tested on ldas-pcdev1.ligo.caltech.edu only.
"""
__author__ = "Francesco Pannarale, Ronaldas Macas"
__email__ = "francesco.pannarale@ligo.org, ronaldas.macas@gmail.com"
__version__ = "1.0"
__date__ = "11.07.2014"
__version__ = "1.1"
__date__ = "18.07.2014"
######################################################################################################################
# Import modules
######################################################################################################################
import argparse
import math
import os
import pwd
import subprocess
import sys
######################################################################################################################
# Parse the arguments
######################################################################################################################
parser = argparse.ArgumentParser(description='Set up a dag file to launch multiple BayesWaveBurst postprocessing\n runs on condor.')
parser.add_argument('--radec_flag', action='store_true', default=False, dest="radec", help="enable plot of injection locations in skymaps")
args = parser.parse_args()
######################################################################################################################
# Function that copies many_plots_1job.sh in all run directories to analyze
######################################################################################################################
......@@ -29,11 +42,14 @@ def ObtainScript(jobDirName, PWD, many_plots_script):
######################################################################################################################
# Function that writes the condor submission script
######################################################################################################################
def WriteSub(jobDirName, PWD):
def WriteSub(jobDirName, PWD, ra, dec):
path=PWD+'/'+jobDirName+'/'
SubFile = open(path+'submitManyPlots.sub', 'w')
SubFile.write('executable='+path+'many_plots_1job.sh\n')
SubFile.write('arguments='+path+'\n')
if str(ra)+str(dec)=="":
SubFile.write('arguments='+path+'\n')
else:
SubFile.write('arguments='+path+' '+str(ra)+' '+str(dec)+'\n')
SubFile.write('universe=vanilla\n')
SubFile.write('getenv=True\n')
SubFile.write('output='+path+'condorManyPlotsOut.txt\n')
......@@ -51,12 +67,38 @@ def WriteSub(jobDirName, PWD):
# Function that generates a single dag file for multiple postprocessing runs with many_plots_1job.sh
######################################################################################################################
def WriteDagFile(jobDirName, PWD):
#Might need to make sur the file exist instead of appending (but the + should take care of that)
# Might need to make sure the file exists instead of appending (but the + should take care of that)
DagFile = open('submitManyPlots.dag', 'a')
DagFile.write('JOB '+jobDirName+' '+PWD+'/'+jobDirName+'/submitManyPlots.sub\n')
DagFile.write('RETRY '+jobDirName+' 1\n\n')
DagFile.close()
######################################################################################################################
# Function that reads the sky location of an injected event from the XML injection file and expresses it in degrees
######################################################################################################################
def GetRADec(jobDirName, PWD):
# Find XML file name assuming the format "m1_m2.xml"
m1 = subprocess.Popen(["echo "+jobDirName+" | cut -d _ -f 2"], stdout=subprocess.PIPE, shell=True).communicate()[0].rstrip()
m2 = subprocess.Popen(["echo "+jobDirName+" | cut -d _ -f 3"], stdout=subprocess.PIPE, shell=True).communicate()[0].rstrip()
job_index = subprocess.Popen(["echo "+jobDirName+" | cut -d _ -f 4"], stdout=subprocess.PIPE, shell=True).communicate()[0].rstrip()
job_index = int(job_index) + 1 # adding +1 because command 'tail' (used below) requires non-zero index
longitude = subprocess.Popen(["lwtprint "+str(m1)+"_"+str(m2)+".xml -t sim_inspiralgroup:sim_inspiral -c longitude | tail -n"+str(job_index)+" | head -n1"], stdout=subprocess.PIPE, shell=True).communicate()[0].rstrip()
latitude = subprocess.Popen(["lwtprint "+str(m1)+"_"+str(m2)+".xml -t sim_inspiralgroup:sim_inspiral -c latitude | tail -n"+str(job_index)+"| head -n1"], stdout=subprocess.PIPE, shell=True).communicate()[0].rstrip()
#Converting from radians to degrees
if longitude < 0:
ra = 360. - float(longitude)*180./math.pi
else:
ra = float(longitude)*180./math.pi
if latitude < 0:
dec = 360. - float(latitude)*180./math.pi
else:
dec = float(latitude)*180./math.pi
return (ra, dec)
######################################################################################################################
# Main
######################################################################################################################
......@@ -92,11 +134,17 @@ for line in iter(PWD_ls.stdout.readline, b''):
job_list.append(jobDirName)
# 2) copy the post-processing script to the job directory
ObtainScript(jobDirName, PWD, many_plots_script)
# 3) write a submit script in it to call the post processing script
WriteSub(jobDirName,PWD)
# 4) tell the dag file to postprocess this job
# 3) if asked by the user get the right ascension and declination of the injected event for the skymap
radec = args.radec
if radec :
ra, dec = GetRADec(jobDirName, PWD)
else:
ra, dec = "",""
# 4) write a submit script in it to call the post processing script
WriteSub(jobDirName,PWD,ra,dec)
# 5) tell the dag file to postprocess this job
WriteDagFile(jobDirName, PWD)
# 5) keep count of the jobs found
# 6) keep count of the jobs found
jobs_number = jobs_number + 1
# All done! Report to the user
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment