Changeset 5102


Ignore:
Timestamp:
Mar 8, 2015 9:32:55 AM (5 years ago)
Author:
mmh
Message:

snapshot of UQ work

Location:
branches/uq
Files:
1 added
9 edited

Legend:

Unmodified
Added
Removed
  • branches/uq/gui/scripts/Makefile.in

    r5029 r5102  
    123123                $(srcdir)/units.tcl \
    124124                $(srcdir)/utils.tcl \
     125                $(srcdir)/uq.tcl \
    125126                $(srcdir)/valueresult.tcl \
    126127                $(srcdir)/videochooser.tcl \
  • branches/uq/gui/scripts/analyzer.tcl

    r5029 r5102  
    7979    protected method _lammpsToSequence {xmlobj path id child data}
    8080    protected method _trajToSequence {xmlobj {path ""}}
     81    protected method _pop_uq_dialog {win}
     82    protected method _setWaitVariable {state}
     83    protected method _adjust_level {win}
    8184
    8285    private variable _tool ""          ;# belongs to this tool
     
    9295    private variable _lastPlot
    9396    private common job                 ;# array var used for blt::bgexec jobs
     97    private variable _wait_uq 0
    9498}
    9599
     
    324328    }
    325329    pack $itk_component(resultpages) -expand yes -fill both
    326 
    327     set f [$itk_component(results) insert end -fraction 0.1]
     330   set f [$itk_component(results) insert end -fraction 0.1]
    328331    itk_component add resultselector {
    329332        Rappture::ResultSelector $f.rsel -resultset $_resultset \
     
    404407    }
    405408    puts "simulation needed"
     409
     410    set uq [$_tool get_uq -uq_type smolyak -uq_args 2]
     411    # pop up UQ window
     412    if {[$uq num_runs] > 1} {
     413        set status [$uq run_dialog $itk_component(simulate)]
     414        if {$status == 0} {
     415            # cancelled
     416            return
     417        }
     418    }
     419
     420    puts "args=$args"
     421    lappend args -uq_type [$uq type]
     422    lappend args -uq_args [$uq args]
     423    puts "args=$args"
     424
    406425    # simulation is needed -- go to simulation page
    407426    $itk_component(notebook) current simulate
     
    468487    pack forget $itk_component(progress)
    469488}
     489
    470490
    471491# ----------------------------------------------------------------------
  • branches/uq/gui/scripts/probdisteditor.tcl

    r5029 r5102  
    300300        set max $_umax
    301301    } else {
    302         set min [Rappture::Units::convert $_umin -units off]
    303         set max [Rappture::Units::convert $_umax -units off]
     302        if {$_umin == ""} {
     303            set min ""
     304        } else {
     305            set min [Rappture::Units::convert $_umin -units off]
     306        }
     307        if {$_umax == ""} {
     308            set max ""
     309        } else {
     310            set max [Rappture::Units::convert $_umax -units off]
     311        }
    304312    }
    305313
     
    318326        uniform {
    319327            if {![info exists _value(min)] || ![info exists _value(max)]} {
     328                puts "UNIFORM min=$min max$max"
    320329                if {$min != "" && $max != ""} {
    321330                    set _value(min) $min
    322331                    set _value(max) $max
    323                 } elseif {[info exists _value(central)]} {
    324                     if {$_value(central) == 0.0} {
    325                         set delta 0.5
    326                     } else {
    327                         set delta [expr {0.5*$_value(central)}]
    328                     }
    329                     set _value(min) [expr {$_value(central) - $delta}]
    330                     set _value(max) [expr {$_value(central) + $delta}]
    331                 } else {
    332                     set _value(min) 0.1
    333                     set _value(max) 0.9
     332                } elseif {$min != ""} {
     333                    set _value(min) $min
     334                    set _value(max) [expr $min + 1]
     335                } elseif {$max != ""} {
     336                    set _value(max) $max
     337                    set _value(min) [expr $max - 1]
    334338                }
    335339                set _uvalue(min) $_value(min)$_units
     
    338342        }
    339343        gaussian {
    340 
    341344            if {![info exists _value(central)]} {
    342345                if {[info exists _value(min)] && [info exists _value(max)]} {
     
    349352                if {[info exists _value(min)] && [info exists _value(max)]} {
    350353                    set _value(stddev) [expr {0.3*($_value(max) - $_value(min))}]
     354                } elseif {$min != "" && $max != ""} {
     355                    set _value(stddev) [expr {0.3*($max - $min)}]
    351356                } else {
    352                     set _value(stddev) [expr {0.3*($max - $min)}]
     357                    set _value(stddev)  [expr _value(central) * 0.10]
    353358                }
    354359            }
     
    630635                set newval [Rappture::Units::convert [$widget get] -context $_units]
    631636            }
    632             if {[catch {Rappture::Units::mcheck_range $newval $_umin $_umax $_units} err]} {
     637            puts "widget=$widget"
     638            set itk $itk_component(gaussianvals).stddev
     639            puts "itk=$itk"
     640            if {$widget != $itk && [catch {Rappture::Units::mcheck_range $newval $_umin $_umax $_units} err]} {
    633641                # oops! value is bad -- edit again
    634642                bell
  • branches/uq/gui/scripts/spectrum.tcl

    r5029 r5102  
    176176# ----------------------------------------------------------------------
    177177itcl::body Rappture::Spectrum::get {args} {
    178     puts "Spectrum::get $args"
    179178    if {[llength $args] == 0} {
    180179        set rlist ""
     
    201200    set value [lindex $args 0]
    202201
    203     puts "SPECTRUN GET value=$value units=$units"
    204 
    205202    switch -- [lindex $value 0] {
    206203        gaussian {
     
    229226        }
    230227    }
    231     puts "SPECTRUN GET NEW value=$value what=$what"
     228
    232229    switch -- $what {
    233230        -color {
  • branches/uq/gui/scripts/tool.tcl

    r5029 r5102  
    2929        return [$_task installdir]
    3030    }
     31    public method get_uq {args} {
     32        sync  ;# sync all widget values to XML
     33        puts "Tool::get_uq $args"
     34        return [eval $_task get_uq $args]
     35    }
    3136    public method run {args} {
    3237        sync  ;# sync all widget values to XML
     
    5863        error "bad value \"$xmlobj\": should be Rappture::Library"
    5964    }
    60 
     65    puts "Tool Init2"
    6166    set _task [Rappture::Task ::#auto $xmlobj $installdir \
    6267        -logger ::Rappture::Logger::log]
    6368
     69    puts "Tool Init3"
    6470    # save a reference to the tool XML in the ControlOwner
    6571    set _xmlobj $xmlobj
     72    puts "Done with Tool Init"
    6673}
    6774
  • branches/uq/gui/scripts/units.tcl

    r5029 r5102  
    7575
    7676proc Rappture::Units::_check_range {value min max units} {
     77    puts "_check_range $value min=$min max=$max units=$units"
    7778    # make sure the value has units
    7879    if {$units != ""} {
    7980        set value [Rappture::Units::convert $value -context $units]
    8081        # for comparisons, remove units
    81         set nv [Rappture::Units::convert $value -units off]
     82        set nv [Rappture::Units::convert $value -context $units -units off]
    8283        # get the units for the value
    8384        set newunits [Rappture::Units::Search::for $value]
     
    8990        if {"" != $units} {
    9091            # compute the minimum in the new units
    91             set minv [Rappture::Units::convert $min -to $newunits -units off]
     92            set minv [Rappture::Units::convert $min -to $newunits -context $units  -units off]
    9293            # same, but include units for printing
    93             set convMinVal [Rappture::Units::convert $min -to $newunits]
     94            set convMinVal [Rappture::Units::convert $min -to $newunits -context $units]
    9495        } else {
    9596            set minv $min
     
    103104        if {"" != $units} {
    104105            # compute the maximum in the new units
    105             set maxv [Rappture::Units::convert $max -to $newunits -units off]
     106            set maxv [Rappture::Units::convert $max -to $newunits -context $units -units off]
    106107            # same, but include units for printing
    107             set convMaxVal [Rappture::Units::convert $max -to $newunits]
     108            set convMaxVal [Rappture::Units::convert $max -to $newunits -context $units ]
    108109        } else {
    109110            set maxv $max
  • branches/uq/lang/tcl/scripts/library.tcl

    r5029 r5102  
    215215    public method remove {{path ""}}
    216216    public method xml {{path ""}}
    217     public method uq_make_template {}
     217    public method uq_get_vars {{template 0}}
    218218
    219219    public method diff {libobj}
     
    10401040}
    10411041
    1042 
    1043 # FIXME: get units convert. change varlist to have no units
    1044 itcl::body Rappture::LibraryObj::uq_make_template {} {
     1042itcl::body Rappture::LibraryObj::uq_get_vars {{template 0}} {
    10451043    set varlist ""
    10461044    set n [$_node selectNodes /run/input//number]
     
    10561054                -context $units -to $units -units off]
    10571055            }
    1058             $x nodeValue @@[$_n getAttribute id]
     1056            if {$template != 0} {
     1057              $x nodeValue @@[$_n getAttribute id]
     1058            }
    10591059            lappend varlist [list [$_n getAttribute id] $val]
    10601060        }
  • branches/uq/lang/tcl/scripts/task.tcl

    r5030 r5102  
    1313#  Copyright (c) 2004-2014  HUBzero Foundation, LLC
    1414#
    15 #  See the file "license.terms" for information on usage and
    16 #  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
     15#  See the file "license.terms" for information on usage and#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
    1716# ======================================================================
    1817package require BLT
     
    2928
    3029    public method run {args}
     30    public method get_uq {args}
    3131    public method abort {}
    3232    public method reset {}
     
    115115    }
    116116    return ""
     117}
     118
     119itcl::body Rappture::Task::get_uq {args} {
     120    puts "Task::get_uq $args"
     121    foreach {path val} $args {
     122        if {$path == "-uq_type"} {
     123            set uq_type $val
     124        } elseif {$path == "-uq_args"} {
     125            set uq_args $val
     126        }
     127    }
     128    set varlist [$_xmlobj uq_get_vars]
     129    return [Rappture::UQ ::#auto $varlist $uq_type $uq_args]
    117130}
    118131
     
    160173        if {$path == "-output"} {
    161174            set _outputcb $val
     175        } elseif {$path == "-uq_type"} {
     176            set uq_type $val
     177        } elseif {$path == "-uq_args"} {
     178            set uq_args $val
    162179        } else {
    163180            $_xmlobj put $path.current $val
     
    193210    # This will turn the driver xml into a template
    194211    # and return a list of the UQ variables and their PDFs.
    195     set uq_varlist [$_xmlobj uq_make_template]
     212    set uq_varlist [$_xmlobj uq_get_vars 1]
    196213
    197214    if {$uq_varlist != ""} {
     
    241258        } else {
    242259            puts "uq_varlist=$uq_varlist"
    243             # FIXME. Default to Smolyak level 2, but allow more later.
    244260            file delete -force puq
    245             set params_file [get_params $file $uq_varlist "smolyak" 2]
     261            set params_file [get_params $file $uq_varlist $uq_type $uq_args]
    246262            set cmd "submit --runName=puq -l -d $params_file uq.py $cmd @:$tfile"
    247263        }
     
    391407        puts "result=$result"
    392408        if {$uq_varlist != ""} {
    393             file delete -force -- new.xml
     409            # UQ. Collect data from all jobs and put it in one xml run file.
     410            file delete -force -- run_uq.xml
    394411            exec puq_analyze.py puq_[pid].hdf5
    395             append result "\n" "=RAPPTURE-RUN=>new.xml"
     412            append result "\n" "=RAPPTURE-RUN=>run_uq.xml"
    396413        }
    397414        if {[regexp {=RAPPTURE-RUN=>([^\n]+)} $result match file]} {
     
    569586itcl::body Rappture::Task::get_params {dfile varlist uq_type args} {
    570587
     588    puts "tcl get_params $dfile $varlist uq_type=$uq_type args=$args"
    571589    # convert tcl list of variables to json so python can read it
    572590    proc varlist2py {inlist} {
     
    597615    }
    598616
    599     puts "varlist=$varlist"
    600617    set varlist [varlist2py $varlist]
    601618    set pid [pid]
  • branches/uq/lang/tcl/scripts/units.tcl

    r5029 r5102  
    7575
    7676proc Rappture::Units::_check_range {value min max units} {
     77    puts "_check_range $value min=$min max=$max units=$units"
    7778    # make sure the value has units
    7879    if {$units != ""} {
    7980        set value [Rappture::Units::convert $value -context $units]
    8081        # for comparisons, remove units
    81         set nv [Rappture::Units::convert $value -units off]
     82        set nv [Rappture::Units::convert $value -context $units -units off]
    8283        # get the units for the value
    8384        set newunits [Rappture::Units::Search::for $value]
     
    8990        if {"" != $units} {
    9091            # compute the minimum in the new units
    91             set minv [Rappture::Units::convert $min -to $newunits -units off]
     92            set minv [Rappture::Units::convert $min -to $newunits -context $units  -units off]
    9293            # same, but include units for printing
    93             set convMinVal [Rappture::Units::convert $min -to $newunits]
     94            set convMinVal [Rappture::Units::convert $min -to $newunits -context $units]
    9495        } else {
    9596            set minv $min
     
    103104        if {"" != $units} {
    104105            # compute the maximum in the new units
    105             set maxv [Rappture::Units::convert $max -to $newunits -units off]
     106            set maxv [Rappture::Units::convert $max -to $newunits -context $units -units off]
    106107            # same, but include units for printing
    107             set convMaxVal [Rappture::Units::convert $max -to $newunits]
     108            set convMaxVal [Rappture::Units::convert $max -to $newunits -context $units ]
    108109        } else {
    109110            set maxv $max
Note: See TracChangeset for help on using the changeset viewer.