Interested in contributing? Checkout the issues and projects pages to see what features have been suggested, or to suggest your own!
The purpose of this package is to leverage the Standards Of Fundamental Astronomy (SOFA) package in order to compute several astrophysical quantities regarding the positions of objects. CppEphem wraps the SOFA functions in easy to use classes, so that astronomers can quickly and easily compute the quantities they need in their own programs.
Here is a list of purposes I wish this code to serve:
- Basic coordinate conversion routines (see CESkyCoord, fully implemented)
- Star & Planet ephemeris
- Star positions for a given observer at a given time (not accounting for proper motion yet)
- Planet positions for a given observer at a given time (implemented in CEPlanet, see tutorials ce101, ce104, planetephem.cpp, and planetpositions.cpp)
- Basic time conversion routines (partially implemented, next priority)
- UTC (Current UTC obtainable from system clock)
- Local time (Current local time obtained from system clock, however user can hand set "UTC offset" if desired)
- Greenwich apparent sidereal time
- Local apparent sidereal time
- Note: Methods also exist for automatically computing and using "DUT1" (i.e. UT1-UTC), x/y polar motions, and TT-UT1
- Date conversion routines (see CEDate, fully implemented)
- Julian Date
- Modified Julian Date
- Gregorian Calendar (year, month, day)
More features will be implemented as time permits. If there is any feature that you would like to see implemented feel free to contact the author or submit an issue and I'll look into it.
The following is a list of currently fully implemented, compiled executables which can be run from the command line:
- Date conversion routines
- cal2jd: Gregorian calendar to Julian date
- cal2mjd: Gregorian calendar to modified Julian date
- jd2cal: Julian date to Gregorian calendar date
- jd2mjd: Julian date to modified Julian date
- mjd2cal: Modified Julian date to Gregorian calendar date
- mjd2jd: Modified Julian date to Julian date
- Coordinate conversion routines (all angles are expected in degrees or HMS/DMS format)
- convcoord: Convert from any coordinate system to any other
- NOTE: Older executables exist for coordinate conversions, but they are more limited than
convcoord
and are considered deprecated.
- Angular separation between two coordinates in the same coordinate system:
- angsep: Compute the angular separation between two coordinates
- Planet ephemeris producer
- planetephem: Computes the ephemeris for a given planet using user supplied geographic and time values.
- planetpositions: Computes current RA,Dec and Az,Alt for planets taking in user specific location (requires ncurses, not compiled by default)
To obtain the code, it should be as simple as cloning the repository from github:
git clone https://github.com/Jvinniec/CppEphem.git CppEphem
Once the code is downloaded, the advised method for compiling the code is via cmake
. To compile via cmake
use the following instructions:
-
Create a new directory to build the code in. This enables you to create a completely clean build in the future by simply deleting and recreating this directory.
mkdir /build/dir/cppephem cd /build/dir/cppephem
-
Now run
cmake
with your desired configuration options to build the code:# configure cmake [-DCMAKE_INSTALL_PREFIX=/your/install/directory/] /path/to/cloned/CppEphem # build (N = number of threads for compilation) cmake --build . [-- -jN]
NOTE: "-Dprefix=" and "-DCMAKE_INSTALL_PREFIX=" will have equivalent behavior of specifying the directory where the code will be installed into.
OPTIONAL: You can now test that the code actually works
cmake --build . --target test
-
Install the code to the specified installation directory:
cmake --build . --target install
This will install the headers, executables, and libraries in the default installation directories (or alternatively the directory specified in
-DCMAKE_INSTALL_PREFIX
during the initial run of cmake). You should make sure to update your$PATH
and$(DY)LD_LIBRARY_PATH
if installing the code to a non-standard location:# On MAC: export PATH=${PATH}:/install/dir/bin export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}:/install/dir/lib # On Linux export PATH=${PATH}:/install/dir/bin export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/install/dir/lib
NOTE: The code has grown to a point where it is no longer feasible to maintain two build systems. Because of this, it has been decided to deprecate the autotools build system and remove it completely in a future version.
To install via autotools, you should be able to build the software very easily using the standard "./configure -> make -> make install" method. Here is a bit more detail.
First, download the repository as described above in "Downloading the code". Second, make sure that the "configure" file exists in the top directory. If not, then do:
./autogen.sh
Third, configure the software (note the "prefix" option is optional):
./configure [--prefix=/your/install/directory/]
Fourth, build the code:
make
Finally, to install the code in an accessible manner (i.e. so that your PATH and (DY)LD_LIBRARY_PATH environment variables know where the executables and libraries are) type:
make install
And that should do it.
If you run into a problem installing when using cmake
and the -Dprefix=
option along the following form:
CMake Error at cmake_install.cmake:44 (file):
file INSTALL cannot set permissions on "~/Applications/CppEphem//include"
Make sure that you pass the full path to the installation directory (i.e. don't
use relative paths with '~/
').
The expectation is that compilers within the last few years should be supported. At the bare minimum your compiler should support C++11. At some point, CppEphem will move to requiring C++14.
To uninstall the code, it is advised to first run
make uninstall
in the top directory in order to remove the executables from your base install directory. Then you can delete the downloaded git repository.
Note: This only works if the code was compiled with autotools, since
cmake does not support make uninstall
.
The author above had no connection or involvement in the development of the SOFA software. Their software is included in this package because it is the standard provided by the International Astronomical Union (IAU). I don't claim to own their code. You can view the readme file in the sofa directory for more information on this software. (Can I not be sued now?)
In all seriousness, the SOFA software package is a rather impressive and phenomenally useful piece of code. I am really grateful to the authors of that package for putting it together.