At present this module defines one dict, ramachandranDist, which contains arrays for All and specific amino acids
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.
Return the configuration file value for key or a default value if not present
Parameters: |
|
---|---|
Returns: | the value found or the default. |
Return the maximum version number seen in SetVersionNumber()
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. |
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.
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) |
Get the revision log information for a specific version of the
Parameters: |
|
---|---|
Returns: | a dictionary with keys (one hopes) ‘author’, ‘date’, ‘msg’, and ‘revision’ |
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: |
|
---|---|
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) |
This performs an update of the files in a local directory from a server.
Parameters: |
|
---|
Module to provide logging services, e.g. track and replay “actions” such as menu item, tree item, button press, value change and so on.
Lookup table for button objects
Contains a list of logged actions; first item is ignored
Called when a menu item is used to log the action as well as call the routine “bind”ed to that menu item
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
Contains values that are needed in the module for past actions & object location
Lookup table for Menu buttons
object that tracks when a menu command is executed
execute one or more commands when the replay button is pressed
Creates a table of menu items and their pseudo-bindings
Object to track when tabs are pressed in the DataFrame window
Object to track when tree items are pressed in the main window
object that tracks changes to a variable
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.
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.
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.
Set to True to enable use of command logging
Set to True to enable debug for logging
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 |
compute Compton scattering factor
Parameters: |
|
---|---|
Returns: | compton scattering factor |
Compute real & imaginary resonant X-ray scattering factors
Parameters: |
|
---|---|
Returns: | C: (f’,f”,mu): real, imaginary parts of resonant scattering & atomic absorption coeff. |
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 |
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 |
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 |
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:
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:
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:
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\)
Fill real & reciprocal metric tensor (G) from A.
Parameters: |
|
---|---|
Returns: | reciprocal (G) & real (g) metric tensors (list of two numpy 3x3 arrays) |
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 |
Compute reciprocal unit cell constants from A returns tuple with a*,b*,c*,alpha*, beta*, gamma* (degrees)
Compute unit cell absorption
Parameters: |
|
---|---|
Returns: | mu-total/Volume |
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)
calculate cos of angle between U & V in generalized coordinates defined by metric tensor G
Parameters: |
|
---|---|
Returns: | cos(phi) |
calculate sin & cos of angle between U & V in generalized coordinates defined by metric tensor G
Parameters: |
|
---|---|
Returns: | cos(phi) & sin(phi) |
convert d-spacing to powder pattern position (2-theta or TOF, musec)
Generate the positionally unique powder diffraction reflections
Parameters: |
|
---|---|
Returns: | HKL unique d list of [h,k,l,d,-1] sorted with largest d first |
Generate the crystallographically unique powder diffraction reflections for a lattice and Bravais type
Parameters: |
|
---|---|
Returns: | HKL = list of [h,k,l,d] sorted with largest d first and is unique part of reciprocal space ignoring anomalous dispersion |
Determine the Bravais lattice number, as used in GenHBravais
Parameters: |
|
---|---|
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) |
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] |
Computes orthogonalization matrix from reciprocal metric tensor G
Returns: | tuple of two 3x3 numpy arrays (A,B)
|
---|
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) |
convert powder pattern position (2-theta or TOF, musec) to d-spacing ignores secondary effects (e.g. difB in TOF)
Compute sample orientation angles vs laboratory coord. system
Parameters: |
|
---|---|
Returns: | psi,gam: Sample odf angles dPSdA,dGMdA: Angle zero derivatives |
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 |
Convert Uij to beta-ij tensors – stub for eventual completion
Parameters: |
|
---|---|
Returns: | beta-ij - numpy array [beta-ij] |
Fill vector [U11,U22,U33,U12,U13,U23] from Uij NB: there is a non numpy version in GSASIIspc: Uij2U
Compute the square of the reciprocal lattice volume (1/V**2) from A’
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 |
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 |
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) |
Calculate critical values for probability ellipsoids from probability
Compute lattice metric tensor from unit cell constants
Parameters: | cell – tuple with a,b,c,alpha, beta, gamma (degrees) |
---|---|
Returns: | 3x3 numpy array |
convert d-spacing to powder pattern position (2-theta or TOF, musec)
Parameters: | invcell – [a*,b*,c*,alpha*, beta*, gamma*] (degrees) |
---|---|
Returns: | reciprocal (G) & real (g) metric tensors (list of two 3x3 arrays) |
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
Prepare rotation matrix for angle in degrees about axis(=0,1,2)
Parameters: |
|
---|---|
Returns: | rotation matrix - 3x3 numpy array |
Prepare rotation matrix for angle in degrees about axis(=0,1,2) with scaling for OpenGL
Parameters: |
|
---|---|
Returns: | rotation matrix - 4x4 numpy array (last row/column for openGL scaling) |
Convert time in sec to H:M:S string
Parameters: | sec – time in seconds |
---|---|
Returns: | H:M:S string (to nearest 100th second) |
Defines a list of self-tests
Space group interpretation routines. Note that space group information is stored in a Space Group (SGData) object.
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
|
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!
Generates the equivalent positions for a specified coordinate and space group
Parameters: |
|
---|---|
Returns: | [[XYZEquiv],Idup,[UijEquiv]]
|
Uses old GSAS Fortran routine genhkl.for
Parameters: |
|
---|---|
Returns: | iabsnt,mulp,Uniq,phi
|
returns Uij terms, multipliers, GUI flags & Uiso2Uij multipliers
From lattice type (‘P’,A’, etc.) returns ‘;’ delimited cell centering vectors
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 |
this is to convert isotropic mustrain to generalized Shkls
Parameters: |
|
---|---|
Returns: | XYZ: array of opposite positions; always contains XYZ |
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” |
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 |
Print the output of SpcGroup in a nicely formatted way.
Parameters: | SGSymbol – space group symbol (string) with spaces between axial fields |
---|---|
Returns: | nothing |
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:
|
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
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’
Generates the number of equivalent positions and a site symmetry code for a specified coordinate and space group
Parameters: |
|
---|---|
Returns: | a two element tuple:
|
Defines a list of self-tests
Routines that render text on OpenGL without use of GLUT.
Code written by Christian Brugger & Stefan Hacker and distributed under GNU General Public License.
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
Display the text centered
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 of the object
Font size
Color/Overlay bitmap of the text
value (bool) - New centered value reinit (bool) - Create a new texture
Sets a new value for ‘centered’
value (bool) - New Font reinit (bool) - Create a new texture
Sets a new font
value (bool) - New font size reinit (bool) - Create a new texture
Sets a new font size
value (bool) - New centered value reinit (bool) - Create a new texture
Sets a new value for ‘centered’
value (bool) - New Text reinit (bool) - Create a new texture
Sets a new text
Text of the object
TextElement bound to this class
Texture of bound TextElement
Size of the used texture
A simple class for using system Fonts to display text in an OpenGL scene
Is text centered
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!!!
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 of the object
Color of the text
Owner count
Text of the object
Used texture
Size of the used texture
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.
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.
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
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.
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