diff --git a/.travis.yml b/.travis.yml
index 0725590d..fbcb26b1 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -15,37 +15,54 @@ branches:
- gh-pages
# Establish which builds we wish to test
-matrix:
+jobs:
include:
# Test Linux with GCC
- os: linux
+ dist: focal
compiler: gcc
+ before_install:
+ - sudo apt-get install -y swig
# Test Linux with Clang
- os: linux
+ dist: focal
compiler: clang
+ before_install:
+ - sudo apt-get install -y swig
# Test OSX with GCC
- os: osx
compiler: gcc
+ addons:
+ homebrew:
+ packages:
+ - swig
+ update: true
# Test OSX with previous Clang
- os: osx
compiler: clang
- osx_image: xcode9.4
+ osx_image: xcode11.6
+ addons:
+ homebrew:
+ packages:
+ - swig
+ update: true
# Test OSX with Clang (latest version)
- os: osx
compiler: clang
- osx_image: xcode10.2
-
-
-# Allow compiling with c++11
-dist: xenial
+ osx_image: xcode12.2
+ addons:
+ homebrew:
+ packages:
+ - swig
+ update: true
# Build steps
script:
- - cmake -Dcoverage=1 ./
+ - cmake -Dcoverage=1 -Dpython-bindings=1 ./
- cmake --build .
- cmake --build . --target test
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a1797f9d..c1fd88ae 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,15 +1,40 @@
+#**************************************************************************
+# CMakeLists.txt: CppEphem *
+# ----------------------------------------------------------------------- *
+# Copyright © 2016-2019 JCardenzana *
+# ----------------------------------------------------------------------- *
+# *
+# This program is free software: you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation, either version 3 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program. If not, see . *
+# *
+#**************************************************************************
+
cmake_minimum_required (VERSION 3.0)
project (CppEphem)
set(CMAKE_BUILD_TYPE Release)
-#set(CMAKE_VERBOSE_MAKEFILE ON)
+#set(CMAKE_VERBOSE_MAKEFILE ON) # This enables verbose printing during build
# Add Version number
set (CppEphem_VERSION_MAJOR 1)
set (CppEphem_VERSION_MINOR 3)
-set (CppEphem_VERSION_PATCH 0)
+set (CppEphem_VERSION_PATCH 99)
set (cppephem_version "${CppEphem_VERSION_MAJOR}.${CppEphem_VERSION_MINOR}.${CppEphem_VERSION_PATCH}")
message ("\nCOMPILING CPPEPHEM VERSION ${cppephem_version}\n")
+# Set SWIG policies
+cmake_policy(SET CMP0086 NEW)
+cmake_policy(SET CMP0078 NEW)
+
# Set some flags necessary for the MAC OS builds
if (CMAKE_SYSTEM_NAME MATCHES Darwin)
set(CMAKE_MACOSX_RPATH 1)
@@ -39,9 +64,6 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/bin)
set (CPPEPHEM_SHARE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/build/share/cppephem)
set (HEADER_OUTPUT_PATH ${CMAKE_BINARY_DIR}/build/include)
-# Define some of the default compiler flags
-#set (CMAKE_CXX_FLAGS "-std=c++11 ${CMake_CXX_FLAGS}")
-
# Define the sofa directory
set (SOFA_DIRECTORY ${CMAKE_SOURCE_DIR}/sofa/src)
if (sofa)
@@ -98,7 +120,6 @@ enable_testing ()
add_subdirectory (cppephem)
add_subdirectory (test)
-
#-------------------------------------------
# Define installation directories
@@ -120,9 +141,13 @@ install(DIRECTORY ${CPPEPHEM_SHARE_OUTPUT_DIRECTORY}
install(DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
USE_SOURCE_PERMISSIONS
DESTINATION ${CMAKE_INSTALL_PREFIX}
- PATTERN "libtest*" EXCLUDE)
+ PATTERN "libtest*" EXCLUDE
+ PATTERN "_*.so" EXCLUDE)
install(DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
USE_SOURCE_PERMISSIONS
DESTINATION ${CMAKE_INSTALL_PREFIX}
PATTERN "test*" EXCLUDE)
+
+# Install Python stuff
+install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/cppephem/swig/pyext/setup.py install --prefix=${CMAKE_INSTALL_PREFIX} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/cppephem/swig/pyext/)")
\ No newline at end of file
diff --git a/ChangeLog.md b/ChangeLog.md
index de91ffe5..af939d52 100755
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -4,6 +4,13 @@ All notable changes to the CppEphem package will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## v1.3.99 : DEVELOPMENT
+ - Add SWIG wrappers for Python bindings
+ - Fix ambiguity in CESkyCoord::AngularSeparation methods
+ - Updated Travis-CI build configuration
+ - Updated SOFA to latest release (2019-07)
+
+
## v1.3.0 : 2019-08-19
- Add executable 'convcoord' for converting between any coordinate systems
- Add support for Ecliptic coordinates [#18]
diff --git a/README.md b/README.md
index 7e4cb041..ef4bc66f 100755
--- a/README.md
+++ b/README.md
@@ -88,7 +88,7 @@ Once the code is downloaded, the advised method for compiling the code is via `c
2. Now run `cmake` with your desired configuration options to build the code:
```bash
# configure
- cmake [-DCMAKE_INSTALL_PREFIX=/your/install/directory/] /path/to/cloned/CppEphem
+ cmake [-Dpython-bindings=1] [-DCMAKE_INSTALL_PREFIX=/your/install/directory/] /path/to/cloned/CppEphem
# build (N = number of threads for compilation)
cmake --build . [-- -jN]
```
@@ -115,9 +115,12 @@ installation directories (or alternatively the directory specified in
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/install/dir/lib
```
+## Support for Python (*experimental*)
+Python bindings can also be generated that allow running the code within Python. This can be done by adding `-Dpython-bindings=1` in the cmake configuration (step 2 above). Note that this requires SWIG (v4 or greater) and Python (v3.5 or greater) to be installed on your system.
+
## Autotools Build
-**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.*
+**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. It is not guaranteed to work.*
To install via autotools, you should be able to build the software
very easily using the standard "./configure -> make -> make install"
diff --git a/configure.ac b/configure.ac
index d9748414..fee8c7b5 100755
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@ dnl DONT FORGET TO CHANGE THE VERSION!
m4_define([CppEphem_VERSION_MAJOR], [1])
m4_define([CppEphem_VERSION_MINOR], [3])
-m4_define([CppEphem_VERSION_PATCH], [0])
+m4_define([CppEphem_VERSION_PATCH], [99])
m4_define([cppephem_version],
[CppEphem_VERSION_MAJOR.CppEphem_VERSION_MINOR.CppEphem_VERSION_PATCH])
diff --git a/cppephem/CMakeLists.txt b/cppephem/CMakeLists.txt
index 05f292c6..74483e1a 100755
--- a/cppephem/CMakeLists.txt
+++ b/cppephem/CMakeLists.txt
@@ -1,3 +1,23 @@
+#**************************************************************************
+# cppephem/CMakeLists.txt: CppEphem *
+# ----------------------------------------------------------------------- *
+# Copyright © 2019 JCardenzana *
+# ----------------------------------------------------------------------- *
+# *
+# This program is free software: you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation, either version 3 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program. If not, see . *
+# *
+#**************************************************************************
#------------------------------------------
# Define include directories
@@ -13,6 +33,7 @@ include_directories (${CMAKE_CURRENT_SOURCE_DIR}/include
#------------------------------------------
set (cppephem_SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/src/CENamespace.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/src/CEBase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/CEAngle.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/CEBody.cpp
${CMAKE_CURRENT_SOURCE_DIR}/src/CECoordinates.cpp
@@ -30,6 +51,7 @@ set (cppephem_SOURCES
set (cppephem_HEADERS
include/CppEphem.h
include/CENamespace.h
+ include/CEBase.h
include/CEAngle.h
include/CEBody.h
include/CECoordinates.h
@@ -72,3 +94,4 @@ set (testcppephem_SOURCES ${cppephem_SOURCES} PARENT_SCOPE)
add_subdirectory (test)
add_subdirectory (src)
add_subdirectory (exec)
+add_subdirectory (swig)
diff --git a/cppephem/exec/CMakeLists.txt b/cppephem/exec/CMakeLists.txt
index 8e004a76..5acdcd06 100755
--- a/cppephem/exec/CMakeLists.txt
+++ b/cppephem/exec/CMakeLists.txt
@@ -1,3 +1,23 @@
+#**************************************************************************
+# cppephem/exec/CMakeLists.txt: CppEphem *
+# ----------------------------------------------------------------------- *
+# Copyright © 2019 JCardenzana *
+# ----------------------------------------------------------------------- *
+# *
+# This program is free software: you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation, either version 3 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program. If not, see . *
+# *
+#**************************************************************************
#------------------------------------------
# Define include directories
diff --git a/cppephem/exec/planetephem.cpp b/cppephem/exec/planetephem.cpp
index c1c0e366..ea3733cc 100755
--- a/cppephem/exec/planetephem.cpp
+++ b/cppephem/exec/planetephem.cpp
@@ -178,10 +178,7 @@ void PrintEphemeris(CEObservation& obs,
// Print some basic information regarding the planet itself
std::printf("= PLANET =====================\n");
- std::printf(" Name : %s\n", planet->Name().c_str());
- std::printf(" Mass : %e kg\n", planet->Mass_kg());
- std::printf(" Radius: %f km\n", planet->Radius_m()/1000.0);
- std::printf(" Albedo: %f\n\n", planet->Albedo());
+ std::printf("%s\n\n", planet->describe().c_str());
std::vector ra;
std::vector dec;
diff --git a/cppephem/include/CEAngle.h b/cppephem/include/CEAngle.h
index e737cadb..fe6da8fe 100644
--- a/cppephem/include/CEAngle.h
+++ b/cppephem/include/CEAngle.h
@@ -25,17 +25,20 @@
#include
#include
+#include "CEBase.h"
#include "CENamespace.h"
-enum class CEAngleType
-{
- DEGREES=0,
- RADIANS=1,
- HMS=2,
- DMS=3
+/**********************************************************************//**
+ * Angle type enum
+ *************************************************************************/
+enum class CEAngleType : unsigned int {
+ DEGREES=0, ///< Degrees
+ RADIANS=1, ///< Radians
+ HMS=2, ///< Hours, minutes, seconds
+ DMS=3 ///< Degrees, arcmin, arcsec
};
-class CEAngle {
+class CEAngle : public CEBase {
public:
// Constructors
CEAngle();
@@ -79,6 +82,10 @@ class CEAngle {
void SetAngle(const std::vector& angle_vec,
const CEAngleType& angle_type);
+ // Necessary methods
+ const std::string ClassName(void) const;
+ const std::string describe(void) const;
+
private:
// Methods
@@ -94,4 +101,14 @@ class CEAngle {
};
-#endif /* CEAngle_h */
\ No newline at end of file
+
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CEAngle::ClassName() const
+{
+ return std::string("CEAngle");
+}
+
+#endif /* CEAngle_h */
diff --git a/cppephem/include/CEBase.h b/cppephem/include/CEBase.h
new file mode 100644
index 00000000..394d4d66
--- /dev/null
+++ b/cppephem/include/CEBase.h
@@ -0,0 +1,39 @@
+/***************************************************************************
+ * CEBase.h: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+#ifndef CEBase_h
+#define CEBase_h
+
+#include
+#include
+
+class CEBase {
+public:
+ // Constructors
+ CEBase();
+ virtual ~CEBase();
+
+ virtual const std::string ClassName(void) const = 0;
+ virtual const std::string describe(void) const;
+
+};
+
+#endif /* CEBase_h */
\ No newline at end of file
diff --git a/cppephem/include/CEBody.h b/cppephem/include/CEBody.h
index d5dbb38f..4a73b5ac 100755
--- a/cppephem/include/CEBody.h
+++ b/cppephem/include/CEBody.h
@@ -69,6 +69,10 @@ class CEBody : public CESkyCoord {
std::string Name(void) const;
void SetName(const std::string& new_name);
+ // Necessary methods
+ const std::string ClassName(void) const;
+ virtual const std::string describe(void) const;
+
private:
/************************************
@@ -86,6 +90,16 @@ class CEBody : public CESkyCoord {
};
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CEBody::ClassName() const
+{
+ return std::string("CEBody");
+}
+
+
/**********************************************************************//**
* Get the name of this object
*
diff --git a/cppephem/include/CECoordinates.h b/cppephem/include/CECoordinates.h
index bc7d1cbe..27735a2b 100755
--- a/cppephem/include/CECoordinates.h
+++ b/cppephem/include/CECoordinates.h
@@ -27,6 +27,7 @@
// CppEphem HEADERS
#include "CEAngle.h"
+#include "CEBase.h"
#include "CEDate.h"
#include "CENamespace.h"
#include "CEException.h"
@@ -46,7 +47,7 @@ enum class CECoordinateType
};
// Initiate the class that holds the coordinate information
-class CECoordinates {
+class CECoordinates : public CEBase {
friend bool operator==(const CECoordinates& lhs, const CECoordinates& rhs);
friend bool operator!=(const CECoordinates& lhs, const CECoordinates& rhs);
@@ -384,7 +385,11 @@ class CECoordinates {
virtual void SetCoordinates(const CECoordinates& coords);
// Support methods
- std::string print(void) const;
+ const std::string print(void) const;
+
+ // Necessary methods
+ const std::string ClassName(void) const;
+ const std::string describe(void) const;
protected:
// Coordinate variables
@@ -402,6 +407,16 @@ class CECoordinates {
};
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CECoordinates::ClassName() const
+{
+ return std::string("CECoordinates");
+}
+
+
/**********************************************************************//**
* Return x coordinate at given Julian date
*
diff --git a/cppephem/include/CECorrections.h b/cppephem/include/CECorrections.h
index bdddcbdd..168632d1 100644
--- a/cppephem/include/CECorrections.h
+++ b/cppephem/include/CECorrections.h
@@ -26,7 +26,9 @@
#include
#include
-class CECorrections {
+#include "CEBase.h"
+
+class CECorrections : public CEBase {
public:
CECorrections();
CECorrections(const CECorrections& other);
@@ -48,6 +50,10 @@ class CECorrections {
void SetTtUt1PredFile(const std::string& filename);
void SetInterp(bool set_interp);
+ // Necessary methods
+ const std::string ClassName(void) const;
+ const std::string describe(void) const;
+
private:
void copy_members(const CECorrections& other);
@@ -99,6 +105,16 @@ class CECorrections {
};
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CECorrections::ClassName() const
+{
+ return std::string("CECorrections");
+}
+
+
/**********************************************************************//**
* Returns the name of the nutation corrections file
*
diff --git a/cppephem/include/CEDate.h b/cppephem/include/CEDate.h
index 06b2e3ea..84a4841c 100755
--- a/cppephem/include/CEDate.h
+++ b/cppephem/include/CEDate.h
@@ -27,6 +27,7 @@
#include
// CppEphem HEADERS
+#include "CEBase.h"
#include "CETime.h"
#include
@@ -36,12 +37,13 @@
/**********************************************************************//**
* Date enum
*************************************************************************/
-enum CEDateType {JD, ///< Julian Date
- MJD, ///< Modified Julian Date
- GREGORIAN ///< Gregorian calendar (year, month, day)
- } ;
+enum class CEDateType : unsigned int {
+ JD=0, ///< Julian Date
+ MJD=1, ///< Modified Julian Date
+ GREGORIAN=2 ///< Gregorian calendar (year, month, day)
+};
-class CEDate {
+class CEDate : public CEBase {
public:
// Default constructor
CEDate(double date=CurrentJD(), CEDateType date_format=CEDateType::JD) ;
@@ -116,6 +118,7 @@ class CEDate {
virtual double GetTime(const double& utc_offset=0.0) const;
virtual double GetTime_UTC() const;
static double CurrentJD();
+ const CEDateType ReturnType() const;
void SetReturnType(CEDateType return_type);
/************************************************************
@@ -125,6 +128,10 @@ class CEDate {
operator double();
operator double() const;
+ // Necessary methods
+ virtual const std::string ClassName(void) const;
+ virtual const std::string describe(void) const;
+
private:
void free_members(void);
@@ -144,6 +151,16 @@ class CEDate {
};
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CEDate::ClassName() const
+{
+ return std::string("CEDate");
+}
+
+
/**********************************************************************//**
* Get the Julian date represented by this object
*************************************************************************/
@@ -240,6 +257,17 @@ double CEDate::GetMJD2JDFactor(void)
}
+/**********************************************************************//**
+ * Get the return type used in the overloaded 'double' operators
+ * @return ::CEDateType for the returned double
+ *************************************************************************/
+inline
+const CEDateType CEDate::ReturnType() const
+{
+ return return_type_;
+}
+
+
/**********************************************************************//**
* Set the return type from the overloaded 'operator double'.
* @param return_type ::CEDateType for the returned double
diff --git a/cppephem/include/CENamespace.h b/cppephem/include/CENamespace.h
index 95c01c78..cd16a5b3 100755
--- a/cppephem/include/CENamespace.h
+++ b/cppephem/include/CENamespace.h
@@ -96,6 +96,11 @@ namespace CppEphem {
void SetTtUt1PredFile(const std::string& filename);
void CorrectionsInterp(bool set_interp);
static CECorrections corrections;
+ void UseNutation(bool use_nut);
+ void UseTtUt1(bool use_ttut1);
+ static bool use_nutation_ = true;
+ static bool use_ttut1_ = true;
+
namespace StrOpt {
// Method for splitting a string based on some delimiter into a vector of strings
@@ -112,6 +117,6 @@ namespace CppEphem {
std::string join_angle(const std::vector& values,
const char& delim);
}
-}
+};
#endif /* CENamespace_h */
diff --git a/cppephem/include/CEObservation.h b/cppephem/include/CEObservation.h
index 6926726b..3381c784 100755
--- a/cppephem/include/CEObservation.h
+++ b/cppephem/include/CEObservation.h
@@ -23,6 +23,7 @@
#define CEObservation_h
// CppEphem HEAD
+#include "CEBase.h"
#include "CEBody.h"
#include "CEDate.h"
#include "CEObserver.h"
@@ -30,7 +31,7 @@
#include "CESkyCoord.h"
-class CEObservation {
+class CEObservation : public CEBase {
public:
// Constructors
CEObservation() ;
@@ -68,6 +69,10 @@ class CEObservation {
virtual void GetApparentXYCoordinate_Deg(double *apparent_X, double *apparent_Y);
bool UpdateCoordinates();
+ // Necessary methods
+ const std::string ClassName(void) const;
+ const std::string describe(void) const;
+
private:
// Member functions for setup and tear down
@@ -95,6 +100,16 @@ class CEObservation {
};
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CEObservation::ClassName() const
+{
+ return std::string("CEObservation");
+}
+
+
/**********************************************************************//**
* Access the underlying objects
* @return Pointer to current observer object
diff --git a/cppephem/include/CEObserver.h b/cppephem/include/CEObserver.h
index d9a9cded..2c2b1178 100755
--- a/cppephem/include/CEObserver.h
+++ b/cppephem/include/CEObserver.h
@@ -23,10 +23,11 @@
#define CEObserver_h
#include "CEAngle.h"
+#include "CEBase.h"
#include "CEDate.h"
#include "CENamespace.h"
-class CEObserver {
+class CEObserver : public CEBase {
public:
CEObserver(void) ;
CEObserver(const double& longitude,
@@ -86,7 +87,9 @@ class CEObserver {
std::vector VelocityICRS(const CEDate& date) const;
// Print information about the observer
- std::string print(void) const;
+ const std::string print(void) const;
+ const std::string ClassName(void) const;
+ const std::string describe(void) const;
private:
@@ -120,6 +123,16 @@ class CEObserver {
};
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CEObserver::ClassName() const
+{
+ return std::string("CEObserver");
+}
+
+
/**********************************************************************//**
* Return observer geographic longitude in radians
*************************************************************************/
diff --git a/cppephem/include/CEPlanet.h b/cppephem/include/CEPlanet.h
index 01431d33..ea40810f 100755
--- a/cppephem/include/CEPlanet.h
+++ b/cppephem/include/CEPlanet.h
@@ -26,11 +26,13 @@
#include "CEBody.h"
#include "CEObserver.h"
-/////////////////////////////////////////////
-/// Date enum
-enum CEPlanetAlgo {SOFA, ///< Use methods included in sofa software
- JPL ///< Use Keplerian algorithm outlined by JPL
- } ;
+/**********************************************************************//**
+ * Planet position algorithm enum
+ *************************************************************************/
+enum class CEPlanetAlgo : unsigned int {
+ SOFA = 0, ///< Use methods included in sofa software
+ JPL = 1 ///< Use Keplerian algorithm outlined by JPL
+};
class CEPlanet : public CEBody {
@@ -46,9 +48,9 @@ class CEPlanet : public CEBody {
CEPlanet& operator=(const CEPlanet& other);
/****** Methods ******/
- double Radius_m();
- double Mass_kg();
- double Albedo();
+ double Radius_m() const;
+ double Mass_kg() const;
+ double Albedo() const;
void SetMeanRadius_m(double new_radius);
void SetMass_kg(double new_mass);
void SetAlbedo(double new_albedo);
@@ -130,6 +132,10 @@ class CEPlanet : public CEBody {
void SetAlgorithm(const CEPlanetAlgo& new_algo);
void SetSofaID(const double& new_id);
+ // Necessary methods
+ const std::string ClassName(void) const;
+ virtual const std::string describe(void) const;
+
private:
void copy_members(const CEPlanet& other);
@@ -204,6 +210,16 @@ class CEPlanet : public CEBody {
};
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CEPlanet::ClassName() const
+{
+ return std::string("CEPlanet");
+}
+
+
/**********************************************************************//**
* @return Algorithm used for computing the planet position
*************************************************************************/
@@ -218,7 +234,7 @@ CEPlanetAlgo CEPlanet::Algorithm(void) const
* @return Radius in meters.
*************************************************************************/
inline
-double CEPlanet::Radius_m()
+double CEPlanet::Radius_m() const
{
return radius_m_;
}
@@ -228,7 +244,7 @@ double CEPlanet::Radius_m()
* @return Mass in kilograms.
*************************************************************************/
inline
-double CEPlanet::Mass_kg()
+double CEPlanet::Mass_kg() const
{
return mass_kg_;
}
@@ -238,7 +254,7 @@ double CEPlanet::Mass_kg()
* @return Albedo.
*************************************************************************/
inline
-double CEPlanet::Albedo()
+double CEPlanet::Albedo() const
{
return albedo_;
}
diff --git a/cppephem/include/CERunningDate.h b/cppephem/include/CERunningDate.h
index aeb00ec6..c23d8bab 100755
--- a/cppephem/include/CERunningDate.h
+++ b/cppephem/include/CERunningDate.h
@@ -47,6 +47,9 @@ class CERunningDate : public CEDate {
void ResetTime(void);
virtual double GetTimerSpeed(void) const;
virtual void SetTimerSpeed(const double& scale=1.0);
+
+ // Necessary methods
+ virtual const std::string ClassName(void) const;
private:
@@ -63,6 +66,16 @@ class CERunningDate : public CEDate {
};
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CERunningDate::ClassName() const
+{
+ return std::string("CERunningDate");
+}
+
+
/**********************************************************************//**
* Get the rate at which the timer is progressing
*
diff --git a/cppephem/include/CESkyCoord.h b/cppephem/include/CESkyCoord.h
index beac21bf..c770f8ac 100644
--- a/cppephem/include/CESkyCoord.h
+++ b/cppephem/include/CESkyCoord.h
@@ -26,6 +26,7 @@
#include
// CppEphem HEADERS
+#include "CEBase.h"
#include "CEAngle.h"
#include "CEDate.h"
#include "CENamespace.h"
@@ -37,8 +38,7 @@
#include "sofa.h"
/** The following enum specifies what coordinates this object represents */
-enum class CESkyCoordType
-{
+enum class CESkyCoordType : unsigned int {
CIRS=0, ///< RA, Dec (referenced at the center of the Earth)
ICRS=1, ///< RA, Dec (referenced at the barycenter of the solarsystem)
GALACTIC=2, ///< Galacitc longitude, latitude
@@ -47,7 +47,7 @@ enum class CESkyCoordType
};
// Class for handling sky coordinates
-class CESkyCoord {
+class CESkyCoord : public CEBase {
friend bool operator==(const CESkyCoord& lhs, const CESkyCoord& rhs);
friend bool operator!=(const CESkyCoord& lhs, const CESkyCoord& rhs);
@@ -68,9 +68,7 @@ class CESkyCoord {
/*********************************************************
* Angular separation between two coordinate positions
*********************************************************/
- virtual CEAngle AngularSeparation(const CESkyCoord& coords) const;
- static CEAngle AngularSeparation(const CESkyCoord& coords1,
- const CESkyCoord& coords2);
+ virtual CEAngle Separation(const CESkyCoord& coords) const;
static CEAngle AngularSeparation(const CEAngle& xcoord_first,
const CEAngle& ycoord_first,
const CEAngle& xcoord_second,
@@ -201,7 +199,9 @@ class CESkyCoord {
virtual void SetCoordinates(const CESkyCoord& coords);
// Support methods
- std::string print(void) const;
+ const std::string print(void) const;
+ const std::string ClassName(void) const;
+ virtual const std::string describe(void) const;
private:
/*********************************************************
@@ -218,6 +218,16 @@ class CESkyCoord {
};
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CESkyCoord::ClassName() const
+{
+ return std::string("CESkyCoord");
+}
+
+
/**********************************************************************//**
* Return x coordinate at given Julian date
*
diff --git a/cppephem/include/CETime.h b/cppephem/include/CETime.h
index 3b9f7102..eb231ee6 100755
--- a/cppephem/include/CETime.h
+++ b/cppephem/include/CETime.h
@@ -26,16 +26,20 @@
#include
#include
+#include "CEBase.h"
#include "CENamespace.h"
-// Time types are defined as:
-// UTC - Coordinate Universal Time
-// GAST - Greenwich Apparent Sidereal Time
-// LAST - Local Apparent Sidereal Time
-// LOCALTIME - Local time (defined as the UTC + timezone_shift_)
-enum CETimeType {UTC, GAST, LAST, LOCALTIME} ;
+/**********************************************************************//**
+ * Time type enum
+ *************************************************************************/
+enum class CETimeType : unsigned int {
+ UTC = 0, ///< Coordinate Universal Time
+ GAST = 1, ///< Greenwich Apparent Sidereal Time
+ LAST = 2, ///< Local Apparent Sidereal Time
+ LOCALTIME = 3 ///< Local time (defined as the UTC + timezone_shift_)
+};
-class CETime {
+class CETime : public CEBase {
public:
// Default constructor
CETime() ;
@@ -109,6 +113,13 @@ class CETime {
// GAST conversions
+ // Printing time
+ std::string HmsStr(const char& delim=':') const;
+
+ // Support methods
+ const std::string ClassName(void) const;
+ virtual const std::string describe(void) const;
+
private:
void copy_members(const CETime& other);
@@ -133,6 +144,16 @@ class CETime {
};
+/**********************************************************************//**
+ * Return name of this class
+ *************************************************************************/
+inline
+const std::string CETime::ClassName() const
+{
+ return std::string("CETime");
+}
+
+
/**********************************************************************//**
* Return the Hour associated with this time object
*
diff --git a/cppephem/include/CppEphem.h b/cppephem/include/CppEphem.h
index 53b1698b..5a049261 100755
--- a/cppephem/include/CppEphem.h
+++ b/cppephem/include/CppEphem.h
@@ -1,7 +1,7 @@
/***************************************************************************
* CppEphem.h: CppEphem *
* ----------------------------------------------------------------------- *
- * Copyright © 2016 JCardenzana *
+ * Copyright © 2016-2019 JCardenzana *
* ----------------------------------------------------------------------- *
* *
* This program is free software: you can redistribute it and/or modify *
@@ -29,6 +29,7 @@
// ALL THE CppEphem HEADERS
#include "CEAngle.h"
+#include "CEBase.h"
#include "CECoordinates.h"
#include "CEDate.h"
#include "CENamespace.h"
diff --git a/cppephem/src/CEAngle.cpp b/cppephem/src/CEAngle.cpp
index 11771e1e..df0a4f58 100644
--- a/cppephem/src/CEAngle.cpp
+++ b/cppephem/src/CEAngle.cpp
@@ -484,6 +484,20 @@ void CEAngle::SetAngle(const std::vector& angle_vec,
}
+/**********************************************************************//**
+ * Returns description of this angle
+ *
+ * @return description of this angle
+ *************************************************************************/
+const std::string CEAngle::describe(void) const
+{
+ std::string msg("CEAngle object:\n");
+ msg += " radians: " + std::to_string(this->Rad()) + "\n";
+ msg += " degrees: " + std::to_string(this->Deg());
+ return msg;
+}
+
+
/**********************************************************************//**
* Set the angle from a vector of doubles representing {hours, minutes, seconds}
*
diff --git a/cppephem/src/CEBase.cpp b/cppephem/src/CEBase.cpp
new file mode 100644
index 00000000..46e2b316
--- /dev/null
+++ b/cppephem/src/CEBase.cpp
@@ -0,0 +1,55 @@
+/***************************************************************************
+ * CEBase.cpp: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/** \class CEBase
+ The CEBase class defines the essential base methods for all classes
+ */
+
+#include
+
+#include "CEBase.h"
+
+
+/**********************************************************************//**
+ * Default constructor
+ *************************************************************************/
+CEBase::CEBase()
+{
+ return;
+}
+
+
+/**********************************************************************//**
+ * Destructor
+ *************************************************************************/
+CEBase::~CEBase()
+{
+ return;
+}
+
+
+/**********************************************************************//**
+ * Return a text description of this object
+ *************************************************************************/
+const std::string CEBase::describe(void) const
+{
+ return std::string(this->ClassName() + " object:");
+}
diff --git a/cppephem/src/CEBody.cpp b/cppephem/src/CEBody.cpp
index b84e2d8b..8a4cb9b0 100755
--- a/cppephem/src/CEBody.cpp
+++ b/cppephem/src/CEBody.cpp
@@ -135,6 +135,16 @@ CESkyCoord CEBody::ObservedCoords(const CEDate& date,
}
+/**********************************************************************//**
+ * Computes the observed coordinates for this object based
+ *************************************************************************/
+const std::string CEBody::describe() const
+{
+ std::string msg = CESkyCoord::describe();
+ msg += " name: " + this->Name();
+ return msg;
+}
+
/*--------------------------------------------------*
* Private methods
*--------------------------------------------------*/
diff --git a/cppephem/src/CECoordinates.cpp b/cppephem/src/CECoordinates.cpp
index 68b35c49..4feb0348 100755
--- a/cppephem/src/CECoordinates.cpp
+++ b/cppephem/src/CECoordinates.cpp
@@ -1706,12 +1706,22 @@ void CECoordinates::SetCoordinates(const CECoordinates& coords)
* Generate a message string that specifies the information about this coordinate
* @return String describing this object
*************************************************************************/
-std::string CECoordinates::print(void) const
+const std::string CECoordinates::print(void) const
{
- std::string msg = "Coordinates:\n";
- msg += " - System : " + std::to_string(int(coord_type_)) + "\n";
- msg += " - X-coord: " + std::to_string(XCoordinate_Deg()) + " deg\n";
- msg += " - Y-coord: " + std::to_string(YCoordinate_Deg()) + " deg\n";
+ return this->describe();
+}
+
+
+/**********************************************************************//**
+ * Generate a message string that specifies the information about this coordinate
+ * @return String describing this object
+ *************************************************************************/
+const std::string CECoordinates::describe(void) const
+{
+ std::string msg = CEBase::describe() + "\n";
+ msg += " System : " + std::to_string(int(coord_type_)) + "\n";
+ msg += " X-coord: " + std::to_string(XCoordinate_Deg()) + " deg\n";
+ msg += " Y-coord: " + std::to_string(YCoordinate_Deg()) + " deg\n";
return msg;
}
diff --git a/cppephem/src/CECorrections.cpp b/cppephem/src/CECorrections.cpp
index 03026eb4..1b7c4809 100644
--- a/cppephem/src/CECorrections.cpp
+++ b/cppephem/src/CECorrections.cpp
@@ -234,6 +234,21 @@ void CECorrections::SetInterp(bool set_interp)
}
+/**********************************************************************//**
+ * Returns a message of the
+ *
+ * @param[in] set_interp New interpolation boolean
+ *************************************************************************/
+const std::string CECorrections::describe(void) const
+{
+ std::string msg = CEBase::describe() + "\n";
+ msg += " Nutation File : " + this->NutationFile() + "\n";
+ msg += " Historical TT-UT1: " + this->TtUt1HistFile() + "\n";
+ msg += " Predicted TT-UT1 : " + this->TtUt1PredFile();
+ return msg;
+}
+
+
/**********************************************************************//**
* Free data member objects
*************************************************************************/
diff --git a/cppephem/src/CEDate.cpp b/cppephem/src/CEDate.cpp
index abdb8c07..cda57103 100755
--- a/cppephem/src/CEDate.cpp
+++ b/cppephem/src/CEDate.cpp
@@ -145,7 +145,7 @@ void CEDate::SetDate(const double& date,
*************************************************************************/
void CEDate::SetDate(std::vector date)
{
- SetDate(GregorianVect2JD(date)) ;
+ SetDate(GregorianVect2JD(date), CEDateType::JD) ;
}
/**********************************************************************//**
@@ -670,6 +670,36 @@ CEDate::operator double() const
}
+/**********************************************************************//**
+ * Returns a string description of this date object
+ * @return description of this date object
+ *************************************************************************/
+const std::string CEDate::describe(void) const
+{
+ std::string msg(CEBase::describe() + "\n");
+ msg += " value: " + std::to_string(double(*this)) + "\n";
+ msg += " units: ";
+
+ // Append the coordinate type
+ switch (return_type_) {
+ case(CEDateType::JD):
+ msg += "julian date";
+ break;
+ case(CEDateType::MJD):
+ msg += "modified julian date";
+ break;
+ case(CEDateType::GREGORIAN):
+ msg += "Gregorian";
+ break;
+ default:
+ msg += "unknown";
+ break;
+ }
+
+ return msg;
+}
+
+
/**********************************************************************//**
* Free data members
*************************************************************************/
diff --git a/cppephem/src/CENamespace.cpp b/cppephem/src/CENamespace.cpp
index c38ac02c..71058ac5 100755
--- a/cppephem/src/CENamespace.cpp
+++ b/cppephem/src/CENamespace.cpp
@@ -95,7 +95,7 @@ void CppEphem::SetTtUt1PredFile(const std::string& filename)
/**********************************************************************//**
* Set the corrections object to use interpolation
*
- * @param[in] set_interp Specifiy whether or not to use interpolation
+ * @param[in] set_interp Specify whether or not to use interpolation
*************************************************************************/
void CppEphem::CorrectionsInterp(bool set_interp)
{
@@ -103,6 +103,28 @@ void CppEphem::CorrectionsInterp(bool set_interp)
}
+/**********************************************************************//**
+ * Turn on/off application of nutation correction values
+ *
+ * @param[in] use_nut Whether or not to use nutation corrections
+ *************************************************************************/
+void CppEphem::UseNutation(bool use_nut)
+{
+ CppEphem::use_nutation_ = use_nut;
+}
+
+
+/**********************************************************************//**
+ * Turn on/off application of TT-UT1 correction values
+ *
+ * @param[in] use_ttut1 Whether or not to use TT-UT1 corrections
+ *************************************************************************/
+void CppEphem::UseTtUt1(bool use_ttut1)
+{
+ CppEphem::use_nutation_ = use_ttut1;
+}
+
+
/**********************************************************************//**
* Return dut1 based on a given modified julian date (seconds)
*
@@ -114,7 +136,9 @@ double CppEphem::dut1(const double& mjd)
double dut1(0.0);
// Fill dut1 if support dir has been defined
- dut1 = CppEphem::corrections.dut1(mjd);
+ if (use_nutation_) {
+ dut1 = CppEphem::corrections.dut1(mjd);
+ }
return dut1;
}
@@ -148,7 +172,11 @@ double CppEphem::dut1Calc(const double& mjd)
*************************************************************************/
double CppEphem::xp(const double& mjd)
{
- return corrections.xpolar(mjd) ;
+ double xpolar(0.0);
+ if (use_nutation_) {
+ xpolar = corrections.xpolar(mjd);
+ }
+ return xpolar;
}
@@ -160,7 +188,11 @@ double CppEphem::xp(const double& mjd)
*************************************************************************/
double CppEphem::yp(const double& mjd)
{
- return corrections.ypolar(mjd);
+ double ypolar(0.0);
+ if (use_nutation_) {
+ ypolar = corrections.ypolar(mjd);
+ }
+ return ypolar;
}
@@ -172,7 +204,11 @@ double CppEphem::yp(const double& mjd)
*************************************************************************/
double CppEphem::deps(const double& mjd)
{
- return corrections.deps(mjd);
+ double deps(0.0);
+ if (use_nutation_) {
+ deps = corrections.deps(mjd);
+ }
+ return deps;
}
@@ -184,7 +220,11 @@ double CppEphem::deps(const double& mjd)
*************************************************************************/
double CppEphem::dpsi(const double& mjd)
{
- return corrections.dpsi(mjd);
+ double dpsi(0.0);
+ if (use_nutation_) {
+ dpsi = corrections.dpsi(mjd);
+ }
+ return dpsi;
}
@@ -196,7 +236,11 @@ double CppEphem::dpsi(const double& mjd)
*************************************************************************/
double CppEphem::ttut1(const double& mjd)
{
- return corrections.ttut1(mjd);
+ double ttut1(0.0);
+ if (use_ttut1_) {
+ ttut1 = corrections.ttut1(mjd);
+ }
+ return ttut1;
}
diff --git a/cppephem/src/CEObservation.cpp b/cppephem/src/CEObservation.cpp
index f89064ea..7c6595d7 100755
--- a/cppephem/src/CEObservation.cpp
+++ b/cppephem/src/CEObservation.cpp
@@ -172,6 +172,21 @@ bool CEObservation::UpdateCoordinates()
}
+/**********************************************************************//**
+ * Return description of this object
+ *
+ * @return Description of this object
+ *************************************************************************/
+const std::string CEObservation::describe(void) const
+{
+ std::string msg = CEBase::describe() + "\n";
+ msg += date_->describe() + "\n";
+ msg += observer_->describe() + "\n";
+ msg += body_->describe();
+ return msg;
+}
+
+
/**********************************************************************//**
* Copy data members from another object
*
diff --git a/cppephem/src/CEObserver.cpp b/cppephem/src/CEObserver.cpp
index 9f7f681b..247c0b6d 100755
--- a/cppephem/src/CEObserver.cpp
+++ b/cppephem/src/CEObserver.cpp
@@ -178,7 +178,17 @@ std::vector CEObserver::VelocityICRS(const CEDate& date) const
* Returns a string containing information about this object
* @return Formatted string containing information about this observer
*************************************************************************/
-std::string CEObserver::print(void) const
+const std::string CEObserver::print(void) const
+{
+ return this->describe();
+}
+
+
+/**********************************************************************//**
+ * Returns a string containing information about this object
+ * @return Formatted string containing information about this observer
+ *************************************************************************/
+const std::string CEObserver::describe(void) const
{
// Fill in the returned string with formatted strings
std::string msg("Observer:\n");
@@ -188,7 +198,7 @@ std::string CEObserver::print(void) const
msg += " Temp = " + std::to_string(Temperature_C()) + " C\n";
msg += " Pressure = " + std::to_string(Pressure_hPa()) + " hPa\n";
msg += " Humidity = " + std::to_string(RelativeHumidity()) + " %%\n";
- msg += " Wavelength= " + std::to_string(Wavelength_um()) + " um\n";
+ msg += " Wavelength= " + std::to_string(Wavelength_um()) + " um";
return msg;
}
diff --git a/cppephem/src/CEPlanet.cpp b/cppephem/src/CEPlanet.cpp
index 4431fdc3..79f3a345 100755
--- a/cppephem/src/CEPlanet.cpp
+++ b/cppephem/src/CEPlanet.cpp
@@ -471,6 +471,23 @@ CEPlanet CEPlanet::Pluto()
}
+/**********************************************************************//**
+ * Generate a message string that specifies the information about this planet
+ *
+ * @return String describing this object
+ *************************************************************************/
+const std::string CEPlanet::describe(void) const
+{
+ std::string msg = CEBase::describe() + "\n";
+ msg += " Name : " + this->Name() + "\n";
+ msg += " Algorithm: " + std::to_string(int(this->Algorithm())) + "\n";
+ msg += " Radius : " + std::to_string(Radius_m()) + " meters\n";
+ msg += " Mass : " + std::to_string(Mass_kg()) + " kg\n";
+ msg += " Albedo : " + std::to_string(Albedo());
+ return msg;
+}
+
+
/**********************************************************************//**
* Set the semi-major axis (in AU) and it's derivative
*
diff --git a/cppephem/src/CESkyCoord.cpp b/cppephem/src/CESkyCoord.cpp
index 361a63ec..5bf370f8 100644
--- a/cppephem/src/CESkyCoord.cpp
+++ b/cppephem/src/CESkyCoord.cpp
@@ -117,47 +117,28 @@ CESkyCoord& CESkyCoord::operator=(const CESkyCoord& other)
* @param[in] coords Another set of coordinates
* @return Angular separation between these coordinates and 'coords'
*************************************************************************/
-CEAngle CESkyCoord::AngularSeparation(const CESkyCoord& coords) const
-{
- return AngularSeparation(*this, coords);
-}
-
-
-/**********************************************************************//**
- * Get the angular separation between two coordinate objects.
- * NOTE: The coordinates are both expected to be in the same
- * coordinate system! If they are in different coordinate systems,
- * use "ConvertTo()" first.
- *
- * @param[in] coords1 First set of coordinates
- * @param[in] coords2 Second set of coordinates
- * @param[in] return_angle_type Specify whether to return angle as DEGREES or RADIANS
- * @return Angular separation between two coordiantes
- *
- * Note that the x-coordinates are expected in the range [0, 2pi] and the
- * y-coordinates are expected in the range [-pi, pi]. Because of this, OBSERVED
- * coordinates first convert the zenith angle to altitude
- *************************************************************************/
-CEAngle CESkyCoord::AngularSeparation(const CESkyCoord& coords1,
- const CESkyCoord& coords2)
+CEAngle CESkyCoord::Separation(const CESkyCoord& coords) const
{
// Make sure the coordinates are in the same frame
- if (coords1.GetCoordSystem() != coords2.GetCoordSystem()) {
- throw CEException::invalid_value("CESkyCoord::AngularSeparation(CESkyCoord&, CESkyCoord&)",
- "Supplied coordinates are in different frames");
+ if (this->GetCoordSystem() != coords.GetCoordSystem()) {
+ std::string msg = std::string("Supplied coordinates are in different frames") +
+ " (this => " + std::to_string(int(this->GetCoordSystem())) +
+ ", coords => " + std::to_string(int(coords.GetCoordSystem())) + ")";
+ throw CEException::invalid_value("CESkyCoord::Separation(CESkyCoord&)",
+ msg);
}
// Get the appropriate Y-Coordinates
- double y1 = coords1.YCoord().Rad();
- double y2 = coords2.YCoord().Rad();
- if (coords1.GetCoordSystem() == CESkyCoordType::OBSERVED) {
+ double y1 = this->YCoord().Rad();
+ double y2 = coords.YCoord().Rad();
+ if (this->GetCoordSystem() == CESkyCoordType::OBSERVED) {
y1 = M_PI_2 - y1;
y2 = M_PI_2 - y2;
}
// Convert the second coordinates to be the same type as the first set of coordinates
- return AngularSeparation(coords1.XCoord(), y1,
- coords2.XCoord(), y2);
+ return AngularSeparation(this->XCoord(), y1,
+ coords.XCoord(), y2);
}
@@ -1024,12 +1005,23 @@ void CESkyCoord::SetCoordinates(const CESkyCoord& coords)
*
* @return String describing this object
*************************************************************************/
-std::string CESkyCoord::print(void) const
+const std::string CESkyCoord::print(void) const
+{
+ return this->describe();
+}
+
+
+/**********************************************************************//**
+ * Generate a message string that specifies the information about this coordinate
+ *
+ * @return String describing this object
+ *************************************************************************/
+const std::string CESkyCoord::describe(void) const
{
- std::string msg = "Coordinates:\n";
- msg += " - System : " + std::to_string(int(coord_type_)) + "\n";
- msg += " - X-coord: " + std::to_string(xcoord_.Deg()) + " deg\n";
- msg += " - Y-coord: " + std::to_string(ycoord_.Deg()) + " deg\n";
+ std::string msg = CEBase::describe() + "\n";
+ msg += " System : " + std::to_string(int(coord_type_)) + "\n";
+ msg += " X-coord: " + std::to_string(xcoord_.Deg()) + " deg\n";
+ msg += " Y-coord: " + std::to_string(ycoord_.Deg()) + " deg\n";
return msg;
}
@@ -1083,7 +1075,7 @@ bool operator==(const CESkyCoord& lhs, const CESkyCoord& rhs)
// Check that the x-coordinate and the y-coordinate are the same
else {
// Check how far appart the coordinates are from each other
- CEAngle angsep = CESkyCoord::AngularSeparation(lhs, rhs);
+ CEAngle angsep = lhs.Separation(rhs);
// Currently require separation < 0.03 arcsec
double marcsec_rad = 4.848e-6;
if (angsep > 3.0*marcsec_rad) {
diff --git a/cppephem/src/CETime.cpp b/cppephem/src/CETime.cpp
index 95bd33c8..91d86fe7 100755
--- a/cppephem/src/CETime.cpp
+++ b/cppephem/src/CETime.cpp
@@ -243,10 +243,35 @@ void CETime::UTC2LAST()
*************************************************************************/
void CETime::UTC2LOCALTIME()
{
-
+ // TODO
+}
+
+
+/**********************************************************************//**
+ * Return string representing the angle in HH:MM:SS
+ *
+ * @param[in] delim Delimiter to use in output string
+ * @return Angle formatted as a string HH:MM:SS
+ *************************************************************************/
+std::string CETime::HmsStr(const char& delim) const
+{
+ // Assemble the string using the specified delimiter
+ return CppEphem::StrOpt::join_angle(time_, delim);
+}
+
+
+/**********************************************************************//**
+ * Return a description of this object
+ *
+ * @return Description of this object
+ *************************************************************************/
+const std::string CETime::describe(void) const
+{
+ std::string msg = CEBase::describe() + "\n";
+ msg += " Time: " + this->HmsStr();
+ return msg;
}
-# pragma mark - Protected Methods
/**********************************************************************//**
* Convert a time formatted as HHMMSS.SS into a vector.
@@ -308,10 +333,25 @@ double CETime::TimeSec2Time(const double& seconds)
// Now do the actual conversion to a vector
double fracsec = secs - std::floor(secs) ; // Fractions of a second
- double sec = int(std::floor(secs)) % 60 ; // Whole seconds
- double min = int(std::floor(secs-sec)/60) % 60 ; // Whole minutes
- double hrs = int(std::floor(secs-sec)/60)/60 ; // Whole hours
- return (hrs*10000) + (min*100) + sec + fracsec ; // Formatted double (HHMMSS.S)
+ int sec = int(std::floor(secs)) % 60 ; // Whole seconds
+ int min = int(std::floor(secs-sec)/60) % 60 ; // Whole minutes
+ int hrs = int(std::floor(secs-sec)/60)/60 ; // Whole hours
+
+ // Format the output and handle precision issues
+ double result = (hrs*10000) + (min*100) + sec + fracsec ; // Formatted double (HHMMSS.S)
+ if (int(result) % 100 >= 60.0) {
+ result -= 60;
+ result += 100;
+ }
+ if (int(result) % 10000 >= 6000) {
+ result -= 6000;
+ result += 10000;
+ }
+ if (result > 240000) {
+ result -= 240000;
+ }
+
+ return result;
}
/**********************************************************************//**
diff --git a/cppephem/src/CMakeLists.txt b/cppephem/src/CMakeLists.txt
index eefbc123..8789acf2 100755
--- a/cppephem/src/CMakeLists.txt
+++ b/cppephem/src/CMakeLists.txt
@@ -1,3 +1,23 @@
+#**************************************************************************
+# cppephem/src/CMakeLists.txt: CppEphem *
+# ----------------------------------------------------------------------- *
+# Copyright © 2017-2019 JCardenzana *
+# ----------------------------------------------------------------------- *
+# *
+# This program is free software: you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation, either version 3 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program. If not, see . *
+# *
+#**************************************************************************
#------------------------------------------
# Define include directories
diff --git a/cppephem/src/angsep.cpp b/cppephem/src/angsep.cpp
index 3c7e5710..1674ce68 100644
--- a/cppephem/src/angsep.cpp
+++ b/cppephem/src/angsep.cpp
@@ -55,7 +55,7 @@ int main(int argc, char** argv)
opts.AsDouble("ycoord2"),
opts.AsBool("InputDegrees"));
- CEAngle angsep = CESkyCoord::AngularSeparation(coord1, coord2);
+ CEAngle angsep = coord1.Separation(coord2);
// Figure out whether we need to convert the output angular separation
if (opts.AsBool("OutputDegrees")) {
diff --git a/cppephem/support/CEExecOptions.h b/cppephem/support/CEExecOptions.h
index 64a543be..7ed8d85e 100644
--- a/cppephem/support/CEExecOptions.h
+++ b/cppephem/support/CEExecOptions.h
@@ -6,6 +6,10 @@
#include "CppEphem.h"
#include "CLOptions.h"
+/** \class CEExecOptions
+ Class for providing options to CppEphem executables
+ */
+
class CEExecOptions : public CLOptions {
public:
diff --git a/cppephem/swig/CEAngle.i b/cppephem/swig/CEAngle.i
new file mode 100644
index 00000000..6cef9903
--- /dev/null
+++ b/cppephem/swig/CEAngle.i
@@ -0,0 +1,111 @@
+/***************************************************************************
+ * CEAngle.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CEAngle.i
+ * @brief SWIG file for CEAngle class
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CEAngle.h"
+%}
+
+/***********************************************************************//**
+ * @enum CEAngleType
+ *
+ * @brief CEAngleType enum class interface definition
+ ***************************************************************************/
+enum class CEAngleType : unsigned int {
+ DEGREES=0, ///< Degrees
+ RADIANS=1, ///< Radians
+ HMS=2, ///< Hours, minutes, seconds
+ DMS=3 ///< Degrees, arcmin, arcsec
+};
+
+/**
+ * CEAngle class
+ */
+class CEAngle : public CEBase {
+public:
+ // Constructors
+ CEAngle();
+ CEAngle(const double& angle);
+ explicit CEAngle(const CEAngle& other);
+ virtual ~CEAngle();
+
+ static CEAngle Hms(const char* angle_str,
+ const char& delim=0);
+ static CEAngle Hms(const std::vector& angle_vec);
+ static CEAngle Dms(const char* angle_str,
+ const char& delim=0);
+ static CEAngle Dms(const std::vector& angle_vec);
+
+ // Create from an angle value
+ static CEAngle Deg(const double& angle);
+ static CEAngle Rad(const double& angle);
+
+ // Methods to return a formatted value for the angle
+ /*!<
+ * Get the HMS formatted as a string
+ *
+ * \param delim delimiter
+ * \param not not a real par
+ */
+ std::string HmsStr(const char& delim=':') const;
+ std::vector HmsVect(void) const;
+ std::string DmsStr(const char& delim=':') const;
+ std::vector DmsVect(void) const;
+ double Deg(void) const;
+ double Rad(void) const;
+
+ // Generic methods for setting the angle
+ void SetAngle(const double& angle,
+ const CEAngleType& angle_type=CEAngleType::RADIANS);
+ void SetAngle(const char* angle_str,
+ const CEAngleType& angle_type,
+ const char& delim=0);
+ void SetAngle(const std::vector& angle_vec,
+ const CEAngleType& angle_type);
+
+ // Necessary methods
+ const std::string ClassName(void) const;
+ const std::string describe(void) const;
+
+};
+
+
+/***********************************************************************//**
+ * @brief CEAngle class extension
+ ***************************************************************************/
+%extend CEAngle {
+
+ // Add python specific functions
+ %pythoncode {
+ def __float__(self):
+ """
+ Return the angle in radians
+ """
+ return self.Rad()
+ }
+
+};
\ No newline at end of file
diff --git a/cppephem/swig/CEBase.i b/cppephem/swig/CEBase.i
new file mode 100644
index 00000000..b51dd93f
--- /dev/null
+++ b/cppephem/swig/CEBase.i
@@ -0,0 +1,64 @@
+/***************************************************************************
+ * CEBase.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CEBase.i
+ * @brief SWIG file for CEBase class
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CEBase.h"
+%}
+
+
+/***********************************************************************//**
+ * @class CEBase
+ *
+ * @brief CEBase class SWIG interface definition
+ ***************************************************************************/
+class CEBase {
+public:
+ // Constructors
+ CEBase();
+ virtual ~CEBase();
+
+ virtual const std::string ClassName(void) const = 0;
+ virtual const std::string describe(void) const;
+
+};
+
+
+/***********************************************************************//**
+ * Extend CEBase class
+ ***************************************************************************/
+%extend CEBase {
+
+ %pythoncode {
+ def __str__(self):
+ """
+ Returns a description of this object
+ """
+ return (self.describe())
+ }
+
+};
\ No newline at end of file
diff --git a/cppephem/swig/CEBody.i b/cppephem/swig/CEBody.i
new file mode 100644
index 00000000..b82d70a3
--- /dev/null
+++ b/cppephem/swig/CEBody.i
@@ -0,0 +1,67 @@
+/***************************************************************************
+ * CEBody.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CEBody.i
+ * @brief SWIG file for CEBody class
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CEBody.h"
+%}
+
+/***********************************************************************//**
+ * @class CEBody
+ *
+ * @brief CEBody class SWIG interface definition
+ ***************************************************************************/
+class CEBody : public CESkyCoord {
+public:
+ /************************************
+ * Basic constructors & destructors
+ ***********************************/
+ CEBody() ;
+ CEBody(const std::string& name,
+ const CEAngle& xcoord,
+ const CEAngle& ycoord,
+ const CESkyCoordType& coord_type=CESkyCoordType::ICRS);
+ CEBody(const CEBody& other,
+ const std::string& name="");
+ CEBody(const CESkyCoord& coords,
+ const std::string& name="");
+ virtual ~CEBody();
+
+ /************************************
+ * Public methods
+ ***********************************/
+
+ virtual CESkyCoord GetCoordinates(const CEDate& date=CEDate::CurrentJD()) const;
+ virtual CESkyCoord ObservedCoords(const CEDate& date,
+ const CEObserver& observer) const;
+ std::string Name(void) const;
+ void SetName(const std::string& new_name);
+
+ // Necessary methods
+ const std::string ClassName(void) const;
+ const std::string describe(void) const;
+};
diff --git a/cppephem/swig/CECorrections.i b/cppephem/swig/CECorrections.i
new file mode 100644
index 00000000..2de44b09
--- /dev/null
+++ b/cppephem/swig/CECorrections.i
@@ -0,0 +1,62 @@
+/***************************************************************************
+ * CECorrections.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CECorrections.i
+ * @brief SWIG file for CECorrections class
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CECorrections.h"
+%}
+
+
+/***********************************************************************//**
+ * @class CECorrections
+ *
+ * @brief CECorrections class SWIG interface definition
+ ***************************************************************************/
+class CECorrections {
+public:
+ CECorrections();
+ CECorrections(const CECorrections& other);
+ virtual ~CECorrections() {}
+
+ double dut1(const double& mjd) const;
+ double xpolar(const double& mjd) const;
+ double ypolar(const double& mjd) const;
+ double deps(const double& mjd) const;
+ double dpsi(const double& mjd) const;
+ double ttut1(const double& mjd) const;
+ std::string NutationFile(void) const;
+ std::string TtUt1HistFile(void) const;
+ std::string TtUt1PredFile(void) const;
+ void SetNutationFile(const std::string& filename);
+ void SetTtUt1HistFile(const std::string& filename);
+ void SetTtUt1PredFile(const std::string& filename);
+ void SetInterp(bool set_interp);
+
+ // Necessary methods
+ const std::string ClassName(void) const;
+ const std::string describe(void) const;
+};
diff --git a/cppephem/swig/CEDate.i b/cppephem/swig/CEDate.i
new file mode 100644
index 00000000..0a265d53
--- /dev/null
+++ b/cppephem/swig/CEDate.i
@@ -0,0 +1,160 @@
+/***************************************************************************
+ * CEDate.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CEDate.i
+ * @brief SWIG file for CEDate class
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CEDate.h"
+%}
+
+/**********************************************************************//**
+ * Date enum
+ *************************************************************************/
+enum class CEDateType : unsigned int {
+ JD=0, ///< Julian Date
+ MJD=1, ///< Modified Julian Date
+ GREGORIAN=2 ///< Gregorian calendar (year, month, day)
+};
+
+/***********************************************************************//**
+ * @class CEDate
+ *
+ * @brief CEDate class SWIG interface definition
+ ***************************************************************************/
+class CEDate : public CEBase {
+public:
+ // Default constructor
+ CEDate(double date=CurrentJD(), CEDateType date_format=CEDateType::JD) ;
+ explicit CEDate(std::vector date) ;
+ explicit CEDate(const CEDate& other) ;
+ virtual ~CEDate();
+
+ // Method that can be used to change the date that is stored in this object
+ virtual void SetDate(const double& date=CurrentJD(),
+ const CEDateType& time_format=CEDateType::JD) ;
+ // Method for setting the dates from the Gregorian calendar dates
+ virtual void SetDate(std::vector date) ;
+
+ /***********************************************************
+ * Methods for getting the stored date in the various formats
+ ***********************************************************/
+ double GetDate(CEDateType time_format=CEDateType::JD) const;
+ virtual double JD() const;
+ virtual double MJD() const;
+ virtual double Gregorian() const;
+ virtual std::vector GregorianVect();
+ int Year();
+ int Month();
+ int Day();
+ double DayFraction();
+
+ /***********************************************************
+ * Methods for converting between different formats
+ ***********************************************************/
+ static double Gregorian2JD(double gregorian);
+ static double GregorianVect2JD(std::vector gregorian);
+ static double Gregorian2MJD(double gregorian);
+ static double GregorianVect2MJD(std::vector gregorian);
+ static double JD2MJD(double jd);
+ static double JD2Gregorian(const double jd);
+ static std::vector JD2GregorianVect(double jd);
+ static double MJD2JD(double mjd);
+ static double MJD2Gregorian(double mjd);
+ static std::vector MJD2GregorianVect(double mjd);
+ static void UTC2UT1(const double& mjd,
+ double* ut11,
+ double* ut12) ;
+ static void UTC2TT(const double& mjd,
+ double* tt1,
+ double* tt2) ;
+ static void UTC2TDB(const double& mjd,
+ double* tdb1,
+ double* tdb2) ;
+
+ /***********************************************************
+ * Some useful helper methods
+ ***********************************************************/
+
+ static double GetMJD2JDFactor();
+ static double dut1(const double& date,
+ const CEDateType& date_type=CEDateType::JD) ;
+ double dut1(void) const;
+ // static double dut1Error(double date, CEDateType date_type=CEDateType::JD) ;
+ // double dut1Error() ;
+ static double xpolar(const double& date,
+ const CEDateType& date_type=CEDateType::JD) ;
+ double xpolar(void) const;
+ static double ypolar(const double& date,
+ const CEDateType& date_type=CEDateType::JD) ;
+ double ypolar(void) const;
+
+ static double GregorianVect2Gregorian(std::vector gregorian) ;
+ static std::vector Gregorian2GregorianVect(double gregorian) ;
+ virtual double GetSecondsSinceMidnight(const double& utc_offset=0.0) ;
+ virtual double GetTime(const double& utc_offset=0.0) const;
+ virtual double GetTime_UTC() const;
+ static double CurrentJD();
+ const CEDateType ReturnType() const;
+ void SetReturnType(CEDateType return_type);
+
+ // Necessary methods
+ const std::string ClassName(void) const;
+ const std::string describe(void) const;
+
+};
+
+
+/**********************************************************************//**
+ * Add some extra functionality
+ *************************************************************************/
+%extend CEDate {
+
+ // Add python specific functions
+ %pythoncode {
+ import datetime
+ def SetDatetime(self, date):
+ """
+ Set the CEDate object from a Python datetime.datetime object
+
+ Parameters
+ ----------
+ date : datetime.datetime
+ Python datetime.datetime object
+ """
+ day_frac = ((date.hour / 24.0) +
+ (date.minute / 1440.0) +
+ (date.second / 86400.0))
+ gregorian_day = [date.year, date.month, date.day, day_frac]
+
+ self.SetDate(gregorian_day)
+
+ def __float__(self):
+ """
+ Returns a float representation of this object
+ """
+ return self.GetDate(self.ReturnType())
+ }
+};
\ No newline at end of file
diff --git a/cppephem/swig/CEException.i b/cppephem/swig/CEException.i
new file mode 100644
index 00000000..06625e59
--- /dev/null
+++ b/cppephem/swig/CEException.i
@@ -0,0 +1,63 @@
+/***************************************************************************
+ * CEException.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CEException.i
+ * @brief SWIG file for CEException class
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CEException.h"
+%}
+%include exception.i
+
+%exception {
+ try {
+ $action
+ }
+ catch (const CEException::invalid_value& e) {
+ SWIG_exception(SWIG_ValueError, e.what());
+ }
+ catch (const CEException::invalid_delimiter& e) {
+ SWIG_exception(SWIG_ValueError, e.what());
+ }
+ catch (const CEException::corr_file_load_error& e) {
+ SWIG_exception(SWIG_IOError, e.what());
+ }
+ catch (const CEException::sofa_error& e) {
+ SWIG_exception(SWIG_ValueError, e.what());
+ }
+ catch (const CEException::sofa_exception& e) {
+ SWIG_exception(SWIG_RuntimeError, e.what());
+ }
+ catch (const CEException& e) {
+ SWIG_exception(SWIG_RuntimeError, e.what());
+ }
+ catch (const std::exception& e) {
+ SWIG_exception(SWIG_RuntimeError, e.what());
+ }
+ catch (...) {
+ SWIG_exception(SWIG_RuntimeError, "unknown exception");
+ }
+};
+
diff --git a/cppephem/swig/CENamespace.i b/cppephem/swig/CENamespace.i
new file mode 100644
index 00000000..9e0d119e
--- /dev/null
+++ b/cppephem/swig/CENamespace.i
@@ -0,0 +1,102 @@
+/***************************************************************************
+ * CENamespace.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+%{
+#include
+#include "CECorrections.h"
+%}
+
+/***********************************************************************//**
+ * CENamespace
+ *
+ * @brief CENamespace namespace SWIG interface definition
+ ***************************************************************************/
+namespace CppEphem {
+ // Define an angle type so that we can differentiate between degrees or radians
+
+ // Approximate temperature at sea-level in Kelvin
+ inline double SeaLevelTemp_K() {return 288.2 ;}
+ inline double SeaLevelTemp_C() {return SeaLevelTemp_K()-273.15 ;}
+ inline double SeaLevelTemp_F() {return (1.8*SeaLevelTemp_C())+32.0 ;}
+
+ // Temperature conversion methods
+ inline double Temp_C2F(const double& temp_C) {return (1.8 * temp_C) + 32.0;}
+ inline double Temp_C2K(const double& temp_C) {return temp_C+273.15;}
+ inline double Temp_F2C(const double& temp_F) {return (temp_F - 32.0)/1.8;}
+ inline double Temp_F2K(const double& temp_F) {return Temp_C2K(Temp_F2C(temp_F));}
+ inline double Temp_K2C(const double& temp_K) {return temp_K - 273.15;}
+ inline double Temp_K2F(const double& temp_K) {return 1.8*temp_K-459.67;}
+
+ // Some constants taken from the sofa dictionary, but with some more discriptive names
+ inline double julian_date_J2000() {return DJ00 ;} ///< Julian Date corresponding to J2000
+ inline double c() {return DC * DAU / DAYSEC ;} ///< speed of light (meters/second)
+ inline double c_au_per_day() {return DC ;} ///< speed of light (astronomical units)/day
+ inline double m_per_au() {return DAU ;} ///< meters per astronomical unit
+ inline double sec_per_day() {return DAYSEC;} ///< Seconds per day
+
+ /*********************************************
+ * Return the 'dut1' value which represents
+ * 'UT1-UTC' for a given MJD or it's error
+ *********************************************/
+ double dut1(const double& mjd) ;
+ double dut1Error(const double& mjd=51544.5) ;
+ double dut1Calc(const double& mjd) ;
+
+ /*********************************************
+ * Polar Motion methods
+ * For the moment, 0.0 should be sufficient. This
+ * assumption may need to be revisited
+ *********************************************/
+ double xp(const double& mjd);
+ double yp(const double& mjd);
+
+ /*********************************************
+ * Earth longitude & obliquity correction
+ *********************************************/
+ double deps(const double& mjd);
+ double dpsi(const double& mjd);
+
+ /*********************************************
+ * TT-UT1 correction
+ *********************************************/
+ double ttut1(const double& mjd);
+
+ /** Method for estimating altitude (in meters) from atmospheric pressure (in hPa) */
+ inline double EstimateAltitude_m(double pressure_hPa)
+ {return -29.3 * SeaLevelTemp_K() * std::log(pressure_hPa/1013.25) ;}
+ /** Method for estimating atmospheric pressure (in hPa) from altitude (in meters) */
+ inline double EstimatePressure_hPa(double elevation_m)
+ {return 1013.25 * std::exp(-elevation_m / (29.3*SeaLevelTemp_K() )) ;}
+
+ // Methods for getting the corrections values
+ std::string NutationFile(void);
+ std::string TtUt1HistFile(void);
+ std::string TtUt1PredFile(void);
+ void SetNutationFile(const std::string& filename);
+ void SetTtUt1HistFile(const std::string& filename);
+ void SetTtUt1PredFile(const std::string& filename);
+ void CorrectionsInterp(bool set_interp);
+ static CECorrections corrections;
+ void UseNutation(bool use_nut);
+ void UseTtUt1(bool use_ttut1);
+ static bool use_nutation_ = true;
+ static bool use_ttut1_ = true;
+}
diff --git a/cppephem/swig/CEObservation.i b/cppephem/swig/CEObservation.i
new file mode 100644
index 00000000..2017334c
--- /dev/null
+++ b/cppephem/swig/CEObservation.i
@@ -0,0 +1,77 @@
+/***************************************************************************
+ * CEObservation.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CEObservation.i
+ * @brief CppEphem observer description class SWIG file
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CEObservation.h"
+%}
+
+
+/***********************************************************************//**
+ * @class CEObservation
+ *
+ * @brief CEObservation class SWIG interface definition
+ ***************************************************************************/
+class CEObservation : public CEBase {
+public:
+ // Constructors
+ CEObservation() ;
+ CEObservation(CEObserver* observer, CEBody* body, CEDate* date);
+ CEObservation(const CEObservation& other);
+ virtual ~CEObservation() ;
+
+ // Setting underlying object pointers
+ virtual void SetObserver(CEObserver* new_observer);
+ virtual void SetBody(CEBody* new_body);
+ virtual void SetDate(CEDate* new_date);
+
+ /// Access the underlying objects
+ CEObserver* Observer();
+ CEBody* Body();
+ CEDate* Date();
+ virtual double GetAzimuth_Rad();
+ virtual double GetAzimuth_Deg();
+ virtual double GetZenith_Rad();
+ virtual double GetZenith_Deg();
+ virtual double GetAltitude_Rad();
+ virtual double GetAltitude_Deg();
+ virtual double GetHourAngle_Rad();
+ virtual double GetHourAngle_Deg();
+ virtual double GetApparentXCoordinate_Rad();
+ virtual double GetApparentXCoordinate_Deg();
+ virtual double GetApparentYCoordinate_Rad();
+ virtual double GetApparentYCoordinate_Deg();
+ virtual void GetAzimuthZenith_Rad(double *azimuth, double *zenith);
+ virtual void GetAzimuthZenith_Deg(double *azimuth, double *zenith);
+ virtual void GetApparentXYCoordinate_Rad(double *apparent_X, double *apparent_Y);
+ virtual void GetApparentXYCoordinate_Deg(double *apparent_X, double *apparent_Y);
+ bool UpdateCoordinates();
+
+ // Necessary methods
+ const std::string ClassName(void) const;
+ const std::string describe(void) const;
+};
\ No newline at end of file
diff --git a/cppephem/swig/CEObserver.i b/cppephem/swig/CEObserver.i
new file mode 100644
index 00000000..7617ac12
--- /dev/null
+++ b/cppephem/swig/CEObserver.i
@@ -0,0 +1,112 @@
+/***************************************************************************
+ * CEObserver.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CEObserver.i
+ * @brief CppEphem observer description class SWIG file
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CEObserver.h"
+%}
+
+
+/***********************************************************************//**
+ * @class CEObserver
+ *
+ * @brief CEObserver class SWIG interface definition
+ ***************************************************************************/
+class CEObserver {
+public:
+ CEObserver(void) ;
+ CEObserver(const double& longitude,
+ const double& latitude,
+ const double& elevation,
+ const CEAngleType& angle_type = CEAngleType::DEGREES) ;
+ CEObserver(const CEObserver& other) ;
+ virtual ~CEObserver(void) ;
+
+ /****************************************************
+ * Methods for accessing the underlying observer info
+ ****************************************************/
+ double Longitude_Rad() const;
+ double Longitude_Deg() const;
+ double Latitude_Rad() const;
+ double Latitude_Deg() const;
+ double Elevation_m() const;
+ double Pressure_hPa() const;
+ double Temperature_C() const;
+ double Temperature_K() const;
+ double Temperature_F() const;
+ double RelativeHumidity() const;
+ double Wavelength_um() const;
+ void SetUTCOffset(const double& utc_offset);
+ double UTCOffset() const;
+ std::vector Time(const CEDate& date);
+ std::vector Time_UTC(const CEDate& date);
+
+ /****************************************************
+ * Methods for setting the underlying observer info
+ ****************************************************/
+ void SetElevation(const double& elevation=0.0);
+ void SetLongitude(const double& longitude,
+ const CEAngleType& angle_type=CEAngleType::RADIANS);
+ void SetLatitude(const double& latitude,
+ const CEAngleType& angle_type=CEAngleType::RADIANS);
+ void SetGeoCoordinates(const double& longitude,
+ const double& latitude,
+ const CEAngleType& angle_type=CEAngleType::RADIANS);
+ void SetPressure_hPa(const double& pressure=CppEphem::EstimatePressure_hPa(CppEphem::SeaLevelTemp_C()));
+ void SetRelativeHumidity(const double& humidity=0.0);
+ void SetTemperature_C(const double& temp_C=CppEphem::SeaLevelTemp_C());
+ void SetTemperature_K(const double& temp_K=CppEphem::SeaLevelTemp_K());
+ void SetTemperature_F(const double& temp_F=CppEphem::SeaLevelTemp_F());
+ void SetWavelength_um(const double& new_wavelength_um);
+
+ /****************************************************
+ * Methods for getting observer position and velocity
+ * vectors relative to CIRS and ICRS coordinates
+ ****************************************************/
+ std::vector PositionGeo(void) const;
+ std::vector PositionCIRS(const CEDate& date) const;
+ std::vector PositionICRS(const CEDate& date) const;
+ std::vector VelocityCIRS(const CEDate& date) const;
+ std::vector VelocityICRS(const CEDate& date) const;
+
+ const std::string describe() const;
+};
+
+
+/***********************************************************************//**
+ * @brief CEObserver class extension
+ ***************************************************************************/
+%extend CEObserver {
+
+ %pythoncode {
+ def __str__(self):
+ """
+ Returns a description of the observer
+ """
+ return (self.describe());
+ }
+}
\ No newline at end of file
diff --git a/cppephem/swig/CERunningDate.i b/cppephem/swig/CERunningDate.i
new file mode 100644
index 00000000..bafb5bb5
--- /dev/null
+++ b/cppephem/swig/CERunningDate.i
@@ -0,0 +1,57 @@
+/***************************************************************************
+ * CERunningDate.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CERunningDate.i
+ * @brief SWIG file for CERunningDate class
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CERunningDate.h"
+%}
+
+/***********************************************************************//**
+ * @class CERunningDate
+ *
+ * @brief CERunningDate class SWIG interface definition
+ ***************************************************************************/
+class CERunningDate : public CEDate {
+public:
+ CERunningDate() ;
+ CERunningDate(const CERunningDate& other);
+ virtual ~CERunningDate() ;
+
+ // Some overloaded methods to make sure that the current
+ // values are obtained first
+ virtual double JD() const;
+ virtual double MJD() const;
+ virtual double Gregorian() const;
+
+ /// Method for getting the number of seconds since this object was created or reset
+ virtual double RunTime(void) const;
+ double ScaledRunTime(void) const;
+ void ResetTime(void);
+ virtual double GetTimerSpeed(void) const;
+ virtual void SetTimerSpeed(const double& scale=1.0);
+
+};
diff --git a/cppephem/swig/CESkyCoord.i b/cppephem/swig/CESkyCoord.i
new file mode 100644
index 00000000..bed66c65
--- /dev/null
+++ b/cppephem/swig/CESkyCoord.i
@@ -0,0 +1,197 @@
+/***************************************************************************
+ * CESkyCoord.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CESkyCoord.i
+ * @brief CppEphem Coordinate conversion class SWIG file
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CESkyCoord.h"
+%}
+
+/***********************************************************************//**
+ * @enum CESkyCoordType
+ *
+ * @brief CESkyCoordType enum class interface definition
+ ***************************************************************************/
+enum class CESkyCoordType : unsigned int {
+ CIRS=0, ///< RA, Dec (referenced at the center of the Earth)
+ ICRS=1, ///< RA, Dec (referenced at the barycenter of the solarsystem)
+ GALACTIC=2, ///< Galacitc longitude, latitude
+ OBSERVED=3, ///< Azimuth, Zenith (requires additional observer information)
+ ECLIPTIC=4 ///< Ecliptic longitude, latitude
+};
+
+/***********************************************************************//**
+ * @class CESkyCoord
+ *
+ * @brief CESkyCoord class SWIG interface definition
+ ***************************************************************************/
+class CESkyCoord {
+public:
+
+ /****** CONSTRUCTORS ******/
+ CESkyCoord() ;
+ CESkyCoord(const CEAngle& xcoord,
+ const CEAngle& ycoord,
+ const CESkyCoordType& coord_type=CESkyCoordType::ICRS) ;
+ explicit CESkyCoord(const CECoordinates& other);
+ CESkyCoord(const CESkyCoord& other) ;
+ virtual ~CESkyCoord() ;
+
+ /*********************************************************
+ * Angular separation between two coordinate positions
+ *********************************************************/
+ virtual CEAngle Separation(const CESkyCoord& coords) const;
+ static CEAngle AngularSeparation(const CEAngle& xcoord_first,
+ const CEAngle& ycoord_first,
+ const CEAngle& xcoord_second,
+ const CEAngle& ycoord_second);
+
+ /**********************************************************
+ * Methods for accessing the coordinate information
+ **********************************************************/
+
+ virtual CEAngle XCoord(const CEDate& jd=CppEphem::julian_date_J2000()) const;
+ virtual CEAngle YCoord(const CEDate& jd=CppEphem::julian_date_J2000()) const;
+
+ // Return coordinate system
+ CESkyCoordType GetCoordSystem(void) const;
+
+ /**********************************************************
+ * Methods for converting between coordinate types
+ **********************************************************/
+ // Note that whenever a date is required, the default will be set to the
+ // start of the J2000 epoch (January 1, 2000 at 12:00 GMT). This corresponds
+ // to the Julian Date of 2451545.0.
+
+ // Convert from CIRS to other coordinates
+ static void CIRS2ICRS(const CESkyCoord& in_cirs,
+ CESkyCoord* out_icrs,
+ const CEDate& date);
+ static void CIRS2Galactic(const CESkyCoord& in_cirs,
+ CESkyCoord* out_galactic,
+ const CEDate& date);
+ static void CIRS2Observed(const CESkyCoord& in_cirs,
+ CESkyCoord* out_observed,
+ const CEDate& date,
+ const CEObserver& observer,
+ CESkyCoord* observed_cirs=nullptr,
+ CEAngle* hour_angle=nullptr);
+ static void CIRS2Ecliptic(const CESkyCoord& in_cirs,
+ CESkyCoord* out_ecliptic,
+ const CEDate& date);
+
+ // Convert from ICRS to other coordinates
+ static void ICRS2CIRS(const CESkyCoord& in_icrs,
+ CESkyCoord* out_cirs,
+ const CEDate& date);
+ static void ICRS2Galactic(const CESkyCoord& in_icrs,
+ CESkyCoord* out_galactic);
+ static void ICRS2Observed(const CESkyCoord& in_icrs,
+ CESkyCoord* out_observed,
+ const CEDate& date,
+ const CEObserver& observer,
+ CESkyCoord* observed_cirs=nullptr,
+ CEAngle* hour_angle=nullptr);
+ static void ICRS2Ecliptic(const CESkyCoord& in_icrs,
+ CESkyCoord* out_ecliptic,
+ const CEDate& date=CEDate());
+
+ // Convert from GALACTIC to other coordinates
+ static void Galactic2CIRS(const CESkyCoord& in_galactic,
+ CESkyCoord* out_cirs,
+ const CEDate& date=CEDate());
+ static void Galactic2ICRS(const CESkyCoord& in_galactic,
+ CESkyCoord* out_icrs);
+ static void Galactic2Observed(const CESkyCoord& in_galactic,
+ CESkyCoord* out_observed,
+ const CEDate& date,
+ const CEObserver& observer,
+ CESkyCoord* observed_galactic=nullptr,
+ CEAngle* hour_angle=nullptr);
+ static void Galactic2Ecliptic(const CESkyCoord& in_galactic,
+ CESkyCoord* out_ecliptic,
+ const CEDate& date=CEDate());
+
+ // Convert from OBSERVED to other coordinates
+ static void Observed2CIRS(const CESkyCoord& in_observed,
+ CESkyCoord* out_cirs,
+ const CEDate& date,
+ const CEObserver& observer);
+ static void Observed2ICRS(const CESkyCoord& in_observed,
+ CESkyCoord* out_icrs,
+ const CEDate& date,
+ const CEObserver& observer);
+ static void Observed2Galactic(const CESkyCoord& in_observed,
+ CESkyCoord* out_galactic,
+ const CEDate& date,
+ const CEObserver& observer);
+ static void Observed2Ecliptic(const CESkyCoord& in_observed,
+ CESkyCoord* out_ecliptic,
+ const CEDate& date,
+ const CEObserver& observer);
+
+ // Convert from ECLIPTIC to other coordinates
+ static void Ecliptic2CIRS(const CESkyCoord& in_ecliptic,
+ CESkyCoord* out_cirs,
+ const CEDate& date=CEDate());
+ static void Ecliptic2ICRS(const CESkyCoord& in_ecliptic,
+ CESkyCoord* out_icrs,
+ const CEDate& date=CEDate());
+ static void Ecliptic2Galactic(const CESkyCoord& in_ecliptic,
+ CESkyCoord* out_galactic,
+ const CEDate& date=CEDate());
+ static void Ecliptic2Observed(const CESkyCoord& in_ecliptic,
+ CESkyCoord* out_observed,
+ const CEDate& date,
+ const CEObserver& observer);
+
+ /*********************************************************
+ * More generic methods for converting between coordinate types
+ *********************************************************/
+ CESkyCoord ConvertTo(const CESkyCoordType& output_coord_type,
+ const CEDate& date=CEDate(),
+ const CEObserver& observer=CEObserver());
+ CESkyCoord ConvertToCIRS(const CEDate& date=CEDate(),
+ const CEObserver& observer=CEObserver());
+ CESkyCoord ConvertToICRS(const CEDate& date=CEDate(),
+ const CEObserver& observer=CEObserver());
+ CESkyCoord ConvertToGalactic(const CEDate& date=CEDate(),
+ const CEObserver& observer=CEObserver());
+ CESkyCoord ConvertToObserved(const CEDate& date=CEDate(),
+ const CEObserver& observer=CEObserver());
+ CESkyCoord ConvertToEcliptic(const CEDate& date=CEDate(),
+ const CEObserver& observer=CEObserver());
+
+ /*********************************************************
+ * Methods for setting the coordinates of this object
+ *********************************************************/
+ virtual void SetCoordinates(const CEAngle& xcoord,
+ const CEAngle& ycoord,
+ const CESkyCoordType& coord_type=CESkyCoordType::ICRS) const;
+ virtual void SetCoordinates(const CESkyCoord& coords);
+
+ virtual const std::string describe(void) const;
+};
diff --git a/cppephem/swig/CETime.i b/cppephem/swig/CETime.i
new file mode 100644
index 00000000..2d8171f1
--- /dev/null
+++ b/cppephem/swig/CETime.i
@@ -0,0 +1,109 @@
+/***************************************************************************
+ * CETime.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file CETime.i
+ * @brief SWIG file for CETime class
+ * @author JCardenzana
+ */
+%{
+/* Put headers and other declarations here that are needed for compilation */
+// CppEphem HEADERS
+#include "CETime.h"
+%}
+
+/**********************************************************************//**
+ * Time type enum
+ *************************************************************************/
+enum class CETimeType : unsigned int {
+ UTC = 0, ///< Coordinate Universal Time
+ GAST = 1, ///< Greenwich Apparent Sidereal Time
+ LAST = 2, ///< Local Apparent Sidereal Time
+ LOCALTIME = 3 ///< Local time (defined as the UTC + timezone_shift_)
+};
+
+class CETime {
+public:
+ // Default constructor
+ CETime();
+ CETime(const double& time,
+ CETimeType time_format=CETimeType::UTC);
+ CETime(std::vector time,
+ CETimeType time_format=CETimeType::UTC);
+ CETime(const CETime& other);
+ virtual ~CETime();
+
+ /*******************************************
+ * Get the time
+ *******************************************/
+
+ double Hour(void) const;
+ double Min(void) const;
+ double Sec(void) const;
+
+ static double CurrentUTC() ;
+ static std::vector CurrentUTC_vect() ;
+ static double UTC(const double& jd) ;
+ static std::vector UTC_vect(const double& jd) ;
+
+ // Convert a double of the form HHMMSS.S to a vector with
+ // the same format as 'time_'
+ static std::vector TimeDbl2Vect(const double& time) ;
+ static double TimeVect2Dbl(std::vector time) ;
+
+ // Convert number of seconds since midnight to HHMMSS.S formatted double
+ static double TimeSec2Time(const double& seconds) ;
+ static std::vector TimeSec2Vect(const double& seconds) ;
+
+ static double SystemUTCOffset_hrs()
+ {
+ time_t now ;
+ time (&now) ;
+ struct tm local;
+ localtime_r(&now, &local) ;
+ return local.tm_gmtoff/3600.0;
+ }
+
+ /*******************************************
+ * Convert between the various time types
+ *******************************************/
+
+ void SetTime(const double& time,
+ CETimeType time_format=CETimeType::UTC) ;
+ void SetTime(std::vector time_vect,
+ CETimeType time_format=CETimeType::UTC) ;
+ void SetHours(const double& hours)
+ {time_[0] = hours ;}
+ void SetMinutes(const double& minutes)
+ {time_[1] = minutes ;}
+ void SetSeconds(const double& seconds)
+ {time_[2] = std::floor(seconds) ;
+ time_[3] = seconds-time_[2] ;}
+
+ /*******************************************
+ * Convert between the various time types
+ *******************************************/
+
+ // UTC conversions
+ static void UTC2GAST() ;
+ static void UTC2LAST() ;
+ static void UTC2LOCALTIME() ;
+};
\ No newline at end of file
diff --git a/cppephem/swig/CMakeLists.txt b/cppephem/swig/CMakeLists.txt
new file mode 100644
index 00000000..f3cb91ef
--- /dev/null
+++ b/cppephem/swig/CMakeLists.txt
@@ -0,0 +1,60 @@
+#**************************************************************************
+# cppephem/swig/CMakeLists.txt: CppEphem *
+# ----------------------------------------------------------------------- *
+# Copyright © 2019 JCardenzana *
+# ----------------------------------------------------------------------- *
+# *
+# This program is free software: you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation, either version 3 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program. If not, see . *
+# *
+#**************************************************************************
+
+if (python-bindings OR javascript-bindings)
+
+ FIND_PACKAGE(SWIG REQUIRED)
+ INCLUDE(${SWIG_USE_FILE})
+
+ # Set the include directories
+ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}
+ ${CMAKE_SOURCE_DIR}/cppephem/include)
+
+ SET(swig_files
+ cppephem.i
+ CEAngle.i
+ CEBody.i
+ CECorrections.i
+ CEDate.i
+ CEException.i
+ CENamespace.i
+ CEObservation.i
+ CEObserver.i
+ CERunningDate.i
+ CESkyCoord.i
+ CETime.i)
+
+ add_custom_target(swig-target ALL DEPENDS ${swig_files})
+
+ foreach(item IN LISTS swig_files)
+ add_custom_command(
+ TARGET swig-target PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/${item}" "${CMAKE_CURRENT_BINARY_DIR}/${item}"
+ DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${item}"
+ )
+ endforeach()
+
+ # Python wrapper
+ if (python-bindings)
+ add_subdirectory (pyext)
+ endif()
+
+endif()
\ No newline at end of file
diff --git a/cppephem/swig/cppephem.i b/cppephem/swig/cppephem.i
new file mode 100644
index 00000000..957b4825
--- /dev/null
+++ b/cppephem/swig/cppephem.i
@@ -0,0 +1,51 @@
+/***************************************************************************
+ * cppephem.i: CppEphem *
+ * ----------------------------------------------------------------------- *
+ * Copyright © 2019 JCardenzana *
+ * ----------------------------------------------------------------------- *
+ * *
+ * This program is free software: you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation, either version 3 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program. If not, see . *
+ * *
+ ***************************************************************************/
+
+/**
+ * @file cppephem.i
+ * @brief Top level CppEphem SWIG file
+ * @author JCardenzana
+ */
+%module(directors="1") cppephem
+
+// Generate very detailed documentation
+//%feature("autodoc", "3");
+%feature("director");
+
+/* Standard typemaps */
+%include stl.i
+%include std_string.i
+%include std_vector.i
+%template(VecDouble) std::vector;
+
+/* Load all of the classes here */
+%include "CEBase.i"
+%include "CEAngle.i"
+%include "CECorrections.i"
+%include "CEDate.i"
+%include "CEException.i"
+%include "CENamespace.i"
+%include "CEObserver.i"
+%include "CERunningDate.i"
+%include "CESkyCoord.i"
+%include "CEBody.i"
+%include "CETime.i"
+%include "CEObservation.i"
diff --git a/cppephem/swig/pyext/CMakeLists.txt b/cppephem/swig/pyext/CMakeLists.txt
new file mode 100644
index 00000000..34664a9e
--- /dev/null
+++ b/cppephem/swig/pyext/CMakeLists.txt
@@ -0,0 +1,73 @@
+#**************************************************************************
+# cppephem/swig/pyext/CMakeLists.txt: CppEphem *
+# ----------------------------------------------------------------------- *
+# Copyright © 2019 JCardenzana *
+# ----------------------------------------------------------------------- *
+# *
+# This program is free software: you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation, either version 3 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program. If not, see . *
+# *
+#**************************************************************************
+
+######################################################
+# This builds the Python wrappers for the code
+######################################################
+
+FIND_PACKAGE(PythonInterp 3.5)
+if(PYTHONINTERP_FOUND)
+ FIND_PACKAGE(PythonLibs)
+endif()
+
+# Ensure SWIG is installed
+FIND_PACKAGE(SWIG 4.0 COMPONENTS python)
+if(SWIG_FOUND)
+ MESSAGE("SWIG found: ${SWIG_EXECUTABLE} ${SWIG_VERSION}")
+endif()
+
+INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
+
+# Pre-configure the python files
+configure_file(cppephem/__init__.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/cppephem/__init__.py)
+configure_file(setup.py.in
+ ${CMAKE_CURRENT_BINARY_DIR}/setup.py)
+
+set_property(SOURCE ../cppephem.i PROPERTY CPLUSPLUS ON)
+
+# Add special doxygen formatting if SWIG version supports it
+if (${SWIG_VERSION} GREATER_EQUAL 4)
+ set_property(SOURCE ../cppephem.i PROPERTY SWIG_FLAGS -doxygen)# -debug-doxygen-translator)
+endif()
+
+SWIG_ADD_LIBRARY(cppephem_pywrap
+ LANGUAGE python
+ OUTPUT_DIR cppephem
+ SOURCES ../cppephem.i)
+
+SWIG_LINK_LIBRARIES(cppephem_pywrap cppephem ${PYTHON_LIBRARIES})
+
+add_custom_command(TARGET cppephem_pywrap
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/_cppephem_pywrap.so" "${CMAKE_CURRENT_BINARY_DIR}/cppephem/_cppephem_pywrap.so")
+
+# Testing code
+add_custom_command(TARGET cppephem_pywrap
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/test" "${CMAKE_CURRENT_BINARY_DIR}/test"
+ COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_SOURCE_DIR}/test/*.py" "${CMAKE_CURRENT_BINARY_DIR}/test/"
+ )
+
+add_test (NAME python-tests
+ COMMAND ${PYTHON_EXECUTABLE} -m unittest test
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
\ No newline at end of file
diff --git a/cppephem/swig/pyext/cppephem/__init__.py.in b/cppephem/swig/pyext/cppephem/__init__.py.in
new file mode 100644
index 00000000..4e3ec0f5
--- /dev/null
+++ b/cppephem/swig/pyext/cppephem/__init__.py.in
@@ -0,0 +1,26 @@
+#*************************************************************************#
+# CppEphem Python module #
+# ----------------------------------------------------------------------- #
+# Copyright © 2019 JCardenzana #
+# ----------------------------------------------------------------------- #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see . #
+# #
+#*************************************************************************#
+
+# Import the actual module classes
+from .cppephem import *
+
+# Set the version information
+__version__ = '${cppephem_version}'
diff --git a/cppephem/swig/pyext/setup.py.in b/cppephem/swig/pyext/setup.py.in
new file mode 100644
index 00000000..52084506
--- /dev/null
+++ b/cppephem/swig/pyext/setup.py.in
@@ -0,0 +1,42 @@
+#*************************************************************************#
+# setup.py.in: CppEphem #
+# ----------------------------------------------------------------------- #
+# Copyright © 2019 JCardenzana #
+# ----------------------------------------------------------------------- #
+# #
+# This program is free software: you can redistribute it and/or modify #
+# it under the terms of the GNU General Public License as published by #
+# the Free Software Foundation, either version 3 of the License, or #
+# (at your option) any later version. #
+# #
+# This program is distributed in the hope that it will be useful, #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
+# GNU General Public License for more details. #
+# #
+# You should have received a copy of the GNU General Public License #
+# along with this program. If not, see . #
+# #
+#*************************************************************************#
+
+# This script is used to install the SWIG generated Python wrapper module
+# for the CppEphem library
+
+import os
+import re
+from distutils.core import setup
+
+def find_packages(path='.'):
+ ret = []
+ for root, dirs, files in os.walk(path):
+ if '__init__.py' in files:
+ ret.append(re.sub('^[^A-z0-9_]+', '', root.replace('/', '.')))
+ return ret
+
+setup(name='cppephem',
+ version='${cppephem_version}',
+ description='CppEphem python module for computing astrophysical coordinates',
+ author='Josh Cardenzana',
+ url='https://jvinniec.github.io/CppEphem/documentation/html/index.html',
+ package_data={'cppephem': ['_cppephem_pywrap.so','cppephemPYTHON_wrap.cxx', 'cppephemPYTHON_wrap.h']},
+ packages=find_packages())
diff --git a/cppephem/swig/pyext/test/__init__.py b/cppephem/swig/pyext/test/__init__.py
new file mode 100644
index 00000000..79b369f5
--- /dev/null
+++ b/cppephem/swig/pyext/test/__init__.py
@@ -0,0 +1 @@
+from .test_ceangle import TestCEAngle
\ No newline at end of file
diff --git a/cppephem/swig/pyext/test/test_ceangle.py b/cppephem/swig/pyext/test/test_ceangle.py
new file mode 100644
index 00000000..de8f6353
--- /dev/null
+++ b/cppephem/swig/pyext/test/test_ceangle.py
@@ -0,0 +1,38 @@
+import unittest
+import cppephem as ce
+
+class TestCEAngle(unittest.TestCase):
+
+ def setUp(self):
+ self.base_ = ce.CEAngle(1.57079632679489661923132169163975144)
+
+ def test_construct(self):
+
+ # Default constructor
+ test1 = ce.CEAngle()
+ self.assertEqual(test1.Rad(), 0.0)
+
+ # Copy constructor (CEAngle)
+ test2 = ce.CEAngle(self.base_);
+ self.assertEqual(test2.Rad(), self.base_.Rad())
+
+ # // Copy-assignment operator (CEAngle)
+ test3 = self.base_
+ self.assertEqual(test3.Rad(), self.base_.Rad());
+
+ # // Copy-assignment operator (double)
+ # double angle_test = M_PI;
+ # CEAngle test4;
+ # test4 = angle_test;
+ # test_double(test4, angle_test, __func__, __LINE__);
+
+ # // Copy-assignment operator (CEAngle)
+ # CEAngle test5;
+ # test5 = base_;
+ # test_double(test5, base_, __func__, __LINE__);
+
+ # // Make sure support methods work
+ # test_string(base_.ClassName(), "CEAngle", __func__, __LINE__);
+ # test_greaterthan(base_.describe().size(), 0, __func__, __LINE__);
+
+ return
\ No newline at end of file
diff --git a/cppephem/test/CMakeLists.txt b/cppephem/test/CMakeLists.txt
index 8c997d1c..88fa0981 100644
--- a/cppephem/test/CMakeLists.txt
+++ b/cppephem/test/CMakeLists.txt
@@ -1,3 +1,23 @@
+#**************************************************************************
+# cppephem/test/CMakeLists.txt: CppEphem *
+# ----------------------------------------------------------------------- *
+# Copyright © 2019 JCardenzana *
+# ----------------------------------------------------------------------- *
+# *
+# This program is free software: you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation, either version 3 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program. If not, see . *
+# *
+#**************************************************************************
#------------------------------------------
# Define include directories
diff --git a/cppephem/test/test_CEAngle.cpp b/cppephem/test/test_CEAngle.cpp
index 6093cdd0..bd9b6f82 100644
--- a/cppephem/test/test_CEAngle.cpp
+++ b/cppephem/test/test_CEAngle.cpp
@@ -32,7 +32,7 @@
test_CEAngle::test_CEAngle() :
CETestSuite()
{
- // Let's use 45 degrees for the tests, or PI/2
+ // Let's use 90 degrees for the tests, or PI/2
base_ = CEAngle(M_PI_2);
}
@@ -92,6 +92,10 @@ bool test_CEAngle::test_construct(void)
test5 = base_;
test_double(test5, base_, __func__, __LINE__);
+ // Make sure support methods work
+ test_string(base_.ClassName(), "CEAngle", __func__, __LINE__);
+ test_greaterthan(base_.describe().size(), 0, __func__, __LINE__);
+
return pass();
}
diff --git a/cppephem/test/test_CEBody.cpp b/cppephem/test/test_CEBody.cpp
index a17e63b6..c17d97ce 100644
--- a/cppephem/test/test_CEBody.cpp
+++ b/cppephem/test/test_CEBody.cpp
@@ -93,6 +93,10 @@ bool test_CEBody::test_construct(void)
test_string(test4.Name(), test1.Name(), __func__, __LINE__);
test(test4.GetCoordinates() == test1.GetCoordinates(), __func__, __LINE__);
+ // Make sure support methods work
+ test_string(base_.ClassName(), "CEBody", __func__, __LINE__);
+ test_greaterthan(base_.describe().size(), 0, __func__, __LINE__);
+
return pass();
}
diff --git a/cppephem/test/test_CECoordinates.cpp b/cppephem/test/test_CECoordinates.cpp
index 17a1c443..a05c2e10 100644
--- a/cppephem/test/test_CECoordinates.cpp
+++ b/cppephem/test/test_CECoordinates.cpp
@@ -136,8 +136,9 @@ bool test_CECoordinates::test_construct()
CECoordinates test5(CECoordinateType::GALACTIC);
test_int(int(test5.GetCoordSystem()), int(CECoordinateType::GALACTIC), __func__, __LINE__);
- // Test print of constructed coordinates
- test_greaterthan(test4.print().size(), 0, __func__, __LINE__);
+ // Make sure support methods work
+ test_string(test5.ClassName(), "CECoordinates", __func__, __LINE__);
+ test_greaterthan(test5.describe().size(), 0, __func__, __LINE__);
return pass();
}
diff --git a/cppephem/test/test_CEDate.cpp b/cppephem/test/test_CEDate.cpp
index 0867c5c3..9d242923 100644
--- a/cppephem/test/test_CEDate.cpp
+++ b/cppephem/test/test_CEDate.cpp
@@ -93,6 +93,10 @@ bool test_CEDate::test_constructor(void)
CEDate test5(jd_20190101);
test_double(test5.JD(), jd_20190101, __func__, __LINE__);
+ // Make sure support methods work
+ test_string(base_date_.ClassName(), "CEDate", __func__, __LINE__);
+ test_greaterthan(base_date_.describe().size(), 0, __func__, __LINE__);
+
return pass();
}
diff --git a/cppephem/test/test_CEObservation.cpp b/cppephem/test/test_CEObservation.cpp
index 9b6bd135..ab60090b 100644
--- a/cppephem/test/test_CEObservation.cpp
+++ b/cppephem/test/test_CEObservation.cpp
@@ -110,6 +110,10 @@ bool test_CEObservation::test_constructor(void)
test(test4.Date() == &base_date_, __func__, __LINE__);
test(test4.Observer() == &base_observer_, __func__, __LINE__);
+ // Make sure support methods work
+ test_string(base_obs_.ClassName(), "CEObservation", __func__, __LINE__);
+ test_greaterthan(base_obs_.describe().size(), 0, __func__, __LINE__);
+
return pass();
}
diff --git a/cppephem/test/test_CEObserver.cpp b/cppephem/test/test_CEObserver.cpp
index 6293528a..115fc343 100644
--- a/cppephem/test/test_CEObserver.cpp
+++ b/cppephem/test/test_CEObserver.cpp
@@ -103,6 +103,11 @@ bool test_CEObserver::test_constructor(void)
test_double(test3.RelativeHumidity(), base_obs_.RelativeHumidity(), __func__, __LINE__);
test_double(test3.Wavelength_um(), base_obs_.Wavelength_um(), __func__, __LINE__);
+ // Make sure support methods work
+ test_string(base_obs_.ClassName(), "CEObserver", __func__, __LINE__);
+ test_greaterthan(base_obs_.print().size(), 0, __func__, __LINE__);
+ test_greaterthan(base_obs_.describe().size(), 0, __func__, __LINE__);
+
return pass();
}
@@ -203,9 +208,6 @@ bool test_CEObserver::test_set_atmoPars()
obs.SetWavelength_um(wavelength);
test_double(obs.Wavelength_um(), wavelength, __func__, __LINE__);
- // Make sure the print statement actually does something
- test(obs.print().size() > 0, __func__, __LINE__);
-
// Reset the tolerance
SetDblTol(old_tol);
return pass();
diff --git a/cppephem/test/test_CEPlanet.cpp b/cppephem/test/test_CEPlanet.cpp
index f50d5119..92bdaf9c 100644
--- a/cppephem/test/test_CEPlanet.cpp
+++ b/cppephem/test/test_CEPlanet.cpp
@@ -106,6 +106,10 @@ bool test_CEPlanet::test_construct(void)
test_double(test4.YCoordinate_Deg(), test2.YCoordinate_Deg(), __func__, __LINE__);
test_int(int(test4.GetCoordSystem()), int(test2.GetCoordSystem()), __func__, __LINE__);
+ // Make sure support methods work
+ test_string(test4.ClassName(), "CEPlanet", __func__, __LINE__);
+ test_greaterthan(test4.describe().size(), 0, __func__, __LINE__);
+
return pass();
}
@@ -230,7 +234,7 @@ bool test_CEPlanet::test_mars(void)
CEPlanet mars2 = CEPlanet::Mars();
mars2.SetAlgorithm(CEPlanetAlgo::JPL);
mars2.UpdateCoordinates(base_date_.JD());
- CEAngle angsep = mars.AngularSeparation(mars2);
+ CEAngle angsep = mars.Separation(mars2);
test_lessthan(angsep.Deg(), 0.1, __func__, __LINE__);
return pass();
@@ -373,7 +377,7 @@ bool test_CEPlanet::test_planet(const CEPlanet& test_planet,
std::printf(" X-diff: %f arcsec\n", (icrs_coords.XCoord().Deg()-true_icrs.XCoord().Deg())*3600.0);
std::printf(" Y-diff: %f arcsec\n", (icrs_coords.YCoord().Deg()-true_icrs.YCoord().Deg())*3600.0);
}
- std::printf(" AngSep ICRS: %e arcsec\n", icrs_coords.AngularSeparation(true_icrs).Deg()*3600.0);
+ std::printf(" AngSep ICRS: %e arcsec\n", icrs_coords.Separation(true_icrs).Deg()*3600.0);
// Test observed coordinates
CESkyCoord obs_coords = test_planet.ObservedCoords(base_date_,
@@ -385,7 +389,7 @@ bool test_CEPlanet::test_planet(const CEPlanet& test_planet,
std::printf(" X-diff: %f arcsec\n", (obs_coords.XCoord().Deg()-true_obs.XCoord().Deg())*3600.0);
std::printf(" Y-diff: %f arcsec\n", (obs_coords.YCoord().Deg()-true_obs.YCoord().Deg())*3600.0);
}
- std::printf(" AngSep Obs : %e arcsec\n", obs_coords.AngularSeparation(true_obs).Deg()*3600.0);
+ std::printf(" AngSep Obs : %e arcsec\n", obs_coords.Separation(true_obs).Deg()*3600.0);
// Update the tolerance
double tol_old = DblTol();
diff --git a/cppephem/test/test_CERunningDate.cpp b/cppephem/test/test_CERunningDate.cpp
index 911d5c3b..ef7f2a17 100644
--- a/cppephem/test/test_CERunningDate.cpp
+++ b/cppephem/test/test_CERunningDate.cpp
@@ -87,6 +87,10 @@ bool test_CERunningDate::test_construct(void)
// Make sure the timer has run
test_greaterthan(test1.RunTime(), naptime_ms_/1000.0, __func__, __LINE__);
+ // Make sure support methods work
+ test_string(base_.ClassName(), "CERunningDate", __func__, __LINE__);
+ test_greaterthan(base_.describe().size(), 0, __func__, __LINE__);
+
return pass();
}
diff --git a/cppephem/test/test_CESkyCoord.cpp b/cppephem/test/test_CESkyCoord.cpp
index 488cb35b..81717a51 100644
--- a/cppephem/test/test_CESkyCoord.cpp
+++ b/cppephem/test/test_CESkyCoord.cpp
@@ -138,6 +138,8 @@ bool test_CESkyCoord::test_construct()
// Test print of constructed coordinates
test_greaterthan(test4.print().size(), 0, __func__, __LINE__);
+ test_string(test4.ClassName(), "CESkyCoord", __func__, __LINE__);
+ test_greaterthan(test4.describe().size(), 0, __func__, __LINE__);
return pass();
}
@@ -395,11 +397,7 @@ bool test_CESkyCoord::test_AngularSeparation(void)
CESkyCoord test2(test2_x, test2_y, CESkyCoordType::ICRS);
// Test the default coordinate separation
- CEAngle angsep = test1.AngularSeparation(test2);
- test_double(angsep.Deg(), 2.0, __func__, __LINE__);
-
- // Static method
- angsep = CESkyCoord::AngularSeparation(test1, test2);
+ CEAngle angsep = test1.Separation(test2);
test_double(angsep.Deg(), 2.0, __func__, __LINE__);
// 2nd static Method not requiring CESkyCoord objects
@@ -412,7 +410,7 @@ bool test_CESkyCoord::test_AngularSeparation(void)
// Test that it fails if the coordinates are not the same type
try {
- angsep = CESkyCoord::AngularSeparation(base_icrs_, base_gal_);
+ angsep = base_icrs_.Separation(base_gal_);
test(false, __func__, __LINE__);
} catch (std::exception &e) {
test(true, __func__, __LINE__);
@@ -477,7 +475,7 @@ bool test_CESkyCoord::test_coords(const CESkyCoord& test,
test.YCoord().Deg(), expected.YCoord().Deg(),
(test.YCoord().Deg()-expected.YCoord().Deg())*3600.0);
std::printf(" AngSep: %e arcsec\n",
- test.AngularSeparation(expected).Deg()*3600.0);
+ test.Separation(expected).Deg()*3600.0);
}
return pass;
}
diff --git a/cppephem/test/test_CETime.cpp b/cppephem/test/test_CETime.cpp
index 157e430f..daf5192c 100644
--- a/cppephem/test/test_CETime.cpp
+++ b/cppephem/test/test_CETime.cpp
@@ -91,6 +91,10 @@ bool test_CETime::test_construct(void)
// Default constructor
+ // Make sure support methods work
+ test_string(test1.ClassName(), "CETime", __func__, __LINE__);
+ test_greaterthan(test1.describe().size(), 0, __func__, __LINE__);
+
return pass();
}
diff --git a/share/CMakeLists.txt b/share/CMakeLists.txt
index e0c8d045..735403ec 100644
--- a/share/CMakeLists.txt
+++ b/share/CMakeLists.txt
@@ -1,3 +1,24 @@
+#**************************************************************************
+# share/CMakeLists.txt: CppEphem *
+# ----------------------------------------------------------------------- *
+# Copyright © 2019 JCardenzana *
+# ----------------------------------------------------------------------- *
+# *
+# This program is free software: you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation, either version 3 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program. If not, see . *
+# *
+#**************************************************************************
+
# list of files for which we add a copy rule
set(resource_files
nutation.txt
diff --git a/sofa/src/CMakeLists.txt b/sofa/src/CMakeLists.txt
index 54dfb634..7cc434f7 100755
--- a/sofa/src/CMakeLists.txt
+++ b/sofa/src/CMakeLists.txt
@@ -1,3 +1,23 @@
+#**************************************************************************
+# sofa/src/CMakeLists.txt: CppEphem *
+# ----------------------------------------------------------------------- *
+# Copyright © 2019 JCardenzana *
+# ----------------------------------------------------------------------- *
+# *
+# This program is free software: you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation, either version 3 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program. If not, see . *
+# *
+#**************************************************************************
include_directories (./)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index 3242870c..29a01567 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,3 +1,23 @@
+#**************************************************************************
+# test/CMakeLists.txt: CppEphem *
+# ----------------------------------------------------------------------- *
+# Copyright © 2019 JCardenzana *
+# ----------------------------------------------------------------------- *
+# *
+# This program is free software: you can redistribute it and/or modify *
+# it under the terms of the GNU General Public License as published by *
+# the Free Software Foundation, either version 3 of the License, or *
+# (at your option) any later version. *
+# *
+# This program is distributed in the hope that it will be useful, *
+# but WITHOUT ANY WARRANTY; without even the implied warranty of *
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+# GNU General Public License for more details. *
+# *
+# You should have received a copy of the GNU General Public License *
+# along with this program. If not, see . *
+# *
+#**************************************************************************
#------------------------------------------
# Define include directories
diff --git a/test/src/CETestSuite.cpp b/test/src/CETestSuite.cpp
index 7475d09d..47ab843d 100644
--- a/test/src/CETestSuite.cpp
+++ b/test/src/CETestSuite.cpp
@@ -262,7 +262,9 @@ bool CETestSuite::test_vect_(const std::vector& value,
T diff = std::fabs(value[i] - expected[i]);
if (diff > rel_tol) {
log_failure("VECTOR values at index "+std::to_string(i)+" " +
- "are NOT equal (difference = " +
+ "are NOT equal (" +
+ std::to_string(value[i]) + " != " +
+ std::to_string(expected[i]) + ", difference = " +
std::to_string(diff) + ")", function, line);
isMatch = false;
}