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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83f9444113e4ab0da243fb8139d3dcd20d2b0facf63253e97fd41ece47e0f22f
|
|
| MD5 |
37153559f1a515c69f616c75bc523916
|
|
| BLAKE2b-256 |
2af7d23c265e13daa3885406da19dd9798fc121ce0fb008252b38b4a18b8d432
|
Provenance
The following attestation bundles were made for angle_parser-0.2.0.tar.gz:
Publisher:
publish.yml on tmolteno/angle-parser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
angle_parser-0.2.0.tar.gz -
Subject digest:
83f9444113e4ab0da243fb8139d3dcd20d2b0facf63253e97fd41ece47e0f22f - Sigstore transparency entry: 2092693845
- Sigstore integration time:
-
Permalink:
tmolteno/angle-parser@b937b1fbb3cc976a4c815357ed2c4d8238f1b54f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/tmolteno
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b937b1fbb3cc976a4c815357ed2c4d8238f1b54f -
Trigger Event:
push
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bba1bf8b03acdc04ffb7dfe21a74981ecceaab671c3d36bf95fd34a6271c30c
|
|
| MD5 |
9c1d2f69b90c3f9cdd29b26e07056b45
|
|
| BLAKE2b-256 |
71454250a354331ea3a36e7abd14fa1313bb87e59c197061a009afa66b0c24ba
|
Provenance
The following attestation bundles were made for angle_parser-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on tmolteno/angle-parser
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
angle_parser-0.2.0-py3-none-any.whl -
Subject digest:
8bba1bf8b03acdc04ffb7dfe21a74981ecceaab671c3d36bf95fd34a6271c30c - Sigstore transparency entry: 2092693955
- Sigstore integration time:
-
Permalink:
tmolteno/angle-parser@b937b1fbb3cc976a4c815357ed2c4d8238f1b54f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/tmolteno
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b937b1fbb3cc976a4c815357ed2c4d8238f1b54f -
Trigger Event:
push
-
Statement type: