GSAS-II Utility Modules

GSASIIdata: Data for computations

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

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.

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.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.SetVersionNumber(RevString)[source]

Set the subversion version number

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

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

GSASIIpath.svnFindLocalChanges(fpath='/Users/toby/software/G2/GSASII')[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.svnGetLog(fpath='/Users/toby/software/G2/GSASII', version=None)[source]

Get the revision log information for a specific version of the

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='/Users/toby/software/G2/GSASII', 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)

GSASIIpath.svnUpdateDir(fpath='/Users/toby/software/G2/GSASII', version=None)[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)[source]

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

GSASIIpath.whichsvn()[source]

Returns a path to the subversion exe file, if any is found. Searches the current path as well as subdirectory “svn” and “svn/bin” in the location of the GSASII source files.

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

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.

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 = {'Tree': None, 'Logging': False, 'LastPaintAction': 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.

config.py: Configuration options

This file contains optional configuration options for GSAS-II. Note that this file is not required to be present and code should be written to provide the default behavior if the file is not present or if any configuration variable is not set, but please do place a docstring here for every used config variable explaining what it does.

config_example.Enable_logging = None

Set to True to enable use of command logging

config_example.logging_debug = None

Set to True to enable debug for logging

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)[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.GetMagFormFacCoeff(El)[source]

Read magnetic form factor data from atomdata.asc file

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.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.getBLvalues(BLtables, ifList=False)[source]

Needs a doc string

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

Needs a doc string

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_1 h^2 + A_2 k^2 + A_3 l^2 + A_4 hk + A_5 hl + A_6 kl}\), where d is the d-spacing, and \(d^*\) is the reciprocal lattice spacing, \(Q = 2 \pi d^* = 2 \pi / d\)

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.Flnh(Start, SHCoef, phi, beta, SGData)[source]

needs doc string

GSASIIlattice.GenHBravais(dmin, Bravais, A)[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 C orthorhombic 10 P orthorhombic 11 C monoclinic 12 P monoclinic 13 P triclinic
  • A – reciprocal metric tensor elements as [G11,G22,G33,2*G12,2*G13,2*G23]
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.GenSHCoeff(SGLaue, SamSym, L, IfLMN=True)[source]

needs doc string

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.Hx2Rh(Hx)[source]

needs doc string

GSASIIlattice.MaxIndex(dmin, A)[source]

needs doc string

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

needs doc string

GSASIIlattice.Pos2dsp(Inst, pos)[source]

convert powder pattern position (2-theta or TOF, musec) to d-spacing ignores secondary effects (e.g. difB in TOF)

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

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.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_rDsqT(H, A, Z, tof, difC)[source]

needs doc string

GSASIIlattice.calc_rDsqZ(H, A, 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)[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.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.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.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 = [<function test0 at 0x108e0cf50>, <function test1 at 0x108e0f050>, <function test2 at 0x108e0f0c8>, <function test3 at 0x108e0f140>, <function test4 at 0x108e0f1b8>, <function test5 at 0x108e0f230>, <function test6 at 0x108e0f2a8>, <function test7 at 0x108e0f320>, <function test8 at 0x108e0f398>, <function test9 at 0x108e0f410>]

Defines a list of self-tests

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

needs doc string

Parameters:
  • HKLd – a list of [h,k,l,d,...];
  • ifreverse – True for largest d first
  • ifdup – True if duplicate d-spacings allowed
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.uniqueCombinations(items, n)[source]

take n distinct items, order is irrelevant

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: The GSAS-II operations for each symmetry operation as a tuple with (center,mult,opnum), 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 and opnum is the number for the symmetry operation, in SGOps (starting with 0).
GSASIIspc.ApplyStringOps(A, SGData, X, Uij=[])[source]

Needs a doc string

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]]

  • [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

GSASIIspc.GenHKLf(HKL, SGData)[source]

Uses old GSAS Fortran routine genhkl.for

Parameters:
  • HKL – [h,k,l]
  • 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

GSASIIspc.GetCSuinel(siteSym)[source]

returns Uij terms, multipliers, GUI flags & Uiso2Uij multipliers

GSASIIspc.GetCSxinel(siteSym)[source]

Needs a doc string

GSASIIspc.GetKNsym(key)[source]

Needs a doc string

GSASIIspc.GetNXUPQsym(siteSym)[source]

Needs a doc string

GSASIIspc.GetOprPtrName(key)[source]

Needs a doc string

GSASIIspc.HStrainNames(SGData)[source]

Needs a doc string

GSASIIspc.Latt2text(Latt)[source]

From lattice type (‘P’,A’, etc.) returns ‘;’ delimited cell centering vectors

GSASIIspc.MT2text(M, T)[source]

From space group matrix/translation operator returns text version

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: array of opposite positions; 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)[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
GSASIIspc.SGpolar(SGData)[source]

Determine identity of polar axes if any

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
  • ‘Laue’: 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
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 two element tuple:

  • The 1st element is a code for the site symmetry (see GetKNsym)
  • The 2nd element is the site multiplicity
GSASIIspc.selftestlist = [<function test0 at 0x108e38aa0>, <function test1 at 0x108e38b18>, <function test2 at 0x108e38b90>, <function test3 at 0x108e38c08>]

Defines a list of self-tests

GSASIIspc.test0()[source]

self-test #0: exercise MoveToUnitCell

GSASIIspc.test1()[source]

self-test #1: SpcGroup and SGPrint 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

gltext: draw OpenGL text

Routines that render text on OpenGL without use of GLUT.

Code written by Christian Brugger & Stefan Hacker and distributed under GNU General Public License.

class gltext.Text(text='Text', font=None, font_size=8, foreground=wx.Colour(), centered=False)[source]

A simple class for using System Fonts to display text in an OpenGL scene. The Text adds a global Cache of already created text elements to TextElement’s base functionality so you can save some memory and increase speed

centered

Display the text centered

draw_text(position=wx.Point(0, 0), scale=1.0, rotation=0)[source]

position (wx.Point) - x/y Position to draw in scene scale (float) - Scale rotation (int) - Rotation in degree

Draws the text to the scene

font

Font of the object

font_size

Font size

foreground

Color/Overlay bitmap of the text

getTextElement()[source]

Returns the text element bound to the Text class

getTexture()[source]

Returns the texture of the bound TextElement

getTexture_size()[source]

Returns a texture size tuple

setCentered(value, reinit=True)[source]

value (bool) - New centered value reinit (bool) - Create a new texture

Sets a new value for ‘centered’

setFont(value, reinit=True)[source]

value (bool) - New Font reinit (bool) - Create a new texture

Sets a new font

setFont_size(value, reinit=True)[source]

value (bool) - New font size reinit (bool) - Create a new texture

Sets a new font size

setForeground(value, reinit=True)[source]

value (bool) - New centered value reinit (bool) - Create a new texture

Sets a new value for ‘centered’

setText(value, reinit=True)[source]

value (bool) - New Text reinit (bool) - Create a new texture

Sets a new text

text

Text of the object

text_element

TextElement bound to this class

texture

Texture of bound TextElement

texture_size

Size of the used texture

class gltext.TextElement(text='', font=None, foreground=wx.Colour(), centered=False)[source]

A simple class for using system Fonts to display text in an OpenGL scene

bind()[source]

Increase refcount

centered

Is text centered

createTexture()[source]

Creates a texture from the settings saved in TextElement, to be able to use normal system fonts conviently a wx.MemoryDC is used to draw on a wx.Bitmap. As wxwidgets device contexts don’t support alpha at all it is necessary to apply a little hack to preserve antialiasing without sticking to a fixed background color:

We draw the bmp in b/w mode so we can use its data as a alpha channel for a solid color bitmap which after GL_ALPHA_TEST and GL_BLEND will show a nicely antialiased text on any surface.

To access the raw pixel data the bmp gets converted to a wx.Image. Now we just have to merge our foreground color with the alpha data we just created and push it all into a OpenGL texture and we are DONE inhalesdelpy

DRAWBACK of the whole conversion thing is a really long time for creating the texture. If you see any optimizations that could save time PLEASE CREATE A PATCH!!!

deleteTexture()[source]

Deletes the OpenGL texture object

draw_text(position=wx.Point(0, 0), scale=1.0, rotation=0)[source]

position (wx.Point) - x/y Position to draw in scene scale (float) - Scale rotation (int) - Rotation in degree

Draws the text to the scene

font

Font of the object

foreground

Color of the text

isBound()[source]

Return refcount

owner_cnt

Owner count

release()[source]

Decrease refcount

text

Text of the object

texture

Used texture

texture_size

Size of the used texture

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.

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.

ImageCalibrants: Calibration Standards

GSASII powder calibrants as a dictionary ImageCalibrants.Calibrants with 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))
(The space group may be an empty string)

as an example:

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

or where “Bravais num” and “(a,b,...)” are repeated in the case of mixtures:

'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)),

To expand this list with locally needed additions, do not modify this 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 information in this file.

Note, some useful Bravais numbers are: F-cubic=0, I-cubic=1, P-cubic=2, R3/m (hex)=3, P6=4, P4mmm=6

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, Cromer(1971) Int. Tables Vol. IV 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

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.

defaultIparms: Table of atomic data

Define 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