Changeset 1181
- Timestamp:
- Nov 25, 2011 4:15:38 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/liveplot.html
r1166 r1181 51 51 Some of the features available in LIVEPLOT are: 52 52 <UL> 53 <LI><IMG SRC="new.gif" alt="New!"> 53 <LI><IMG SRC="new.gif" alt="New!"> 54 Plotting of Topas refinement results in LIVEPLOT: 55 Upon request, LIVEPLOT has been augmented to read in results from 56 Topas, as well as GENLES. 57 <a HREF="#Topas">See below for details.</a> 58 <LI><IMG SRC="new.gif" alt="New!"> 54 59 Regions of the plot can be magnified to show more detail, for example 55 60 in regions at high Q. … … 432 437 433 438 </UL> 439 <a name="Topas"></a> 440 <B>Plotting of Topas refinement results in LIVEPLOT</B> 441 Upon request, LIVEPLOT has been augmented to read in results from 442 Topas. Follow the procedure 443 <A 444 HREF="http://topas.dur.ac.uk/topaswiki/doku.php?id=outputting_publication_quality_plots_using_expgui">Publication 445 Quality Plots using Liveplot in EXPGUI</A> from the <A 446 HREF="http://topas.dur.ac.uk/topaswiki">Durham University Topas Wiki</A> to 447 generate an output file that LIVEPLOT can read. Then use the "Import 448 from Topas" menu item in the File menu to open a dialog window where 449 the file can be imported. It is optimal to use the extension 450 <tt>.ascii</tt> for the Topas export file. 451 <P> 452 Note that in normal use, LIVEPLOT is started from inside EXPGUI with 453 an open .EXP file. If LIVEPLOT will be used frequently for Topas, it 454 may be useful to create a shortcut to start LIVEPLOT directly. This 455 can be done in Windows by following these 456 <A 457 HREF="https://subversion.xor.aps.anl.gov/trac/EXPGUI/wiki/InstallWindows#shortcut">instructions 458 to make a short cut</A>, but reference file <tt>.../expgui/liveplot</tt> 459 rather than file <tt>.../expgui/expgui</tt>. Similar things can be 460 done in Linux and on the Mac. 434 461 435 462 <hr><h2>LIVEPLOT/BKGEDIT Keyboard Shortcuts</h2> -
trunk/liveplot
r1166 r1181 15 15 set exitstat 0 16 16 set expnam [file root [lindex $argv 0]] 17 if {$expnam == ""} {catch {puts "error -- no experiment name"}; set exitstat 1}17 #if {$expnam == ""} {catch {puts "error -- no experiment name"}; set exitstat 1} 18 18 if $exitstat { 19 19 catch {puts "usage: $argv0 expnam \[hist #\] \[legend\]"} … … 107 107 } 108 108 set expgui(RadiiList) {} 109 set ::expmap(phaselist) {} 109 110 110 111 proc waitmsg {message} { … … 252 253 global expgui modtime expnam 253 254 if [catch { 254 set modtime [file mtime $expnam.EXP]255 255 set loadtime [time { 256 if {$expgui(tcldump) == ""} { 256 set modtime 0 257 if {$::topasfile != ""} { 258 set p "TOPAS import" 259 readdata_topas $box 260 } elseif {$expgui(tcldump) == ""} { 261 set modtime [file mtime $expnam.EXP] 257 262 set p HSTDMP 258 263 readdata_hst $box 259 264 } else { 265 set modtime [file mtime $expnam.EXP] 260 266 set p TCLDUMP 261 267 readdata_tcl $box … … 357 363 calcvec set $calclist 358 364 bckvec set $bcklist 359 diffvec set [obsvec - calcvec]360 foreach vec {obsvec calcvec diffvec} {365 #diffvec set [obsvec - calcvec] 366 foreach vec {obsvec calcvec} { 361 367 # probably not needed with recent versions of BLT: 362 368 global $vec … … 450 456 } 451 457 458 set ::topasfile "" 459 proc get_topas_file {} { 460 set ::topasfile [tk_getOpenFile -title "Select Topas File" -parent . \ 461 -defaultextension .ascii \ 462 -filetypes { 463 {"Topas ascii export" ".ascii"} 464 {"all files" "*"} 465 }] 466 if {$::topasfile == ""} return 467 if {[catch {set input [open $::topasfile r]} errmsg]} { 468 MyMessageBox -parent . -title "Open Error" \ 469 -message "An error occured trying to open file $::topasfile: $errmsg" \ 470 -icon error -type Ignore -default ignore 471 set ::topasfile "" 472 return 473 } 474 close $input 475 readdata .g 476 } 477 478 proc readdata_topas {box} { 479 global expgui expnam reflns graph 480 global lasthst 481 global hst peakinfo xunits weightlist 482 #set file "liveplot_output.ascii" 483 if {$::topasfile == ""} return 484 if {[catch {set input [open $::topasfile r]} errmsg]} { 485 MyMessageBox -parent . -title "Open Error" \ 486 -message "An error occured trying to open file $::topasfile: $errmsg" \ 487 -icon error -type Ignore -default ignore 488 return 489 } 490 491 $box config -title "(TOPAS import in progress)" 492 update 493 # parse the output of a file 494 set lasthst $hst 495 # initalize arrays 496 set num -1 497 set xlist {} 498 set obslist {} 499 set calclist {} 500 set bcklist {} 501 set xunits {} 502 set weightlist {} 503 global refhkllist refphaselist refpos 504 set refhkllist {} 505 set refphaselist {} 506 set refpos {} 507 # define a list of reflection positions for each phase 508 for {set i 1} {$i < 10} {incr i} { 509 set reflns($i) {} 510 } 511 set i 0 512 while {[gets $input line] >= 0} { 513 incr i 514 if {[string first ":" $line] != -1} continue 515 # run update every 50th line 516 if {$i > 50} {set i 0; update} 517 if {[llength $line] == 5} { 518 scan $line %e%e%e%e%e X d Iobs Icalc Isig 519 if {$Isig > 0} { 520 if {$graph(xunits) == 0} { 521 lappend xlist $X 522 } elseif {$graph(xunits) == 1} { 523 lappend xlist $d 524 } else { 525 lappend xlist [expr {6.283185307179586 / $d}] 526 } 527 lappend obslist $Iobs 528 lappend calclist $Icalc 529 #lappend bcklist 0 530 lappend weightlist [expr {1./($Isig * $Isig)}] 531 } 532 } elseif {[llength $line] == 7} { 533 scan $line %e%e%e%e%e%e%d h k l m d tt ph 534 if {$graph(xunits) == 0} { 535 set x $tt 536 } elseif {$graph(xunits) == 1} { 537 set x $d 538 } else { 539 set x [expr {6.283185307179586 / $d}] 540 } 541 set ph [expr {int($ph)}] 542 lappend reflns($ph) $x 543 lappend refhkllist "$h,$k,$l" 544 lappend refphaselist $ph 545 lappend refpos $x 546 } elseif {[llength $line] == 3} { 547 scan $line %e%e%e x d b 548 lappend bcklist $b 549 } else { 550 puts "unexpected input: $line" 551 } 552 } 553 close $input 554 555 if {$graph(xunits) == 0} { 556 set xunits "2-Theta" 557 } elseif {$graph(xunits) == 1} { 558 set xunits "d" 559 } else { 560 set xunits "Q" 561 } 562 foreach elem [$box element names] { 563 eval $box element config $elem $graph(ElementShowOption) 564 } 565 xvec set $xlist 566 obsvec set $obslist 567 calcvec set $calclist 568 bckvec set $bcklist 569 #diffvec set [obsvec - calcvec] 570 refposvec set $refpos 571 set ::expmap(phaselist) [lsort -unique $refphaselist] 572 RegisterPhases $::expmap(phaselist) 573 if {$expgui(autotick)} { 574 foreach i $::expmap(phaselist) { 575 set peakinfo(flag$i) 1 576 } 577 } 578 #wifdvec length 0 579 # if {$graph(chi2)} { 580 # wifdvec set $WGT 581 # wifdvec set [wifdvec * diffvec] 582 # wifdvec set [wifdvec * diffvec] 583 # # now do a running sum 584 # set sum 0 585 # set sumlist {} 586 # foreach n [wifdvec range 0 end] { 587 # set sum [expr {$sum + $n}] 588 # lappend sumlist $sum 589 # } 590 # wifdvec set $sumlist 591 # wifdvec set [wifdvec / [wifdvec length]] 592 # } elseif {$graph(OmCoS)} { 593 # wifdvec set $WGT 594 # wifdvec expr sqrt(wifdvec) 595 # wifdvec set [wifdvec * diffvec] 596 # } 597 if $graph(backsub) { 598 obsvec set [obsvec - bckvec] 599 calcvec set [calcvec - bckvec] 600 } 601 foreach vec {obsvec calcvec} { 602 # probably not needed with recent versions of BLT: 603 global $vec 604 # sometimes needed for latest version of BLT (2.4z) 605 catch {$vec variable $vec} 606 } 607 ApplyMag 608 plotdata 609 } 610 452 611 proc SetTitle {} { 453 612 set bx .title … … 572 731 global expnam hst peakinfo xunits yunits cycle reflns modtime 573 732 global lasthst graph expgui box 574 global obsvec calcvec diffvec 575 576 if {$graph(yunits) == 2} { 733 global obsvec calcvec diffvec bckvec 734 735 if {$graph(yunits) == 0} { 736 diffvec set [obsvec - calcvec] 737 $box element config 1 -label bckgr -line 1 -hide 0 738 $box element config 4 -label diff -line 1 -hide 0 739 } elseif {$graph(yunits) == 1} { 740 diffvec set [obsvec - calcvec] 741 $box element config 1 -label bckgr -line 1 -hide 0 742 $box element config 4 -label diff -line 1 -hide 0 743 } elseif {$graph(yunits) == 2} { 577 744 set yunits {Intensity/sigma(I)} 578 745 wifdvec set $::weightlist … … 584 751 wifdvec set {} 585 752 $box element config 1 -label {} -line 0 -hide 1 753 $box element config 4 -label diff -line 1 -hide 0 754 } elseif {$graph(yunits) == 3} { 755 bckvec expr 0*bckvec 756 set msg {} 757 if {[set calcvec(min)] <= 0} { 758 if {$msg != ""} {append msg ", "} 759 append msg "calculated" 760 } 761 if {[set obsvec(min)] <= 0} { 762 if {$msg != ""} {append msg " & "} 763 append msg "observed" 764 } 765 if {$msg != ""} { 766 MyMessageBox -parent . -title "Invalid Range" \ 767 -message "Log computation impossible due to zero or negative $msg intensity values" \ 768 -icon warning -type Continue -default continue 769 } else { 770 set yunits {log(Intensity)} 771 obsvec expr log10(obsvec) 772 calcvec expr log10(calcvec) 773 if {[set bckvec(min)] <= 0} { 774 bckvec set {} 775 $box element config 1 -label {} -line 0 -hide 1 776 } else { 777 bckvec expr log10(bckvec) 778 $box element config 1 -label bckgr -line 1 -hide 0 779 } 780 diffvec set {} 781 $box element config 4 -label {} -line 0 -hide 1 782 } 586 783 } else { 587 784 $box element config 1 -label bckgr -line 1 -hide 0 785 $box element config 4 -label diff -line 1 -hide 0 588 786 } 589 787 … … 691 889 } 692 890 } 693 # offset the difference pattern 694 set maxdiff [set diffvec(max)] 695 if {$expgui(autotick)} { 696 diffvec set [diffvec + [expr {$cmin - $maxdiff}]] 697 } else { 698 diffvec set [diffvec + [expr {$cmin - 1.1*$maxdiff}]] 699 } 700 diffvec notify now 701 891 catch { 892 # offset the difference pattern 893 set maxdiff [set diffvec(max)] 894 if {$expgui(autotick)} { 895 diffvec set [diffvec + [expr {$cmin - $maxdiff}]] 896 } else { 897 diffvec set [diffvec + [expr {$cmin - 1.1*$maxdiff}]] 898 } 899 diffvec notify now 900 } 702 901 # force an update of the plot as BLT may not 703 902 $box config -title [$box cget -title] … … 2156 2355 .a.file.menu.export add command -label "to PDF" -command ExportPDF 2157 2356 } 2357 2358 .a.file.menu add command -label "Import from Topas" \ 2359 -command {get_topas_file} 2158 2360 2159 2361 .a.file.menu add command -label Quit -command "destroy ." … … 2366 2568 .g marker create line -coords "$xl -Inf $xl Inf" -name mag[incr i] 2367 2569 .g marker create text -coords "$xl Inf" -name mag[incr i] -text "x$ym" -anchor w 2368 foreach vec {obsvec calcvec bckvec diffvec} {2570 foreach vec {obsvec calcvec bckvec} { 2369 2571 global $vec 2370 2572 $vec expr {$vec * ymult} … … 2522 2724 .a.options.menu.yunits add radiobutton -label "I/Sigma(I)" \ 2523 2725 -variable graph(yunits) -value 2 \ 2726 -command {set cycle [getcycle];readdata .g} 2727 .a.options.menu.yunits add radiobutton -label "log(I)" \ 2728 -variable graph(yunits) -value 3 \ 2524 2729 -command {set cycle [getcycle];readdata .g} 2525 2730 .a.options.menu add command -label "HKL labeling" -command setlblopts … … 2712 2917 } 2713 2918 2714 expload $expnam.EXP 2715 mapexp 2716 if {$expgui(autotick)} { 2717 foreach i $::expmap(phaselist) { 2718 set peakinfo(flag$i) 1 2719 } 2720 } 2721 2919 if {$expnam != ""} { 2920 expload $expnam.EXP 2921 mapexp 2922 if {$expgui(autotick)} { 2923 foreach i $::expmap(phaselist) { 2924 set peakinfo(flag$i) 1 2925 } 2926 } 2927 } else { 2928 mapexp 2929 } 2930 2722 2931 # fill the histogram menu 2723 2932 if {[llength $expmap(powderlist)] > 15} { … … 2770 2979 } 2771 2980 2772 foreach num $expmap(phaselist) { 2773 .a.file.menu.tick add checkbutton -label "Phase $num" \ 2981 proc RegisterPhases {phaselist } { 2982 foreach num $phaselist { 2983 .a.file.menu.tick add checkbutton -label "Phase $num" \ 2774 2984 -variable peakinfo(flag$num) \ 2775 2985 -command plotdata 2776 if {$program != "bkgedit"} {2777 2778 }2779 .a.options.menu.tick add command -label "Phase $num opts" \2986 if {$::program != "bkgedit"} { 2987 bind . <Key-$num> ".a.file.menu.tick invoke [.a.file.menu.tick index end]" 2988 } 2989 .a.options.menu.tick add command -label "Phase $num opts" \ 2780 2990 -command "minioptionsbox $num" 2781 } 2991 } 2992 } 2993 RegisterPhases $expmap(phaselist) 2782 2994 2783 2995 # N = load next histogram
Note: See TracChangeset
for help on using the changeset viewer.