![Shows logo dependent on light mode or dark mode.](https://user-images.githubusercontent.com/25423296/163456779-a8556205-d0a5-45e2-ac17-42d089e3c3f8.png)
Icon created by astroastra
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 project is licensed under the terms of the GNU General Public License v3.0.
See the LICENSE file for details.
Copyright (C) 2024 sapphimars
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.
- Python 3.12 or higher
- Dependencies:
- Matplotlib >= 3.5
- Pint >= 0.20
pip install physkit
pdm install
To install test dependencies:
pdm install -G test
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
from physkit.conversions import convert_unit
result = convert_unit(1, 'm', 'cm')
print(result) # Outputs: 100.0
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
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()
physkit constant G --system cgs
physkit convert 1 m cm
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.
If you encounter any issues or have suggestions, feel free to open an issue on GitHub.
For inquiries, contact me via GitHub: sapphimars