Example 2

Read and explore the output from Example 2 -- a multidim parameter study that evaluates the effects of varying temperature and precipitation on sediment load values in HydroTrend.

Use pylab magic:


In [ ]:
%pylab inline

Read the Dakota tabular data file.


In [ ]:
dat_file = '../examples/2-hydrotrend/dakota.dat'
data = numpy.loadtxt(dat_file, skiprows=1, unpack=True, usecols=[0,2,3,4,5])

Extract the temperature and precipitation parameter values from the tabular data array.


In [ ]:
T = data[1,]
P = data[2,]
print 'Temperature:'
print T
print 'Precipitation:'
print P

Plot the multidim parameter study evaluation locations.


In [ ]:
plot(T, P, 'ro')
xlim((5, 25))
ylim((1, 3))
xlabel('$T \,(^{\circ}C)$')
ylabel('$P \,(m)$')
title('Planview of parameter study locations')

Next, to make surface and contour plots of the Dakota responses, the $T$, $P$ and $Q_s$ values have to be reshaped into 2D arrays.


In [ ]:
m = len(set(T))
n = len(set(P))
T2 = T.reshape(n,m)
P2 = P.reshape(n,m)
Qs2 = data[3,].reshape(n,m)

Make a wire mesh surface plot of the mean $Q_s$ values at the study locations.


In [ ]:
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure()
ax = Axes3D(fig)
ax.plot_wireframe(T2, P2, Qs2)
ax.set_xlabel('$T \,(^\circ C)$')
ax.set_ylabel('$P \,(m)$')
ax.set_zlabel('$Q_s \,(kg \, s^{-1})$')

Make a contour plot of the mean $Q_s$ values at the study locations.


In [ ]:
contour(T2, P2, Qs2, 15, cmap=cm.Blues_r)
xlim((5, 25))
ylim((1, 3))
xlabel('$T \,(^\circ C)$')
ylabel('$P \,(m)$')