A Python toolkit providing physical constants, unit conversions, and plotting styles
Project description
Icon created by astroastra
Physkit - A Python toolkit for constants, unit conversions, and equations
Physkit is a Python library for performing scientific computations, unit conversions, and working with physical constants and equations.
It provides tools for astrophysical and physical calculations, supporting multiple unit systems and CLI functionalities.
This is mostly for my own personal use. I found it nice to have a no frills way to convert units and easily get constants in the units I need.
License
This project is licensed under the terms of the GNU General Public License v3.0.
See the LICENSE file for details.
Copyright (C) 2024 sapphimars
Third-Party Licenses
This project makes use of the following third-party libraries:
- Matplotlib - Licensed under the Matplotlib License Agreement. See licenses/LICENSE-MATPLOTLIB.txt or directly on their repository.
- Pint - Licensed under the BSD 3-Clause License. See licenses/LICENSE-PINT.txt or directly on their repository.
Note: Third-party libraries included in this project are licensed under their respective terms. See the licenses/ directory for full details.
Installation
Requirements
- Python 3.12 or higher
- Dependencies:
- Matplotlib >= 3.5
- Pint >= 0.20
Install via pip
pip install physkit
For Development
pdm install
To install test dependencies:
pdm install -G test
Usage Examples
Access Constants
import physkit as pk
from physkit.constants import constants as csts
print(csts.G) # Gravitational constant in SI
pk.set_default("cgs")
print(csts.G) # Gravitational constant in CGS
Unit Conversion
from physkit.conversions import convert_unit
result = convert_unit(1, 'm', 'cm')
print(result) # Outputs: 100.0
Equations
from physkit.equations import equations
# Default units are SI. Specify other units explicitly, like so:
mass = 1.0 # Solar mass
radius = equations.gravitational_radius(mass, 'M_sun', 'km') # input mass in solar masses
print(radius) # Gravitational radius in km
Plot Styling
This is just a quick way to make good looking plots simply.
import physkit as pk
import matplotlib.pyplot as plt
x_data = [...] # Example data for x and y
y_data = [...]
fig, ax = plt.subplots()
pk.plot_styler(x_data, y_data, ax=ax, title="test",
ylabel="y label", xlabel="x label", loglog=True)
plt.show()
Command Line Interface (CLI)
physkit constant G --system cgs
physkit convert 1 m cm
Contributing
Contributions are welcome!
- Fork the repository.
- Create a new branch (
git checkout -b feature-name). - Commit changes (
git commit -m "Add new feature"). - Push to your branch (
git push origin feature-name). - Open a Pull Request.
Issues
If you encounter any issues or have suggestions, feel free to open an issue on GitHub.
Contact
For inquiries, contact me via GitHub: sapphimars
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file physkit-0.1.23.tar.gz.
File metadata
- Download URL: physkit-0.1.23.tar.gz
- Upload date:
- Size: 30.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.6 CPython/3.12.12 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d2a083a136ea7b7e155fc36491bc353c124154099bfb85bb1cb14f516412b35
|
|
| MD5 |
ee1a60ab5d8c32350e085e53a906f144
|
|
| BLAKE2b-256 |
3e8513e5db76ec9e41b0b4d2b92d85569f61e1d5bc6f452eee87e991b089ee3b
|
File details
Details for the file physkit-0.1.23-py3-none-any.whl.
File metadata
- Download URL: physkit-0.1.23-py3-none-any.whl
- Upload date:
- Size: 32.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: pdm/2.26.6 CPython/3.12.12 Linux/6.11.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c45800de43b7adb550790442f3c6988b9d4539ecf9a74467f143d8d6b21f4cd6
|
|
| MD5 |
6e462d21dc69b0f75a9337adcb9759fd
|
|
| BLAKE2b-256 |
e6b25aab73b5dc164e9c36a51d26dfdafd1bbf1ca1374f93e9c068d1376d187f
|