Commit 175cc615 authored by Ben Farr's avatar Ben Farr
Browse files

Add analytic tests to pipeline and automated testing script

Original: 5d3968cfb1403793fe00a53a7b6e699308e84255
parent ed829634
......@@ -76,7 +76,7 @@ padding=16
events=all
# Overlap between segments when analysing a continuous span of time
# segment-overlap = 32
# segment-overlap=32
# Can manually over-ride time limits here.
# If analysing a continuous stretch of time the start and end times must
......@@ -293,6 +293,11 @@ adapt-temps=
# Setting time prior [seconds]
#dt=0.1
# The following options are for using analytic test functions
#correlatedGaussianLikelihood=
#bimodalGaussianLikelihood=
#rosenbrockLikelihood=
# The following three options control various marginalised likelihoods. Use at most one.
# Analytically marginalise over phase (only for Newtonian amplitude orders)
margphi=
......@@ -356,6 +361,10 @@ skyres=0.5
# This deltaLogP value should be the number of signal parameters divided by 2.
#deltaLogP=4
# CSVs for analytic tests
#meanVectors=unimodal_test_means.csv
#covarianceMatrix=test_correlation_matrix.csv
# Send an email linking to the final page
#email=albert.einstein@ligo.org
......
......@@ -23,6 +23,14 @@ parser.add_argument('--gracedb', action='store_true',
default=False,
help='Runs the analysis for the GraceDB test event T169545.')
parser.add_argument('--analytic-tests', action='store_true',
default=False,
help='Run on the unmodal and bimodial Gaussian and Rosenbrock test functions.')
parser.add_argument('--analytic-csv-dir', type=str,
default='./',
help='Directory containing the CSVs describing the analytic tests.')
parser.add_argument('--pptest', action='store_true',
default=False,
help='Runs a P-P analysis.')
......@@ -76,6 +84,12 @@ try:
except:
print ini_file+' will be modified.'
analytic_csv_dir = os.path.abspath(args.analytic_csv_dir)
if args.analytic_tests:
csvs = glob.glob(analytic_csv_dir+"/*csv")
for csv in csvs:
shutil.copy(csv,args.output+'/'+os.path.basename(csv))
os.chdir(args.output)
path_keys = {'datafind': 'ligo_data_find',
......@@ -325,6 +339,84 @@ if args.bbh_injection:
subprocess.call(lalinferenceargs)
############################################################
def replace_analytic_test(line, test_func):
if 'webdir=' in line:
return line.replace(line.split('=')[-1],web_outputdir+'/'+test_func+'/webdir/')
if 'baseurl=' in line:
return line.replace(line.split('=')[-1],'file://'+web_outputdir+'/'+test_func+'/webdir/')
if 'fake-cache=' in line:
return line.replace(line,"fake-cache={'H1':'LALSimAdLIGO','L1':'LALSimAdLIGO','V1':'LALSimAdVirgo'}")
if 'dataseed=' in line:
return line.replace('#','').strip()+'\n'
if 'analyse-all-time' in line:
return 'analyse-all-time=True\n'
if 'ignore-science-segments=' in line:
return 'ignore-science-segments=True\n'
if 'seglen=' in line:
return 'seglen=1\n'
if 'gps-start-time=' in line:
return 'gps-start-time=0\n'
if 'gps-end-time=' in line:
return 'gps-end-time=2\n'
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=256")
if 'maxmcmc=' in line:
return line.replace(line,"#maxmcmc=3000")
if test_func != "rosenbrockLikelihood":
if 'meanVectors=' in line:
csv = args.output+'/'+test_func+'_means.csv'
if os.path.isfile(csv):
return 'meanVectors='+csv+'\n'
if 'covarianceMatrix=' in line:
csv = args.output+'/'+'test_correlation_matrix.csv'
if os.path.isfile(csv):
return 'covarianceMatrix='+csv+'\n'
return line
if args.analytic_tests:
test_funcs = ['correlatedGaussianLikelihood', 'bimodalGaussianLikelihood', 'rosenbrockLikelihood']
for test_func in test_funcs:
os.makedirs(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:
with open(args.output+'/'+test_func+'/'+os.path.basename(ini_file)+'.bak','r') as fin:
for line in fin:
fout.write(replace_analytic_test(line, test_func))
lalinferenceargs = [ 'lalinference_pipe'
, '-r'
, './run'
, '-p'
, './daglog'
, args.output+'/'+test_func+'/'+os.path.basename(ini_file)
]
if args.condor_submit:
lalinferenceargs.append('--condor-submit')
subprocess.call(lalinferenceargs)
############################################################
def replace_pptest(line):
......
......@@ -850,6 +850,13 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
else:
selected_events=None
if(self.config.has_option('engine','correlatedGaussianLikelihood') or
self.config.has_option('engine','bimodalGaussianLikelihood') or
self.config.has_option('engine','rosenbrockLikelihood')):
analytic_test = True
else:
analytic_test = False
# No input file given, analyse the entire time stretch between gpsstart and gpsend
if self.config.has_option('input','analyse-all-time') and self.config.getboolean('input','analyse-all-time')==True:
print 'Setting up for analysis of continuous time stretch %f - %f'%(gpsstart,gpsend)
......@@ -871,11 +878,13 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
while(t<gpsend):
ev=Event(trig_time=t+seglen-2)
ev.set_engine_option('segment-start',str(t-overlap))
ev.set_engine_option('time-min',str(t))
if not analytic_test:
ev.set_engine_option('time-min',str(t))
tMax=t + seglen - overlap
if tMax>=gpsend:
tMax=gpsend
ev.set_engine_option('time-max',str(tMax))
if not analytic_test:
ev.set_engine_option('time-max',str(tMax))
events.append(ev)
t=tMax
return events
......@@ -1236,7 +1245,7 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
myifos=set([])
for ifo in ifos:
for seg in self.segments[ifo]:
if segstart >= seg.start() and segend < seg.end():
if segstart >= seg.start() and segend <= seg.end():
myifos.add(ifo)
ifos=myifos
if len(ifos)==0:
......@@ -1441,8 +1450,8 @@ class LALInferencePipelineDAG(pipeline.CondorDAG):
if gotdata:
self.add_node(node)
else:
'Print no data found for time %f'%(end_time)
return None
print 'no data found for time %f'%(end_time)
return None, bayeswavepsdnode
if extra_options is not None:
for opt in extra_options.keys():
node.add_var_arg('--'+opt+' '+extra_options[opt])
......
m1, m2, costheta_jn, phase, psi, ra, dec, logdistance, time, a1, a2, tilt1, tilt2, phi12, phi_jl
1.514217143033650537e+01, 6.063740170449759326e+00, -4.210686614017933316e-02, 2.924440307697235841e+00, 2.995800628518570097e+00, 2.878758490647420398e+00, -2.405592886753007420e-01, 3.903888175904865587e+00, -8.588988316647944155e-02, 4.027652321227926380e-01, 4.374953239990266862e-01, 1.433679315629145856e+00, 1.441052036478498222e+00, 2.853800812191395586e+00, 2.850091117089986970e+00
1.685782856966349641e+01, 7.936259829550240674e+00, 4.210686614017933316e-02, 3.358744999482350391e+00, 3.287384678661016135e+00, 3.404426816532165834e+00, 2.405592886753007420e-01, 4.096111824095134857e+00, 8.588988316647944155e-02, 5.972347678772074175e-01, 5.625046760009733138e-01, 1.707913337960647260e+00, 1.700540617111294894e+00, 3.429384494988190646e+00, 3.433094190089599262e+00
m1, m2, costheta_jn, phase, psi, ra, dec, logdistance, time, a1, a2, tilt1, tilt2, phi12, phi_jl
16.0, 7.0, 0.0, 3.141592653589793, 3.141592653589793, 3.141592653589793, 0.0, 4.0, 0.0, 0.5, 0.5, 1.5707963267948966, 1.5707963267948966, 3.141592653589793, 3.141592653589793
4.599186593318236455e-02,-5.489748382557155248e-03,-5.125336118372740080e-04,6.310741387091149636e-04,-5.128470284006775119e-04,-1.074998398302583376e-03,-1.167836861249167040e-03,-7.694897715679858714e-04,5.260905282822457476e-04,1.360795754823171779e-04,1.970785895702775801e-04,1.053761268939609795e-03,-8.023132316053279344e-04,1.383103227113925866e-03,-1.052394735671202675e-03
-5.489748382557151779e-03,5.478640427684031838e-02,-2.393101458418423031e-04,-2.491407823545352309e-03,-9.338553047165586087e-05,1.526332189635919850e-03,-3.665553719224811432e-03,3.169780190169034896e-04,6.761345004654851359e-04,-3.759976153266847724e-04,5.571796842520161447e-04,-1.116809351461912599e-03,-7.033670229857136909e-04,-3.534509978109373358e-03,2.345270853874419949e-03
-5.125336118372740080e-04,-2.393101458418421946e-04,1.108117610091863113e-04,-1.660774795680858203e-05,-7.764205550884585116e-05,-7.590277284859921062e-05,-7.188257677339316613e-05,1.255360574197783764e-05,-5.063455956785590823e-05,5.767975762436319673e-05,2.886527364339236154e-05,4.152053124867138525e-05,-4.354153067533662972e-05,7.032802357888986620e-05,-9.745486788237736620e-05
6.310741387091149636e-04,-2.491407823545352309e-03,-1.660774795680856848e-05,2.947196332915053615e-03,-3.850861613476366731e-04,-1.131742021612593423e-04,9.796309417027073470e-04,-2.407847281809416149e-05,-1.809367534662931860e-04,-8.560285041708446779e-06,1.220618881532609064e-04,1.103534358996022161e-05,3.261776531025266271e-04,-3.249787199220539554e-04,-5.796634070727268821e-04
-5.128470284006775119e-04,-9.338553047165613192e-05,-7.764205550884585116e-05,-3.850861613476366189e-04,1.328457160898005541e-03,-3.674776827218033588e-04,-1.244386086190234686e-04,7.067905265651232109e-05,1.506556141267217258e-04,1.352887124542726497e-06,5.319182621224510354e-05,-6.417063490265883911e-05,1.532621400089476905e-05,-3.258872829973066517e-04,-4.560360202322924538e-04
-1.074998398302583376e-03,1.526332189635919850e-03,-7.590277284859922417e-05,-1.131742021612592880e-04,-3.674776827218034672e-04,4.317612325601107894e-03,8.845843191354932052e-04,-3.487058531494282090e-04,-2.079809771946313629e-05,-3.955745826391884461e-05,-2.167693575226642628e-04,9.737526755558731340e-05,-1.206893099293788964e-04,-6.370611332578865688e-04,3.286931361162723523e-04
-1.167836861249167907e-03,-3.665553719224811866e-03,-7.188257677339313903e-05,9.796309417027073470e-04,-1.244386086190234686e-04,8.845843191354932052e-04,3.616798210497917335e-03,-2.975191547087507968e-04,-1.952104526014412933e-04,2.236429424115952383e-04,-2.117822374679926230e-05,-2.962546795336588076e-04,2.822034243865472478e-04,-5.123405657297256158e-05,-8.356166476617618577e-04
-7.694897715679857629e-04,3.169780190169034896e-04,1.255360574197782917e-05,-2.407847281809418860e-05,7.067905265651228044e-05,-3.487058531494283175e-04,-2.975191547087510137e-04,5.773426706808799762e-04,5.521731225009531750e-05,-1.700804880540516520e-04,6.749693090695893201e-05,-9.972137823002499379e-05,-1.237668867616082151e-04,-1.671878276048168279e-04,3.495582063898903971e-04
5.260905282822457476e-04,6.761345004654850275e-04,-5.063455956785590823e-05,-1.809367534662932402e-04,1.506556141267217258e-04,-2.079809771946313629e-05,-1.952104526014413204e-04,5.521731225009531750e-05,4.610670018969680517e-04,-1.042701081287956608e-04,-9.861561285861987115e-06,-1.397383616105031881e-04,-5.910518389959229507e-05,1.058856623744708174e-05,-9.970008161638034539e-05
1.360795754823174489e-04,-3.759976153266847724e-04,5.767975762436319673e-05,-8.560285041708329888e-06,1.352887124542700874e-06,-3.955745826391885816e-05,2.236429424115952383e-04,-1.700804880540517062e-04,-1.042701081287956743e-04,5.909125052583997584e-04,2.192545816395299204e-05,-3.232183992063706050e-05,-7.542207331389261943e-05,-4.418752491570875876e-04,-1.765264706189653308e-04
1.970785895702776343e-04,5.571796842520161447e-04,2.886527364339236154e-05,1.220618881532609741e-04,5.319182621224508999e-05,-2.167693575226643441e-04,-2.117822374679924875e-05,6.749693090695893201e-05,-9.861561285862004055e-06,2.192545816395298866e-05,2.441771576241655545e-04,-4.770765187366058323e-05,-1.755156666408266635e-04,-2.573946887242001437e-05,-2.242158666961410914e-04
1.053761268939610012e-03,-1.116809351461912599e-03,4.152053124867139202e-05,1.103534358996028091e-05,-6.417063490265878490e-05,9.737526755558735406e-05,-2.962546795336586450e-04,-9.972137823002498024e-05,-1.397383616105031881e-04,-3.232183992063706050e-05,-4.770765187366059678e-05,1.175067171939288236e-03,2.175988100809144775e-05,-3.583994582735928428e-05,-3.198947382559092422e-04
-8.023132316053279344e-04,-7.033670229857144499e-04,-4.354153067533661617e-05,3.261776531025266271e-04,1.532621400089472500e-05,-1.206893099293788964e-04,2.822034243865473562e-04,-1.237668867616081609e-04,-5.910518389959226797e-05,-7.542207331389264653e-05,-1.755156666408266635e-04,2.175988100809141387e-05,1.052098804356614526e-03,5.031005485835133233e-05,1.671549530338130329e-04
1.383103227113926083e-03,-3.534509978109374225e-03,7.032802357888987975e-05,-3.249787199220539554e-04,-3.258872829973066517e-04,-6.370611332578864604e-04,-5.123405657297252092e-05,-1.671878276048168279e-04,1.058856623744710884e-05,-4.418752491570878045e-04,-2.573946887242001437e-05,-3.583994582735928428e-05,5.031005485835142042e-05,5.176508998467517671e-03,-2.532055516308608689e-05
-1.052394735671202675e-03,2.345270853874419949e-03,-9.745486788237733909e-05,-5.796634070727270990e-04,-4.560360202322924538e-04,3.286931361162725150e-04,-8.356166476617618577e-04,3.495582063898903971e-04,-9.970008161638029118e-05,-1.765264706189653850e-04,-2.242158666961410914e-04,-3.198947382559092422e-04,1.671549530338130058e-04,-2.532055516308608689e-05,5.310821611359238699e-03
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