Skip to main content

Build Status PyPI Version License: GPL v3

Light mode logo
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:

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

Metadata

Release files for physkit 0.1.23

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for physkit 0.1.23
File Size Uploaded
physkit-0.1.23.tar.gz 30.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for physkit 0.1.23
File Interpreter ABI Platform
physkit-0.1.23-py3-none-any.whl Python 3 none any Details

Total release size: 62.8 kB

Release files / physkit-0.1.23.tar.gz

Download URL physkit-0.1.23.tar.gz
Size 30.8 kB
Tags Source
SHA-256 checksum
How to use checksums
8d2a083a136ea7b7e155fc36491bc353c124154099bfb85bb1cb14f516412b35
BLAKE2b-256 checksum
How to use checksums
3e8513e5db76ec9e41b0b4d2b92d85569f61e1d5bc6f452eee87e991b089ee3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.26.6 CPython/3.12.12 Linux/6.11.0-1018-azure

Release files / physkit-0.1.23-py3-none-any.whl

Download URL physkit-0.1.23-py3-none-any.whl
Size 32.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c45800de43b7adb550790442f3c6988b9d4539ecf9a74467f143d8d6b21f4cd6
BLAKE2b-256 checksum
How to use checksums
e6b25aab73b5dc164e9c36a51d26dfdafd1bbf1ca1374f93e9c068d1376d187f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via pdm/2.26.6 CPython/3.12.12 Linux/6.11.0-1018-azure

Release history Release notifications | RSS feed

This release

0.1.23 This release

2 release files

0.1.16

2 release files

0.1.15

2 release files

0.1.14

2 release files

0.1.13

2 release files

0.1.12

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.5

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page