Skip to content

Kramers-Kronig transform for Python written in Rust

License

Notifications You must be signed in to change notification settings

Hayashi-Yudai/pykk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pykk

Downloads License PyPI version shields.io Test

Python library for calculating Kramers-Kronig transform written in Rust.

Requirements

  • Python >=3.9,< 3.13

Install

If you use Windows or Linux, you can install with pip command.

$ pip install pykk

If not, you can install Rust and build from the source.

build

If you want to build from source, you need maturin. I prepare virtual environment with poetry for building.

$ poetry install
$ poetry run maturin build --release

You can see .whl file in $PROJECT_ROOT/target/wheels. Install it by pip command.

How to use

This library has two functions for calculating Kramers-Kronig transform, the transformation from real to imaginary part and vice versa.

import pykk

energy = [1, 2, 3, 4]  # the values MUST have the same intervals
real = [1, 2, 3, 4]

imag = pykk.real2imag(energy, real)  # real -> imaginary part
real_kk = pykk.imag2real(energy, imag)  # imaginary -> real part

Performance

Compare the performance with the code implemented by Python. The length of the data is ~ 1000 data points.

Python 3.8 pykk
37 s 0.4 ms

License

This application contains artifacts distributed under the license of the Apache License, Version 2.0.