Changeset 79


Ignore:
Timestamp:
Dec 4, 2009 5:00:03 PM (13 years ago)
Author:
toby
Message:

# on 1999/04/08 20:33:23, toby did:
add tick autoscaling
deal with two word colors (Peach Puff)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/liveplot

    • Property rcs:date changed from 1999/04/06 22:27:03 to 1999/04/08 20:33:23
    • Property rcs:lines changed from +31 -16 to +137 -106
    • Property rcs:rev changed from 1.8 to 1.9
    r78 r79  
    4646set expgui(fadetime) 10
    4747set expgui(hklbox) 1
     48set expgui(autotick) 0
    4849set expgui(pixelregion) 5
    4950set peakinfo(obssym) scross
    5051set peakinfo(obssize) 1.0
     52# create a set of markers for each phase
     53for {set i 1} {$i < 10} {incr i} {
     54    set peakinfo(flag$i) 0
     55    set peakinfo(max$i) Inf
     56    set peakinfo(min$i) -Inf
     57    set peakinfo(dashes$i) 1
     58}
    5159
    5260if [catch {package require BLT} errmsg] {
     
    183191            error $errmsg
    184192        }
    185         $box config -title "Read error: $errmsg"
    186         puts "error message: $errmsg"
     193        $box config -title "Read error"
     194        tk_dialog .err "Read Error" "Read Error -- $errmsg" \
     195                error 0 OK
    187196        update
    188197    }
     
    196205    update
    197206    # parse the output of a file
    198         set lasthst $hst
     207    set lasthst $hst
    199208###########################################################################
    200209#       set input [open histdump.inp w]
     
    203212#       set input [open "| $expgui(gsasexe)/hstdump $expnam  < histdump.inp" w+]
    204213###########################################################################
    205         # use histdump for right now
    206         set input [open histdump$hst.inp w]
    207         puts $input "$expnam"
    208         puts $input "L"
    209         puts $input "$hst"
    210         puts $input "0"
    211         close $input
    212         # use hstdmp without an experiment name so that output
    213         # is not sent to the .LST file
    214         set input [open "| $expgui(gsasexe)/hstdmp < histdump$hst.inp" r]
    215        
    216         # initalize arrays
    217         set num -1
    218         set xlist {}
    219         set obslist {}
    220         set calclist {}
    221         set bcklist {}
    222         set xunits {}
    223         # define a list of reflection positions for each phase
    224         for {set i 1} {$i < 10} {incr i} {
    225             set reflns($i) {}
    226         }
    227         set i 0
    228         while {[gets $input line] >= 0} {
    229             incr i
    230             # run update every 50th line
    231             if {$i > 50} {set i 0; update}
    232             if [scan $line %d num] {
    233                 if {$num > 0} {
    234                     set Ispec 0
    235                     set X -999
    236                     scan [string range $line 8 end] %e%e%e%e%e%e \
    237                             X Iobs Icalc Ispec fixB fitB
    238                     #puts $line
    239                     # eliminate excluded points
    240                     if {$Ispec > 0.0 && $X >= 0} {
    241                         lappend xlist $X
    242                         lappend obslist $Iobs
    243                         lappend calclist $Icalc
    244                         lappend bcklist [expr $fixB + $fitB]
    245                     }
    246                     # add peaks to peak lists
    247                     #    puts "[string range $line 6 6]"
    248                     # is this 6 or 7; 6 on win & 7 on SGI
    249                     if [regexp {[1-9]} [string range $line 6 7] ph] {
    250                         lappend reflns($ph) $X
    251                     }
    252                 }
    253             } else {
    254                 regexp {Time|Theta|keV} $line xunits
    255             }
    256         }
    257         if {$xunits == "Theta"} {set xunits "2-Theta"}
    258         close $input
    259         catch {file delete histdump$hst.inp}
    260         xvec set $xlist
    261         obsvec set $obslist
    262         calcvec set $calclist
    263         bckvec set $bcklist
    264         diffvec set [obsvec - calcvec]
    265         global obsvec calcvec diffvec
    266         set maxdiff  [set diffvec(max)]
    267         set ymin1 [expr [set calcvec(min)] - 1.1*$maxdiff]
    268         set ymin2 [expr [set obsvec(min)] - 1.1*$maxdiff]
    269         if {$ymin1 < $ymin2} {
    270             diffvec set [diffvec + $ymin1]
    271         } {
    272             diffvec set [diffvec + $ymin2]
    273         }
    274         plotdata $box
     214    # use histdump for right now
     215    set input [open histdump$hst.inp w]
     216    puts $input "$expnam"
     217    puts $input "L"
     218    puts $input "$hst"
     219    puts $input "0"
     220    close $input
     221    # use hstdmp without an experiment name so that output
     222    # is not sent to the .LST file
     223    set input [open "| $expgui(gsasexe)/hstdmp < histdump$hst.inp" r]
     224   
     225    # initalize arrays
     226    set num -1
     227    set xlist {}
     228    set obslist {}
     229    set calclist {}
     230    set bcklist {}
     231    set xunits {}
     232    # define a list of reflection positions for each phase
     233    for {set i 1} {$i < 10} {incr i} {
     234        set reflns($i) {}
     235    }
     236    set i 0
     237    while {[gets $input line] >= 0} {
     238        incr i
     239        # run update every 50th line
     240        if {$i > 50} {set i 0; update}
     241        if [scan $line %d num] {
     242            if {$num > 0} {
     243                set Ispec 0
     244                set X -999
     245                scan [string range $line 8 end] %e%e%e%e%e%e \
     246                        X Iobs Icalc Ispec fixB fitB
     247                #puts $line
     248                # eliminate excluded points
     249                if {$Ispec > 0.0 && $X >= 0} {
     250                    lappend xlist $X
     251                    lappend obslist $Iobs
     252                    lappend calclist $Icalc
     253                    lappend bcklist [expr $fixB + $fitB]
     254                }
     255                # add peaks to peak lists
     256                #    puts "[string range $line 6 6]"
     257                # is this 6 or 7; 6 on win & 7 on SGI
     258                if [regexp {[1-9]} [string range $line 6 7] ph] {
     259                    lappend reflns($ph) $X
     260                }
     261            }
     262        } else {
     263            regexp {Time|Theta|keV} $line xunits
     264        }
     265    }
     266    if {$xunits == "Theta"} {set xunits "2-Theta"}
     267    close $input
     268    catch {file delete histdump$hst.inp}
     269    xvec set $xlist
     270    obsvec set $obslist
     271    calcvec set $calclist
     272    bckvec set $bcklist
     273    diffvec set [obsvec - calcvec]
     274    global obsvec calcvec diffvec
     275    set maxdiff  [set diffvec(max)]
     276    set cmin [set calcvec(min)]
     277    set omin [set obsvec(min)]
     278    set cmax [set calcvec(max)]
     279    set omax [set obsvec(max)]
     280    set expgui(min) [expr $omin < $cmin ? $omin : $cmin]
     281    set expgui(max) [expr $omax > $cmax ? $omax : $cmax]
     282    set ymin1 [expr $cmin - 1.1*$maxdiff]
     283    set ymin2 [expr $omin - 1.1*$maxdiff]
     284    if {$ymin1 < $ymin2} {
     285        diffvec set [diffvec + $ymin1]
     286    } {
     287        diffvec set [diffvec + $ymin2]
     288    }
     289    plotdata $box
    275290}
    276291
     
    329344    global obsvec calcvec diffvec
    330345    set maxdiff  [set diffvec(max)]
    331     set ymin1 [expr [set calcvec(min)] - 1.1*$maxdiff]
    332     set ymin2 [expr [set obsvec(min)] - 1.1*$maxdiff]
     346    set cmin [set calcvec(min)]
     347    set omin [set obsvec(min)]
     348    set cmax [set calcvec(max)]
     349    set omax [set obsvec(max)]
     350    set expgui(min) [expr $omin < $cmin ? $omin : $cmin]
     351    set expgui(max) [expr $omax > $cmax ? $omax : $cmax]
     352    set ymin1 [expr $cmin - 1.1*$maxdiff]
     353    set ymin2 [expr $omin - 1.1*$maxdiff]
    333354    if {$ymin1 < $ymin2} {
    334355        diffvec set [diffvec + $ymin1]
     
    336357        diffvec set [diffvec + $ymin2]
    337358    }
     359   
    338360    plotdata $box
    339361}
     
    416438proc plotdata {box} {
    417439    global expnam hst peakinfo xunits yunits cycle reflns modtime
    418     global lasthst graph
     440    global lasthst graph expgui
    419441
    420442    # is there a new histogram to load?
     
    443465    # now deal with peaks
    444466    for {set i 1} {$i < 10} {incr i} {
     467        if {$expgui(autotick)} {
     468            set div [expr ( $expgui(max) - $expgui(min) )/40.]
     469            set ymin [expr $expgui(min) - ($i+1) * $div]
     470            set ymax [expr $expgui(min) - $i * $div]
     471        } else {
     472            set ymin $peakinfo(min$i)
     473            set ymax $peakinfo(max$i)
     474        }
    445475        set j 0
    446476        if [set peakinfo(flag$i)] {
     
    451481                }
    452482                $box marker config peaks${i}_$j  -under 1 \
    453                         -coords "$X $peakinfo(min$i) $X $peakinfo(max$i)"
    454                 $box marker config peaks${i}_$j \
    455                         $graph(MarkerColorOpt) $peakinfo(color$i)
    456                 if $peakinfo(dashes$i) {
    457                     catch {
     483                        -coords "$X $ymin $X $ymax"
     484                catch {
     485                    $box marker config peaks${i}_$j \
     486                            $graph(MarkerColorOpt) [list $peakinfo(color$i)]
     487                    if $peakinfo(dashes$i) {
    458488                        $box marker config peaks${i}_$j -dashes "5 5"
    459489                    }
     
    493523
    494524proc minioptionsbox {num} {
    495     global blt_version tcl_platform peakinfo
     525    global blt_version tcl_platform peakinfo expgui
    496526    set bx .opt$num
    497527    catch {destroy $bx}
     
    509539                -variable peakinfo(dashes$i)] -side top
    510540    }
    511     pack [frame $bx.p$i -bd 2 -relief groove] -side top
    512     #   pack [checkbutton $bx.p$i.0 -text "Show phase $i reflns" \
    513             #           -variable peakinfo(flag$i)] -side left -anchor w
    514     pack [label $bx.p$i.1 -text "  Y min:"] -side left
    515     pack [entry $bx.p$i.2 -textvariable peakinfo(min$i) -width 5] \
    516             -side left
    517     pack [label $bx.p$i.3 -text "  Y max:"] -side left
    518     pack [entry $bx.p$i.4 -textvariable peakinfo(max$i) -width 5] \
    519             -side left
     541    if !$expgui(autotick) {
     542        pack [frame $bx.p$i -bd 2 -relief groove] -side top
     543        #       pack [checkbutton $bx.p$i.0 -text "Show phase $i reflns" \
     544                #               -variable peakinfo(flag$i)] -side left -anchor w
     545        pack [label $bx.p$i.1 -text "  Y min:"] -side left
     546        pack [entry $bx.p$i.2 -textvariable peakinfo(min$i) -width 5] \
     547                -side left
     548        pack [label $bx.p$i.3 -text "  Y max:"] -side left
     549        pack [entry $bx.p$i.4 -textvariable peakinfo(max$i) -width 5] \
     550                -side left
     551    }
    520552    pack [frame $bx.c$i -bd 2 -relief groove] -side top
    521553   
     
    680712# save some of the global options in ~/.gsas_config
    681713proc SaveOptions {} {
    682     global graph expgui
     714    global graph expgui peakinfo
    683715    set fp [open [file join ~ .gsas_config] a]
    684716    puts $fp "set graph(legend) $graph(legend)"
     
    692724    puts $fp "set peakinfo(obssize) $peakinfo(obssize)"
    693725    puts $fp "set expgui(pixelregion) $expgui(pixelregion)"
    694 
     726    puts $fp "set expgui(autotick) $expgui(autotick)"
    695727    close $fp
    696728}
     
    735767
    736768# fetch EXP file processing routines
    737 source [file join $expgui(scriptdir) readexp.tcl]
     769#source [file join $expgui(scriptdir) readexp.tcl]
    738770
    739771set fl [file join $expgui(scriptdir) icddcmd.tcl]
     
    791823$box yaxis config -title {}
    792824setlegend $box $graph(legend)
    793 # create a set of markers for each phase
    794 for {set i 1} {$i < 10} {incr i} {
    795     set peakinfo(flag$i) 0
    796     set peakinfo(max$i) Inf
    797     set peakinfo(min$i) -Inf
    798     set peakinfo(dashes$i) 1
    799 }
    800825
    801826updateifnew
     
    832857.a.options.menu add cascade -label "Configure Tickmarks" -menu .a.options.menu.tick
    833858menu .a.options.menu.tick
     859.a.options.menu.tick add radiobutton -label "Manual Placement" \
     860        -value 0 -variable expgui(autotick) -command "plotdata $box"
     861.a.options.menu.tick add radiobutton -label "Auto locate" \
     862        -value 1 -variable expgui(autotick) -command "plotdata $box"
     863.a.options.menu.tick add separator
    834864foreach num {1 2 3 4 5 6 7 8 9} {
    835865    .a.options.menu.tick add command -label "Phase $num" \
     
    882912    regexp {([a-z]*)([0-9]*)} $element junk var num
    883913    if {$var == "color"} {
    884         catch {
     914        if {$peakinfo($element) == ""} return
     915        if [catch {
    885916            .opt$num.c$num.2 config -bg $peakinfo($element)
    886         }
     917        } ] return
    887918        set i $num
    888919        set j 0
     
    890921            catch {
    891922                $box element config phase$i -color $peakinfo(color$i)
    892             } errmsg
     923            }
    893924            foreach X $reflns($i) {
    894925                incr j
    895926                catch {
    896927                    $box marker config peaks${i}_$j \
    897                             $graph(MarkerColorOpt) $peakinfo(color$i)
     928                            $graph(MarkerColorOpt) [list $peakinfo(color$i)]
    898929                }
    899930            }
Note: See TracChangeset for help on using the changeset viewer.