Skip to content

A Python toolkit providing physical constants, unit conversions, and plotting styles

License

Notifications You must be signed in to change notification settings

sapphimars/physkit

Repository files navigation

Build Status PyPI Version License: GPL v3

Shows logo dependent on light mode or dark mode.
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.


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:

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!

  1. Fork the repository.
  2. Create a new branch (git checkout -b feature-name).
  3. Commit changes (git commit -m "Add new feature").
  4. Push to your branch (git push origin feature-name).
  5. 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

About

A Python toolkit providing physical constants, unit conversions, and plotting styles

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages