Codebase list xrayutilities / upstream/1.7.1+git20210715.1.9ac4344
Import upstream version 1.7.1+git20210715.1.9ac4344 Debian Janitor 2 years ago
123 changed file(s) with 373 addition(s) and 261 deletion(s). Raw diff Collapse all Expand all
0 * update copyright notices from git commit history
1 * fix code error found by linting (flake8)
2 * CIF atom type normalization of oxidation state (issue #122)
3 * improve documentation of PowerModel multiprocessing code (issue #121)
4 * fix numpy-1.20 deprecation warnings
5 * bugfix in kinematical diffraction model.
6 * add visualization of individual layer densities (issue #107)
7 * new coplanar_alphaf helper function
8
09 v1.7.1, 2021-01-02
110
211 * harmonize dependency versions between README and setup.py
1111 =============
1212
1313
14 [![Build Status](https://dev.azure.com/dominikkriegner/xrayutilities/_apis/build/status/dkriegner.xrayutilities?repoName=dkriegner%2Fxrayutilities&branchName=master)](https://dev.azure.com/dominikkriegner/xrayutilities/_build/latest?definitionId=1&repoName=dkriegner%2Fxrayutilities&branchName=master)
14 [![Build Status](https://dev.azure.com/dominikkriegner/xrayutilities/_apis/build/status/dkriegner.xrayutilities?repoName=dkriegner%2Fxrayutilities&branchName=main)](https://dev.azure.com/dominikkriegner/xrayutilities/_build/)
1515
1616 xrayutilities is a collection of scripts used to analyze and simulate x-ray
1717 diffraction data. It consists of a Python package and several routines coded
215215 Classifier: License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
216216 Requires-Python: ~=3.6
217217 Description-Content-Type: text/markdown
218 Provides-Extra: fit
218219 Provides-Extra: plot
219 Provides-Extra: fit
11 =============
22
33
4 [![Build Status](https://dev.azure.com/dominikkriegner/xrayutilities/_apis/build/status/dkriegner.xrayutilities?repoName=dkriegner%2Fxrayutilities&branchName=master)](https://dev.azure.com/dominikkriegner/xrayutilities/_build/latest?definitionId=1&repoName=dkriegner%2Fxrayutilities&branchName=master)
4 [![Build Status](https://dev.azure.com/dominikkriegner/xrayutilities/_apis/build/status/dkriegner.xrayutilities?repoName=dkriegner%2Fxrayutilities&branchName=main)](https://dev.azure.com/dominikkriegner/xrayutilities/_build/)
55
66 xrayutilities is a collection of scripts used to analyze and simulate x-ray
77 diffraction data. It consists of a Python package and several routines coded
371371 for i in range(len(lines)):
372372 lines[i] = re.sub(r'^\s*Note:', r'.. note::', lines[i])
373373
374
374375 def skip(app, what, name, obj, would_skip, options):
375376 """always document __init__ and __call__ functions"""
376377 if name in ["__init__", "__call__"]:
377378 return False
378379 return would_skip
379380
381
380382 def setup(app):
381383 app.connect('autodoc-process-docstring', process_docstring)
382384 app.connect("autodoc-skip-member", skip)
55 Examples
66 ========
77
8 In the following a few code-snippets are shown which should help you getting started with *xrayutilities*. Not all of the codes shown in the following will be run-able as stand-alone script. For fully running scripts look in the `examples <https://github.com/dkriegner/xrayutilities/tree/master/examples>`_ or in the `download <https://sourceforge.net/projects/xrayutilities>`_.
8 In the following a few code-snippets are shown which should help you getting started with *xrayutilities*. Not all of the codes shown in the following will be run-able as stand-alone script. For fully running scripts look in the `examples <https://github.com/dkriegner/xrayutilities/tree/main/examples>`_ or in the `download <https://sourceforge.net/projects/xrayutilities>`_.
99
1010
1111 Reading data from data files
9595 e.Save2HDF5(h5file, group="/frelon_%04d" % i)
9696
9797 .. seealso::
98 the fully working example provided in the `examples <https://github.com/dkriegner/xrayutilities/tree/master/examples>`_ directory perfectly suited for reading data from beamline ID01
98 the fully working example provided in the `examples <https://github.com/dkriegner/xrayutilities/tree/main/examples>`_ directory perfectly suited for reading data from beamline ID01
9999
100100 Reading XRDML files
101101 ^^^^^^^^^^^^^^^^^^^
115115
116116
117117 .. seealso::
118 the fully working example provided in the `examples <https://github.com/dkriegner/xrayutilities/tree/master/examples>`_ directory
118 the fully working example provided in the `examples <https://github.com/dkriegner/xrayutilities/tree/main/examples>`_ directory
119119
120120 Other formats
121121 ^^^^^^^^^^^^^
130130 * support is also provided for reading of ``cif`` files from structure
131131 databases to extract unit cell parameters as well es read data from those files (pdCIF, ESG files)
132132
133 See the `examples <https://github.com/dkriegner/xrayutilities/tree/master/examples>`_ directory for more information and working example scripts.
133 See the `examples <https://github.com/dkriegner/xrayutilities/tree/main/examples>`_ directory for more information and working example scripts.
134134
135135 Angle calculation using :class:`~xrayutilities.experiment.Experiment` and :mod:`~xrayutilities.materials` classes
136136 -----------------------------------------------------------------------------------------------------------------
55 Simulation examples
66 ===================
77
8 In the following a few code-snippets are shown which should help you getting started with reflectivity and diffraction simulations using *xrayutilities*. All simulations in *xrayutilities* are for layers systems and currently there are no plans to extend this to other geometries. Note that not all of the codes shown in the following will be run-able as stand-alone scripts. For fully running scripts look in the `examples <https://github.com/dkriegner/xrayutilities/tree/master/examples>`_ directory in the `download <https://sourceforge.net/projects/xrayutilities>`_.
8 In the following a few code-snippets are shown which should help you getting started with reflectivity and diffraction simulations using *xrayutilities*. All simulations in *xrayutilities* are for layers systems and currently there are no plans to extend this to other geometries. Note that not all of the codes shown in the following will be run-able as stand-alone scripts. For fully running scripts look in the `examples <https://github.com/dkriegner/xrayutilities/tree/main/examples>`_ directory in the `download <https://sourceforge.net/projects/xrayutilities>`_.
99
1010 Building Layer stacks for simulations
1111 -------------------------------------
295295 Fitting of diffraction data
296296 ~~~~~~~~~~~~~~~~~~~~~~~~~~~
297297
298 All diffraction models can be embedded into the :class:`~xrayutilities.simpack.fit.FitModel` class, which is suitable to refine the model parameters. Below (and in the `examples <https://github.com/dkriegner/xrayutilities/tree/master/examples>`_ directory) a runnable script is shown which shows the fitting for a pseudomorphic InMnAs epilayer on InAs(001). The fitting is performed using the `lmfit <https://lmfit.github.io/lmfit-py/>`_ Python package which needs to be installed when you want to use this fitting function. As one can see below the :func:`~xrayutilities.simpack.FitModel.set_param_hint` function can be used to set up the respective fit parameters including their boundaries and possible correlation with other parameters of the model. It should be equally possible to fit more complex layer structures, however, I expect that one needs to adjust manually the starting parameters to yield something very reasonable. Since this capabilities are rather new please report back any success/problems you have with this via the mailing list.
298 All diffraction models can be embedded into the :class:`~xrayutilities.simpack.fit.FitModel` class, which is suitable to refine the model parameters. Below (and in the `examples <https://github.com/dkriegner/xrayutilities/tree/main/examples>`_ directory) a runnable script is shown which shows the fitting for a pseudomorphic InMnAs epilayer on InAs(001). The fitting is performed using the `lmfit <https://lmfit.github.io/lmfit-py/>`_ Python package which needs to be installed when you want to use this fitting function. As one can see below the :func:`~xrayutilities.simpack.FitModel.set_param_hint` function can be used to set up the respective fit parameters including their boundaries and possible correlation with other parameters of the model. It should be equally possible to fit more complex layer structures, however, I expect that one needs to adjust manually the starting parameters to yield something very reasonable. Since this capabilities are rather new please report back any success/problems you have with this via the mailing list.
299299
300300 .. code-block:: python
301301 :linenos:
376376 # pm.close() # after end-of-use
377377
378378
379 Note that in MS windows you need to encapsulate this code into a dummy function to allow for the multiprocessing module to work correctly. The code then must look like::
379 Note that in MS windows and macOS you need to encapsulate this code into a dummy function to allow for the multiprocessing module to work correctly. See the `Python documentation <https://docs.python.org/3/library/multiprocessing.html#the-spawn-and-forkserver-start-methods>`_ for details. The code then must look like::
380380
381381 import numpy
382382 import xrayutilities as xu
393393 pm.close()
394394
395395 if __name__ == '__main__':
396 freeze_support()
396 freeze_support() # only required on MS Windows
397397 main()
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2017 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2017-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import multiprocessing
1818 import os
2424
2525
2626 def main():
27 """dummy main function to enable multiprocessing on windows"""
27 """
28 dummy main function to enable multiprocessing on Windows and macOS.
29 This is required to avoid starting of the multiprocessing code upon import
30 of the script and is connected with the used multiprocessing start method.
31
32 See also:
33 https://docs.python.org/3/library/multiprocessing.html#the-spawn-and-forkserver-start-methods
34 """
2835 mpl.rcParams['font.size'] = 16.0
2936 mpl.rcParams['lines.linewidth'] = 2.0
3037
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2020-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616 # Copyright (C) 2020 Mike Moron <mike.moron@tu-dortmund.de>
1717
1818 import numpy as np
3737
3838 # conventional X-ray reflectivity modelling
3939 m = xu.simpack.SpecularReflectivityModel(ls)
40 pos, eldens = m.densityprofile(500)
40 pos, eldens, layer_eldens = m.densityprofile(500, individual_layers=True)
41
4142
4243 # slice the layerstack into an Amorphous sublayer at every 0.1 angstrom.
4344 # at the top a vacuum layer is added
5960 fig = plt.figure()
6061 ax = fig.add_subplot(111)
6162 ax.plot(pos, eldens, '.-', label='conventional')
63 for i in range(len(layer_eldens)):
64 ax.plot(pos, layer_eldens[i], ':')
6265 ax.plot(spos, seldens, '.-', label='sliced') # arbitrary shift for vis.
6366 ax.legend()
6467 ax.set_xlabel(r'z-position')
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
1515 # Copyright (C) 2013 Raphael Grifone <raphael.grifone@esrf.fr>
16 # Copyright (C) 2013 Dominik Kriegner <dominik.kriegner@gmail.com>
16 # Copyright (C) 2013-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1717
1818 """
1919 The function below is a modification of the hotpixelkill function included in
5050 e = xu.io.EDFFile(f)
5151 ccdraw = e.data
5252 if len(ccdavg) == 0:
53 ccdavg = ccdraw.astype(numpy.float)
53 ccdavg = ccdraw.astype(float)
5454 else:
5555 ccdavg += ccdraw
5656 n += 1
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2012 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2012-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 Example script to show how to use xrayutilities to read and plot
5454 # correction
5555 normalizer_detcorr = xu.IntensityNormalizer(
5656 "MCA", mon="Monitor", time="Seconds",
57 absfun=lambda d: d["detcorr"] / d["psd2"].astype(numpy.float))
57 absfun=lambda d: d["detcorr"] / d["psd2"].astype(float))
5858
5959 # substrate material used for Bragg peak calculation to correct for
6060 # experimental offsets
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
1515 # Copyright (C) 2009 Eugen Wintersberger <eugen.wintersberger@desy.de>
16 # Copyright (C) 2009-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
16 # Copyright (C) 2009-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1717
1818 """
1919 xrayutilities is a Python package for assisting with x-ray diffraction
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2018-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2011-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import numpy
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2011-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2011-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 functions to help with experimental alignment during experiments, especially
151151 rad = radians(x)
152152 p2 = math.radians(p[2])
153153 r = numpy.concatenate([degrees(sin(rad)) / cos(rad - p2),
154 numpy.ones(x.shape, dtype=numpy.float),
154 numpy.ones(x.shape, dtype=float),
155155 - math.degrees(p[0]) * sin(rad) /
156156 cos(rad - p2) ** 2 * sin(rad - p2)])
157157 r.shape = (3,) + x.shape
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2010 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2010-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 xrayutilities derives its own exceptions which are raised
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
1515 # Copyright (C) 2009-2010 Eugen Wintersberger <eugen.wintersberger@desy.de>
16 # Copyright (C) 2009-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
16 # Copyright (C) 2009-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1717 # Copyright (C) 2012 Tanja Etzelstorfer <tanja.etzelstorfer@jku.at>
1818
1919 """
484484 flag to tell if angles are passed as degree (default: True)
485485 sampledis : tuple or list or array-like
486486 sample displacement vector in relative units of the detector
487 distance (default: (0, 0, 0))
487 distance. Applies to parallal beam geometry. (default: (0, 0, 0))
488488 """
489489 flags = 0
490490 if self._has_translations:
564564 flag to tell if angles are passed as degree (default: True)
565565 sampledis : tuple or list or array-like
566566 sample displacement vector in relative units of the detector
567 distance (default: (0, 0, 0))
567 distance. Applies to parallal beam geometry. (default: (0, 0, 0))
568568
569569 Returns
570570 -------
768768 flag to tell if angles are passed as degree (default: True)
769769 sampledis : tuple or list or array-like
770770 sample displacement vector in relative units of the detector
771 distance (default: (0, 0, 0))
771 distance. Applies to parallal beam geometry. (default: (0, 0, 0))
772772
773773 Returns
774774 -------
10181018 flag to tell if angles are passed as degree (default: True)
10191019 sampledis : tuple or list or array-like
10201020 sample displacement vector in relative units of the detector
1021 distance (default: (0, 0, 0))
1021 distance. Applies to parallal beam geometry. (default: (0, 0, 0))
10221022
10231023
10241024 Returns
15751575 x-ray energy in eV (default: converted self._wl)
15761576 deg : bool, optional
15771577 flag to tell if angles are passed as degree (default: True)
1578 sampledis : tuple, list or array-like, optional
1578 sampledis : tuple or list or array-like
15791579 sample displacement vector in relative units of the detector
1580 distance (default: (0, 0, 0))
1580 distance. Applies to parallal beam geometry. (default: (0, 0, 0))
15811581
15821582 Returns
15831583 -------
1515 # Copyright (C) 2009-2010, 2013
1616 # Eugen Wintersberger <eugen.wintersberger@desy.de>
1717 # Copyright (C) 2009 Mario Keplinger <mario.keplinger@jku.at>
18 # Copyright (C) 2009-2017 Dominik Kriegner <dominik.kriegner@gmail.com>
18 # Copyright (C) 2009-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1919
2020 import abc
2121
164164 """
165165 prepare array for passing to c-code
166166 """
167 if isinstance(a, (list, tuple, numpy.float, numpy.int)):
167 if isinstance(a, (list, tuple, float, int)):
168168 a = numpy.asarray(a)
169169 return a.reshape(a.size)
170170
1515 # Copyright (C) 2009-2010, 2013
1616 # Eugen Wintersberger <eugen.wintersberger@desy.de>
1717 # Copyright (C) 2009 Mario Keplinger <mario.keplinger@jku.at>
18 # Copyright (C) 2009-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
18 # Copyright (C) 2009-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1919
2020 import numpy
2121
250250 for i in range(self.nx):
251251 for j in range(self.ny):
252252 self._gdata[i, j] = []
253 self._gnorm = numpy.zeros((self.nx, self.ny), dtype=numpy.int)
253 self._gnorm = numpy.zeros((self.nx, self.ny), dtype=int)
254254
255255 def Clear(self):
256256 self._allocate_memory()
284284
285285 # perform gridding this should be moved to native code if possible
286286 def gindex(x, min, delt):
287 return numpy.round((x - min) / delt).astype(numpy.int)
287 return numpy.round((x - min) / delt).astype(int)
288288
289289 xdelta = delta(self.xmin, self.xmax, self.nx)
290290 ydelta = delta(self.ymin, self.ymax, self.ny)
1515 # Copyright (C) 2009-2010, 2013
1616 # Eugen Wintersberger <eugen.wintersberger@desy.de>
1717 # Copyright (C) 2009 Mario Keplinger <mario.keplinger@jku.at>
18 # Copyright (C) 2009-2016 Dominik Kriegner <dominik.kriegner@gmail.com>
18 # Copyright (C) 2009-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
1919
2020 import numpy
2121
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2013, 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 # module for handling files stored in the CBF data format
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2013-2014 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717
1818 """
7878 def ReadMCA(self):
7979 self.mca = numpy.empty((len(self.mca_files),
8080 numpy.loadtxt(self.mca_files[0]).shape[0]),
81 dtype=numpy.float)
81 dtype=float)
8282 for i in range(len(self.mca_files)):
8383 mcadata = numpy.loadtxt(self.mca_files[i])
8484
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
1515 # Copyright (C) 2009-2010 Eugen Wintersberger <eugen.wintersberger@desy.de>
16 # Copyright (C) 2010-2012,2014-2015
16 # Copyright (C) 2010-2012,2014-2019
1717 # Dominik Kriegner <dominik.kriegner@gmail.com>
1818 # Copyright (C) 2012 Tanja Etzelstorfer <tanja.etzelstorfer@jku.at>
1919
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import glob
1818 import os.path
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 module for reading ILL data files (station D23): numor files
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2012-2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2012-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import time
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import copy
1818 import re
108108 loopheader = []
109109 numOfEntries = -1
110110 multiline = None
111 label = None
111112
112113 while True:
113114 line = fh.readline().decode('ascii')
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015-2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717
1818 """
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
1515 # Copyright (C) 2009 Eugen Wintersberger <eugen.wintersberger@desy.de>
16 # Copyright (C) 2009-2013 Dominik Kriegner <dominik.kriegner@gmail.com>
16 # Copyright (C) 2009-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1717
1818 """
1919 a set of routines to convert Seifert ASCII files to HDF5
267267 self.data.append(tmplist)
268268
269269 # in the end we convert the data list to a numeric array
270 self.data = numpy.array(self.data, dtype=numpy.float)
270 self.data = numpy.array(self.data, dtype=float)
271271 for key in self.axispos:
272272 self.axispos[key] = numpy.array(self.axispos[key])
273273
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
1515 # Copyright (C) 2009-2010 Eugen Wintersberger <eugen.wintersberger@desy.de>
16 # Copyright (C) 2009-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
16 # Copyright (C) 2009-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
17 # Copyright (C) 2019 Daniel Schick <schick.daniel@gmail.com>
1718
1819 """
1920 a class for observing a SPEC data file
510511
511512 # write the initial motor positions as attributes
512513 for k in self.init_motor_pos:
513 g.attrs[k] = numpy.float(self.init_motor_pos[k])
514 g.attrs[k] = float(self.init_motor_pos[k])
514515
515516 # if scan contains MCA data write also MCA parameters
516517 g.attrs['has_mca'] = self.has_mca
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
1515 # Copyright (C) 2009-2010 Eugen Wintersberger <eugen.wintersberger@desy.de>
16 # Copyright (C) 2009-2015 Dominik Kriegner <dominik.kriegner@gmail.com>
16 # Copyright (C) 2009-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
1717
1818 """
1919 module to handle spectra data
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
1515 # Copyright (C) 2009 Eugen Wintersberger <eugen.wintersberger@desy.de>
16 # Copyright (C) 2010-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
16 # Copyright (C) 2010-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1717
1818 from . import elements
1919 from .atom import Atom
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2009-2012 Eugen Wintersberger <eugen.wintersberger@desy.de>
1516 # Copyright (C) 2012-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1617 """
1718 script to create the HDF5 database from the raw data of XOP.
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2009-2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 module containing the Atom class which handles the database access for atomic
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2010-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2010-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import copy
1818 import io
217217 def get_element(cifstring):
218218 el = re.sub(r"['\"]", r"", cifstring)
219219 if '+' in el or '-' in el:
220 # add oxidation number if not present
221 for sign in ('+', '-'):
222 if sign in el:
223 if not el[el.index(sign)-1].isdigit():
224 signidx = el.index(sign)
225 el = el[:signidx] + '1' + el[signidx:]
226 # replace special characters
220227 for r, o in zip(('dot', 'p', 'm'), ('.', '+', '-')):
221 # move special character to last position
222228 el = el.replace(o, r)
223229 else:
224230 el = re.sub(r"([0-9])", r"", el)
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
1515 # Copyright (C) 2009 Eugen Wintersberger <eugen.wintersberger@desy.de>
16 # Copyright (C) 2010-2015 Dominik Kriegner <dominik.kriegner@gmail.com>
16 # Copyright (C) 2010-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1717
1818 from .atom import Atom
1919
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2018 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2018-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 implement convenience functions to define Heusler materials.
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2018 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2018-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import math
1818 from math import pi
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2013-2017 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import numpy
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2017-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2017-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616 """
1717 module handling crystal lattice structures. A SGLattice consists of a space
1818 group number and the position of atoms specified as Wyckoff positions along
12681268 # check all atomic species seperately
12691269 for el in elements:
12701270 catoms = list(filter(lambda at: at[0] == el, atoms))
1271 found = numpy.zeros(len(catoms), dtype=numpy.bool)
1271 found = numpy.zeros(len(catoms), dtype=bool)
12721272 # see if atomic positions fit to Wyckoff positions
12731273 for k, wyckpos in wp[sgrp].items():
12741274 num = int(k[:-1])
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2018-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2017-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 __all__ = ["RangeDict", "eqhkl_default", "eqhkl_custom", "wp"]
1818
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
1515 # Copyright (C) 2009 Eugen Wintersberger <eugen.wintersberger@desy.de>
16 # Copyright (C) 2010-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
16 # Copyright (C) 2010-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1717
1818 from .algebra import solve_quartic
1919 from .fit import (fit_peak2d, gauss_fit, linregress, multPeakFit, multPeakPlot,
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016-2018 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 module providing analytic algebraic functions not implemented in scipy or any
7777 t36 = 16 * t17 * t27
7878 t37 = 144 * t07 * t12 * t17
7979 t30 = t26 + t28 + t29 - t35 - t36 - t37
80 t31 = t30.astype(numpy.complex)**(1./2)
80 t31 = t30.astype(complex)**(1./2)
8181 t32 = (t24 * t31) / 18
8282 t34 = (4 * t07 * t17) / 3
8383 t33 = t22 + t23 + t32 - t34
84 t38 = 1 / t33.astype(numpy.complex)**(1./6)
84 t38 = 1 / t33.astype(complex)**(1./6)
8585 t39 = t33**(1./3)
8686 t40 = 12 * a0 * t01
8787 t41 = t33**(2./3)
9191 t47 = (9 * t14 * t15) / 64
9292 t48 = 3 * a3 * a1 * t04
9393 t44 = t08 + t40 + t42 + t43 - t46 - t47 - t48
94 t45 = t44.astype(numpy.complex)**(1./2)
94 t45 = t44.astype(complex)**(1./2)
9595 t49 = 6.**(1./2)
9696 t50 = 27 * t12
9797 t51 = 2 * t07 * t08
9898 t52 = 3 * t24 * t31
9999 t62 = 72 * t07 * t17
100100 t53 = t50 + t51 + t52 - t62
101 t54 = t53.astype(numpy.complex)**(1./2)
101 t54 = t53.astype(complex)**(1./2)
102102 t55 = 3 * t03 * t49 * t54
103103 t59 = t08 * t45
104104 t60 = 12 * t17 * t45
105105 t61 = 9 * t41 * t45
106106 t63 = 12 * t07 * t39 * t45
107107 t56 = t55 - t59 - t60 - t61 - t63
108 t57 = t56.astype(numpy.complex)**(1./2)
109 t58 = 1. / t44.astype(numpy.complex)**(1./4)
108 t57 = t56.astype(complex)**(1./2)
109 t58 = 1. / t44.astype(complex)**(1./4)
110110 t64 = (t38 * t45) / 6
111111 t65 = - t55 - t59 - t60 - t61 - t63
112 t66 = t65.astype(numpy.complex)**(1./2)
112 t66 = t65.astype(complex)**(1./2)
113113
114114 return (-(a3 * t01) / 4 - (t38 * t45) / 6 - (t38 * t57 * t58) / 6,
115115 (t38 * t57 * t58) / 6 - (t38 * t45) / 6 - (a3 * t01) / 4,
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2012-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2012-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616 """
1717 module with a function wrapper to scipy.optimize.leastsq
1818 for fitting of a 2D function to a peak or a 1D Gauss fit with
649649 if fit.stopreason[0] not in ['Sum of squares convergence']:
650650 print("XU.math.multPeakFit: fit NOT converged (%s)"
651651 % fit.stopreason[0])
652 return Nono, None, None, None
652 return None, None, None, None
653653 except IndexError:
654654 print("XU.math.multPeakFit: fit most probably NOT converged (%s)"
655655 % str(fit.stopreason))
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2012-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2012-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 module with several common function needed in xray data analysis
8585 dataout = data.copy()
8686
8787 mean = (data[:-2] + data[2:]) / 2.
88 mask = numpy.zeros_like(data[1:-1], dtype=numpy.bool)
88 mask = numpy.zeros_like(data[1:-1], dtype=bool)
8989 if threshold:
9090 mask = numpy.logical_or(
9191 mask, numpy.logical_or(data[1:-1] * threshold < mean,
182182 r = numpy.vstack((- (p[0] - x) / p[1]**2 * Gauss1d(x, *lp),
183183 (p[0] - x) ** 2 / (p[1] ** 3) * Gauss1d(x, *lp),
184184 Gauss1d(x, *lp) / p[2],
185 numpy.ones(x.shape, dtype=numpy.float)))
185 numpy.ones(x.shape, dtype=float)))
186186
187187 return r
188188
320320 8 * p[2] * p[1] * (x-p[0])**2 /
321321 (4*p[0]**2 - 8*p[0]*x + p[1]**2 + 4*x**2) ** 2,
322322 1 / (1 + (2 * (x - p[0]) / p[1]) ** 2),
323 numpy.ones(x.shape, dtype=numpy.float)))
323 numpy.ones(x.shape, dtype=float)))
324324 return r
325325
326326
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016-2018 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import fractions
1818 import math
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016-2017 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2017-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616 """
1717 Defines new matplotlib Sqrt scale which further allows for negative values by
1818 using the sign of the original value as sign of the plotted value.
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2010-2011 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2010-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 module to provide functions that perform block averaging
235235 Examples
236236 --------
237237 >>> detcorr = IntensityNormalizer("MCA", time="Seconds",
238 >>> absfun=lambda d: d["PSDCORR"]/d["PSD"].astype(numpy.float))
238 >>> absfun=lambda d: d["PSDCORR"]/d["PSD"].astype(float))
239239 """
240240 valid_kwargs = {'mon': 'monitor field name',
241241 'time': 'count time field/value',
385385 sets the flatfield of the detector
386386 """
387387 if isinstance(flatf, (list, tuple, numpy.ndarray)):
388 self._flatfield = numpy.array(flatf, dtype=numpy.float)
388 self._flatfield = numpy.array(flatf, dtype=float)
389389 self._flatfieldav = numpy.mean(self._flatfield[
390390 self._flatfield.nonzero()])
391391 self._flatfield[self.flatfield < 1.e-5] = 1.0
411411 sets the darkfield of the detector
412412 """
413413 if isinstance(darkf, (list, tuple, numpy.ndarray)):
414 self._darkfield = numpy.array(darkf, dtype=numpy.float)
414 self._darkfield = numpy.array(darkf, dtype=float)
415415 self._darkfieldav = numpy.mean(self._darkfield)
416416 elif isinstance(darkf, type(None)):
417417 self._darkfield = None
450450 else:
451451 rawdata = data[self._det]
452452
453 corrint = numpy.zeros(rawdata.shape, dtype=numpy.float)
453 corrint = numpy.zeros(rawdata.shape, dtype=float)
454454
455455 # set needed variables
456456 # monitor intensity
527527 corrint = (corrint / self._flatfield[numpy.newaxis, :] *
528528 self._flatfieldav)
529529
530 elif len(rawdata.shape) == 2 and isinstance(c, numpy.float):
530 elif len(rawdata.shape) == 2 and isinstance(c, float):
531531 # single 2D detector frame
532532 corrint = rawdata * c
533533
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 Module provides functions to convert a q-vector from reciprocal space to
5858 bounds to be handed over to the scipy.minimize routine. The function
5959 will expand fixed values to two equal bounds
6060 constraints, list
61 list of equivility constraints for fixed values
61 list of equality constraints for fixed values
6262 """
6363 lb = []
6464 ub = []
6969 lb.append(b[0])
7070 ub.append(b[1])
7171 elif len(b) == 1:
72 # due to a bug in scipy >= 1.5.0 we need to allow a small
73 # variation
74 lb.append(b[0] - config.EPSILON)
75 ub.append(b[0] + config.EPSILON)
76 # to really fix the parameter we create an equivalent
77 # constraint; see scipy/scipy#12433
72 # upper = lower bound needs an equality constraint.
73 lb.append(-numpy.inf)
74 ub.append(numpy.inf)
75 # see scipy/scipy#12433
7876 constraints.append(dict(type='eq',
7977 fun=lambda x, j=j, v=b[0]: x[j] - v,
8078 # lambda j=j to bind variable by value
8280 else:
8381 raise InputError('bound values must have two or one elements')
8482 elif isinstance(b, numbers.Number):
85 # due to a bug in scipy >= 1.5.0 we need to allow a small variation
86 lb.append(b - config.EPSILON)
87 ub.append(b + config.EPSILON)
88 # to really fix the parameter we create an equivalent
89 # constraint; see scipy/scipy#12433
83 # upper = lower bound needs an equality constraint.
84 lb.append(-numpy.inf)
85 ub.append(numpy.inf)
86 # see scipy/scipy#12433
9087 constraints.append(dict(type='eq',
9188 fun=lambda x, j=j, v=b: x[j] - v,
9289 # lambda j=j to bind variable by value
9390 ))
9491 elif b is None:
95 lb.append(-np.inf)
96 ub.append(np.inf)
92 lb.append(-numpy.inf)
93 ub.append(numpy.inf)
9794 else:
9895 raise InputError('bound value is of invalid type (%s)' % type(b))
9996
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2012-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616 """
1717 simulation subpackage of xrayutilities.
1818
2828 DarwinModelAlloy, DarwinModelGaInAs001,
2929 DarwinModelSiGe001, GradedBuffer)
3030 from .fit import FitModel
31 from .helpers import coplanar_alphai, get_qz
31 from .helpers import coplanar_alphaf, coplanar_alphai, get_qz
3232 from .models import (DiffuseReflectivityModel, DynamicalModel,
3333 DynamicalReflectivityModel, KinematicalModel,
3434 KinematicalMultiBeamModel, LayerModel, Model,
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616 import abc
1717 import collections.abc
1818 import copy
207207 Ih = {'S': numpy.zeros(len(self.qz)), 'P': numpy.zeros(len(self.qz))}
208208 geomfact = heaviside(self.alphai) * heaviside(self.alphaf)
209209 for pol in self.get_polarizations():
210 r, rbar, t = (numpy.zeros(self.npoints, dtype=numpy.complex),
211 numpy.zeros(self.npoints, dtype=numpy.complex),
212 numpy.ones(self.npoints, dtype=numpy.complex))
210 r, rbar, t = (numpy.zeros(self.npoints, dtype=complex),
211 numpy.zeros(self.npoints, dtype=complex),
212 numpy.ones(self.npoints, dtype=complex))
213213 for nrep, subml in ml:
214214 r, rbar, t = self._recur_sim(nrep, subml, r, rbar, t, pol)
215215 self.r, self.rbar, self.t = r, rbar, t
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import numpy
1818
1919 from .. import config, utilities
2020
2121
22 def coplanar_alphai(qx, qz, en='config'):
22 def coplanar_alphai(qx, qz, en='config', nan_Laue=False):
2323 """
24 calculate coplanar incidence angle from knowledge of the qx and qz
25 coordinates
24 calculate coplanar incidence angle from knowledge of the qx (inplane) and
25 qz (out of plane) coordinates
2626
2727 Parameters
2828 ----------
3232 out of plane momentum transfer component
3333 en : float or str, optional
3434 x-ray energy (eV). By default the value from the config is used.
35 nan_Laue : bool, optional
36 set output points inside the Laue zone to 'nan'. default: False
3537
3638 Returns
3739 -------
3840 alphai : array-like
39 the incidence angle in degree. points in the Laue zone are set to
41 the incidence angle in degree
42 """
43 if isinstance(en, str) and en == 'config':
44 en = utilities.energy(config.ENERGY)
45 k = 2 * numpy.pi / utilities.en2lam(en)
46 th = numpy.arcsin(numpy.sqrt(qx**2 + qz**2) / (2 * k))
47 ai = numpy.arctan2(qx, qz) + th
48 if nan_Laue:
49 if isinstance(ai, numpy.ndarray): # remove positions in Laue zone
50 ai[qz < numpy.sqrt(2 * qx * k - qx**2)] = numpy.nan
51 else:
52 if qz < numpy.sqrt(2 * qx * k - qx**2):
53 ai = numpy.nan
54 return numpy.degrees(ai)
55
56
57 def coplanar_alphaf(qx, qz, en='config', nan_Laue=False):
58 """
59 calculate coplanar exit angle from knowledge of the qx (inplane) and qz
60 (out of plane) coordinates
61
62 Parameters
63 ----------
64 qx : array-like
65 inplane momentum transfer component
66 qz : array-like
67 out of plane momentum transfer component
68 en : float or str, optional
69 x-ray energy (eV). By default the value from the config is used.
70 nan_Laue : bool, optional
71 set output points inside the Laue zone to 'nan'. default: False
72
73 Returns
74 -------
75 alphaf : array-like
76 the exit angle in degree. points in the Laue zone are set to
4077 'nan'.
4178 """
4279 if isinstance(en, str) and en == 'config':
4380 en = utilities.energy(config.ENERGY)
4481 k = 2 * numpy.pi / utilities.en2lam(en)
4582 th = numpy.arcsin(numpy.sqrt(qx**2 + qz**2) / (2 * k))
46 ai = numpy.arctan2(qx, qz) + th
47 if isinstance(ai, numpy.ndarray): # remove positions in Laue zone
48 ai[qz < numpy.sqrt(2 * qx * k - qx**2)] = numpy.nan
49 else:
50 if qz < numpy.sqrt(2 * qx * k - qx**2):
51 ai = numpy.nan
52 return numpy.degrees(ai)
83 af = th - numpy.arctan2(qx, qz)
84 if nan_Laue:
85 if isinstance(af, numpy.ndarray): # remove positions in Laue zone
86 af[qz < numpy.sqrt(2 * qx * k - qx**2)] = numpy.nan
87 else:
88 if qz < numpy.sqrt(2 * qx * k - qx**2):
89 af = numpy.nan
90 return numpy.degrees(af)
5391
5492
5593 def get_qz(qx, alphai, en='config'):
69107 Returns
70108 -------
71109 array-like
72 the qz position for the given incidence angle
110 the qz position for the given incidence angle. The output is nan in
111 case the inplane momentum transfer can not be reached.
73112 """
74113 if isinstance(en, str) and en == 'config':
75114 en = utilities.energy(config.ENERGY)
76115 k = 2 * numpy.pi / utilities.en2lam(en)
77116 ai = numpy.radians(alphai)
78 return numpy.sqrt(k**2 - (qx + k * numpy.cos(ai))**2) + k * numpy.sin(ai)
117 qz = numpy.sqrt(k**2 - (qx + k * numpy.cos(ai))**2) + k * numpy.sin(ai)
118 return qz
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import abc
1818 import copy
327327 domega = numpy.arctan2(qinp, qz)
328328 alphai, alphaf = (theta + domega, theta - domega)
329329 # calculate structure factors
330 f = numpy.empty((len(self.lstack), len(qz)), dtype=numpy.complex)
331 fhkl = numpy.empty(len(self.lstack), dtype=numpy.complex)
330 f = numpy.empty((len(self.lstack), len(qz)), dtype=complex)
331 fhkl = numpy.empty(len(self.lstack), dtype=complex)
332332 for i, l in enumerate(self.lstack):
333333 m = l.material
334334 fhkl[i] = m.StructureFactor(m.Q(*hkl), en=self.energy) /\
336336 f[i, :] = m.StructureFactorForQ(qv, en0=self.energy) /\
337337 m.lattice.UnitCellVolume()
338338
339 E = numpy.zeros(len(qz), dtype=numpy.complex)
339 E = numpy.zeros(len(qz), dtype=complex)
340340 return rel, alphai, alphaf, f, fhkl, E, t
341341
342342 def _get_qz(self, qz, alphai, alphaf, chi0, absorption, refraction):
343343 k = self.exp.k0
344 q = qz.astype(numpy.complex)
344 q = qz.astype(complex)
345345 if absorption and not refraction:
346346 q += 1j * k * numpy.imag(chi0) / \
347347 numpy.sin((alphai + alphaf) / 2)
398398 if l.thickness == numpy.inf:
399399 E += fhkl[i] * numpy.exp(-1j * z[i] * q) / (1j * q)
400400 else:
401 E += - fhkl[i] * numpy.exp(-1j * q * z[i]) * \
401 E += fhkl[i] * numpy.exp(-1j * q * z[i]) * \
402402 (1 - numpy.exp(1j * q * l.thickness)) / (1j * q)
403403
404404 wf = numpy.sqrt(heaviside(ai) * heaviside(af) * rel**2 /
668668 # deviation of the incident beam from the kinematical maximum
669669 eta = numpy.radians(alphai) - thetaB - asym
670670
671 xs = None # avoid linting error in code below
671672 for pol in self.get_polarizations():
672 x = numpy.zeros(len(alphai), dtype=numpy.complex)
673 x = numpy.zeros(len(alphai), dtype=complex)
673674 for i, l in enumerate(self.lstack):
674675 beta = (2 * eta * numpy.sin(2 * thetaB) +
675676 self.chi0[i] * (1 - gammah / gamma0) -
770771 ah[mask] = numpy.arcsin(pp[mask])
771772
772773 nal = len(ai)
774 Ps = None # make linter happy
773775 for pol in self.get_polarizations():
774776 if pol == 'S':
775777 CC = numpy.ones(nal)
779781 if config.VERBOSITY >= config.INFO_ALL:
780782 print('XU.DynamicalModel: calc. %s-polarization...' % (pol))
781783
782 M = numpy.zeros((nal, 4, 4), dtype=numpy.complex)
784 M = numpy.zeros((nal, 4, 4), dtype=complex)
783785 for j in range(4):
784786 M[:, j, j] = numpy.ones(nal)
785787
794796 X = solve_quartic(A4, A3, A2, A1, A0)
795797 X = numpy.asarray(X).T
796798
797 kz = numpy.zeros((nal, 4), dtype=numpy.complex)
799 kz = numpy.zeros((nal, 4), dtype=complex)
798800 kz[:, :2] = X[numpy.imag(X) <= 0].reshape(nal, 2)
799801 kz[:, 2:] = X[numpy.imag(X) > 0].reshape(nal, 2)
800802
801 P = numpy.zeros((nal, 4, 4), dtype=numpy.complex)
802 phi = numpy.zeros((nal, 4, 4), dtype=numpy.complex)
803 P = numpy.zeros((nal, 4, 4), dtype=complex)
804 phi = numpy.zeros((nal, 4, 4), dtype=complex)
803805 c = ((Kix**2)[:, numpy.newaxis] + kz**2 - kc[jL]**2) / k**2 /\
804806 self.chimh['S'][jL] / CC[:, numpy.newaxis]
805807 if jL > 0:
827829 numpy.einsum('...ij,...jk', M, R), phi)
828830 Ps = numpy.copy(P)
829831
830 B = numpy.zeros((nal, 4, 4), dtype=numpy.complex)
832 B = numpy.zeros((nal, 4, 4), dtype=complex)
831833 B[..., :2] = M[..., :2]
832834 B[:, 0, 2] = -numpy.ones(nal)
833835 B[:, 1, 3] = -numpy.ones(nal)
951953 else:
952954 shape = numpy.ones(np)
953955
954 ETs = numpy.ones(np, dtype=numpy.complex)
955 ERs = numpy.zeros(np, dtype=numpy.complex)
956 ETs = numpy.ones(np, dtype=complex)
957 ERs = numpy.zeros(np, dtype=complex)
956958 ks = -self.exp.k0 * numpy.sqrt(sai**2 - 2 * cd[0] * rho[0])
957959
958960 for i in range(ns):
972974 R = shape * abs(ER / ET)**2
973975 return self.scale_simulation(self.convolute_resolution(lai, R))
974976
975 def densityprofile(self, nz, plot=False):
977 def densityprofile(self, nz, plot=False, individual_layers=False):
976978 """
977979 calculates the electron density of the layerstack from the thickness
978980 and roughness of the individual layers
983985 number of values on which the profile should be calculated
984986 plot : bool, optional
985987 flag to tell if a plot of the profile should be created
988 individual_layers : bool, optional
989 return the density contributions of all layers as additional return
990 value.
986991
987992 Returns
988993 -------
990995 z-coordinates, z = 0 corresponds to the surface
991996 eprof : array-like
992997 electron profile
998 layereprof : 2D array, optional
999 electron profile of every sublayer with shape (nlayer, nz). This
1000 is only returned when individual_layers=True
9931001 """
9941002 if plot:
9951003 try:
10471055 sdown = (1 + erf((zdownint - z) / sigint / numpy.sqrt(2))) / 2
10481056 w[i, :] = sup - sdown
10491057
1050 prof = numpy.sum(dr[:, numpy.newaxis] * w[:, ...], axis=0)
1058 layer_prof = dr[:, numpy.newaxis] * w[:, ...]
1059 prof = numpy.sum(layer_prof, axis=0)
10511060
10521061 if plot:
10531062 plt.figure('XU:density_profile', figsize=(5, 3))
1063 for i, layer in enumerate(self.lstack):
1064 plt.plot(z, layer_prof[i, :], ':r', lw=1, label=layer.name)
10541065 plt.plot(z, prof, '-k', lw=2, label='electron density')
10551066 plt.xlabel(r'z ($\mathrm{\AA}$)')
10561067 plt.ylabel(r'electron density (e$^-$ cm$^{-3}$)')
10571068 plt.tight_layout()
10581069
1070 if individual_layers:
1071 return z, prof, layer_prof
10591072 return z, prof
10601073
10611074
13431356 else:
13441357 shape = numpy.ones(np)
13451358
1346 ETs = numpy.ones(np, dtype=numpy.complex)
1347 ERs = numpy.zeros(np, dtype=numpy.complex)
1359 ETs = numpy.ones(np, dtype=complex)
1360 ERs = numpy.zeros(np, dtype=complex)
13481361 ks = -self.exp.k0 * numpy.sqrt(sai**2 - 2 * cd[0] * rho[0])
13491362
13501363 for i in range(ns):
16151628 k-vector, z-component of k-vector in the material.
16161629 """
16171630 k0 = -K * numpy.sin(alphai)
1618 kz = numpy.zeros((N+1, NqL, Nqz), dtype=numpy.complex)
1619 T = numpy.zeros((N+1, NqL, Nqz), dtype=numpy.complex)
1620 R = numpy.zeros((N+1, NqL, Nqz), dtype=numpy.complex)
1631 kz = numpy.zeros((N+1, NqL, Nqz), dtype=complex)
1632 T = numpy.zeros((N+1, NqL, Nqz), dtype=complex)
1633 R = numpy.zeros((N+1, NqL, Nqz), dtype=complex)
16211634 for jn in range(N+1):
16221635 kz[jn, ...] = -K * numpy.sqrt(numpy.sin(alphai)**2 -
16231636 2 * delta[jn])
16241637
1625 T[N, ...] = numpy.ones((NqL, Nqz), dtype=numpy.complex)
1638 T[N, ...] = numpy.ones((NqL, Nqz), dtype=complex)
16261639 kzs = kz[N, ...] # kz in substrate
16271640 for jn in range(N-1, -1, -1):
16281641 kzn = kz[jn, ...]
16811694 psi : array-like
16821695 correlation function
16831696 """
1684 psi = numpy.zeros((NqL, Nqz), dtype=numpy.complex)
1697 psi = numpy.zeros((NqL, Nqz), dtype=complex)
16851698 if H == 0.5 or H == 1:
1686 dpsi = numpy.zeros_like(psi, dtype=numpy.complex)
1699 dpsi = numpy.zeros_like(psi, dtype=complex)
16871700 m = isurf > 0
16881701 n = 1
16891702 s = numpy.copy(b)
18341847 T2 = 2 * k02 / (k02 + kz2)
18351848 R01 = (k01 - kz1) / (k01 + kz1)
18361849 R02 = (k02 - kz2) / (k02+kz2)
1837 R1 = numpy.zeros((NqL, Nqz), dtype=numpy.complex)
1850 R1 = numpy.zeros((NqL, Nqz), dtype=complex)
18381851 R2 = numpy.copy(R1)
18391852 nproc = 1
18401853 else: # method == 2
18571870 z[jn] = z[jn-1] - thick[jn-1]
18581871
18591872 # calculation of the deltas
1860 delt = numpy.zeros(N+1, dtype=numpy.complex)
1873 delt = numpy.zeros(N+1, dtype=complex)
18611874 for jn in range(N+1):
18621875 if jn == 0:
18631876 delt[jn] = delta[jn]
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2019 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2019-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import math
1818
1313 # You should have received a copy of the GNU General Public License
1414 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1515 #
16 # Copyright (C) 2016-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1716 # Copyright (C) 2015-2017 Marcus H. Mendenhall <marcus.mendenhall@nist.gov>
17 # Copyright (C) 2017-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1818
1919 # FP_profile was derived from http://dx.doi.org/10.6028/jres.120.014.c
2020
137137 ]
138138
139139 ft_factors.sort()
140 ft_factors = numpy.array(ft_factors, numpy.int)
140 ft_factors = numpy.array(ft_factors, int)
141141
142142 # used for debugging moments from FP_profile.axial_helper().
143143 moment_list = []
350350 b = self.add_buffer # shortcut
351351
352352 # a real-format scratch buffer
353 self._rb1 = b(numpy.zeros(nn, numpy.float))
353 self._rb1 = b(numpy.zeros(nn, float))
354354 # a real-format scratch buffer
355 self._rb2 = b(numpy.zeros(nn, numpy.float))
355 self._rb2 = b(numpy.zeros(nn, float))
356356 # a real-format scratch buffer
357 self._rb3 = b(numpy.zeros(nn, numpy.float))
357 self._rb3 = b(numpy.zeros(nn, float))
358358 # a complex-format scratch buffer
359 self._cb1 = b(numpy.zeros(nn, numpy.complex))
359 self._cb1 = b(numpy.zeros(nn, complex))
360360 # a scratch buffer used by the axial helper
361361 self._f0buf = b(numpy.zeros(self.oversampling *
362 twotheta_output_points, numpy.float))
362 twotheta_output_points, float))
363363 # a scratch buffer used for axial divergence
364364 self._epsb2 = b(numpy.zeros(self.oversampling *
365 twotheta_output_points, numpy.float))
365 twotheta_output_points, float))
366366 # the I2+ buffer
367367 self._I2p = b(numpy.zeros(self.oversampling *
368 twotheta_output_points, numpy.float))
368 twotheta_output_points, float))
369369 # the I2- buffer
370370 self._I2m = b(numpy.zeros(self.oversampling *
371 twotheta_output_points, numpy.float))
371 twotheta_output_points, float))
372372 # another buffer used for axial divergence
373373 self._axial = b(numpy.zeros(self.oversampling *
374 twotheta_output_points, numpy.float))
374 twotheta_output_points, float))
375375 # the largest frequency in Fourier space
376376 omega_max = self.n_omega_points * 2 * pi / window_fullwidth
377377 # build the x grid and the complex array that is the convolver
460460 """
461461 self.param_dicts["conv_" + convolver].update(kwargs)
462462
463 def get_conv(self, name, key, format=numpy.float):
463 def get_conv(self, name, key, format=float):
464464 """
465465 get a cached, pre-computed convolver associated with the given
466466 parameters, or a newly zeroed convolver if the cache doesn't contain
10431043 if "equatorial_divergence_deg" in kwargs:
10441044 del kwargs["equatorial_divergence_deg"] # not used
10451045
1046 flag, axfn = self.get_conv(me, kwargs, numpy.complex)
1046 flag, axfn = self.get_conv(me, kwargs, complex)
10471047 if flag:
10481048 return axfn # already up to date if first return is True
10491049
10851085 # we also need the diffractometer radius from the global space
10861086 kwargs["diffractometer_radius"] = self.param_dicts[
10871087 "conv_global"]["diffractometer_radius"]
1088 flag, tailfn = self.get_conv(me, kwargs, numpy.complex)
1088 flag, tailfn = self.get_conv(me, kwargs, complex)
10891089 if flag:
10901090 return tailfn # already up to date
10911091
11451145 """
11461146 if width is None:
11471147 return # no convolver
1148 flag, conv = self.get_conv(name, width, numpy.float)
1148 flag, conv = self.get_conv(name, width, float)
11491149 if flag:
11501150 return conv # already up to date
11511151 rb1 = self._rb1
12401240 if hasattr(v, 'tolist'):
12411241 key[k] = v.tolist()
12421242
1243 flag, emiss = self.get_conv(me, key, numpy.complex)
1243 flag, emiss = self.get_conv(me, key, complex)
12441244 if flag:
12451245 return emiss # already up to date
12461246
13021302 return None
13031303 twotheta0 = self.param_dicts["conv_global"]["twotheta0"]
13041304 key = (twotheta0, equatorial_divergence_deg)
1305 flag, conv = self.get_conv(me, key, numpy.complex)
1305 flag, conv = self.get_conv(me, key, complex)
13061306 if flag:
13071307 return conv # already up to date
13081308
13431343 kwargs["diffractometer_radius"] = self.param_dicts[
13441344 "conv_global"]["diffractometer_radius"]
13451345
1346 flag, conv = self.get_conv(me, kwargs, numpy.complex)
1346 flag, conv = self.get_conv(me, kwargs, complex)
13471347 if flag:
13481348 return conv # already up to date
13491349 xx = type("data", (), kwargs) # make it dot-notation accessible
13961396 flag, conv = self.get_conv(me,
13971397 (twotheta0, diffractometer_radius,
13981398 specimen_displacement, zero_error_deg),
1399 numpy.complex)
1399 complex)
14001400 if flag:
14011401 return conv # already up to date
14021402
14551455 return None
14561456 kwargs.update(self.param_dicts["conv_global"])
14571457
1458 flag, conv = self.get_conv(me, kwargs, numpy.float)
1458 flag, conv = self.get_conv(me, kwargs, float)
14591459 if flag:
14601460 return conv # already up to date
14611461
15061506 if not self.gaussian_smoother_bins_sigma:
15071507 return # no smoothing
15081508 flag, buf = self.get_conv(me, self.gaussian_smoother_bins_sigma,
1509 format=numpy.float)
1509 format=float)
15101510 if flag:
15111511 return buf # already computed
15121512 buf[:] = self.omega_vals
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016-2017 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2017-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import numbers
1818 from math import sqrt
573573 if exp is not None:
574574 ax.plot(twotheta, exp, formatexp, label=labelexp)
575575 if mask is None:
576 mask = numpy.ones_like(twotheta, dtype=numpy.bool)
576 mask = numpy.ones_like(twotheta, dtype=bool)
577577 if isinstance(sim, PowderModel):
578578 simdata = sim.simulate(twotheta[mask])
579579 sim.plot(twotheta[mask], label=labelsim, formatspec=formatsim, ax=ax)
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import collections.abc
1818 import copy
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2010-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2010-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 """
1818 xrayutilities utilities contains a conglomeration of useful functions
1111 =============
1212
1313
14 [![Build Status](https://dev.azure.com/dominikkriegner/xrayutilities/_apis/build/status/dkriegner.xrayutilities?repoName=dkriegner%2Fxrayutilities&branchName=master)](https://dev.azure.com/dominikkriegner/xrayutilities/_build/latest?definitionId=1&repoName=dkriegner%2Fxrayutilities&branchName=master)
14 [![Build Status](https://dev.azure.com/dominikkriegner/xrayutilities/_apis/build/status/dkriegner.xrayutilities?repoName=dkriegner%2Fxrayutilities&branchName=main)](https://dev.azure.com/dominikkriegner/xrayutilities/_build/)
1515
1616 xrayutilities is a collection of scripts used to analyze and simulate x-ray
1717 diffraction data. It consists of a Python package and several routines coded
215215 Classifier: License :: OSI Approved :: GNU General Public License v2 or later (GPLv2+)
216216 Requires-Python: ~=3.6
217217 Description-Content-Type: text/markdown
218 Provides-Extra: fit
218219 Provides-Extra: plot
219 Provides-Extra: fit
11 LICENSE.txt
22 MANIFEST.in
33 README.md
4 pyproject.toml
45 setup.py
56 doc/source/conf.py
67 doc/source/example_xu_ccd_parameter.py
171172 src/qconversion.c
172173 src/qconversion.h
173174 src/xrayutilities.h
174 tests/__init__.py
175175 tests/test_HXRD.py
176176 tests/test_NonCOP.py
177177 tests/test_alloy_content_calc.py
0 h5py
01 numpy>=1.9.2
12 scipy>=0.13.0
2 h5py
33
44 [fit]
55 lmfit>=1.0.1
0 [build-system]
1 requires = ["setuptools", "wheel", "numpy"]
2 build-backend = "setuptools.build_meta"
3
4 [tool.coverage.paths]
5 source = [
6 "lib",
7 "*/site-packages"
8 ]
9
10 [tool.coverage.run]
11 branch = true
12 parallel = true
13 source = [
14 "xrayutilities"
15 ]
16
17 [tool.tox]
18 legacy_tox_ini = """
19 [tox]
20 envlist = py{36,37,38,39},coverage
21 distshare = {toxinidir}/dist
22
23 [testenv]
24 wheel = true
25 allowlist_externals =
26 mv
27 deps =
28 h5py
29 lmfit
30 matplotlib
31 numpy
32 scipy
33 pytest
34 pytest-cov
35 coverage[toml]
36 commands =
37 pytest --cov --cov-config pyproject.toml --junitxml=.tox/junit.{envname}.xml --cov-report=xml:.tox/coverage.xml
38 mv .coverage .tox/.coverage.{envname}
39
40 [testenv:coverage]
41 commands =
42 coverage combine .tox/
43 coverage xml -i -o .tox/coverage.xml
44 coverage report -i
45 mv .coverage .tox/
46 """
184184 "Development Status :: 5 - Production/Stable",
185185 "License :: OSI Approved :: GNU General Public License v2 or later "
186186 "(GPLv2+)"
187 ],
187 ],
188188 long_description=long_description,
189189 long_description_content_type="text/markdown",
190190 author_email="eugen.wintersberger@desy.de, dominik.kriegner@gmail.com",
195195 package_data={
196196 "xrayutilities": ["VERSION", "*.conf"],
197197 "xrayutilities.materials": [os.path.join("data", "*")]
198 },
198 },
199199 python_requires='~=3.6',
200200 setup_requires=['numpy', 'scipy', 'h5py'],
201201 install_requires=['numpy>=1.9.2', 'scipy>=0.13.0', 'h5py'],
202202 extras_require={
203203 'plot': ["matplotlib>=3.1.0"],
204204 'fit': ["lmfit>=1.0.1"],
205 },
205 },
206206 include_dirs=[numpy.get_include()],
207207 ext_modules=[extmodul],
208208 cmdclass=cmdclass,
209209 url="https://xrayutilities.sourceforge.io",
210210 license="GPLv2",
211211 script_args=args
212 )
212 )
1313 * You should have received a copy of the GNU General Public License
1414 * along with this program; if not, see <http://www.gnu.org/licenses/>.
1515 *
16 * Copyright (C) 2010-2016 Dominik Kriegner <dominik.kriegner@gmail.com>
16 * Copyright (C) 2010-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1717 */
1818
1919 /* ######################################
131131 }
132132 }
133133
134 INLINE void tensorprod(double *RESTRICT v1, double *RESTRICT v2,
134 INLINE void tensorprod(double *v1, double *v2,
135135 double *RESTRICT m) {
136136 unsigned int i, j;
137137 for (i = 0; i < 3; i = i + 1) {
1313 * You should have received a copy of the GNU General Public License
1414 * along with this program; if not, see <http://www.gnu.org/licenses/>.
1515 *
16 * Copyright (C) 2013-2016 Dominik Kriegner <dominik.kriegner@gmail.com>
16 * Copyright (C) 2013-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1717 */
1818 #pragma once
1919
6363 INLINE void matvec(double *RESTRICT m, double *RESTRICT v,
6464 double *RESTRICT r);
6565
66 INLINE void tensorprod(double *RESTRICT v1, double *RESTRICT v2,
66 INLINE void tensorprod(double *v1, double *v2,
6767 double *RESTRICT m);
6868
6969 INLINE void summat(double *RESTRICT m1, double *RESTRICT m2);
+0
-17
tests/__init__.py less more
0 # This file is part of xrayutilities.
1 #
2 # xrayutilities is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License as published by
4 # the Free Software Foundation; either version 2 of the License, or
5 # (at your option) any later version.
6 #
7 # This program is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 # GNU General Public License for more details.
11 #
12 # You should have received a copy of the GNU General Public License
13 # along with this program; if not, see <http://www.gnu.org/licenses/>.
14 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
16 # 2016 Eugen Wintersberger <eugen.wintersberger@desy.de>
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2012-2016 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2018 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2018-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import math
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2019 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2019-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os
1818 import subprocess
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014-2018 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2017 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015,2018 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import tempfile
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2019 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2019-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import math
1818 import os.path
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015-2019 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2017-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import math
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2017 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os.path
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2018-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2012-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os
1818 import tempfile
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import math
1818 import os
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2020 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2012-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2012-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2019 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2012-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2016-2017 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2016-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import math
1818 import unittest
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014-2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014-2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014-2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2013-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2014 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2014-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2019 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2019-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2019 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2019-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
16 #
17
1618
1719 import unittest
1820
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2017 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2017-2021 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import os
1818 import unittest
139139
140140
141141 if __name__ == '__main__':
142 freeze_support()
142 freeze_support() # required for MS Windows
143143 unittest.main()
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2018 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2018-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2019 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2019-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818
1212 # You should have received a copy of the GNU General Public License
1313 # along with this program; if not, see <http://www.gnu.org/licenses/>.
1414 #
15 # Copyright (C) 2015 Dominik Kriegner <dominik.kriegner@gmail.com>
15 # Copyright (C) 2015-2020 Dominik Kriegner <dominik.kriegner@gmail.com>
1616
1717 import unittest
1818