GithubHelp home page GithubHelp logo

python-novas's Introduction

Welcome to NOVAS Py

Important

This GitHub repository is merely a mirror of this official United States Naval Observatory software library, with the code tweaked to make possible its release on the Python Package Index as the novas package. None of the library’s actual authors are involved with this repository. Its official documentation is here:

What is NOVAS?

NOVAS is an integrated package of functions for computing various commonly needed quantities in positional astronomy. The package can supply, in one or two function calls, the instantaneous coordinates of any star or solar system body in a variety of coordinate systems. At a lower level, NOVAS also provides astrometric utility transformations, such as those for precession, nutation, aberration, parallax, and gravitational deflection of light. The computations are accurate to better than one milliarcsecond. The NOVAS library is an easy-to-use facility that can be incorporated into data reduction programs, telescope control systems, and simulations. The U.S. parts of The Astronomical Almanac are prepared using NOVAS.

What is NOVAS Py?

With NOVAS Py, the USNO is expanding NOVAS to the Python programming language. The NOVAS Py module is simply a wrapper around the NOVAS C code; all computations are still performed by the C code. NOVAS Py makes use of Python's ctypes module.

Installation

The NOVAS Py Module

The NOVAS Py module is installed from the top-level source directory with the command python setup.py install. If there are multiple versions of Python installed, the NOVAS Py package will be installed for the version used to run the setup.py script. Note that you may need superuser or administrator privileges to install the package.

Ephemerides

NOVAS requires access to a high-accuracy solar system ephemeris in order to compute places of solar system bodies and the highest-accuracy star places. Groups in the U.S., France, and Russia now construct high-accuracy solar system ephemerides. NOVAS is able to use solar system ephemerides that use JPL's export format, for example, the "developmental ephemerides," designated as "DEnnn", which are produced by JPL in the U.S. NOVAS C provides an implementation of JPL's ephemeris-access software that enables reading and interpolating a binary, direct-access ephemeris file.

Before using any NOVAS functionality that requires access to the ephemerides, you must first open the file with the ephem_open function (from novas.compat.eph_manager import ephem_open). You must either pass ephem_open the path to the binary ephemeris file you wish to use or have the path set in an environment variable named EPHEMERIS_FILE. If you choose to do the latter, you may then call ephem_open without passing any arguments to the function.

Consult the NOVAS C User Guide for directions on how to create the binary ephemeris file.

Package Layout

Phase one of NOVAS Py is intended to feel like NOVAS C. For the most part, function calls in Python match the function calls in C. All results are returned from the function. Some function inputs have been reordered so that the function can support optional inputs.

NOVAS functions can be found under the novas.compat namespace. Functions from eph_manager.c, solsys1.c, and nutation.c can be found under novas.compat.eph_manager, novas.compat.solsys, and novas.compat.nutation, respectively.

Note on constants

NOVAS Py includes a constants file copied from the NOVAS C constants file; this is only provided for consistency with the NOVAS C package. Since the wrapped NOVAS C functions are where the constants are used, and those functions obtain the constants from the NOVAS C constants file, any changes to constants in the NOVAS Py constants file will have no effect.

Notes on error handling

Error return codes from NOVAS C functions are handled by raising an appropriate exception. However, given the way NOVAS C does error codes, it was found that some return codes from higher-level C functions can represent more than one error. For these cases the developer choose what was felt to be the most likely or most important error code to escalate to an exception. All possible error codes are in the c_error dictionaries attached to each C function object, within each wrapper function, but those with duplicate numbers are commented out at this time.

Tests

Some tests are available in the tests source directory; they are designed to work with Python >= 2.7. To run the tests with Python 2.5 or 2.6, first install the unittest2 module

Using NOVAS Py

Once installation is complete, the NOVAS functions can be found under the novas.compat namespace. Nutation models can be found under novas.nutation, and constants under novas.constants.

python-novas's People

Contributors

brandon-rhodes avatar cdeil avatar lpsinger avatar mslonina avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

python-novas's Issues

UnicodeDecodeError in setup.py with Python 3 on Mac

With Python 3.2 from Macports on Mac OS X 10.8 I get the following error if I try to install python-novas:

$ python3.2 setup.py build
Traceback (most recent call last):
  File "setup.py", line 211, in <module>
    main()
  File "setup.py", line 196, in main
    options['long_description'] = open('README-PyPI').read()
  File "/opt/local/Library/Frameworks/Python.framework/Versions/3.2/lib/python3.2/encodings/ascii.py", line 26, in decode
    return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 1630: ordinal not in range(128)

cio_location crashes it NameError

I think this is not the upstream repository so this bug may not belong here, but I didn't find any bug reporting option here: http://aa.usno.navy.mil/software/novas/novas_py/novaspy_intro.php

A simple attempt to call novas.compat.cio_location crashes with a strange NameError:

>>> novas.compat.cio_location(novas.constants.T0)
NameError                                 Traceback (most recent call last)
<ipython-input-45-424d4effe030> in <module>()
----> 1 novas.compat.cio_location(novas.constants.T0)

[...]/novas/compat/compat.py in cio_location(jd_tdb, accuracy)
   2716 
   2717     ra_cio = c_double()
-> 2718     ref_sys - c_short()
   2719 
   2720     return_value = _cio_location(jd_tdb, accuracy, byref(ra_cio),

NameError: name 'ref_sys' is not defined

FYI I fresh installed novas and successfully run the self test with:

python -m unittest discover novas
................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 193 tests in 0.024s

OK

I'll report the bug upstream myself if you point me to the proper way to do it. Thanks.

Update GitHub from new code released by USNO

The Naval Observatory released an official NOVAS 3.1.1 version of their own back in October! I should do two things.

  1. Update this project on GitHub and PyPI with updated code from their new version.
  2. Add their URL to my nightly script that notifies me when a web page changes!

python novas support for newer ephemerides

Hello!

There does not seem to be support for newer than de405.bsp. Having previously done

pip install novas_de405

(works with ephem_opn())

I tried forcing the issue by downloading de440.bsp and then

jd_begin, jd_end, de_number = ephem_open('de440.bsp')

which gives

File "/usr/local/lib/python3.6/site-packages/novas/compat/eph_manager.py", line 90, in ephem_open
ctypes.byref(de_number))
File "/usr/local/lib/python3.6/site-packages/novas/init.py", line 53, in _check_c_errors
raise error0
OSError: from C function 'ephem_open': unable to set record length; ephemeris (DE number) not in look-up table.

Side note: "skyfield" is able to open the de440.bsp (eph = api.load("de440.bsp"))

celpole function is not found in novaslib

File "/Library/Python/2.7/site-packages/novas-3.1.1.4-py2.7.egg/novas/compat/compat.py", line 2022, in cel_pole
_cel_pole = novaslib.celpole
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/init.py", line 378, in getattr
func = self.getitem(name)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/init.py", line 383, in getitem
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7ffb7ed31840, celpole): symbol not found

_cel_pole = novaslib.celpole

ECI to ECEF

Is there a way to do ECI to ECEF conversions with this software that includes the nutation, polar, precession, and sideral rotations?

Windows Support

Hi All!

Would Windows support be as simple as compiling the C code in VC2010, etc? Or, does the code base have hard dependencies on POSIX systems?

python-novas DE405 seems to differ from JPL DE405

The constant names in python-novas DE405 are different from
ftp://ssd.jpl.nasa.gov/pub/eph/planets/ascii/de405/header.405

It appears that denum is in a different location, or missing.
A de405 generated with jplbin.h and the associated c files is the same size as python3.5/dist-packages/novas_de405/DE405.bin
But, /usr/bin/hd shows the contents of the two files to differ.
Was this change made for some reason?

Test errors with Python 3.3 on Ubuntu

See https://travis-ci.org/cdeil/python-novas/jobs/4255471

During the install:

76  byte-compiling /home/travis/virtualenv/python3.3/lib/python3.3/site-packages/novas/tests/checkout-stars-full.py to checkout-stars-full.cpython-33.pyc
77  File "/home/travis/virtualenv/python3.3/lib/python3.3/site-packages/novas/tests/checkout-stars-full.py", line 9
78    print "JPL Ephemeris DE%i open. jd_beg = %9.2f  jd_end = %9.2f\n" % \
79                                                                    ^
80 SyntaxError: invalid syntax

Then there's test errors because from novas import novaslib fails because the shared lib is called libnovas.cpython-33m.so

Support for M1 Macs

Hi,

this should be a simple fix in setup.py to support M1 Macs (or rather - ARM64 platform):

'extra_compile_args': ['-arch', 'i386',
                                       '-arch', 'x86_64',
                                       '-arch', 'arm64',
                                       '-O2', '-Wall', '-fPIC']

Note the extra arch flag. Tested this locally, can provide PR later on.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.