Changeset 780


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

# on 2004/04/27 14:07:39, toby did:
plot (obs-calc)/sigma
Add ability to scan zoom region with arrow keys

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/liveplot

    • Property rcs:date changed from 2003/12/05 12:54:08 to 2004/04/27 14:07:39
    • Property rcs:lines changed from +8 -5 to +70 -9
    • Property rcs:rev changed from 1.38 to 1.39
    r758 r780  
    5252set yunits {}
    5353set graph(chi2) 0
     54set graph(OmCoS) 0
    5455set graph(xunits) 0
    5556set graph(yunits) 0
     
    5758set graph(color_diff) blue
    5859set graph(color_chi2) magenta
     60set graph(color_OmCoS) magenta
    5961set graph(color_bkg) green
    6062set graph(color_obs) black
     
    426428        wifdvec set [wifdvec / [wifdvec length]]
    427429    }
     430    if {$graph(OmCoS)} {
     431        wifdvec set $WGT
     432        wifdvec expr sqrt(wifdvec)
     433        wifdvec set [wifdvec * diffvec]
     434    }
    428435    if $graph(backsub) {
    429436        obsvec set [obsvec - bckvec]
     
    570577            -symbol $peakinfo(obssym) -color $graph(color_obs) \
    571578            -pixels [expr 0.125 * $peakinfo(obssize)]i
    572     $box element config 0 -color $graph(color_chi2)
     579    if $graph(chi2) {
     580        $box element config 0 -dash 0 -line 3 -color $graph(color_chi2)
     581    } else {
     582        $box element config 0 -dash 4 -line 2 -color $graph(color_OmCoS)
     583    }
    573584    $box element config 1 -color $graph(color_bkg)
    574585    $box element config 2 -color $graph(color_calc)
     
    700711    if {$color == ""} return
    701712    set peakinfo(color$num) $color
     713}
     714
     715proc setSymcolor {var lbl} {
     716    global graph
     717    set color [tk_chooseColor -initialcolor $graph(color_$var) \
     718            -title "Choose $lbl color"]
     719    if {$color == ""} return
     720    set graph(color_$var) $color
    702721}
    703722
     
    957976    }
    958977    puts $fp "# LIVEPLOT saved options from [clock format [clock seconds]]"
    959     foreach v {printout legend outname outcmd autoraise chi2 xunits yunits} {
     978    foreach v {printout legend outname outcmd autoraise chi2 xunits yunits OmCoS} {
    960979        puts $fp "set graph($v) [list $graph($v)]"
    961980    }
    962     foreach v {diff chi2 bkg calc obs input fit} {
     981    foreach v {diff chi2 bkg calc obs input fit OmCoS} {
    963982        puts $fp "set graph(color_$v) [list $graph(color_$v)]"
    964983    }
     
    10571076    global graph box
    10581077    if $graph(chi2) {
     1078        catch {$box y2axis config -min 0}
     1079        $box y2axis config -title {Cumulative Chi Squared}
    10591080        eval $box y2axis config $graph(ElementShowOption)
    10601081        eval $box element config 0 $graph(ElementShowOption) -label "Chi2"
     1082        #$box elem conf 0 -dash 0 -line 3
     1083        set cycle [getcycle]
     1084        readdata .g
     1085    } elseif $graph(OmCoS) {
     1086        catch {$box y2axis config -min ""}
     1087        $box y2axis config -title {(obs-calc)/sigma}
     1088        eval $box y2axis config $graph(ElementShowOption)
     1089        eval $box element config 0 $graph(ElementShowOption) -label "(O-C)/s"
     1090        #$box elem conf 0 -dash 4 -line 2
    10611091        set cycle [getcycle]
    10621092        readdata .g
     
    10671097    }
    10681098}
     1099
    10691100# evaluate the Chebyshev polynomial with coefficients A at point x
    10701101# coordinates are rescaled from $xmin=-1 to $xmax=1
     
    18831914            "x=[format %.3f [$graph(blt) xaxis invtransform $x]] y=[format %.3f [$graph(blt) yaxis invtransform $y]]"
    18841915}
     1916
    18851917#-------------------------------------------------------------------------
    18861918# override options with locally defined values
     
    20732105.a.options.menu add cascade -label "Symbol color" -menu .a.options.menu.color
    20742106menu .a.options.menu.color
    2075 set l1 {obs calc diff bkg chi2}
    2076 set l2 {Observed Calculated Obs-Calc Background Cumulative-Chi2}
     2107set l1 {obs calc diff bkg chi2 OmCoS}
     2108set l2 {Observed Calculated Obs-Calc Background Cumulative-Chi2 (obs-calc)/sig}
    20772109if {$program != "liveplot"} {
    20782110    lappend l1 input fit
     
    20822114foreach var $l1 lbl $l2 {
    20832115    .a.options.menu.color add command -label $lbl \
    2084         -command "set graph(color_$var) \[tk_chooseColor -initialcolor \$graph(color_$var) -title \"Choose \$lbl color\"]; plotdata"
     2116        -command "setSymcolor $var $lbl; plotdata"
    20852117}
    20862118if {$expgui(tcldump) != "" && $program == "liveplot"} {
     
    21312163            -variable graph(autoraise)
    21322164    .a.options.menu add checkbutton -label "Cumulative Chi2" \
    2133             -variable graph(chi2) -command ShowCumulativeChi2
     2165            -variable graph(chi2) \
     2166            -command "set graph(OmCoS) 0; ShowCumulativeChi2"
     2167    .a.options.menu add checkbutton -label "(Obs-Calc)/sig" \
     2168            -variable graph(OmCoS) \
     2169            -command "set graph(chi2) 0; ShowCumulativeChi2"
    21342170    .a.options.menu add command -label "Save Options" -underline 1 \
    21352171            -command "SaveOptions"
     
    23572393bind . <Key-l> {ToggleLiveCursor}
    23582394bind . <Key-L> {ToggleLiveCursor}
     2395# move the zoom region around
     2396proc ScanZoom {box key frac} {
     2397    foreach var  {xl xh yl yh} axis {xaxis  xaxis  yaxis  yaxis} \
     2398            flg  {-min -max -min -max} {
     2399        set $var [$box $axis cget $flg]
     2400        if {$var == ""} return
     2401    }
     2402    catch {
     2403        switch -- $key {
     2404            Right {set a x; set l $xl; set h $xh; set d [expr {$frac*($h-$l)}]}
     2405            Left {set a x; set l $xl; set h $xh; set d [expr {-$frac*($h-$l)}]}
     2406            Up   {set a y; set l $yl; set h $yh; set d [expr {$frac*($h-$l)}]}
     2407            Down {set a y; set l $yl; set h $yh; set d [expr {-$frac*($h-$l)}]}
     2408        }
     2409        $box ${a}axis configure -min [expr {$l + $d}] -max [expr {$h + $d}]
     2410    }
     2411}
     2412bind . <Key-Up> "ScanZoom $box %K .1"
     2413bind . <Key-Left> "ScanZoom $box %K .1"
     2414bind . <Key-Right> "ScanZoom $box %K .1"
     2415bind . <Key-Down> "ScanZoom $box %K .1"
     2416bind . <Control-Key-Up> "ScanZoom $box %K 1.0"
     2417bind . <Control-Key-Left> "ScanZoom $box %K 1.0"
     2418bind . <Control-Key-Right> "ScanZoom $box %K 1.0"
     2419bind . <Control-Key-Down> "ScanZoom $box %K 1.0"
    23592420# seems to be needed in OSX
    23602421update
Note: See TracChangeset for help on using the changeset viewer.