GithubHelp home page GithubHelp logo

dkriegner / xrayutilities Goto Github PK

View Code? Open in Web Editor NEW
77.0 13.0 28.0 61.25 MB

xrayutilities - a package with useful scripts for X-ray diffraction physicists

Home Page: http://xrayutilities.sourceforge.io

License: GNU General Public License v2.0

Python 88.63% C 11.37%
scientific diffraction diffraction-analysis x-ray-crystallography x-ray-physics

xrayutilities's Introduction

xrayutilities

Build Status

xrayutilities is a collection of scripts used to analyze and simulate x-ray diffraction data. It consists of a Python package and several routines coded in C. For analysis the package is especially useful for the reciprocal space conversion of diffraction data taken with linear and area detectors. For simulations code for X-ray reflectivity, kinematical and dynamical diffraction simulation of crystal truncation rods as well as fundamental parameters powder diffraction is included.

Copyright (C) 2009-2024 Dominik Kriegner [email protected]

Copyright (C) 2009-2013 Eugen Wintersberger [email protected]

Mailing list and issue tracker

To get in touch with us or report an issue please use the mailing list (https://sourceforge.net/p/xrayutilities/mailman/xrayutilities-users/) or the Github issue tracker (https://github.com/dkriegner/xrayutilities/issues). When you want to follow announcements of major changes or new releases its recommended to sign up for the mailing list

Contents

  • examples: directory with example scripts and configurations
  • lib/xrayutilities: directory with the sources for the Python package
  • tests: directory with the unittest scripts
  • setup.py: setuptools install script used for the package installation

Installation (pip)

Using the python package manager pip you can install xrayutilities by executing

pip install xrayutilities

or for a user installation (without admin access) use

pip install --user xrayutilities

Installation (source)

Installing xrayutilities from source is an easy process done by executing

pip install .

in the source folder of xrayutilities on the command line/terminal. Directly calling setup.py by

python setup.py install

or

python setup.py install --prefix=<install_path>

is possible but you have to manually ensure that the dependencies are all installed! The first command installs xrayutilities in the systems default directories, whereas in the second command you can manually specify the installation path.

By default the installation procedure tries to enable OpenMP support (recommended). It is disabled silently if OpenMP is not available. It can also be disabled by using the --without-openmp option for the installation:

python setup.py build_ext --without-openmp install

Requirements

The following requirements are needed for installing and using xrayutilities:

  • Python (>= 3.6)
  • h5py
  • scipy (version >= 0.18.0)
  • numpy (version >= 1.9)
  • lmfit (>= 1.0.1)
  • matplotlib (optional, version >= 3.1.0)
  • mayavi (optional, only used optionally in Crystal.show_unitcell)

When building from source you also might need:

  • C-compiler (preferential with OpenMP support)
  • Python dev headers
  • setuptools
  • pytest (optional - only if you want to run the test environment)
  • sphinx (optional - only when you want to build the documentation)
  • numpydoc (optional - only when you want to build the documentation)
  • rst2pdf (optional - only when you want to build the documentation)
  • sphinx_rtd_theme (optional - only when you want to build the documentation)
  • svglib (optional - only when you want to build the pdf documentation)

refer to your operating system documentation to find out how to install those packages. On Microsoft Windows refer to the Documentation for the easiest way of the installation (Anaconda, Python(x,y), or WinPython).

Python-2.7 and Python-3.X compatibility

The current development is for Python3 (version >=3.6) only. xrayutilities up to version 1.5.x can be used with Python-2.7 as well. Python 3.3 to 3.5 was supported up to 1.6.0.

The Python package configuration

The following steps should only be necessary when using non-default installation locations to ensure the Python module is found by the Python interpreter. In this case the module is installed under /lib[64]/python?.?/site-packages on Unix systems and /Lib/site-packages on Windows systems.

If you have installed the Python package in a directory unknown to your Python distribution, you have to tell Python where to look for the Package. There are several ways how to do this:

  • add the directory where the package is installed to your PYTHONPATH environment variable.

  • add the path to sys.path in the .pythonrc file placed in your home directory

    import sys
    sys.path.append("path to the xrayutilities package")
    
  • simply apply the previous method in every script where you want to use the xrayutilities package before importing the package

    import sys
    sys.path.append("path to the xrayutilities package")
    import xrayutilities
    

Obtaining the source code

The sources are hosted on sourceforge in git repository. Use

git clone https://github.com/dkriegner/xrayutilities.git

to clone the git repository. If you would like to have commit rights contact one of the administrators.

Update

if you already installed xrayutilities you can update it by navigating into its source folder and obtain the new sources by ::

git pull

or download the new tarball from sourceforge (https://sf.net/projects/xrayutilities) if any code changed during the update you need to reinstall the Python package. Thats easiest achieved by

pip install .

In case you are not certain about the installation location it can be determined by

python -c "import xrayutilities as xu; print xu.__file__"
  /usr/local/lib64/python3.6/site-packages/xrayutilities/__init__.pyc

if the output is e.g.: /usr/local/lib64/python3.6/site-packages/xrayutilities/init.py you previously installed xrayutilities in /usr/local, which should be used again as install path. Use ::

pip install --prefix=<path to install directory> .

to install the updated package.

Documentation

Documentation for xrayutilities is found on the webpage https://xrayutilities.sourceforge.io

The API-documentation can also be browsed by

pydoc -p PORT

in any web-browser, after the installation is finished.

xrayutilities's People

Contributors

andrews-tuwien avatar dkriegner avatar dschick avatar eugenwintersberger avatar f-iniv avatar hugovk avatar prjemian avatar trdd avatar verybitter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xrayutilities's Issues

PowderModel misses some important fit parameters

So far several important fitting parameters are missing and can not be optimized by the least squares fitting procedure.

A maybe incomplete list of missing parameters:

  • lattice parameters/unit cell angles and other parameters of the Crystals (like atomic positions or Debye-Waller factors)
  • The x-ray wavelength or some of its components in the emission spectrum
  • Relative intensities of the lines in the emission spectrum

Import crystal structure from CIF file

Hi,

I try to import a crystal structure in cubic from a CIF file.

import xrayutilities.materials.cif as cif
crystal = cif.CIFFile("./Si.cif")
calcite = crystal.SGLattice()
print(Is)

The code above gives the following output.

1 triclinic P1: a = 5.4309, b = 5.4309 c= 5.4309
alpha = 90.000, beta = 90.000, gamma = 90.000
Lattice base:
.....

Obviously, Si is not triclinic P1. I import the same CIF file from other programs and the CIF file does not have any issues.

I wonder if I miss anything here. Thanks in advance.

Dan Shim

Si.cif.zip

P08 data parser

A new file reader for the new (easy) ascii-files created at beamline P08 at DESY should be included. In addition to standard data parsing and name based access also the header needs to be parsed correctly.

Multiple scans should be parsed together. support for linear detector data should be included.

Reported by: dkriegner

change line scan extraction functions

functions to obtain a line scan from a reciprocal space map measurement should operate on the raw data instead of the gridded reciprocal space map (at least for 2D measurements).

the 1D gridder should be used extensively to provide this functionality

Reported by: dkriegner

lam2en function can be misleading

currently there is only one function for energy to wavelength and wavelength to energy conversion. since the introduction of names for energy and wavelength this is however misleading

e.g. what means
xu.utilities.lam2en('CuKa1')

the name suggests it returns an energy, however, it is often used different and will return actually the wavelength. there should be two functions lam2en and en2lam to distinguish such cases!

Reported by: dkriegner

use sphinx_build target

setuptools offers a sphinx_build target which we currently ignore but should use and abandon our custom changes in setup.py

Reported by: dkriegner

PowderDiffraction works only for isotropic convolvers

If a powder profile depends on the Miller indices HKL the powder diffraction class needs to treat all contributions to a powder line independently. This is not done by default since it would significantly slow down the calculation but should optionally be possible to allow for such anisotropic convolvers (e.g. anisotropic size of crystallites)

PowderDiffraction instance might misbehave when the number of distinct peaks changes

When upon a structural change of the material the number of distinct peaks is changing the PowderDiffraction instance fails to detect this and will not work correctly in some cases. (specifically when not enough convolvers were predefined upon class creation.

Such cases should be detected and necessary convolvers should be created as needed.

Q2AngFit fails despite narrow bounds & error code 0?

Hi,
I'm trying to verify my geometry settings and set things up to use the angles from our instrument.
I have a problem when converting from angles back to HKL: Even when I start very close with strict bounds, the fit goes for the limits of the range. Any idea why this is happening? I tried the built-in crystal structure as well as the triclinic one which comes from a SPEC refinement and should work quite well.

import xrayutilities as xu
import matplotlib.pyplot as plt
import numpy as np

# Energy 9keV
en = 9000

# Our sample angles:
# alpha = AOI
# chi (fixed at -90deg, meaning vertical sample)
# omegaV = sample rotation about its normal (leaving L unchanged in a c-cut sample
#
# Detector angles:
# gamma = azimuth (theta-2theta means gamma=2alpha coordinated scan)
# delta = elevation
# direct beam position at gamma, delta = 0
qconv = xu.QConversion(('z+','x+','z-'),('z+','y-'),(1,0,0))

# This matches our setting in SPEC during the last beamtime:
# c-cut sample with omegaV zeroed to the SPEC value
omegavOffset = -44.6
ovx = np.sin(np.deg2rad(omegavOffset))
ovy = np.cos(np.deg2rad(omegavOffset))
hxrd = xu.HXRD(np.array([ovx,ovy,0]),np.array([0,0,1]),en=en,qconv=qconv)

# Built-in data for bcc-Fe
Fe = xu.materials.Fe

# Triclinic cell from the SPEC refinement of our peaks
# (almost cubic of course)
FeTriclinic = xu.materials.Crystal("Fe",\
 xu.materials.SGLattice(2, 2.9038,2.8939,2.8823,89.8225,90.0546,90.3348,\
 atoms=[xu.materials.e.Fe,xu.materials.e.Fe],pos=['1a','1h']))

# Tetragonal cell for later epitaxy calculations (non-primitive, doubled)
FeTetragonal = xu.materials.Crystal("Fe",\
 xu.materials.SGLattice(123,np.sqrt(2)*2.8665,2.8665,\
 atoms=[xu.materials.e.Fe,xu.materials.e.Fe,xu.materials.e.Fe],pos=['1a','1c','2e']))

# Primitive bcc unit cell
FeBcc  = xu.materials.Crystal("Fe",\
 xu.materials.SGLattice(229, 2.8665, atoms=[xu.materials.e.Fe, ], pos=['2a', ]))

# Experimental goniometer angles for (2 0 2)
# The next indexed peak at -90deg sample rotation from there was (0 -2 2)
alp,chi,ov = (4,-90,18.37)
gam,delta = (84.6,25)

# To not print too many digits
def npp( x ):
   "print stuff as numpy arrays"
   np.set_printoptions(precision=3)
   print(np.asarray(x))
   np.set_printoptions(precision=8) #reset default
   return 0

print('Built-in BCC Fe:')
print('This should be ~ (2  0 2)')
npp(hxrd.Ang2HKL(alp,chi,ov,gam,delta,mat=Fe))
print('This should be ~ (0 -2 2)')
npp(hxrd.Ang2HKL(alp,chi,ov-90,gam,delta,mat=Fe))

print('\nOwn BCC Fe:')
print('This should be ~ (2  0 2)')
npp(hxrd.Ang2HKL(alp,chi,ov,gam,delta,mat=FeBcc))
print('This should be ~ (0 -2 2)')
npp(hxrd.Ang2HKL(alp,chi,ov-90,gam,delta,mat=FeBcc))

print('\nOwn Triclinic Fe:')
print('This should be ~ (2  0 2)')
npp(hxrd.Ang2HKL(alp,chi,ov,gam,delta,mat=FeTriclinic))
print('This should be ~ (0 -2 2)')
npp(hxrd.Ang2HKL(alp,chi,ov-90,gam,delta,mat=FeTriclinic))

print('\nOwn Tetragonal Fe:')
print('This should be ~ (2sqrt2  0 2)')
npp(hxrd.Ang2HKL(alp,chi,ov,gam,delta,mat=FeTetragonal))
print('This should be ~ (0 -2sqrt2 2)')
npp(hxrd.Ang2HKL(alp,chi,ov-90,gam,delta,mat=FeTetragonal))

# Experimental angles at (2 1 1)
alp211 = 5
ov211 = 19.35
gam211 = 53.1
delta211 = 57.8

print('\nExpvalues were:')
npp((alp211, chi, ov211, gam211, delta211))
print('\nThis should be ~ (2 1 1)')
npp(hxrd.Ang2HKL(alp211,chi,ov211,gam211,delta211,mat=Fe))

print('\nBackwards calculation for 5deg AOI, (2 1 1) peak:')
fittedangles, qerror, errcode = xu.q2ang_fit.Q2AngFit(Fe.Q(2,1,1),\
 hxrd, bounds = (5, -90, (15, 25), (50,60), (50,60)),\
 startvalues = (alp211, chi, ov211, gam211, delta211))
npp(fittedangles)
print('\nCalculating forwards again:')
npp(hxrd.Ang2HKL(*fittedangles,mat=FeTriclinic))

The first tests check out but the results of the last bit are:

Expvalues were:
[  5.   -90.    19.35  53.1   57.8 ]

This should be ~ (2 1 1)
[ 1.97   0.997  1.007]

Backwards calculation for 5deg AOI, (2 1 1) peak:
XU.Q2AngFit: q-error=8.219 with error-code 0 (Optimization terminated successfully.)
[  5. -90.  25.  50.  50.]

Calculating forwards again:
[ 1.633  1.102  1.135]

make installation more easy by fully using distutils

at the moment we use scons for installation of the c-library, scons is calling distutils for the installtion of the python package. it would be more convenient for users to avoid the usage of scons and use distutils for the full installation

this requires moving the c-code to a c-extension
scons should not be required anymore for users. we should keep it for building the documentation, webpage and so on.

we could ship prebuilt packages for windows once this is done!

Reported by: dkriegner

fix pdf documentation

currently including svg images is not working in rst2pdf. rst2pdf-0.93 (last release) also does not support python3 and sphinx >=1.3

Reported by: dkriegner

Fitting XRD data for thin films and superlattices

It would be helpful if the kinematical diffraction model could be used to do a rough fit of formatted XRD data for thin films and superlattices in the same way that data for X-ray reflection can be fit. Being able to choose which factors are varied would be helpful as well.

parsing of chemical formulas for material definition

Parsing of chemical formulas would make the definition of Amorphous materials much easier.
e.g.

cofe = xu.materials.Amorphous('CoFe', rho_cofe, [('Co', 0.5), ('Fe', 0.5)])

should be simplified to

cofe = xu.materials.Amorphous('CoFe', rho_cofe)

Reported by: dkriegner

fix internal links in documentation

cross references in documentation do currently not work. it needs to be investigated what it needs for them to be present. I realized that depending on the sphinx version there are cases where the links are present.

Reported by: dkriegner

Error using xu.io.EDFFile

The mentioned routine gives back an error while it seems to work for other people. I am able to open my .edf images via fabIO however.

I am attaching a .zip with the code and an example image. The error I get is as follows
xu.io.EDFFile_Error.zip
:

Traceback (most recent call last):
File "XRD_evaluation_ID9_DK.py", line 80, in
qx, qy, qz, gint, gridder = gridmap(imagenr=1, pathname="./Scan_S6_C3/S6_3K_C3_%04d.edf", stepsize=0.5, start_angle=-10., nx=nx, ny=ny, nz=nz)
File "XRD_evaluation_ID9_DK.py", line 71, in gridmap
qx, qy, qz, intensity = rawmap(imagenr, pathname, stepsize, start_angle)
File "XRD_evaluation_ID9_DK.py", line 52, in rawmap
a = e.data
File "/usr/local/lib/python2.7/dist-packages/xrayutilities/io/edf.py", line 323, in data
self._data[i] = self.ReadData(i)
File "/usr/local/lib/python2.7/dist-packages/xrayutilities/io/edf.py", line 285, in ReadData
% (fmt_str, len(bindata) / tot_nofp))
IOError: XU.io.EDFFile: data format (H) has different byte-length, from amount of data one expects 1 bytes per entry

Updating wavelength in PowderDiffraction

I'm trying to calculate a powder diffraction pattern, but am unable to update the wavelength in the global dictionary. I am able to update other keys, and add a wavelength key and pass it to fpsettings, but this has no effect on the output pattern. This script is based off the xrayutilities_experiment_Powder_example_Iron example and I'm currently running it inside a jupyter notebook. I tried some alternatives: running this as an executable in a directory alongside a xrayutilities.conf file, and also passing a wl=#.## argument directly to PowderDiffraction() but am not having any luck. Any advice?

%matplotlib inline

import matplotlib.pyplot as plt
import numpy as np
import xrayutilities as xu
from xrayutilities.materials.cif import CIFFile
from xrayutilities.materials.material import Crystal

ni_cif = CIFFile('./stru/Ni.cif')
ni_crystal = Crystal(name="Ni", lat=ni_cif.SGLattice())

#X-ray wavelength is 0.1866 Angstroms
settings = {'global': {'wavelength': 0.1866e-10,
                      'dominant_wavelength': 0.1866e-10,
                      'diffractometer_radius': 0.010101}}

ni_powder = xu.simpack.Powder(ni_crystal, 1)
pd = xu.simpack.PowderDiffraction(ni_powder, fpsettings=settings)

tt = np.arange(1, 200, 0.01)
inte = pd.Calculate(tt)

print(pd)

fig, ax1 = plt.subplots(1, 1, figsize=(8,8))

ax1.plot(tt, inte)
ax1.set_xlim(0,200)

Here is a partial output of the printed settings dictionary:

Settings: {'absorption': {'absorption_coefficient': 100000.0}, 
'global': {'wavelength': 1.866e-11, 
'dominant_wavelength': 1.5405929759615019e-10,
'equatorial_divergence_deg': 0.5,
'diffractometer_radius': 0.010101}}

simpack: ignore variation of structure factor

for better comparison of dynamic and kinematic diffraction models it would be nice to enable the possibility to switch of the use of F(Q) and use only F(hkl)

Reported by: dkriegner

Convolutions for powder diffraction

I have just recently discovered xrayutilities, and find it an exceedingly nice package for many purposes.

I do extensive powder diffraction work, and would like to integrate some extra features which would be broadly useful to the powder community. I have developed a pure-python code which implements the Fundamental Parameters Approach to compute peak shapes directly from basic machine and sample parameters. The paper on it is at: Journal of Research of NIST, and the code is provided as ancillary material, accessible at FPA Python Code. I think it would take very little effort for someone to wrap this code so that it fits in under the Powder experiment class as an alternative to the Gaussian convolver. This code includes essentially all currently documented aberrations to the peak shape from instrument geometry, crystal microstructure, and sample properties such as absorption. It is also extensible via simple plugins to handle extra aberrations.

I don't know what the development schedule for new bits of xrayutilities is. I probably do not have time to fully implement the needed wrapper for this, but would be glad to assist with the process.

fix futurewarning during unittests

...python2.7/site-packages/xrayutilities/materials/atom.py:66: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if en == "config":
.../python2.7/site-packages/xrayutilities/materials/atom.py:73: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
  if en == "config":

when en is an array of intensities then the current way of comparing 'en' to have the value 'config' is not correct anymore (change in numpy) and should be replaced by:

if isinstance(en, str) and en == 'config':
    pass

Reported by: dkriegner

'en' keyword not functioning in xu.simpack.PowderModel class

While trying to change the energy of x-rays for simulating xrd data, I noticed that the pattern wouldn't change by setting the en=(energy, eV) keyword when PowderModel is instantiated.

e.g., looking at the tutorial example
(https://xrayutilities.sourceforge.io/simulations.html#powder-diffraction-simulations)

pm = xu.simpack.PowderModel(Fe_powder, Co_powder, I0=100, en=10000)
The addition of the 'en' keyword does not affect the output. After the above line of code, I checked the energy of the PowderDiffraction class that was created:
in: pm.pdiff[0].energy out: 8047.8230999999987

After some digging, I noticed I could override this and set the energy manually by:
pm.pdiff[0].energy=10000

However it seemed to me that this keyword should have worked. I can see that the keyword get's passed down in the source code, but for whatever reason the PowderDiffraction class that comes out still has the Cu Kalpha1 energy.

I made a jupyter notebook showing the bug based on the example from the tutorial. I couldn't attach it here as a .ipynb so I changed the extension to txt. I've also attached a PDF of the notebook.
XrayUtilities_BugDemonstration.pdf
XrayUtilities_BugDemonstration.txt

optimize structure factor and chi calculation

structure factor and chi calculation still has a lot of overhead since the atomic scattering factor database function are called for every atom in the unit cell and do not consider that most atoms appear multiple times!
this should be reorganized to work more efficient!

Reported by: dkriegner

Powder Models Improvement

Hi,

I am a physicist working since a while with x-rays but only recently on powders.

First of all, thanks for the very nice package and in particular the relatively new powders models. With some colleagues we have used TOPAS so far but we are eager to switch to something open, easily installable, etc.

In this sense the current interface is nice but could probably be improved a bit:

  1. is there any way not to use some 'convolver' ? For example in our experiment (at a synchrotron) we did not use any Soller slits, how can I bypass it ? I could not find a way in the documentation. Looking at the code it seems that this option is not actually implemented. In general a better documentation or more complete example would be very nice to have.

  2. It would be nice to add some commonly used 'corrections' like the footprint correction

I am willing to help in any way that makes sense including proposing code changes, comparing the numerical results with calculations done by TOPAS or improving documentations and examples.

Thanks again,
marco

qconversion.c needs major cleanup

For performance reasons there are many variants of the ang2q_conversion for point, linear, and area detectors. the respective different functions for point, linear, and area detector however share the same interface to the python code and the variable checking/conversion code should therefore be moved to a common wrapper function!

This should make the code more readable and managable in future!

Reported by: dkriegner

the Gridder class should be an abstract class

The Gridder class serves as abstraction of all the derived classes Gridder1D, Gridder2D, ...

The class itself however should not be usable since its methods rely on properties which are defined only in the derived classes.

@eugenwintersberger what is the best/pythonic way to solve this?

I see two options:

  1. using the abc module or
  2. defining dummy variable in Gridder to make it run-able, but still its useless....

option 2 seems easy, but does not look like the best solution...

check if unexpected keyword arguments are given

in most functions which accept **kwargs a check should be added to raise an error in case an unexpected keyword argument is given. users might in this way easier find an error in their scripts.

Reported by: dkriegner

BUG in spec.py for whitespaces in motornames

BUG in getspecscan and geth5scan in io/spec.py for spec motornames with whitespaces:

1036 - h5scan.attrs["INIT_MOPO_%s" % motname]
1036 + h5scan.attrs["INIT_MOPO_%s" % makeNaturalName(motname)]

1112 - sscan.init_motor_pos["INIT_MOPO_%s" % motname])
1112 + sscan.init_motor_pos["INIT_MOPO_%s" % makeNaturalName(motname)])

Reported by: dschick

Tetragonal systems have the wrong angle gamma

I was trying to use a tetragonal system of space group 123 (a=b =/= c, alpha = beta = gamma = 90deg).

In spacegrouplattice.py, the tetragonal systems have a value of 120deg for gamma (probably copy&paste from hexagonal/trigonal), so I just changed it there.

Example code showing a primitive unit cell for iron and a doubled one (to get epitaxy on MgO working...):

import xrayutilities as xu
import numpy as np

FeTetr = xu.materials.Crystal("Fe", xu.materials.SGLattice(123,np.sqrt(2)*2.8665,2.8665,
                                                       atoms=[xu.materials.e.Al,xu.materials.e.Bi,xu.materials.e.Ca],
                                                             pos=['1a','1c','2e']))

print('Tetragonal:')   
for at, pos, occ, b in FeTetr.lattice.base():
    print(at,pos,occ,b)

FeBcc  = xu.materials.Crystal("Fe", xu.materials.SGLattice(229, 2.8665, atoms=[xu.materials.e.Fe, ], pos=['2a', ]))

print('\nBcc:')
for at, pos, occ, b in FeBcc.lattice.base():
    print(at,pos,occ,b)
    
FeTetr.environment((0,0,0))
FeBcc.environment((0,0,0))

With 120deg, the environment are not the same, even though they should be. With 90deg, they are the same, only the multiplicities split and there are tiny numerical differences.

advertise mailinglist

The visibility of the mailing list should be increased. It should be mentioned in the readme and documentation as primary contact in case of problems with installation and use!

geth5_scan: return motors as recarray

[om, tt], MAP = xu.io.geth5_scan(h5file, 36, 'omega', 'gamma')

this method returns the motor positions in a list, whereas the counter values from the SPEC file are returned as a numpy array which can be indexed by the counter name: MAP['counterName']

is it possible to return the motor positions also as a numpy array, ie. a recarray which can be indexed by the motorname?

Reported by: dschick

add screenshots to SF page

now that we can produce some nice simulations and fit XRR data we should have some screenshots showing this

Reported by: dkriegner

xrayutilities error on reading COD database cif

I am trying to simulate the powder x-ray pattern from a COD cif.

My python code is grab from internet:

#from pymatgen import Lattice, Structure
import numpy
import xrayutilities as xru
#from xrayutilities.materials.cif import CIFFile
from xrayutilities.materials import CIFFile
from xrayutilities.materials.material import Crystal
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
import matplotlib

matplotlib.rcParams.update({'font.size': 18})
fig_size = [15, 12]
plt.rcParams["figure.figsize"] = fig_size

xu_cif = CIFFile("bifeo3.cif")

xu_crystal = Crystal(name="BiFeO3", lat=xu_cif.SGLattice())

two_theta = numpy.arange(0, 80, 0.01)
powder = xru.simpack.smaterials.Powder(xu_crystal, 1)
pm = xru.simpack.PowderModel(powder, I0=100)
intensities = pm.simulate(two_theta)
plt.plot(two_theta,intensities)
plt.xlim(0,80)
ax = plt.axes()
ax.xaxis.set_major_locator(ticker.MultipleLocator(5))
ax.yaxis.set_major_formatter(ticker.FormatStrFormatter('%.4f'))
plt.title("XRD Pattern for " + xu_crystal.name)
plt.xlabel("2 theta (degrees)")
plt.ylabel("Intensity")
plt.show()

My cif test if from COD database:

#------------------------------------------------------------------------------
#$Date: 2016-02-18 17:37:37 +0200 (Thu, 18 Feb 2016) $
#$Revision: 176729 $
#$URL: svn://www.crystallography.net/cod/cif/1/00/10/1001090.cif $
#------------------------------------------------------------------------------
#
# This file is available in the Crystallography Open Database (COD),
# http://www.crystallography.net/
#
# All data on this site have been placed in the public domain by the
# contributors.
#
data_1001090
loop_
_publ_author_name
'Moreau, J M'
'Michel, C'
'Gerson, R'
'James, W J'
_publ_section_title
;
Ferroelectric Bi Fe O~3~ X-Ray and neutron diffraction study
;
_journal_coden_ASTM              JPCSAW
_journal_name_full               'Journal of Physics and Chemistry of Solids'
_journal_page_first              1315
_journal_page_last               1320
_journal_paper_doi               10.1016/S0022-3697(71)80189-0
_journal_volume                  32
_journal_year                    1971
_chemical_formula_structural     'Bi Fe O3'
_chemical_formula_sum            'Bi Fe O3'
_chemical_name_systematic        'Bismuth iron(III) oxide'
_space_group_IT_number           161
_symmetry_cell_setting           trigonal
_symmetry_space_group_name_Hall  'R 3 -2"c'
_symmetry_space_group_name_H-M   'R 3 c :H'
_cell_angle_alpha                90
_cell_angle_beta                 90
_cell_angle_gamma                120
_cell_formula_units_Z            6
_cell_length_a                   5.5876(3)
_cell_length_b                   5.5876(3)
_cell_length_c                   13.867(1)
_cell_volume                     374.9
_refine_ls_R_factor_all          0.09
_cod_original_sg_symbol_H-M      'R 3 c H'
_cod_database_code               1001090
loop_
_symmetry_equiv_pos_as_xyz
x,y,z
-y,x-y,z
y-x,-x,z
-y,-x,1/2+z
x,x-y,1/2+z
y-x,y,1/2+z
1/3+x,2/3+y,2/3+z
2/3+x,1/3+y,1/3+z
1/3-y,2/3+x-y,2/3+z
2/3-y,1/3+x-y,1/3+z
1/3-x+y,2/3-x,2/3+z
2/3-x+y,1/3-x,1/3+z
1/3-y,2/3-x,1/6+z
2/3-y,1/3-x,5/6+z
1/3+x,2/3+x-y,1/6+z
2/3+x,1/3+x-y,5/6+z
1/3-x+y,2/3+y,1/6+z
2/3-x+y,1/3+y,5/6+z
loop_
_atom_site_label
_atom_site_type_symbol
_atom_site_symmetry_multiplicity
_atom_site_Wyckoff_symbol
_atom_site_fract_x
_atom_site_fract_y
_atom_site_fract_z
_atom_site_occupancy
_atom_site_attached_hydrogens
_atom_site_calc_flag
Bi1 Bi3+ 6 a 0. 0. 0. 1. 0 d
Fe1 Fe3+ 6 a 0. 0. 0.2212(15) 1. 0 d
O1 O2- 18 b 0.443(2) 0.012(4) 0.9543(20) 1. 0 d
loop_
_atom_type_symbol
_atom_type_oxidation_number
Bi3+ 3.000
Fe3+ 3.000
O2- -2.000

This gives an Output error:

Traceback (most recent call last):
  File "main.py", line 15, in <module>
    xu_cif = CIFFile("bifeo3.cif")
  File "lib/python3.6/site-packages/xrayutilities/materials/cif.py", line 180, in __init__
    self.SymStruct()
  File "lib/python3.6/site-packages/xrayutilities/materials/cif.py", line 378, in SymStruct
    element = getattr(elements, el)
AttributeError: module 'xrayutilities.materials.elements' has no attribute 'Bi+'

When I remove the + sign of the chage in the cif, the library works.

Please, guide me to solve this issue.
Congratulation for the work and thanks for the attention.

parsing cif files without generators

Parsing of cif files without included generators should also work and produce a complete Crystal instance including the correct atomic positions

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.