source: trunk/dumpexp.tcl

Last change on this file was 1251, checked in by toby, 9 years ago

use svn ps svn:eol-style "native" * to change line ends

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Revision Id
File size: 4.1 KB
Line 
1#!/bin/sh
2# the next line restarts this script using wish found in the path\
3exec 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 1251 2014-03-10 22:17:29Z toby $
10
11package require Tk
12
13if {[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}
20
21set filename [lindex $argv 0]
22
23set expgui(font) 14
24set expgui(debug) 0
25
26pack [label .l -text "Reading $filename\nPlease wait"]
27update
28wm protocol . WM_DELETE_WINDOW {puts ""; exit}
29#=============================================================================
30#----------------------------------------------------------------
31# where are we?
32set expgui(script) [info script]
33# translate links -- go six levels deep
34foreach 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
47if {[file pathtype $expgui(script)] == "relative"} {
48    set expgui(script) [file join [pwd] $expgui(script)]
49}
50set expgui(scriptdir) [file dirname $expgui(script) ]
51#----------------------------------------------------------------
52source [file join $expgui(scriptdir) opts.tcl]
53# fetch EXP file processing routines
54source [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
58set filelist [file join $expgui(scriptdir) localconfig]
59if {$tcl_platform(platform) == "windows"} {
60    lappend filelist "c:/gsas.config"
61} else {
62    lappend filelist [file join ~ .gsas_config]
63}
64catch {
65    foreach file $filelist {
66        if [file exists $file] {source $file}
67    }
68}
69
70SetTkDefaultOptions $expgui(font)
71
72if {![file exists $filename]} {
73    # read error
74    wm withdraw .
75    tk_dialog .err {Bad file} \
76            "$argv0: error\nfile $filename not found" \
77            error 0 Continue
78    exit
79}
80set fmt [expload $filename]
81if {$fmt < 0} {
82    # read error
83    wm withdraw .
84    tk_dialog .err {Bad file} \
85            "$argv0: error reading $filename\nThis is not a valid GSAS .EXP file" \
86            error 0 Continue
87    exit
88}
89mapexp
90if {[llength $expmap(phaselist)] == 0} {
91    # read error
92    wm withdraw .
93    tk_dialog .err {Bad file} \
94            "$argv0: error reading $filename\nNo phases found" \
95            error 0 Continue
96    exit
97}
98if {[llength $expmap(phaselist)] > 1} {
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}
103    }
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        set phase {}
124        tkwait variable phase
125    }
126} else {
127    set phase $expmap(phaselist)
128    if {$expmap(phasetype) == 4} {
129        tk_dialog .err {Only mm phase} \
130                "$argv0: unable to read from $filename\nOnly a macromolecular phase is present." \
131                error 0 Continue
132        exit
133    }
134}
135foreach v {a b c alpha beta gamma} {
136    lappend l [phaseinfo $phase $v]
137}
138set l1 {}
139foreach a $expmap(atomlist_$phase) {
140    set l2 {}
141    foreach p {label x y z type frac} {
142        lappend l2 [atominfo $phase $a $p]
143    }
144    if {[atominfo $phase $a temptype] == "I"} {
145        lappend l2 [atominfo $phase $a Uiso]
146    } else {
147        set ueq {} 
148        catch {
149            set ueq [expr {
150                ([atominfo $phase $a U11] + 
151                [atominfo $phase $a U22] + 
152                [atominfo $phase $a U33]) /3.
153            }]
154            }
155        lappend l2 $ueq
156#    }
157    lappend l1 $l2
158}
159puts [list [phaseinfo $phase spacegroup] $l $l1]
160exit
Note: See TracBrowser for help on using the repository browser.