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


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.


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, usually created in the directory where the GSAS-II script (…/GSASII/GSASII.py) is located. A softlink to Python is created inside that app bundle, but the softlink name is GSAS-II so that “GSAS-II” shows up as the name of the app in the menu bar, etc. rather than “Python”. A soft link named GSAS-II.py, referencing the GSASII.py script, is created so that some file menu items also are labeled with GSAS-II (but not the right capitalization, alas).

This can be used two different ways.

  1. In the usual way, for conda-type installations where Python is in <condaroot>/bin and GSAS-II is in <condaroot>/GSASII, a premade app is restored from a tar file. This works best for 11.0 (Big Sur) where there are security constraints in place.

  2. If Python is not in that location or a name/location is specified for the app that will be created, this script creates an app (AppleScript) with the GSAS-II and the python locations hard coded. When an AppleScript is created, this script tests to make sure that a wxpython script will run inside the app and if not, it searches for a pythonw image and tries that.

This has been tested with several versions of Python interpreters from Anaconda and does not require pythonw (Python.app).

Run this script with no arguments or with one or two arguments.

The first argument, if supplied, is a reference to the GSASII.py script, which can have a relative or absolute path (the absolute path is determined). If not supplied, the GSASII.py script will be used from the directory where this (makeMacApp.py) script is found.

The second argument, if supplied, provides the name/location for the app to be created. This can be used to create multiple app copies using different Python versions (likely use for development only). If the second argument is used, the AppleScript is created rather than restored from g2app.tar.gz

makeMacApp.AppleScript = ''

Contains an AppleScript to start GSAS-II, launching Python and the GSAS-II python script.

makeMacApp.RunPython(image, cmd)[source]

Run a command in a python image

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 the the same as the path to the makeBat.py file and 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. Recent testing on Raspbian.

This is a work in progress as I learn more about shortcuts in Linux.

Run this script with one optional argument, the path to the GSASII.py. The script path 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 GSASII.py script is assumed to be in the same directory as this file.

17.7. makeTutorial: Make Tutorial Web Page

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

makeTutorial.onlineVideos = []

a list of videos that are in box.com, since I don’t know how to retrieve this automatically any more.

17.8. makeVarTbl: Make Variables Table

This creates a table of variable names from the definitions supplied in GSASIIobj.CompileVarDesc() which is used as input for the Sphinx documentation (in the GSAS-II Variable Names table). This is run as part of the Sphinx build from inside docs/source/conf.py.

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


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


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

17.10. testSytSym: Test Site Symmetry

A GUI program for testing the site symmetry generation routines.


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.11. testSSymbols: Test Superspace Group Symbols

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


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]