Index: /branches/uq/puq/get_params.py
===================================================================
--- /branches/uq/puq/get_params.py	(revision 5147)
+++ /branches/uq/puq/get_params.py	(revision 5148)
@@ -1,7 +1,12 @@
 #!/usr/bin/env python
-from puq import *
-import csv, sys, os
+import sys
+from puq import NormalParameter, UniformParameter, Sweep, RapptureHost, Smolyak
+import csv, os
 import numpy as np
 from puq.jpickle import unpickle
+
+sys.stdout = open("gp.out", 'w')
+sys.stderr = open("gp.err", 'w')
+
 
 dfile, pid, varlist, uq_type, args = sys.argv[1:]
@@ -9,12 +14,8 @@
 hname = "puq_%s.hdf5" % pid
 
-
-sys.stdout = open("gp.log", 'w')
-sys.stderr = open("gp.err", 'w')
-
 print sys.argv[1:]
 varlist = unpickle(varlist)
 print "varlist=", varlist
-print type(varlist)
+
 
 v = {}
Index: /branches/uq/puq/puq_analyze.py
===================================================================
--- /branches/uq/puq/puq_analyze.py	(revision 5147)
+++ /branches/uq/puq/puq_analyze.py	(revision 5148)
@@ -1,15 +1,16 @@
 #!/usr/bin/env python
 import sys
+import os
+import numpy as np
+import h5py
+import re
+from puq.jpickle import unpickle
+import xml.etree.ElementTree as xml
+
 sys.stdout = open("analyze.out", 'w')
 sys.stderr = open("analyze.err", 'w')
 
-import puq
-import csv
-import numpy as np
-import os, h5py
-from puq.jpickle import unpickle
-import xml.etree.ElementTree as xml
 
-
+# Restore the state of a PUQ session from a HDF5 file.
 def load_from_hdf5(name):
     h5 = h5py.File(name, 'r+')
@@ -24,30 +25,49 @@
     return sw
 
-sw = load_from_hdf5(sys.argv[1])
-sw.analyze()
 
-h5 = h5py.File(sys.argv[1], 'r+')
+# Plots probability curves
+def plot_pdf_curve(xvals, vname, percent, desc):
+    print 'plot_pdf_curve %s %s %s' % (vname, percent, desc)
+    # compute upper and lower percentiles
+    pm = (100 - percent)/200.0
+    pp = 1 - pm
+
+    # collect data into an array
+    xarr = np.empty(len(xvals[vname]))
+    yp = np.empty(len(xvals[vname]))
+    ym = np.empty(len(xvals[vname]))
+    for vindex in sorted(xvals[vname].keys()):
+        xarr[vindex] = xvals[vname][vindex]
+        yp[vindex] = pcurves[vname][vindex].ppf(pp)
+        ym[vindex] = pcurves[vname][vindex].ppf(pm)
+
+    curve = xml.SubElement(dout, 'curve', {'id': 'curve_pdf-%s-%s' % (vname, percent)})
+    about = xml.SubElement(curve, 'about')
+    if percent == 0:
+        xml.SubElement(about, 'label').text = "mean"
+    else:
+        xml.SubElement(about, 'label').text = "middle %s%%" % percent
+    xml.SubElement(about, 'group').text = '%s (Probability)' % desc
+    comp = xml.SubElement(curve, 'component')
+    xy = xml.SubElement(comp, 'xy')
+    pts = ""
+    for x, y in zip(xarr, yp):
+        pts += "%s %s " % (x, y)
+    if percent == 0:
+        pts += '\n'
+    else:
+        for x, y in reversed(zip(xarr, ym)):
+            pts += "%s %s " % (x, y)
+        pts += "%s %s\n" % (xarr[0], yp[0])
+    xy.text = pts
 
 
-dtree = xml.parse('run_uq.xml')
-droot = dtree.getroot()
-dout = droot.find('output')
-
-uqtype = h5.attrs['UQtype']
-for v in h5[uqtype]:
-    print 'PDF', v
-    rs = unpickle(h5['/%s/%s/response' % (uqtype, v)].value)
-    pdf = rs.pdf(fit=False)
-
-    id = '%s PDF' % v
+def plot_pdf(v, pdf, desc):
+    id = '%s (PDF)' % desc
     elem = xml.SubElement(dout, 'curve', {'id': id})
     about = xml.SubElement(elem, 'about')
-    label = xml.SubElement(about, 'label')
-    label.text = id
-    desc = xml.SubElement(about, 'description')
-    desc.text = "PDF for %s" % id
+    xml.SubElement(about, 'label').text = id
     yaxis = xml.SubElement(elem, 'yaxis')
-    label = xml.SubElement(yaxis, 'label')
-    label.text = 'Probability'
+    xml.SubElement(yaxis, 'label').text = 'Probability'
 
     component = xml.SubElement(elem, 'component')
@@ -59,8 +79,52 @@
     xy.text = pts
 
+
+sw = load_from_hdf5(sys.argv[1])
+sw.analyze()
+
+h5 = h5py.File(sys.argv[1], 'r+')
+dtree = xml.parse('run_uq.xml')
+droot = dtree.getroot()
+dout = droot.find('output')
+
+# curves built from pdfs
+pcurves = {}
+xvals = {}
+
+regexp = re.compile('([ \da-z]+)\[([ \d]+)\]')
+
+uqtype = h5.attrs['UQtype']
+for v in h5[uqtype]:
+    rs = unpickle(h5['/%s/%s/response' % (uqtype, v)].value)
+    pdf = rs.pdf(fit=False)
+    odata = h5['/output/data/%s' % v]
+
+    # For curves built from pdfs, just put them in a dict for now
+    if 'x' in odata.attrs:
+        matches = regexp.findall(v)
+        vname, vindex = matches[0]
+        vindex = int(vindex)
+        if vname not in pcurves:
+            pcurves[vname] = {}
+            xvals[vname] = {}
+        xvals[vname][vindex] = odata.attrs['x']
+        pcurves[vname][vindex] = pdf
+    else:
+        desc = h5['/output/data/%s' % v].attrs['description']
+        plot_pdf(v, pdf, desc)
+
+# now do pdf curves
+for vname in xvals:
+    desc = h5['/output/data/%s[0]' % vname].attrs['description']
+    plot_pdf_curve(xvals, vname, 0, desc)
+    plot_pdf_curve(xvals, vname, 50, desc)
+    plot_pdf_curve(xvals, vname, 95, desc)
+
 with open('run_uq.xml', 'w') as f:
     f.write("<?xml version=\"1.0\"?>\n")
     dtree.write(f)
 
-
+with open('run_uq2.xml', 'w') as f:
+    f.write("<?xml version=\"1.0\"?>\n")
+    dtree.write(f)
 h5.close()
Index: anches/uq/puq/uq.py
===================================================================
--- /branches/uq/puq/uq.py	(revision 5147)
+++ 	(revision )
@@ -1,8 +1,0 @@
-#!/usr/bin/env python
-# This little wrapper exists so we can use the driver
-# xml file as a template.
-# submit should be called like this:
-# submit --runName=puq -l -d params.csv uq.py fermi.py driver25725.xml @:driver25725.xml
-import sys, os
-fname = os.path.basename(sys.argv[3])
-os.system("%s %s %s" % (sys.argv[1], sys.argv[2], fname))
