Sigmyne/SuperNOVAS 是一个托管在 GitHub 上的开源项目,主要使用 C 编写,采用 The Unlicense 许可证,目前获得 62 个 Star、16 次 Fork。
仓库全名
Sigmyne/SuperNOVAS
README 摘要
SuperNOVAS The NOVAS C astrometry library, made better. C99 API documentation C++ API documentation SuperNOVAS pages on github.io SuperNOVAS is a C/C++ astronomy software library, providing high-precision astrometry such as one might need for running an observatory, a precise planetarium program, or for analyzing astronomical datasets. It started as a fork of the Naval Observatory Vector Astrometry Software (NOVAS)…
SuperNOVAS is a C/C++ astronomy software library, providing
high-precision astrometry such as one might need for running an observatory, a precise planetarium program, or for
analyzing astronomical datasets. It started as a fork of the Naval Observatory Vector Astrometry Software
(NOVAS) C version 3.1, but since then it has grown into its own,
providing bug fixes, tons of new features, and a much improved API compared to the original NOVAS.
SuperNOVAS is easy to use and it is very fast, with 3–5 orders of magnitude faster position calculations than
astropy 8.0.2 in a single thread (see the benchmarks), and its performance
will scale further with the number of CPUs when calculations are performed in parallel threads.
SuperNOVAS is suitable for POSIX (e.g. Linux, BSD, MacOS, LynxOS), Windows, Android, as well as embedded and
bare-metal platforms alike.
SuperNOVAS is available through the Sigmyne/SuperNOVAS repository on
GitHub, without licensing restrictions. Its source code is compatible with the C99 and C++11 standards, and hence
should be suitable for old and new platforms alike. And, despite it being a light-weight library, it fully supports
the IAU 2000/2006 resolutions and the
IERS 2010 conventions for microarcsecond-level
position calculations.
This document has been updated for the v1.9 and later releases.
Citation
If you use SuperNOVAS in your work, please cite as:
SuperNOVAS is a supercharged fork of the The Naval Observatory Vector Astrometry Software
(NOVAS). (It is not related to the separate NOVA / libnova library.)
The primary goal of SuperNOVAS is to improve on the original NOVAS C library via:
At the same time, SuperNOVAS aims to be fully backward compatible with the intended functionality of the upstream
NOVAS C library, such that it can be used as a build-time replacement for NOVAS in your application without having
to change existing (functional) code you may have written for NOVAS C.
SuperNOVAS is really quite easy to use. Its new API is just as simple and intuitive as that of astropy (or so
we strive for it to be), and it is similarly well documented also (see the
documentation for the C99 and/or
C++ APIs). You can typically achieve the
same results with similar lines of code on
C or
C++
with SuperNOVAS as with astropy, notwithstanding a little more involved error handling (due to the lack of
try / except style constructs in C/C++).
SuperNOVAS was created and is maintained by Attila Kovács. Outside contributions
are very welcome. See how you can contribute to make
SuperNOVAS even better.
SuperNOVAS fixes a number of outstanding issues with NOVAS C 3.1:
Fixes the sidereal_time bug, whereby the sidereal_time() function
had an incorrect unit cast. This was a documented issue of NOVAS C 3.1.
Fixes the ephem_close bug, whereby ephem_close() in
eph_manager.c did not reset the EPHFILE pointer to NULL. This was a documented issue of NOVAS C 3.1.
Fixes antedating velocities and distances for light travel time in ephemeris(). When getting positions and
velocities for Solar-system sources, it is important to use the values from the time light originated from the
observed body rather than at the time that light arrives to the observer. This correction was done properly for
positions, but not for velocities or distances, resulting in incorrect observed radial velocities or apparent
distances being reported for spectroscopic observations or for angular-physical size conversions.
Fixes bug in ira_equinox() which may return the result for the wrong type of equinox (mean vs. true) if the
equinox argument was changing from 1 to 0, and back to 1 again with the date being held the same. This affected
routines downstream also, such as sidereal_time().
Fixes accuracy switching bug in cio_basis(), cio_location(), ecl2equ(), equ2ecl_vec(), ecl2equ_vec(),
geo_posvel(), place(), and sidereal_time(). All these functions returned a cached value for the other
accuracy if the other input parameters are the same as a prior call, except the accuracy.
Fixes multiple bugs related to using cached values in cio_basis() with alternating CIO location reference
systems. This affected many CIRS-based position calculations downstream.
Fixes bug in equ2ecl_vec() and ecl2equ_vec() whereby a query with coord_sys = 2 (GCRS) has overwritten the
cached mean obliquity value for coord_sys = 0 (mean equinox of date). As a result, a subsequent call with
coord_sys = 0 and the same date as before would return the results in GCRS coordinates instead of the requested
mean equinox of date coordinates.
Fixes aberration() returning NaN vectors if the ve argument is 0. It now returns the unmodified input vector
appropriately instead.
Fixes unpopulated az output value in equ2hor() at zenith. While any azimuth is acceptable really, it results in
unpredictable behavior. Hence, we set az to 0.0 for zenith to be consistent.
Fixes potential string overflows and eliminates associated compiler warnings.
Nutation series used truncated expressions for the fundamental arguments, resulting in μas-level errors in when
dozens or more years away from the reference epoch of J2000.
[v1.1] Fixes division by zero bug in d_light() if the first position argument is the ephemeris reference
position (e.g. the Sun for solsys3.c). The bug affects for example grav_def(), where it effectively results in
the gravitational deflection due to the Sun being skipped.
[v1.1] The NOVAS C 3.1 implementation of rad_vel() has a number of issues that produce inaccurate results.
The errors are typically at or below the tens of m/s level for objects not moving at relativistic speeds.
[v1.4] The NOVAS C 3.1 implementation of cel2ter() / ter2cel() was such that if both xp and yp
parameters were zero, then no wobble correction was applied, not even for the TIO longitude (s’). The error from
this omission is very small, at just a few μas (microarcseconds) within a couple of centuries of J2000.
[v1.6] The NOVAS C geo_posvel() function is imprecise for geodetic observer locations on Earth, since it
does not account for polar offsets xp, yp. As such the geocentric GCRS observer position
and velocity vectors are accurate at the tens of meters level only. For Earth-based observers, SuperNOVAS adds
novas_site_gcrs_posvel() as a more precise alternative.
[v1.8] The NOVAS C transform_cat() calculated reprojected radial velocities using the Doppler factor derived
for the original radial velocity, when applying proper motion. The resulting difference is typically negligible so
long as the proper motion correction itself is small, but may become significant in case of large proper motion
corrections.
[v1.8] The NOVAS C transform_cat() used the initial angular-to-physical conversion factor, based on the
initial distance, when calculating the final quantities. Instead, the conversion factor should be recalculated for
the final distance before calculating the output motion parameters. The difference is typically negligible, except
perhaps for fast moving stars, and/or large time offsets from the catalog epoch.
[v1.9] Wrong NOVAS C k factor, and used incorrectly, for converting between proper motion and apparent 3D
motion in transform_cat() and in starvectors(). The k factor converts between physical and apparent motions,
and accounts for the changing light travel time as the star moves closer to, or further away from, the observer.
However, proper motion is already apparent motion, by definition, hence the use of k for proper motion is wrong.
Also, the factor ought to have been 1 / (1 + rv / c), but was 1 / (1 - rv / c) – that is the radial
velocity (rv) was included with the wrong sign. The typical errors from the bug are at or below 1 mas over a
century, but for Barnard’s star they are close around 0.4 arcsecs per century. (Thanks to Mike Kretlow for bringing
attention to this issue).
[v1.9] The NOVAS C proper motion model (in proper_motion() and transform_cat()) holds the light-time
corrected apparent 3D motion constant through the ages, rather than assuming a constant true physical motion like
SOFA. The difference for typical stars, with proper motion below 25 mas/yr, are at the μas level over a century,
but for Barnard’s star it is around 1.2 mas over a century. (Thanks to Mike Kretlow for bringing attention to this
issue).
[v1.9] The original NOVAS C implemetation did not account for the transverse Doppler effect in starvectors(),
such as described in Stumpff 1985. With it, the proper motion discrepancy w.r.t. SOFA is below to 1 nanoarcsecond
over a century.
[v1.9] The NOVAS C calculation of the spectroscopic radial velocity measure has ignored the transverse Dopper
effect for Solar-system bodies.
Compatibility with NOVAS C 3.1
SuperNOVAS strives to maintain API compatibility with the upstream NOVAS C 3.1 library, but not binary (ABI)
compatibility.
If you have code that was written for NOVAS C 3.1, it should work with SuperNOVAS as is, without modifications.
Simply (re)build your application against SuperNOVAS, and you are good to go.
The lack of binary compatibility just means that you cannot drop-in replace the libraries (e.g. the static
libnovas.a, or the shared libnovas.so), from NOVAS C 3.1 with those from SuperNOVAS. Instead, you will have to
build (compile) your application referencing the SuperNOVAS headers and/or libraries from the start.
This is because some function signatures have changed, e.g. to use an enum argument instead of the nondescript
short int option arguments used in NOVAS C 3.1, or because we added a return value to a function that was declared
void in NOVAS C 3.1. We also changed the object structure to contain a long ID number instead of short to
accommodate JPL NAIF codes, for which 16-bit storage is insufficient.
On MacOS you may install the dependencies with Homebrew:
brew install curl calceph doxygen
Installing dependencies on BSD
On BSD (e.g. FreeBSD, OpenBSD) you might install curl and calceph. And you will also need additional packages for
building SuperNOVAS, such as and cmake and/or gmake, and pkgconf:
The SuperNOVAS distribution contains a GNU Makefile, which is suitable for compiling the library (as well as
local documentation, and tests, etc.) on POSIX systems such as Linux, MacOS X, BSD, Cygwin or WSL – using
GNU make.
Before compiling the library take a look a config.mk and edit it as necessary for your needs, or else define
the necessary variables in the shell prior to invoking make. For example:
ENABLE_CPP: As of v1.6, SuperNOVAS offers a C++11 API and library also, but it is not enabled by default. To
build C++ library (libsupernovas++), and install the C++ header (supernovas.h) and documentation you should
set this option to 1, either in your environment or else in config.mk.
CALCEPH C library integration is automatic on Linux if
ldconfig can locate the libcalceph shared library. You can also control CALCEPH integration manually, e.g. by
setting CALCEPH_SUPPORT = 1 in config.mk or in the shell prior to the build. CALCEPH integration will require
an accessible installation of the CALCEPH development files (C headers and unversioned static or shared libraries
depending on the needs of the build).
NAIF CSPICE Toolkit integration is automatic on Linux if ldconfig
can locate the libcspice shared library. You can also control CSPICE integration manually, e.g. by setting
CSPICE_SUPPORT = 1 in config.mk or in the shell prior to the build. CSPICE integration will require an
accessible installation of the CSPICE development files (C headers, under a cspice/ subfolder in the header
search path, and unversioned static or shared libraries depending on the needs of the build). You might want to
check out the Sigmyne/cspice-sharedlib repository for
building CSPICE as a shared library.
If your compiler does not support the C11 standard and it is not GCC >=3.3, but provides some nonstandard
support for declaring thread-local variables, you may want to pass the keyword to use to declare variables as
thread local via -DTHREAD_LOCAL=... added to CFLAGS. (Don’t forget to enclose the string value in escaped
quotes in config.mk, or unescaped if defining the THREAD_LOCAL shell variable prior to invoking make.)
Additionally, you may set number of environment variables to futher customize the build, such as:
CC: The C compiler to use (default: gcc).
CPPFLAGS: C preprocessor flags, such as externally defined compiler constants.
CFLAGS: Flags to pass onto the C compiler (default: -g -Os -Wall). Note, -Iinclude will be added
automatically.
LDFLAGS: Extra linker flags (default is not set). Note, -lm will be added automatically.
CSTANDARD: Optionally, specify the C standard to compile for, e.g. c99 to compile for the C99 standard. If
defined then -std=$(CSTANDARD) is added to CFLAGS automatically.
WEXTRA: If set to 1, -Wextra is added to CFLAGS automatically.
FORTIFY: If set it will set the _FORTIFY_SOURCE macro to the specified value (gcc supports values 1
through 3). It affords varying levels of extra compile time / runtime checks.
CHECKEXTRA: Extra options to pass to cppcheck for the make check target
WITHOUT_CURL: Setting to 1 disables building against libcurl. Without cURL support, the EOP fetching functions
and methods will return an error or invalid EOP, with errno set to ENOSYS.
WITHOUT_LIBC: Setting to 1 builds the library for bare-metal or WebAssembly targets that have no libc file I/O,
heap allocator, or system clock. This sets the WITHOUT_LIBC, WITHOUT_SYSTEM_CLOCK, and WITHOUT_CURL
preprocessor flags. Without libc support, you cannot use the system clock to set current time, and/or manage
leap seconds and Earth Orientation Parameters automatically. You must set these explicitly instead. See
Cross-compiling for embedded targets section below.
DOXYGEN: Specify the doxygen executable to use for generating documentation. If not set (default), make will
use doxygen in your PATH (if any). You can also set it to none to disable document generation and the
checking for a usable doxygen version entirely.
Now you are ready to build the library:
$ make
will compile the shared (e.g. lib/libsupernovas.so) libraries, and compile the API documentation (into doc/)
using doxygen (if available). Alternatively, you can build select components of the above with the make targets
shared, and local-dox respectively. And, if unsure, you can always call make help to see what build targets are
available.
To build SuperNOVAS as static libraries, use make static.
After building the library you can install the above components to the desired locations on your system. For a
system-wide install you may simply run:
$ sudo make install
Or, to install in some other locations, you may set a prefix and/or DESTDIR. For example, to install under /opt
instead, you can:
$ sudo make prefix="/opt" install
Or, to stage the installation (to /usr) under a ‘build root’:
$ make DESTDIR="/tmp/stage" install
[!NOTE]
if you want to build SuperNOVAS for your old NOVAS C application you might want to further customize the build.
See section on
legacy application in the
C99 User’s guide.
Building with GNU make on BSD
On BSD, you will need to use gmake instead of make (see section on dependencies above). You will also need
pkgconf s.t. gcc may locate the dependencies (headers and libraries). In practice, it means setting
CPPFLAGS and LDFLAGS to contain the appropriate include and library paths and libraries prior to calling
gmake. E.g., to build against both libcurl and calceph:
Now you can build SuperNOVAS, for example as a shared library, with:
gmake shared
Cross-compiling for embedded targets
SuperNOVAS can be compiled as a static library for bare-metal embedded systems (e.g. ARM Cortex-M) or WebAssembly
targets (as of v1.7, thanks to Kiran Shila). Set WITHOUT_LIBC=1 to build in freestanding mode, which disables all
libc file I/O, heap allocation, and system clock dependencies:
where we cross-compile using the arm-none-eabi-gcc compiler with target-specific flags.
For WebAssembly with Emscripten, use emmake which substitutes the compiler and archiver
automatically:
emmake make WITHOUT_LIBC=1 static
Note, that some SuperNOVAS functionality is lost when built without libc, such as setting current time or
managing Earth Orientation Parameters (EOP) automatically. Thus, you will have to specify these explicity instead,
when needed.
Build / install using CMake
As of v1.5, SuperNOVAS can be built using CMake (big thanks to Kiran Shila). CMake allows
for greater portability than the regular GNU Makefile. Note, however, that the CMake configuration does not support
all of the build options of the GNU Makefile, such as automatic CALCEPH and CSPICE integration on Linux, supporting
legacy NOVAS C style builds, and code coverage tracking.
The basic build recipe for CMake is:
$ cmake -B build
$ cmake --build build
The SuperNOVAS CMake build supports the following options (in addition to the standard CMake options):
BUILD_SHARED_LIBS=ON|OFF (default: OFF) - Build shared libraries instead of static
BUILD_DOC=ON|OFF (default: OFF) - Compile HTML documentation. Requires doxygen.
BUILD_EXAMPLES=ON|OFF (default: OFF) - Build the included examples
Or, on Windows (Microsoft Visual C) you will want:
$ cmake --build build --config Release
If the config / CMAKE_BUILD_TYPE is not set, the build will only use the CFLAGS (if any) that were set in the
environment. This is ideal for those who want to have full control of the compiler flags used in the build.
Specifying Release or Debug will append a particular set of appropriate compiler options which are suited for the
given build type. (If you want to use the MinGW compiler on Windows, you’ll want to set
-DCMAKE_C_COMPILER=gcc -G "MinGW Makefiles" options also.)
After a successful build, you can install the Runtime (libraries), and Development (headers, CMake config, and
pkg-config) components, e.g. under /usr/local, as:
$ cmake --install build --prefix /usr/local
Or, you can use the --component option to install just the selected components. For example to install just
the Runtime component:
As of version 1.5, SuperNOVAS is available through the vcpkg registry. The vcpkg port
supports a wide range of platforms, including Linux, Windows, MacOS, and Android – for both arm64 and x64
architectures (and in case of Windows also x86). It is effectively the same as the CMake build (above), only with
more simplicity, convenience, and dependency resolution.
The vcpkg port has optional add-on features, which may be installed along with the core library as needed. The
following features are available:
core – The core C99 library (this is installed by default if no components are specified).
cpp – The C++11 extension runtime and development files.
solsys-calceph – CALCEPH plugin runtime and development files. (It also installs the calceph dependency as
needed).
You can install just the core C99 library of SuperNOVAS (without the C++ API and CALCEPH support) with vcpkg as:
SuperNOVAS is packaged for Fedora / EPEL and Debian Linux distributions, and derivatives based on these
(Ubuntu, Mint, RHEL, CentOS Stream, Alma Linux, Rocky Linux, Oracle Linux etc.).
On Fedora / EPEL based distributions you might install all components via:
In both cases the first package is the runtime library, the second is the C++11 runtime library, the third is the
runtime for the solsys-calceph plugin, then documentation, and finally the files needed for application development.
[!NOTE]
The turnaround time for Debian packages is quite slow, and typically follows the Debian release cycle, whereas the
Fedora / EPEL and Ubuntu packages are usually fully up-to-date (i.e. in stable) within a week of a new SuperNOVAS
release. Somewhat newer Debian versions may be found in testing, but even that tends to lag behind the stable
Fedora / EPEL or Ubuntu versions.
Homebrew package
As of version 1.5, there is also a Homebrew package through the maintainer’s own Tap.
To install SuperNOVAS via Homebrew, in the recommended default configuration:
$ brew tap attipaci/pub
$ brew install supernovas
The above will build and install SuperNOVAS with the C++ API extension and the CALCEPH plugin support (including the
calceph dependency, as needed). However, you may add further options to customize your build:
--with-doxygen – Install with local HTML documentation.
--without-c++ – Install without the C++ API extension and runtime.
--without-calceph – Install without CALCEPH support (and dependency).
--without-curl – Install without libcurl support (disables EOP fetching from IERS).
Nix package
As of version 1.5, there is also a Nixpackage.
This declarative and determinstic package manager can be used on every Linux distribution as well as MacOS.
The default package includes the solsys-calceph plugin, but can be overriden by changing withCalceph.
Install to your profile with
$ nix profile add nixpkgs#supernovas
Or include in your Nix build of other software with
nativeBuildInputs = with pkgs; [supernovas];
Celestial coordinate systems (old vs. new)
Figure 1. SuperNOVAS Coordinate Systems and Conversions. Functions indicated in bold face are available in NOVAS C also. All other functions are available in SuperNOVAS only. SuperNOVAS also adds efficient matrix transformations between the equatorial systems.
The IAU 2000 and 2006 resolutions have completely
overhauled the system of astronomical coordinate transformations to enable higher precision astrometry. (Super)NOVAS
supports coordinate calculations both in the old (pre IAU 2000) ways, and in the new IAU standard method. The table
below provides an overview of how the old and new methods define some of the terms differently:
Concept
Old standard
New IAU standard
Catalog coordinate system
MOD (e.g. FK4, FK5, HIP…)
International Celestial Reference System (ICRS)
Dynamical system
True of Date (TOD)
Celestial Intermediate Reference System (CIRS)
Dynamical R.A. origin
equinox of date
Celestial Intermediate Origin (CIO)
Precession, nutation, bias
no tidal terms
IAU 2000/2006 precession/nutation model
Celestial Pole offsets
dψ, dε (for TOD)
xp, yp (for ITRS)
Earth rotation measure
Greenwich Sidereal Time (GST)
Earth Rotation Angle (ERA)
Pseudo Earth-fixed system
PEF
Terrestrial Intermediate Reference System (TIRS)
Earth rotation origin
Greenwich Meridian
Terrestrial Intermediate Origin (TIO)
Earth-fixed System
WGS84
International Terrestrial Reference System (ITRS)
See the various enums and constants defined in novas.h, as well as the descriptions on the various NOVAS routines
on how they are appropriate for the old and new methodologies respectively. Figure 1 also shows the relation of the
various old and new coordinate systems and the (Super)NOVAS functions for converting position / velocity vectors among
them.
[!NOTE]
In NOVAS, the barycentric BCRS and the geocentric GCRS systems are effectively synonymous to ICRS, since the origin
for positions and for velocities, in any reference system, is determined by the observer location. Aberration and
gravitational deflection correction included for apparent places only (as seen from the observer location,
regardless of where that is), but not for geometric places.
[!TIP]
Older catalogs, such as J2000 (FK5), HIP, B1950 (FK4) or B1900 are just special cases of MOD (mean-of-date)
coordinates for the J2000, J1991.25, B1950, and B1900 epochs, respectively.
[!CAUTION]
Applying residual polar offsets (Δdψ, Δdε or xp, yp) to the
TOD equator (via cel_pole()) is discouraged. Instead, the sub-arcsecond level corrections to Earth orientation
(xp, yp) should be used only for converting between the pseudo Earth-fixed (PEF or TIRS)
and ITRS, and vice-versa (e.g. with novas_make_frame() or wobble()).
[!NOTE]
WGS84 has been superseded by ITRS for higher accuracy definitions of Earth-based locations. WGS84 matches ITRS to
the 10m level globally, but it does not account for continental drifts and crustal motion. In (Super)NOVAS all
Earth-base locations are presumed ITRS. ITRS longitude, latitude, and altitude coordinates are referenced to the
GRS80 ellipsoid, whereas GPS locations are referenced to the WGS84 ellipsoid. SuperNOVAS offers ways to convert
between the two if needed.
SuperNOVAS can do a lot of things on its own. What it cannot do alone is provide precise positions for
Solar-system bodies. For that, you need ephemeris data and a helping hand from an external tool to access them. Even
if you don’t particularly care to obtain precise planet positions per se, they are needed for a range of
high-precision calculations (such as for positional calculations for Earth-based observers, and gravitational
deflections in full-precision observing frames).
Therefore, it is strongly recommended that you download
planetary ephemeris files from NASA / JPL (such as
the DE440, or the smaller DE440s, or the long-term DE441), and install CALCEPH or the
CSPICE Toolkit for accessing these. I recommend CALCEPH, because it is
more widely available (also in packaged form), and it is also more modern, and actively maintained.
If you go with CALCEPH, as recommended, your use of SuperNOVAS should always start with something like this
(regardless of whether you will use the C99 or the C++ API afterwards):
#include <novas-calceph.h>
// Use DE440, DE440s, or DE441 as your planet provider...
t_calcephbin *pleph = calceph_open("/path/to/de440.bsp");
status = novas_use_calceph_planets(pleph);
if(status < 0) {
// Oops something went wrong...
}
Don’t forget to link with -lsolsys-calceph and -lcalceph flags added you yor build. With that, you have now
unlocked a lot of the high-precision capabilities of SuperNOVAS. Have fun with it!
For more details on using CALCEPH or integrating other ways for providing ephemeris data to SuperNOVAS look at
the section below.
Pick your flavor (C or C++)
As of v1.6 SuperNOVAS comes in two flavors, the original C99 API, and a higher-level C++11 API. Depending on which
one you intend to use, choose the appropriate link to an external document below for further information:
Incorporating Solar-system ephemeris data or services
If you want to use SuperNOVAS to calculate positions for a range of Solar-system objects, and/or to do it with
precision, you will have to interface it to a suitable provider of ephemeris data. The preferred ways to do that in
SuperNOVAS enumerated below. (The legacy NOVAS C ways are not covered here, since they require specialized builds
of SuperNOVAS, which are covered
separately.)
NASA/JPL provides generic ephemerides for the major
planets, satellites thereof, the 300 largest asteroids, the Lagrange points, and some Earth orbiting stations. For
example, DE440 covers the major planets,
and the Sun, Moon, and barycenters for times between 1550 AD and 2650 AD. Or, you can use the
JPL HORIZONS system (via the command-line / telnet or API interfaces) to
generate custom ephemerides (SPK/BSP) for just about all known solar systems bodies, down to the tiniest rocks.
The CALCEPH library provides easy-to-use access to JPL and
INPOP ephemeris files from C/C++. As of version 1.2, we provide optional support for interfacing SuperNOVAS with
the CALCEPH C library for handling Solar-system objects.
Prior to building SuperNOVAS simply set CALCEPH_SUPPORT to 1 in config.mk or in your environment (or for CMake
configure with the -DENABLE_CALCEPH=ON). Depending on the build target (or type), it will build
libsolsys-calceph.so[.1] (target shared or CMake option -DBUILD_SHARED_LIBS=ON1) or libsolsys-calceph.a (target
static or default CMake build) libraries or solsys-calceph.o (target solsys, no CMake equivalent), which provide
the novas_use_calceph() and novas_use_calceph_planets(), and novas_calceph_use_ids() functions.
Of course, you will need access to the CALCEPH C development files (C headers and unversioned libcalceph.so or .a
library) for the build to succeed. Here is an example on how you’d use CALCEPH with SuperNOVAS in your application
code:
First and foremost, you should use CALCEPH to provide planet positions via the DE440 or DE440s (smaller file size)
or DE441 (long term) ephemeris data:
#include <novas-calceph.h>
// Use DE440, DE440s, or DE441 as your planet provider...
t_calcephbin *pleph = calceph_open("/path/to/de440.bsp");
status = novas_use_calceph_planets(pleph);
if(status < 0) {
// Oops something went wrong...
}
Even if you don’t care for the planets, you’ll still need the planetary ephemeris for a lot of the high-precision
calculations, so don’t skip on this step if you can help it.
Beyond just the planets, you might want to download and use further ephemeris data, such as for the many moons
orbiting planets, the major asteroids, various minor bodies of interest (e.g. comets, NEOs), or man-made spacecrafts.
You can activate an additional set (or sets) of ephemeris files separately from the planetary ephemeris above. For
example:
// Open all files that you will use concurrently
t_calcephbin *eph = calceph_open_array(...);
// Tell SperNOVAS to use CALCEPH with these files for obtaining
// positions for objects contained within them
int status = novas_use_calceph(eph);
if(status < 0) {
// Oops something went wrong...
}
All modern JPL (SPK) ephemeris files should work with the solsys-calceph plugin. When linking your application,
add -lsolsys-calceph to your link flags (or else link with solsys-calceph.o), and link against the CALCEPH library
also (-lcalceph). That’s all there is to it.
When using CALCEPH, ephemeris objects are referenced by their ID numbers (object.number), unless it is set to -1, in
which case name-based lookup will be used instead. ID numbers are assumed to be NAIF by default, but
novas_calceph_use_ids() can select between NAIF or CALCEPH numbering systems, if necessary.
NAIF CSPICE toolkit integration
The NAIF CSPICE Toolkit is the canonical standard library for JPL
ephemeris files from C/C++. As of version 1.2, we provide optional support for interfacing SuperNOVAS with CSPICE
for handling Solar-system objects.
Prior to building SuperNOVAS simply set CSPICE_SUPPORT to 1 in config.mk or in your environment (or for CMake
configure with -DENABLE_CSPICE=ON). Depending on the build target, it will build libsolsys-cspice.so[.1] (target
shared or CMake option -DBUILD_SHARED_LIBS=ON) or libsolsys-cspice.a (target static or default CMake build)
libraries or solsys-cspice.o (target solsys, no CMake equivalent), which provide the novas_use_cspice(),
novas_use_cspice_planets(), and novas_use_cspice_ephem() functions to enable CSPICE for providing data for all
Solar-system sources, or for major planets only, or for other bodies only, respectively. You can also manage the
active kernels with the cspice_add_kernel() and cspice_remove_kernel() functions.
Of course, you will need access to the CSPICE development files (C headers, installed under a cspice/ directory
of a header search location, and the unversioned libcspice.so or .a library) for the build to succeed. You may
want to check out the Sigmyne/cspice-sharedlib GitHub
repository to help you build CSPICE with shared libraries and dynamically linked tools.
Here is an example on how you might use CSPICE with SuperNOVAS in your application code:
#include <novas-cspice.h>
// You can load the desired kernels for CSPICE
// E.g. load DE440s and the Mars satellites:
int status;
status = cspice_add_kernel("/path/to/de440s.bsp");
if(status < 0) {
// oops, the kernels must not have loaded...
...
}
// Load additional kernels as needed...
status = cspice_add_kernel("/path/to/mar097.bsp");
...
// Then use CSPICE as your SuperNOVAS ephemeris provider
novas_use_cspice();
All JPL ephemeris data will work with the solsys-cspice plugin. When linking your application, add -lsolsys-cspice
to your link flags (or else link with solsys-cspice.o), and of course the CSPICE library also. That’s all there is
to it.
When using CSPICE, ephemeris objects are referenced by their NAIF ID numbers (object.number), unless that number is
set to -1, in which case name-based lookup will be used instead.
Universal ephemeris data / service integration
Possibly the most universal way to integrate ephemeris data with SuperNOVAS is to write your own
novas_ephem_provider function.
int my_ephem_reader(const char *name, long id, double jd_tdb_high, double jd_tdb_low,
enum novas_origin *restrict origin,
double *restric pos, double *restrict vel) {
// Your custom ephemeris reader implementation here
...
}
which takes an object ID number (such as a NAIF), an object name, and a split TDB date (for precision) as it inputs,
and returns the type of origin with corresponding ICRS position and velocity vectors in the supplied pointer
locations. The function can use either the ID number or the name to identify the object or file (whatever is the most
appropriate for the implementation and for the supplied parameters). The positions and velocities may be returned
either relative to the SSB or relative to the heliocenter, and accordingly, your function should set the value
pointed at by origin to NOVAS_BARYCENTER or NOVAS_HELIOCENTER accordingly. Positions and velocities are
rectangular ICRS x,y,z vectors in units of AU and AU/day respectively.
This way you can easily integrate current ephemeris data, e.g. for the Minor Planet Center (MPC), or whatever other
ephemeris service you prefer.
Once you have your adapter function, you can set it as your ephemeris service via set_ephem_provider():
set_ephem_provider(my_ephem_reader);
By default, your custom my_ephem_reader function will be used for NOVAS_EPHEM_OBJECT type objects only (i.e.
anything other than the major planets, the Sun, Moon, Solar-system Barycenter…). But, you can use the same function
for the major planets (NOVAS_PLANET type objects) also via:
The above simply instructs SuperNOVAS to use the same ephemeris provider function for planets as what was set
for NOVAS_EPHEM_OBJECT type objects, provided you compiled SuperNOVAS with BUILTIN_SOLSYS_EPHEM = 1 (in
config.mk), or else you link your code against solsys-ephem.c explicitly. Easy-peasy.
Many of the (Super)NOVAS functions take an accuracy argument, which determines to what level of precision quantities
are calculated. The argument can have one of two values, which correspond to typical precisions around:
enum novas_accuracy value
Typical precision
NOVAS_REDUCED_ACCURACY
~ 1 milli-arcsecond (mas)
NOVAS_FULL_ACCURACY
~ 1 micro-arcsecond (μas)
Note, that some functions will not support full accuracy calculations, unless you have provided a high-precision
ephemeris provider for the major planets (and any Solar-system bodies of interest), which does not come with
SuperNOVAS out of the box. In the absence of a suitable high-precision ephemeris provider, some functions might
return an error if called with NOVAS_FULL_ACCURACY.
Prerequisites to precise results
The SuperNOVAS library is in principle capable of calculating positions to microarcsecond, and velocities to
mm/s, precision for all types of celestial sources. However, there are certain prerequisites and practical
considerations before that level of accuracy is reached. (Click on the wedge next to each heading below to expand
the details.)
The IAU 2000/2006 conventions and methods
High precision calculations will generally require that you use SuperNOVAS with the new IAU standard quantities
and methods. The old ways were simply not suited for precision much below the milliarcsecond level. In particular,
Earth orientation parameters (EOP) should be applied only for converting between TIRS (or PEF) and ITRS systems, and
defined either with novas_make_frame() or else with wobble(). The old ways of incorporating (global) offsets in
the TOD coordinates via cel_pole() should be avoided.
Gravitational effects
Calculations much below the milliarcsecond level will require accounting for gravitational bending around massive
Solar-system bodies, and hence will require you to provide a high-precision ephemeris provider for the major planets.
Without it, there is no guarantee of achieving precision below the milli-arcsecond level in general, especially when
observing near the Sun or massive planets (e.g. observing Jupiter’s or Saturn’s moons, near conjunction with their
host planet). Therefore, some functions will return with an error, if used with NOVAS_FULL_ACCURACY in the absence
of a suitable high-precision planetary ephemeris provider.
Solar-system ephemeris
Precise calculations for Solar-system sources requires precise ephemeris data for both the target object as well as
for Earth, and the Sun. For the highest precision calculations you also need positions for all major planets to
calculate gravitational deflection precisely. By default, SuperNOVAS can only provide approximate positions for
the Earth and Sun (see earth_sun_calc()) at the tens of arcsecond level. You will need to provide a way to interface
SuperNOVAS with a suitable ephemeris source (such as CALCEPH, or the CSPICE toolkit from JPL) to obtain precise
positions for Solar-system bodies. See the section further above for more information how you can do
that.
Earth orientation parameters (EOP)
Calculating precise positions for any Earth-based observations requires precise knowledge of Earth orientation
parameters (EOP) at the time of observation. Earth’s pole is subject to predictable precession and nutation, but also
small irregular and diurnal variations in the orientation of the rotational axis and the rotation period (a.k.a. polar
wobble). You can apply the EOP values in novas_set_time() (for UT1-UTC), and novas_make_frame() (xp
and yp) (or via the C++ EOP class) to improve the astrometric precision of Earth based coordinate
calculations. Without the EOP values, positions for Earth-based calculations will be accurate at the tenths of
arcsecond level only.
The IERS Bulletins provide up-to-date
measurements, historical data, and near-term projections for the polar offsets, the UT1-UTC time difference. For
sub-milliarcsecond accuracy the mean values published by IERS should be interpolated before passing to the likes of
novas_set_time() or novas_make_frame(). At the micro-arcsecond (μas) level, you will need to ensure also that
the EOP values are provided for the same ITRF realization as the observer’s location, e.g. via
novas_itrf_transform_eop().
As of version 1.7, SuperNOVAS provides the option to fetch EOP values from IERS automatically, as needed. However,
beware that the IERS servers (or mirrors) may experience intermittent outages, and file formats or availability may
change. Therefore, for critical applications it is still recommended that you supply your EOP values explicitly, if
possible.
Atmospheric refraction model
Ground based observations are subject to atmospheric refraction. SuperNOVAS offers the option to include
refraction corrections with a set of atmospheric models, or using models you provide. Estimating refraction accurately
requires local weather parameters (pressure, temperature, and humidity), which may be be specified within the
on_surface data structure alongside the observer location. A standard radio refraction model is included as of
version 1.1, as well as our implementation of the wavelength-dependent IAU refraction model
(novas_wave_refraction() since version 1.4) based on the SOFA iauRefco() function. If none of the built-in options
satisfies your needs, you may also implement your own refraction correction to use.
Reduced accuracy shortcuts
When one does not need positions at the microarcsecond level, some shortcuts can be made to the recipe above:
You may forgo reconciling the ITRF realizations of EOP vs. an Earth-based observing site, if precision at the
microarcsecond level is not required.
You may skip the interpolation of published EOP values, if accuracy below the milliarcsecond level is not required.
You can use NOVAS_REDUCED_ACCURACY instead of NOVAS_FULL_ACCURACY for the calculations. This typically has an
effect at or below the milliarcsecond level only, but may be much faster to calculate.
You might skip the pole offsets xp, yp. These are tenths of arcsec, typically.
You may not need to interface to an ephemeris provider if you don’t need positions for Solar-system objects, and
you are willing to ignore gravitational redhifts / deflections around Solar-system bodies.
Runtime debug support
You can enable or disable debugging output to stderr with novas_debug(enum novas_debug_mode), where the argument
is one of the defined constants from novas.h:
novas_debug_mode value
Description
NOVAS_DEBUG_OFF
No debugging output (default)
NOVAS_DEBUG_ON
Prints error messages and traces to stderr
NOVAS_DEBUG_EXTRA
Same as above but with stricter error checking
The main difference between NOVAS_DEBUG_ON and NOVAS_DEBUG_EXTRA is that the latter will treat minor issues as
errors also, while the former may ignore them. For example, place() will return normally by default if it cannot
calculate gravitational bending around massive planets in full accuracy mode. It is unlikely that this omission would
significantly alter the result in most cases, except for some very specific ones when observing in a direction close
to a major planet. Thus, with NOVAS_DEBUG_ON, place() go about as usual even if the Jupiter’s position is not
known. However, NOVAS_DEBUG_EXTRA will not give it a free pass, and will make place() return an error (and print
the trace) if it cannot properly account for gravitational bending around the major planets as it is expected to.
When debug mode is enabled, any error condition (such as NULL pointer arguments, or invalid input values etc.) will
be reported to the standard error, complete with call tracing within the SuperNOVAS library, s.t. users can have a
better idea of what exactly did not go to plan (and where). The debug messages can be disabled by passing
NOVAS_DEBUG_OFF (0) as the argument to the same call. Here is an example error trace when your application calls
grav_def() with NOVAS_FULL_ACCURACY while solsys3 provides Earth and Sun positions only and when debug mode is
NOVAS_DEBUG_EXTRA (otherwise we’ll ignore that we skipped the almost always negligible deflection due to planets):
You can use the built-in error tracing to identify where things go awry in your code. You can turn on error tracing
for your entire code, or for a relevant section, in which a SuperNOVAS function returns an error (such as -1 or
NaN), e.g.:
novas_debug(NOVAS_DEBUG_ON);
// The part of your code that might have to do with the error return...
...
novas_debug(NOVAS_DEBUG_OFF);
Representative benchmarks
To get an idea of the speed of SuperNOVAS, you can use make benchmark on your machine. Figure 2 below
summarizes the single-threaded results obtained with v1.8.0 on an AMD Ryzen 5 PRO 6650U laptop (Linux 7.2.11, GCC
16.2.1). While this is clearly not the state of the art for today’s server class machines, it nevertheless gives you a
ballpark idea for how a typical, not so new, run-of-the-mill PC might perform.
Figure 2. SuperNOVAS apparent position calculation benchmarks, including proper motion, the IAU 2000 precession-nutation model, polar wobble, aberration, and gravitational deflection corrections, and precise spectroscopic redhift calculations.
The tests calculate apparent positions (in CIRS) for a set of sidereal sources with random parameters, using either
the SuperNOVASnovas_sky_pos() or the legacy NOVAS C place(), both in full accuracy and reduced accuracy
modes. The two methods are equivalent, and both include calculating a precise geometric position, as well as
aberration and gravitational deflection corrections from the observer’s point of view.
Description
accuracy
positions / sec
novas_sky_pos(), same frame
reduced
3556775
full
3555723
place(), same time, same observer
reduced
970271
full
969258
novas_sky_pos(), individual
reduced
82363
full
14398
place(), individual
reduced
81545
full
14344
For reference, we also provide the reduced accuracy benchmarks from NOVAS C 3.1.
Description
accuracy
positions / sec
NOVAS C 3.1 place(), same frame
reduced
503401
NOVAS C 3.1 place(), individual
reduced
64171
As one may observe, the SuperNOVASnovas_sky_pos() significantly outperforms the legacy place() function, when
repeatedly calculating positions for sources for the same instant of time and same observer location, providing 4–5
times faster performance than place() with the same observer and time. And when cycling through a set of predefined
frames the novas_sky_pos may be 40–250 faster than place(), depending on the accuracy. When observing frames are
reused, the performance is essentially independent of the accuracy.
For individual observing times or observer locations, the calculations of apparent positions at reduced, mas-level,
accuracy are generally around 5–6 times faster than with the full, μas level, accuracy.
For comparison, a very similar benchmark with astropy (v8.0.2 on Python v3.14.8) on the
same machine, provides 90-100 positions / second both for a fixed frame and for individual frames. As such,
SuperNOVAS is a whopping ~40000 times faster than astropy for calculations in the same observing frame, and
2–3 orders of magnitude faster than astropy for individual frames. (The astropy benchmarking code is also
provided under the benchmark/ folder in the SuperNOVAS GitHub repository).
Description
positions / sec
astropy 8.0.2 (python 3.14.8), same frame
91
astropy 8.0.2 (python 3.14.8), individual
99
The above benchmarks are all for single-threaded performance. Since SuperNOVAS is generally thread-safe, you can
expect that performance shall scale with the number of concurrent CPUs used when used multi-threaded. Thus, on a
16-core desktop PC, with similar single core performance, you could calculate 56 million precise positions per second,
if you wanted to. To put that into perspective, you could calculate precise apparent positions for the entire Gaia
dataset (1.7 billion stars) in just 30 seconds on your desktop PC. (It would take 2 weeks with astropy if
multiprocessing, or a 7 months in a single astropy process).
Below is a non-exhaustive overview new features added by SuperNOVAS on top of the existing NOVAS C API. See
CHANGELOG.md for more details.
New in v1.0
New runtime configuration:
The planet position, and generic Solar-system position calculator functions can be set at runtime, and users
can provide their own custom implementations, e.g. to read ephemeris data, such as from a JPL .bsp file.
If CIO locations vs GCRS are important to the user, the user may call set_cio_locator_file() at runtime to
specify the location of the binary CIO interpolation table (e.g. CIO_RA.TXT or cio_ra.bin) to use, even if
the library was compiled with the different default CIO locator path.
The default low-precision nutation calculator nu2000k() can be replaced by another suitable IAU 2006 nutation
approximation. For example, the user may want to use the iau2000b() model or some custom algorithm instead.
New constants, and enums – adding more specificity and transparency to option switches and physical units.
Many new functions to provide more coordinate transformations, inverse calculations, and more intuitive usage.
New in v1.1
New observing-frame based approach for calculations (frames.c). A novas_frame object uniquely defines both the
place and time of observation, with a set of precalculated transformations and constants. Once the frame is
defined it can be used very efficiently to calculate positions for multiple celestial objects with minimum
additional computational cost. The frames API is also more elegant and more versatile than the low-level NOVAS C
approach for performing the same kind of calculations. And, frames are inherently thread-safe since post-creation
their internal state is never modified during the calculations.
评论