Skip to main content

AstroCalculator, a Calculator for Astronomers and Physicists

Project description

AstroCalculator, a Calculator for Astronomers and Physicists

About

AstroCalculator is a calculator for astronomers and physicists written in Python.
Author: ChongChong He (chongchong.he@anu.edu.au)

Installation

You can install astrocalculator from PyPI:

pip install astrocalculator

astrocalculator is supported on Python 3.6 and above.

How to use

Start the program with calc. You will see a modernized, color-coded interactive command line interface powered by rich and prompt_toolkit. An input can be 1) a single variable or constant like k_B, 2) an expression like m_e c^2, or 3) a list of variable assignments followed by a final expression to evaluate, e.g. M = 1.4 M_sun, R = 10 km, sqrt(2 G M / R).

Another way is to use it as a Python module in your script or interactively in iPython. Put the following in your code:

from calc import *

Now you can use all the physical constants defined in astrocalculator as listed in here.

Example inputs and outputs

Input[1]: m_p

Parsed input = m_p
Result (SI)  = 
  Name   = Proton mass
  Value  = 1.67262192369e-27
  Uncertainty  = 5.1e-37
  Unit  = kg
  Reference = CODATA 2018
Result (cgs) = 1.6726e-24 g

Input[2]: m_e c^2

Parsed input = c**2*m_e
Result (SI)  = 8.1871e-14 m N
Result (cgs) = 8.1871e-07 erg

Input[3]: in MeV

0.51100 MeV

Input[4]: M = 1.4 M_sun, R = 10 km, sqrt(2 G M / R)

Parsed input = sqrt(2*G*M*1/R)
Result (SI)  = 1.9277e+08 m / s
Result (cgs) = 1.9277e+10 cm / s

Input[5]: in km/s

1.9277e+05 km / s

Todos

  • Add latex preview

References

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

astrocalculator-0.4.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

astrocalculator-0.4.0-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file astrocalculator-0.4.0.tar.gz.

File metadata

  • Download URL: astrocalculator-0.4.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for astrocalculator-0.4.0.tar.gz
Algorithm Hash digest
SHA256 dc8277f62b1380c41ecb4bcd8b37b1a13fbc3676f557a076194d1dcd8fd3e0ad
MD5 0d28b8084229bc0fc402b6d6c3900079
BLAKE2b-256 32c55b1c83b038d4af80a0e744d684199fd5a796b0abdb8895fc2ea67063e9ae

See more details on using hashes here.

File details

Details for the file astrocalculator-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for astrocalculator-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 caa80637bd9b113407a534e602a652f6269a0a7612784832152751750b2e06a9
MD5 710861ff33630bee880419acb7a64aaf
BLAKE2b-256 efbcaf8ec6101772a71e83141250347f144f7e9e662452c1d44146ca4630fd74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page