Changeset 1226 for branches/sandbox


Ignore:
Timestamp:
Dec 7, 2012 4:38:02 PM (8 years ago)
Author:
toby
Message:

fixes for anom and fourier GUIs

Location:
branches/sandbox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/anomal.tcl

    r1222 r1226  
    1515     set ::anom_wave [histinfo $histlbl lam1]
    1616     foreach test $::expmap(powderlist) {
    17              #puts "[histinfo $test lam1] versus $::anom_wave"
    18              if {[histinfo $test lam1] == $::anom_wave} {
    19                 lappend ::anom_list $test
    20              }
    21      if {[llength $::anom_list] == 0} return
     17         #puts "[histinfo $test lam1] versus $::anom_wave"
     18         if {[histinfo $test lam1] == $::anom_wave} {
     19             lappend ::anom_list $test
     20         }
    2221     }
    2322     #puts "this wavelength is found in histogram $::anom_list"
     
    2625     set ::anom_abort [histinfo $histlbl anomff]
    2726
    28      if {[histinfo $histlbl anomff] == ""} {
    29         catch {destroy .anomwarning}
    30         set anomwarn .anomwarning
    31         toplevel $anomwarn
    32         wm title $anomwarn "Warning"
    33         wm geometry $anomwarn 400x200+10+10
    34         grid [frame $anomwarn.buz -bd 2 -relief groove] -column 0 -row 0 -sticky news
    35         grid [label $anomwarn.buz.text -text "No information in EXP file.  Run GENLES to generate\n\u0394f' and \u0394f\" data"]\
    36              -row 0 -column 0
    37         grid [button $anomwarn.buz.but -width 8 -text "continue" -command {destroy .anomwarning}] -column 0 -row 1
    38      }
    39      foreach temp [histinfo $histlbl anomff] {
    40              incr ::anom_atomcount
    41              set ::anom_lbl($::anom_atomcount) [lindex $temp 0]
    42              set ::anom_fp($::anom_atomcount) [lindex $temp 1]
    43              set ::anom_f2p($::anom_atomcount) [lindex $temp 2]
    44              #puts "$::anom_lbl($::anom_atomcount) $::anom_fp($::anom_atomcount) $::anom_f2p($::anom_atomcount)"
    45      }
     27    foreach temp [histinfo $histlbl anomff] {
     28        incr ::anom_atomcount
     29        set ::anom_lbl($::anom_atomcount) [lindex $temp 0]
     30        set ::anom_fp($::anom_atomcount) [lindex $temp 1]
     31        set ::anom_f2p($::anom_atomcount) [lindex $temp 2]
     32        #puts "$::anom_lbl($::anom_atomcount) $::anom_fp($::anom_atomcount) $::anom_f2p($::anom_atomcount)"
     33    }
    4634}
    4735
    4836proc anomalous_editor {args} {
    49      if {$::anom_atomcount == 0} {return}
     37    if {[llength $::anom_list] == 0} {
     38        MyMessageBox -parent . -title "No Anom Hists" \
     39            -icon warning \
     40            -message "No appropriate histograms for \u0394f' and \u0394f\" fields"
     41        return
     42    }
     43    # make a list of atom types in all phases
     44    foreach ph $::expmap(phaselist) {
     45        foreach at $::expmap(atomlist_$ph) {
     46            set typelist([atominfo $ph $at type]) ""
     47        }
     48    }
     49    # find the elements that do not have anom values already
     50    set oldff {}
     51    foreach items [histinfo [lindex $::anom_list 0] anomff] {
     52        lappend oldff [lindex $items 0]
     53    }
     54    set newff {}
     55    foreach typ [array names typelist] {
     56        if {[lsearch $oldff $typ] == -1} {lappend newff $typ}
     57    }
     58    #puts "newff = $newff"
     59    #if {$::anom_atomcount == 0} {return}
    5060     catch {destroy .anomalous}
    5161     set anomal .anomalous
    5262     toplevel $anomal
    5363     wm title $anomal "Anomalous Dispersion Terms"
    54      wm geometry $anomal 520x370+10+10
     64     #wm geometry $anomal 520x370+10+10
    5565     putontop $anomal
     66     set str {}
     67     foreach i $::anom_list {
     68         if {$str != ""} {append str ", "}
     69         append str $i
     70     }
    5671
    57      grid [frame $anomal.list -bd 2 -relief groove] -row 0 -column 0 -sticky news
    58      grid [label $anomal.list.lbl1 -text "The anomalous dispersion terms will be set for x-ray histograms\n with wavelength $::anom_wave angstroms:"] -row 0 -column 0
    59      grid [label $anomal.list.lbl1a -text "$::anom_list"] -row 1 -column 0
     72    grid [frame $anomal.list -bd 2 -relief groove] -row 0 -column 0 -sticky news
     73    grid [label $anomal.list.lbl1 -text "The anomalous dispersion terms will be set for x-ray histogram(s)\n with wavelength $::anom_wave angstroms \[histogram(s) $str\]"] -row 0 -column 0
     74    grid [frame $anomal.con -bd 2 -relief groove] -row 6  -column 0 -sticky news
     75    set cmd "anomalous_add $anomal [list $newff]"
     76    grid [button $anomal.con.addnew -text "Add new type:"  \
     77              -command $cmd] -column 0 -row 4
     78    if {[llength $oldff] >= 9 || [llength $newff] == 0} {
     79        $anomal.con.addnew configure -state disabled
     80    } else {
     81        eval tk_optionMenu $anomal.con.elem ::anom_new $newff
     82        grid $anomal.con.elem -column 1 -row 4
     83    }
     84    grid columnconfigure $anomal.con 2 -weight 1
     85    grid [button $anomal.con.save  -width 8 -text "Save"  -command {anomalous_save}] \
     86        -column 3 -row 4 -padx 3
     87    grid [button $anomal.con.abort -width 8 -text "Cancel" -command {anomalous_abort}] \
     88        -column 4 -row 4 -padx 3
     89    grid columnconfigure $anomal.con 5 -weight 1
    6090
    61      grid [frame $anomal.con -bd 2 -relief groove] -row 5  -column 0 -sticky news
    62      grid [button $anomal.con.save  -width 8 -text "Save"  -command {anomalous_save}] -column 0 -row 4 -padx 3
    63      grid [button $anomal.con.abort -width 8 -text "Cancel" -command {anomalous_abort}] -column 1 -row 4 -padx 3
    64 
    65      grid [frame $anomal.warning -bd 2 -relief groove] -row 7 -column 0 -sticky news
    66      grid [label $anomal.warning.1 -anchor center -text "*Warning.  GSAS will only store \u0394f' and \u0394f\" values \n for the first nine atom types*"] \
     91     grid [frame $anomal.warning -bd 2 -relief groove] -row 5 -column 0 -sticky news
     92     grid [label $anomal.warning.1 -text "Note: only 9 sets of \u0394f' and \u0394f\" values can be saved"] \
    6793          -columnspan 2 -column 0 -row 0 -pady 3
    68      grid [label $anomal.warning.2 -anchor center -text "Notice: \u0394f' and \u0394f\" fields are added after GENLES is run."] \
    69           -columnspan 2 -column 0 -row 1 -pady 3
     94#     grid [label $anomal.warning.2 -anchor center -text "Notice: \u0394f' and \u0394f\" fields are added after GENLES is run."] \
     95#          -columnspan 2 -column 0 -row 1 -pady 3
    7096
    7197     grid [frame $anomal.info -bd 2 -relief groove -width 600] -row 1 -column 0 -sticky ns
     98    anom_fill_table $anomal.info
     99}
    72100
    73       set top $anomal.info
    74       set main $anomal.info
     101proc anomalous_add {anomal newff} { 
     102    add_anomff $::anom_list $::anom_new
     103    incr ::expgui(changed)
     104    set oldff {}
     105    foreach items [histinfo [lindex $::anom_list 0] anomff] {
     106        lappend oldff [lindex $items 0]
     107    }
     108    set ff {}
     109    foreach typ $newff {
     110        if {[lsearch $oldff $typ] == -1} {lappend ff $typ}       
     111    }
     112    set newff $ff
     113    destroy $anomal.con.elem
     114    if {[llength $newff] == 0} {
     115        $anomal.con.addnew configure -state disabled       
     116    } else {
     117        eval tk_optionMenu $anomal.con.elem ::anom_new $newff
     118        set ::anom_new [lindex $newff 0]
     119        grid $anomal.con.elem -column 1 -row 4
     120    }
     121    anomalous_load
     122    anom_fill_table $anomal.info
     123}
    75124
     125proc anom_fill_table {top} {
     126    eval destroy [winfo children $top]
    76127     grid [label $top.toplabel1  -text "Type" -width 8] -column 0 -row 0
    77128     grid [label $top.toplabel2  -anchor center -text " \u0394f'" -width 8]  -column 2 -row 0
    78129     grid [label $top.toplabel3  -anchor center -text " \u0394f\"" -width 8] -column 4 -row 0
    79130     for {set i 1} {$i <= $::anom_atomcount} {incr i} {
    80          grid [label $main.atom_lbl($i) -text "$::anom_lbl($i)" -width 8] -column 0 -row $i
    81          grid [entry $main.atom_fp($i)  -textvariable ::anom_fp($i)  -width 8] -column 2 -row $i
    82          grid [entry $main.atom_f2p($i) -textvariable ::anom_f2p($i) -width 8] -column 4 -row $i
     131         grid [label $top.atom_lbl($i) -text "$::anom_lbl($i)" -width 8] -column 0 -row $i
     132         grid [entry $top.atom_fp($i)  -textvariable ::anom_fp($i)  -width 8] -column 2 -row $i
     133         grid [entry $top.atom_f2p($i) -textvariable ::anom_f2p($i) -width 8] -column 4 -row $i
    83134     }
    84135}
  • branches/sandbox/gsascmds.tcl

    r1221 r1226  
    39383938    if {[lsearch $::expmap(phaselist) $phase] == -1} return
    39393939    # check that all Fourier records are set to the current phase
     3940    set msg ""
    39403941    foreach i [listFourier] {
    39413942        set ph [Fourierinfo $i phase]
    3942         if {$ph != $phase} {Fourierinfo $i phase set $phase}
     3943        if {$ph != $phase} {
     3944            #Fourierinfo $i phase set $phase
     3945            set msg "Reset previous Fourier map(s) for phase $ph?"
     3946        }
     3947    }
     3948    if {$msg != ""} {
     3949        set ans [MyMessageBox -parent . -title "Reset Fourier?" \
     3950                     -message $msg -icon warning -type okcancel]
     3951        if {$ans == "ok"} {
     3952            delFourier
     3953        } else {
     3954            return
     3955        }
    39433956    }
    39443957    # for now we will not offer access to section, (dmin, dmax not supported)
     
    39964009        append ::DXTL(histlist) $i
    39974010    }
     4011    # if we don't have any histograms, set either set the only choice or
     4012    # warn the user
     4013    if {$::DXTL(histlist) == ""} {
     4014        if {[llength $::expmap(powderlist)] == 1} {
     4015            AddFourierHist $::expmap(powderlist)
     4016            set ::DXTL(histlist) $::expmap(powderlist)
     4017        } else {
     4018            set ::DXTL(histlist) "<None: must be set>"
     4019        }
     4020    }
    39984021    grid [label $box.2.m1 -text min] -column 2 -row 2
    39994022    grid [label $box.2.m2 -text max] -column 3 -row 2
  • branches/sandbox/readexp.tcl

    r1220 r1226  
    20532053    }
    20542054    return 1
     2055}
     2056
     2057proc add_anomff {histlist type {fp 0} {fpp 0}} {
     2058    global expgui
     2059    foreach hist $histlist {
     2060        if {$hist < 10} {
     2061            set key "HST  $hist"
     2062        } else {
     2063            set key "HST $hist"
     2064        }
     2065        if ![validreal fp 10 3] {return 0}
     2066        if ![validreal fpp 10 3] {return 0}
     2067        foreach i {1 2 3 4 5 6 7 8 9} {
     2068            if {![existsexp "${key}FFANS$i"]} {
     2069                makeexprec "${key}FFANS$i"
     2070                setexp "${key}FFANS$i" [string trim $type] 3 8
     2071                setexp "${key}FFANS$i" $fp 11 10
     2072                setexp "${key}FFANS$i" $fpp 21 10
     2073                setexp "${key}FFANS$i" "NN" 34 2
     2074                return 1
     2075            }
     2076        }
     2077        return 0
     2078    }
    20552079}
    20562080
Note: See TracChangeset for help on using the changeset viewer.