16. GSAS-II Misc Scripts

16.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]
class testDeriv.testDerivmain(*args, **kwargs)[source]

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

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

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(*args, **kwargs)[source]

16.4. makeMacApp: Create Mac Applet

This script creates an AppleScript app bundle to launch GSAS-II. The app is 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

16.5. makeBat: Create GSAS-II Batch File

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.

16.6. makeLinux: Create Linux Shortcuts

This script creates a menu entry for Gnome & KDE desktop managers and puts it in a place where it can be “indexed.”

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.

16.7. makeTutorial: Make Tutorial Web Page

Creates an HTML page (GSASII/help/Tutorials.html) listing all the tutorials in GSASIIctrlGUI.tutorialIndex. Run this after adding a new tutorial to that index.

makeTutorial.onlineVideos = ['https://anl.box.com/v/CalibrationofanareadetectorinG', 'https://anl.box.com/v/CalibrationTutorial', 'https://anl.box.com/v/CalibrationofaTOFpowderdiffrac', 'https://anl.box.com/v/Combinedrefinement', 'https://anl.box.com/v/TOFcombinedXNRietveldrefinemen', 'https://anl.box.com/v/NeutronCWPowderData', 'https://anl.box.com/v/FindProfParamCW', 'https://anl.box.com/v/DeterminingWavelength', 'https://anl.box.com/v/FitPeaks----', 'https://anl.box.com/v/LaboratoryX-', 'https://anl.box.com/v/FittingSmallAngleScatteringDat', 'https://anl.box.com/v/FitBkgTut---', 'https://anl.box.com/v/SmallAngleImageProcessing', 'https://anl.box.com/v/Integrationofareadetectordatai', 'https://anl.box.com/v/MerohedraltwinrefinementinGSAS', 'https://anl.box.com/v/ParametricFitting', 'https://anl.box.com/v/SequentialRefinementofSmallAng', 'https://anl.box.com/v/SequentialTutorial', 'https://anl.box.com/v/SimpleMagnetic', 'https://anl.box.com/v/SimTutorial-', 'https://anl.box.com/v/SmallAngleSizeDistribution', 'https://anl.box.com/v/StackingFaults-I', 'https://anl.box.com/v/StartingGSAS', 'https://anl.box.com/v/Strainfittingof2DdatainGSAS-II', 'https://anl.box.com/v/Textureanalysisof2DdatainGSAS-', 'https://anl.box.com/v/TOFSequentialSinglePeakFit', 'https://anl.box.com/v/RigidBodyRef']

a list of videos that are in box, since I don’t know how to check if they are present anymore

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

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.