Skip to main content

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

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.1.tar.gz (3.2 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.1-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for angle_parser-0.2.1.tar.gz
Algorithm Hash digest
SHA256 b389c3475f4935db6777b3d40740249aca692d3ffd5630f47969ee584b63a508
MD5 0e1802ed38a7a5f761cf31c9991887ff
BLAKE2b-256 835eb1907a02f3478e3b65fce24fa812a74e5dab515c1c6768a3bd1e3df7b2db

See more details on using hashes here.

Provenance

The following attestation bundles were made for angle_parser-0.2.1.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.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for angle_parser-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93629180ed34a5d5b687d30be44705da2972ec4a006b6cc0d032a49f5b0845ba
MD5 8e9b49c45f5b2f3c84411c8640973c9b
BLAKE2b-256 ebeac9b0c5ef959dbb0be695f99f10a709f289df54259979425a3fbcf5876975

See more details on using hashes here.

Provenance

The following attestation bundles were made for angle_parser-0.2.1-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.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.0

2 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