🔬 xaspy - framework for X-ray absorption spectroscopy
🚧🚧🚧 (always) under construction, developing parallel to my PhD journey 🚧🚧🚧
This small python module wants to help with X-ray absorption spectroscopy analysis and pre-evaluation during beam times. Similar software and strongly inspired by (but mostly for EXAFS): larch. Strong focus on X-ray magnetic circular dichroism XMCD.
toc of readme
💻 installation
xaspy can be installed via PyPi or downloaded here from github as the source code.
The necessary requirements can be found in requirement.txt file. Install via pip:
pip install xaspy
Update to the newest version with:
pip install xaspy -U
🤖 telegram bot
As a small side project I coded a small telegram bot (see folder bot_src). The telegram bot can be added via link to you contacts: t.me/xaspy_bot or writing to @xaspy_bot. The first implementation is returning the X-ray absorption edges for your specific elements. The backend is provided by XrayDB.
🔬 XAS
XMCD
The function XMCD merges and interpolates the spectra for same spin angular momentum of the photon. Correlates the curves on top of each other and builds the XMCD and XAS signal. After that subtraction of different backgrounds is possible (linear, stepfunctions, ...). Also different normalization factors are possible.
hysteresis loops
For multiple hysteresis curves in one file use class mHYST with included functions. Use plot_separated() to plot multiple hysteresis loops separated. Function average_loops() takes the loop numbers and averages them.
backgrounds
the xaspy.xas.backgrounds module provides multiple possible backgrounds to correct the measured data.
⬇️ import data
beam lines
Different read in functions for special beamlines: e.g. VEKMAG/PM3 at BESSY II in Berlin.
SPECS files
Large SPECS files usually contain multiple runs in one large ASCII file. A very useful SPECS file splitter (split.py) can be found in folder utils. For usage see the docstring in the file header.
Mössbauer
First functions for the implementation of the Pi program for Mössbauer analysis. readin.PiMoss('path/filename') can no be used to import plotting data from the .dat-files generated from Pi. Different implemented plotting funtions can be called from the class.
I would recommend using the following saving procedures:
| extension | content |
|---|---|
| filename.mos | raw data from measurement |
| filename.mos.rtf | fitting information important for Pi |
| filename.dat | exported ascii data table |
import of theoretical calculations
Reading functions for output files for programs like FEFF, multiX, xraylarch, quanty ...
despiking of data
This function is to remove spikes from data while loading the data into the RAM. It does not change the raw data. This function creates '.spike' file with list of columns to avoid, which will automatically be dropped while reading data in via a pandas df. Please use a basic read in function as follows:
#function for read in a is number of scan
def rd(a,raw=False):
path = '../path/to/'
file = path + 'file'
a = a
dff = pd.read_csv(path+'file_{0:03}'.format(a), delim_whitespace=True,skiprows=[1]) # example readin
if raw==False:
try:
with open(file+'.spike','rb') as f:
b = pickle.load(f)
if a in b:
todrop = b[a]
dff = dff.drop(todrop) #returns cleaned pandas file if .spike is existent and has an entry for scan number
except:
pass
else:
pass
return dff #returns pandas file
Alternatively you can also load the raw or spiked data with:
rd(nr, raw=True)
next steps (maybe/hopefully)
- write (better) docs
- improve telegram bot
- continous integration and testing
- Total Electron Yield measurement correction
- Luminescence 2nd order correction
- improve fast despiking
- fit convolution and energy shift between theoretic and measured spectrum
- working with .rtf-files for Mössbauer spectra from Pi
- write unittests
- plot Mössbauer spectra from Pi
- fast and basic XMCD evaluation
- added telegram bot
Metadata
Release files for xaspy 0.3.9
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 | |
|---|---|---|---|---|
| xaspy-0.3.9.tar.gz | 21.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| xaspy-0.3.9-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 43.5 kB
Release files / xaspy-0.3.9.tar.gz
| Download URL | xaspy-0.3.9.tar.gz |
|---|---|
| Size | 21.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
190e1c89a328c1ccaa41816cb9a451993062da94bba8bc184785715f02b20336
|
|
BLAKE2b-256 checksum How to use checksums |
d9db653a5e563dcf2a0289e88d9a1da9a034f0e6f716023d2b9395bffc2fba9c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.0
|
Release files / xaspy-0.3.9-py3-none-any.whl
| Download URL | xaspy-0.3.9-py3-none-any.whl |
|---|---|
| Size | 22.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cdcb61976c730a1163b13cc9a6c6b06963d03300309f9c65f88756d1ae5f3d65
|
|
BLAKE2b-256 checksum How to use checksums |
a2495dae45492a68ea2032b69b8de76c8c2a09883c1ddc7876ed96b61df3af59
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.0
|
Security for xaspy 0.3.9
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.