Changeset 391 for trunk/liveplot


Ignore:
Timestamp:
Dec 4, 2009 5:05:23 PM (11 years ago)
Author:
toby
Message:

# on 2001/05/11 18:32:34, toby did:
Add support for WIF David's Cumulative Chi2 function
Link to web page
put Cumulative Chi
2 & background on top

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/liveplot

    • Property rcs:date changed from 2000/12/22 19:44:07 to 2001/05/11 18:32:34
    • Property rcs:lines changed from +30 -12 to +58 -24
    • Property rcs:rev changed from 1.14 to 1.15
    r362 r391  
    3838set xunits {}
    3939set yunits {}
     40set graph(chi2) 0
    4041set graph(xunits) 0
    4142set graph(yunits) 0
     
    157158set expgui(gsasdir) [file dirname $expgui(scriptdir)]
    158159set expgui(gsasexe) [file join $expgui(gsasdir) exe]
     160set expgui(docdir) [file join $expgui(scriptdir) doc]
    159161
    160162# called by a trace on expgui(lblfontsize)
     
    198200        update
    199201    }
     202    $box element show [lsort -decreasing [$box element show]]
    200203}
    201204   
     
    315318    set CALC {}
    316319    set BKG {}
     320    set WGT {}
    317321    global refhkllist refphaselist refpos
    318322    set refpos {}
     
    340344    refposvec set $refpos
    341345    diffvec set [obsvec - calcvec]
     346    if {$graph(chi2)} {
     347        wifdvec set $WGT
     348        wifdvec set [wifdvec * diffvec]
     349        wifdvec set [wifdvec * diffvec]
     350        # now do a running sum
     351        set sum 0
     352        set sumlist {}
     353        foreach n [wifdvec range 0 end] {
     354            set sum [expr $sum + $n]
     355            lappend sumlist $sum
     356        }
     357        wifdvec set $sumlist
     358        wifdvec set [wifdvec / [wifdvec length]]
     359    }
    342360    if $graph(backsub) {
    343361        obsvec set [obsvec - bckvec]
     
    457475    bckvec notify now
    458476    diffvec notify now
     477    wifdvec notify now
    459478    $box config -title "$expnam cycle $cycle Hist $hst"
    460479    $box xaxis config -title $xunits
     
    462481    setlegend $box $graph(legend)
    463482    # reconfigure the obs data
    464     $box element configure obs \
     483    $box element configure 3 \
    465484            -symbol $peakinfo(obssym) \
    466485            -pixels [expr 0.125 * $peakinfo(obssize)]i
     
    492511                }
    493512            }
    494             # $box element config phase$i -mapped  1
    495513            catch {$box element create phase$i}
    496514            catch {
     
    717735    set fp [open [file join ~ .gsas_config] a]
    718736    puts $fp "set graph(legend) $graph(legend)"
     737    puts $fp "set graph(chi2) $graph(chi2)"
    719738    puts $fp "set graph(printout) $graph(printout)"
    720739    puts $fp "set graph(outname) $graph(outname)"
     
    811830    donewaitmsg
    812831}
     832proc ShowCumulativeChi2 {} {
     833    global graph box
     834    if $graph(chi2) {
     835        eval $box y2axis config $graph(ElementShowOption)
     836        eval $box element config 0 $graph(ElementShowOption) -label "Chi2"
     837        set cycle [getcycle]
     838        readdata .g
     839    } else {
     840        eval $box element config 0 $graph(ElementHideOption)
     841        eval $box y2axis config $graph(ElementHideOption)
     842        $box element config 0 -label ""
     843    }
     844}
     845
     846source [file join $expgui(scriptdir) gsascmds.tcl]
    813847
    814848# override options with locally defined values
     
    829863
    830864# vectors
    831 vector xvec
    832 xvec notify never
    833 vector obsvec
    834 obsvec notify never
    835 vector calcvec
    836 calcvec notify never
    837 vector bckvec
    838 bckvec notify never
    839 vector diffvec
    840 diffvec notify never
    841 vector refposvec
    842 refposvec notify never
     865foreach vec {xvec obsvec calcvec bckvec diffvec refposvec wifdvec} {
     866    vector $vec
     867    $vec notify never
     868}
    843869# create the graph
    844870if [catch {
     
    861887            error 0 "Limp ahead"
    862888}
    863 $box element create obs -color black -linewidth 0 \
     889$box element create 0 -xdata xvec -ydata wifdvec -color magenta \
     890        -line 3 -symbol none -label "Chi2" -mapy y2
     891$box element create 3 -color black -linewidth 0 -label Obs \
    864892        -symbol $peakinfo(obssym) \
    865893        -pixels [expr 0.125 * $peakinfo(obssize)]i
    866 $box element create calc -color red  -symbol none 
    867 $box element create diff -color blue  -symbol none 
    868 $box element config obs -xdata xvec -ydata obsvec
    869 $box element config calc -xdata xvec -ydata calcvec
    870 $box element config diff -xdata xvec -ydata diffvec
     894$box element create 2 -label Calc -color red  -symbol none 
     895$box element create 4 -label diff -color blue  -symbol none 
     896$box element config 3 -xdata xvec -ydata obsvec
     897$box element config 2 -xdata xvec -ydata calcvec
     898$box element config 4 -xdata xvec -ydata diffvec
    871899if {$expgui(tcldump) != ""} {
    872     $box element create bckg -color green  -symbol none 
    873     $box element config bckg -xdata xvec -ydata bckvec
     900    $box element create 1 -label bckgr -color green  -symbol none 
     901    $box element config 1 -xdata xvec -ydata bckvec
    874902    bind . <Shift-Button-1> "lblhkl $box %x"
    875903    bind . <Key-h> "lblhkl $box %x"
     
    880908$box yaxis config -title {}
    881909setlegend $box $graph(legend)
     910ShowCumulativeChi2
    882911
    883912updateifnew
     
    956985.a.options.menu add checkbutton -label "Raise on update" \
    957986        -variable graph(autoraise)
     987.a.options.menu add checkbutton -label "Cumulative Chi2" \
     988        -variable graph(chi2) -command ShowCumulativeChi2
    958989.a.options.menu add command -label "Save Options" -underline 1 \
    959990        -command "SaveOptions"
     991$box y2axis config -min 0 -title {Cumulative Chi Squared}
     992ShowCumulativeChi2
    960993
    961994pack [menubutton .a.help -text Help -underline 0 -menu .a.help.menu] -side right
    962995menu .a.help.menu -tearoff 0
     996.a.help.menu add command -command "MakeWWWHelp liveplot.html" -label "Web page"
    963997.a.help.menu add command -command aboutliveplot -label About
    964998
Note: See TracChangeset for help on using the changeset viewer.