Imported Upstream version 1.0.3
Eugen Wintersberger
10 years ago
0 | v1.0.3, 2013-10-25 | |
1 | ||
2 | * build_doc target for setup.py to help build docs (thanks to F. Picca) | |
3 | * fix python setup.py --help | |
4 | * add PseudoVoigt function in 1D | |
5 | * add Lorentzian peak shape in addition to Gaussian in new function | |
6 | multPeakFit | |
7 | * some minor bug fixes | |
8 | ||
0 | 9 | v1.0.2, 2013-09-17 |
1 | 10 | |
2 | 11 | * add documentation source to tarball |
0 | 0 | Metadata-Version: 1.1 |
1 | 1 | Name: xrayutilities |
2 | Version: 1.0.2 | |
2 | Version: 1.0.3 | |
3 | 3 | Summary: package for x-ray diffraction data evaluation |
4 | 4 | Home-page: http://xrayutilities.sourceforge.net |
5 | 5 | Author: Dominik Kriegner |
163 | 163 | |
164 | 164 | in any web-browser, after the installation is finished. |
165 | 165 | |
166 | To build the PDF documentation from the sources use sphinx: | |
167 | ||
168 | sphinx-build -b latex doc/source doc/latex | |
169 | cd doc/latex; make | |
166 | To build the PDF documentation from the docu-sources use: | |
167 | ||
168 | python setup.py build_doc -b latex | |
169 | cd build/sphinx/latex; make | |
170 | 170 | |
171 | or generate a texinfo file using | |
172 | ||
173 | sphinx-build -b texinfo doc/source doc/texinfo | |
174 | cd doc/texinfo; make | |
171 | You will need sphinx and pdflatex including latex-recommended, latex-extra | |
172 | and fonts-recommended. | |
173 | ||
174 | Or generate a texinfo file using | |
175 | ||
176 | python setup.py build_doc -b texinfo | |
177 | cd build/sphinx/texinfo; make | |
175 | 178 | |
176 | 179 | |
177 | 180 | PACKAGING |
155 | 155 | |
156 | 156 | in any web-browser, after the installation is finished. |
157 | 157 | |
158 | To build the PDF documentation from the sources use sphinx: | |
158 | To build the PDF documentation from the docu-sources use: | |
159 | 159 | |
160 | sphinx-build -b latex doc/source doc/latex | |
161 | cd doc/latex; make | |
160 | python setup.py build_doc -b latex | |
161 | cd build/sphinx/latex; make | |
162 | 162 | |
163 | or generate a texinfo file using | |
163 | You will need sphinx and pdflatex including latex-recommended, latex-extra | |
164 | and fonts-recommended. | |
164 | 165 | |
165 | sphinx-build -b texinfo doc/source doc/texinfo | |
166 | cd doc/texinfo; make | |
166 | Or generate a texinfo file using | |
167 | ||
168 | python setup.py build_doc -b texinfo | |
169 | cd build/sphinx/texinfo; make | |
167 | 170 | |
168 | 171 | |
169 | 172 | PACKAGING |
49 | 49 | # The short X.Y version. |
50 | 50 | version = '1.0' |
51 | 51 | # The full version, including alpha/beta/rc tags. |
52 | release = '1.0.2' | |
52 | release = '1.0.3' | |
53 | 53 | |
54 | 54 | # The language for content autogenerated by Sphinx. Refer to documentation |
55 | 55 | # for a list of supported languages. |
380 | 380 | :linenos: |
381 | 381 | :language: python |
382 | 382 | |
383 | A possible output of this script could be | |
384 | ||
385 | .. code-block:: python | |
386 | ||
387 | fitted parameters: epsilon: 8.0712e-08 (2,['Parameter convergence']) | |
388 | param: (cch1,cch2,pwidth1,pwidth2,tiltazimuth,tilt,detrot,outerangle_offset) | |
389 | param: 140.07 998.34 4.4545e-05 4.4996e-05 72.0 1.97 -0.792 -1.543 | |
390 | please check the resulting data (consider setting plot=True) | |
391 | detector rotation axis / primary beam direction (given by user): ['z+', 'y-'] / x+ | |
392 | detector pixel directions / distance: z- y+ / 1 | |
393 | detector initialization with: init_area('z-','y+',cch1=140.07,cch2=998.34,Nch1=516,Nch2=516, pwidth1=4.4545e-05,pwidth2=4.4996e-05,distance=1.,detrot=-0.792,tiltazimuth=72.0,tilt=1.543) | |
394 | AND ALWAYS USE an (additional) OFFSET of -1.9741deg in the OUTER DETECTOR ANGLE! | |
395 | ||
396 | ||
397 | The output gives the fitted detector parameters and compiles the python code line one needs to use to initialize the detector. | |
398 | Important to note is that the outer angle offset which was determined by the fit (-1.9741 degree in the aboves example) is not included in the initialization of the detector parameters BUT needs to be used in every call to the q-conversion function as offset. | |
399 | This step needs to be performed manually by the user! | |
400 | ||
383 | 401 | Area detector (Variant 2) |
384 | 402 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
385 | 403 |
31 | 31 | |
32 | 32 | print("angles: 0,0,0,90") |
33 | 33 | (qx,qy,qz) = qconv(0,0,0,90) |
34 | print("Q= %6.3f %6.3f %6.3f (Abs: %6.3f)" %(qx[0],qy[0],qz[0],numpy.linalg.norm((qx,qy,qz)))) | |
34 | print("Q= %6.3f %6.3f %6.3f (Abs: %6.3f)" %(qx,qy,qz,numpy.linalg.norm((qx,qy,qz)))) | |
35 | 35 | |
36 | 36 | print("angles: 90,0,0,90") |
37 | 37 | (qx,qy,qz) = qconv(90,0,0,90) |
38 | print("Q= %6.3f %6.3f %6.3f (Abs: %6.3f)" %(qx[0],qy[0],qz[0],numpy.linalg.norm((qx,qy,qz)))) | |
38 | print("Q= %6.3f %6.3f %6.3f (Abs: %6.3f)" %(qx,qy,qz,numpy.linalg.norm((qx,qy,qz)))) | |
39 | 39 | |
40 | 40 | print("angles: 0,90,0,90") |
41 | 41 | (qx,qy,qz) = qconv(0,90,0,90) |
42 | print("Q= %6.3f %6.3f %6.3f (Abs: %6.3f)" %(qx[0],qy[0],qz[0],numpy.linalg.norm((qx,qy,qz)))) | |
42 | print("Q= %6.3f %6.3f %6.3f (Abs: %6.3f)" %(qx,qy,qz,numpy.linalg.norm((qx,qy,qz)))) | |
43 | 43 |
20 | 20 | from distutils.fancy_getopt import FancyGetopt |
21 | 21 | import os.path |
22 | 22 | import numpy |
23 | import sys | |
23 | 24 | |
24 | 25 | cliopts = [] |
25 | 26 | cliopts.append(("without-openmp",None,"build without OpenMP support")) |
26 | 27 | |
27 | 28 | options = FancyGetopt(option_table = cliopts) |
28 | args,opts = options.getopt() | |
29 | ||
30 | #first read all the arguments passed to the script | |
31 | #we need to do this otherwise the --help commands would not work | |
32 | args = sys.argv[1:] | |
33 | try: | |
34 | #search the arguments for options we would like to use | |
35 | #get new args with the custom options stripped away | |
36 | args,opts = options.getopt(args) | |
37 | except: | |
38 | pass | |
29 | 39 | |
30 | 40 | #set default flags |
31 | 41 | without_openmp = False |
63 | 73 | e.extra_link_args = lopt[ c ] |
64 | 74 | build_ext.build_extensions(self) |
65 | 75 | |
76 | cmdclass = {'build_ext': build_ext_subclass} | |
77 | ||
66 | 78 | with open('README.txt') as f: |
67 | 79 | long_description = f.read() |
68 | 80 | |
75 | 87 | os.path.join('xrayutilities','src','gridder3d.c')], |
76 | 88 | define_macros = user_macros) |
77 | 89 | |
90 | try: | |
91 | import sphinx | |
92 | from sphinx.setup_command import BuildDoc | |
93 | ||
94 | class build_doc(BuildDoc): | |
95 | def run(self): | |
96 | # make sure the python path is pointing to the newly built | |
97 | # code so that the documentation is built on this and not a | |
98 | # previously installed version | |
99 | build = self.get_finalized_command('build') | |
100 | sys.path.insert(0, os.path.abspath(build.build_lib)) | |
101 | try: | |
102 | sphinx.setup_command.BuildDoc.run(self) | |
103 | except UnicodeDecodeError: | |
104 | print("ERROR: unable to build documentation" | |
105 | " because Sphinx do not handle" | |
106 | " source path with non-ASCII characters. Please" | |
107 | " try to move the source package to another" | |
108 | " location (path with *only* ASCII characters)") | |
109 | sys.path.pop(0) | |
110 | ||
111 | cmdclass['build_doc'] = build_doc | |
112 | except ImportError: | |
113 | pass | |
114 | ||
78 | 115 | setup(name="xrayutilities", |
79 | version="1.0.2", | |
116 | version="1.0.3", | |
80 | 117 | author="Eugen Wintersberger, Dominik Kriegner", |
81 | 118 | description="package for x-ray diffraction data evaluation", |
82 | 119 | classifiers=["Topic :: Scientific/Engineering :: Physics", |
95 | 132 | requires=['numpy','scipy','matplotlib','tables'], |
96 | 133 | include_dirs = [numpy.get_include()], |
97 | 134 | ext_modules = [extmodul], |
98 | cmdclass = {'build_ext': build_ext_subclass }, | |
135 | cmdclass = cmdclass, | |
99 | 136 | url="http://xrayutilities.sourceforge.net", |
100 | 137 | license="GPLv2", |
101 | 138 | script_args = args |
18 | 18 | |
19 | 19 | from .. import config |
20 | 20 | from .. import experiment |
21 | from .. import gridder as xugridder | |
21 | from .. import gridder3d as xugridder | |
22 | 22 | |
23 | 23 | def getindex3d(x,y,z,xgrid,ygrid,zgrid): |
24 | 24 | """ |
1774 | 1774 | else: |
1775 | 1775 | [qx,qy,qz] = exphxrd.Ang2Q(om,tt) |
1776 | 1776 | [qxsub,qysub,qzsub] = exphxrd.Ang2Q(omalign,ttalign) |
1777 | params = [qysub[0],qzsub[0],0.001,0.001,psd.max(),0,0.] | |
1778 | params,covariance = math.fit_peak2d(qy.flatten(),qz.flatten(),psd.flatten(),params,[qysub[0]-frange[0],qysub[0]+frange[0],qzsub[0]-frange[1],qzsub[0]+frange[1]],math.Gauss2d,maxfev=10000) | |
1777 | params = [qysub,qzsub,0.001,0.001,psd.max(),0,0.] | |
1778 | params,covariance = math.fit_peak2d(qy.flatten(),qz.flatten(),psd.flatten(),params,[qysub-frange[0],qysub+frange[0],qzsub-frange[1],qzsub+frange[1]],math.Gauss2d,maxfev=10000) | |
1779 | 1779 | # correct params |
1780 | 1780 | params[6] = params[6]%(numpy.pi) |
1781 | 1781 | if params[5]<0 : params[5] = 0 |
1786 | 1786 | |
1787 | 1787 | if plot: |
1788 | 1788 | plt.figure(); plt.clf() |
1789 | from .. import gridder | |
1789 | from ..gridder2d import Gridder2D | |
1790 | 1790 | from .. import utilities |
1791 | gridder = gridder.Gridder2D(400,400) | |
1791 | gridder = Gridder2D(400,400) | |
1792 | 1792 | gridder(qy,qz,psd) |
1793 | 1793 | # calculate intensity which should be plotted |
1794 | 1794 | INT = utilities.maplog(gridder.gdata.transpose(),4,0) |
1125 | 1125 | raise Exception("unknown keyword argument given: allowed are 'B': orthonormalization matrix, 'U': orientation matrix, 'mat': material object, 'dettype': string with detector type") |
1126 | 1126 | |
1127 | 1127 | if "B" in kwargs: |
1128 | B = numpy.array(B) | |
1128 | B = numpy.array(kwargs['B']) | |
1129 | 1129 | kwargs.pop("B") |
1130 | 1130 | elif "mat" in kwargs: |
1131 | 1131 | mat = kwargs['mat'] |
1135 | 1135 | B = numpy.identity(3) |
1136 | 1136 | |
1137 | 1137 | if "U" in kwargs: |
1138 | U = numpy.array(U) | |
1138 | U = numpy.array(kwargs['U']) | |
1139 | 1139 | kwargs.pop("U") |
1140 | 1140 | else: |
1141 | 1141 | U = self._transform.matrix |
42 | 42 | from .functions import Gauss3d |
43 | 43 | from .functions import TwoGauss2d |
44 | 44 | from .functions import Lorentz1d |
45 | from .functions import Lorentz1d_der_x | |
46 | from .functions import Lorentz1d_der_p | |
45 | 47 | from .functions import Lorentz2d |
48 | from .functions import PseudoVoigt1d | |
46 | 49 | |
47 | 50 | from .fit import fit_peak2d |
48 | 51 | from .fit import gauss_fit |
52 | from .fit import multPeakFit | |
53 | from .fit import multPeakPlot | |
49 | 54 | from .fit import multGaussFit |
50 | 55 | from .fit import multGaussPlot |
28 | 28 | |
29 | 29 | from .. import config |
30 | 30 | from .functions import Gauss1d,Gauss1d_der_x,Gauss1d_der_p |
31 | from .functions import Lorentz1d,Lorentz1d_der_x,Lorentz1d_der_p | |
31 | 32 | |
32 | 33 | try: |
33 | 34 | from matplotlib import pyplot as plt |
83 | 84 | # use least-square fit |
84 | 85 | myodr.set_job(fit_type=2) |
85 | 86 | |
86 | # # DK comment out because this command triggers a synthax error with new scipy version 2013/5/7 | |
87 | # # DK commented out because this command triggers a synthax error with new scipy version 2013/5/7 | |
87 | 88 | # if config.VERBOSITY >= config.DEBUG: |
88 | 89 | # myodr.set_iprint(final=1) |
89 | 90 | |
156 | 157 | return p,pcov |
157 | 158 | |
158 | 159 | |
159 | def multGaussFit(x,data,peakpos,peakwidth,dranges=None): | |
160 | """ | |
161 | function to fit multiple Gaussian peaks with linear background to a set of data | |
160 | def multGaussFit(*args,**kwargs): | |
161 | """ | |
162 | convenience function to keep API stable | |
163 | see multPeakFit for documentation | |
164 | """ | |
165 | kwargs['peaktype']='Gaussian' | |
166 | return multPeakFit(*args,**kwargs) | |
167 | ||
168 | def multPeakFit(x,data,peakpos,peakwidth,dranges=None,peaktype='Gaussian'): | |
169 | """ | |
170 | function to fit multiple Gaussian/Lorentzian peaks with linear background to a set of data | |
162 | 171 | |
163 | 172 | Parameters |
164 | 173 | ---------- |
168 | 177 | peakwidth: initial values for the peak width |
169 | 178 | dranges: list of tuples with (min,max) value of the data ranges to use. |
170 | 179 | does not need to have the same number of entries as peakpos |
180 | peaktype: type of peaks to be used: can be either 'Gaussian' or 'Lorentzian' | |
171 | 181 | |
172 | 182 | Returns |
173 | 183 | ------- |
178 | 188 | amp: list of amplitudes of the peaks derived by the fit |
179 | 189 | background: array of background values at positions x |
180 | 190 | """ |
191 | if peaktype=='Gaussian': | |
192 | pfunc = Gauss1d | |
193 | pfunc_derx = Gauss1d_der_x | |
194 | elif peaktype=='Lorentzian': | |
195 | pfunc = Lorentz1d | |
196 | pfunc_derx = Lorentz1d_der_x | |
197 | else: | |
198 | raise ValueError('wrong value for parameter peaktype was given') | |
199 | ||
181 | 200 | def deriv_x(p, x): |
182 | 201 | """ |
183 | 202 | function to calculate the derivative of the signal of multiple peaks and background w.r.t. the x-coordinate |
190 | 209 | |
191 | 210 | # sum up peak functions contributions |
192 | 211 | for i in range(len(p)//3): |
193 | ldx = Gauss1d_der_x(x,p[3*i],p[3*i+1],p[3*i+2],0) | |
212 | ldx = pfunc_derx(x,p[3*i],p[3*i+1],p[3*i+2],0) | |
194 | 213 | derx += ldx |
195 | 214 | |
196 | 215 | # background contribution |
214 | 233 | # peak functions contributions |
215 | 234 | for i in range(len(p)//3): |
216 | 235 | lp = (p[3*i],p[3*i+1],p[3*i+2],0) |
217 | derp = numpy.append(derp,-2*(lp[0]-x)*Gauss1d(x,*lp)) | |
218 | derp = numpy.append(derp,(lp[0]-x)**2/(2*lp[1]**3)*Gauss1d(x,*lp)) | |
219 | derp = numpy.append(derp,Gauss1d(x,*lp)/lp[2]) | |
220 | ||
236 | if peaktype == 'Gaussian': | |
237 | derp = numpy.append(derp,-2*(lp[0]-x)*pfunc(x,*lp)) | |
238 | derp = numpy.append(derp,(lp[0]-x)**2/(2*lp[1]**3)*pfunc(x,*lp)) | |
239 | derp = numpy.append(derp,pfunc(x,*lp)/lp[2]) | |
240 | else: # Lorentzian | |
241 | derp = numpy.append(derp,4*(x-lp[0])* lp[2]/lp[1]/(1+(2*(x-lp[0])/lp[1])**2)**2) | |
242 | derp = numpy.append(derp,4*(lp[0]-x)* lp[2]/lp[1]**2/(1+(2*(x-lp[0])/lp[1])**2)**2) | |
243 | derp = numpy.append(derp,1/(1+(2*(x-p[0])/p[1])**2)) | |
244 | ||
221 | 245 | # background contributions |
222 | 246 | derp = numpy.append(derp,x) |
223 | 247 | derp = numpy.append(derp,numpy.ones(x.size)) |
238 | 262 | |
239 | 263 | # sum up peak functions |
240 | 264 | for i in range(len(p)//3): |
241 | lf = Gauss1d(x,p[3*i],p[3*i+1],p[3*i+2],0) | |
265 | lf = pfunc(x,p[3*i],p[3*i+1],p[3*i+2],0) | |
242 | 266 | f += lf |
243 | 267 | |
244 | 268 | # background |
290 | 314 | fit = my_odr.run() |
291 | 315 | |
292 | 316 | if(config.VERBOSITY >= config.DEBUG): |
293 | print("XU.math.multGaussFit: fitted parameters") | |
317 | print("XU.math.multPeakFit: fitted parameters") | |
294 | 318 | print(fit.beta) |
295 | 319 | try: |
296 | 320 | if fit.stopreason[0] not in ['Sum of squares convergence']: |
297 | print("XU.math.multGaussFit: fit NOT converged (%s)" %fit.stopreason[0]) | |
321 | print("XU.math.multPeakFit: fit NOT converged (%s)" %fit.stopreason[0]) | |
298 | 322 | return None,None,None,None |
299 | 323 | except: |
300 | print("XU.math.multGaussFit: fit most probably NOT converged (%s)" %str(fit.stopreason)) | |
324 | print("XU.math.multPeakFit: fit most probably NOT converged (%s)" %str(fit.stopreason)) | |
301 | 325 | return None,None,None,None |
302 | 326 | # prepare return values |
303 | 327 | fpos = fit.beta[:-2:3] |
307 | 331 | |
308 | 332 | return fpos,fwidth,famp,background |
309 | 333 | |
310 | def multGaussPlot(x,fpos,fwidth,famp,background,dranges=None,fig="xu_plot",fact=1.): | |
311 | """ | |
312 | function to plot multiple Gaussian peaks with linear background | |
334 | ||
335 | def multGaussPlot(*args,**kwargs): | |
336 | """ | |
337 | convenience function to keep API stable | |
338 | see multPeakPlot for documentation | |
339 | """ | |
340 | kwargs['peaktype']='Gaussian' | |
341 | return multPeakPlot(*args,**kwargs) | |
342 | ||
343 | def multPeakPlot(x,fpos,fwidth,famp,background,dranges=None,peaktype='Gaussian',fig="xu_plot",fact=1.): | |
344 | """ | |
345 | function to plot multiple Gaussian/Lorentz peaks with background values given by an array | |
313 | 346 | |
314 | 347 | Parameters |
315 | 348 | ---------- |
320 | 353 | background: array with background values |
321 | 354 | dranges: list of tuples with (min,max) value of the data ranges to use. |
322 | 355 | does not need to have the same number of entries as fpos |
356 | peaktype: type of peaks to be used: can be either 'Gaussian' or 'Lorentzian' | |
323 | 357 | fig: matplotlib figure number or name |
324 | 358 | fact: factor to use as multiplicator in the plot |
325 | 359 | """ |
326 | 360 | |
327 | 361 | try: plt.__name__ |
328 | 362 | except NameError: |
329 | print("XU.math.multGaussPlot: Warning: plot functionality not available") | |
363 | print("XU.math.multPeakPlot: Warning: plot functionality not available") | |
330 | 364 | return |
331 | 365 | |
332 | 366 | plt.figure(fig) |
345 | 379 | |
346 | 380 | f = numpy.zeros(lx.size) |
347 | 381 | for i in range(len(fpos)): |
348 | lf = Gauss1d(lx,fpos[i],fwidth[i],famp[i],0) | |
382 | if peaktype=='Gaussian': | |
383 | lf = Gauss1d(lx,fpos[i],fwidth[i],famp[i],0) | |
384 | elif peaktype=='Lorentzian': | |
385 | lf = Lorentz1d(lx,fpos[i],fwidth[i],famp[i],0) | |
386 | else: | |
387 | raise ValueError('wrong value for parameter peaktype was given') | |
349 | 388 | f += lf |
350 | 389 | plt.plot(lx,(lf+lb)*fact,'k:') |
351 | 390 |
110 | 110 | for parameter description see Gauss1d |
111 | 111 | """ |
112 | 112 | |
113 | return 2*(p[0]-x)*Gauss1d(x,*p) | |
113 | lp = numpy.copy(p) | |
114 | lp[3] = 0 | |
115 | return 2*(p[0]-x)*Gauss1d(x,*lp) | |
114 | 116 | |
115 | 117 | |
116 | 118 | def Gauss1d_der_p(x,*p): |
120 | 122 | |
121 | 123 | for parameter description see Gauss1d |
122 | 124 | """ |
123 | ||
124 | r = numpy.concatenate(( -2*(p[0]-x)*Gauss1d(x,*p),\ | |
125 | (p[0]-x)**2/(2*p[1]**3)*Gauss1d(x,*p),\ | |
126 | Gauss1d(x,*p)/p[2],\ | |
125 | lp = numpy.copy(p) | |
126 | lp[3] = 0 | |
127 | r = numpy.concatenate(( -2*(p[0]-x)*Gauss1d(x,*lp),\ | |
128 | (p[0]-x)**2/(2*p[1]**3)*Gauss1d(x,*lp),\ | |
129 | Gauss1d(x,*lp)/p[2],\ | |
127 | 130 | numpy.ones(x.shape,dtype=numpy.float) )) |
128 | 131 | r.shape = (4,) + x.shape |
129 | 132 | |
224 | 227 | |
225 | 228 | return g |
226 | 229 | |
230 | def Lorentz1d_der_x(x,*p): | |
231 | """ | |
232 | function to calculate the derivative of a Gaussian with respect to x | |
233 | ||
234 | for parameter description see Lorentz1d | |
235 | """ | |
236 | ||
237 | return 4*(p[0]-x)* p[2]/p[1]/(1+(2*(x-p[0])/p[1])**2)**2 | |
238 | ||
239 | def Lorentz1d_der_p(x,*p): | |
240 | """ | |
241 | function to calculate the derivative of a Gaussian with respect the | |
242 | parameters p | |
243 | ||
244 | for parameter description see Lorentz1d | |
245 | """ | |
246 | ||
247 | r = numpy.concatenate(( 4*(x-p[0])* p[2]/p[1]/(1+(2*(x-p[0])/p[1])**2)**2,\ | |
248 | 4*(p[0]-x)* p[2]/p[1]**2/(1+(2*(x-p[0])/p[1])**2)**2,\ | |
249 | 1/(1+(2*(x-p[0])/p[1])**2),\ | |
250 | numpy.ones(x.shape,dtype=numpy.float) )) | |
251 | r.shape = (4,) + x.shape | |
252 | ||
253 | return r | |
254 | ||
227 | 255 | def Lorentz2d(x,y,*p): |
228 | 256 | """ |
229 | 257 | function to calculate a general two dimensional Lorentzian |
248 | 276 | |
249 | 277 | g = p[5]+p[4]/(1+(2*(rcen_x-xp)/p[2])**2+(2*(rcen_y-yp)/p[3])**2) |
250 | 278 | return g |
279 | ||
280 | ||
281 | def PseudoVoigt1d(x,*p): | |
282 | """ | |
283 | function to calculate a pseudo Voigt function as linear combination of a Gauss and Lorentz peak | |
284 | ||
285 | Parameters | |
286 | ---------- | |
287 | p: list of parameters of the Lorentz-function | |
288 | [XCEN,FWHM,AMP,BACKGROUND,ETA] | |
289 | ETA: 0 ...1 0 means pure Gauss and 1 means pure Lorentz | |
290 | x,y: coordinate(s) where the function should be evaluated | |
291 | ||
292 | Returns | |
293 | ------- | |
294 | the value of the PseudoVoigt described by the parameters p | |
295 | at position (x,y) | |
296 | ||
297 | """ | |
298 | ||
299 | f = p[3]+p[2] * ( p[4]*(1/(1+(2*(x-p[0])/(p[1]/2.))**2)) + (1-p[4])*numpy.exp(-numpy.log(2)*((p[0]-x)/(p[1]/2.))**2) ) | |
300 | ||
301 | return f | |
251 | 302 | |
252 | 303 | |
253 | 304 | def Debye1(x): |
Binary diff not shown