Installation
This package requires xraylib and compwizard. On Windows, xraylib can be installed through the Anaconda interface.
conda install -c conda-forge xraylib=4.0.0
pip instal compwizard
For further information on how to install xraylib on other operational systems, check xraylib wiki.
This module can be installed with:
pip install xfit
Usage
This module provides the "Spectrum" class. It is possible to initialize this class with a numpy nd.array or loading an *.mca or *.spt file, by giving the path.
For the continuum estimation algorithm, refer to the Continuum.py file.
Test.py file provides a common *.mca file to use with the example.py script provided.
Example 1
import xfit
import numpy as np
import matplotlib.pyplot as plt
path = r"./test.mca"
pool_file = r"./pool.txt"
Spec = xfit.Spectrum(file_path=path)
Spec.calibrate() #if no arguments are passed, it gets the parameters from the mca or spt header
Spec.estimate_continuum(30, 11, 11, 3) #iterations, filter window, sav-gol window, sav-gol order
Spec.fit_fano_and_noise()
Spec.create_pool(pool_file)
Spec.fit()
#Plot ------
fig, ax = plt.subplots()
ax.plot(Spec.energyaxis, Spec.data, color="black", label="Data")
ax.plot(Spec.energyaxis, Spec.continuum, color="green", label="Continuum")
for element in Spec.areas.keys():
ax.plot(Spec.energyaxis,
Spec.plots[element],
label=element+" fit result",
color=ElementColors[element],
linestyle="--")
ax.legend(loc=1, fancybox=1)
ax.set_yscale("log")
plt.show()
0.11400000005960464 80.00951851146041 (Fano and Noise values found, respectively)
Example 2
import xfit
import numpy as np
ydata = np.arange(1024)
fit_pool = {}
fit_pool["elements"] = {}
fit_pool["elements"]["Cu"] = ["KA1","KA2","KB1","KB3"]
fit_pool["bg"] = 1 #Forces the use of continuum estimation for the fit
Spec = xfit.Spectrum(array=ydata)
Spec.calibrate(x=channels, y=energies)
Spec.estimate_continuum(30, 11, 11, 3)
Spec.fit_fano_and_noise()
Spec.pool = fit_pool
Spec.fit()
#or simply: Spec.fit(pool=fit_pool)
#Plot ------
fig, ax = plt.subplots()
ax.plot(Spec.energyaxis, Spec.data, color="black", label="Data")
ax.plot(Spec.energyaxis, Spec.continuum, color="green", label="Continuum")
for element in Spec.areas.keys():
ax.plot(Spec.energyaxis,
Spec.plots[element],
label=element+" fit result",
color=ElementColors[element],
linestyle="--")
ax.legend(loc=1, fancybox=1)
ax.set_yscale("log")
plt.show()
Metadata
Release files for xfit 0.1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| xfit-0.1.1.0.tar.gz | 12.1 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xfit-0.1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 24.7 kB
Release files / xfit-0.1.1.0.tar.gz
| Download URL | xfit-0.1.1.0.tar.gz |
|---|---|
| Size | 12.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
00e7f067ff001b658456953f2874b6ab1b3fdf97f6da4909d00a7ff8e418f96b
|
|
BLAKE2b-256 checksum How to use checksums |
87aaf48930b8da2f79ba83b1c36e060c84ef035ea1b8e01d5ebb95a9c8aea1c8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/54.1.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
|
Release files / xfit-0.1.1.0-py3-none-any.whl
| Download URL | xfit-0.1.1.0-py3-none-any.whl |
|---|---|
| Size | 12.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f1e7fea44ce729969e2d1cb0917351888ede5c184f595c03ed3b3dedcc821788
|
|
BLAKE2b-256 checksum How to use checksums |
8d73858e746ff5be46899d0fd603201b5145de60914c3298b7f60f002f2812fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.7.0 requests/2.23.0 setuptools/54.1.2 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
|
Security for xfit 0.1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.