Changeset 1157 for branches/sandbox


Ignore:
Timestamp:
Jul 26, 2011 12:47:57 PM (9 years ago)
Author:
toby
Message:

liveplot: export to gnuplot; plot I/sigma(I); change title & size of labels; improve tick location; make autoticks standard; expgui: new menu item to create InstParm? file; InstEdit?: bug fixes; remove fprime since not in GSAS anymore; fix 2Theta max bug for CW instruments; updates to doc files

Location:
branches/sandbox
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/sandbox/addcmds.tcl

    r1150 r1157  
    709709    # mode must be t-max or 2theta, at least for now
    710710    if {$newhist(LimitMode) != 1} return
    711     # is a instrument parameter file loaded? If not, try again later
    712     if {[string trim $newhist(instfile)] == ""} return
    713711    # get data bank number, test if valid
    714712    set num $newhist(banknum)
    715713    if {[catch {expr $num}]} {return}
    716714    if {$newhist(insttype) == "TOF"} {
     715        # is a instrument parameter file loaded? If not, try again later
     716        if {[string trim $newhist(instfile)] == ""} return
    717717        set newhist(2tLimit) [expr {$newhist(tmin$num) / 10.}]
    718718        # at Ashfia's request, override the bank header # with the
  • branches/sandbox/doc/expgui.html

    r1150 r1157  
    500500
    501501The INSTEDIT utility is used to edit or create an instrument parameter file.
    502 At this time it can only be used to edit files for
    503 constant-wavelength data. The utility can be started from the "Edit File"
    504 button in the
     502The utility can be started from the "Edit File" button in the
    505503<A HREF="expgui3.html#AddHist">"Add New Histogram"</A> dialog, or from the
    506 the "instedit" option in the Powder menu. In the latter case, the user
    507 is given the chance to select an input file. If no file is selected,
    508 a new, empty, file is created. An example INSTEDIT window appears below.
     504the "instedit" option in the Powder menu. Alternately, to create a new
     505  instrument parameter file, choose Powder menu option "New InstParm
     506  file". (It is also possible
     507  to create a new file using the standard instedit by selecting
     508  "Cancel" when asked for an input file.)
     509An example INSTEDIT window appears below.
    509510<P>
    510511<img SRC="instedit1.gif" align=RIGHT alt="EXPGUI Screen snapshot">
     
    618619records can slow the GSAS programs
    619620(this is less of a problem on faster computers). For these reasons, it may be
    620 a good idea to prune the older history records from the file. If more than 100
    621 history records are found in an experiment file, EXPGUI suggests that the
    622 older history entries be deleted. Alternately the File/EraseHistory command
    623 can be used to invoke the this option.
     621a good idea to prune the older history records from the file.
     622The File/EraseHistory command can be used to invoke the this option.
    624623<P>
    625624On the dialog the number of history records to be retained is specified.
  • branches/sandbox/doc/expguic.html

    r971 r1157  
    4949        experiment file from scratch.
    5050<DT>expnam<DD>
    51 Equivalent to Open, included since this is the command used in other
    52 GSAS shells to select GSAS experiments.
     51Equivalent to Open (included for historical reasons.)
     52
    5353<DT>Save<DD>Saves modifications to the current experiment file to disk (shortcut Alt-S).
    5454<DT>Save As<DD>Saves modifications to the current experiment file to disk
     
    6060  offers the program user the option to update these files. The update
    6161  will fail if the user does not have permission to change the EXPGUI
    62   or GSAS files. In this case, a system administrator may be needed.
     62  or GSAS files. In this case, a system administrator may be needed.
     63  <DT>revert<DD>Used to load an <a href="#archive">archived</A>
     64    (backup) version of the current .EXP file.
    6365<DT>EraseHistory<DD>Deletes old history records to speed reading of the .EXP file.
    64 <DT>convert<DD>Convert a standard ASCII file to the direct access format used by GSAS (and for UNIX, the reverse)
     66<DT>convert<DD>Convert a standard ASCII file to the direct access
     67  format used by GSAS (and for UNIX, the reverse) -- this is not
     68  likely to be needed, as GSAS now does most conversions automatically.
    6569<DT>exit<DD>Exit EXPGUI (shortcut Alt-X or ^C)
    6670</DL>
     
    99103revised .EXP file, which means that you reject the last set of changes.
    100104This is useful if
    101 GENLES blows up or you have done something wrong. The advantage
    102 of turning "autoload EXP" on is
     105GENLES blows up or you have done something wrong. The reason to
     106turning "autoload EXP" on is
    103107that there is one less thing to do when running GSAS programs.
    104108Note that it is still possible to reverse changes, if
    105 <a href="#archive">archive files</A>, but this may require more effort.
    106 
     109<a href="#archive">archive files</A>, but this may require more
     110  effort. See the File/revert menu entry.
    107111<a name="execprompt"></a>
    108112<DT>Prompt after GSAS run<DD>
     
    121125screen cluttered with EXPGUI when it can't be used,
    122126but this is an option so that the mode can be turned off by those people
    123 who find this behavior annoying.
     127who find this behavior annoying. It appears this option causes
     128  problems on Windows 7.
    124129
    125130<a name="AutostartGRWND"></a>
     
    225230<DT>rawplot<DD>Plot powder data
    226231<DT>fitspec<DD>Fit a TOF vanadium scattering spectrum
    227 <DT>tofnorm<DD>Normalize a TOF spectrum
    228232<DT><a HREF="liveplot.html#bkgedit">bkgedit</a>
    229233<DD>Invokes the <a HREF="liveplot.html#bkgedit">BKGEDIT</a> program
     
    233237to set the upper and lower limits for a histogram, as well as
    234238edit excluded regions.
     239<DT>seqgsas<DD>Invokes the sequential GSAS refinement program to run
     240  GENLES on a set of very similar data files.
     241<DT>mustrplot<DD>Plot microstrain results
     242<DT><a HREF="expgui.html#INSTEDIT">instedit</A><DD>Invokes the <a HREF="expgui.html#INSTEDIT">instedit</A>
     243  to edit an instrument parameter file.
     244<DT>New InstParm file<DD>Creates a new instrument parameter file using
     245  <a HREF="expgui.html#INSTEDIT">instedit</A>.
     246
     247
    235248</DL>
    236249<img SRC="m3.gif"  BORDER=3 alt="EXPGUI Screen snapshot">
     
    238251
    239252<a name="4"></a>
    240 <h3>C.4 Single Crystal Menu</h3>
     253<h3>C.4 Xtal (Single Crystal) Menu</h3>
    241254<BLOCKQUOTE>
    242255This menu contains links to GSAS programs used for
     
    268281<DT>fourier<DD>Generate Fourier map
    269282<DT>forsrh<DD>Search Fourier map for peaks
     283<DT>gsas2map<DD>Exports a Fourier map in formats used by other
     284  programs (for example Fox and DRAWxtl).
    270285<DT><a HREF="liveplot.html#liveplot">liveplot</a>
    271286<DD>Invokes the <a HREF="liveplot.html#liveplot">LIVEPLOT</a> program
     
    274289<DT>vrstplot<DD>Create a VRML 3-D file for viewing with 3rd party software
    275290<DT>widplt<DD>Displays the FWHM as a function of Q, 2Theta,... for UVWXY values input or read from an EXP file
     291<DT><a HREF="expgui.html#ABSPLT">absplt</A>
     292<DD>The <a HREF="expgui.html#ABSPLT">absplt</A> program displays the
     293  absorption/reflectivity correction curve for values used in a histogram.
     294<DT>mustrplot<DD>Plot microstrain results
     295<DT>seqplot<DD>Plot results from seqgsas
    276296</DL>
    277297<img SRC="m5.gif"  BORDER=3 alt="EXPGUI Screen snapshot">
     
    287307<DT>bijcalc<DD>Thermal parameter analysis
    288308<DT>disagl<DD>Distance/angle calculations
     309<DT>disaglviewer<DD>Display results from distance/angle calculations
     310  in a graphical browser.
    289311<DT>reflist<DD>List reflection data
    290312<DT>geometry<DD>Molecular geometry calculations
     
    297319<DT>ramafit<DD>Fits torsion angle distributions, particularly in peptide
    298320chains, for use in restraints.
     321<DT>seqplot<DD>Plot results from seqgsas
    299322</DL>
    300323<img SRC="m6.gif"  BORDER=3 alt="EXPGUI Screen snapshot">
     
    307330<DL>
    308331<DT>cllchg<DD>Transform unit cell
    309 <DT>fprime<DD>Compute f, f', f'' and mu/rho for an element for a range of x-ray wavelengths
     332<DT>composition<DD>Computes the chemical composition of a unit cell
     333accounting for site multiplicies and occupancies
    310334<DT>rducll<DD>Unit cell reduction
    311335<DT>spcgroup<DD>Space group symbol interpreter
     336<DT>seqgsas<DD>Invokes the sequential GSAS refinement program to run
     337  GENLES on a set of very similar data files.
     338<DT>seqplot<DD>Plot results from seqgsas
    312339<DT>unimol<DD>Unique molecule assembler
    313340</DL>
     
    315342</BLOCKQUOTE>
    316343
    317 <a name="8"></a>
    318 <h3>C.8 Import/Export Menu</h3>
    319 <BLOCKQUOTE>
    320 This menu contains utilities for importing information into GSAS and
    321 exporting.
    322 <DL>
    323 <DT>exp2xtl<DD>Prepare a .XTL format file of atomic positions. This
    324 file is used in MSI software such as Cerius and InsightII.
    325 <DT>gsas2cif<DD>Prepare IUCr crystallographic information (CIF) file
    326 <DT>hklsort<DD>Prepare HKL tables
    327 <DT>pubtable<DD>Prepare atom parameter tables
    328 <DT>convert<DD>Convert a standard ASCII file to the direct access format used by GSAS (and for UNIX, the reverse)
    329 <DT>cad4rd<DD>Prepare CAD4 single crystal data
    330 <DT>dbwscnv<DD>Convert a powder diffraction data file from DBWS format
    331 <DT>x17bcnv<DD>Convert an energy dispersive diffractogram data file from NSLS X17b
    332 <DT>p3r3data<DD>Prepare Siemens/Brucker P3R3 single crystal data
    333 <DT>sxtldata<DD>Prepare generic single crystal data
    334 <DT>gsas2pdb<DD>
    335 Import (using GSAS2PDB & EXPEDT) and export coordinates (for
    336 macromolecular phases) to/from Protein Data Base files
    337 <DT>ref2asc<DD>
    338 Exports a GSAS reflection file to ASCII for use in non-GSAS programs
    339 <DT>ref2bin<DD>
    340 Imports an ASCII reflection file to the GSAS binary format
    341 </DL>
    342 <img SRC="m8.gif"  BORDER=3 alt="EXPGUI Screen snapshot">
    343 </BLOCKQUOTE>
    344 
    345344<a name="9"></a>
    346 <h3>C.9 Macro Menu
     345<h3>C.8 Macro Menu
    347346<IMG SRC="new.gif" HEIGHT=13 WIDTH=36 alt="New!">
    348347</h3>
     
    402401</DL>
    403402</BLOCKQUOTE>
     403
     404<a name="8"></a>
     405<h3>C.9 Import/Export Menu</h3>
     406<BLOCKQUOTE>
     407This menu contains utilities for importing information into GSAS and
     408exporting it to other programs.
     409<DL>
     410<DT>Coord Export<DD>This provides a series of routines that are used
     411to write coordinates and possibly other information to files:<P>
     412<DL>
     413<DT>gsas2cif<DD>Prepares IUCr crystallographic information (CIF) file
     414that documents the current refinement. The CIF contains the
     415coordinates for all phases as well as the observed and computed
     416diffraction patterns. The templates used by GSAS2CIF can be customized
     417to provide a detailed description of the experimental measurements and
     418results for use in documenting analysis for publication or
     419deposition.
     420<DT>coords-only CIF<DD>For export of intermediate results to another
     421program, CIF can be a useful exchange format. This routine provides a
     422CIF with the current coordinates from one phase and not much else.
     423<DT>export to DRAWxtl<DD>This writes a .STR file used in the DRAWxtl
     424program and optionally launches DRAWxtl.
     425<DT>export to SHELX<DD>This writes coordinates for a selected phase in
     426the .INS format used by SHELX and several other programs.
     427<DT>export to PLATON<DD>This writes coordinates for a selected phase in
     428the .SPF format used by PLATON
     429<DT>export test format<DD>This demonstrates how a coordinate export
     430routine can be added to EXPGUI. See the <A
     431HREF="expgui_cfg.html#export">documentation on this</A> for further
     432information.
     433<DT>export to FOX<DD>This prepares a XML file with coordinates for use
     434in the FOX program
     435<DT>MSI .xtl<DD>Prepare a .XTL format file of atomic positions. This
     436file is used in older Accelrys software such as Cerius and
     437Insight-II. It may no longer be of value.
     438</DL>
     439
     440<DT>CIF Export<DD>This provides a series of routines that are used
     441to prepare CIF files:<P>
     442<DL>
     443<DT>gsas2cif<DD>Prepares IUCr crystallographic information (CIF) file
     444that documents the current refinement. The CIF contains the
     445coordinates for all phases as well as the observed and computed
     446diffraction patterns. The templates used by GSAS2CIF can be customized
     447to provide a detailed description of the experimental measurements and
     448results for use in documenting analysis for publication or
     449deposition.
     450<DT>FillTemplate<DD>Used to edit the CIF template files used in GSAS2CIF
     451<DT>CIFselect<DD>Used to select interatomic distances and angles to be
     452included in the CIF created by GSAS2CIF.
     453</DL>
     454
     455<DT>hklsort<DD>Prepare HKL tables
     456<DT>pubtable<DD>Prepare atom parameter tables
     457<DT>convert<DD>Convert a standard ASCII file to the direct access format used by GSAS (and for UNIX, the reverse)
     458<DT>cad4rd<DD>Prepare CAD4 single crystal data
     459<DT>dbwscnv<DD>Convert a powder diffraction data file from DBWS format
     460<DT>x17bcnv<DD>Convert an energy dispersive diffractogram data file from NSLS X17b
     461<DT>p3r3data<DD>Prepare Siemens/Brucker P3R3 single crystal data
     462<DT>sxtldata<DD>Prepare generic single crystal data
     463<DT>gsas2pdb<DD>
     464Import (using GSAS2PDB & EXPEDT) and export coordinates (for
     465macromolecular phases) to/from Protein Data Base files
     466<DT>ref2asc<DD>
     467Exports a GSAS reflection file to ASCII for use in non-GSAS programs
     468<DT>ref2bin<DD>
     469Imports an ASCII reflection file to the GSAS binary format
     470<DT>gsas2map<DD>Exports a Fourier map in formats used by other
     471  programs (for example Fox and DRAWxtl).
     472</DL>
     473<img SRC="m8.gif"  BORDER=3 alt="EXPGUI Screen snapshot">
     474</BLOCKQUOTE>
     475
    404476<hr>
    405477<TABLE BORDER BGCOLOR="#FFFF40" ALIGN=RIGHT>
  • branches/sandbox/doc/liveplot.html

    r1150 r1157  
    4040<P>
    4141Both LIVEPLOT and BKGEDIT get the current diffraction information
    42 by running the GSAS TCLDUMP program, if installed, or
    43 the GSAS HSTDUMP otherwise. The TCLDUMP program has been optimized for use
    44 with LIVEPLOT and allows LIVEPLOT to offer a number of extra
    45 options that are not available when HSTDUMP is used. Since TCLDUMP has been
    46 included in GSAS since April of 2000, the following documentation assumes
    47 that TCLDUMP is installed.
     42by running the GSAS TCLDUMP program. (In GSAS/EXPGUI before 2001, the
     43GSAS HSTDUMP program was used, which was less powerful. This code has
     44not been removed, but will not be used if TCLDUMP is present.)
    4845
    4946<a name="liveplot"></a>
     
    5451Some of the features available in LIVEPLOT are:
    5552<UL>
    56 <LI>The plot is updated automatically after each refinement run
     53<LI><IMG SRC="new.gif" alt="New!">
     54Regions of the plot can be magnified to show more detail, for example
     55  in regions at high Q.
     56<LI><IMG SRC="new.gif" alt="New!">
     57Plots can be <a href="#export">exported to obtain publication-quality
     58graphics </a> -- <B><I>now on all platforms</I></B>.
     59<LI><IMG SRC="new.gif" alt="New!"> Intensity can be displayed as I/sigma(I)
     60 <LI>The plot is updated automatically after each refinement run
    5761<LI>The plot can be "zoomed-in", by clicking on the corners of the
    5862area to be magnified and "zoomed-out" using the
     
    6165The units used for plotting histograms can be selected. Choices are:
    6266native units (2Theta/TOF/KeV); d-space (A) or Q (A<sup>-1</sup>)
    63 <LI><IMG SRC="new.gif" alt="New!">
    64 Regions of the plot can be magnified to show more detail, for example
    65   in regions at high Q.
    66   <LI>
    67 The background (fixed plus fitted) can be plotted or can be subtracted.
     67 <LI>
     68  The background (fixed plus fitted) can be plotted or can be subtracted.
    6869<LI>
    6970Reflection tickmarks can be displayed in a variety of formats
     
    7980<LI>
    8081The cursor position can be displayed
    81 <LI>
    82 Plots can be <a href="#export">exported to obtain publication-quality
    83 graphics.</a>
    8482</UL>
    8583
     
    393391<B>Export plot options</B>
    394392<UL><LI>
    395 The plot can be exported to
     393<IMG SRC="new.gif" alt="New!">
     394The LIVEPLOT program can export plots to to a <I>high quality</I> PDF
     395  file for presentations or publications using <A
     396  HREF="http://www.gnuplot.info/">gnuplot</A>.
     397  The PDF will match what is is shown on fairly
     398  closely with respect to colors, <A href="#plotfont">font sizes</a>
     399  and <a href="#zoom">zoom</a>. The new <A href="#magnification">plot magnification</a> to show detail in
     400  the fit and for publication increase the
     401  <A href="#plotfont">plot font</a> so that the figure size can be
     402  reduced to the standard Rietveld postage stamp, required by so many
     403  Journals -- allowing the text to be discerned, even if the problems in the
     404  fit cannot.
     405  <P>Starting August
     406  2011, windows and Mac versions of gnuplot are included with the GSAS
     407  binaries; gnuplot is easily
     408  installed on Linux with standard tools such as yum (Redhat),
     409  apt-get (ubuntu) or zypper (openSuse).
     410
     411<P><LI>  The plot can be exported to
    396412<A HREF="http://plasma-gate.weizmann.ac.il/Grace/">Grace</A>, WYSIWYG 2D plotting tool for X-Windows
    397 that produces publication-quality graphics. Many UNIX users know
    398 this program under a previous name, xmgr.
    399 The export is implemented
    400 by producing an ASCII file with instructions that
    401 creates a plot with similar formatting to what appears on the
    402 screen in LIVEPLOT/BKGEDIT. However, the output quality from
    403 Grace is much higher quality. Further, Grace
    404 can be used to enhanced and annotate the plot further.
    405 <LI>
     413that produces publication-quality graphics that appear very similar to
     414  what is seen in LIVEPLOT/BKGEDIT. Further, Grace
     415  can be used to enhance the plot, for example by editing captions,
     416  figure display options and even annotate the plot.
     417  Grace runs well on Linux and Mac computers; Many UNIX users know
     418  this program under a previous name, xmgr.
     419  For Windows,
     420  installation of <A HREF="http://cygwin.com/">Cygwin</A> is required.
     421  <P><LI>
    406422For use in many other graphics programs, LIVEPLOT will produce a
    407423"comma separated variable" data file with the data displayed on the screen.
     
    409425set line styles and scaling, etc., but this does provide an option for
    410426generating high-quality graphics for presentations and publications.
    411 <LI>LIVEPLOT will produce PostScript versions of the plot on the screen,
     427<P><LI>LIVEPLOT will produce PostScript versions of the plot on the screen,
    412428but the quality is rather low (this is a limitation of the BLT graphics
    413429package).
     430  <P><LI>LIVEPLOT/BKGFIT can also be used to prepare input for FOX (Free
     431  Objects for Xtallography).
     432 
    414433</UL>
    415434
     
    468487<DT>Export Plot
    469488<DD>This offers options for exporting the plot in multiple formats.
    470 I am hoping to add more export formats eventually.
    471 <DL><DL>
     489<DL><DL>
     490<DT>to PDF
     491 <IMG SRC="new.gif" alt="New!">
     492<DD>Creates a <I>high quality</I> PDF file that may be useful for
     493  presentations or publications. Note that you may wish to use
     494  <A href="#magnification">plot magnification</a> to show detail in
     495  the fit and for publication increase the
     496  <A href="#plotfont">plot font</a> so that the figure size can be
     497  reduced.
     498
    472499<DT>to PostScript
    473500<DD>Creates a <I>low quality</I> PostScript file containing the LIVEPLOT
     
    476503On Windows, a program such ghostview may be needed to translate the
    477504PostScript to a format that can be viewed or printed.
    478 <A name="grace">
     505
     506  <A name="grace">
    479507<DT>to Grace
    480508<IMG SRC="note.gif" alt="Note!">
     
    484512After the plot is exported, it can be further
    485513enhanced and annotated in grace.
     514
     515<DT>to .csv file
     516  <DD>Creates a "comma separated variable" file. This contains all the
     517  diffraction data shown in the plot. It can be used to produce a plot
     518  in some other graphics program.
     519  <DT>Fox XML
     520  <DD>The Fox program provides structure solution capabilities. This
     521  option can be used to write data in the XML format that Fox uses.
    486522</DL></DL>
    487523<DT>Quit
     
    535571<DT>Y units
    536572<DD>The intensity values can be normalized by the incident spectrum
    537 (for energy dispersive methods).
     573(for energy dispersive methods) or
     574  <IMG SRC="new.gif" alt="New!"> can be displayed as a ratio with the
     575  experimental uncertainty [I<sub>obs</sub>/sigma(I<sub>obs</sub>),
     576  I<sub>calc</sub>/sigma(I<sub>obs</sub>) and their difference].
    538577</DL></DL>
    539578<br clear=all>
     
    565604<DT>Set screen font
    566605<DD>This option is used to control the font used for menus, graphics and
    567 other aspects of windows.
     606other aspects of windows. This value can be saved as a default value.
     607<A name="plotfont">
     608  <DT>Set plot font
     609<DD>This option is used to change the font used in the plot
     610  window. This has a similar effect to changing the screen font, but
     611  can be changed over a wider range and only affects the
     612  graph. Changing the font size either way will change the font used
     613  in the exported .PDF.
    568614<DT>Raise on update
    569615<DD>This causes the plot to be placed on top of other windows, if partially
  • branches/sandbox/expgui

    r1152 r1157  
    44484448    }
    44494449}
     4450$expgui(fm).powder.menu add command -label "New InstParm file" -command {EditInstFile (new)}
    44504451
    44514452# Macro menu
  • branches/sandbox/gsasmenu.tcl

    r1036 r1157  
    2626        bkgedit
    2727        excledt
    28         instedit
    2928        seqgsas
    3029        mustrplot
     30        instedit
    3131    }
    3232    xtal {
     
    5858        cllchg
    5959        composition
    60         fprime
    6160        hklgen
    6261        rducll
     
    311310    }
    312311
    313     fprime      {{runGSASprog $cmd} {
    314         Compute f, f', f'' and mu/rho for an element for a range of x-ray wavelengths}
    315     }
    316 
    317312    dbwscnv     {{runGSASprog $cmd} {
    318313        Convert a powder diffraction data file from DBWS format}
     
    368363    instedit    {{EditInstFile} {
    369364        Edit an instrument parameter file}
     365    }
     366    {New InstParm file} {- {
     367        Create a new instrument parameter file}
    370368    }
    371369
  • branches/sandbox/instedit.tcl

    r991 r1157  
    7878    # loop over banks
    7979    set msg {}
    80     for {set i 1} {$i <= $instdat(lastbank)} {incr i} {
    81         instbankinfo rad $i set $instdat(rad$i)
    82         instbankinfo head $i set $instdat(head$i)
    83         if {[string trim $instdat(name$i)] == ""} {
    84             append msg "\n  The instrument name may not be blank"
    85         }
    86         instbankinfo name $i set $instdat(name$i)
    87         set l {}
    88         foreach var {difc difa zero pola ipola kratio} {
    89             lappend l $instdat(${var}$i)
    90         }
    91         if {[instbankinfo icons $i set $l] != 1} {
    92             append msg "\n  There is an error in values for:\n    the wavelength, zero or polarization"
    93         }
    94         # loop over the profile terms
    95 
    96         for {set j 1} {$j <= $instparms(proftypes${i})} {incr j} {
    97             set l {}
    98             for {set k 1} {$k <= $instparms(profterms${i}_$j)} {incr k} {
    99                 lappend l $instdat(prof${i}_${j}_$k)
    100             }
    101             if {[instprofinfo $i $j set [list \
    102                     $instdat(proftype${i}_$j) $instdat(profcut${i}_$j) $l]\
    103                     ] != 1} {
    104                 append msg "\n  There is an error in the values for profile set $j."
    105             }
    106         }
    107         if {$msg != ""} {
    108             MyMessageBox -parent . -title "No save" \
     80    if {[catch {
     81        for {set i 1} {$i <= $instdat(lastbank)} {incr i} {
     82            instbankinfo rad $i set $instdat(rad$i)
     83            instbankinfo head $i set $instdat(head$i)
     84            if {[string trim $instdat(name$i)] == ""} {
     85                append msg "\n  The instrument name may not be blank"
     86            }
     87            instbankinfo name $i set $instdat(name$i)
     88            set l {}
     89            foreach var {difc difa zero pola ipola kratio} {
     90                lappend l $instdat(${var}$i)
     91            }
     92            if {[instbankinfo icons $i set $l] != 1} {
     93                append msg "\n  There is an error in values for:\n    the wavelength, zero or polarization"
     94            }
     95            # loop over the profile terms
     96           
     97            for {set j 1} {$j <= $instparms(proftypes${i})} {incr j} {
     98                set l {}
     99                for {set k 1} {$k <= $instparms(profterms${i}_$j)} {incr k} {
     100                    lappend l $instdat(prof${i}_${j}_$k)
     101                }
     102                if {[instprofinfo $i $j set [list \
     103                                                 $instdat(proftype${i}_$j) $instdat(profcut${i}_$j) $l]\
     104                        ] != 1} {
     105                    append msg "\n  There is an error in the values for profile set $j."
     106                }
     107            }
     108            if {$msg != ""} {
     109                MyMessageBox -parent . -title "No save" \
    109110                    -message "Error in input for bank $i:$msg" -icon warning \
    110111                    -type Sorry -default sorry
    111             return
    112         }
     112                return
     113            }
     114        }
     115    } errmsg]} {
     116        if {$errmsg == ""} return
     117        MyMessageBox -parent . -title "No save" \
     118            -message "Error in input (did you define data type, profile type, etc?):\n$errmsg" -icon warning \
     119            -type Sorry -default sorry
     120        return
    113121    }
    114122    if {$filename == ""} {
     
    150158proc instShowBank {box} {
    151159    global instdat instparms
     160    set instparms(profileframe) {}
     161
    152162    set topfr $box.a
    153163    if {$instparms(bank) == 0} return
     
    159169    }
    160170    if {$instparms(banklabel) == ""} {
    161         puts starting
    162171        return
    163172    }
     
    562571proc AddInstProfile {box b} {
    563572    global instparms instdat
    564     set frame $instparms(profileframe)
    565573    incr instparms(proftypes${b})
    566574    instShowBank $box
     
    759767                -parent $instparms(top) -defaultextension .ins \
    760768                -filetypes {{"Instrument parameters file" ".ins .inst .prm"} {All *.*}}]
     769    } elseif {$filename == "(new)"} {
     770        set instparms(filename) ""
    761771    } else {
    762772        set instparms(filename) $filename
  • branches/sandbox/liveplot

    r1144 r1157  
    1414# process command line arguments
    1515set exitstat 0
    16 set expnam [lindex $argv 0]
     16set expnam [file root [lindex $argv 0]]
    1717if {$expnam == ""} {catch {puts "error -- no experiment name"}; set exitstat 1}
    1818if $exitstat {
     
    2020    exit
    2121}
    22 
     22# work in .EXP directory (in case files will be exported).
     23catch {
     24    cd [file dirname $expnam]
     25}
    2326# get name of script
    2427set expgui(script) [info script]
     
    4245    set graph(legend) [lindex $argv 2]
    4346}
     47set plot_title "(None)"
    4448
    4549set graph(backsub) 0
     
    7983set expgui(fadetime) 10
    8084set expgui(hklbox) 1
    81 set expgui(autotick) 0
     85set expgui(autotick) 1
    8286set expgui(phaselabel) 0
    8387set expgui(pixelregion) 5
     
    358362    }
    359363    ApplyMag
    360     set maxdiff  [set diffvec(max)]
    361     set cmin [set calcvec(min)]
    362     set omin [set obsvec(min)]
    363     set cmax [set calcvec(max)]
    364     set omax [set obsvec(max)]
    365     set expgui(min) [expr {$omin < $cmin ? $omin : $cmin}]
    366     set expgui(max) [expr {$omax > $cmax ? $omax : $cmax}]
    367     set ymin1 [expr {$cmin - 1.1*$maxdiff}]
    368     set ymin2 [expr {$omin - 1.1*$maxdiff}]
    369     if {$ymin1 < $ymin2} {
    370         diffvec set [diffvec + $ymin1]
    371     } {
    372         diffvec set [diffvec + $ymin2]
    373     }
    374364    plotdata
    375365}
     
    454444    }
    455445    ApplyMag
    456     global obsvec calcvec diffvec
    457     set maxdiff  [set diffvec(max)]
    458     set cmin [set calcvec(min)]
    459     set omin [set obsvec(min)]
    460     set cmax [set calcvec(max)]
    461     set omax [set obsvec(max)]
    462     set expgui(min) [expr {$omin < $cmin ? $omin : $cmin}]
    463     set expgui(max) [expr {$omax > $cmax ? $omax : $cmax}]
    464     set ymin1 [expr {$cmin - 1.1*$maxdiff}]
    465     set ymin2 [expr {$omin - 1.1*$maxdiff}]
    466     if {$ymin1 < $ymin2} {
    467         diffvec set [diffvec + $ymin1]
    468     } {
    469         diffvec set [diffvec + $ymin2]
    470     }
    471    
     446    plotdata
     447}
     448
     449proc SetTitle {} {
     450    set bx .title
     451    toplevel $bx
     452    wm title $bx "Edit plot title"
     453    wm iconname $bx "Edit plot title"
     454    grid [label $bx.txt -text "Enter plot title below"] -row 1 -column 1
     455    grid [entry $bx.title -width 70] -row 2 -column 1
     456    grid [frame $bx.a] -row 3 -column 1
     457    grid [button $bx.a.save -text "Save" \
     458              -command "set plot_title \"\[$bx.title get\]\"; destroy $bx" \
     459             ] -row 1 -column 1
     460    grid [button $bx.a.quit -text "Quit" \
     461              -command "destroy $bx" \
     462             ] -row 1 -column 2
     463    putontop $bx
     464    tkwait window $bx
     465    afterputontop
    472466    plotdata
    473467}
     
    575569    global expnam hst peakinfo xunits yunits cycle reflns modtime
    576570    global lasthst graph expgui box
     571    global obsvec calcvec diffvec
     572
     573    if {$graph(yunits) == 2} {
     574        set yunits {Intensity/sigma(I)}
     575        wifdvec set $::weightlist
     576        wifdvec expr sqrt(wifdvec)
     577        obsvec set [obsvec * wifdvec]
     578        calcvec set [calcvec * wifdvec]
     579        bckvec set {}
     580        diffvec set [obsvec - calcvec]
     581        wifdvec set {}
     582        $box element config 1 -label {} -line 0 -hide 1
     583    } else {
     584        $box element config 1 -label bckgr -line 1 -hide 0
     585    }
     586
     587    set cmin [set calcvec(min)]
     588    set omin [set obsvec(min)]
     589    set cmax [set calcvec(max)]
     590    set omax [set obsvec(max)]
     591    set expgui(min) [expr {$omin < $cmin ? $omin : $cmin}]
     592    set expgui(max) [expr {$omax > $cmax ? $omax : $cmax}]
    577593
    578594    foreach p $::expmap(phaselist) {
     
    595611        return
    596612    }
    597     $box config -title "$expnam cycle $cycle Hist $hst"
     613    if {$::plot_title == "(None)"} {
     614        $box config -title "$expnam cycle $cycle Hist $hst"
     615    } else {
     616        $box config -title $::plot_title
     617    }
    598618    $box xaxis config -title $xunits
    599619    $box yaxis config -title $yunits
     
    625645    calcvec notify now
    626646    bckvec notify now
    627     diffvec notify now
    628647    wifdvec notify now
    629648    # now deal with peaks
    630     for {set i 1} {$i < 10} {incr i} {
    631         if {$expgui(autotick)} {
    632             set div [expr {( $expgui(max) - $expgui(min) )/40.}]
    633             set ymin [expr {$expgui(min) - ($i+1) * $div}]
    634             set ymax [expr {$expgui(min) - $i * $div}]
    635         } else {
    636             set ymin $peakinfo(min$i)
    637             set ymax $peakinfo(max$i)
    638         }
    639         set j 0
    640         if [set peakinfo(flag$i)] {
    641             foreach X $reflns($i) {
    642                 incr j
    643                 catch {
    644                     $box marker create line -name peaks${i}_$j
    645                 }
    646                 $box marker config peaks${i}_$j  -under 1 \
    647                         -coords "$X $ymin $X $ymax"
    648                 catch {
    649                     $box marker config peaks${i}_$j \
    650                             $graph(MarkerColorOpt) [list $peakinfo(color$i)]
    651                     if {$peakinfo(dashes$i) && ! $expgui(autotick)} {
    652                         $box marker config peaks${i}_$j -dashes "5 5"
    653                     }
    654                 }
     649    #for {set i 1} {$i < 10} {incr i}
     650    set k 0
     651    set cmin $expgui(min)
     652    foreach i $::expmap(phaselist) {
     653        if {[set peakinfo(flag$i)]} {
     654            incr k
     655            if {$expgui(autotick)} {
     656                set div [expr {( $expgui(max) - $expgui(min) )/40.}]
     657                set ymin [expr {$expgui(min) - ($k+1) * $div}]
     658                set ymax [expr {$expgui(min) - $k * $div}]
     659                if {$cmin > $ymin} {set cmin $ymin}
     660            } else {
     661                set ymin $peakinfo(min$i)
     662                set ymax $peakinfo(max$i)
     663            }
     664            set j 0
     665            foreach X $reflns($i) {
     666                incr j
     667                catch {
     668                    $box marker create line -name peaks${i}_$j
     669                }
     670                $box marker config peaks${i}_$j  -under 1 \
     671                    -coords "$X $ymin $X $ymax"
     672                catch {
     673                    $box marker config peaks${i}_$j \
     674                        $graph(MarkerColorOpt) [list $peakinfo(color$i)]
     675                    if {$peakinfo(dashes$i) && ! $expgui(autotick)} {
     676                        $box marker config peaks${i}_$j -dashes "5 5"
     677                    }
     678                }
    655679            }
    656680            catch {$box element create phase$i}
    657681            catch {
    658682                $box element config phase$i -color $peakinfo(color$i) \
    659                         -label $graph(label$i)
     683                    -label $graph(label$i)
    660684            }
    661685        } else {
     
    664688        }
    665689    }
     690    # offset the difference pattern
     691    set maxdiff  [set diffvec(max)]
     692    if {$expgui(autotick)} {
     693        diffvec set [diffvec + [expr {$cmin - $maxdiff}]]
     694    } else {
     695        diffvec set [diffvec + [expr {$cmin - 1.1*$maxdiff}]]
     696    }
     697    diffvec notify now
     698
    666699    # force an update of the plot as BLT may not
    667700    $box config -title [$box cget -title]
     
    11251158        eval $box y2axis config $graph(ElementHideOption)
    11261159        $box element config 0 -label ""
     1160        # clear the vector
     1161        wifdvec set {}
     1162        wifdvec notify now
    11271163    }
    11281164}
     
    20492085setlegend $box $graph(legend)
    20502086
     2087set ps2pdfcmd {}
     2088set gnuplotpath {}
     2089# find gnuplot
     2090if {$::tcl_platform(platform) == "windows"} {
     2091    set gnuplotpath [file join $::expgui(gsasexe) "gnuplot/gnuplot.exe"]
     2092    if {![file exists $gnuplotpath]} {
     2093        set gnuplotpath [auto_execok gnuplot.exe]
     2094    }
     2095} else {
     2096    set ::env(PATH) "${::expgui(gsasexe)}:${::env(PATH)}"
     2097    auto_reset
     2098    set gnuplotpath [auto_execok gnuplot]
     2099}
     2100# find postscript conversion routine
     2101if {$::tcl_platform(platform) == "windows"} {
     2102    set gspath [file join $command(exedir) "gs/bin/gswin32c.exe"]
     2103    if {![file exists $gspath]} {
     2104        set gspath [auto_execok gswin32c.exe]
     2105    }
     2106    if {[file exists $gspath]} {
     2107        set ps2pdfcmd "$gspath -q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=\"\$pdfoutname\" -c save pop -f \"\$psoutname\""
     2108    }
     2109} else {
     2110    # look for ghostscript
     2111    set gspath [auto_execok gs]
     2112    if {[file exists $gspath]} {
     2113        set ps2pdfcmd "$gspath -q -P- -dSAFER -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=\$pdfoutname -c save pop -f \$psoutname"
     2114    } else {
     2115        set gspath [auto_execok pstopdf]; # this is on Mac only
     2116        if {[file exists $gspath]} {
     2117            set ps2pdfcmd "$gspath \$psoutname -o \$pdfoutname"
     2118        }
     2119    }
     2120}
     2121set gnuplotexport {}
     2122catch {
     2123    source [file join $expgui(scriptdir) gnuplot.tcl]
     2124}
     2125
     2126#======================================================================
     2127# make menus
    20512128frame .a -bd 3 -relief groove
    20522129pack [menubutton .a.file -text File -underline 0 -menu .a.file.menu] -side left
     
    20572134.a.file.menu add command -label "Update Plot" \
    20582135        -command {set cycle [getcycle];readdata .g}
     2136.a.file.menu add command -label "Set Plot Title" \
     2137        -command SetTitle
    20592138.a.file.menu add cascade -label "Export plot" -menu .a.file.menu.export
    20602139menu .a.file.menu.export
     
    20652144    .a.file.menu.export add command -label "to Grace" -command exportgrace
    20662145}
     2146if {$gnuplotpath == {}} {
     2147    .a.file.menu.export add cascade -label "gnuplot program not found"
     2148} elseif {$gnuplotexport == ""} {
     2149    .a.file.menu.export add cascade -label "file gnuplot.tcl not found"
     2150} elseif {$ps2pdfcmd == ""} {
     2151    .a.file.menu.export add cascade -label "gs or pstopdf program not found"
     2152} else {
     2153    .a.file.menu.export add command -label "to PDF" -command ExportPDF
     2154}
     2155
    20672156.a.file.menu add command -label Quit -command "destroy ."
    20682157.a.file.menu.export add command -label "as .csv file" \
     
    20972186set maglist {}
    20982187set mag0 1.0
    2099 # display magnification routines -- not currently in use
     2188# display magnification routines
    21002189proc ShowMag {} {
    21012190    global blt_version tcl_platform peakinfo expgui
     
    22802369}
    22812370
     2371# create a PDF using GNUPLOT & GhostScript
     2372proc ExportPDF {} {
     2373    set msg {}
     2374    if {$::gnuplotpath == {}} {
     2375        append msg "\n\tThe gnuplot program was not found"
     2376    }
     2377    if {$::gnuplotexport == ""} {
     2378        append msg "\n\tfile gnuplot.tcl not found in $::expgui(scriptdir)"
     2379    }
     2380    if {$::ps2pdfcmd == ""} {
     2381        append msg "\n\tNo PDF conversion routine (ghostscript or pstopdf on Mac was found"
     2382    }
     2383    if {$msg != ""} {
     2384        MyMessageBox -parent . -title "Gnuplot/GS Error" \
     2385                -message $msg \
     2386                -icon error -type OK -default OK
     2387        return 0
     2388    }
     2389
     2390    set pdfoutname [tk_getSaveFile -title "Select output file" -parent . \
     2391                        -defaultextension ".pdf" \
     2392                        -initialdir [pwd] \
     2393                        -initialfile "[file rootname $::expnam].pdf"]
     2394    if { $pdfoutname == "" } { return }
     2395    set rootname [file root $pdfoutname]
     2396    set csvoutname "$rootname.csv"
     2397    set gplotname "$rootname.gplot"
     2398    set psoutname "$rootname.ps"
     2399    foreach filename [list $pdfoutname $csvoutname $gplotname $psoutname] {
     2400        catch {file -force delete $filename}
     2401    }
     2402    waitmsg "running gnuplot, Please wait"
     2403    Graph2Gnuplot .g $gplotname $psoutname $csvoutname
     2404    if {![file exists $gplotname]} {
     2405        set msg "\n  Output file for gnuplot not created! ($gplotname)"
     2406    }
     2407    if {![file exists $csvoutname]} {
     2408        append msg "\n   Output file for gnuplot not created! ($csvoutname)"
     2409    }
     2410    if {$msg == ""} {
     2411        if {[catch { exec $::gnuplotpath $gplotname } err]} {
     2412            append msg "Error in running gnuplot: $err"
     2413        }
     2414        if {![file exists $psoutname]} {
     2415            append msg "\n   Output file from gnuplot not created! ($psoutname)"
     2416        }
     2417    }
     2418    if {$msg == ""} {
     2419        if {[catch { eval exec [subst $::ps2pdfcmd]} err]} {
     2420            append msg "Error in PDF conversion: $err"
     2421        }
     2422        if {![file exists $pdfoutname]} {
     2423            append msg "\n   PDF file not created! ($pdfoutname)"
     2424        }
     2425    }
     2426    donewaitmsg
     2427    if {$msg == ""} {
     2428        # clean up
     2429        foreach filename [list $csvoutname $gplotname $psoutname] {
     2430            catch {file -force delete $filename}
     2431        }
     2432        MyMessageBox -parent . -title "PDF created" \
     2433            -message "Success: PDF file created ($pdfoutname)" \
     2434            -type OK -default OK
     2435        return 1
     2436    } else {
     2437        # something failed
     2438        MyMessageBox -parent . -title "Gnuplot/GS Error" \
     2439                -message "Error: $msg" \
     2440                -icon error -type OK -default OK
     2441        return 0
     2442    }
     2443}
     2444
     2445# resize graph font only
     2446proc ResizeGraphFont {graph font} {
     2447    foreach w {legend xaxis yaxis xaxis yaxis \
     2448                   x2axis y2axis x2axis y2axis} \
     2449        o {-font -tickfont -tickfont -titlefont -titlefont \
     2450               -tickfont -tickfont -titlefont -titlefont} {
     2451                   catch {
     2452                       $graph $w configure $o $font
     2453                   }
     2454               }
     2455    catch {
     2456        set curfont [$graph cget -font]
     2457        if {[string tolower [lindex $curfont 0]] == "symbol"} {
     2458            $graph configure -font "Symbol [lrange $font 1 end]"
     2459        } else {
     2460            $graph configure -font $font
     2461        }
     2462    }
     2463}
     2464
    22822465if {$program == "liveplot"} {
    22832466    .a.mag.menu add command -label "Add region" -command "AddMag"
     
    23302513            -variable graph(yunits) -value 1 \
    23312514            -command {set cycle [getcycle];readdata .g}
     2515    .a.options.menu.yunits add radiobutton -label "I/Sigma(I)" \
     2516            -variable graph(yunits) -value 2 \
     2517            -command {set cycle [getcycle];readdata .g}
    23322518    .a.options.menu add command -label "HKL labeling" -command setlblopts
    23332519    .a.options.menu add checkbutton -label "Subtract background" \
     
    23542540}
    23552541if {$program == "liveplot"} {
     2542    .a.options.menu add cascade -menu  .a.options.menu.gfont \
     2543        -label "Graph font"
     2544    menu .a.options.menu.gfont
     2545    foreach f {12 14 16 18 20 22 24 26 28 32 36 40} {
     2546        .a.options.menu.gfont add radiobutton \
     2547            -command "ResizeGraphFont .g \[list Helvetica -$f\]" \
     2548            -label $f -font "Helvetica -$f"
     2549    }
    23562550    .a.options.menu add checkbutton -label "Raise on update" \
    23572551            -variable graph(autoraise)
     
    25132707expload $expnam.EXP
    25142708mapexp
    2515 
     2709if {$expgui(autotick)} {
     2710    foreach i $::expmap(phaselist) {
     2711        set peakinfo(flag$i) 1
     2712    }
     2713}
     2714       
    25162715# fill the histogram menu
    25172716if {[llength $expmap(powderlist)] > 15} {
Note: See TracChangeset for help on using the changeset viewer.