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

Moved lalinference_review_test to configparser

parent 5d1e4565
...@@ -43,7 +43,7 @@ def guess_url(fslocation): ...@@ -43,7 +43,7 @@ def guess_url(fslocation):
webpath=os.path.join('~%s'%(USER),b) webpath=os.path.join('~%s'%(USER),b)
onweb=True onweb=True
else: else:
(c,d)=fslocation.split(USER) (c,d)=fslocation.split(USER,1)
for k in ['public_html','WWW','www_html']: for k in ['public_html','WWW','www_html']:
trypath=c+os.environ['USER']+'/'+k+d trypath=c+os.environ['USER']+'/'+k+d
#Follow symlinks #Follow symlinks
...@@ -1844,7 +1844,7 @@ class SingularityJob(pipeline.CondorDAGJob): ...@@ -1844,7 +1844,7 @@ class SingularityJob(pipeline.CondorDAGJob):
# Add data transfer options # Add data transfer options
self.add_condor_cmd('should_transfer_files','YES') self.add_condor_cmd('should_transfer_files','YES')
self.add_condor_cmd('when_to_transfer_output','ON_EXIT_OR_EVICT') self.add_condor_cmd('when_to_transfer_output','ON_EXIT_OR_EVICT')
def write_script(self,path): def write_script(self,path):
""" """
Write the wrapper script Write the wrapper script
...@@ -1854,7 +1854,7 @@ class SingularityJob(pipeline.CondorDAGJob): ...@@ -1854,7 +1854,7 @@ class SingularityJob(pipeline.CondorDAGJob):
f.writelines(self.wrapper_string) f.writelines(self.wrapper_string)
f.close() f.close()
os.chmod(path,0755) os.chmod(path,0755)
def write_sub_file(self): def write_sub_file(self):
""" """
Over-load CondorDAGJob.write_sub_file to write the wrapper script and Over-load CondorDAGJob.write_sub_file to write the wrapper script and
...@@ -1872,7 +1872,7 @@ class SingularityJob(pipeline.CondorDAGJob): ...@@ -1872,7 +1872,7 @@ class SingularityJob(pipeline.CondorDAGJob):
super(SingularityJob,self).write_sub_file() super(SingularityJob,self).write_sub_file()
# Put the true exe back just in case # Put the true exe back just in case
self.set_executable(true_exec) self.set_executable(true_exec)
class SingularityNode(pipeline.CondorDAGNode): class SingularityNode(pipeline.CondorDAGNode):
......
...@@ -6,6 +6,7 @@ import subprocess ...@@ -6,6 +6,7 @@ import subprocess
import socket import socket
import glob import glob
import lalinference import lalinference
import ConfigParser
prefix='' prefix=''
try: try:
...@@ -33,7 +34,7 @@ parser.add_argument('--analytic-tests', action='store_true', ...@@ -33,7 +34,7 @@ parser.add_argument('--analytic-tests', action='store_true',
help='Run on the unmodal and bimodial Gaussian and Rosenbrock test functions.') help='Run on the unmodal and bimodial Gaussian and Rosenbrock test functions.')
parser.add_argument('--analytic-csv-dir', type=str, parser.add_argument('--analytic-csv-dir', type=str,
default='./', default=prefix,
help='Directory containing the CSVs describing the analytic tests.') help='Directory containing the CSVs describing the analytic tests.')
parser.add_argument('--pptest', action='store_true', parser.add_argument('--pptest', action='store_true',
...@@ -72,23 +73,13 @@ else: ...@@ -72,23 +73,13 @@ else:
web_outputdir=os.path.abspath(args.output) web_outputdir=os.path.abspath(args.output)
args.output=os.path.abspath(args.output) args.output=os.path.abspath(args.output)
os.makedirs(args.output)
if args.bns_injection: if args.bns_injection:
args.bns_injection=os.path.abspath(args.bns_injection) args.bns_injection=os.path.abspath(args.bns_injection)
if args.bbh_injection: if args.bbh_injection:
args.bbh_injection=os.path.abspath(args.bbh_injection) args.bbh_injection=os.path.abspath(args.bbh_injection)
backup_file=args.output+'/'+os.path.basename(args.ini_file)+'.bak'
ini_file=args.output+'/'+os.path.basename(args.ini_file)
os.makedirs(args.output)
shutil.copy(args.ini_file,backup_file)
try:
shutil.copy(args.ini_file,ini_file)
except:
print ini_file+' will be modified.'
analytic_csv_dir = os.path.abspath(args.analytic_csv_dir) analytic_csv_dir = os.path.abspath(args.analytic_csv_dir)
if args.analytic_tests: if args.analytic_tests:
csvs = glob.glob(analytic_csv_dir+"/*csv") csvs = glob.glob(analytic_csv_dir+"/*csv")
...@@ -104,69 +95,38 @@ except KeyError: ...@@ -104,69 +95,38 @@ except KeyError:
print 'LALINFERENCE_PREFIX variable not defined, could not find LALInference installation.' print 'LALINFERENCE_PREFIX variable not defined, could not find LALInference installation.'
sys.exit() sys.exit()
def replace(line): def init_ini_file(file=args.ini_file):
cp=ConfigParser.SafeConfigParser()
fp=open(file)
cp.optionxform = str
cp.readfp(fp)
fp.close()
if 'lalsuite-install=' in line: cp.set('condor','lalsuite-install',lalinf_prefix)
return 'lalsuite-install='+lalinf_prefix cp.set('analysis','engine',args.engine)
if 'engine=' in line: cp.remove_option('analysis','nparallel')
return line.replace(line.split('=')[-1],args.engine)+'\n'
if 'nparallel=' in line:
return '# '+line
if 'accounting_group=' in line:
return line.replace('#','').strip()+'\n'
return line
with open(ini_file,'w') as fout: return cp
with open(backup_file,'r') as fin:
for line in fin:
fout.write(replace(line))
############################################################ ############################################################
def replace_fiducial_bns(line): def set_fiducial_bns(cp):
if 'webdir=' in line:
return line.replace(line.split('=')[-1],web_outputdir+'/fiducialBNS/webdir/') cp.set('lalinference','fake-cache',"{'H1':'LALSimAdLIGO','L1':'LALSimAdLIGO','V1':'LALSimAdVirgo'}")
if 'baseurl=' in line: cp.set('analysis','dataseed','1234')
return line.replace(line.split('=')[-1],'file://'+web_outputdir+'/fiducialBNS/webdir/') cp.set('engine','0noise','')
if 'ifos=' in line:
return "ifos=['H1','L1']\n" cp.set('paths','webdir',web_outputdir+'/fiducialBNS/webdir/')
if 'fake-cache=' in line: cp.set('lalinference','flow',"{'H1':40,'L1':40,'V1':40}")
return line.replace(line,"fake-cache={'H1':'LALSimAdLIGO','L1':'LALSimAdLIGO','V1':'LALSimAdVirgo'}") cp.set('engine','approx','SEOBNRv4_ROMpseudoFourPN')
if 'ignore-science-segments=' in line: cp.set('resultspage','deltaLogP','5')
return 'ignore-science-segments=True\n' cp.set('engine','comp-max','3.5')
if 'flow=' in line: cp.set('engine','comp-min','0.8')
return line.replace('#','').replace('40','50').strip()+'\n'
if 'dataseed=' in line: cp.set('engine','neff','500')
return line.replace('#','').strip()+'\n' cp.set('engine','nlive','512')
if 'margphi=' in line:
return line.replace('#','').strip()+'\n' return cp
if 'amporder=' in line:
return 'amporder=0\n'
if 'disable-spin=' in line:
return '#disable-spin=\n'
if 'parname-max' in line:
return line+'\ndistance-max=400\n'
if 'deltaLogP=' in line:
return 'deltaLogP=5.0\n'
if 'approx=' in line:
return line.replace(line,"approx=SEOBNRv4_ROMpseudoFourPN")+'\n'
if 'srate=' in line:
return line.replace(line,"srate=2048")+'\n'
if 'seglen=' in line:
return line.replace(line,"seglen=18")
if 'comp-max=' in line:
return line.replace(line,"comp-max=3.5")+'\n'
if 'comp-min=' in line:
return line.replace(line,"comp-min=0.5")+'\n'
if '0noise=' in line:
return line.replace('#','').strip()+'\n'
if 'neff=' in line:
return line.replace(line,"neff=500")
if 'nlive=' in line:
return line.replace(line,"nlive=512")
if 'maxmcmc=' in line:
return line.replace(line,"#maxmcmc=3000")
return line
if args.bns_injection: if args.bns_injection:
...@@ -174,13 +134,11 @@ if args.bns_injection: ...@@ -174,13 +134,11 @@ if args.bns_injection:
os.chdir(args.output+'/fiducialBNS/') os.chdir(args.output+'/fiducialBNS/')
shutil.copy(args.bns_injection,args.output+'/fiducialBNS/') shutil.copy(args.bns_injection,args.output+'/fiducialBNS/')
shutil.copy(ini_file,args.output+'/fiducialBNS/'+os.path.basename(ini_file)+'.bak') BNS_ini_file=os.path.join(args.output,'fiducialBNS','BNS.ini')
shutil.copy(ini_file,args.output+'/fiducialBNS/')
with open(args.output+'/fiducialBNS/'+os.path.basename(ini_file),'w') as fout: cpBNS=set_fiducial_bns(init_ini_file())
with open(args.output+'/fiducialBNS/'+os.path.basename(ini_file)+'.bak','r') as fin: with open(BNS_ini_file,'w') as cpfile:
for line in fin: cpBNS.write(cpfile)
fout.write(replace_fiducial_bns(line))
lalinferenceargs = [ 'lalinference_pipe' lalinferenceargs = [ 'lalinference_pipe'
, '-I' , '-I'
...@@ -189,8 +147,7 @@ if args.bns_injection: ...@@ -189,8 +147,7 @@ if args.bns_injection:
, './run' , './run'
, '-p' , '-p'
, './daglog' , './daglog'
, args.output+'/fiducialBNS/'+os.path.basename(ini_file) , BNS_ini_file ]
]
if args.condor_submit: if args.condor_submit:
lalinferenceargs.append('--condor-submit') lalinferenceargs.append('--condor-submit')
...@@ -199,44 +156,28 @@ if args.bns_injection: ...@@ -199,44 +156,28 @@ if args.bns_injection:
################################################### ###################################################
def replace_GraceDB(line): def set_GraceDB(cp):
if 'webdir=' in line:
return line.replace(line.split('=')[-1],web_outputdir+'/GraceDB/webdir/') cp.set('analysis','upload-to-gracedb','True')
if 'baseurl=' in line: cp.set('paths','webdir',web_outputdir+'/GraceDB/webdir/')
return line.replace(line.split('=')[-1],'file://'+web_outputdir+'/GraceDB/webdir/')
if 'ifos=' in line: cp.set('datafind','types',"{'H1':'H1_HOFT_C00','L1':'L1_HOFT_C00','V1':'V1Online'}")
return "ifos=['H1','L1']\n" cp.set('data','channels',"{'H1':'H1:GDS-CALIB_STRAIN','L1':'L1:GDS-CALIB_STRAIN','V1':'V1:FAKE_h_16384Hz_4R'}")
if 'upload-to-gracedb=' in line:
return 'upload-to-gracedb=True\npegasus.transfer.links=false\n' cp.set('engine','distance-max','300')
if 'ignore-science-segments=' in line:
return 'ignore-science-segments=True\n' return cp
if 'skyarea=' in line:
return line.replace('#','').strip()+'\n'
if 'types=' in line:
return "types={'H1':'H1_HOFT_C00','L1':'L1_HOFT_C00','V1':'V1Online'}\n"
if 'channels=' in line:
return "channels={'H1':'H1:GDS-CALIB_STRAIN','L1':'L1:GDS-CALIB_STRAIN','V1':'V1:FAKE_h_16384Hz_4R'}\n"
if 'margphi=' in line:
return line.replace('#','').strip()+'\n'
if 'amporder=' in line:
return 'amporder=0\npsdFit=\ndifferential-buffer-limit=1000000\n'
if 'parname-max' in line:
return line+'distance-max=300\n'
return line
if args.gracedb: if args.gracedb:
os.makedirs(args.output+'/GraceDB/') os.makedirs(args.output+'/GraceDB/')
os.chdir(args.output+'/GraceDB/') os.chdir(args.output+'/GraceDB/')
shutil.copy(ini_file,args.output+'/GraceDB/'+os.path.basename(ini_file)+'.bak') GDB_ini_file=os.path.join(args.output,'GraceDB','GDB.ini')
shutil.copy(ini_file,args.output+'/GraceDB/')
cpGDB=set_GraceDB(init_ini_file())
with open(args.output+'/GraceDB/'+os.path.basename(ini_file),'w') as fout: with open(GDB_ini_file,'w') as cpfile:
with open(args.output+'/GraceDB/'+os.path.basename(ini_file)+'.bak','r') as fin: cpGDB.write(cpfile)
for line in fin:
fout.write(replace_GraceDB(line))
lalinferenceargs = [ 'lalinference_pipe' lalinferenceargs = [ 'lalinference_pipe'
, '--gid' , '--gid'
...@@ -245,8 +186,7 @@ if args.gracedb: ...@@ -245,8 +186,7 @@ if args.gracedb:
, './run' , './run'
, '-p' , '-p'
, './daglog' , './daglog'
, args.output+'/GraceDB/'+os.path.basename(ini_file) , GDB_ini_file ]
]
if args.condor_submit: if args.condor_submit:
lalinferenceargs.append('--condor-submit') lalinferenceargs.append('--condor-submit')
...@@ -255,46 +195,24 @@ if args.gracedb: ...@@ -255,46 +195,24 @@ if args.gracedb:
############################################################ ############################################################
def replace_fiducial_bbh(line): def set_fiducial_bbh(cp):
if 'webdir=' in line:
return line.replace(line.split('=')[-1],web_outputdir+'/fiducialBBH/webdir/') cp.set('lalinference','fake-cache',"{'H1':'LALSimAdLIGO','L1':'LALSimAdLIGO','V1':'LALSimAdVirgo'}")
if 'baseurl=' in line: cp.set('analysis','dataseed','1234')
return line.replace(line.split('=')[-1],'file://'+web_outputdir+'/fiducialBBH/webdir/') cp.set('engine','0noise','')
if 'ifos=' in line:
return "ifos=['H1','L1']\n" cp.set('paths','webdir',web_outputdir+'/fiducialBBH/webdir/')
if 'fake-cache=' in line: cp.set('lalinference','flow',"{'H1':40,'L1':40,'V1':40}")
return line.replace(line,"fake-cache={'H1':'LALSimAdLIGO','L1':'LALSimAdLIGO','V1':'LALSimAdVirgo'}") cp.set('engine','approx','IMRPhenomPv2pseudoFourPN')
if 'ignore-science-segments=' in line: cp.set('analysis','roq','True')
return 'ignore-science-segments=True\n' cp.remove_option('engine','disable-spin')
if 'dataseed=' in line: cp.set('resultspage','deltaLogP','6')
return line.replace('#','').strip()+'\n' cp.set('engine','distance-max','2000')
if 'disable-spin=' in line:
return '#disable-spin=\n' cp.set('engine','neff','500')
if 'margphi=' in line: cp.set('engine','nlive','512')
return '#margphi=\n'
if 'flow=' in line: return cp
return line.replace('#','').strip()+'\n'
if 'roq_b_matrix_directory=' in line:
return line.replace('#','').strip()+'\n'
if 'computeroqweights=' in line:
return line.replace('#','').strip()+'\n'
if 'approx=' in line:
return line.replace(line,"approx=IMRPhenomPv2pseudoFourPN")+'\n'
if 'parname-max' in line:
return line+'\ndistance-max=2000\n'
if 'deltaLogP=' in line:
return 'deltaLogP=6.0\n'
if '0noise=' in line:
return line.replace('#','').strip()+'\n'
if 'neff=' in line:
return line.replace(line,"neff=500")
if 'nlive=' in line:
return line.replace(line,"nlive=512")
if 'maxmcmc=' in line:
return line.replace(line,"#maxmcmc=3000")
if 'fref=' in line:
return line.replace('#','').replace('100','20').strip()+'\n'
return line
if args.bbh_injection: if args.bbh_injection:
...@@ -302,13 +220,11 @@ if args.bbh_injection: ...@@ -302,13 +220,11 @@ if args.bbh_injection:
os.chdir(args.output+'/fiducialBBH/') os.chdir(args.output+'/fiducialBBH/')
shutil.copy(args.bbh_injection,args.output+'/fiducialBBH/') shutil.copy(args.bbh_injection,args.output+'/fiducialBBH/')
shutil.copy(ini_file,args.output+'/fiducialBBH/'+os.path.basename(ini_file)+'.bak') BBH_ini_file=os.path.join(args.output,'fiducialBBH','BBH.ini')
shutil.copy(ini_file,args.output+'/fiducialBBH/')
with open(args.output+'/fiducialBBH/'+os.path.basename(ini_file),'w') as fout: cpBBH=set_fiducial_bbh(init_ini_file())
with open(args.output+'/fiducialBBH/'+os.path.basename(ini_file)+'.bak','r') as fin: with open(BBH_ini_file,'w') as cpfile:
for line in fin: cpBBH.write(cpfile)
fout.write(replace_fiducial_bbh(line))
lalinferenceargs = [ 'lalinference_pipe' lalinferenceargs = [ 'lalinference_pipe'
, '-I' , '-I'
...@@ -317,8 +233,7 @@ if args.bbh_injection: ...@@ -317,8 +233,7 @@ if args.bbh_injection:
, './run' , './run'
, '-p' , '-p'
, './daglog' , './daglog'
, args.output+'/fiducialBBH/'+os.path.basename(ini_file) , BBH_ini_file ]
]
if args.condor_submit: if args.condor_submit:
lalinferenceargs.append('--condor-submit') lalinferenceargs.append('--condor-submit')
...@@ -326,55 +241,34 @@ if args.bbh_injection: ...@@ -326,55 +241,34 @@ if args.bbh_injection:
subprocess.call(lalinferenceargs) subprocess.call(lalinferenceargs)
############################################################ ############################################################
def replace_analytic_test(line, test_func): def set_analytic_test(cp, test_func):
if 'webdir=' in line:
return line.replace(line.split('=')[-1],web_outputdir+'/'+test_func+'/webdir/') cp.set('paths','webdir',web_outputdir+'/'+test_func+'/webdir/')
if 'baseurl=' in line: cp.set('lalinference','fake-cache',"{'H1':'LALSimAdLIGO','L1':'LALSimAdLIGO','V1':'LALSimAdVirgo'}")
return line.replace(line.split('=')[-1],'file://'+web_outputdir+'/'+test_func+'/webdir/') cp.set('analysis','dataseed','1234')
if 'fake-cache=' in line:
return line.replace(line,"fake-cache={'H1':'LALSimAdLIGO','L1':'LALSimAdLIGO','V1':'LALSimAdVirgo'}") cp.set('input','analyse-all-time','True')
if 'dataseed=' in line: cp.set('input','gps-start-time','0')
return line.replace('#','').strip()+'\n' cp.set('input','gps-end-time','2')
if 'analyse-all-time' in line: cp.set('input','segment-overlap','0')
return 'analyse-all-time=True\n' cp.set('input','psd-length','1')
if 'ignore-science-segments=' in line:
return 'ignore-science-segments=True\n' cp.set('engine','seglen','1')
if 'seglen=' in line: cp.set('engine','approx','SpinTaylorT4')
return 'seglen=1\n' cp.set('engine',test_func,'')
if 'gps-start-time=' in line: cp.set('engine','neff','10000')
return 'gps-start-time=0\n' cp.set('engine','nlive','512')
if 'gps-end-time=' in line:
return 'gps-end-time=2\n' cp.set('resultspage','deltaLogP','7')
if 'segment-overlap=' in line:
return 'segment-overlap=0\n'
if ' psd-length=' in line:
return 'psd-length=1\n'
if 'dataseed=' in line:
return line.replace('#','').strip()+'\n'
if 'disable-spin=' in line:
return '#disable-spin=\n'
if 'approx=' in line:
return line.replace(line,"approx=SpinTaylorT4")+'\n'
if test_func+'=' in line:
return test_func+'=\n'
if 'deltaLogP=' in line:
return 'deltaLogP=7\n'
if 'neff=' in line:
return line.replace(line,"neff=10000")
if 'nlive=' in line:
return line.replace(line,"nlive=512")
if 'maxmcmc=' in line:
return line.replace(line,"#maxmcmc=3000")
if test_func != "rosenbrockLikelihood": if test_func != "rosenbrockLikelihood":
if 'meanVectors=' in line: csv = args.output+'/'+test_func+'_means.csv'
csv = args.output+'/'+test_func+'_means.csv' if os.path.isfile(csv):
if os.path.isfile(csv): cp.set('resultspage','meanVectors',csv)
return 'meanVectors='+csv+'\n' csv = args.output+'/'+'test_correlation_matrix.csv'
if 'covarianceMatrix=' in line: if os.path.isfile(csv):
csv = args.output+'/'+'test_correlation_matrix.csv' cp.set('resultspage','covarianceMatrix',csv)
if os.path.isfile(csv):
return 'covarianceMatrix='+csv+'\n' return cp
return line
if args.analytic_tests: if args.analytic_tests:
test_funcs = ['correlatedGaussianLikelihood', 'bimodalGaussianLikelihood', 'rosenbrockLikelihood'] test_funcs = ['correlatedGaussianLikelihood', 'bimodalGaussianLikelihood', 'rosenbrockLikelihood']
...@@ -382,21 +276,20 @@ if args.analytic_tests: ...@@ -382,21 +276,20 @@ if args.analytic_tests:
os.makedirs(args.output+'/' + test_func + '/') os.makedirs(args.output+'/' + test_func + '/')
os.chdir(args.output+'/' + test_func + '/') os.chdir(args.output+'/' + test_func + '/')
shutil.copy(ini_file,args.output+'/'+test_func+'/'+os.path.basename(ini_file)+'.bak')
shutil.copy(ini_file,args.output+'/'+test_func+'/')
with open(args.output+'/'+test_func+'/'+os.path.basename(ini_file),'w') as fout: shutil.copy(args.bbh_injection,args.output+'/'+test_func+'/')
with open(args.output+'/'+test_func+'/'+os.path.basename(ini_file)+'.bak','r') as fin: analytic_ini_file=os.path.join(args.output,test_func,'analytic.ini')
for line in fin:
fout.write(replace_analytic_test(line, test_func)) cpanalytic=set_analytic_test(init_ini_file(), test_func)
with open(analytic_ini_file,'w') as cpfile:
cpanalytic.write(cpfile)
lalinferenceargs = [ 'lalinference_pipe' lalinferenceargs = [ 'lalinference_pipe'
, '-r' , '-r'
, './run' , './run'
, '-p' , '-p'
, './daglog' , './daglog'
, args.output+'/'+test_func+'/'+os.path.basename(ini_file) , analytic_ini_file ]
]
if args.condor_submit: if args.condor_submit:
lalinferenceargs.append('--condor-submit') lalinferenceargs.append('--condor-submit')
...@@ -405,51 +298,39 @@ if args.analytic_tests: ...@@ -405,51 +298,39 @@ if args.analytic_tests:
############################################################ ############################################################
def replace_pptest(line): def set_pptest(cp):
if 'webdir=' in line:
return line.replace(line.split('=')[-1],web_outputdir+'/pptest/webdir/') cp.set('paths','webdir',web_outputdir+'/pptest/webdir/')
if 'baseurl=' in line: cp.set('lalinference','fake-cache',"{'H1':'LALSimAdLIGO','L1':'LALSimAdLIGO','V1':'LALSimAdVirgo'}")
return line.replace(line.split('=')[-1],'file://'+web_outputdir+'/pptest/webdir/') cp.set('analysis','dataseed','1234')
if 'fake-cache=' in line:
return line.replace(line,"fake-cache={'H1':'LALSimAdLIGO','L1':'LALSimAdLIGO','V1':'LALSimAdVirgo'}") cp.remove_option('engine','margphi')
if 'ignore-science-segments=' in line: cp.set('engine','margtime','')
return 'ignore-science-segments=True\n' cp.set('engine','amporder','-1')
if 'dataseed=' in line: cp.set('engine','fref','0')
return line.replace('#','').strip()+'\n' cp.set('engine','distance-max','2000'