Changeset 45 for trunk/liveplot
- Timestamp:
- Dec 4, 2009 4:59:28 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/liveplot
- Property rcs:date changed from 1998/11/23 20:35:13 to 1999/01/21 22:44:12
- Property rcs:rev changed from 1.1 to 1.2
- Property rcs:lines set to +112 -73
r9 r45 6 6 set expnam [lindex $argv 0] 7 7 if {$expnam == ""} {puts "error -- no experiment name"; set exitstat 1} 8 set gsasexe [lindex $argv 1]9 if {$gsasexe == ""} {puts "error -- no gsas directory"; set exitstat 1}10 8 if $exitstat { 11 puts "usage: $argv0 expnam gsasexedir\[hist #\] \[legend\]"9 puts "usage: $argv0 expnam \[hist #\] \[legend\]" 12 10 destroy . 13 11 } 14 if {[lindex $argv 2] == ""} { 15 puts "warning -- no histogram number assuming 1" 12 if {[lindex $argv 1] == ""} { 16 13 set hst 1 17 14 } else { 18 set hst [lindex $argv 2]19 } 20 if {[lindex $argv 3] == ""} {21 set legend115 set hst [lindex $argv 1] 16 } 17 if {[lindex $argv 2] == ""} { 18 set graph(legend) 1 22 19 } else { 23 set legend [lindex $argv 3] 24 } 20 set graph(legend) [lindex $argv 2] 21 } 22 23 24 if {$tcl_platform(platform) == "windows"} { 25 set graph(printout) 1 26 } else { 27 set graph(printout) 0 28 } 29 30 # default values 31 set graph(outname) out.ps 32 set graph(outcmd) lpr 33 25 34 if [catch {package require BLT} errmsg] { 26 35 tk_dialog .err "BLT Error" "Error -- Unable to load the BLT package" \ … … 72 81 waitmsg "Loading histogram, Please wait" 73 82 83 #-------------------------------------------------------------- 84 # define constants 85 array set peakinfo { 86 color1 magenta 87 color2 cyan 88 color3 yellow 89 color4 sienna 90 color5 orange 91 color6 DarkViolet 92 color7 HotPink 93 color8 salmon 94 color9 LimeGreen 95 } 96 set cycle -1 97 set modtime 0 98 99 #---------------------------------------------------------------- 74 100 # where are we? 75 set scriptname[info script]101 set expgui(script) [info script] 76 102 # translate links -- go six levels deep 77 103 foreach i {1 2 3 4 5 6} { 78 if {[file type $ scriptname] == "link"} {79 set link [file readlink $ scriptname]104 if {[file type $expgui(script)] == "link"} { 105 set link [file readlink $expgui(script)] 80 106 if { [file pathtype $link] == "absolute" } { 81 set scriptname$link107 h set expgui(script) $link 82 108 } { 83 set scriptname [file dirname $scriptname]/$link109 set expgui(script) [file dirname $expgui(script)]/$link 84 110 } 85 111 } else { … … 87 113 } 88 114 } 89 set scriptdir [file dirname $scriptname] 115 116 # fixup relative paths 117 if {[file pathtype $expgui(script)] == "relative"} { 118 set expgui(script) [file join [pwd] $expgui(script)] 119 } 120 set expgui(scriptdir) [file dirname $expgui(script) ] 121 set expgui(gsasdir) [file dirname $expgui(scriptdir)] 122 set expgui(gsasexe) [file join $expgui(gsasdir) exe] 123 124 # fetch EXP file processing routines 125 source [file join $expgui(scriptdir) readexp.tcl] 126 127 # override options with locally defined values 128 if [file exists [file join $expgui(scriptdir) localconfig]] { 129 source [file join $expgui(scriptdir) localconfig] 130 } 131 if [file exists [file join ~ .gsas_config]] { 132 source [file join ~ .gsas_config] 133 } 90 134 91 135 proc readdata {box} { 92 global gsasexeexpnam reflns136 global expgui expnam reflns 93 137 global lasthst 94 global hst legendpeakinfo units138 global hst peakinfo units 95 139 $box config -title "(Histogram update in progress)" 96 140 update … … 102 146 # puts $input "$hst" 103 147 # close $input 104 # set input [open "| $ gsasexe/hstdump $expnam < histdump.inp" w+]148 # set input [open "| $expgui(gsasexe)/hstdump $expnam < histdump.inp" w+] 105 149 ########################################################################### 106 150 # use histdump for right now 107 set input [open histdump .inp w]151 set input [open histdump$hst.inp w] 108 152 puts $input "$expnam" 109 153 puts $input "L" … … 113 157 # use hstdmp without an experiment name so that output 114 158 # is not sent to the .LST file 115 set input [open "| $ gsasexe/hstdmp < histdump.inp" r]159 set input [open "| $expgui(gsasexe)/hstdmp < histdump$hst.inp" r] 116 160 117 161 # initalize arrays … … 159 203 if {$units == "Theta"} {set units "2-Theta"} 160 204 close $input 161 file delete histdump .inp205 file delete histdump$hst.inp 162 206 xvec set $xlist 163 207 obsvec set $obslist … … 183 227 184 228 proc plotdata {box} { 185 global expnam hst legend peakinfo units cycle reflns229 global expnam hst peakinfo units cycle reflns modtime 186 230 global lasthst graph 187 231 … … 191 235 xvec notify now 192 236 set cycle -1 237 set modtime 0 193 238 $box config -title "Please wait: loading histogram $hst" 194 239 update … … 202 247 $box config -title "$expnam cycle $cycle Hist $hst" 203 248 $box xaxis config -title $units 204 setlegend $box $ legend249 setlegend $box $graph(legend) 205 250 # now deal with peaks 206 251 set j 0 … … 372 417 } 373 418 419 # save some of the global options in ~/.gsas_config 420 proc SaveOptions {} { 421 global graph 422 set fp [open [file join ~ .gsas_config] a] 423 puts $fp "set graph(legend) $graph(legend)" 424 puts $fp "set graph(printout) $graph(printout)" 425 puts $fp "set graph(outname) $graph(outname)" 426 puts $fp "set graph(outcmd) $graph(outcmd)" 427 close $fp 428 } 429 374 430 proc aboutliveplot {} { 375 431 global Revision … … 382 438 } 383 439 384 if {$tcl_platform(platform) == "windows"} {385 set graph(printout) 1386 } else {387 set graph(printout) 0388 }389 set graph(outname) out.ps390 set graph(outcmd) lpr391 392 440 proc getcycle {} { 393 global expnam gsasexe tcl_platform441 global expnam 394 442 set cycle -1 395 443 catch { 396 # windows-specific code 397 if {$tcl_platform(platform) == "windows"} { 398 set fp [open $expnam.EXP r] 399 set line [read $fp] 400 close $fp 401 } else { 402 set line [exec $gsasexe/convdtos < $expnam.EXP ] 403 } 404 regexp {GNLS RUN.*Total cycles run *([0-9]*) } $line x cycle 444 set fp [open $expnam.EXP r] 445 set text [read $fp] 446 close $fp 447 regexp {GNLS RUN.*Total cycles run *([0-9]*) } $text x cycle 405 448 } 406 449 return $cycle … … 408 451 409 452 proc updateifnew {} { 410 global cycle 411 set newcycle [getcycle] 412 if {$newcycle != $cycle} { 413 set cycle $newcycle 414 # delay one second 415 after 1000 416 readdata .g 417 } 418 # check every ten seconds 419 after 10000 updateifnew 420 } 421 422 # define constants 423 array set peakinfo { 424 color1 magenta 425 color2 cyan 426 color3 yellow 427 color4 sienna 428 color5 orange 429 color6 DarkViolet 430 color7 HotPink 431 color8 salmon 432 color9 LimeGreen 433 } 453 global cycle modtime expnam 454 if {[file mtime $expnam.EXP] != $modtime} { 455 set modtime [file mtime $expnam.EXP] 456 set newcycle [getcycle] 457 if {$newcycle != $cycle} { 458 set cycle $newcycle 459 # delay one second 460 # after 1000 461 readdata .g 462 } 463 } 464 # check every second 465 # after 10000 updateifnew 466 after 1000 updateifnew 467 } 468 434 469 # vectors 435 470 vector xvec … … 448 483 $box element create obs -color black -symbol scross -linewidth 0 449 484 $box element create calc -color red -symbol none 450 $box element create bckg -color green -symbol none485 #$box element create bckg -color green -symbol none 451 486 $box element create diff -color blue -symbol none 452 487 $box element config obs -xdata xvec -ydata obsvec 453 488 $box element config calc -xdata xvec -ydata calcvec 454 $box element config bckg -xdata xvec -ydata bckvec489 #$box element config bckg -xdata xvec -ydata bckvec 455 490 $box element config diff -xdata xvec -ydata diffvec 456 491 $box yaxis config -title {} 457 setlegend $box $ legend492 setlegend $box $graph(legend) 458 493 # create a set of markers for each phase 459 494 for {set i 1} {$i < 10} {incr i} { … … 464 499 } 465 500 466 global cycle467 set cycle -1468 501 updateifnew 469 502 frame .a -bd 3 -relief groove … … 497 530 -command "minioptionsbox $num" 498 531 } 499 .a.options.menu add checkbutton -label "Include legend" -variable legend \ 500 -command {setlegend $box $legend} 532 .a.options.menu add checkbutton -label "Include legend" \ 533 -variable graph(legend) \ 534 -command {setlegend $box $graph(legend)} 501 535 .a.options.menu add command -label "Set PS output" -command setpostscriptout 502 503 if [file exists $scriptdir/icddcmd.tcl] {source $scriptdir/icddcmd.tcl} 504 if [file exists $scriptdir/cellgen.tcl] {source $scriptdir/cellgen.tcl} 505 506 if [file exists ~/.liveplotrc] {source ~/.liveplotrc} 536 .a.options.menu add command -label "Save Options" -underline 1 \ 537 -command "SaveOptions" 538 539 # fetch EXP file processing routines 540 source [file join $expgui(scriptdir) readexp.tcl] 541 542 set fl [file join $expgui(scriptdir) icddcmd.tcl] 543 if [file exists $fl] {source $fl} 544 set fl [file join $expgui(scriptdir) cellgen.tcl] 545 if [file exists $fl] {source $fl} 507 546 508 547 pack [menubutton .a.help -text Help -underline 0 -menu .a.help.menu] -side right
Note: See TracChangeset
for help on using the changeset viewer.