Welcome to qef’s documentation!¶
Contents:
qef¶
quasielastic fitting
- Free software: MIT license
- Documentation: https://qef.readthedocs.io.
Features¶
- TODO
Credits¶
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.
Installation¶
Stable release¶
To install qef, run this command in your terminal:
$ pip install qef
This is the preferred method to install qef, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources¶
The sources for qef can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/jmborr/qef
Or download the tarball:
$ curl -OL https://github.com/jmborr/qef/tarball/master
Once you have a copy of the source, you can install it with:
$ python setup.py install
Modules¶
Models¶
DeltaDiracModel¶
-
class
qef.models.deltadirac.
DeltaDiracModel
(independent_vars=['x'], prefix='', missing=None, name=None, **kwargs)[source]¶ Bases:
lmfit.model.Model
A function that is zero everywhere except for the x-value closest to the center parameter.
At value-closest-to-center, the model evaluates to the amplitude parameter divided by the x-spacing. This last division is necessary to preserve normalization with integrating the function over the X-axis
- Fitting parameters:
- integrated intensity
amplitude
\(A\) - position of the peak
center
\(E_0\)
- integrated intensity
-
qef.models.deltadirac.
delta_dirac
(x, amplitude=1.0, center=0.0)[source]¶ function is zero except for the x-value closest to center.
At value-closest-to-center, the function evaluates to the amplitude divided by the x-spacing.
Parameters: - x :class:`~numpy:numpy.ndarray` – domain of the function, energy
- amplitude (float) – Integrated intensity of the curve
- center (float) – position of the peak
Resolution models¶
-
class
qef.models.resolution.
TabulatedResolutionModel
(xs, ys, *args, **kwargs)[source]¶ Bases:
qef.models.tabulatedmodel.TabulatedModel
Interpolator of resolution data with no fit parameters
Parameters:
StretchedExponentialFTModel – Fourier transform of the stretched exponential¶
-
class
qef.models.strexpft.
StretchedExponentialFTModel
(independent_vars=['x'], prefix='', missing=None, name=None, **kwargs)[source]¶ Bases:
lmfit.model.Model
Fourier transform of the symmetrized stretched exponential
\[S(E) = A \int_{-\infty}^{\infty} dt/h e^{-i2\pi(E-E_0)t/h} e^{|\frac{x}{\tau}|^\beta}\]Normalization and maximum at \(E=E_0\):
\[\int_{-\infty}^{\infty} dE S(E) = A max(S) = A \frac{\tau}{\beta} \Gamma(\beta^{-1})\]Uses scipy.fftpack.fft for the Fourier transform
- Fitting parameters:
- integrated intensity
amplitude
\(A\) - position of the peak
center
\(E_0\) - nominal relaxation time
tau`
\(\tau\) - stretching exponent
beta
\(\beta\)
- integrated intensity
If the time unit is picoseconds, then the reciprocal energy unit is mili-eV
-
qef.models.strexpft.
strexpft
(x, amplitude=1.0, center=0.0, tau=10.0, beta=1.0)[source]¶ Fourier transform of the symmetrized stretched exponential
\[S(E) = A \int_{-\infty}^{\infty} dt/h e^{-i2\pi(E-E_0)t/h} e^{|\frac{x}{\tau}|^\beta}\]Normalization and maximum at \(E=E_0\):
\[\int_{-\infty}^{\infty} dE S(E) = A\]\[max(S) = A \frac{\tau}{\beta} \Gamma(\beta^{-1})\]Uses
fft()
for the Fourier transformParameters: - x (
ndarray
) – domain of the function, energy - amplitude (float) – Integrated intensity of the curve
- center (float) – position of the peak
- tau (float) – relaxation time.
- beta (float) – stretching exponent
- If the time units are picoseconds, then the energy units are mili-eV.
Returns: values – function over the domain
Return type: - x (
TabulatedModel – linear interpolator for a numerical table of intensity values¶
-
class
qef.models.tabulatedmodel.
TabulatedModel
(xs, ys, *args, **kwargs)[source]¶ Bases:
lmfit.model.Model
fitting the tabulated Model to some arbitrary points
Parameters:
TeixeiraWater – jump-diffusion model for water¶
-
class
qef.models.teixeira.
TeixeiraWaterModel
(independent_vars=['x'], q=0.0, prefix='', missing=None, name=None, **kwargs)[source]¶ Bases:
lmfit.model.Model
This fitting function models the dynamic structure factor for a particle undergoing jump diffusion.
- Teixeira, M.-C. Bellissent-Funel, S. H. Chen, and A. J. Dianoux. Phys. Rev. A, 31:1913-1917
\[S(Q,E) = \frac{A}{\pi} \cdot \frac{\Gamma}{\Gamma^2+(E-E_0)^2}\]\[\Gamma = \frac{\hbar\cdot D\cdot Q^2}{1+D\cdot Q^2\cdot \tau}\]\(\Gamma\) is the HWHM of the lorentzian curve.
At 298K and 1atm, water has \(D=2.30 10^{-5} cm^2/s\) and \(\tau=1.25 ps\).
A jump length \(l\) can be associated: \(l^2=2N\cdot D\cdot \tau\), where \(N\) is the dimensionality of the diffusion problem (\(N=3\) for diffusion in a volume).
- Fitting parameters:
- integrated intensity
amplitude
\(A\) - position of the peak
center
\(E_0\) - residence time
center
\(\tau\) - diffusion coefficient
dcf
\(D\)
- integrated intensity
- Attributes:
- Momentum transfer
q
- Momentum transfer
-
fwhm_expr
¶ Constraint expression for FWHM
-
guess
(y, x=None, **kwargs)[source]¶ Guess starting values for the parameters of a model.
Parameters: Returns: parameters with guessed values
Return type:
-
height_expr
¶ Constraint expression for maximum peak height.
Operators¶
Convolution operator¶
-
class
qef.operators.convolve.
Convolve
(resolution, model, **kws)[source]¶ Bases:
lmfit.model.CompositeModel
Convolution between model and resolution.
It is assumed that the resolution FWHM is energy independent. Non-symmetric energy ranges are allowed (when the range of negative values is different than that of positive values).
The convolution requires multiplication by the X-spacing to preserve normalization
-
qef.operators.convolve.
convolve
(model, resolution)[source]¶ Convolution of resolution with model data.
It is assumed that the resolution FWHM is energy independent. We multiply by spacing \(dx\) of independent variable \(x\).
\[(model \otimes resolution)[n] = dx * \sum_m model[m] * resolution[m-n]\]Parameters: - model (numpy.ndarray) – model data
- resolution (numpy.ndarray) – resolution data
Returns: Return type:
Contributing¶
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions¶
Report Bugs¶
Report bugs at https://github.com/jmborr/qef/issues.
If you are reporting a bug, please include:
- Your operating system name and version.
- Any details about your local setup that might be helpful in troubleshooting.
- Detailed steps to reproduce the bug.
Fix Bugs¶
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features¶
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation¶
qef could always use more documentation, whether as part of the official qef docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback¶
The best way to send feedback is to file an issue at https://github.com/jmborr/qef/issues.
If you are proposing a feature:
- Explain in detail how it would work.
- Keep the scope as narrow as possible, to make it easier to implement.
- Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!¶
Ready to contribute? Here’s how to set up qef for local development.
Fork the qef repo on GitHub.
Clone your fork locally:
$ git clone git@github.com:your_name_here/qef.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv qef $ cd qef/ $ python setup.py develop
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ flake8 qef tests $ python setup.py test or py.test $ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines¶
Before you submit a pull request, check that it meets these guidelines:
- The pull request should include tests.
- If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
- The pull request should work for Python 2.6, 2.7, 3.3, 3.4 and 3.5, and for PyPy. Check https://travis-ci.org/jmborr/qef/pull_requests and make sure that the tests pass for all supported Python versions.
Credits¶
Development Lead¶
- Jose Borreguero <borreguero@gmail.com>
Contributors¶
None yet. Why not be the first?