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: Chong-Chong He (che1234@umd.edu)

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 command line interface where you can type in your inputs. A 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

  • parse keyword 'in' at the last line and automatically change User Unit.
  • 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.1.1.tar.gz (6.1 kB view details)

Uploaded Source

Built Distribution

astrocalculator-0.1.1-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: astrocalculator-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for astrocalculator-0.1.1.tar.gz
Algorithm Hash digest
SHA256 287ccee543753bb24e10e9e58737f1025c848d847371e6a64b64cf6ed44a8216
MD5 c2934e27c1d82ba3c2a5753bff214c7e
BLAKE2b-256 58e2c458377004bdb4ca9526cad98caa717ea101386b01c119aec2f857de7ccc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: astrocalculator-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.0.0 pkginfo/1.5.0.1 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3

File hashes

Hashes for astrocalculator-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dff6a4ade74ddd55a57f073a977b7bf2dda8a8b6c02844c7d353e216a5ece28b
MD5 c95f24c081b4c6171c8c9e20d7e90ffb
BLAKE2b-256 bc13942ecb624794899a8c1af26a34a3e25cccb6fd521111de8e8408eaedf113

See more details on using hashes here.

Supported by

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