Changeset 5103


Ignore:
Timestamp:
Mar 8, 2015, 9:34:59 PM (9 years ago)
Author:
mmh
Message:

uq work snapshot

Location:
branches/uq
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/uq/gui/scripts/probdisteditor.tcl

    r5102 r5103  
    326326        uniform {
    327327            if {![info exists _value(min)] || ![info exists _value(max)]} {
    328                 puts "UNIFORM min=$min max$max"
     328                # puts "UNIFORM min=$min max=$max"
    329329                if {$min != "" && $max != ""} {
    330330                    set _value(min) $min
     
    342342        }
    343343        gaussian {
     344            # puts "GAUSSIAN min=$min max=$max"
    344345            if {![info exists _value(central)]} {
    345346                if {[info exists _value(min)] && [info exists _value(max)]} {
     
    349350                }
    350351            }
     352            # puts "central=$_value(central)"
    351353            if {![info exists _value(stddev)]} {
    352354                if {[info exists _value(min)] && [info exists _value(max)]} {
     
    355357                    set _value(stddev) [expr {0.3*($max - $min)}]
    356358                } else {
    357                     set _value(stddev)  [expr _value(central) * 0.10]
    358                 }
    359             }
    360 
     359                    set _value(stddev)  [expr $_value(central) * 0.10]
     360                }
     361            }
     362            if {$_value(stddev) <= 0} {
     363                set _value(stddev) 1.0
     364            }
     365            # puts "stddev=$_value(stddev)"
    361366            # lower bound is -3 deviations or tool min
    362367            set trunc [expr {$_value(central) - 3*$_value(stddev)}]
  • branches/uq/gui/scripts/uq.tcl

    r5102 r5103  
    5353
    5454        label $inner.type.labeltext -text "Level" -font "Arial 9"
    55         Rappture::Spinint $inner.type.level -min 2 -max 20
     55        Rappture::Spinint $inner.type.level -min 1 -max 20
    5656        $inner.type.level value $_args
    5757        bind $inner.type.level <<Value>> [itcl::code $this _adjust_level $inner]
  • branches/uq/puq/puq_analyze.py

    r5029 r5103  
    11#!/usr/bin/env python
    2 from puq import *
     2import sys
     3sys.stdout = open("analyze.out", 'w')
     4sys.stderr = open("analyze.err", 'w')
     5
     6import puq
    37import csv
    48import numpy as np
    5 import sys, os, h5py
     9import os, h5py
     10from puq.jpickle import unpickle
     11import xml.etree.ElementTree as xml
    612
    713
     
    2026sw = load_from_hdf5(sys.argv[1])
    2127sw.analyze()
     28
     29h5 = h5py.File(sys.argv[1], 'r+')
     30
     31
     32dtree = xml.parse('run_uq.xml')
     33droot = dtree.getroot()
     34dout = droot.find('output')
     35
     36uqtype = h5.attrs['UQtype']
     37for v in h5[uqtype]:
     38    print 'PDF', v
     39    rs = unpickle(h5['/%s/%s/response' % (uqtype, v)].value)
     40    pdf = rs.pdf(fit=False)
     41
     42    id = '%s PDF' % v
     43    elem = xml.SubElement(dout, 'curve', {'id': id})
     44    about = xml.SubElement(elem, 'about')
     45    label = xml.SubElement(about, 'label')
     46    label.text = id
     47    desc = xml.SubElement(about, 'description')
     48    desc.text = "PDF for %s" % id
     49    yaxis = xml.SubElement(elem, 'yaxis')
     50    label = xml.SubElement(yaxis, 'label')
     51    label.text = 'Probability'
     52
     53    component = xml.SubElement(elem, 'component')
     54    xy = xml.SubElement(component, 'xy')
     55    pts = "%s 0\n" % pdf.x[0]
     56    for x, y in zip(pdf.x, pdf.y):
     57        pts += "%s %s\n" % (x, y)
     58    pts += "%s 0\n" % pdf.x[-1]
     59    xy.text = pts
     60
     61with open('run_uq.xml', 'w') as f:
     62    f.write("<?xml version=\"1.0\"?>\n")
     63    dtree.write(f)
     64
     65
     66h5.close()
Note: See TracChangeset for help on using the changeset viewer.