-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtweak_bounds.py
More file actions
48 lines (43 loc) · 1.04 KB
/
tweak_bounds.py
File metadata and controls
48 lines (43 loc) · 1.04 KB
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
'''
simple code to read in a file and increase or decrease weights to be two orders of magnitude
above or below starting value.
'''
infile = 'pest_pm-all.pst'
outfile = 'pest_pm-allFIXED.pst'
windows_flag = True
'''
if windows_flag:
lineend = '\r\n'
else:
lineend = '\n'
'''
ofp = open(outfile,'w')
indat = open(infile,'r').readlines()
NPAR = int(indat[3].strip().split()[0])
cpar = 0
parflag = False
for i,line in enumerate(indat):
if parflag == False:
if '* parameter data' in line:
parflag = True
ofp.write(line)
else:
cpar+=1
cline = line.strip().split()
cv = float(cline[3])
lb = float(cline[4])
ub = float(cline[5])
if cv - lb < 0:
lb /= 100
if ub - cv < 0:
ub *= 100
cline[4] = '%20.8e' %(lb)
cline[5] = '%20.8e' %(ub)
outline = ''
for k in cline:
outline += '%s ' %(k)
outline += '\n'
ofp.write(outline)
if cpar == NPAR:
parflag = False
ofp.close()