Changeset 5166


Ignore:
Timestamp:
Mar 23, 2015, 1:48:24 PM (5 years ago)
Author:
mmh
Message:

snapshot of uq work

Location:
branches/uq
Files:
4 edited

Legend:

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

    r5121 r5166  
    11031103
    11041104    #
     1105    # Now handle SUBMIT-PROGRESS
     1106    #
     1107    while {[regexp -indices {=SUBMIT-PROGRESS=> aborted=([0-9]+) finished=([0-9]+) failed=([0-9]+) executing=([0-9]+)\
     1108        waiting=([0-9]+) setting_up=([0-9]+) setup=([0-9]+) %done=([0-9.]+) timestamp=([0-9.]+)} $message \
     1109        match aborted finished failed executing waiting setting_up setup percent ts mesg]} {
     1110
     1111        set mesg ""
     1112        foreach {i0 i1} $percent break
     1113        set percent [string range $message $i0 $i1]
     1114        foreach {i0 i1} $failed break
     1115        set failed [string range $message $i0 $i1]
     1116        foreach {i0 i1} $match break
     1117        set message [string replace $message $i0 $i1]
     1118
     1119        if {$failed != 0} {set mesg "$failed jobs failed!"}
     1120        if {$percent >= 100} { set mesg "Jobs finished.  Analyzing results..."}
     1121
     1122        pack $itk_component(progress) -fill x -padx 10 -pady 10
     1123        $itk_component(progress) settings -percent $percent -message $mesg
     1124    }
     1125
     1126
     1127    #
    11051128    # Break up the remaining lines according to =RAPPTURE-ERROR=> messages.
    11061129    # Show errors in a special color.
  • branches/uq/gui/scripts/numberentry.tcl

    r5029 r5166  
    4343itcl::body Rappture::NumberEntry::constructor {owner path args} {
    4444    puts "NumberEntry '$path' '$args'"
    45     set varname [lindex [split $path ()] 1]
    46 
     45    set varname [lindex [split $path ()] end-1]
    4746    if {[catch {$owner isa Rappture::ControlOwner} valid] != 0 || !$valid} {
    4847        error "bad object \"$owner\": should be Rappture::ControlOwner"
     
    5150    set _path $path
    5251
    53     puts "LABEL=[label]"
    5452    #
    5553    # Figure out what sort of control to create
     
    6462    set class Rappture::Gauge
    6563    set units [string trim [$_owner xml get $path.units]]
    66     puts "units=$units"
    6764    if {$units != ""} {
    6865        set desc [Rappture::Units::description $units]
     
    123120    #
    124121    set str [string trim [$_owner xml get $path.default]]
    125     puts "Default=$str"
    126122    if {$str ne ""} {
    127123        $itk_component(gauge) value $str
  • branches/uq/gui/scripts/probdisteditor.tcl

    r5103 r5166  
    243243            if {"" != $_umin} {
    244244                if {"" != $units} {
    245                     set tmp(min) [Rappture::Units::convert $_umin -to $units -units off]
     245                    set tmp(min) [Rappture::Units::convert $_umin -to $units -context $units -units off]
    246246                } else {
    247247                    set tmp(min) $_umin
     
    250250            if {"" != $_umax} {
    251251                if {"" != $units} {
    252                     set tmp(max) [Rappture::Units::convert $_umax -to $units -units off]
     252                    set tmp(max) [Rappture::Units::convert $_umax -to $units -context $units -units off]
    253253                } else {
    254254                    set tmp(max) $_umax
  • branches/uq/puq/puq_analyze.py

    r5148 r5166  
    6262    xy.text = pts
    6363
     64def dist(x1,y1, x2,y2, x3,y3): # x3,y3 is the point
     65    diffx = x2-x1
     66    diffy = y2-y1
     67    sqdiff = float(diffx**2 + diffy**2)
     68
     69    u = ((x3 - x1) * diffx + (y3 - y1) * diffy) / sqdiff
     70
     71    if u > 1:
     72        u = 1
     73    elif u < 0:
     74        u = 0
     75
     76    x = x1 + u * diffx
     77    y = y1 + u * diffy
     78
     79    dx = x - x3
     80    dy = y - y3
     81
     82    return np.sqrt(dx*dx + dy*dy)
     83
     84# Plots advanced probability curves
     85def plot_pdf_acurve(hf, acurves, vname, percent, desc):
     86    print 'plot_pdf_acurve %s %s %s' % (vname, percent, desc)
     87    # compute upper and lower percentiles
     88    pm = (100 - percent)/200.0
     89    pp = 1 - pm
     90    vlen = len(acurves[vname])
     91
     92    print 'vlen=', vlen
     93    # collect data into an array
     94    xp = np.empty(vlen)
     95    xm = np.empty(vlen)
     96    yp = np.empty(vlen)
     97    ym = np.empty(vlen)
     98
     99    for vindex in sorted(acurves[vname].keys()):
     100        print 'vindex=', vindex
     101        x1 = acurves[vname][vindex][0].ppf(pp)
     102        x2 = acurves[vname][vindex][0].ppf(pm)
     103        y1 = acurves[vname][vindex][1].ppf(pp)
     104        y2 = acurves[vname][vindex][1].ppf(pm)
     105        xd = hf['/output/data/%s.x[%d]' % (vname, int(vindex))].value
     106        yd = hf['/output/data/%s.y[%d]' % (vname, int(vindex))].value
     107        #p1, p2 = get_closest2()
     108        if int(vindex) == 2:
     109            print x1, x2, y1, y2
     110            print 'xd=', repr(xd)
     111            print 'yd=', repr(yd)
     112
     113        #xp[vindex] = x1
     114        #xm[vindex] = x2
     115        #yp[vindex] = y1
     116        #ym[vindex] = y2
     117    return
     118    curve = xml.SubElement(dout, 'curve', {'id': 'curve_pdf-%s-%s' % (vname, percent)})
     119    about = xml.SubElement(curve, 'about')
     120    if percent == 0:
     121        xml.SubElement(about, 'label').text = "mean"
     122    else:
     123        xml.SubElement(about, 'label').text = "middle %s%%" % percent
     124    xml.SubElement(about, 'group').text = '%s (Probability)' % desc
     125    comp = xml.SubElement(curve, 'component')
     126    xy = xml.SubElement(comp, 'xy')
     127    pts = ""
     128    for x, y in zip(xarr, yp):
     129        pts += "%s %s " % (x, y)
     130    if percent == 0:
     131        pts += '\n'
     132    else:
     133        for x, y in reversed(zip(xarr, ym)):
     134            pts += "%s %s " % (x, y)
     135        pts += "%s %s\n" % (xarr[0], yp[0])
     136    xy.text = pts
     137
    64138
    65139def plot_pdf(v, pdf, desc):
     
    91165pcurves = {}
    92166xvals = {}
    93 
    94 regexp = re.compile('([ \da-z]+)\[([ \d]+)\]')
     167acurves = {}
     168
     169reg1 = re.compile('([ \da-zA-Z]+)\[([ \d]+)\]')
     170reg2 = re.compile('([ \da-zA-Z]+)\.([xy])\[([ \d]+)\]')
    95171
    96172uqtype = h5.attrs['UQtype']
     
    102178    # For curves built from pdfs, just put them in a dict for now
    103179    if 'x' in odata.attrs:
    104         matches = regexp.findall(v)
     180        matches = reg1.findall(v)
    105181        vname, vindex = matches[0]
    106182        vindex = int(vindex)
     
    110186        xvals[vname][vindex] = odata.attrs['x']
    111187        pcurves[vname][vindex] = pdf
     188    elif reg2.findall(v) != []:
     189        matches = reg2.findall(v)
     190        vname, xy, vindex = matches[0]
     191        if vname not in acurves:
     192            acurves[vname] = {}
     193        if vindex not in acurves[vname]:
     194            acurves[vname][vindex] = {}
     195        if xy == 'x':
     196            acurves[vname][vindex][0] = pdf
     197        else:
     198            acurves[vname][vindex][1] = pdf
    112199    else:
    113200        desc = h5['/output/data/%s' % v].attrs['description']
     
    121208    plot_pdf_curve(xvals, vname, 95, desc)
    122209
     210#for vname in acurves:
     211#    desc = h5['/output/data/%s.x[0]' % vname].attrs['description']
     212#    plot_pdf_acurve(h5, acurves, vname, 0, desc)
     213#    plot_pdf_acurve(h5, acurves, vname, 50, desc)
     214#    plot_pdf_acurve(h5, acurves, vname, 95, desc)
     215
    123216with open('run_uq.xml', 'w') as f:
    124217    f.write("<?xml version=\"1.0\"?>\n")
Note: See TracChangeset for help on using the changeset viewer.