-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplot_bpas.py
More file actions
executable file
·52 lines (41 loc) · 1.36 KB
/
plot_bpas.py
File metadata and controls
executable file
·52 lines (41 loc) · 1.36 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
49
50
51
52
'''
parameter plotting for PEST
a m!ke@usgs joint
contact: mnfienen@usgs.gov
'''
import numpy as np
import os
import pylab as plt
from matplotlib.backends.backend_pdf import PdfPages
basecase = 'assp3tr'
allfiles = os.listdir(os.getcwd())
bpas = dict()
for cf in allfiles:
if ((basecase in cf) and ('bpa' in cf) and (cf[-4:] != '.bpa')):
cind = int(cf.split('.')[-1])
bpas[cind] = cf
# open the initial bpa file to get parameter names
parnames = np.genfromtxt(bpas[0],skip_header=1,usecols=[0],dtype=None)
# grab the first set of values from bpas[0]
vals = np.genfromtxt(bpas[0],skip_header=1,usecols=[1])
# now, if there are more than one
if len(bpas) > 1:
for cf in bpas:
tmp = np.genfromtxt(bpas[cf],skip_header=1,usecols=[1])
vals = np.vstack((vals,tmp))
# make a matrix that can be more easily manipulated
vals = vals.T
normvals = vals/np.atleast_2d(vals[:,0]).T
# zip up and make a dictionary for the individual plots
allvals = dict(zip(parnames,vals))
# make a PDF with a page for each parameter, plotting all values
pp = PdfPages(basecase + '_parvalues.pdf')
for cp in sorted(allvals):
currfig = plt.figure()
pvs = allvals[cp]
plt.plot(np.arange(len(pvs))+1,pvs,'o-')
plt.xlabel('Iteration')
plt.ylabel('Parameter Value')
plt.title('Parameter Values for %s' %(cp))
pp.savefig()
pp.close()