\(\renewcommand\AA{\text{Å}}\)
19. GSAS-II Misc Scripts
19.1. testDeriv: Check derivative computation
Use this to check derivatives used in structure least squares refinement against numerical values computed in this script.
To use set DEBUG=True
in GSASIIstrMain.py (line 40, as of version
2546); run the least squares - zero cycles is sufficient. Do the “Save
Results”; this will write the file testDeriv.dat in the local
directory.
Then run this program to see plots of derivatives for all parameters refined in the last least squares. Shown will be numerical derivatives generated over all observations (including penalty terms) and the corresponding analytical ones produced in the least squares. They should match. Profiling is also done for function calculation & for the 1st selected derivative (rest should be the same).
19.2. GSASIItestplot: Plotting for testDeriv
Plotting module used for script testDeriv.
19.3. scanCCD: reduce data from scanning CCD
Quickly prototyped routine for reduction of data from detector described in B.H. Toby, T.J. Madden, M.R. Suchomel, J.D. Baldwin, and R.B. Von Dreele, “A Scanning CCD Detector for Powder Diffraction Measurements”. Journal of Applied Crystallography. 46(4): p. 1058-63 (2013). This is no longer being updated.
19.4. makeMacApp: Create MacOS Applet
This script creates an AppleScript app bundle to launch GSAS-II. It is called by bootstrap.py during the GSAS-II installation process. It creates a “copy” of Python that is able to run wx.Python programs and names this version of Python as GSAS-II so that items in the menus are named correctly.
This routine creates an app bundle named GSAS-II.app. Inside the bundle is a symbolic link to the Python executable named “GSAS-II” that will be used to run GSAS-II. Having this link named that way causes the name of the app to shows in the menu bar as “GSAS-II” rather than “Python”. Also used by the app, is another symbolic link named GSAS-II.py, which must be placed in the same directory as the app bundle. This file is linked to the G2.py script and the link is run using the link to Python. This also causes other items in the app to be labeled as GSAS-II (but not with the right capitalization, alas).
The original contents of the app bundle was created interactively and, after some manual edits, the contents of that was placed into a tar file distributed with GSAS-II, and is expanded in this script. This method seems to be needed for MacOS 11.0+ (Big Sur and later) where Apple’s security constraints seem to prevent creation of the app directly. Older code (not currently in use) created the app from “scratch” using the osacompile utility, but that no longer seems to work.
Three different paths are needed to run this script:
path2GSAS: The location where the GSAS-II Python files are found.
installLoc: The location where the GSAS-II.app app bundle and
the GSAS-II.py will be placed. This will be the parent of path2GSAS
pythonLoc: The location of the Python executable.
Under normal circumstances, the locations for all of these paths can be determined from the location of the makeMacApp.py file. Note that when GSAS-II is installed from git using gitstrap.py, the git repository is placed at <loc>/GSAS-II and the GSAS-II Python scripts are placed in the <loc>/GSAS-II/GSASII child directory. GSAS-II is started from the <loc>/GSAS-II/GSAS-II.py script created here and the current script (makeMacApp.py) will be found in <loc>/GSAS-II/GSASII/install/.
When the GSAS-II conda installers are used, the git repository is placed at $CONDA_HOME/GSAS-II so that <loc> above is $CONDA_HOME. Also, the Python executable will be found in $CONDA_HOME/bin/Python. Thus, if this file is in makePath (typically <loc>/GSAS-II/GSASII/install), then
path2GSAS will be makePath/.. and
installLoc will be path2GSAS/.. and
pythonLoc will be installLoc/../bin/python,
but these locations can be overridden from the command-line arguments. If a Python location is not supplied and is not at the default location (installLoc/../bin/python) then the Python executable currently running this script (from sys.executable) is used.
Run this script with no arguments or with one or two arguments.
The first argument, if supplied, provides the path to be used for the app bundle will be created. Note that GSAS-II.app and GSAS-II.py will be created in this directory.
The second argument, if supplied, is path2GSAS, a path to the location G2.py script, which can be a relative path (the absolute path is determined). If not supplied, the G2.py script is expected to be located in the directory above where this (makeMacApp.py) script is found.
The third argument, if supplied, provides the full path for the Python installation to be used inside the app bundle that will be created. If not supplied, and Python exists at installLoc/../bin/python, that will be used. If that does not exist, then the location of the current Python executable (from sys.executable) will be used.
- GSASII.install.makeMacApp.AppleScript = ''
Will be set to contain an AppleScript to start GSAS-II by launching Python and the GSAS-II Python script. Not currently used.
19.5. makeBat: Create GSAS-II Batch File
This script performs Windows specific installation steps to allow for easy launching of GSAS-II. It is called by bootstrap.py during the GSAS-II installation process.
This script creates a file named RunGSASII.bat
and a desktop shortcut to that file.
It registers the filetype .gpx so that the GSAS-II project files exhibit the
GSAS-II icon and so that double-clicking on them opens them in GSAS-II.
Run this script with no arguments; the path to the G2.py
file
is assumed to be in the parent directory to the one where this file
(makeBat.py
) is found.
The contents of this file may also be run from inside the gitstrap.py installation script. In that case, the following variables are already defined:
path2GSAS2 is the directory with all GSAS-II Python code
G2script has the location of the G2.py file
path2repo is the location of the GSAS-II git repository
The path to Python is determined from the version of Python used to run this script.
19.6. makeLinux: Create Linux Shortcuts
This script performs Linux specific installation steps that allowscreates files allowing GSAS-II to be launched from a desktop icon or desktop manager menu. Not all desktop managers will recognize these files. It is called by bootstrap.py during the GSAS-II installation process.
This script creates a menu entry and dektop shortcut for Gnome (and perhaps KDE) desktop managers. The most recent testing has been on Raspberry Pi OS. My hope is to improve this further to work conveniently with a wider range of Linux desktop managers.
Run this script with one optional argument, the location of the G2.py
file. That location may be specified relative to the current path or given
an absolute path, but will be accessed via an absolute path.
If no arguments are supplied, the path to the G2.py
file
is assumed to be in the parent directory to the one where this file
(makeLinux.py
) is found.
The contents of this file may also be run from inside the gitstrap.py installation script. In that case, the following variables are already defined:
path2GSAS2 is the directory with all GSAS-II Python code
G2script has the location of the G2.py file
path2repo is the location of the GSAS-II git repository
The path to Python is determined from the version of Python used to run this script.
19.7. makeVarTbl: Make Table of Variable Names
This creates a table of variable names from the definitions supplied
in GSASIIobj.CompileVarDesc()
. This table is used in the
Sphinx documentation as the GSAS-II Variable Names table.
This is run as part of the Sphinx build from inside docs/source/conf.py
.
19.8. testSytSym: Test Site Symmetry
A GUI program for testing the site symmetry generation routines.
19.9. testSSymbols: Test Superspace Group Symbols
A GUI program for testing the 3+1 superspace group symmetry generation routines.
19.10. Self-test Modules
A set of scripts that can be run to test a series of self-tests in GSAS-II.
19.10.1. test_diffax.py
Performs a DIFFaX computation using the GSAS-II interface to the pydiffax.so [.pyd] module
19.10.2. test_elm.py
Performs a very simple test on the element tables.
19.10.3. test_image.py
Performs tests that image integration and pixel masking are working. Also tests the imports that require GSAS-II-compiled binaries.
- tests.test_image.test_image()[source]
Read in a MAR image (tests pack_f binary module) and then integrate it using GeneratePixelMask (tests fmask binary module)
19.10.4. test_kvec.py
Performs a series of tests on the k-vector search code.
- tests.test_kvec.test_KVecCandidateUpdate()[source]
self-test #3: test the updating of the list of alternative k vectors
- tests.test_kvec.test_LatConstruct()[source]
self-test #1: test the lattice vectors construction routine
19.10.5. test_lattice.py
Performs comprehensive unit tests for many but by no means all
routines in GSASIIlattice
.
- tests.test_lattice.selftestlist = [<function test_gmat>, <function test_Avec>, <function test_2cell>, <function test_invcell>, <function test_V>, <function test_2AB>, <function test_Brav>, <function test_Laue>]
Defines a list of self-tests
19.10.6. test_nistlat.py
Tests the two NIST*LATTICE binaries, LATTIC and convcell using their Python wrappers in module nistlat.py
19.10.7. test_scriptref.py
Performs a CW GSAS-II refinement using GSASIIscriptable and tutorial data. Tests texture code as well.
- tests.test_scriptref.test_refine()[source]
Performs a GSAS-II refinement using GSASIIscriptable and tutorial data
19.10.8. test_spg.py
Unit tests for code in GSASIIspc.py. Also exercises the pyspg Fortran routine.
- tests.test_spg.selftestlist = [<function test_MoveToUnitCell>, <function test_SpcGroup1>, <function test_SpcGroup2>, <function test_SytSym>]
Defines a list of self-tests
- tests.test_spg.test_SytSym()[source]
self-test #3: exercise SytSym against selected data from IT Volume A
19.10.9. test_tofref.py
Perform a TOF GSAS-II refinement using GSASIIscriptable and tutorial data. This tests the TOF diffraction code and that Marquardt damping works.
19.11. Other scripts
A few scripts are also placed in the GSAS-II auxiliary repositories
19.11.1. gitstrap.py
gitstrap.py
inGSASII-buildtools/install/
is used to install the GSAS-II package, including the appropriate binary files. May be used directly to install GSAS-II from inside Python in an appropriately configured Python installation, or is also used to obtain or update the GSAS-II files in a conda installation.
19.11.2. gitcompile.py
gitcompile.py
inGSASII-buildtools/install/
is used to install the GSAS-II package, but also compiles the binary files. May be used directly to install GSAS-II from inside Python in an appropriately configured Python installation.
19.11.3. makeGitTutorial.py
makeGitTutorial.py
inGSASII-tutorials/scripts/
provides a script to creates the HTML page (GSASII/help/Tutorials.html
) that lists all the tutorials defined in variableGSASIIctrlGUI.tutorialIndex
. Run this after adding new tutorials to that catalog.
19.11.4. tag-version.py
tag-version.py
inGSASII/install/
creates a new numerical tag number (advancing from5898
to5899
) for the most recent git check in and records that in thegit_version.py
file. This also advances the minor version number for the GSAS-II version number (from5.x.y
to5.(x+1).0
). Use this when there is a significant change to GSAS-II functionality.
19.11.5. incr-mini-version.py
incr-mini-version.py
inGSASII/install/
creates a new numerical tag number (advancing from5898
to5899
) for the most recent git check in and records that in thegit_version.py
file. This also advances the “mini” version number for the GSAS-II version number (from5.x.y
to5.x.(y+1)
). Use this to note a minor by noteworthy change to GSAS-II functionality, such as a bug fix where users should be aware that something has changed.
19.11.6. macStartScript.py
macStartScript.py
inGSASII/install/
creates a MacOS applet to start GSAS-II similar to what is inmakeMacApp.py
(where the app is taken from a tar file). This is not in regular use, as it seems to have some permissions problems, but may be needed to updatemakeMacApp.py
.