\(\renewcommand\AA{\text{Å}}\)

17. GSAS-II Misc Scripts

17.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).

testDeriv.main()[source]

Starts main application to compute and plot derivatives

class testDeriv.testDeriv(parent)[source]

17.2. GSASIItestplot: Plotting for testDeriv

Plotting module used for script testDeriv.

class GSASIItestplot.Plot(parent, id=-1, dpi=None, **kwargs)[source]

Creates a plotting window

class GSASIItestplot.PlotNotebook(id=-1)[source]

creates a Wx application and a plotting notebook

Show(show=True) bool[source]

Shows or hides the window.

17.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.

scanCCD.main()[source]

starts main application to merge data from scanning CCD

class scanCCD.scanCCD(parent)[source]
PlotXY(XY, newPlot=False, type='')[source]

simple plot of xy data, used for diagnostic purposes

class scanCCD.scanCCDmain(redirect=False, filename=None, useBestVisual=False, clearSigInt=True)[source]
OnInit(self) bool[source]

17.4. makeMacApp: Create Mac 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 GSASII.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 GSASII.py (and other GSAS-II 
   Python files) are found. 
installLoc: The location where the GSAS-II.app app bundle and 
   the GSAS-II.py will be placed.
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 at the GSASII child directory, so that GSAS-II is started from the GSASII.py script at <loc>/GSAS-II/GSASII/ 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 GSASII.py script, which can be a relative path (the absolute path is determined). If not supplied, the GSASII.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.

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.

17.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 GSASII.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 GSASII.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.

17.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 GSASII.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 GSASII.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 GSASII.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.

17.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.

17.8. unit_tests: Self-test Module

A script that can be run to test a series of self-tests in GSAS-II.

At present, only modules GSASIIspc and GSASIIlattice have self-tests and these have not been tested or updated in many, many years.

unit_tests.test_GSASIIlattice()[source]

Test registered self-tests in GSASIIlattice. Takes no input and returns nothing. Throws an Exception if a test fails.

unit_tests.test_GSASIIspc()[source]

Test registered self-tests in GSASIIspc. Takes no input and returns nothing. Throws an Exception if a test fails.

17.9. testSytSym: Test Site Symmetry

A GUI program for testing the site symmetry generation routines.

testSytSym.main()[source]

Starts main application to compute and plot derivatives

class testSytSym.testSytSmain(redirect=False, filename=None, useBestVisual=False, clearSigInt=True)[source]
OnInit(self) bool[source]
class testSytSym.testSytSym(parent)[source]

17.10. testSSymbols: Test Superspace Group Symbols

A GUI program for testing the 3+1 superspace group symmetry generation routines.

testSSymbols.main()[source]

Starts main application to compute and plot derivatives

class testSSymbols.testSSmain(redirect=False, filename=None, useBestVisual=False, clearSigInt=True)[source]
OnInit(self) bool[source]
class testSSymbols.testSSymbols(parent)[source]

17.11. Other scripts

A few scripts are also placed in the GSAS-II auxiliary repositories

GSASII-buildtools/install/gitstrap.py

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.

GSASII-buildtools/install/setgitversion.py

Used during the gsas2full (& gsas2complete) build process to modify the g2complete & g2full .template files to reflect the versions of Python & packages that should be used for builds.

GSASII-tutorials/scripts/makeGitTutorial.py

Provides a script to creates the HTML page (GSASII/help/Tutorials.html) that lists all the tutorials defined in variable GSASIIctrlGUI.tutorialIndex. Run this after adding new tutorials to that catalog.