[851] | 1 | #!/bin/sh |
---|
| 2 | # the next line restarts this script using wish found in the path\ |
---|
| 3 | exec wish "$0" "$@" |
---|
| 4 | # If this does not work, change the #!/usr/bin/wish line below |
---|
| 5 | # to reflect the actual wish location and delete all preceeding lines |
---|
| 6 | # |
---|
| 7 | # (delete here and above) |
---|
| 8 | #!/usr/bin/wish |
---|
| 9 | # $Id: dumpexp.tcl 930 2009-12-04 23:14:35Z toby $ |
---|
| 10 | |
---|
| 11 | package require Tk |
---|
| 12 | |
---|
[459] | 13 | if {[llength $argv] != 1} { |
---|
| 14 | wm withdraw . |
---|
| 15 | tk_dialog .err {Wrong Args} \ |
---|
| 16 | "$argv0: argument should be a .EXP file name" \ |
---|
| 17 | error 0 Continue |
---|
| 18 | exit |
---|
| 19 | } |
---|
[675] | 20 | |
---|
| 21 | set filename [lindex $argv 0] |
---|
| 22 | |
---|
[459] | 23 | set expgui(font) 14 |
---|
| 24 | set expgui(debug) 0 |
---|
| 25 | |
---|
[675] | 26 | pack [label .l -text "Reading $filename\nPlease wait"] |
---|
[459] | 27 | update |
---|
| 28 | wm protocol . WM_DELETE_WINDOW {puts ""; exit} |
---|
| 29 | #============================================================================= |
---|
| 30 | #---------------------------------------------------------------- |
---|
| 31 | # where are we? |
---|
| 32 | set expgui(script) [info script] |
---|
| 33 | # translate links -- go six levels deep |
---|
| 34 | foreach i {1 2 3 4 5 6} { |
---|
| 35 | if {[file type $expgui(script)] == "link"} { |
---|
| 36 | set link [file readlink $expgui(script)] |
---|
| 37 | if { [file pathtype $link] == "absolute" } { |
---|
| 38 | set expgui(script) $link |
---|
| 39 | } { |
---|
| 40 | set expgui(script) [file dirname $expgui(script)]/$link |
---|
| 41 | } |
---|
| 42 | } else { |
---|
| 43 | break |
---|
| 44 | } |
---|
| 45 | } |
---|
| 46 | # fixup relative paths |
---|
| 47 | if {[file pathtype $expgui(script)] == "relative"} { |
---|
| 48 | set expgui(script) [file join [pwd] $expgui(script)] |
---|
| 49 | } |
---|
| 50 | set expgui(scriptdir) [file dirname $expgui(script) ] |
---|
| 51 | #---------------------------------------------------------------- |
---|
| 52 | source [file join $expgui(scriptdir) opts.tcl] |
---|
| 53 | # fetch EXP file processing routines |
---|
| 54 | source [file join $expgui(scriptdir) readexp.tcl] |
---|
| 55 | # commands for running GSAS programs |
---|
| 56 | #source [file join $expgui(scriptdir) gsascmds.tcl] |
---|
| 57 | # override options with locally defined values |
---|
[703] | 58 | set filelist [file join $expgui(scriptdir) localconfig] |
---|
| 59 | if {$tcl_platform(platform) == "windows"} { |
---|
| 60 | lappend filelist "c:/gsas.config" |
---|
| 61 | } else { |
---|
| 62 | lappend filelist [file join ~ .gsas_config] |
---|
[459] | 63 | } |
---|
[703] | 64 | catch { |
---|
| 65 | foreach file $filelist { |
---|
| 66 | if [file exists $file] {source $file} |
---|
| 67 | } |
---|
[459] | 68 | } |
---|
[703] | 69 | |
---|
[459] | 70 | SetTkDefaultOptions $expgui(font) |
---|
| 71 | |
---|
[675] | 72 | if {![file exists $filename]} { |
---|
[459] | 73 | # read error |
---|
| 74 | wm withdraw . |
---|
| 75 | tk_dialog .err {Bad file} \ |
---|
[675] | 76 | "$argv0: error\nfile $filename not found" \ |
---|
[459] | 77 | error 0 Continue |
---|
| 78 | exit |
---|
| 79 | } |
---|
[675] | 80 | set fmt [expload $filename] |
---|
[459] | 81 | if {$fmt < 0} { |
---|
| 82 | # read error |
---|
| 83 | wm withdraw . |
---|
| 84 | tk_dialog .err {Bad file} \ |
---|
[675] | 85 | "$argv0: error reading $filename\nThis is not a valid GSAS .EXP file" \ |
---|
[459] | 86 | error 0 Continue |
---|
| 87 | exit |
---|
| 88 | } |
---|
| 89 | mapexp |
---|
| 90 | if {[llength $expmap(phaselist)] == 0} { |
---|
| 91 | # read error |
---|
| 92 | wm withdraw . |
---|
| 93 | tk_dialog .err {Bad file} \ |
---|
[675] | 94 | "$argv0: error reading $filename\nNo phases found" \ |
---|
[459] | 95 | error 0 Continue |
---|
| 96 | exit |
---|
| 97 | } |
---|
| 98 | if {[llength $expmap(phaselist)] > 1} { |
---|
[545] | 99 | # count non-mm phases |
---|
| 100 | set i 0 |
---|
| 101 | foreach p $expmap(phaselist) type $expmap(phasetype) { |
---|
| 102 | if {$type != 4} {incr i; set phase $p} |
---|
[459] | 103 | } |
---|
[545] | 104 | if {$i > 1} { |
---|
| 105 | # need to select a phase |
---|
| 106 | .l config -text "Select a phase" |
---|
| 107 | foreach p $expmap(phaselist) type $expmap(phasetype) { |
---|
| 108 | set n [phaseinfo $p name] |
---|
| 109 | pack [radiobutton .p$p -text "Phase $p: $n" -variable phase \ |
---|
| 110 | -value $p] -anchor w |
---|
| 111 | if {$type == 4} { |
---|
| 112 | .p$p config -state disabled |
---|
| 113 | } |
---|
| 114 | } |
---|
| 115 | wm withdraw . |
---|
| 116 | update idletasks |
---|
| 117 | set x [expr {[winfo screenwidth .]/2 - [winfo reqwidth .]/2}] |
---|
| 118 | set y [expr {[winfo screenheight .]/2 - [winfo reqheight .]/2}] |
---|
| 119 | wm geom . +$x+$y |
---|
| 120 | wm deiconify . |
---|
| 121 | grab . |
---|
| 122 | focus . |
---|
| 123 | tkwait variable phase |
---|
| 124 | } |
---|
[459] | 125 | } else { |
---|
| 126 | set phase $expmap(phaselist) |
---|
[545] | 127 | if {$expmap(phasetype) == 4} { |
---|
| 128 | tk_dialog .err {Only mm phase} \ |
---|
[675] | 129 | "$argv0: unable to read from $filename\nOnly a macromolecular phase is present." \ |
---|
[545] | 130 | error 0 Continue |
---|
| 131 | exit |
---|
| 132 | } |
---|
[459] | 133 | } |
---|
| 134 | foreach v {a b c alpha beta gamma} { |
---|
| 135 | lappend l [phaseinfo $phase $v] |
---|
| 136 | } |
---|
| 137 | set l1 {} |
---|
| 138 | foreach a $expmap(atomlist_$phase) { |
---|
| 139 | set l2 {} |
---|
| 140 | foreach p {label x y z type frac} { |
---|
| 141 | lappend l2 [atominfo $phase $a $p] |
---|
| 142 | } |
---|
| 143 | if {[atominfo $phase $a temptype] == "I"} { |
---|
| 144 | lappend l2 [atominfo $phase $a Uiso] |
---|
| 145 | } else { |
---|
| 146 | set ueq {} |
---|
| 147 | catch { |
---|
| 148 | set ueq [expr { |
---|
| 149 | ([atominfo $phase $a U11] + |
---|
| 150 | [atominfo $phase $a U22] + |
---|
| 151 | [atominfo $phase $a U33]) /3. |
---|
| 152 | }] |
---|
| 153 | } |
---|
| 154 | lappend l2 $ueq |
---|
| 155 | # } |
---|
| 156 | lappend l1 $l2 |
---|
| 157 | } |
---|
| 158 | puts [list [phaseinfo $phase spacegroup] $l $l1] |
---|
| 159 | exit |
---|