Skip to main content

An angle parsing module

Project description

angle-parser

A simple Python module for parsing angle strings.

Installation

pip install angle-parser

Usage

from angle_parser import parse_angle

# Whitespace between value and suffix is optional
parse_angle("90 deg")       # 1.5707963267948966  (π/2 radians)
parse_angle("90deg")        # 1.5707963267948966  (same, no space)
parse_angle("1 arcmin")     # 0.000290888...       (1/60 degree in radians)
parse_angle("1'")           # 0.000290888...       (synonym for arcmin)
parse_angle("1 arcsec")     # 4.8481368...e-06     (1/3600 degree in radians)
parse_angle('1"')           # 4.8481368...e-06     (synonym for arcsec)
parse_angle("1000 mas")     # 4.8481368...e-06     (milli-arcsec)
parse_angle("1e6 uas")      # 4.8481368...e-06     (micro-arcsec)
parse_angle("1 rad")        # 1.0
parse_angle("-45 deg")      # -0.785398...         (negative angles)
parse_angle("1.5e2 deg")    # 2.617993...          (scientific notation)

Supported Suffixes

Suffix Description Radians multiplier
deg Degrees π/180
arcmin Arcminutes (1/60 degree) π/10800
' Arcminutes (synonym) π/10800
arcsec Arcseconds (1/3600 deg) π/648000
" Arcseconds (synonym) π/648000
mas Milli-arcseconds π/648000000
uas Micro-arcseconds π/648000000000
rad Radians 1.0

API

parse_angle(string)

Parse an angle string and return the value in radians.

  • Parameters: string — A string containing a numeric value followed by a valid suffix (deg, arcmin/', arcsec/", mas, uas, rad). Whitespace between the value and suffix is optional.
  • Returns: float — The angle in radians.
  • Raises: ValueError — if the string does not match the expected format.

License

Copyright (c) Tim Molteno 2026 (tim@elec.ac.nz)

MIT License

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

angle_parser-0.2.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

angle_parser-0.2.0-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file angle_parser-0.2.0.tar.gz.

File metadata

  • Download URL: angle_parser-0.2.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for angle_parser-0.2.0.tar.gz
Algorithm Hash digest
SHA256 83f9444113e4ab0da243fb8139d3dcd20d2b0facf63253e97fd41ece47e0f22f
MD5 37153559f1a515c69f616c75bc523916
BLAKE2b-256 2af7d23c265e13daa3885406da19dd9798fc121ce0fb008252b38b4a18b8d432

See more details on using hashes here.

Provenance

The following attestation bundles were made for angle_parser-0.2.0.tar.gz:

Publisher: publish.yml on tmolteno/angle-parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file angle_parser-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: angle_parser-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for angle_parser-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8bba1bf8b03acdc04ffb7dfe21a74981ecceaab671c3d36bf95fd34a6271c30c
MD5 9c1d2f69b90c3f9cdd29b26e07056b45
BLAKE2b-256 71454250a354331ea3a36e7abd14fa1313bb87e59c197061a009afa66b0c24ba

See more details on using hashes here.

Provenance

The following attestation bundles were made for angle_parser-0.2.0-py3-none-any.whl:

Publisher: publish.yml on tmolteno/angle-parser

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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