forked from acarvalh/Limit_codes
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoutputNonresLimits.py
executable file
·71 lines (51 loc) · 1.81 KB
/
outputNonresLimits.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
#run with args <output from combine> <nonres senario> <output file for all limits>
#the goal is to extract the limits (6 numbers) from input #1 and the scenario (lambda, yt, c2) from input #2
#the output is appended to output #3
import sys
from string import atof
if len(sys.argv) < 4:
print "Not enough arguments"
exit(1)
combineFileName=sys.argv[1]
scenarioName=sys.argv[2]
outputFileName=sys.argv[3]
combineFile = open(combineFileName,'r')
obsLim = -1
expLim = [-1, -1, -1, -1, -1]
for line in combineFile:
#Does the line contain Observerd?
if line.find("Observed Limit:") >= 0 :
obsLim=atof(line[line.find('r < ')+4:])
continue
#Does the line contain Expected?
if line.find("Expected 2.5%:") >= 0 :
expLim[0]=atof(line[line.find('r < ')+4:])
continue
if line.find("Expected 16.0%:") >= 0 :
expLim[1]=atof(line[line.find('r < ')+4:])
continue
if line.find("Expected 50.0%:") >= 0 :
expLim[2]=atof(line[line.find('r < ')+4:])
continue
if line.find("Expected 84.0%:") >= 0 :
expLim[3]=atof(line[line.find('r < ')+4:])
continue
if line.find("Expected 97.5%:") >= 0 :
expLim[4]=atof(line[line.find('r < ')+4:])
continue
combineFile.close()
if obsLim < 0:
obsLim = expLim[2]
#parse the scenario name
scenarioList=scenarioName.replace('d','.').replace('m','-').split('_')
if len(scenarioList) <6:
print "Invalid scenario name"
exit(1)
lambda_hhh=atof(scenarioList[1])
yt=atof(scenarioList[3])
c2=atof(scenarioList[5])
#append everything to outputFileName
outputfile = open(outputFileName,'a')
outputfile.write("%2d %4.2f %3d %.4f %.4f %.4f %.4f %.4f %.4f\n" % (c2,yt,lambda_hhh,expLim[0],expLim[1],expLim[2],expLim[3],expLim[4],obsLim) )
outputfile.close()