Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Python bindings for ERFA

Project description

PyPI Status DOI 10.5281/zenodo.3940699 Travis CI Status Documentation Status

PyERFA is the Python wrapper for the ERFA library (Essential Routines for Fundamental Astronomy), a C library containing key algorithms for astronomy, which is based on the SOFA library published by the International Astronomical Union (IAU). All C routines are wrapped as Numpy universal functions, so that they can be called with scalar or array inputs.

The project is a split of astropy._erfa module, developed in the context of Astropy project, into a standalone package. It contains the ERFA C source code as a git submodule. The wrapping is done with help of the Jinja2 template engine.

If you use this package in your research, please cita it via DOI 10.5281/zenodo.3940699.

Installation instructions

The package can be installed from the package directory using a simple:

$ pip install .

and similarly a wheel can be created with:

$ pip wheel .

Note

If you already have the C library liberfa on your system, you can use that by setting environment variable PYERFA_USE_SYSTEM_LIBERFA=1.

Testing

For testing, one can install the packages together with its testing dependencies and then test it with:

$ pip install .[test]
$ pytest

Alternatively, one can use tox, which will set up a separate testing environment for you, with:

$ tox -e test

Usage

The package can be imported as erfa which has all ERFA ufuncs wrapped with python code that tallies errors and warnings. Also exposed are the constants defined by ERFA in erfam.h, as well as numpy.dtype corresponding to structures used by ERFA. Examples:

>>> import erfa
>>> erfa.jd2cal(2460000., [0, 1, 2, 3])
(array([2023, 2023, 2023, 2023], dtype=int32),
 array([2, 2, 2, 2], dtype=int32),
 array([24, 25, 26, 27], dtype=int32),
 array([0.5, 0.5, 0.5, 0.5]))
>>> erfa.plan94(2460000., [0, 1, 2, 3], 1)
array([([ 0.09083713, -0.39041392, -0.21797389], [0.02192341, 0.00705449, 0.00149618]),
       ([ 0.11260694, -0.38275202, -0.21613731], [0.02160375, 0.00826891, 0.00217806]),
       ([ 0.13401992, -0.37387798, -0.21361622], [0.0212094 , 0.00947838, 0.00286503]),
       ([ 0.15500031, -0.36379788, -0.21040601], [0.02073822, 0.01068061, 0.0035561 ])],
      dtype={'names':['p','v'], 'formats':[('<f8', (3,)),('<f8', (3,))], 'offsets':[0,24], 'itemsize':48, 'aligned':True})
>>> erfa.dt_pv
dtype([('p', '<f8', (3,)), ('v', '<f8', (3,))], align=True)
>>> erfa.dt_eraLDBODY
dtype([('bm', '<f8'), ('dl', '<f8'), ('pv', '<f8', (2, 3))], align=True)
>>> erfa.DAYSEC
86400.0

It is also possible to use the ufuncs directly, though then one has to deal with the warning and error states explicitly. For instance, compare:

>>> erfa.jd2cal(-600000., [0, 1, 2, 3])
Traceback (most recent call last):
...
ErfaError: ERFA function "jd2cal" yielded 4 of "unacceptable date (Note 1)"
>>> erfa.ufunc.jd2cal(-600000., [0, 1, 2, 3])
(array([-1, -1, -1, -1], dtype=int32),
 ...,
 array([-1, -1, -1, -1], dtype=int32))

License

PyERFA is licensed under a 3-clause BSD style license - see the LICENSE.rst file.

Project details


Download files

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

Files for pyerfa, version 1.7.3
Filename, size File type Python version Upload date Hashes
Filename, size pyerfa-1.7.3-cp36-cp36m-macosx_10_9_x86_64.whl (306.3 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp36-cp36m-manylinux1_i686.whl (641.4 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp36-cp36m-manylinux1_x86_64.whl (701.6 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp36-cp36m-manylinux2010_i686.whl (641.4 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp36-cp36m-manylinux2010_x86_64.whl (701.6 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp36-cp36m-win32.whl (320.9 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp36-cp36m-win_amd64.whl (327.3 kB) File type Wheel Python version cp36 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp37-cp37m-macosx_10_9_x86_64.whl (306.3 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp37-cp37m-manylinux1_i686.whl (642.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp37-cp37m-manylinux1_x86_64.whl (702.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp37-cp37m-manylinux2010_i686.whl (642.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp37-cp37m-manylinux2010_x86_64.whl (702.4 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp37-cp37m-win32.whl (320.9 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp37-cp37m-win_amd64.whl (327.3 kB) File type Wheel Python version cp37 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp38-cp38-macosx_10_9_x86_64.whl (307.0 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp38-cp38-manylinux1_i686.whl (665.5 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp38-cp38-manylinux1_x86_64.whl (731.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp38-cp38-manylinux2010_i686.whl (665.5 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp38-cp38-manylinux2010_x86_64.whl (731.8 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp38-cp38-win32.whl (321.1 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp38-cp38-win_amd64.whl (328.2 kB) File type Wheel Python version cp38 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp39-cp39-macosx_10_9_x86_64.whl (303.5 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp39-cp39-manylinux1_i686.whl (640.2 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp39-cp39-manylinux1_x86_64.whl (698.3 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp39-cp39-manylinux2010_i686.whl (640.2 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp39-cp39-manylinux2010_x86_64.whl (698.3 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp39-cp39-win32.whl (320.6 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pyerfa-1.7.3-cp39-cp39-win_amd64.whl (328.2 kB) File type Wheel Python version cp39 Upload date Hashes View
Filename, size pyerfa-1.7.3.tar.gz (768.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page