4. GSAS-II Utility Modules

4.1. GSASIIpath: locations & updates

Routines for dealing with file locations, etc.

Determines the location of the compiled (.pyd or .so) libraries.

Interfaces with subversion (svn): Determine the subversion release number by determining the highest version number where SetVersionNumber() is called (best done in every GSASII file). Other routines will update GSASII from the subversion server if svn can be found.

Accesses configuration options, as defined in config.py

GSASIIpath.DoNothing()[source]

A routine that does nothing. This is called in place of IPyBreak and pdbBreak except when the debug option is set True in config.py

GSASIIpath.DownloadG2Binaries(g2home, verbose=True)[source]

Download GSAS-II binaries from appropriate section of the GSAS-II svn repository based on the platform, numpy and Python version

GSASIIpath.GetConfigValue(key, default=None)[source]

Return the configuration file value for key or a default value if not present

Parameters:
  • key (str) – a value to be found in the configuration (config.py) file
  • default – a value to be supplied is none is in the config file or the config file is not found. Defaults to None
Returns:

the value found or the default.

GSASIIpath.GetVersionNumber()[source]

Return the maximum version number seen in SetVersionNumber()

GSASIIpath.IPyBreak()

A routine that does nothing. This is called in place of IPyBreak and pdbBreak except when the debug option is set True in config.py

GSASIIpath.IPyBreak_base(userMsg=None)[source]

A routine that invokes an IPython session at the calling location This routine is only used when debug=True is set in config.py

GSASIIpath.InvokeDebugOpts()[source]

Called in GSASII.py to set up debug options

GSASIIpath.LoadConfigFile(filename)[source]

Read a GSAS-II configuration file. Comments (starting with “%”) are removed, as are empty lines

Parameters:filename (str) – base file name (such as ‘file.dat’). Files with this name are located from the path and the contents of each are concatenated.
Returns:a list containing each non-empty (after removal of comments) line found in every matching config file.
GSASIIpath.MacRunScript(script)[source]

Start a bash script in a new terminal window. Used on Mac OS X only.

Parameters:script (str) – file name for a bash script
GSASIIpath.MacStartGSASII(g2script, project='')[source]

Start a new instance of GSAS-II by opening a new terminal window and starting a new GSAS-II process. Used on Mac OS X only.

Parameters:
  • g2script (str) – file name for the GSASII.py script
  • project (str) – GSAS-II project (.gpx) file to be opened, default is blank which opens a new project
GSASIIpath.MakeByte2str(arg)[source]

Convert output from subprocess pipes (bytes) to str (unicode) in Python 3. In Python 2: Leaves output alone (already str). Leaves stuff of other types alone (including unicode in Py2) Works recursively for string-like stuff in nested loops and tuples.

typical use:

out = MakeByte2str(out)

or:

out,err = MakeByte2str(s.communicate())
GSASIIpath.SetBinaryPath(printInfo=False, loadBinary=True)[source]

Add location of GSAS-II shared libraries (binaries: .so or .pyd files) to path

This routine must be executed after GSASIIpath is imported and before any other GSAS-II imports are done.

GSASIIpath.SetConfigValue(parmdict)[source]

Set configuration variables from a dictionary where elements are lists First item in list is the default value and second is the value to use.

GSASIIpath.SetVersionNumber(RevString)[source]

Set the subversion version number

Parameters:RevString (str) – something like “$Revision: 4994 $” that is set by subversion when the file is retrieved from subversion.

Place GSASIIpath.SetVersionNumber("$Revision: 4994 $") in every python file.

GSASIIpath.TestSPG(fpth)[source]

Test if pyspg.[so,.pyd] can be run from a location in the path

GSASIIpath.addPrevGPX(fil, configDict)[source]

Add a GPX file to the list of previous files. Move previous names to start of list. Keep most recent five files

GSASIIpath.exceptHook(*args)[source]

A routine to be called when an exception occurs. It prints the traceback with fancy formatting and then calls an IPython shell with the environment of the exception location.

This routine is only used when debug=True is set in config.py

GSASIIpath.findConda()[source]

Determines if GSAS-II has been installed as g2conda or gsas2full with conda located relative to this file. We could also look for conda relative to the python (sys.executable) image, but I don’t want to muck around with python that someone else installed.

GSASIIpath.g2home = 'https://subversion.xray.aps.anl.gov/pyGSAS'

Define the location of the GSAS-II subversion repository

GSASIIpath.getsvnProxy()[source]

Loads a proxy for subversion from the proxyinfo.txt file created by bootstrap.py or File => Edit Proxy…; If not found, then the standard http_proxy and https_proxy environment variables are scanned (see https://docs.python.org/3/library/urllib.request.html#urllib.request.getproxies) with case ignored and that is used.

GSASIIpath.pdbBreak()

A routine that does nothing. This is called in place of IPyBreak and pdbBreak except when the debug option is set True in config.py

GSASIIpath.proxycmds = []

Used to hold proxy information for subversion, set if needed in whichsvn

GSASIIpath.runScript(cmds=[], wait=False, G2frame=None)[source]

run a shell script of commands in an external process

Parameters:
  • cmds (list) – a list of str’s, each ietm containing a shell (cmd.exe or bash) command
  • wait (bool) – if True indicates the commands should be run and then the script should return. If False, then the currently running Python will exit. Default is False
  • G2frame (wx.Frame) – provides the location of the current .gpx file to be used to restart GSAS-II after running the commands, if wait is False. Default is None which prevents restarting GSAS-II regardless of the value of wait.
GSASIIpath.setsvnProxy(host, port, etc=[])[source]

Sets the svn commands needed to use a proxy

GSASIIpath.svnChecksumPatch(svn, fpath, verstr)[source]

This performs a fix when svn cannot finish an update because of a Checksum mismatch error. This seems to be happening on OS X for unclear reasons.

GSASIIpath.svnCleanup(fpath='/home/docs/checkouts/readthedocs.org/user_builds/gsas-ii/checkouts/latest', verbose=True)[source]

This runs svn cleanup on a selected local directory.

Parameters:fpath (str) – path to repository dictionary, defaults to directory where the current file is located
GSASIIpath.svnFindLocalChanges(fpath='/home/docs/checkouts/readthedocs.org/user_builds/gsas-ii/checkouts/latest')[source]
Returns a list of files that were changed locally. If no files are changed,
the list has length 0
Parameters:fpath – path to repository dictionary, defaults to directory where the current file is located
Returns:None if there is a subversion error (likely because the path is not a repository or svn is not found)
GSASIIpath.svnGetFileStatus(fpath='/home/docs/checkouts/readthedocs.org/user_builds/gsas-ii/checkouts/latest', version=None)[source]

Compare file status to repository (svn status -u)

Returns:updatecount,modcount,locked where updatecount is the number of files waiting to be updated from repository modcount is the number of files that have been modified locally locked is the number of files tagged as locked
GSASIIpath.svnGetLog(fpath='/home/docs/checkouts/readthedocs.org/user_builds/gsas-ii/checkouts/latest', version=None)[source]

Get the revision log information for a specific version of the specified package

Parameters:
  • fpath (str) – path to repository dictionary, defaults to directory where the current file is located.
  • version (int) – the version number to be looked up or None (default) for the latest version.
Returns:

a dictionary with keys (one hopes) ‘author’, ‘date’, ‘msg’, and ‘revision’

GSASIIpath.svnGetRev(fpath='/home/docs/checkouts/readthedocs.org/user_builds/gsas-ii/checkouts/latest', local=True)[source]

Obtain the version number for the either the last update of the local version or contacts the subversion server to get the latest update version (# of Head).

Parameters:
  • fpath (str) – path to repository dictionary, defaults to directory where the current file is located
  • local (bool) – determines the type of version number, where True (default): returns the latest installed update False: returns the version number of Head on the server
Returns:

the version number as an str or None if there is a subversion error (likely because the path is not a repository or svn is not found). The error message is placed in global variable svnLastError

GSASIIpath.svnInstallDir(URL, loadpath)[source]

Load a subversion tree into a specified directory

Parameters:
  • URL (str) – the repository URL
  • loadpath (str) – path to locate files
GSASIIpath.svnList(URL, verbose=True)[source]

Get a list of subdirectories from and svn repository

GSASIIpath.svnLocCache = None

Cached location of svn to avoid multiple searches for it

GSASIIpath.svnSwitch2branch(branch=None, loc=None, svnHome=None)[source]

Switch to a subversion branch if specified. Switches to trunk otherwise.

GSASIIpath.svnSwitchDir(rpath, filename, baseURL, loadpath=None, verbose=True)[source]

This performs a switch command to move files between subversion trees. Note that if the files were previously downloaded, the switch command will update the files to the newest version.

Parameters:
  • rpath (str) – path to locate files, relative to the GSAS-II installation path (defaults to path2GSAS2)
  • URL (str) – the repository URL
  • loadpath (str) – the prefix for the path, if specified. Defaults to path2GSAS2
  • verbose (bool) – if True (default) diagnostics are printed
GSASIIpath.svnUpdateDir(fpath='/home/docs/checkouts/readthedocs.org/user_builds/gsas-ii/checkouts/latest', version=None, verbose=True)[source]

This performs an update of the files in a local directory from a server.

Parameters:
  • fpath (str) – path to repository dictionary, defaults to directory where the current file is located
  • version – the number of the version to be loaded. Used only cast as a string, but should be an integer or something that corresponds to a string representation of an integer value when cast. A value of None (default) causes the latest version on the server to be used.
GSASIIpath.svnUpdateProcess(version=None, projectfile=None, branch=None)[source]

perform an update of GSAS-II in a separate python process

GSASIIpath.svnUpgrade(fpath='/home/docs/checkouts/readthedocs.org/user_builds/gsas-ii/checkouts/latest')[source]

This reformats subversion files, which may be needed if an upgrade of subversion is done.

Parameters:fpath (str) – path to repository dictionary, defaults to directory where the current file is located
GSASIIpath.svnVersion(svn=None)[source]

Get the version number of the current subversion executable

Returns:a string with a version number such as “1.6.6” or None if subversion is not found.
GSASIIpath.svnVersionNumber(svn=None)[source]

Get the version number of the current subversion executable

Returns:a fractional version number such as 1.6 or None if subversion is not found.
GSASIIpath.whichsvn()[source]

Returns a path to the subversion exe file, if any is found. Searches the current path after adding likely places where GSAS-II might install svn.

Returns:None if svn is not found or an absolute path to the subversion executable file.

4.2. GSASIIlog: Logging of “Actions”

Module to provide logging services, e.g. track and replay “actions” such as menu item, tree item, button press, value change and so on.

This capability is not currently implemented, but might be resurrected in some future version of GSAS-II.

GSASIIlog.ButtonBindingLookup = {}

Lookup table for button objects

class GSASIIlog.ButtonLogEntry(locationcode, label)[source]

Object to track button press

GSASIIlog.G2logList = [None]

Contains a list of logged actions; first item is ignored

GSASIIlog.InvokeMenuCommand(id, G2frame, event)[source]

Called when a menu item is used to log the action as well as call the routine “bind”ed to that menu item

class GSASIIlog.LogEntry[source]

Base class to define logging objects. These store information on events in a manner that can be pickled and saved – direct references to wx objects is not allowed.

Each object must define:

  • __init__: stores the information needed to log & later recreate the action
  • __str__ : shows a nice ASCII string for each action
  • Replay: recreates the action when the log is played

optional:

  • Repaint: redisplays the current window
GSASIIlog.LogInfo = {'LastPaintAction': None, 'Logging': False, 'Tree': None}

Contains values that are needed in the module for past actions & object location

GSASIIlog.LogOff()[source]

Turn Off logging of actions

GSASIIlog.LogOn()[source]

Turn On logging of actions

GSASIIlog.LogVarChange(result, key)[source]

Called when a variable is changed to log that action

GSASIIlog.MakeButtonLog(locationcode, label)[source]

Create a ButtonLogEntry action log

GSASIIlog.MakeTabLog(title, tabname)[source]

Create a TabLogEntry action log

GSASIIlog.MakeTreeLog(textlist)[source]

Create a TreeLogEntry action log

GSASIIlog.MenuBindingLookup = {}

Lookup table for Menu buttons

class GSASIIlog.MenuLogEntry(menulabellist)[source]

object that tracks when a menu command is executed

Replay()[source]

Perform a Menu item action when read from the log

GSASIIlog.OnReplayPress(event)[source]

execute one or more commands when the replay button is pressed

GSASIIlog.ReplayLog(event)[source]

replay the logged actions

GSASIIlog.SaveMenuCommand(id, G2frame, handler)[source]

Creates a table of menu items and their pseudo-bindings

GSASIIlog.ShowLogStatus()[source]

Return the logging status

class GSASIIlog.TabLogEntry(title, tabname)[source]

Object to track when tabs are pressed in the DataFrame window

Repaint()[source]

Used to redraw a window created in response to a Tab press

Replay()[source]

Perform a Tab press action when read from the log

class GSASIIlog.TreeLogEntry(itemlist)[source]

Object to track when tree items are pressed in the main window

Repaint()[source]

Used to redraw a window created in response to a click on a data tree item

Replay()[source]

Perform a Tree press action when read from the log

class GSASIIlog.VarLogEntry(treeRefs, indexRefs, value)[source]

object that tracks changes to a variable

Replay()[source]

Perform a Variable Change action, when read from the log

class GSASIIlog.dictLogged(obj, treeRefs, indexRefs=[])[source]

A version of a dict object that tracks the source of the object back to the location on the G2 tree. If a list (tuple) or dict are pulled from inside this object the source information is appended to the provinance tracking lists.

tuples are converted to lists.

class GSASIIlog.listLogged(obj, treeRefs, indexRefs=[])[source]

A version of a list object that tracks the source of the object back to the location on the G2 tree. If a list (tuple) or dict are pulled from inside this object the source information is appended to the provinance tracking lists.

tuples are converted to lists.

4.3. config_example.py: Configuration options

This file contains optional configuration options for GSAS-II. The variables in this file can be copied to file config.py, which is imported if present. Access these variables using GSASIIpath.GetConfigValue(), which returns None if the variable is not set. Note that a config.py file need not be present, but if in use it will typically be found with the GSAS-II source directory (GSASIIpath.Path2GSAS2) or a directory for local GSAS-II modifications (~/.G2local/ or /Documents and Settings/<User>/.G2local/). Note that the contents of config.py is usually changed using GSASIIctrlGUI.SelectConfigSetting.

When defining new config variables for GSAS-II, define them here with a default value: use None or a string for strings, or use integers or real values. Include a doc string after each variable is defined to explain what it does. Use names ending in _location or _directory for items that will contain directory names. Use names ending in _exec for executable files (.exe on windows).

For example:

test_int = 0
test_float = 0.0
test_string = None (or)
test_string = 'value'
config_example.Arc_mask_azimuth = 10.0

Specifies the default azimuthal range for creation of arc masks. Default is 10.0 degrees 2-theta.

config_example.Autoint_PollTime = 30.0

Specifies the frequency, in seconds that AutoInt checks for new files. Default is 30 seconds

config_example.Autoscale_ParmNames = ['userComment2', 'extraInputs\\1\\extraInputs', 'Ion_Chamber_I0']

Gives the possible selection of incident monitor names as found in an image metadata file. Used in AutoIntegration

config_example.Clip_on = True

if True then line plots willl be clipped at plot border; if False line plots extend nto white space around plot frme

config_example.Column_Metadata_directory = None

When specified and when images are read, GSAS-II will read metadata from a 1-ID style .par and a .EXT_lbls (EXT = image extension) or .lbls file. See GSASIIfiles.readColMetadata() for information on how this is done.

config_example.Contour_color = 'Paired'

Specifies the color map to be used for contour plots (images, pole figures, etc.) will be applied for new images and if Saved for a new start of GSAS-II

config_example.DefaultAutoScale = 'userComment2'

DefaultAutoScale selects one of the AutoScale_ParmNames. Used in AutoIntegration

config_example.DrawAtoms_default = ''

Allows selection of the default plotting mode for structures in Draw Atoms. The only valid values are: ‘lines’, ‘vdW balls’, ‘sticks’, ‘balls & sticks’, ‘ellipsoids’. %% If a non-valid choice is used (the default) ‘vdW balls’ is used.

config_example.Enable_logging = False

Set to True to enable use of command logging (under development.)

config_example.Help_mode = 'browser'

Set to “internal” to use a Python-based web viewer to display help documentation and tutorials. If set to the default (“browser”) the default web browser is used.

config_example.Image_2theta_max = 50.0

Specifies a default 2-theta maximum used for calibration and integration as the Outer 2-theta value. Will be applied for newly-read images, but if changed the new value will be saved.

config_example.Image_2theta_min = 5.0

Specifies a default 2-theta minimum used for calibration and integration as the Inner 2-theta value. Will be applied for newly-read images, but if changed the new value will be saved.

config_example.Image_calibrant = ''

Specifies a default calibrant material for images. Will be applied for newly-read images, but if changed the specified material will be saved.

config_example.Import_directory = None

Specifies a default location for importing (reading) input files. Will be updated if Save_paths is True. Note that os.path.expanduser is run on this before it is used, so the user’s home directory can be specified with a ‘~’.

config_example.Instprm_default = False

when True, GSAS-II instprm file are shown as default; when False, old GSAS stype prm, etc files are default

config_example.Main_Pos = '(100,100)'

Main window location - will be updated & saved when user moves it. If position is outside screen then it will be repositioned to default

config_example.Main_Size = '(700,450)'

Main window size (width, height) - initially uses wx.DefaultSize but will updated and saved as the user changes the window

config_example.Movie_fps = 10

Specifies movie frames-per-second; larger number will make smoother modulation movies but larger files.

config_example.Movie_time = 5

Specifices time in sec for one modulation loop; larger number will give more frames for same fps’

config_example.Multiprocessing_cores = 0

Specifies the number of cores to use when performing multicore computing. A number less than zero causes the recommended number of cores [using multiprocessing.cpu_count()/2] to be used. Setting this number to 0 or 1 avoids use of the multiprocessing module: all computations are performed in-line.

config_example.PDF_Rmax = 100.0

Maximum radius for G(r) calculations: range is from 10-200A; default is 100A

config_example.Plot_Colors = 'k r g b m c'

The colors for line plots: use one of ‘k’-black, ‘r’-red, ‘b’-blue, ‘g’-green, ‘m’-magenta, ‘c’-cyan for the line colors in order of obs., calc., back., diff., color5 & color6 separated by spaces; 6 items required.

config_example.Plot_Pos = '(200,200)'

Plot window location - will be updated & saved when user moves it these widows. If position is outside screen then it will be repositioned to default

config_example.Plot_Size = '(700,600)'

Plot window size (width, height) - initially uses wx.DefaultSize but will updated and saved as the user changes the window

config_example.Ring_mask_thickness = 0.1

Specifies the default thickness for creation of ring and arc masks. Default is 0.1 degrees 2-theta.

config_example.Save_paths = False

When set to True, the last-used path for saving of .gpx and for importing of input files is saved in the configuration file. Note that since this causes the config.py file to be updated whenever files are saved/imported, any temporary config settings can be saved to disk at that point.

config_example.SeparateHistPhaseTreeItem = False

When this is set to True, the parameters for each histogram in each phase are placed in a separate 1st-level tree item rather than in the Data tab for each phase. Requires GSAS-II be restarted to take effect. Default is False.

This option is under development and is not fully tested.

config_example.Show_timing = False

If True, shows various timing results.

config_example.Spot_mask_diameter = 1.0

Specifies the default diameter for creation of spot masks. Default is 1.0 mm

config_example.Starting_directory = None

Specifies a default location for starting GSAS-II and where .gpx files should be read from. Will be updated if Save_paths is True. Note that os.path.expanduser is run on this before it is used, so the user’s home directory can be specified with a ‘~’.

config_example.Tick_length = 8.0

Specifies the length of phase tick marks in pixels. Default is 8.

config_example.Tick_width = 1.0

Specifies the width of phase tick marks in pixels. Fractional values do seem to produce an effect. Default is 1.

config_example.Transpose = False

Set to True to cause images to be Transposed when read (for code development)

config_example.Tutorial_location = None

Change this to place tutorials by in a different spot. If None, this defaults to <user>/My Documents/G2tutorials (on windows) or <user>/G2tutorials. If you want to use a different location, this can be set here. To install into the location where GSAS-II is installed, use this:

Tutorial_location = GSASIIpath.path2GSAS2

As another example, to use ~/.G2tutorials do this:

Tutorial_location = '~/.G2tutorials'

Note that os.path.expanduser is run on Tutorial_location before it is used. Also note that GSASIIpath is imported inside config.py; other imports should be avoided.

config_example.debug = False

Set to True to turn on debugging mode.This enables use of IPython on exceptions and on calls to GSASIIpath.IPyBreak(). Calls to GSASIIpath.pdbBreak() will invoke pdb at that location.

If debug is False, calls to GSASIIpath.IPyBreak() and GSASIIpath.pdbBreak() are ignored.

config_example.enum_DrawAtoms_default = ['', 'lines', 'vdW balls', 'sticks', 'balls & sticks', 'ellipsoids']

choices for DrawAtoms_default

config_example.fullIntegrate = True

If True then full image integration is default; False otherwise

config_example.fullrmc_exec = None

Defines the full path to a Python executable that has been configured with the fullrmc package. If None (the default), GSAS-II will see if fullrmc can be imported into the current Python and if not a executable named fullrmc* (or fullrmc*.exe on Windows) can be found in the GSAS-II binary directory or in the system path.

config_example.lastUpdateNotice = 0

Defines the version number for the last update notice that has been shown. This should not need to be changed manually.

config_example.logging_debug = False

Set to True to enable debug for logging (under development.)

config_example.previous_GPX_files = []

A list of previously used .gpx files

config_example.show_gpxSize = False

When True, the sizes of the sections of the GPX file are listed when the GPX file is opened. Default is False.

config_example.wxInspector = False

If set to True, the wxInspector widget is displayed when GSAS-II is started.

4.4. GSASIIElem: functions for element types

GSASIIElem.CheckElement(El)[source]

Check if element El is in the periodic table

Parameters:El (str) – One or two letter element symbol, capitaliztion ignored
Returns:True if the element is found
GSASIIElem.ComptonFac(El, SQ)[source]

compute Compton scattering factor

Parameters:
  • El – element dictionary
  • SQ – (sin-theta/lambda)**2
Returns:

compton scattering factor

GSASIIElem.FPcalc(Orbs, KEv)[source]

Compute real & imaginary resonant X-ray scattering factors

Parameters:
  • Orbs – list of orbital dictionaries as defined in GetXsectionCoeff
  • KEv – x-ray energy in keV
Returns:

C: (f’,f”,mu): real, imaginary parts of resonant scattering & atomic absorption coeff.

GSASIIElem.FixValence(El)[source]

Returns the element symbol, even when a valence is present

GSASIIElem.GetAtomInfo(El, ifMag=False)[source]

reads element information from atmdata.py

GSASIIElem.GetBLtable(General)[source]

returns a dictionary of neutron scattering length data for atom types & isotopes found in General

Parameters:General (dict) – dictionary of phase info.; includes AtomTypes & Isotopes
Returns:BLtable, dictionary of scattering length data; key is atom type
GSASIIElem.GetFFC5(ElSym)[source]

Get 5 term form factor and Compton scattering data

Parameters:ElSym – str(1-2 character element symbol with proper case);
Return El:dictionary with 5 term form factor & compton coefficients
GSASIIElem.GetFFtable(atomTypes)[source]

returns a dictionary of form factor data for atom types found in atomTypes

Parameters:atomTypes (list) – list of atom types
Returns:FFtable, dictionary of form factor data; key is atom type
GSASIIElem.GetFormFactorCoeff(El)[source]

Read X-ray form factor coefficients from atomdata.py file

Parameters:El (str) – element 1-2 character symbol, case irrevelant
Returns:FormFactors: list of form factor dictionaries

Each X-ray form factor dictionary is:

  • Symbol: 4 character element symbol with valence (e.g. ‘NI+2’)
  • Z: atomic number
  • fa: 4 A coefficients
  • fb: 4 B coefficients
  • fc: C coefficient
GSASIIElem.GetMFtable(atomTypes, Landeg)[source]

returns a dictionary of magnetic form factor data for atom types found in atomTypes

Parameters:
  • atomTypes (list) – list of atom types
  • Landeg (list) – Lande g factors for atomTypes
Returns:

FFtable, dictionary of form factor data; key is atom type

GSASIIElem.GetMagFormFacCoeff(El)[source]

Read magnetic form factor data from atmdata.py

Parameters:El – 2 character element symbol
Returns:MagFormFactors: list of all magnetic form factors dictionaries for element El.

each dictionary contains:

  • ‘Symbol’:Symbol
  • ‘Z’:Z
  • ‘mfa’: 4 MA coefficients
  • ‘nfa’: 4 NA coefficients
  • ‘mfb’: 4 MB coefficients
  • ‘nfb’: 4 NB coefficients
  • ‘mfc’: MC coefficient
  • ‘nfc’: NC coefficient
GSASIIElem.GetXsectionCoeff(El)[source]

Read atom orbital scattering cross sections for fprime calculations via Cromer-Lieberman algorithm

Parameters:El – 2 character element symbol
Returns:Orbs: list of orbitals each a dictionary with detailed orbital information used by FPcalc

each dictionary is:

  • ‘OrbName’: Orbital name read from file
  • ‘IfBe’ 0/2 depending on orbital
  • ‘BindEn’: binding energy
  • ‘BB’: BindEn/0.02721
  • ‘XSectIP’: 5 cross section inflection points
  • ‘ElEterm’: energy correction term
  • ‘SEdge’: absorption edge for orbital
  • ‘Nval’: 10/11 depending on IfBe
  • ‘LEner’: 10/11 values of log(energy)
  • ‘LXSect’: 10/11 values of log(cross section)
GSASIIElem.MagScatFac(El, SQ)[source]

compute value of form factor

Parameters:
  • El – element dictionary defined in GetFormFactorCoeff
  • SQ – (sin-theta/lambda)**2
  • gfac – Lande g factor (normally = 2.0)
Returns:

real part of form factor

GSASIIElem.ScatFac(El, SQ)[source]

compute value of form factor

Parameters:
  • El – element dictionary defined in GetFormFactorCoeff
  • SQ – (sin-theta/lambda)**2
Returns:

real part of form factor

GSASIIElem.SetupGeneral(data, dirname)[source]

Initialize the General sections of the Phase tree contents Called by SetupGeneral in GSASIIphsGUI and in GSASIIscriptable.SetupGeneral

GSASIIElem.getBLvalues(BLtables, ifList=False)[source]

Needs a doc string

GSASIIElem.getFFvalues(FFtables, SQ, ifList=False)[source]

Needs a doc string

GSASIIElem.getMFvalues(MFtables, SQ, ifList=False)[source]

Needs a doc string

4.5. GSASIIlattice: Unit cells

Perform lattice-related computations

Note that G is the reciprocal lattice tensor, and g is its inverse, \(G = g^{-1}\), where

\[\begin{split}g = \left( \begin{matrix} a^2 & a b\cos\gamma & a c\cos\beta \\ a b\cos\gamma & b^2 & b c \cos\alpha \\ a c\cos\beta & b c \cos\alpha & c^2 \end{matrix}\right)\end{split}\]

The “A tensor” terms are defined as \(A = (\begin{matrix} G_{11} & G_{22} & G_{33} & 2G_{12} & 2G_{13} & 2G_{23}\end{matrix})\) and A can be used in this fashion: \(d^* = \sqrt {A_0 h^2 + A_1 k^2 + A_2 l^2 + A_3 hk + A_4 hl + A_5 kl}\), where d is the d-spacing, and \(d^*\) is the reciprocal lattice spacing, \(Q = 2 \pi d^* = 2 \pi / d\). Note that GSAS-II variables p::Ai (i = 0, 1,… 5) and p is a phase number are used for the Ai values. See A2cell(), cell2A() for interconversion between A and unit cell parameters; cell2Gmat() Gmat2cell() for G and cell parameters.

When the hydrostatic/elastic strain coefficients (Dij, \(D_{ij}\)) are used, they are added to the A tensor terms (Ai, \(A_{i}\)) so that A is redefined \(A = (\begin{matrix} A_{0} + D_{11} & A_{1} + D_{22} & A_{2} + D_{33} & A_{3} + 2D_{12} & A_{4} + 2D_{13} & A_{5} + 2D_{23}\end{matrix})\). See cellDijFill(). Note that GSAS-II variables p:h:Dij (i,j = 1, 2, 3) and p is a phase number and h a histogram number are used for the Dij values.

GSASIIlattice.A2Gmat(A, inverse=True)[source]

Fill real & reciprocal metric tensor (G) from A.

Parameters:
  • A – reciprocal metric tensor elements as [G11,G22,G33,2*G12,2*G13,2*G23]
  • inverse (bool) – if True return both G and g; else just G
Returns:

reciprocal (G) & real (g) metric tensors (list of two numpy 3x3 arrays)

GSASIIlattice.A2cell(A)[source]

Compute unit cell constants from A

Parameters:A – [G11,G22,G33,2*G12,2*G13,2*G23] G - reciprocal metric tensor
Returns:a,b,c,alpha, beta, gamma (degrees) - lattice parameters
GSASIIlattice.A2invcell(A)[source]

Compute reciprocal unit cell constants from A returns tuple with a*,b*,c*,alpha*, beta*, gamma* (degrees)

GSASIIlattice.CellAbsorption(ElList, Volume)[source]

Compute unit cell absorption

Parameters:
  • ElList (dict) – dictionary of element contents including mu and number of atoms be cell
  • Volume (float) – unit cell volume
Returns:

mu-total/Volume

GSASIIlattice.CellBlock(nCells)[source]

Generate block of unit cells n*n*n on a side; [0,0,0] centered, n = 2*nCells+1 currently only works for nCells = 0 or 1 (not >1)

GSASIIlattice.CentCheck(Cent, H)[source]

needs doc string

GSASIIlattice.CosAngle(U, V, G)[source]

calculate cos of angle between U & V in generalized coordinates defined by metric tensor G

Parameters:
  • U – 3-vectors assume numpy arrays, can be multiple reflections as (N,3) array
  • V – 3-vectors assume numpy arrays, only as (3) vector
  • G – metric tensor for U & V defined space assume numpy array
Returns:

cos(phi)

GSASIIlattice.CosSinAngle(U, V, G)[source]

calculate sin & cos of angle between U & V in generalized coordinates defined by metric tensor G

Parameters:
  • U – 3-vectors assume numpy arrays
  • V – 3-vectors assume numpy arrays
  • G – metric tensor for U & V defined space assume numpy array
Returns:

cos(phi) & sin(phi)

GSASIIlattice.CrsAng(H, cell, SGData)[source]

needs doc string

GSASIIlattice.Dsp2pos(Inst, dsp)[source]

convert d-spacing to powder pattern position (2-theta or TOF, musec)

GSASIIlattice.FindNonstandard(controls, Phase)[source]

Find nonstandard setting of magnetic cell that aligns with parent nuclear cell

Parameters:
  • controls – list unit cell indexing controls
  • Phase – dict new magnetic phase data (NB:not G2 phase construction); modified here
Returns:

None

GSASIIlattice.Flnh(Start, SHCoef, phi, beta, SGData)[source]

needs doc string

GSASIIlattice.GenCellConstraints(Trans, origPhase, newPhase, origA, debug=False)[source]

Generate the constraints between two unit cells constants for a phase transformed by matrix Trans.

Parameters:
  • Trans (np.array) – a 3x3 direct cell transformation matrix where, Trans = np.array([ [2/3, 4/3, 1/3], [-1, 0, 0], [-1/3, -2/3, 1/3] ]) (for a’ = 2/3a + 4/3b + 1/3c; b’ = -a; c’ = -1/3, -2/3, 1/3)
  • origPhase (int) – phase id (pId) for original phase
  • newPhase (int) – phase id for the transformed phase to be constrained from original phase
  • origA (list) – reciprocal cell (“A*”) tensor
  • debug (bool) – If true, the constraint input is used to compute and print A* and from that the direct cell for the transformed phase.
GSASIIlattice.GenHBravais(dmin, Bravais, A, cctbx_args=None)[source]

Generate the positionally unique powder diffraction reflections

Parameters:
  • dmin – minimum d-spacing in A
  • Bravais

    lattice type (see GetBraviasNum). Bravais is one of:

    • 0 F cubic
    • 1 I cubic
    • 2 P cubic
    • 3 R hexagonal (trigonal not rhombohedral)
    • 4 P hexagonal
    • 5 I tetragonal
    • 6 P tetragonal
    • 7 F orthorhombic
    • 8 I orthorhombic
    • 9 A orthorhombic
    • 10 B orthorhombic
    • 11 C orthorhombic
    • 12 P orthorhombic
    • 13 I monoclinic
    • 14 A monoclinic
    • 15 C monoclinic
    • 16 P monoclinic
    • 17 P triclinic
  • A – reciprocal metric tensor elements as [G11,G22,G33,2*G12,2*G13,2*G23]
  • cctbx_args (dict) –

    items defined in CCTBX:

    • ’sg_type’: value from cctbx.sgtbx.space_group_type(symmorphic_sgs[ibrav])
    • ’uctbx_unit_cell’: pointer to cctbx.uctbx.unit_cell()
    • ’miller_index_generator’: pointer to cctbx.miller.index_generator()
Returns:

HKL unique d list of [h,k,l,d,-1] sorted with largest d first

GSASIIlattice.GenHLaue(dmin, SGData, A)[source]

Generate the crystallographically unique powder diffraction reflections for a lattice and Bravais type

Parameters:
  • dmin – minimum d-spacing
  • SGData

    space group dictionary with at least

    • ’SGLaue’: Laue group symbol: one of ‘-1’,’2/m’,’mmm’,’4/m’,’6/m’,’4/mmm’,’6/mmm’, ‘3m1’, ‘31m’, ‘3’, ‘3R’, ‘3mR’, ‘m3’, ‘m3m’
    • ’SGLatt’: lattice centering: one of ‘P’,’A’,’B’,’C’,’I’,’F’
    • ’SGUniq’: code for unique monoclinic axis one of ‘a’,’b’,’c’ (only if ‘SGLaue’ is ‘2/m’) otherwise an empty string
  • A – reciprocal metric tensor elements as [G11,G22,G33,2*G12,2*G13,2*G23]
Returns:

HKL = list of [h,k,l,d] sorted with largest d first and is unique part of reciprocal space ignoring anomalous dispersion

GSASIIlattice.GenPfHKLs(nMax, SGData, A)[source]

Generate the unique pole figure reflections for a lattice and Bravais type. Min d-spacing=1.0A & no more than nMax returned

Parameters:
  • nMax – maximum number of hkls returned
  • SGData

    space group dictionary with at least

    • ’SGLaue’: Laue group symbol: one of ‘-1’,’2/m’,’mmm’,’4/m’,’6/m’,’4/mmm’,’6/mmm’, ‘3m1’, ‘31m’, ‘3’, ‘3R’, ‘3mR’, ‘m3’, ‘m3m’
    • ’SGLatt’: lattice centering: one of ‘P’,’A’,’B’,’C’,’I’,’F’
    • ’SGUniq’: code for unique monoclinic axis one of ‘a’,’b’,’c’ (only if ‘SGLaue’ is ‘2/m’) otherwise an empty string
  • A – reciprocal metric tensor elements as [G11,G22,G33,2*G12,2*G13,2*G23]
Returns:

HKL = list of ‘h k l’ strings sorted with largest d first; no duplicate zones

GSASIIlattice.GenSHCoeff(SGLaue, SamSym, L, IfLMN=True)[source]

needs doc string

GSASIIlattice.GenSSHLaue(dmin, SGData, SSGData, Vec, maxH, A)[source]

needs a doc string

GSASIIlattice.GenerateCellConstraints()[source]

Generate unit cell constraints for transforming one set of A tensor values to another using symbolic math (requires the sympy package)

Note that this is only used to do the symbolic math needed to generate cell relationships. It is not used normally in GSAS-II.

GSASIIlattice.GetBraviasNum(center, system)[source]

Determine the Bravais lattice number, as used in GenHBravais

Parameters:
  • center – one of: ‘P’, ‘C’, ‘I’, ‘F’, ‘R’ (see SGLatt from GSASIIspc.SpcGroup)
  • system – one of ‘cubic’, ‘hexagonal’, ‘tetragonal’, ‘orthorhombic’, ‘trigonal’ (for R) ‘monoclinic’, ‘triclinic’ (see SGSys from GSASIIspc.SpcGroup)
Returns:

a number between 0 and 13 or throws a ValueError exception if the combination of center, system is not found (i.e. non-standard)

GSASIIlattice.GetKcl(L, N, SGLaue, phi, beta)[source]

needs doc string

GSASIIlattice.GetKclKsl(L, N, SGLaue, psi, phi, beta)[source]
This is used for spherical harmonics description of preferred orientation;
cylindrical symmetry only (M=0) and no sample angle derivatives returned
GSASIIlattice.GetKsl(L, M, SamSym, psi, gam)[source]

needs doc string

GSASIIlattice.Glnh(Start, SHCoef, psi, gam, SamSym)[source]

needs doc string

GSASIIlattice.Gmat2A(G)[source]

Extract A from reciprocal metric tensor (G)

Parameters:G – reciprocal maetric tensor (3x3 numpy array
Returns:A = [G11,G22,G33,2*G12,2*G13,2*G23]
GSASIIlattice.Gmat2AB(G)[source]

Computes orthogonalization matrix from reciprocal metric tensor G

Returns:tuple of two 3x3 numpy arrays (A,B)
  • A for crystal to Cartesian transformations (A*x = np.inner(A,x) = X)
  • B (= inverse of A) for Cartesian to crystal transformation (B*X = np.inner(B,X) = x)
GSASIIlattice.Gmat2cell(g)[source]

Compute real/reciprocal lattice parameters from real/reciprocal metric tensor (g/G) The math works the same either way.

Parameters:(or G) (g) – real (or reciprocal) metric tensor 3x3 array
Returns:a,b,c,alpha, beta, gamma (degrees) (or a*,b*,c*,alpha*,beta*,gamma* degrees)
GSASIIlattice.HKL2SpAng(H, cell, SGData)[source]

Computes spherical coords for hkls; view along 001

Parameters:
  • H (array) – arrays of hkl
  • cell (tuple) – a,b,c, alpha, beta, gamma (degrees)
  • SGData (dict) – space group dictionary
Returns:

arrays of r,phi,psi (radius,inclination,azimuth) about 001

GSASIIlattice.Hx2Rh(Hx)[source]

needs doc string

GSASIIlattice.LaueUnique(Laue, HKLF)[source]

Impose Laue symmetry on hkl

Parameters:
  • Laue (str) –

    Laue symbol, as below

    centrosymmetric Laue groups:

    ['-1','2/m','112/m','2/m11','mmm','-42m','-4m2','4/mmm','-3','-3m',
    '-31m','-3m1','6/m','6/mmm','m3','m3m']
    

    noncentrosymmetric Laue groups:

    ['1','2','211','112','m','m11','11m','222','mm2','m2m','2mm',
    '4','-4','422','4mm','3','312','321','3m','31m','3m1','6','-6',
    '622','6mm','-62m','-6m2','23','432','-43m']
    
  • HKLF – np.array([[h,k,l,…]]) reflection set to be converted
Returns:

HKLF new reflection array with imposed Laue symmetry

GSASIIlattice.LaueUnique2(SGData, refList)[source]

Impose Laue symmetry on hkl

Parameters:
  • SGData – space group data from ‘P ‘+Laue
  • HKLF – np.array([[h,k,l,…]]) reflection set to be converted
Returns:

HKLF new reflection array with imposed Laue symmetry

GSASIIlattice.MaxIndex(dmin, A)[source]

needs doc string

GSASIIlattice.OdfChk(SGLaue, L, M)[source]

needs doc string

GSASIIlattice.PlaneIntercepts(Amat, H, phase, stack)[source]

find unit cell intercepts for a stack of hkl planes

GSASIIlattice.Pos2dsp(Inst, pos)[source]

convert powder pattern position (2-theta or TOF, musec) to d-spacing

GSASIIlattice.RBsymCheck(Atoms, ct, cx, cs, AtLookUp, Amat, RBObjIds, SGData)[source]

Checks members of a rigid body to see if one is a symmetry equivalent of another. If so the atom site frac is set to zero. param: Atoms: atom array as defined in GSAS-II; modified here param: ct: int location of atom type in Atoms item param: cx: int location of x,y,z,frac in Atoms item param: AtLookUp: dict: atom lookup by Id table param: Amat: np .array: crystal-to-Cartesian transformationmatri param: RBObjIds: list: atom Id belonging to rigid body being tested param: SGData: Dict: GSAS-II space group info. :return: Atoms with modified atom frac entries

GSASIIlattice.Rh2Hx(Rh)[source]

needs doc string

GSASIIlattice.SamAng(Tth, Gangls, Sangl, IFCoup)[source]

Compute sample orientation angles vs laboratory coord. system

Parameters:
  • Tth – Signed theta
  • Gangls – Sample goniometer angles phi,chi,omega,azmuth
  • Sangl – Sample angle zeros om-0, chi-0, phi-0
  • IFCoup – True if omega & 2-theta coupled in CW scan
Returns:

psi,gam: Sample odf angles dPSdA,dGMdA: Angle zero derivatives

GSASIIlattice.SwapIndx(Axis, H)[source]

needs doc string

GSASIIlattice.SwapItems(Alist, pos1, pos2)[source]

exchange 2 items in a list

GSASIIlattice.TOF2dsp(Inst, Pos)[source]

convert powder pattern TOF, musec to d-spacing by successive approximation Pos can be numpy array

GSASIIlattice.TransformCell(cell, Trans)[source]

Transform lattice parameters by matrix

Parameters:
  • cell – list a,b,c,alpha,beta,gamma,(volume)
  • Trans – array transformation matrix
Returns:

array transformed a,b,c,alpha,beta,gamma,volume

GSASIIlattice.TransformPhase(oldPhase, newPhase, Trans, Uvec, Vvec, ifMag, Force=True)[source]

Transform atoms from oldPhase to newPhase M’ is inv(M) does X’ = M(X-U)+V transformation for coordinates and U’ = MUM/det(M) for anisotropic thermal parameters

Parameters:
  • oldPhase – dict G2 phase info for old phase
  • newPhase – dict G2 phase info for new phase; with new cell & space group atoms are from oldPhase & will be transformed
  • Trans – lattice transformation matrix M
  • Uvec – array parent coordinates transformation vector U
  • Vvec – array child coordinate transformation vector V
  • ifMag – bool True if convert to magnetic phase; if True all nonmagnetic atoms will be removed
Returns:

newPhase dict modified G2 phase info

Returns:

atCodes list atom transformation codes

GSASIIlattice.U6toUij(U6)[source]

Fill matrix (Uij) from U6 = [U11,U22,U33,U12,U13,U23] NB: there is a non numpy version in GSASIIspc: U2Uij

Parameters:U6 (list) – 6 terms of u11,u22,…
Returns:Uij - numpy [3][3] array of uij
GSASIIlattice.Uij2Ueqv(Uij, GS, Amat)[source]

returns 1/3 trace of diagonalized U matrix :param Uij: numpy array [Uij] :param GS: Uij too betaij conversion matrix :param Amat: crystal to Cartesian transformation matrix :returns: 1/3 trace of diagonalized U matrix :returns: True if nonpositive-definate; False otherwise

GSASIIlattice.Uij2betaij(Uij, G)[source]

Convert Uij to beta-ij tensors – stub for eventual completion

Parameters:
  • Uij – numpy array [Uij]
  • G – reciprocal metric tensor
Returns:

beta-ij - numpy array [beta-ij]

GSASIIlattice.UijtoU6(U)[source]

Fill vector [U11,U22,U33,U12,U13,U23] from Uij NB: there is a non numpy version in GSASIIspc: Uij2U

GSASIIlattice.betaij2Uij(betaij, G)[source]

Convert beta-ij to Uij tensors

:param beta-ij - numpy array [beta-ij] :param G: reciprocal metric tensor :returns: Uij: numpy array [Uij]

GSASIIlattice.calc_V(A)[source]

Compute the real lattice volume (V) from A

GSASIIlattice.calc_rDsq(H, A)[source]

needs doc string

GSASIIlattice.calc_rDsq2(H, G)[source]

needs doc string

GSASIIlattice.calc_rDsqSS(H, A, vec)[source]

needs doc string

GSASIIlattice.calc_rDsqT(H, A, Z, tof, difC)[source]

needs doc string

GSASIIlattice.calc_rDsqTSS(H, A, vec, Z, tof, difC)[source]

needs doc string

GSASIIlattice.calc_rDsqZ(H, A, Z, tth, lam)[source]

needs doc string

GSASIIlattice.calc_rDsqZSS(H, A, vec, Z, tth, lam)[source]

needs doc string

GSASIIlattice.calc_rV(A)[source]

Compute the reciprocal lattice volume (V*) from A

GSASIIlattice.calc_rVsq(A)[source]

Compute the square of the reciprocal lattice volume (1/V**2) from A’

GSASIIlattice.cell2A(cell)[source]

Obtain A = [G11,G22,G33,2*G12,2*G13,2*G23] from lattice parameters

Parameters:cell – [a,b,c,alpha,beta,gamma] (degrees)
Returns:G reciprocal metric tensor as 3x3 numpy array
GSASIIlattice.cell2AB(cell, alt=False)[source]

Computes orthogonalization matrix from unit cell constants

Parameters:cell (tuple) – a,b,c, alpha, beta, gamma (degrees)
Returns:tuple of two 3x3 numpy arrays (A,B) A for crystal to Cartesian transformations A*x = np.inner(A,x) = X B (= inverse of A) for Cartesian to crystal transformation B*X = np.inner(B,X) = x
GSASIIlattice.cell2GS(cell)[source]

returns Uij to betaij conversion matrix

GSASIIlattice.cell2Gmat(cell)[source]

Compute real and reciprocal lattice metric tensor from unit cell constants

Parameters:cell – tuple with a,b,c,alpha, beta, gamma (degrees)
Returns:reciprocal (G) & real (g) metric tensors (list of two numpy 3x3 arrays)
GSASIIlattice.cellDijFill(pfx, phfx, SGData, parmDict)[source]

Returns the filled-out reciprocal cell (A) terms from the parameter dictionaries corrected for Dij.

Parameters:
  • pfx (str) – parameter prefix (“n::”, where n is a phase number)
  • SGdata (dict) – a symmetry object
  • parmDict (dict) – a dictionary of parameters
Returns:

A,sigA where each is a list of six terms with the A terms

GSASIIlattice.cellXformRelations = {0: ['1.0*A0*T[0,0]**2', '1.0*A1*T[0,1]**2', '1.0*A2*T[0,2]**2', '1.0*A3*T[0,0]*T[0,1]', '1.0*A4*T[0,0]*T[0,2]', '1.0*A5*T[0,1]*T[0,2]'], 1: ['1.0*A0*T[1,0]**2', '1.0*A1*T[1,1]**2', '1.0*A2*T[1,2]**2', '1.0*A3*T[1,0]*T[1,1]', '1.0*A4*T[1,0]*T[1,2]', '1.0*A5*T[1,1]*T[1,2]'], 2: ['1.0*A0*T[2,0]**2', '1.0*A1*T[2,1]**2', '1.0*A2*T[2,2]**2', '1.0*A3*T[2,0]*T[2,1]', '1.0*A4*T[2,0]*T[2,2]', '1.0*A5*T[2,1]*T[2,2]'], 3: ['2.0*A0*T[0,0]*T[1,0]', '2.0*A1*T[0,1]*T[1,1]', '2.0*A2*T[0,2]*T[1,2]', '1.0*A3*(T[0,0]*T[1,1] + T[1,0]*T[0,1])', '1.0*A4*(T[0,0]*T[1,2] + T[1,0]*T[0,2])', '1.0*A5*(T[0,1]*T[1,2] + T[1,1]*T[0,2])'], 4: ['2.0*A0*T[0,0]*T[2,0]', '2.0*A1*T[0,1]*T[2,1]', '2.0*A2*T[0,2]*T[2,2]', '1.0*A3*(T[0,0]*T[2,1] + T[2,0]*T[0,1])', '1.0*A4*(T[0,0]*T[2,2] + T[2,0]*T[0,2])', '1.0*A5*(T[0,1]*T[2,2] + T[2,1]*T[0,2])'], 5: ['2.0*A0*T[1,0]*T[2,0]', '2.0*A1*T[1,1]*T[2,1]', '2.0*A2*T[1,2]*T[2,2]', '1.0*A3*(T[1,0]*T[2,1] + T[2,0]*T[1,1])', '1.0*A4*(T[1,0]*T[2,2] + T[2,0]*T[1,2])', '1.0*A5*(T[1,1]*T[2,2] + T[2,1]*T[1,2])']}

cellXformRelations provide the constraints on newA[i] values for a new cell generated from oldA[i] values.

GSASIIlattice.combinations(items, n)[source]

take n distinct items, order matters

GSASIIlattice.criticalEllipse(prob)[source]

Calculate critical values for probability ellipsoids from probability

GSASIIlattice.fillgmat(cell)[source]

Compute lattice metric tensor from unit cell constants

Parameters:cell – tuple with a,b,c,alpha, beta, gamma (degrees)
Returns:3x3 numpy array
GSASIIlattice.fmtCellConstraints(cellConstr)[source]

Format the cell relationships created in GenerateCellConstraints() in a format that can be used to generate constraints.

Use:

cXforms = G2lat.fmtCellConstraints(G2lat.GenerateCellConstraints())

Note that this is only used to do the symbolic math needed to generate cell relationships. It is not used normally in GSAS-II.

GSASIIlattice.getHKLmax(dmin, SGData, A)[source]

finds maximum allowed hkl for given A within dmin

GSASIIlattice.getPeakPos(dataType, parmdict, dsp)[source]

convert d-spacing to powder pattern position (2-theta or TOF, musec)

GSASIIlattice.invcell2Gmat(invcell)[source]
Compute real and reciprocal lattice metric tensor from reciprocal
unit cell constants
Parameters:invcell – [a*,b*,c*,alpha*, beta*, gamma*] (degrees)
Returns:reciprocal (G) & real (g) metric tensors (list of two 3x3 arrays)
GSASIIlattice.invpolfcal(ODFln, SGData, phi, beta)[source]

needs doc string

GSASIIlattice.permutations(items)[source]

take all items, order matters

GSASIIlattice.polfcal(ODFln, SamSym, psi, gam)[source]

Perform a pole figure computation. Note that the the number of gam values must either be 1 or must match psi. Updated for numpy 1.8.0

GSASIIlattice.prodMGMT(G, Mat)[source]

Transform metric tensor by matrix

Parameters:
  • G – array metric tensor
  • Mat – array transformation matrix
Returns:

array new metric tensor

GSASIIlattice.rotdMat(angle, axis=0)[source]

Prepare rotation matrix for angle in degrees about axis(=0,1,2)

Parameters:
  • angle – angle in degrees
  • axis – axis (0,1,2 = x,y,z) about which for the rotation
Returns:

rotation matrix - 3x3 numpy array

GSASIIlattice.rotdMat4(angle, axis=0)[source]

Prepare rotation matrix for angle in degrees about axis(=0,1,2) with scaling for OpenGL

Parameters:
  • angle – angle in degrees
  • axis – axis (0,1,2 = x,y,z) about which for the rotation
Returns:

rotation matrix - 4x4 numpy array (last row/column for openGL scaling)

GSASIIlattice.sec2HMS(sec)[source]

Convert time in sec to H:M:S string

Parameters:sec – time in seconds
Returns:H:M:S string (to nearest 100th second)
GSASIIlattice.selections(items, n)[source]

take n (not necessarily distinct) items, order matters

GSASIIlattice.selftestlist = []

Defines a list of self-tests

GSASIIlattice.sortHKLd(HKLd, ifreverse, ifdup, ifSS=False)[source]

sort reflection list on d-spacing; can sort in either order

Parameters:
  • HKLd – a list of [h,k,l,d,…];
  • ifreverse – True for largest d first
  • ifdup – True if duplicate d-spacings allowed
Returns:

sorted reflection list

GSASIIlattice.subVals(expr, A, T)[source]

Evaluate the symbolic expressions by substituting for A0-A5 & Tij

This can be used on the cell relationships created in GenerateCellConstraints() like this:

Trans = np.array([ [2/3, 4/3, 1/3], [-1, 0, 0], [-1/3, -2/3, 1/3] ])
T = np.linalg.inv(Trans).T
print([subVals(i,Aold,T) for i in GenerateCellConstraints()])
Parameters:
  • expr (list) – a list of sympy expressions.
  • A (list) – This is the A* tensor as defined above.
  • T (np.array) – a 3x3 transformation matrix where, Trans = np.array([ [2/3, 4/3, 1/3], [-1, 0, 0], [-1/3, -2/3, 1/3] ]) (for a’ = 2/3a + 4/3b + 1/3c; b’ = -a; c’ = -1/3, -2/3, 1/3) then T = np.linalg.inv(Trans).T

Note that this is only used to do the symbolic math needed to generate cell relationships. It is not used normally in GSAS-II.

GSASIIlattice.symInner(M1, M2)[source]

Compute inner product of two square matrices with symbolic processing Use dot product because sympy does not define an inner product primitive

This requires that M1 & M2 be two sympy objects, as created in GenerateCellConstraints().

Note that this is only used to do the symbolic math needed to generate cell relationships. It is not used normally in GSAS-II.

GSASIIlattice.test1()[source]

test cell2A and A2Gmat

GSASIIlattice.test2()[source]

test Gmat2A, A2cell, A2Gmat, Gmat2cell

GSASIIlattice.test3()[source]

test invcell2Gmat

GSASIIlattice.test4()[source]

test calc_rVsq, calc_rV, calc_V

GSASIIlattice.test5()[source]

test A2invcell

GSASIIlattice.test6()[source]

test cell2AB

GSASIIlattice.test7()[source]

test GetBraviasNum(…) and GenHBravais(…)

GSASIIlattice.test8()[source]

test GenHLaue

GSASIIlattice.test9()[source]

test GenHLaue

GSASIIlattice.textureIndex(SHCoef)[source]

needs doc string

GSASIIlattice.transposeHKLF(transMat, Super, refList)[source]

Apply transformation matrix to hkl(m) param: transmat: 3x3 or 4x4 array param: Super: 0 or 1 for extra index param: refList list of h,k,l,…. return: newRefs transformed list of h’,k’,l’,,, return: badRefs list of noninteger h’,k’,l’…

GSASIIlattice.uniqueCombinations(items, n)[source]

take n distinct items, order is irrelevant

4.6. GSASIIspc: Space group module

Space group interpretation routines. Note that space group information is stored in a Space Group (SGData) object.

GSASIIspc.AllOps(SGData)[source]

Returns a list of all operators for a space group, including those for centering and a center of symmetry

Parameters:SGData – from SpcGroup()
Returns:(SGTextList,offsetList,symOpList,G2oprList) where
  • SGTextList: a list of strings with formatted and normalized symmetry operators.
  • offsetList: a tuple of (dx,dy,dz) offsets that relate the GSAS-II symmetry operation to the operator in SGTextList and symOpList. these dx (etc.) values are added to the GSAS-II generated positions to provide the positions that are generated by the normalized symmetry operators.
  • symOpList: a list of tuples with the normalized symmetry operations as (M,T) values (see SGOps in the Space Group object)
  • G2oprList: a list with the GSAS-II operations for each symmetry operation as a tuple with (center,mult,opnum,opcode), where center is (0,0,0), (0.5,0,0), (0.5,0.5,0.5),…; where mult is 1 or -1 for the center of symmetry where opnum is the number for the symmetry operation, in SGOps (starting with 0) and opcode is mult*(100*icen+j+1).
  • G2opcodes: a list with the name that GSAS-II uses for each symmetry operation (same as opcode, above)
GSASIIspc.ApplyStringOps(A, SGData, X, Uij=[])[source]

Needs a doc string

GSASIIspc.ApplyStringOpsMom(A, SGData, SSGData, Mom)[source]

Applies string operations to modulated magnetic moment components used in drawing Drawing matches Bilbao MVISUALIZE

GSASIIspc.CheckSpin(isym, SGData)[source]

Check for exceptions in spin rules

GSASIIspc.ElemPosition(SGData)[source]

Under development. Object here is to return a list of symmetry element types and locations suitable for say drawing them. So far I have the element type… getting all possible locations without lookup may be impossible!

GSASIIspc.GenAtom(XYZ, SGData, All=False, Uij=[], Move=True)[source]

Generates the equivalent positions for a specified coordinate and space group

Parameters:
  • XYZ – an array, tuple or list containing 3 elements: x, y & z
  • SGData – from SpcGroup()
  • All – True return all equivalent positions including duplicates; False return only unique positions
  • Uij – [U11,U22,U33,U12,U13,U23] or [] if no Uij
  • Move – True move generated atom positions to be inside cell False do not move atoms
Returns:

[[XYZEquiv],Idup,[UijEquiv],spnflp]

  • [XYZEquiv] is list of equivalent positions (XYZ is first entry)
  • Idup = [-][C]SS where SS is the symmetry operator number (1-24), C (if not 0,0,0)
  • is centering operator number (1-4) and - is for inversion Cell = unit cell translations needed to put new positions inside cell [UijEquiv] - equivalent Uij; absent if no Uij given
  • +1/-1 for spin inversion of operator - empty if not magnetic

GSASIIspc.GenHKL(HKL, SGData)[source]

Generates all equivlent reflections including Friedel pairs :param HKL: [h,k,l] must be integral values :param SGData: space group data obtained from SpcGroup :returns: array Uniq: equivalent reflections

GSASIIspc.GenHKLf(HKL, SGData)[source]

Uses old GSAS Fortran routine genhkl.for

Parameters:
  • HKL – [h,k,l] must be integral values for genhkl.for to work
  • SGData – space group data obtained from SpcGroup
Returns:

iabsnt,mulp,Uniq,phi

  • iabsnt = True if reflection is forbidden by symmetry
  • mulp = reflection multiplicity including Friedel pairs
  • Uniq = numpy array of equivalent hkl in descending order of h,k,l
  • phi = phase offset for each equivalent h,k,l

GSASIIspc.GetCSpqinel(SpnFlp, dupDir)[source]

returns Mxyz terms, multipliers, GUI flags

GSASIIspc.GetCSuinel(siteSym)[source]

returns Uij terms, multipliers, GUI flags & Uiso2Uij multipliers

GSASIIspc.GetCSxinel(siteSym)[source]

returns Xyz terms, multipliers, GUI flags

GSASIIspc.GetGenSym(SGData)[source]

Get the space group generator symbols :param SGData: from SpcGroup() LaueSym = (‘-1’,’2/m’,’mmm’,’4/m’,’4/mmm’,’3R’,’3mR’,’3’,’3m1’,’31m’,’6/m’,’6/mmm’,’m3’,’m3m’) LattSym = (‘P’,’A’,’B’,’C’,’I’,’F’,’R’)

GSASIIspc.GetKNsym(key)[source]

Needs a doc string

GSASIIspc.GetLittleGrpOps(SGData, vec)[source]

Find rotation part of operators that leave vec unchanged

Parameters:
  • SGData – space group data structure as defined in SpcGroup above.
  • vec – a numpy array of fractional vector coordinates
Returns:

Little - list of operators [M,T] that form the little gropu

GSASIIspc.GetNXUPQsym(siteSym)[source]

The codes XUPQ are for lookup of symmetry constraints for position(X), thermal parm(U) & magnetic moments (P & Q)

GSASIIspc.GetOprName(key)[source]

Needs a doc string

GSASIIspc.GetOprPtrName(key)[source]

Needs a doc string

GSASIIspc.GetOprPtrNumber(key)[source]

Needs a doc string

GSASIIspc.GetSGSpin(SGData, MSgSym)[source]

get spin generators from magnetic space group symbol

GSASIIspc.HStrainNames(SGData)[source]

Needs a doc string

GSASIIspc.Latt2text(Cen)[source]

From lattice centering vectors returns ‘;’ delimited cell centering vectors

GSASIIspc.MT2text(Opr, reverse=False)[source]

From space group matrix/translation operator returns text version

GSASIIspc.MagSSText2MTS(Opr, G2=False)[source]

From magnetic super space group cif text returns matrix/translation + spin flip

GSASIIspc.MagSytSym(SytSym, dupDir, SGData)[source]

site sym operations: 1,-1,2,3,-3,4,-4,6,-6,m need to be marked if spin inversion

GSASIIspc.MagText2MTS(mcifOpr, CIF=True)[source]

From magnetic space group cif text returns matrix/translation + spin flip

GSASIIspc.MoveToUnitCell(xyz)[source]

Translates a set of coordinates so that all values are >=0 and < 1

Parameters:xyz – a list or numpy array of fractional coordinates
Returns:XYZ - numpy array of new coordinates now 0 or greater and less than 1
GSASIIspc.Muiso2Shkl(muiso, SGData, cell)[source]

this is to convert isotropic mustrain to generalized Shkls

GSASIIspc.MustrainCoeff(HKL, SGData)[source]

Needs a doc string

GSASIIspc.MustrainNames(SGData)[source]

Needs a doc string

GSASIIspc.Opposite(XYZ, toler=0.0002)[source]
Gives opposite corner, edge or face of unit cell for position within tolerance.
Result may be just outside the cell within tolerance
Parameters:
  • XYZ – 0 >= np.array[x,y,z] > 1 as by MoveToUnitCell
  • toler – unit cell fraction tolerance making opposite
Returns:

XYZ: dict of opposite positions; key=unit cell & always contains XYZ

GSASIIspc.SGErrors(IErr)[source]

Interprets the error message code from SpcGroup. Used in SpaceGroup.

Parameters:IErr – see SGError in SpcGroup()
Returns:ErrString - a string with the error message or “Unknown error”
GSASIIspc.SGPrint(SGData, AddInv=False)[source]

Print the output of SpcGroup in a nicely formatted way. Used in SpaceGroup

Parameters:SGData – from SpcGroup()
Returns:SGText - list of strings with the space group details SGTable - list of strings for each of the operations
GSASIIspc.SGProd(OpA, OpB)[source]
Form space group operator product. OpA & OpB are [M,V] pairs;
both must be of same dimension (3 or 4). Returns [M,V] pair
GSASIIspc.SGPtGroup(SGData)[source]

Determine point group of the space group - done after space group symbol has been evaluated by SpcGroup. Only short symbols are allowed

Parameters:SGData – from :func SpcGroup
Returns:SSGPtGrp & SSGKl (only defaults for Mono & Ortho)
GSASIIspc.SGpolar(SGData)[source]

Determine identity of polar axes if any

GSASIIspc.SSChoice(SGData)[source]

Gets the unique set of possible super space groups for a given space group

GSASIIspc.SSGModCheck(Vec, modSymb, newMod=True)[source]

Checks modulation vector compatibility with supersymmetry space group symbol. if newMod: Superspace group symbol takes precidence & the vector will be modified accordingly

GSASIIspc.SSGPrint(SGData, SSGData, AddInv=False)[source]

Print the output of SSpcGroup in a nicely formatted way. Used in SSpaceGroup

Parameters:
  • SGData – space group data structure as defined in SpcGroup above.
  • SSGData – from SSpcGroup()
Returns:

SSGText - list of strings with the superspace group details SGTable - list of strings for each of the operations

GSASIIspc.SSLatt2text(SSGCen)[source]

Lattice centering vectors to text

GSASIIspc.SSMT2text(Opr)[source]

From superspace group matrix/translation operator returns text version

GSASIIspc.SSpaceGroup(SGSymbol, SSymbol)[source]

Print the output of SSpcGroup in a nicely formatted way.

Parameters:
  • SGSymbol – space group symbol with spaces between axial fields.
  • SSymbol – superspace group symbol extension (string).
Returns:

nothing

GSASIIspc.SSpcGroup(SGData, SSymbol)[source]

Determines supersymmetry information from superspace group name; currently only for (3+1) superlattices

Parameters:
  • SGData – space group data structure as defined in SpcGroup above (see SGData).
  • SSymbol – superspace group symbol extension (string) defining modulation direction & generator info.
Returns:

(SSGError,SSGData)

  • SGError = 0 for no errors; >0 for errors (see SGErrors below for details)

  • SSGData - is a dict (see Superspace Group object) with entries:

    • ’SSpGrp’: full superspace group symbol, accidental spaces removed; for display only
    • ’SSGCen’: 4D cell centering vectors [0,0,0,0] at least
    • ’SSGOps’: 4D symmetry operations as [M,T] so that M*x+T = x’

GSASIIspc.SpaceGroup(SGSymbol)[source]

Print the output of SpcGroup in a nicely formatted way.

Parameters:SGSymbol – space group symbol (string) with spaces between axial fields
Returns:nothing
GSASIIspc.SpcGroup(SGSymbol)[source]

Determines cell and symmetry information from a short H-M space group name

Parameters:SGSymbol – space group symbol (string) with spaces between axial fields
Returns:(SGError,SGData)
  • SGError = 0 for no errors; >0 for errors (see SGErrors below for details)
  • SGData - is a dict (see Space Group object) with entries:
    • ’SpGrp’: space group symbol, slightly cleaned up
    • ’SGFixed’: True if space group data can not be changed, e.g. from magnetic cif; otherwise False
    • ’SGGray’: True if 1’ in symbol - gray group for mag. incommensurate phases
    • ’SGLaue’: one of ‘-1’, ‘2/m’, ‘mmm’, ‘4/m’, ‘4/mmm’, ‘3R’, ‘3mR’, ‘3’, ‘3m1’, ‘31m’, ‘6/m’, ‘6/mmm’, ‘m3’, ‘m3m’
    • ’SGInv’: boolean; True if centrosymmetric, False if not
    • ’SGLatt’: one of ‘P’, ‘A’, ‘B’, ‘C’, ‘I’, ‘F’, ‘R’
    • ’SGUniq’: one of ‘a’, ‘b’, ‘c’ if monoclinic, ‘’ otherwise
    • ’SGCen’: cell centering vectors [0,0,0] at least
    • ’SGOps’: symmetry operations as [M,T] so that M*x+T = x’
    • ’SGSys’: one of ‘triclinic’, ‘monoclinic’, ‘orthorhombic’, ‘tetragonal’, ‘rhombohedral’, ‘trigonal’, ‘hexagonal’, ‘cubic’
    • ’SGPolax’: one of ‘ ‘, ‘x’, ‘y’, ‘x y’, ‘z’, ‘x z’, ‘y z’, ‘xyz’, ‘111’ for arbitrary axes
    • ’SGPtGrp’: one of 32 point group symbols (with some permutations), which
      is filled by SGPtGroup, is external (KE) part of supersymmetry point group
    • ’SSGKl’: default internal (Kl) part of supersymmetry point group; modified
      in supersymmetry stuff depending on chosen modulation vector for Mono & Ortho
    • ’BNSlattsym’: BNS lattice symbol & cenering op - used for magnetic structures
GSASIIspc.StandardizeSpcName(spcgroup)[source]

Accept a spacegroup name where spaces may have not been used in the names according to the GSAS convention (spaces between symmetry for each axis) and return the space group name as used in GSAS

GSASIIspc.StringOpsProd(A, B, SGData)[source]

Find A*B where A & B are in strings ‘-’ + ‘100*c+n’ + ‘+ijk’ where ‘-’ indicates inversion, c(>0) is the cell centering operator, n is operator number from SgOps and ijk are unit cell translations (each may be <0). Should return resultant string - C. SGData - dictionary using entries:

  • ‘SGCen’: cell centering vectors [0,0,0] at least
  • ‘SGOps’: symmetry operations as [M,T] so that M*x+T = x’
GSASIIspc.SytSym(XYZ, SGData)[source]

Generates the number of equivalent positions and a site symmetry code for a specified coordinate and space group

Parameters:
  • XYZ – an array, tuple or list containing 3 elements: x, y & z
  • SGData – from SpcGroup
Returns:

a four element tuple:

  • The 1st element is a code for the site symmetry (see GetKNsym)
  • The 2nd element is the site multiplicity
  • Ndup number of overlapping operators
  • dupDir Dict - dictionary of overlapping operators
GSASIIspc.Text2MT(mcifOpr, CIF=True)[source]

From space group cif text returns matrix/translation

GSASIIspc.TextOps(text, table, reverse=False)[source]

Makes formatted operator list :param text,table: arrays of text made by SGPrint :param reverse: True for x+1/2 form; False for 1/2+x form :returns: OpText: full list of symmetry operators; one operation per line generally printed to console for use via cut/paste in other programs, but could be used for direct input

GSASIIspc.Trans2Text(Trans)[source]

from transformation matrix to text

GSASIIspc.UpdateSytSym(Phase)[source]

Update site symmetry/site multiplicity after space group/BNS lattice change

GSASIIspc.altSettingOrtho = {'A b a 2': {'abc': 'A b a 2', 'acb': 'A c 2 a', 'bac': 'B b a 2', 'bca': 'C c 2 a', 'cab': 'B 2 c b', 'cba': 'C 2 c b'}, 'A b m 2': {'abc': 'A b m 2', 'acb': 'A c 2 m', 'bac': 'B m a 2', 'bca': 'C m 2 a', 'cab': 'B 2 c m', 'cba': 'C 2 m b'}, 'A m a 2': {'abc': 'A m a 2', 'acb': 'A m 2 a', 'bac': 'B b m 2', 'bca': 'C c 2 m', 'cab': 'B 2 m b', 'cba': 'C 2 c m'}, 'A m m 2': {'abc': 'A m m 2', 'acb': 'A m 2 m', 'bac': 'B m m 2', 'bca': 'C m 2 m', 'cab': 'B 2 m m', 'cba': 'C 2 m m'}, 'C 2 2 2': {'abc': 'C 2 2 2', 'acb': 'B 2 2 2', 'bac': 'C 2 2 2', 'bca': 'B 2 2 2', 'cab': 'A 2 2 2', 'cba': 'A 2 2 2'}, 'C 2 2 21': {'abc': 'C 2 2 21', 'acb': 'B 2 21 2', 'bac': 'C 2 2 21', 'bca': 'B 2 21 2', 'cab': 'A 21 2 2', 'cba': 'A 21 2 2'}, 'C c c 2': {'abc': 'C c c 2', 'acb': 'B b 2 b', 'bac': 'C c c 2', 'bca': 'B b 2 b', 'cab': 'A 2 a a', 'cba': 'A 2 a a'}, 'C c c a': {'abc': 'C c a a', 'acb': 'B b a b', 'bac': 'C c c b', 'bca': 'B b c b', 'cab': 'A b a a', 'cba': 'A c a a'}, 'C c c m': {'abc': 'C c c m', 'acb': 'B b m b', 'bac': 'C c c m', 'bca': 'B b m b', 'cab': 'A m a a', 'cba': 'A m a a'}, 'C m c 21': {'abc': 'C m c 21', 'acb': 'B m 21 b', 'bac': 'C c m 21', 'bca': 'B b 21 m', 'cab': 'A 21 m a', 'cba': 'A 21 a m'}, 'C m c a': {'abc': 'C m c a', 'acb': 'B m a b', 'bac': 'C c m b', 'bca': 'B b c m', 'cab': 'A b m a', 'cba': 'A c a m'}, 'C m c m': {'abc': 'C m c m', 'acb': 'B m m b', 'bac': 'C c m m', 'bca': 'B b m m', 'cab': 'A m m a', 'cba': 'A m a m'}, 'C m m 2': {'abc': 'C m m 2', 'acb': 'B m 2 m', 'bac': 'C m m 2', 'bca': 'B m 2 m', 'cab': 'A 2 m m', 'cba': 'A 2 m m'}, 'C m m a': {'abc': 'C m m a', 'acb': 'B m a m', 'bac': 'C m m b', 'bca': 'B m c m', 'cab': 'A b m m', 'cba': 'A c m m'}, 'C m m m': {'abc': 'C m m m', 'acb': 'B m m m', 'bac': 'C m m m', 'bca': 'B m m m', 'cab': 'A m m m', 'cba': 'A m m m'}, 'F 2 2 2': {'abc': 'F 2 2 2', 'acb': 'F 2 2 2', 'bac': 'F 2 2 2', 'bca': 'F 2 2 2', 'cab': 'F 2 2 2', 'cba': 'F 2 2 2'}, 'F d d 2': {'abc': 'F d d 2', 'acb': 'F d 2 d', 'bac': 'F d d 2', 'bca': 'F d 2 d', 'cab': 'F 2 d d', 'cba': 'F 2 d d'}, 'F d d d': {'abc': 'F d d d', 'acb': 'F d d d', 'bac': 'F d d d', 'bca': 'F d d d', 'cab': 'F d d d', 'cba': 'F d d d'}, 'F m m 2': {'abc': 'F m m 2', 'acb': 'F m 2 m', 'bac': 'F m m 2', 'bca': 'F m 2 m', 'cab': 'F 2 m m', 'cba': 'F 2 m m'}, 'F m m m': {'abc': 'F m m m', 'acb': 'F m m m', 'bac': 'F m m m', 'bca': 'F m m m', 'cab': 'F m m m', 'cba': 'F m m m'}, 'I 2 2 2': {'abc': 'I 2 2 2', 'acb': 'I 2 2 2', 'bac': 'I 2 2 2', 'bca': 'I 2 2 2', 'cab': 'I 2 2 2', 'cba': 'I 2 2 2'}, 'I 21 21 21': {'abc': 'I 21 21 21', 'acb': 'I 21 21 21', 'bac': 'I 21 21 21', 'bca': 'I 21 21 21', 'cab': 'I 21 21 21', 'cba': 'I 21 21 21'}, 'I b a 2': {'abc': 'I b a 2', 'acb': 'I c 2 a', 'bac': 'I b a 2', 'bca': 'I c 2 a', 'cab': 'I 2 c b', 'cba': 'I 2 c b'}, 'I b a m': {'abc': 'I b a m', 'acb': 'I c m a', 'bac': 'I b a m', 'bca': 'I c m a', 'cab': 'I m c b', 'cba': 'I m c b'}, 'I b c a': {'abc': 'I b c a', 'acb': 'I c a b', 'bac': 'I c a b', 'bca': 'I b c a', 'cab': 'I b c a', 'cba': 'I c a b'}, 'I m a 2': {'abc': 'I m a 2', 'acb': 'I m 2 a', 'bac': 'I b m 2', 'bca': 'I c 2 m', 'cab': 'I 2 m b', 'cba': 'I 2 c m'}, 'I m m 2': {'abc': 'I m m 2', 'acb': 'I m 2 m', 'bac': 'I m m 2', 'bca': 'I m 2 m', 'cab': 'I 2 m m', 'cba': 'I 2 m m'}, 'I m m a': {'abc': 'I m m a', 'acb': 'I m a m', 'bac': 'I m m b', 'bca': 'I m c m', 'cab': 'I b m m', 'cba': 'I c m m'}, 'I m m m': {'abc': 'I m m m', 'acb': 'I m m m', 'bac': 'I m m m', 'bca': 'I m m m', 'cab': 'I m m m', 'cba': 'I m m m'}, 'P 2 2 2': {'abc': 'P 2 2 2', 'acb': 'P 2 2 2', 'bac': 'P 2 2 2', 'bca': 'P 2 2 2', 'cab': 'P 2 2 2', 'cba': 'P 2 2 2'}, 'P 2 2 21': {'abc': 'P 2 2 21', 'acb': 'P 2 21 2', 'bac': 'P 2 2 21', 'bca': 'P 2 21 2', 'cab': 'P 21 2 2', 'cba': 'P 21 2 2'}, 'P 21 21 2': {'abc': 'P 21 21 2', 'acb': 'P 21 2 21', 'bac': 'P 21 21 2', 'bca': 'P 21 2 21', 'cab': 'P 2 21 21', 'cba': 'P 2 21 21'}, 'P 21 21 21': {'abc': 'P 21 21 21', 'acb': 'P 21 21 21', 'bac': 'P 21 21 21', 'bca': 'P 21 21 21', 'cab': 'P 21 21 21', 'cba': 'P 21 21 21'}, 'P b a 2': {'abc': 'P b a 2', 'acb': 'P c 2 a', 'bac': 'P b a 2', 'bca': 'P c 2 a', 'cab': 'P 2 c b', 'cba': 'P 2 c b'}, 'P b a m': {'abc': 'P b a m', 'acb': 'P c m a', 'bac': 'P b a m', 'bca': 'P c m a', 'cab': 'P m c b', 'cba': 'P m c b'}, 'P b a n': {'abc': 'P b a n', 'acb': 'P c n a', 'bac': 'P b a n', 'bca': 'P c n a', 'cab': 'P n c b', 'cba': 'P n c b'}, 'P b c a': {'abc': 'P b c a', 'acb': 'P c a b', 'bac': 'P c a b', 'bca': 'P b c a', 'cab': 'P b c a', 'cba': 'P c a b'}, 'P b c m': {'abc': 'P b c m', 'acb': 'P c m b', 'bac': 'P c a m', 'bca': 'P b m a', 'cab': 'P m c a', 'cba': 'P m a b'}, 'P b c n': {'abc': 'P b c n', 'acb': 'P c n b', 'bac': 'P c a n', 'bca': 'P b n a', 'cab': 'P n c a', 'cba': 'P n a b'}, 'P c a 21': {'abc': 'P c a 21', 'acb': 'P b 21 a', 'bac': 'P b c 21', 'bca': 'P c 21 b', 'cab': 'P 21 a b', 'cba': 'P 21 c a'}, 'P c c 2': {'abc': 'P c c 2', 'acb': 'P b 2 b', 'bac': 'P c c 2', 'bca': 'P b 2 b', 'cab': 'P 2 a a', 'cba': 'P 2 a a'}, 'P c c a': {'abc': 'P c c a', 'acb': 'P b a b', 'bac': 'P c c b', 'bca': 'P b c b', 'cab': 'P b a a', 'cba': 'P c a a'}, 'P c c m': {'abc': 'P c c m', 'acb': 'P b m b', 'bac': 'P c c m', 'bca': 'P b m b', 'cab': 'P m a a', 'cba': 'P m a a'}, 'P c c n': {'abc': 'P c c n', 'acb': 'P b n b', 'bac': 'P c c n', 'bca': 'P b n b', 'cab': 'P n a a', 'cba': 'P n a a'}, 'P m a 2': {'abc': 'P m a 2', 'acb': 'P m 2 a', 'bac': 'P b m 2', 'bca': 'P c 2 m', 'cab': 'P 2 m b', 'cba': 'P 2 c m'}, 'P m c 21': {'abc': 'P m c 21', 'acb': 'P m 21 b', 'bac': 'P c m 21', 'bca': 'P b 21 m', 'cab': 'P 21 m a', 'cba': 'P 21 a m'}, 'P m m 2': {'abc': 'P m m 2', 'acb': 'P m 2 m', 'bac': 'P m m 2', 'bca': 'P m 2 m', 'cab': 'P 2 m m', 'cba': 'P 2 m m'}, 'P m m a': {'abc': 'P m m a', 'acb': 'P m a m', 'bac': 'P m m b', 'bca': 'P m c m', 'cab': 'P b m m', 'cba': 'P c m m'}, 'P m m m': {'abc': 'P m m m', 'acb': 'P m m m', 'bac': 'P m m m', 'bca': 'P m m m', 'cab': 'P m m m', 'cba': 'P m m m'}, 'P m m n': {'abc': 'P m m n', 'acb': 'P m n m', 'bac': 'P m m n', 'bca': 'P m n m', 'cab': 'P n m m', 'cba': 'P n m m'}, 'P m n 21': {'abc': 'P m n 21', 'acb': 'P m 21 n', 'bac': 'P n m 21', 'bca': 'P n 21 m', 'cab': 'P 21 m n', 'cba': 'P 21 n m'}, 'P m n a': {'abc': 'P m n a', 'acb': 'P m a n', 'bac': 'P n m b', 'bca': 'P n c m', 'cab': 'P b m n', 'cba': 'P c n m'}, 'P n a 21': {'abc': 'P n a 21', 'acb': 'P n 21 a', 'bac': 'P b n 21', 'bca': 'P c 21 n', 'cab': 'P 21 n b', 'cba': 'P 21 c n'}, 'P n c 2': {'abc': 'P n c 2', 'acb': 'P n 2 b', 'bac': 'P c n 2', 'bca': 'P b 2 n', 'cab': 'P 2 n a', 'cba': 'P 2 a n'}, 'P n m a': {'abc': 'P n m a', 'acb': 'P n a m', 'bac': 'P m n b', 'bca': 'P m c n', 'cab': 'P b n m', 'cba': 'P c m n'}, 'P n n 2': {'abc': 'P n n 2', 'acb': 'P n 2 n', 'bac': 'P n n 2', 'bca': 'P n 2 n', 'cab': 'P 2 n n', 'cba': 'P 2 n n'}, 'P n n a': {'abc': 'P n n a', 'acb': 'P n a n', 'bac': 'P n n b', 'bca': 'P n c n', 'cab': 'P b n n', 'cba': 'P c n n'}, 'P n n m': {'abc': 'P n n m', 'acb': 'P n m n', 'bac': 'P n n m', 'bca': 'P n m n', 'cab': 'P m n n', 'cba': 'P m n n'}, 'P n n n': {'abc': 'P n n n', 'acb': 'P n n n', 'bac': 'P n n n', 'bca': 'P n n n', 'cab': 'P n n n', 'cba': 'P n n n'}}

A dictionary of alternate settings for orthorhombic unit cells

GSASIIspc.checkHKLextc(HKL, SGData)[source]

Checks if reflection extinct - does not check centering

Parameters:
  • HKL – [h,k,l]
  • SGData – space group data obtained from SpcGroup
Returns:

True if extinct; False if allowed

GSASIIspc.checkMagextc(HKL, SGData)[source]

Checks if reflection magnetically extinct; does fullcheck (centering, too) uses algorthm from Gallego, et al., J. Appl. Cryst. 45, 1236-1247 (2012)

Parameters:
  • HKL – [h,k,l]
  • SGData – space group data obtained from SpcGroup; must have magnetic symmetry SpnFlp data
Returns:

True if magnetically extinct; False if allowed (to match GenHKLf)

GSASIIspc.fixMono(SpGrp)[source]

fixes b-unique monoclinics in e.g. P 1 2/1c 1 –> P 21/c

GSASIIspc.selftestlist = [<function test0>, <function test1>, <function test2>, <function test3>]

Defines a list of self-tests

GSASIIspc.sgequiv_2002_orthorhombic = {'AE2A': 'A c 2 a', 'AE2M': 'A c 2 m', 'AEA2': 'A b a 2', 'AEAA': 'A b a a', 'AEAM': 'A c a m', 'AEM2': 'A b m 2', 'AEMA': 'A b m a', 'AEMM': 'A b m m', 'B2EB': 'B 2 c b', 'B2EM': 'B 2 c m', 'BBE2': 'B b a 2', 'BBEB': 'B b c b', 'BBEM': 'B b c m', 'BME2': 'B m a 2', 'BMEB': 'B m a b', 'BMEM': 'B m c m', 'C2CE': 'C 2 c b', 'C2ME': 'C 2 m b', 'CC2E': 'C c 2 a', 'CCCE': 'C c c a', 'CCME': 'C c m b', 'CM2E': 'C m 2 a', 'CMCE': 'C m c a', 'CMME': 'C m m a'}

A dictionary of orthorhombic space groups that were renamed in the 2002 Volume A, along with the pre-2002 name. The e designates a double glide-plane

GSASIIspc.spg2origins = {'A b a a': [-0.25, 0, -0.25], 'A c a a': [-0.25, -0.25, 0], 'B b a b': [0, -0.25, -0.25], 'B b c b': [-0.25, -0.25, 0], 'C c c a': [0, -0.25, -0.25], 'C c c b': [-0.25, 0, -0.25], 'F d - c': [-0.375, -0.375, -0.375], 'F d -3': [-0.125, -0.125, -0.125], 'F d -3 c': [-0.375, -0.375, -0.375], 'F d -3 m': [-0.125, -0.125, -0.125], 'F d 3': [-0.125, -0.125, -0.125], 'F d 3 m': [-0.125, -0.125, -0.125], 'F d d d': [-0.125, -0.125, -0.125], 'I 41/a': [0, -0.25, -0.125], 'I 41/a c d': [0, 0.25, -0.125], 'I 41/a m d': [0, 0.25, -0.125], 'P 4/n': [-0.25, -0.25, 0], 'P 4/n b m': [-0.25, -0.25, 0], 'P 4/n c c': [-0.25, -0.25, 0], 'P 4/n m m': [-0.25, -0.25, 0], 'P 4/n n c': [-0.25, -0.25, -0.25], 'P 42/n': [-0.25, -0.25, -0.25], 'P 42/n b c': [-0.25, -0.25, -0.25], 'P 42/n c m': [-0.25, 0.25, -0.25], 'P 42/n m c': [-0.25, 0.25, -0.25], 'P 42/n n m': [-0.25, 0.25, -0.25], 'P b a n': [-0.25, -0.25, 0], 'P c n a': [-0.25, 0, -0.25], 'P m m n': [-0.25, -0.25, 0], 'P m n m': [-0.25, 0, -0.25], 'P n -3 m': [-0.25, -0.25, -0.25], 'P n -3 n': [-0.25, -0.25, -0.25], 'P n 3 m': [-0.25, -0.25, -0.25], 'P n 3 n': [-0.25, -0.25, -0.25], 'P n c b': [0, -0.25, -0.25], 'P n m m': [0, -0.25, -0.25], 'P n n n': [-0.25, -0.25, -0.25], 'p n -3': [-0.25, -0.25, -0.25], 'p n 3': [-0.25, -0.25, -0.25]}

A dictionary of all spacegroups that have 2nd settings; the value is the 1st –> 2nd setting transformation vector as X(2nd) = X(1st)-V, nonstandard ones are included.

GSASIIspc.spgbyNum = [None, 'P 1', 'P -1', 'P 2', 'P 21', 'C 2', 'P m', 'P c', 'C m', 'C c', 'P 2/m', 'P 21/m', 'C 2/m', 'P 2/c', 'P 21/c', 'C 2/c', 'P 2 2 2', 'P 2 2 21', 'P 21 21 2', 'P 21 21 21', 'C 2 2 21', 'C 2 2 2', 'F 2 2 2', 'I 2 2 2', 'I 21 21 21', 'P m m 2', 'P m c 21', 'P c c 2', 'P m a 2', 'P c a 21', 'P n c 2', 'P m n 21', 'P b a 2', 'P n a 21', 'P n n 2', 'C m m 2', 'C m c 21', 'C c c 2', 'A m m 2', 'A b m 2', 'A m a 2', 'A b a 2', 'F m m 2', 'F d d 2', 'I m m 2', 'I b a 2', 'I m a 2', 'P m m m', 'P n n n', 'P c c m', 'P b a n', 'P m m a', 'P n n a', 'P m n a', 'P c c a', 'P b a m', 'P c c n', 'P b c m', 'P n n m', 'P m m n', 'P b c n', 'P b c a', 'P n m a', 'C m c m', 'C m c a', 'C m m m', 'C c c m', 'C m m a', 'C c c a', 'F m m m', 'F d d d', 'I m m m', 'I b a m', 'I b c a', 'I m m a', 'P 4', 'P 41', 'P 42', 'P 43', 'I 4', 'I 41', 'P -4', 'I -4', 'P 4/m', 'P 42/m', 'P 4/n', 'P 42/n', 'I 4/m', 'I 41/a', 'P 4 2 2', 'P 4 21 2', 'P 41 2 2', 'P 41 21 2', 'P 42 2 2', 'P 42 21 2', 'P 43 2 2', 'P 43 21 2', 'I 4 2 2', 'I 41 2 2', 'P 4 m m', 'P 4 b m', 'P 42 c m', 'P 42 n m', 'P 4 c c', 'P 4 n c', 'P 42 m c', 'P 42 b c', 'I 4 m m', 'I 4 c m', 'I 41 m d', 'I 41 c d', 'P -4 2 m', 'P -4 2 c', 'P -4 21 m', 'P -4 21 c', 'P -4 m 2', 'P -4 c 2', 'P -4 b 2', 'P -4 n 2', 'I -4 m 2', 'I -4 c 2', 'I -4 2 m', 'I -4 2 d', 'P 4/m m m', 'P 4/m c c', 'P 4/n b m', 'P 4/n n c', 'P 4/m b m', 'P 4/m n c', 'P 4/n m m', 'P 4/n c c', 'P 42/m m c', 'P 42/m c m', 'P 42/n b c', 'P 42/n n m', 'P 42/m b c', 'P 42/m n m', 'P 42/n m c', 'P 42/n c m', 'I 4/m m m', 'I 4/m c m', 'I 41/a m d', 'I 41/a c d', 'P 3', 'P 31', 'P 32', 'R 3', 'P -3', 'R -3', 'P 3 1 2', 'P 3 2 1', 'P 31 1 2', 'P 31 2 1', 'P 32 1 2', 'P 32 2 1', 'R 3 2', 'P 3 m 1', 'P 3 1 m', 'P 3 c 1', 'P 3 1 c', 'R 3 m', 'R 3 c', 'P -3 1 m', 'P -3 1 c', 'P -3 m 1', 'P -3 c 1', 'R -3 m', 'R -3 c', 'P 6', 'P 61', 'P 65', 'P 62', 'P 64', 'P 63', 'P -6', 'P 6/m', 'P 63/m', 'P 6 2 2', 'P 61 2 2', 'P 65 2 2', 'P 62 2 2', 'P 64 2 2', 'P 63 2 2', 'P 6 m m', 'P 6 c c', 'P 63 c m', 'P 63 m c', 'P -6 m 2', 'P -6 c 2', 'P -6 2 m', 'P -6 2 c', 'P 6/m m m', 'P 6/m c c', 'P 63/m c m', 'P 63/m m c', 'P 2 3', 'F 2 3', 'I 2 3', 'P 21 3', 'I 21 3', 'P m 3', 'P n 3', 'F m -3', 'F d -3', 'I m -3', 'P a -3', 'I a -3', 'P 4 3 2', 'P 42 3 2', 'F 4 3 2', 'F 41 3 2', 'I 4 3 2', 'P 43 3 2', 'P 41 3 2', 'I 41 3 2', 'P -4 3 m', 'F -4 3 m', 'I -4 3 m', 'P -4 3 n', 'F -4 3 c', 'I -4 3 d', 'P m -3 m', 'P n -3 n', 'P m -3 n', 'P n -3 m', 'F m -3 m', 'F m -3 c', 'F d -3 m', 'F d -3 c', 'I m -3 m', 'I a -3 d']

Space groups indexed by number

GSASIIspc.spglist = {'A2/m': ('A 2', 'A m', 'A a', 'A n', 'A 2/m', 'A 2/a', 'A 2/n'), 'Ammm': ('A 21 2 2', 'A 2 2 2', 'A 2 m m', 'A 21 m a', 'A 21 a m', 'A 2 a a', 'A m 2 m', 'A m m 2', 'A b m 2', 'A c 2 m', 'A m a 2', 'A m 2 a', 'A b a 2', 'A c 2 a', 'A m m a', 'A m a m', 'A b m a', 'A c a m', 'A m m m', 'A m a a', 'A b m m', 'A c m m', 'A c a a', 'A b a a'), 'Bmmm': ('B 2 21 2', 'B 2 2 2', 'B m 2 m', 'B m 21 b', 'B b 21 m', 'B b 2 b', 'B m m 2', 'B 2 m m', 'B 2 c m', 'B m a 2', 'B 2 m b', 'B b m 2', 'B 2 c b', 'B b a 2', 'B b m m', 'B m m b', 'B b c m', 'B m a b', 'B m m m', 'B b m b', 'B m a m', 'B m c m', 'B b a b', 'B b c b'), 'C1': ('C 1', 'C -1'), 'C2/m': ('C 2', 'C m', 'C c', 'C n', 'C 2/m', 'C 2/c', 'C 2/n'), 'Cmmm': ('C 2 2 21', 'C 2 2 2', 'C m m 2', 'C m c 21', 'C c m 21', 'C c c 2', 'C m 2 m', 'C 2 m m', 'C m 2 a', 'C 2 m b', 'C c 2 m', 'C 2 c m', 'C c 2 a', 'C 2 c b', 'C m c m', 'C c m m', 'C m c a', 'C c m b', 'C m m m', 'C c c m', 'C m m a', 'C m m b', 'C c c a', 'C c c b'), 'Fm3m': ('F 2 3', 'F m 3', 'F m -3', 'F d 3', 'F d -3', 'F 4 3 2', 'F 41 3 2', 'F -4 3 m', 'F -4 3 c', 'F m 3 m', 'F m -3 m', 'F m 3 c', 'F m -3 c', 'F d 3 m', 'F d -3 m', 'F d 3 c', 'F d -3 c'), 'Fmmm': ('F 2 2 2', 'F m m m', 'F d d d', 'F m m 2', 'F m 2 m', 'F 2 m m', 'F d d 2', 'F d 2 d', 'F 2 d d'), 'I2/m': ('I 2', 'I m', 'I a', 'I n', 'I c', 'I 2/m', 'I 2/a', 'I 2/c', 'I 2/n'), 'I4/mmm': ('I 4', 'I 41', 'I -4', 'I 4/m', 'I 41/a', 'I 4 2 2', 'I 41 2 2', 'I 4 m m', 'I 4 c m', 'I 41 m d', 'I 41 c d', 'I -4 m 2', 'I -4 c 2', 'I -4 2 m', 'I -4 2 d', 'I 4/m m m', 'I 4/m c m', 'I 41/a m d', 'I 41/a c d'), 'Im3m': ('I 2 3', 'I 21 3', 'I m 3', 'I m -3', 'I a 3', 'I a -3', 'I 4 3 2', 'I 41 3 2', 'I -4 3 m', 'I -4 3 d', 'I m -3 m', 'I m 3 m', 'I a 3 d', 'I a -3 d', 'I n 3 n', 'I n -3 n'), 'Immm': ('I 2 2 2', 'I 21 21 21', 'I m m 2', 'I m 2 m', 'I 2 m m', 'I b a 2', 'I 2 c b', 'I c 2 a', 'I m a 2', 'I 2 m b', 'I c 2 m', 'I m 2 a', 'I b m 2', 'I 2 c m', 'I m m m', 'I b a m', 'I m c b', 'I c m a', 'I b c a', 'I c a b', 'I m m a', 'I b m m ', 'I m c m', 'I m a m', 'I m m b', 'I c m m'), 'P1': ('P 1', 'P -1'), 'P2/m': ('P 2', 'P 21', 'P m', 'P a', 'P c', 'P n', 'P 2/m', 'P 21/m', 'P 2/c', 'P 2/a', 'P 2/n', 'P 21/c', 'P 21/a', 'P 21/n'), 'P4/mmm': ('P 4', 'P 41', 'P 42', 'P 43', 'P -4', 'P 4/m', 'P 42/m', 'P 4/n', 'P 42/n', 'P 4 2 2', 'P 4 21 2', 'P 41 2 2', 'P 41 21 2', 'P 42 2 2', 'P 42 21 2', 'P 43 2 2', 'P 43 21 2', 'P 4 m m', 'P 4 b m', 'P 42 c m', 'P 42 n m', 'P 4 c c', 'P 4 n c', 'P 42 m c', 'P 42 b c', 'P -4 2 m', 'P -4 2 c', 'P -4 21 m', 'P -4 21 c', 'P -4 m 2', 'P -4 c 2', 'P -4 b 2', 'P -4 n 2', 'P 4/m m m', 'P 4/m c c', 'P 4/n b m', 'P 4/n n c', 'P 4/m b m', 'P 4/m n c', 'P 4/n m m', 'P 4/n c c', 'P 42/m m c', 'P 42/m c m', 'P 42/n b c', 'P 42/n n m', 'P 42/m b c', 'P 42/m n m', 'P 42/n m c', 'P 42/n c m'), 'P6/mmm': ('P 3', 'P 31', 'P 32', 'P -3', 'P 3 1 2', 'P 3 2 1', 'P 31 1 2', 'P 31 2 1', 'P 32 1 2', 'P 32 2 1', 'P 3 m 1', 'P 3 1 m', 'P 3 c 1', 'P 3 1 c', 'P -3 1 m', 'P -3 1 c', 'P -3 m 1', 'P -3 c 1', 'P 6', 'P 61', 'P 65', 'P 62', 'P 64', 'P 63', 'P -6', 'P 6/m', 'P 63/m', 'P 6 2 2', 'P 61 2 2', 'P 65 2 2', 'P 62 2 2', 'P 64 2 2', 'P 63 2 2', 'P 6 m m', 'P 6 c c', 'P 63 c m', 'P 63 m c', 'P -6 m 2', 'P -6 c 2', 'P -6 2 m', 'P -6 2 c', 'P 6/m m m', 'P 6/m c c', 'P 63/m c m', 'P 63/m m c'), 'Pm3m': ('P 2 3', 'P 21 3', 'P m 3', 'P m -3', 'P n 3', 'P n -3', 'P a 3', 'P a -3', 'P 4 3 2', 'P 42 3 2', 'P 43 3 2', 'P 41 3 2', 'P -4 3 m', 'P -4 3 n', 'P m 3 m', 'P m -3 m', 'P n 3 n', 'P n -3 n', 'P m 3 n', 'P m -3 n', 'P n 3 m', 'P n -3 m'), 'Pmmm': ('P 2 2 2', 'P 2 2 21', 'P 21 2 2', 'P 2 21 2', 'P 21 21 2', 'P 2 21 21', 'P 21 2 21', 'P 21 21 21', 'P m m 2', 'P 2 m m', 'P m 2 m', 'P m c 21', 'P 21 m a', 'P b 21 m', 'P m 21 b', 'P c m 21', 'P 21 a m', 'P c c 2', 'P 2 a a', 'P b 2 b', 'P m a 2', 'P 2 m b', 'P c 2 m', 'P m 2 a', 'P b m 2', 'P 2 c m', 'P c a 21', 'P 21 a b', 'P c 21 b', 'P b 21 a', 'P b c 21', 'P 21 c a', 'P n c 2', 'P 2 n a', 'P b 2 n', 'P n 2 b', 'P c n 2', 'P 2 a n', 'P m n 21', 'P 21 m n', 'P n 21 m', 'P m 21 n', 'P n m 21', 'P 21 n m', 'P b a 2', 'P 2 c b', 'P c 2 a', 'P n a 21', 'P 21 n b', 'P c 21 n', 'P n 21 a', 'P b n 21', 'P 21 c n', 'P n n 2', 'P 2 n n', 'P n 2 n', 'P m m m', 'P n n n', 'P c c m', 'P m a a', 'P b m b', 'P b a n', 'P n c b', 'P c n a', 'P m m a', 'P b m m', 'P m c m', 'P m a m', 'P m m b', 'P c m m', 'P n n a', 'P b n n', 'P n c n', 'P n a n', 'P n n b', 'P c n n', 'P m n a', 'P b m n', 'P n c m', 'P m a n', 'P n m b', 'P c n m', 'P c c a', 'P b a a', 'P b c b', 'P b a b', 'P c c b', 'P c a a', 'P b a m', 'P m c b', 'P c m a', 'P c c n', 'P n a a', 'P b n b', 'P b c m', 'P m c a', 'P b m a', 'P c m b', 'P c a m', 'P m a b', 'P n n m', 'P m n n', 'P n m n', 'P m m n', 'P n m m', 'P m n m', 'P b c n', 'P n c a', 'P b n a', 'P c n b', 'P c a n', 'P n a b', 'P b c a', 'P c a b', 'P n m a', 'P b n m', 'P m c n', 'P n a m', 'P m n b', 'P c m n'), 'R3-H': ('R 3', 'R -3', 'R 3 2', 'R 3 m', 'R 3 c', 'R -3 m', 'R -3 c')}

A dictionary of space groups as ordered and named in the pre-2002 International Tables Volume A, except that spaces are used following the GSAS convention to separate the different crystallographic directions. Note that the symmetry codes here will recognize many non-standard space group symbols with different settings. They are ordered by Laue group

GSASIIspc.splitSSsym(SSymbol)[source]

Splits supersymmetry symbol into two lists of strings

GSASIIspc.test0()[source]

self-test #0: exercise MoveToUnitCell

GSASIIspc.test1()[source]

self-test #1: SpcGroup against previous results

GSASIIspc.test2()[source]

self-test #2: SpcGroup against cctbx (sgtbx) computations

GSASIIspc.test3()[source]

self-test #3: exercise SytSym (includes GetOprPtrName, GenAtom, GetKNsym) for selected space groups against info in IT Volume A

4.7. GSASIIdata: Data for computations

At present this module defines one dict, ramachandranDist, which contains arrays for All and specific amino acids.

4.8. GSASIIfiles: data (non-GUI) I/O routines

Module with miscellaneous routines for input and output from files.

This module should not contain any references to wxPython so that it can be imported for scriptable use or potentially on clients where wx is not installed.

Future refactoring: This module and GSASIIIO.py needs some work to move non-wx routines here. It may will likely make sense to rename the module(s) at that point.

GSASIIfiles.G2Print(*args, **kwargs)[source]

Print with filtering based level of output (see G2SetPrintLevel()). Use G2Print() as replacement for print().

Parameters:mode (str) – if specified, this should contain the mode for printing (‘error’, ‘warn’ or anything else). If not specified, the first argument of the print command (args[0]) should contain the string ‘error’ for error messages and ‘warn’ for warning messages (capitalization and additional letters ignored.)
GSASIIfiles.G2SetPrintLevel(level)[source]

Set the level of output from calls to G2Print(), which should be used in place of print() within GSASII. Settings for the mode are ‘all’, ‘warn’, ‘error’ or ‘none’

Parameters:level (str) – a string used to set the print level, which may be ‘all’, ‘warn’, ‘error’ or ‘none’. Note that capitalization and extra letters in level are ignored, so ‘Warn’, ‘warnings’, etc. will all set the mode to ‘warn’
GSASIIfiles.G2printLevel = 'all'

This defines the level of output from calls to G2Print(), which should be used in place of print() within this module. Settings for this are ‘all’, ‘warn’, ‘error’ or ‘none’. Also see: G2Print() and G2SetPrintLevel().

GSASIIfiles.GetColumnMetadata(reader)[source]

Add metadata to an image from a column-type metadata file using readColMetadata()

Parameters:reader – a reader object from reading an image
GSASIIfiles.LoadControls(Slines, data)[source]

Read values from a .imctrl (Image Controls) file

GSASIIfiles.LoadExportRoutines(parent, traceback=False)[source]

Routine to locate GSASII exporters

GSASIIfiles.LoadImportRoutines(prefix, errprefix=None, traceback=False)[source]

Routine to locate GSASII importers matching a prefix string

GSASIIfiles.PDFWrite(PDFentry, fileroot, PDFsaves, PDFControls, Inst={}, Limits=[])[source]

Write PDF-related data (G(r), S(Q),…) into files, as selected.

Parameters:
  • PDFentry (str) – name of the PDF entry in the tree. This is used for comments in the file specifying where it came from; it can be arbitrary
  • fileroot (str) – name of file(s) to be written. The extension will be ignored.
  • PDFsaves (list) – flags that determine what type of file will be written: PDFsaves[0], if True writes a I(Q) file with a .iq extension PDFsaves[1], if True writes a S(Q) file with a .sq extension PDFsaves[2], if True writes a F(Q) file with a .fq extension PDFsaves[3], if True writes a G(r) file with a .gr extension PDFsaves[4], if True writes G(r) in a pdfGUI input file with a .gr extension. Note that if PDFsaves[3] and PDFsaves[4] are both True, the pdfGUI overwrites the G(r) file. PDFsaves[5], if True writes F(Q) & g(R) with .fq & .gr extensions overwrites these if selected by option 2, 3 or 4
  • PDFControls (dict) – The PDF parameters and computed results
  • Inst (dict) – Instrument parameters from the PDWR entry used to compute the PDF. Needed only when PDFsaves[4] is True.
  • Limits (list) – Computation limits from the PDWR entry used to compute the PDF. Needed only when PDFsaves[4] is True.
GSASIIfiles.ReadPowderInstprm(instLines, bank, databanks, rd)[source]

Read lines from a GSAS-II (new) instrument parameter file similar to G2pwdGUI.OnLoad If instprm file has multiple banks each with header #Bank n: …, this finds matching bank no. to load - problem with nonmatches?

Note that this routine performs a similar role to GSASIIdataGUI.GSASII.ReadPowderInstprm(), but that will call a GUI routine for selection when needed. This routine will raise exceptions on errors and will select the first bank when a choice might be appropriate. TODO: refactor to combine the two routines.

Parameters:
  • instLines (list) – strings from GSAS-II parameter file; can be concatenated with ‘;’
  • bank (int) – bank number to check when instprm file has ‘#BANK n:…’ strings when bank = n then use parameters; otherwise skip that set. Ignored if BANK n: not present. NB: this kind of instprm file made by a Save all profile command in Instrument Par ameters
Return dict:

Inst instrument parameter dict if OK, or str: Error message if failed

(transliterated from GSASIIdataGUI.py:1235 (rev 3008), function of the same name)

GSASIIfiles.RereadImageData(ImageReaderlist, imagefile, ImageTag=None, FormatName='')[source]

Read a single image with an image importer. This is called to reread an image after it has already been imported, so it is not necessary to reload metadata.

Based on GetImageData.GetImageData() which this can replace where imageOnly=True

Parameters:
  • ImageReaderlist (list) – list of Reader objects for images
  • imagefile (str) – name of image file
  • ImageTag (int/str) – specifies a particular image to be read from a file. First image is read if None (default).
  • formatName (str) – the image reader formatName
Returns:

an image as a numpy array

GSASIIfiles.SetPowderInstParms(Iparm, rd)[source]

extracts values from instrument parameters in rd.instdict or in array Iparm. Create and return the contents of the instrument parameter tree entry.

GSASIIfiles.WriteControls(filename, data)[source]

Write current values to a .imctrl (Image Controls) file

GSASIIfiles.evalColMetadataDicts(items, labels, lbldict, keyCols, keyExp, ShowError=False)[source]

Evaluate the metadata for a line in the .par file

GSASIIfiles.find(name, path)[source]

find 1st occurance of file in path

GSASIIfiles.readColMetadata(imagefile)[source]

Reads image metadata from a column-oriented metadata table (1-ID style .par file). Called by GetColumnMetadata()

The .par file has any number of columns separated by spaces. The directory for the file must be specified in Config variable config_example.Column_Metadata_directory. As an index to the .par file a second “label file” must be specified with the same file root name as the .par file but the extension must be .XXX_lbls (where .XXX is the extension of the image) or if that is not present extension .lbls.

Parameters:imagefile (str) – the full name of the image file (with extension, directory optional)
Returns:a dict with parameter values. Named parameters will have the type based on the specified Python function, named columns will be character strings

The contents of the label file will look like this:

# define keywords
filename:lambda x,y: "{}_{:0>6}".format(x,y)|33,34
distance: float | 75
wavelength:lambda keV: 12.398425/float(keV)|9
pixelSize:lambda x: [74.8, 74.8]|0
ISOlikeDate: lambda dow,m,d,t,y:"{}-{}-{}T{} ({})".format(y,m,d,t,dow)|0,1,2,3,4
Temperature: float|53
FreePrm2: int | 34 | Free Parm2 Label
# define other variables
0:day
1:month
2:date
3:time
4:year
7:I_ring
This file contains three types of lines in any order.
  • Named parameters are evaluated with user-supplied Python code (see subsequent information). Specific named parameters are used to determine values that are used for image interpretation (see table, below). Any others are copied to the Comments subsection of the Image tree item.
  • Column labels are defined with a column number (integer) followed by a colon (:) and a label to be assigned to that column. All labeled columns are copied to the Image’s Comments subsection.
  • Comments are any line that does not contain a colon.

Note that columns are numbered starting at zero.

Any named parameter may be defined provided it is not a valid integer, but the named parameters in the table have special meanings, as descibed. The parameter name is followed by a colon. After the colon, specify Python code that defines or specifies a function that will be called to generate a value for that parameter.

Note that several keywords, if defined in the Comments, will be found and placed in the appropriate section of the powder histogram(s)’s Sample Parameters after an integration: Temperature, Pressure, Time, FreePrm1, FreePrm2, FreePrm3, Omega, Chi, and Phi.

After the Python code, supply a vertical bar (|) and then a list of one more more columns that will be supplied as arguments to that function.

Note that the labels for the three FreePrm items can be changed by including that label as a third item with an additional vertical bar. Labels will be ignored for any other named parameters.

The examples above are discussed here:

filename:lambda x,y: "{}_{:0>6}".format(x,y)|33,34

Here the function to be used is defined with a lambda statement:

lambda x,y: "{}_{:0>6}".format(x,y)

This function will use the format function to create a file name from the contents of columns 33 and 34. The first parameter (x, col. 33) is inserted directly into the file name, followed by a underscore (_), followed by the second parameter (y, col. 34), which will be left-padded with zeros to six characters (format directive :0>6).

When there will be more than one image generated per line in the .par file, an alternate way to generate list of file names takes into account the number of images generated:

lambda x,y,z: ["{}_{:0>6}".format(x,int(y)+i) for i in range(int(z))]

Here a third parameter is used to specify the number of images generated, where the image number is incremented for each image.

distance: float | 75
Here the contents of column 75 will be converted to a floating point number by calling float on it. Note that the spaces here are ignored.
wavelength:lambda keV: 12.398425/float(keV)|9
Here we define an algebraic expression to convert an energy in keV to a wavelength and pass the contents of column 9 as that input energy
pixelSize:lambda x: [74.8, 74.8]|0
In this case the pixel size is a constant (a list of two numbers). The first column is passed as an argument as at least one argument is required, but that value is not used in the expression.
ISOlikeDate: lambda dow,m,d,t,y:"{}-{}-{}T{} ({})".format(y,m,d,t,dow)|0,1,2,3,4
This example defines a parameter that takes items in the first five columns and formats them in a different way. This parameter is not one of the pre-defined parameter names below. Some external code could be used to change the month string (argument m) to a integer from 1 to 12.
FreePrm2: int | 34 | Free Parm2 Label
In this example, the contents of column 34 will be converted to an integer and placed as the second free-named parameter in the Sample Parameters after an integration. The label for this parameter will be changed to “Free Parm2 Label”.

Pre-defined parameter names

keyword required type Description
filename yes str or list generates the file name prefix for the matching image file (MyImage001 for file /tmp/MyImage001.tif) or a list of file names.
polarization no float generates the polarization expected based on the monochromator angle, defaults to 0.99.
center no list of 2 floats generates the approximate beam center on the detector in mm, such as [204.8, 204.8].
distance yes float generates the distance from the sample to the detector in mm
pixelSize no list of 2 floats generates the size of the pixels in microns such as [200.0, 200.0].
wavelength yes float generates the wavelength in Angstroms
GSASIIfiles.readColMetadataLabels(lblFil)[source]

Read the .*lbls file and setup for metadata assignments

GSASIIfiles.readMasks(filename, masks, ignoreThreshold)[source]

Read a GSAS-II masks file

GSASIIfiles.sfloat(S)[source]

Convert a string to float. An empty field or a unconvertable value is treated as zero

4.9. GSASIImpsubs: routines used in multiprocessing

The routines here are called either directly when GSAS-II is used without multiprocessing or in separate cores when multiprocessing is used.

These routines are designed to be used in one of two ways:

  • when multiprocessing is enabled (see global variable useMP) the computational routines are called in separate Python interpreter that is created and then deleted after use.
  • when useMP is False, these routines are called directly from the main “thread”.

Note that GSASIImpsubs.InitMP() should be called before any of the other routines in this module are used.

GSASIImpsubs.ComputePwdrProfCW(profList)[source]

Compute the peaks profile for a set of CW peaks and add into the yc array

GSASIImpsubs.ComputePwdrProfPink(profList)[source]

Compute the peaks profile for a set of TOF peaks and add into the yc array

GSASIImpsubs.ComputePwdrProfTOF(profList)[source]

Compute the peaks profile for a set of TOF peaks and add into the yc array

GSASIImpsubs.InitFobsSqGlobals(x1, ratio1, shl1, xB1, xF1, im1, lamRatio1, kRatio1, xMask1, Ka21)[source]

Initialize for the computation of Fobs Squared for powder histograms. Puts lots of junk into the global namespace in this module.

GSASIImpsubs.InitMP(allowMP=True)[source]

Called to initialize use of Multiprocessing

GSASIImpsubs.InitPwdrProfGlobals(im1, shl1, x1)[source]

Initialize for the computation of Fobs Squared for powder histograms. Puts lots of junk into the global namespace in this module.

GSASIImpsubs.ResetMP()[source]

Call after changing Config var ‘Multiprocessing_cores’ to force a resetting of the useMP from the parameter.

4.10. ElementTable: Periodic Table Data

Element table data for building periodic table with valences & JMOL colors. Need these in case we go back to this periodic table coloring scheme.

Defines list ElTable which contains all defined oxidation states for each element, the location in the table, an element name, a color, a size and a second color.

4.11. FormFactors: Scattering Data

Contains atomic scattering factors from “New Analytical Scattering Factor Functions for Free Atoms and Ions for Free Atoms and Ions”, D. Waasmaier & A. Kirfel, Acta Cryst. (1995). A51, 416-413.

Also, tabulated coefficients for calculation of Compton Cross Section as a function of sin(theta)/lambda from “Analytic Approximations to Incoherently Scattered X-Ray Intensities”, H. H. M. Balyuzi, Acta Cryst. (1975). A31, 600.

4.12. ImageCalibrants: Calibration Standards

GSASII powder calibrants in dictionary ImageCalibrants.Calibrants containing substances commonly used for powder calibrations for image data.

Each entry in ImageCalibrants consists of:

 'key':([Bravais num,],[space group,],[(a,b,c,alpha,beta,gamma),],no. lines skipped,(dmin,pixLimit,cutOff),(absent list))

* See below for Bravais num assignments.
* The space group may be an empty string.
* The absent list is optional; it gives indices of lines that have no intensity despite being allowed - see the Si example below; counting begins at zero

As an example:

'LaB6  SRM660a':([2,],['',][(4.1569162,4.1569162,4.1569162,90,90,90),],0,(1.0,10,10.)),

For calibrants that are mixtures, the “Bravais num” and “(a,b,…)” values are repeated, as in this case:

'LaB6 & CeO2':([2,0],['',''] [(4.1569,4.1569,4.1569,90,90,90),(5.4117,5.4117,5.4117,90,90,90)], 0, (1.0,2,1.)),

Note that Si has reflections (the 4th, 11th,…) that are not extinct by symmetry but still have zero intensity. These are supplied in the final list:

'Si':([0,],['F d 3 m'],[(5.4311946,5.4311946,5.4311946,90,90,90),],0,(1.,10,10.),(3,10,13,20,23,26,33,35,40,43)),
Note, the Bravais numbers are:
  • 0 F cubic
  • 1 I cubic
  • 2 P cubic
  • 3 R hexagonal (trigonal not rhombohedral)
  • 4 P hexagonal
  • 5 I tetragonal
  • 6 P tetragonal
  • 7 F orthorhombic
  • 8 I orthorhombic
  • 9 C orthorhombic
  • 10 P orthorhombic
  • 11 C monoclinic
  • 12 P monoclinic
  • 13 P triclinic

4.12.1. User-Defined Calibrants

To expand this list with locally needed additions, do not modify this ImageCalibrants.py file, because you may lose these changes during a software update. Instead duplicate the format of this file in a file named UserCalibrants.py and there define the material(s) you want:

Calibrants={
  'LaB6 skip 2 lines':([2,],['',],[(4.1569162,4.1569162,4.1569162,90,90,90),],2,(1.0,10,10),()),
}

New key values will be added to the list of options. If a key is duplicated, the information in UserCalibrants.py will override the entry in this (the ImageCalibrants.py file).

4.13. atmdata: Table of atomic data

The entries here are:

XrayFF: a dict of form factor coefficients

AtmSize: atom Sizes, bond radii, angle radii, H-bond radii

AtmBlens: atom masses & neutron scattering length (b,b’), sig(incoh) @ 1A

MagFF: neutron magnetic form factor coeff: M for j<0> & N for j<2>

Sources:

Exponential scattering factor curve coeficients, Cromer and Waber(1971) Int. Tables Vol. IV. Delta f’ and delta f” terms calcd via D.T. Cromer & D.A. Liberman (1981), Acta Cryst. A37, 267-268. Atomic weights from CRC 56th Edition

Neutron scattering lengths & abs. cross sections from H. Rauch & W. Waschowski, Neutron Data Booklet, 2003. X-ray <j0> & <j2> coeff. from Intl. Tables for Cryst, Vol. C 5-d <j0> & <j2> from Kobayashi K, Nagao T, Ito M. Acta Crystallogr A67, 473-480 (2011)

Neutron anomalous coeff (LS) from fitting Lynn & Seeger, At. Data & Nuc. Data Tables, 44, 191-207(1990)

O2- x-ray scattering factor from Tokonami (1965) Acta Cryst 19, 486

At wts from 14th ed Nuclides & Isotopes, 1989 GE Co.

4.14. defaultIparms: Table of instrument parameters

Defines some default instrument parameters. Format for each is a list of strings finished with a ‘ ‘. Begin with ‘#GSAS-II…’ as the reader routine checks this. Each line can be comprised of a block of ‘;’ delimited name:value pairs. All instrument parameters must be included; even those = 0. Use a GSAS-II instprm file as a source for the entries.

For a new entry:

Append a useful name to defaultIparms_lbl.

Append the list of lines to defaultIparms.

defaultIparm_lbl: defines a list of labels.

defaultIparms: defines a list of multiple strings with values for each set of defaults.

4.15. ReadMarCCDFrame: Read Mar Files

class ReadMarCCDFrame.marFrame(File, byteOrd='<', IFD={})[source]

A class to extract correct mar header and image info from a MarCCD file

Parameters:
  • File (str) – file object [from open()]
  • byteOrd – ‘<’ (default) or ‘>’
  • IFD (dict) –

    ?