Compare commits

...

5 Commits

117 changed files with 69 additions and 453303 deletions

1
.gitignore vendored
View File

@ -98,6 +98,7 @@ test-suite.log
/data/*.gschema.xml
# Documentation related files
/docs/reference/*/*.actions
/docs/reference/*/*.args
/docs/reference/*/*.hierarchy
/docs/reference/*/*.interfaces

View File

@ -1,7 +1,7 @@
include $(top_srcdir)/swe-glib.mk
ACLOCAL_AMFLAGS = -I m4
SUBDIRS = swe swe/src swe/doc src po data tests
SUBDIRS = src po data tests
if ENABLE_GTK_DOC
SUBDIRS += docs/reference/swe-glib

View File

@ -102,7 +102,7 @@ AS_IF([ test "x$use_gcov" = "xyes"], [
AC_MSG_ERROR([ccache must be disabled when --enable-coverage option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
fi
ltp_version_list="1.6 1.7 1.8 1.9 1.10"
ltp_version_list="1.6 1.7 1.8 1.9 1.10 1.14"
AC_CHECK_PROG(LTP, lcov, lcov)
AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
@ -160,17 +160,11 @@ PKG_CHECK_MODULES([GIO], [gio-2.0 >= 2.26])
GLIB_GSETTINGS
AC_CONFIG_MACRO_DIR([m4])
LIBSWE_LIBS='$(top_builddir)/swe/src/libswe-$(SWE_VERSION).la'
AC_SUBST(LIBSWE_LIBS)
LIBSWE_GLIB_LIBS='$(top_builddir)/src/libswe-glib-$(SWE_GLIB_API_VERSION).la'
AC_SUBST(LIBSWE_GLIB_LIBS)
AC_CONFIG_FILES([
Makefile
swe/Makefile
swe/src/Makefile
swe/doc/Makefile
src/Makefile
data/Makefile
po/Makefile.in

View File

@ -9,79 +9,7 @@ gsettings_SCHEMAS = eu.polonkai.gergely.swe-glib.gschema.xml
@GSETTINGS_RULES@
swephdir = $(pkgdatadir)
sweph_DATA = \
sweph-data/seas_00.se1 \
sweph-data/seas_06.se1 \
sweph-data/seas_12.se1 \
sweph-data/seas_18.se1 \
sweph-data/seas_24.se1 \
sweph-data/seas_30.se1 \
sweph-data/seas_36.se1 \
sweph-data/seas_42.se1 \
sweph-data/seas_48.se1 \
sweph-data/seasm06.se1 \
sweph-data/seasm12.se1 \
sweph-data/seasm18.se1 \
sweph-data/seasm24.se1 \
sweph-data/seasm30.se1 \
sweph-data/seasm36.se1 \
sweph-data/seasm42.se1 \
sweph-data/seasm48.se1 \
sweph-data/seasm54.se1 \
sweph-data/semo_00.se1 \
sweph-data/semo_06.se1 \
sweph-data/semo_12.se1 \
sweph-data/semo_18.se1 \
sweph-data/semo_24.se1 \
sweph-data/semo_30.se1 \
sweph-data/semo_36.se1 \
sweph-data/semo_42.se1 \
sweph-data/semo_48.se1 \
sweph-data/semom06.se1 \
sweph-data/semom12.se1 \
sweph-data/semom18.se1 \
sweph-data/semom24.se1 \
sweph-data/semom30.se1 \
sweph-data/semom36.se1 \
sweph-data/semom42.se1 \
sweph-data/semom48.se1 \
sweph-data/semom54.se1 \
sweph-data/sepl_00.se1 \
sweph-data/sepl_06.se1 \
sweph-data/sepl_12.se1 \
sweph-data/sepl_18.se1 \
sweph-data/sepl_24.se1 \
sweph-data/sepl_30.se1 \
sweph-data/sepl_36.se1 \
sweph-data/sepl_42.se1 \
sweph-data/sepl_48.se1 \
sweph-data/seplm06.se1 \
sweph-data/seplm12.se1 \
sweph-data/seplm18.se1 \
sweph-data/seplm24.se1 \
sweph-data/seplm30.se1 \
sweph-data/seplm36.se1 \
sweph-data/seplm42.se1 \
sweph-data/seplm48.se1 \
sweph-data/seplm54.se1 \
sweph-data/seleapsec.txt \
sweph-data/s136199.se1 \
sweph-data/s136199s.se1 \
sweph-data/se00010s.se1 \
sweph-data/se00034s.se1 \
sweph-data/se00157s.se1 \
sweph-data/se07066s.se1 \
sweph-data/se08405s.se1 \
sweph-data/se10199s.se1 \
sweph-data/se90377.se1 \
sweph-data/se90377s.se1 \
sweph-data/se90482.se1 \
sweph-data/se90482s.se1 \
$(NULL)
EXTRA_DIST = \
$(sweph_DATA) \
swe-glib.spec \
gschema.template

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -1,31 +0,0 @@
# This file contains the dates of leap seconds to be taken into account
# by the Swiss Ephemeris.
# For each new leap second add the date of its insertion in the format
# yyyymmdd, e.g. "20081231" for 21 december 2008
19720630
19721231
19731231
19741231
19751231
19761231
19771231
19781231
19791231
19810630
19820630
19830630
19850630
19871231
19891231
19901231
19920630
19930630
19949630
19951231
19970630
19981231
20051231
20081231
20120630
20150630
20161231

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,76 +0,0 @@
# Orbital elements of ficticious planets
# 27 Jan. 2000
#
# This file is part of the Swiss Ephemeris, from Version 1.52 on.
#
# Warning! These planets do not exist!
#
# The user can add his or her own elements.
# 960 is the maximum number of ficticious planets.
#
# The elements order is as follows:
# 1. epoch of elements (Julian day)
# 2. equinox (Julian day or "J1900" or "B1950" or "J2000")
# 3. mean anomaly at epoch
# 4. semi-axis
# 5. eccentricity
# 6. argument of perihelion (ang. distance of perihelion from node)
# 7. ascending node
# 8. inclination
# 9. name of planet
#
# use '#' for comments
# to compute a body with swe_calc(), use planet number
# ipl = SE_FICT_OFFSET_1 + number_of_elements_set,
# e.g. number of Kronos is ipl = 39 + 4 = 43
#
# Witte/Sieggruen planets, refined by James Neely
J1900, J1900, 163.7409, 40.99837, 0.00460, 171.4333, 129.8325, 1.0833, Cupido # 1
J1900, J1900, 27.6496, 50.66744, 0.00245, 148.1796, 161.3339, 1.0500, Hades # 2
J1900, J1900, 165.1232, 59.21436, 0.00120, 299.0440, 0.0000, 0.0000, Zeus # 3
J1900, J1900, 169.0193, 64.81690, 0.00305, 208.8801, 0.0000, 0.0000, Kronos # 4
J1900, J1900, 138.0533, 70.29949, 0.00000, 0.0000, 0.0000, 0.0000, Apollon # 5
J1900, J1900, 351.3350, 73.62765, 0.00000, 0.0000, 0.0000, 0.0000, Admetos # 6
J1900, J1900, 55.8983, 77.25568, 0.00000, 0.0000, 0.0000, 0.0000, Vulcanus # 7
J1900, J1900, 165.5163, 83.66907, 0.00000, 0.0000, 0.0000, 0.0000, Poseidon # 8
#
# Isis-Transpluto; elements from "Die Sterne" 3/1952, p. 70ff.
# Strubell does not give an equinox. 1945 is taken in order to
# reproduce the as best as ASTRON ephemeris. (This is a strange
# choice, though.)
# The epoch according to Strubell is 1772.76.
# 1772 is a leap year!
# The fraction is counted from 1 Jan. 1772
2368547.66, 2431456.5, 0.0, 77.775, 0.3, 0.7, 0, 0, Isis-Transpluto # 9
# Nibiru, elements from Christian Woeltge, Hannover
1856113.380954, 1856113.380954, 0.0, 234.8921, 0.981092, 103.966, -44.567, 158.708, Nibiru # 10
# Harrington, elements from Astronomical Journal 96(4), Oct. 1988
2374696.5, J2000, 0.0, 101.2, 0.411, 208.5, 275.4, 32.4, Harrington # 11
# according to W.G. Hoyt, "Planets X and Pluto", Tucson 1980, p. 63
2395662.5, 2395662.5, 34.05, 36.15, 0.10761, 284.75, 0, 0, Leverrier (Neptune) # 12
2395662.5, 2395662.5, 24.28, 37.25, 0.12062, 299.11, 0, 0, Adams (Neptune) # 13
2425977.5, 2425977.5, 281, 43.0, 0.202, 204.9, 0, 0, Lowell (Pluto) # 14
2425977.5, 2425977.5, 48.95, 55.1, 0.31, 280.1, 100, 15, Pickering (Pluto) # 15
# intramercurian hypothetical Vulcan acc. to L.H. Weston
J1900,JDATE, 252.8987988 + 707550.7341 * T, 0.13744, 0.019, 322.212069+1670.056*T, 47.787931-1670.056*T, 7.5, Vulcan # 16
# Selena/White Moon
J2000,JDATE, 242.2205555 + 5143.5418158 * T, 0.05280098949, 0.0, 0.0, 0.0, 0.0, Selena/White Moon, geo # 17
# Hypothetical planet Proserpina, according to http://www.geocities.com/Hollywood/Academy/7519/proserpina.html
# J1900, 170.73 + 51.05 * T
J1900,JDATE, 170.73, 79.225630, 0, 0, 0, 0, Proserpina #18
# Waldemath's Second Earth Moon
# Elements were derived by D.Koch from Waldemaths original elements as given in
# David Walters' book on Vulcan. They differ from Solar Fire (Graham Dawsons)
# elements, which are based on the assumption that the "mean longitude" given
# by Waldemath is an observation (a true longitude)
# Neither Swisseph nor Solar fire elements agree with Delphine Jay's ephemeris,
# which is obviously wrong.
2414290.95827875,2414290.95827875, 70.3407215 + 109023.2634989 * T, 0.0068400705250028, 0.1587, 8.14049594 + 2393.47417444 * T, 136.24878256 - 1131.71719709 * T, 2.5, Waldemath, geo # 19
#
# The following elements are for test only
# (Selena without T)
J2000,JDATE, 242.2205555, 0.05279142865925, 0.0, 0.0, 0.0, 0.0, Selena/White Moon, geo # 17
# (Selena with T, gives exactly the same position)
J2000,JDATE, 242.2205555 + 5143.5418158 * T, 0.05279142865925, 0.0, 0.0, 0.0, 0.0, Selena/White Moon with T Terms, geo # 17
J2000, JDATE, 174.794787 + 149472.5157715 * T, 0.38709831, 0.20563175 + 0.000020406 * T, 29.125226 + 0.3702885 * T, 48.330893 + 1.186189 * T, 7.004986 + 0.0018215 * T, Mercury elem. for equ. of date # 18
J2000, J2000, 174.794787 + 149472.5157715 * T, 0.38709831, 0.20563175 + 0.000020406 * T, 29.125226 + 0.2842872 * T, 48.330893 - 0.1254229 * T, 7.004986 - 0.0059516 * T, Mercury Test J2000 Elements# 18

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -92,7 +92,7 @@ expand_content_files=
# e.g. GTKDOC_CFLAGS=-I$(top_srcdir) -I$(top_builddir) $(GTK_DEBUG_FLAGS)
# e.g. GTKDOC_LIBS=$(top_builddir)/gtk/$(gtktargetlib)
GTKDOC_CFLAGS=
GTKDOC_LIBS=$(LIBSWE_GLIB_LIBS) $(NULL)
GTKDOC_LIBS=$(LIBSWE_GLIB_LIBS) -lswe -ldl $(NULL)
# This includes the standard gtk-doc make rules, copied by gtkdocize.
include $(top_srcdir)/gtk-doc.make

View File

@ -64,7 +64,7 @@ libswe_glib_2_0_la_SOURCES = \
$(NULL)
libswe_glib_2_0_la_CFLAGS = $(GLIB_CFLAGS) $(GOBJECT_CFLAGS) -Wall
libswe_glib_2_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) $(LIBSWE_LIBS)
libswe_glib_2_0_la_LIBADD = $(GLIB_LIBS) $(GOBJECT_LIBS) -lswe
libswe_glib_2_0_la_DEPENDENCIES = \
$(NULL)
@ -94,6 +94,7 @@ SweGlib_@SWE_GLIB_API_VERSION_U@_gir_LIBS = libswe-glib-2.0.la
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_SCANNERFLAGS = --identifier-prefix=Gswe --symbol-prefix=gswe --warn-all
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_INCLUDES = GLib-2.0 GObject-2.0
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_CFLAGS = -D__SWE_GLIB_BUILDING__ -I$(top_srcdir) -I$(srcdir) -I$(builddir)
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_LDFLAGS = $(GLIB_LIBS) $(GOBJECT_LIBS) -lswe
SweGlib_@SWE_GLIB_API_VERSION_U@_gir_EXPORT_PACKAGES = swe-glib
INTROSPECTION_GIRS = SweGlib-$(SWE_GLIB_API_VERSION).gir

View File

@ -18,11 +18,11 @@
*/
#include "swe-glib.h"
#include "gswe-enumtypes.h"
#include "@filename@"
/*** END file-header ***/
/*** BEGIN file-production ***/
#include "@filename@"
/* enumerations from "@filename@" */
/*** END file-production ***/

View File

@ -15,11 +15,11 @@
* You should have received a copy of the GNU General Public License
* along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
#include <swephexp.h>
#include "swe-glib.h"
#include "swe-glib-private.h"
#include "../swe/src/swephexp.h"
#define glforeach(a, b) for ((a) = (b); (a); (a) = g_list_next((a)))
/**
@ -805,14 +805,39 @@ gswe_moment_calculate_house_positions(GsweMoment *moment, GError **err)
err
);
}
if (gswe_moment_has_planet(moment, GSWE_PLANET_DESCENDANT)) {
calculate_data_by_position(
moment,
GSWE_PLANET_DESCENDANT,
fmod(ascmc[0] + 180.0, 180.0),
err
);
}
if (gswe_moment_has_planet(moment, GSWE_PLANET_MC)) {
calculate_data_by_position(moment, GSWE_PLANET_MC, ascmc[1], err);
}
if (gswe_moment_has_planet(moment, GSWE_PLANET_IC)) {
calculate_data_by_position(
moment,
GSWE_PLANET_IC,
fmod(ascmc[2] + 180.0, 180.0),
err
);
}
if (gswe_moment_has_planet(moment, GSWE_PLANET_VERTEX)) {
calculate_data_by_position(moment, GSWE_PLANET_VERTEX, ascmc[3], err);
}
if (gswe_moment_has_planet(moment, GSWE_PLANET_ANTIVERTEX)) {
calculate_data_by_position(
moment,
GSWE_PLANET_ANTIVERTEX,
fmod(ascmc[3] + 180.0, 180.0),
err
);
}
}
/**

View File

@ -18,8 +18,8 @@
*/
#include <math.h>
#include <glib.h>
#include <swephexp.h>
#include "../swe/src/swephexp.h"
#include "swe-glib-private.h"
#include "swe-glib.h"
#include "gswe-timestamp.h"

View File

@ -35,9 +35,12 @@
* GswePlanet:
* @GSWE_PLANET_NONE: no planet
* @GSWE_PLANET_ASCENDANT: the ascendant
* @GSWE_PLANET_DESCENDANT: the descendant
* @GSWE_PLANET_MC: midheaven (Medium Coeli)
* @GSWE_PLANET_IC: Immum Coeli
* @GSWE_PLANET_VERTEX: the Vertex (the point where the ecliptic meats the
* primal vertical)
* @GSWE_PLANET_ANTIVERTEX: the Antivertex (the point opposing the Vertex)
* @GSWE_PLANET_MOON_NODE: the mean ascending (north) Moon node
* @GSWE_PLANET_MOON_SOUTH_NODE: the mean descending (south) Moon node
* @GSWE_PLANET_MOON_APOGEE: the mean Moon apogee (sometimes called Dark Moon,
@ -80,6 +83,9 @@ typedef enum {
GSWE_PLANET_MOON_NODE,
GSWE_PLANET_MOON_APOGEE,
GSWE_PLANET_MOON_SOUTH_NODE,
GSWE_PLANET_DESCENDANT,
GSWE_PLANET_IC,
GSWE_PLANET_ANTIVERTEX,
/* Actual astrological planets */
GSWE_PLANET_SUN = 11,

View File

@ -18,8 +18,8 @@
#include <glib.h>
#define GETTEXT_PACKAGE "swe-glib"
#include <glib/gi18n-lib.h>
#include <swephexp.h>
#include "../swe/src/swephexp.h"
#include "swe-glib.h"
#include "swe-glib-private.h"
@ -178,6 +178,14 @@ void gswe_init_with_dir(gchar *directory)
9.0,
2
);
ADD_PLANET(gswe_planet_info_table, planet_info,
GSWE_PLANET_DESCENDANT,
-1,
FALSE,
_("Descendant"),
0.0,
0
);
ADD_PLANET(gswe_planet_info_table, planet_info,
GSWE_PLANET_MC,
-1,
@ -186,6 +194,14 @@ void gswe_init_with_dir(gchar *directory)
5.0,
1
);
ADD_PLANET(gswe_planet_info_table, planet_info,
GSWE_PLANET_IC,
-1,
FALSE,
_("Immum Coeli"),
0.0,
0
);
ADD_PLANET(gswe_planet_info_table, planet_info,
GSWE_PLANET_VERTEX,
-1,
@ -194,6 +210,14 @@ void gswe_init_with_dir(gchar *directory)
2.0,
0
);
ADD_PLANET(gswe_planet_info_table, planet_info,
GSWE_PLANET_ANTIVERTEX,
-1,
FALSE,
_("Anti-vertex"),
0.0,
0
);
ADD_PLANET(gswe_planet_info_table, planet_info,
GSWE_PLANET_MOON_NODE,
SE_MEAN_NODE,
@ -204,6 +228,9 @@ void gswe_init_with_dir(gchar *directory)
);
ADD_PLANET(gswe_planet_info_table, planet_info,
GSWE_PLANET_MOON_SOUTH_NODE,
// As this is just the opposing point of the mean node,
// we actually calculate that, and simply add 180
// degrees when queried.
SE_MEAN_NODE,
TRUE,
_("Descending Moon Node"),

View File

@ -1 +0,0 @@
EXTRA_DIST = README

View File

@ -1,5 +0,0 @@
This directory contains version 2.0 of the Swiss Ephemeris programming library
in a reduced form, so it can be used in an Autotools project like Astrognome.
If you need the full version, you can download it from
ftp://ftp.astro.com/pub/swisseph/ (as of July, 2013)

View File

@ -1 +0,0 @@
EXTRA_DIST = swephprg.pdf swisseph.pdf

Binary file not shown.

Binary file not shown.

View File

@ -1,54 +0,0 @@
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
If the developer choses the Swiss Ephemeris Professional license,
he must follow the instructions as found in http://www.astro.com/swisseph/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/

View File

@ -1,25 +0,0 @@
lib_LTLIBRARIES = libswe-2.0.la
libswe_2_0_la_SOURCES = swedate.c swehouse.c swejpl.c swemmoon.c swemplan.c swepcalc.c sweph.c swepdate.c swephlib.c swecl.c swehel.c
libswe_2_0_la_CFLAGS = $(CFLAGS) -Wall
libswe_2_0_la_LIBADD = $(LIBS)
EXTRA_DIST = \
LICENSE \
README \
swemptab.c \
swemptab.h \
swedate.h \
swedll.h \
swehouse.h \
swejpl.h \
swenut2000a.h \
sweodef.h \
swepcalc.h \
swephexp.h \
sweph.h \
swephlib.h \
fixstars.cat \
sedeltat.txt.inactive \
sefstars.txt \
seorbel.txt \
$(NULL)

View File

@ -1,6 +0,0 @@
This directory holds the Swiss Ephemeris library. It can be downloaded from
http://www.astro.com/swisseph/ and used via the GPL licence.
The original directory is stripped down, and the unneded files are deleted (like
the swetest source and such. In the future, even the library may be optimised
further.

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +0,0 @@
# This file allows to make new Delta T known to the Swiss Ephemeris.
# Note, these values override the values given in the internal Delta T
# table of the Swiss Ephemeris.
#
# If you want to use this file, change its file name and remove the
# the extension '.inactive'. As soon as you do so, the values below
# will be used, i.e. they will override the internal Delta T values
# of the Swiss Ephemeris.
#
# Format: year and seconds (decimal)
2007 65.15
2008 65.46
2009 65.78

File diff suppressed because it is too large Load Diff

View File

@ -1,76 +0,0 @@
# Orbital elements of ficticious planets
# 27 Jan. 2000
#
# This file is part of the Swiss Ephemeris, from Version 1.52 on.
#
# Warning! These planets do not exist!
#
# The user can add his or her own elements.
# 960 is the maximum number of ficticious planets.
#
# The elements order is as follows:
# 1. epoch of elements (Julian day)
# 2. equinox (Julian day or "J1900" or "B1950" or "J2000")
# 3. mean anomaly at epoch
# 4. semi-axis
# 5. eccentricity
# 6. argument of perihelion (ang. distance of perihelion from node)
# 7. ascending node
# 8. inclination
# 9. name of planet
#
# use '#' for comments
# to compute a body with swe_calc(), use planet number
# ipl = SE_FICT_OFFSET_1 + number_of_elements_set,
# e.g. number of Kronos is ipl = 39 + 4 = 43
#
# Witte/Sieggruen planets, refined by James Neely
J1900, J1900, 163.7409, 40.99837, 0.00460, 171.4333, 129.8325, 1.0833, Cupido # 1
J1900, J1900, 27.6496, 50.66744, 0.00245, 148.1796, 161.3339, 1.0500, Hades # 2
J1900, J1900, 165.1232, 59.21436, 0.00120, 299.0440, 0.0000, 0.0000, Zeus # 3
J1900, J1900, 169.0193, 64.81690, 0.00305, 208.8801, 0.0000, 0.0000, Kronos # 4
J1900, J1900, 138.0533, 70.29949, 0.00000, 0.0000, 0.0000, 0.0000, Apollon # 5
J1900, J1900, 351.3350, 73.62765, 0.00000, 0.0000, 0.0000, 0.0000, Admetos # 6
J1900, J1900, 55.8983, 77.25568, 0.00000, 0.0000, 0.0000, 0.0000, Vulcanus # 7
J1900, J1900, 165.5163, 83.66907, 0.00000, 0.0000, 0.0000, 0.0000, Poseidon # 8
#
# Isis-Transpluto; elements from "Die Sterne" 3/1952, p. 70ff.
# Strubell does not give an equinox. 1945 is taken in order to
# reproduce the as best as ASTRON ephemeris. (This is a strange
# choice, though.)
# The epoch according to Strubell is 1772.76.
# 1772 is a leap year!
# The fraction is counted from 1 Jan. 1772
2368547.66, 2431456.5, 0.0, 77.775, 0.3, 0.7, 0, 0, Isis-Transpluto # 9
# Nibiru, elements from Christian Woeltge, Hannover
1856113.380954, 1856113.380954, 0.0, 234.8921, 0.981092, 103.966, -44.567, 158.708, Nibiru # 10
# Harrington, elements from Astronomical Journal 96(4), Oct. 1988
2374696.5, J2000, 0.0, 101.2, 0.411, 208.5, 275.4, 32.4, Harrington # 11
# according to W.G. Hoyt, "Planets X and Pluto", Tucson 1980, p. 63
2395662.5, 2395662.5, 34.05, 36.15, 0.10761, 284.75, 0, 0, Leverrier (Neptune) # 12
2395662.5, 2395662.5, 24.28, 37.25, 0.12062, 299.11, 0, 0, Adams (Neptune) # 13
2425977.5, 2425977.5, 281, 43.0, 0.202, 204.9, 0, 0, Lowell (Pluto) # 14
2425977.5, 2425977.5, 48.95, 55.1, 0.31, 280.1, 100, 15, Pickering (Pluto) # 15
# intramercurian hypothetical Vulcan acc. to L.H. Weston
J1900,JDATE, 252.8987988 + 707550.7341 * T, 0.13744, 0.019, 322.212069+1670.056*T, 47.787931-1670.056*T, 7.5, Vulcan # 16
# Selena/White Moon
J2000,JDATE, 242.2205555 + 5143.5418158 * T, 0.05280098949, 0.0, 0.0, 0.0, 0.0, Selena/White Moon, geo # 17
# Hypothetical planet Proserpina, according to http://www.geocities.com/Hollywood/Academy/7519/proserpina.html
# J1900, 170.73 + 51.05 * T
J1900,JDATE, 170.73, 79.225630, 0, 0, 0, 0, Proserpina #18
# Waldemath's Second Earth Moon
# Elements were derived by D.Koch from Waldemaths original elements as given in
# David Walters' book on Vulcan. They differ from Solar Fire (Graham Dawsons)
# elements, which are based on the assumption that the "mean longitude" given
# by Waldemath is an observation (a true longitude)
# Neither Swisseph nor Solar fire elements agree with Delphine Jay's ephemeris,
# which is obviously wrong.
2414290.95827875,2414290.95827875, 70.3407215 + 109023.2634989 * T, 0.0068400705250028, 0.1587, 8.14049594 + 2393.47417444 * T, 136.24878256 - 1131.71719709 * T, 2.5, Waldemath, geo # 19
#
# The following elements are for test only
# (Selena without T)
J2000,JDATE, 242.2205555, 0.05279142865925, 0.0, 0.0, 0.0, 0.0, Selena/White Moon, geo # 17
# (Selena with T, gives exactly the same position)
J2000,JDATE, 242.2205555 + 5143.5418158 * T, 0.05279142865925, 0.0, 0.0, 0.0, 0.0, Selena/White Moon with T Terms, geo # 17
J2000, JDATE, 174.794787 + 149472.5157715 * T, 0.38709831, 0.20563175 + 0.000020406 * T, 29.125226 + 0.3702885 * T, 48.330893 + 1.186189 * T, 7.004986 + 0.0018215 * T, Mercury elem. for equ. of date # 18
J2000, J2000, 174.794787 + 149472.5157715 * T, 0.38709831, 0.20563175 + 0.000020406 * T, 29.125226 + 0.2842872 * T, 48.330893 - 0.1254229 * T, 7.004986 - 0.0059516 * T, Mercury Test J2000 Elements# 18

File diff suppressed because it is too large Load Diff

View File

@ -1,592 +0,0 @@
/*********************************************************
$Header: /home/dieter/sweph/RCS/swedate.c,v 1.75 2009/04/08 07:17:29 dieter Exp $
version 15-feb-89 16:30
swe_date_conversion()
swe_revjul()
swe_julday()
************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
If the developer choses the Swiss Ephemeris Professional license,
he must follow the instructions as found in http://www.astro.com/swisseph/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
/*
swe_date_conversion():
This function converts some date+time input {d,m,y,uttime}
into the Julian day number tjd.
The function checks that the input is a legal combination
of dates; for illegal dates like 32 January 1993 it returns ERR
but still converts the date correctly, i.e. like 1 Feb 1993.
The function is usually used to convert user input of birth data
into the Julian day number. Illegal dates should be notified to the user.
Be aware that we always use astronomical year numbering for the years
before Christ, not the historical year numbering.
Astronomical years are done with negative numbers, historical
years with indicators BC or BCE (before common era).
Year 0 (astronomical) = 1 BC historical.
year -1 (astronomical) = 2 BC
etc.
Many users of Astro programs do not know about this difference.
Return: OK or ERR (for illegal date)
*********************************************************/
# include "swephexp.h"
# include "sweph.h"
static TLS AS_BOOL init_leapseconds_done = FALSE;
int CALL_CONV swe_date_conversion(int y,
int m,
int d, /* day, month, year */
double uttime, /* UT in hours (decimal) */
char c, /* calendar g[regorian]|j[ulian] */
double *tjd)
{
int rday, rmon, ryear;
double rut, jd;
int gregflag = SE_JUL_CAL;
if (c == 'g')
gregflag = SE_GREG_CAL;
rut = uttime; /* hours UT */
jd = swe_julday(y, m, d, rut, gregflag);
swe_revjul(jd, gregflag, &ryear, &rmon, &rday, &rut);
*tjd = jd;
if (rmon == m && rday == d && ryear == y) {
return OK;
} else {
return ERR;
}
} /* end date_conversion */
/*************** swe_julday ********************************************
* This function returns the absolute Julian day number (JD)
* for a given calendar date.
* The arguments are a calendar date: day, month, year as integers,
* hour as double with decimal fraction.
* If gregflag = SE_GREG_CAL (1), Gregorian calendar is assumed,
* if gregflag = SE_JUL_CAL (0),Julian calendar is assumed.
The Julian day number is a system of numbering all days continously
within the time range of known human history. It should be familiar
to every astrological or astronomical programmer. The time variable
in astronomical theories is usually expressed in Julian days or
Julian centuries (36525 days per century) relative to some start day;
the start day is called 'the epoch'.
The Julian day number is a double representing the number of
days since JD = 0.0 on 1 Jan -4712, 12:00 noon (in the Julian calendar).
Midnight has always a JD with fraction .5, because traditionally
the astronomical day started at noon. This was practical because
then there was no change of date during a night at the telescope.
From this comes also the fact the noon ephemerides were printed
before midnight ephemerides were introduced early in the 20th century.
NOTE: The Julian day number must not be confused with the Julian
calendar system.
Be aware the we always use astronomical year numbering for the years
before Christ, not the historical year numbering.
Astronomical years are done with negative numbers, historical
years with indicators BC or BCE (before common era).
Year 0 (astronomical) = 1 BC
year -1 (astronomical) = 2 BC
etc.
Original author: Marc Pottenger, Los Angeles.
with bug fix for year < -4711 15-aug-88 by Alois Treindl
(The parameter sequence m,d,y still indicates the US origin,
be careful because the similar function date_conversion() uses
other parameter sequence and also Astrodienst relative juldate.)
References: Oliver Montenbruck, Grundlagen der Ephemeridenrechnung,
Verlag Sterne und Weltraum (1987), p.49 ff
related functions: swe_revjul() reverse Julian day number: compute the
calendar date from a given JD
date_conversion() includes test for legal date values
and notifies errors like 32 January.
****************************************************************/
double CALL_CONV swe_julday(int year, int month, int day, double hour, int gregflag)
{
double jd;
double u,u0,u1,u2;
u = year;
if (month < 3) u -=1;
u0 = u + 4712.0;
u1 = month + 1.0;
if (u1 < 4) u1 += 12.0;
jd = floor(u0*365.25)
+ floor(30.6*u1+0.000001)
+ day + hour/24.0 - 63.5;
if (gregflag == SE_GREG_CAL) {
u2 = floor(fabs(u) / 100) - floor(fabs(u) / 400);
if (u < 0.0) u2 = -u2;
jd = jd - u2 + 2;
if ((u < 0.0) && (u/100 == floor(u/100)) && (u/400 != floor(u/400)))
jd -=1;
}
return jd;
}
/*** swe_revjul ******************************************************
swe_revjul() is the inverse function to swe_julday(), see the description
there.
Arguments are julian day number, calendar flag (0=julian, 1=gregorian)
return values are the calendar day, month, year and the hour of
the day with decimal fraction (0 .. 23.999999).
Be aware the we use astronomical year numbering for the years
before Christ, not the historical year numbering.
Astronomical years are done with negative numbers, historical
years with indicators BC or BCE (before common era).
Year 0 (astronomical) = 1 BC historical year
year -1 (astronomical) = 2 BC historical year
year -234 (astronomical) = 235 BC historical year
etc.
Original author Mark Pottenger, Los Angeles.
with bug fix for year < -4711 16-aug-88 Alois Treindl
*************************************************************************/
void CALL_CONV swe_revjul (double jd, int gregflag,
int *jyear, int *jmon, int *jday, double *jut)
{
double u0,u1,u2,u3,u4;
u0 = jd + 32082.5;
if (gregflag == SE_GREG_CAL) {
u1 = u0 + floor (u0/36525.0) - floor (u0/146100.0) - 38.0;
if (jd >= 1830691.5) u1 +=1;
u0 = u0 + floor (u1/36525.0) - floor (u1/146100.0) - 38.0;
}
u2 = floor (u0 + 123.0);
u3 = floor ( (u2 - 122.2) / 365.25);
u4 = floor ( (u2 - floor (365.25 * u3) ) / 30.6001);
*jmon = (int) (u4 - 1.0);
if (*jmon > 12) *jmon -= 12;
*jday = (int) (u2 - floor (365.25 * u3) - floor (30.6001 * u4));
*jyear = (int) (u3 + floor ( (u4 - 2.0) / 12.0) - 4800);
*jut = (jd - floor (jd + 0.5) + 0.5) * 24.0;
}
/* transform local time to UTC or UTC to local time
*
* input
* iyear ... dsec date and time
* d_timezone timezone offset
* output
* iyear_out ... dsec_out
*
* For time zones east of Greenwich, d_timezone is positive.
* For time zones west of Greenwich, d_timezone is negative.
*
* For conversion from local time to utc, use +d_timezone.
* For conversion from utc to local time, use -d_timezone.
*/
void CALL_CONV swe_utc_time_zone(
int32 iyear, int32 imonth, int32 iday,
int32 ihour, int32 imin, double dsec,
double d_timezone,
int32 *iyear_out, int32 *imonth_out, int32 *iday_out,
int32 *ihour_out, int32 *imin_out, double *dsec_out
)
{
double tjd, d;
AS_BOOL have_leapsec = FALSE;
double dhour;
if (dsec >= 60.0) {
have_leapsec = TRUE;
dsec -= 1.0;
}
dhour = ((double) ihour) + ((double) imin) / 60.0 + dsec / 3600.0;
tjd = swe_julday(iyear, imonth, iday, 0, SE_GREG_CAL);
dhour -= d_timezone;
if (dhour < 0.0) {
tjd -= 1.0;
dhour += 24.0;
}
if (dhour >= 24.0) {
tjd += 1.0;
dhour -= 24.0;
}
swe_revjul(tjd + 0.001, SE_GREG_CAL, iyear_out, imonth_out, iday_out, &d);
*ihour_out = (int) dhour;
d = (dhour - (double) *ihour_out) * 60;
*imin_out = (int) d;
*dsec_out = (d - (double) *imin_out) * 60;
if (have_leapsec)
*dsec_out += 1.0;
}
/*
* functions for the handling of UTC
*/
/* Leap seconds were inserted at the end of the following days:*/
#define NLEAP_SECONDS 26
#define NLEAP_SECONDS_SPACE 100
static TLS int leap_seconds[NLEAP_SECONDS_SPACE] = {
19720630,
19721231,
19731231,
19741231,
19751231,
19761231,
19771231,
19781231,
19791231,
19810630,
19820630,
19830630,
19850630,
19871231,
19891231,
19901231,
19920630,
19930630,
19940630,
19951231,
19970630,
19981231,
20051231,
20081231,
20120630,
20150630,
0 /* keep this 0 as end mark */
};
#define J1972 2441317.5
#define NLEAP_INIT 10
/* Read additional leap second dates from external file, if given.
*/
static int init_leapsec(void)
{
FILE *fp;
int ndat, ndat_last;
int tabsiz = 0;
int i;
char s[AS_MAXCH];
char *sp;
if (!init_leapseconds_done) {
init_leapseconds_done = TRUE;
tabsiz = NLEAP_SECONDS;
ndat_last = leap_seconds[NLEAP_SECONDS - 1];
/* no error message if file is missing */
if ((fp = swi_fopen(-1, "seleapsec.txt", swed.ephepath, NULL)) == NULL)
return NLEAP_SECONDS;
while(fgets(s, AS_MAXCH, fp) != NULL) {
sp = s;
while (*sp == ' ' || *sp == '\t') sp++;
sp++;
if (*sp == '#' || *sp == '\n')
continue;
ndat = atoi(s);
if (ndat <= ndat_last)
continue;
/* table space is limited. no error msg, if exceeded */
if (tabsiz >= NLEAP_SECONDS_SPACE)
return tabsiz;
leap_seconds[tabsiz] = ndat;
tabsiz++;
}
if (tabsiz > NLEAP_SECONDS) leap_seconds[tabsiz] = 0; /* end mark */
fclose(fp);
return tabsiz;
}
/* find table size */
tabsiz = 0;
for (i = 0; i < NLEAP_SECONDS_SPACE; i++) {
if (leap_seconds[i] == 0)
break;
else
tabsiz++;
}
return tabsiz;
}
/*
* Input: Clock time UTC, year, month, day, hour, minute, second (decimal).
* gregflag Calendar flag
* serr error string
* Output: An array of doubles:
* dret[0] = Julian day number TT (ET)
* dret[1] = Julian day number UT1
*
* Function returns OK or Error.
*
* - Before 1972, swe_utc_to_jd() treats its input time as UT1.
* Note: UTC was introduced in 1961. From 1961 - 1971, the length of the
* UTC second was regularly changed, so that UTC remained very close to UT1.
* - From 1972 on, input time is treated as UTC.
* - If delta_t - nleap - 32.184 > 1, the input time is treated as UT1.
* Note: Like this we avoid errors greater than 1 second in case that
* the leap seconds table (or the Swiss Ephemeris version) is not updated
* for a long time.
*/
int32 CALL_CONV swe_utc_to_jd(int32 iyear, int32 imonth, int32 iday, int32 ihour, int32 imin, double dsec, int32 gregflag, double *dret, char *serr)
{
double tjd_ut1, tjd_et, tjd_et_1972, dhour, d;
int iyear2, imonth2, iday2;
int i, j, ndat, nleap, tabsiz_nleap;
/*
* error handling: invalid iyear etc.
*/
tjd_ut1 = swe_julday(iyear, imonth, iday, 0, gregflag);
swe_revjul(tjd_ut1, gregflag, &iyear2, &imonth2, &iday2, &d);
if (iyear != iyear2 || imonth != imonth2 || iday != iday2) {
if (serr != NULL)
sprintf(serr, "invalid date: year = %d, month = %d, day = %d", iyear, imonth, iday);
return ERR;
}
if (ihour < 0 || ihour > 23
|| imin < 0 || imin > 59
|| dsec < 0 || dsec >= 61
|| (dsec >= 60 && (imin < 59 || ihour < 23 || tjd_ut1 < J1972))) {
if (serr != NULL)
sprintf(serr, "invalid time: %d:%d:%.2f", ihour, imin, dsec);
return ERR;
}
dhour = (double) ihour + ((double) imin) / 60.0 + dsec / 3600.0;
/*
* before 1972, we treat input date as UT1
*/
if (tjd_ut1 < J1972) {
dret[1] = swe_julday(iyear, imonth, iday, dhour, gregflag);
dret[0] = dret[1] + swe_deltat_ex(dret[1], -1, NULL);
return OK;
}
/*
* if gregflag = Julian calendar, convert to gregorian calendar
*/
if (gregflag == SE_JUL_CAL) {
gregflag = SE_GREG_CAL;
swe_revjul(tjd_ut1, gregflag, &iyear, &imonth, &iday, &d);
}
/*
* number of leap seconds since 1972:
*/
tabsiz_nleap = init_leapsec();
nleap = NLEAP_INIT; /* initial difference between UTC and TAI in 1972 */
ndat = iyear * 10000 + imonth * 100 + iday;
for (i = 0; i < tabsiz_nleap; i++) {
if (ndat <= leap_seconds[i])
break;
nleap++;
}
/*
* For input dates > today:
* If leap seconds table is not up to date, we'd better interpret the
* input time as UT1, not as UTC. How do we find out?
* Check, if delta_t - nleap - 32.184 > 0.9
*/
d = swe_deltat_ex(tjd_ut1, -1, NULL) * 86400.0;
if (d - (double) nleap - 32.184 >= 1.0) {
dret[1] = tjd_ut1 + dhour / 24.0;
dret[0] = dret[1] + swe_deltat_ex(dret[1], -1, NULL);
return OK;
}
/*
* if input second is 60: is it a valid leap second ?
*/
if (dsec >= 60) {
j = 0;
for (i = 0; i < tabsiz_nleap; i++) {
if (ndat == leap_seconds[i]) {
j = 1;
break;
}
}
if (j != 1) {
if (serr != NULL)
sprintf(serr, "invalid time (no leap second!): %d:%d:%.2f", ihour, imin, dsec);
return ERR;
}
}
/*
* convert UTC to ET and UT1
*/
/* the number of days between input date and 1 jan 1972: */
d = tjd_ut1 - J1972;
/* SI time since 1972, ignoring leap seconds: */
d += (double) ihour / 24.0 + (double) imin / 1440.0 + dsec / 86400.0;
/* ET (TT) */
tjd_et_1972 = J1972 + (32.184 + NLEAP_INIT) / 86400.0;
tjd_et = tjd_et_1972 + d + ((double) (nleap - NLEAP_INIT)) / 86400.0;
d = swe_deltat_ex(tjd_et, -1, NULL);
tjd_ut1 = tjd_et - swe_deltat_ex(tjd_et - d, -1, NULL);
tjd_ut1 = tjd_et - swe_deltat_ex(tjd_ut1, -1, NULL);
dret[0] = tjd_et;
dret[1] = tjd_ut1;
return OK;
}
/*
* Input: tjd_et Julian day number, terrestrial time (ephemeris time).
* gregfalg Calendar flag
* Output: UTC year, month, day, hour, minute, second (decimal).
*
* - Before 1 jan 1972 UTC, output UT1.
* Note: UTC was introduced in 1961. From 1961 - 1971, the length of the
* UTC second was regularly changed, so that UTC remained very close to UT1.
* - From 1972 on, output is UTC.
* - If delta_t - nleap - 32.184 > 1, the output is UT1.
* Note: Like this we avoid errors greater than 1 second in case that
* the leap seconds table (or the Swiss Ephemeris version) has not been
* updated for a long time.
*/
void CALL_CONV swe_jdet_to_utc(double tjd_et, int32 gregflag, int32 *iyear, int32 *imonth, int32 *iday, int32 *ihour, int32 *imin, double *dsec)
{
int i;
int second_60 = 0;
int iyear2, imonth2, iday2, nleap, ndat, tabsiz_nleap;
double d, tjd, tjd_et_1972, tjd_ut, dret[10];
/*
* if tjd_et is before 1 jan 1972 UTC, return UT1
*/
tjd_et_1972 = J1972 + (32.184 + NLEAP_INIT) / 86400.0;
d = swe_deltat_ex(tjd_et, -1, NULL);
tjd_ut = tjd_et - swe_deltat_ex(tjd_et - d, -1, NULL);
tjd_ut = tjd_et - swe_deltat_ex(tjd_ut, -1, NULL);
if (tjd_et < tjd_et_1972) {
swe_revjul(tjd_ut, gregflag, iyear, imonth, iday, &d);
*ihour = (int32) d;
d -= (double) *ihour;
d *= 60;
*imin = (int32) d;
*dsec = (d - (double) *imin) * 60.0;
return;
}
/*
* minimum number of leap seconds since 1972; we may be missing one leap
* second
*/
tabsiz_nleap = init_leapsec();
swe_revjul(tjd_ut-1, SE_GREG_CAL, &iyear2, &imonth2, &iday2, &d);
ndat = iyear2 * 10000 + imonth2 * 100 + iday2;
nleap = 0;
for (i = 0; i < tabsiz_nleap; i++) {
if (ndat <= leap_seconds[i])
break;
nleap++;
}
/* date of potentially missing leapsecond */
if (nleap < tabsiz_nleap) {
i = leap_seconds[nleap];
iyear2 = i / 10000;
imonth2 = (i % 10000) / 100;;
iday2 = i % 100;
tjd = swe_julday(iyear2, imonth2, iday2, 0, SE_GREG_CAL);
swe_revjul(tjd+1, SE_GREG_CAL, &iyear2, &imonth2, &iday2, &d);
swe_utc_to_jd(iyear2,imonth2,iday2, 0, 0, 0, SE_GREG_CAL, dret, NULL);
d = tjd_et - dret[0];
if (d >= 0) {
nleap++;
} else if (d < 0 && d > -1.0/86400.0) {
second_60 = 1;
}
}
/*
* UTC, still unsure about one leap second
*/
tjd = J1972 + (tjd_et - tjd_et_1972) - ((double) nleap + second_60) / 86400.0;
swe_revjul(tjd, SE_GREG_CAL, iyear, imonth, iday, &d);
*ihour = (int32) d;
d -= (double) *ihour;
d *= 60;
*imin = (int32) d;
*dsec = (d - (double) *imin) * 60.0 + second_60;
/*
* For input dates > today:
* If leap seconds table is not up to date, we'd better interpret the
* input time as UT1, not as UTC. How do we find out?
* Check, if delta_t - nleap - 32.184 > 0.9
*/
d = swe_deltat_ex(tjd_et, -1, NULL);
d = swe_deltat_ex(tjd_et - d, -1, NULL);
if (d * 86400.0 - (double) (nleap + NLEAP_INIT) - 32.184 >= 1.0) {
swe_revjul(tjd_et - d, SE_GREG_CAL, iyear, imonth, iday, &d);
*ihour = (int32) d;
d -= (double) *ihour;
d *= 60;
*imin = (int32) d;
*dsec = (d - (double) *imin) * 60.0;
}
if (gregflag == SE_JUL_CAL) {
tjd = swe_julday(*iyear, *imonth, *iday, 0, SE_GREG_CAL);
swe_revjul(tjd, gregflag, iyear, imonth, iday, &d);
}
}
/*
* Input: tjd_ut Julian day number, universal time (UT1).
* gregfalg Calendar flag
* Output: UTC year, month, day, hour, minute, second (decimal).
*
* - Before 1 jan 1972 UTC, output UT1.
* Note: UTC was introduced in 1961. From 1961 - 1971, the length of the
* UTC second was regularly changed, so that UTC remained very close to UT1.
* - From 1972 on, output is UTC.
* - If delta_t - nleap - 32.184 > 1, the output is UT1.
* Note: Like this we avoid errors greater than 1 second in case that
* the leap seconds table (or the Swiss Ephemeris version) has not been
* updated for a long time.
*/
void CALL_CONV swe_jdut1_to_utc(double tjd_ut, int32 gregflag, int32 *iyear, int32 *imonth, int32 *iday, int32 *ihour, int32 *imin, double *dsec)
{
double tjd_et = tjd_ut + swe_deltat_ex(tjd_ut, -1, NULL);
swe_jdet_to_utc(tjd_et, gregflag, iyear, imonth, iday, ihour, imin, dsec);
}

View File

@ -1,82 +0,0 @@
/*********************************************************
$Header: /home/dieter/sweph/RCS/swedate.h,v 1.74 2008/06/16 10:07:20 dieter Exp $
version 15-feb-89 16:30
*********************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
If the developer choses the Swiss Ephemeris Professional license,
he must follow the instructions as found in http://www.astro.com/swisseph/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _SWEDLL_H
extern EXP32 int swe_date_conversion (
int y , int m , int d , /* year, month, day */
double utime, /* universal time in hours (decimal) */
char c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */
double *tgmt);
extern EXP32 double *swe_julday(
int year, int month, int day, double hour,
int gregflag);
extern EXP32 void swe_revjul (
double jd,
int gregflag,
int *jyear, int *jmon, int *jday, double *jut);
#endif
#ifdef __cplusplus
} /* extern C */
#endif

View File

@ -1,535 +0,0 @@
/* SWISSEPH
* $Header: /home/dieter/sweph/RCS/swedll.h,v 1.75 2009/04/08 07:19:08 dieter Exp $
*
* Windows DLL interface imports for the Astrodienst SWISSEPH package
*
**************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
If the developer choses the Swiss Ephemeris Professional license,
he must follow the instructions as found in http://www.astro.com/swisseph/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
/* $Id: swedll.h,v 1.75 2009/04/08 07:19:08 dieter Exp $ */
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _SWEDLL_H
#define _SWEDLL_H
#ifndef _SWEPHEXP_INCLUDED
#include "swephexp.h"
#endif
#ifdef USE_DLL16 /* 16bit DLL */
#define DllImport extern
#else
# ifdef __cplusplus
#define DllImport extern "C" __declspec( dllimport )
# else
#define DllImport __declspec( dllimport )
# endif
#endif
#if defined (PASCAL) || defined(__stdcall)
#define CALL_CONV_IMP __stdcall
#else
#define CALL_CONV_IMP
#endif
DllImport int32 CALL_CONV_IMP swe_heliacal_ut(double JDNDaysUTStart, double *geopos, double *datm, double *dobs, char *ObjectName, int32 TypeEvent, int32 iflag, double *dret, char *serr);
DllImport int32 CALL_CONV_IMP swe_heliacal_pheno_ut(double JDNDaysUT, double *geopos, double *datm, double *dobs, char *ObjectName, int32 TypeEvent, int32 helflag, double *darr, char *serr);
DllImport int32 CALL_CONV_IMP swe_vis_limit_mag(double tjdut, double *geopos, double *datm, double *dobs, char *ObjectName, int32 helflag, double *dret, char *serr);
/* the following are secret, for Victor Reijs' */
DllImport int32 CALL_CONV_IMP swe_heliacal_angle(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr);
DllImport int32 CALL_CONV_IMP swe_topo_arcus_visionis(double tjdut, double *dgeo, double *datm, double *dobs, int32 helflag, double mag, double azi_obj, double alt_obj, double azi_sun, double azi_moon, double alt_moon, double *dret, char *serr);
DllImport double CALL_CONV_IMP swe_degnorm(double deg);
DllImport char * CALL_CONV_IMP swe_version(char *);
DllImport int32 CALL_CONV_IMP swe_calc(
double tjd, int ipl, int32 iflag,
double *xx,
char *serr);
DllImport int32 CALL_CONV_IMP swe_calc_ut(
double tjd_ut, int32 ipl, int32 iflag,
double *xx,
char *serr);
DllImport int32 CALL_CONV_IMP swe_fixstar(
char *star, double tjd, int32 iflag,
double *xx,
char *serr);
DllImport int32 CALL_CONV_IMP swe_fixstar_ut(
char *star, double tjd_ut, int32 iflag,
double *xx,
char *serr);
DllImport int32 CALL_CONV_IMP swe_fixstar_mag(
char *star, double *xx, char *serr);
DllImport double CALL_CONV_IMP swe_sidtime0(double tjd_ut, double ecl, double nut);
DllImport double CALL_CONV_IMP swe_sidtime(double tjd_ut);
DllImport double CALL_CONV_IMP swe_deltat_ex(double tjd, int32 iflag, char *serr);
DllImport double CALL_CONV_IMP swe_deltat(double tjd);
DllImport int CALL_CONV_IMP swe_houses(
double tjd_ut, double geolat, double geolon, int hsys,
double *hcusps, double *ascmc);
DllImport int CALL_CONV_IMP swe_houses_ex(
double tjd_ut, int32 iflag, double geolat, double geolon, int hsys,
double *hcusps, double *ascmc);
DllImport int CALL_CONV_IMP swe_houses_armc(
double armc, double geolat, double eps, int hsys,
double *hcusps, double *ascmc);
DllImport double CALL_CONV_IMP swe_house_pos(
double armc, double geolon, double eps, int hsys, double *xpin, char *serr);
DllImport char * CALL_CONV_IMP swe_house_name(int hsys);
DllImport int32 CALL_CONV_IMP swe_gauquelin_sector(
double t_ut, int32 ipl, char *starname, int32 iflag, int32 imeth, double *geopos, double atpress, double attemp, double *dgsect, char *serr);
DllImport void CALL_CONV_IMP swe_set_sid_mode(
int32 sid_mode, double t0, double ayan_t0);
DllImport int32 CALL_CONV_IMP swe_get_ayanamsa_ex(double tjd_et, int32 iflag, double *daya, char *serr);
DllImport int32 CALL_CONV_IMP swe_get_ayanamsa_ex_ut(double tjd_ut, int32 iflag, double *daya, char *serr);
DllImport double CALL_CONV_IMP swe_get_ayanamsa(double tjd_et);
DllImport double CALL_CONV_IMP swe_get_ayanamsa_ut(double tjd_ut);
DllImport char * CALL_CONV_IMP swe_get_ayanamsa_name(int32 isidmode);
DllImport int CALL_CONV_IMP swe_date_conversion(
int y , int m , int d , /* year, month, day */
double utime, /* universal time in hours (decimal) */
char c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */
double *tjd);
DllImport double CALL_CONV_IMP swe_julday(
int year, int mon, int mday,
double hour,
int gregflag);
DllImport void CALL_CONV_IMP swe_revjul(
double jd, int gregflag,
int *year, int *mon, int *mday,
double *hour);
DllImport void CALL_CONV_IMP swe_utc_time_zone(
int32 iyear, int32 imonth, int32 iday,
int32 ihour, int32 imin, double dsec,
double d_timezone,
int32 *iyear_out, int32 *imonth_out, int32 *iday_out,
int32 *ihour_out, int32 *imin_out, double *dsec_out);
DllImport int32 CALL_CONV_IMP swe_utc_to_jd(
int32 iyear, int32 imonth, int32 iday,
int32 ihour, int32 imin, double dsec,
int32 gregflag, double *dret, char *serr);
DllImport void CALL_CONV_IMP swe_jdet_to_utc(
double tjd_et, int32 gregflag,
int32 *iyear, int32 *imonth, int32 *iday,
int32 *ihour, int32 *imin, double *dsec);
DllImport void CALL_CONV_IMP swe_jdut1_to_utc(
double tjd_ut, int32 gregflag,
int32 *iyear, int32 *imonth, int32 *iday,
int32 *ihour, int32 *imin, double *dsec);
DllImport int CALL_CONV_IMP swe_time_equ(
double tjd, double *e, char *serr);
DllImport int CALL_CONV_IMP swe_lmt_to_lat(double tjd_lmt, double geolon, double *tjd_lat, char *serr);
DllImport int CALL_CONV_IMP swe_lat_to_lmt(double tjd_lat, double geolon, double *tjd_lmt, char *serr);
DllImport double CALL_CONV_IMP swe_get_tid_acc(void);
DllImport void CALL_CONV_IMP swe_set_tid_acc(double tidacc);
DllImport void CALL_CONV_IMP swe_set_ephe_path(char *path);
DllImport void CALL_CONV_IMP swe_set_jpl_file(char *fname);
DllImport void CALL_CONV_IMP swe_close(void);
DllImport char * CALL_CONV_IMP swe_get_planet_name(int ipl, char *spname);
DllImport void CALL_CONV_IMP swe_cotrans(double *xpo, double *xpn, double eps);
DllImport void CALL_CONV_IMP swe_cotrans_sp(double *xpo, double *xpn, double eps);
DllImport void CALL_CONV_IMP swe_set_topo(double geolon, double geolat, double height);
DllImport void CALL_CONV_IMP swe_set_astro_models(int32 *imodel);
/****************************
* from swecl.c
****************************/
/* computes geographic location and attributes of solar
* eclipse at a given tjd */
DllImport int32 CALL_CONV_IMP swe_sol_eclipse_where(double tjd, int32 ifl, double *geopos, double *attr, char *serr);
DllImport int32 CALL_CONV_IMP swe_lun_occult_where(double tjd, int32 ipl, char *starname, int32 ifl, double *geopos, double *attr, char *serr);
/* computes attributes of a solar eclipse for given tjd, geolon, geolat */
DllImport int32 CALL_CONV_IMP swe_sol_eclipse_how(double tjd, int32 ifl, double *geopos, double *attr, char *serr);
/* finds time of next local eclipse */
DllImport int32 CALL_CONV_IMP swe_sol_eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, double *tret, double *attr, int32 backward, char *serr);
DllImport int32 CALL_CONV_IMP swe_lun_occult_when_loc(double tjd_start, int32 ipl, char *starname, int32 ifl, double *geopos, double *tret, double *attr, int32 backward, char *serr);
/* finds time of next eclipse globally */
DllImport int32 CALL_CONV_IMP swe_sol_eclipse_when_glob(double tjd_start, int32 ifl, int32 ifltype, double *tret, int32 backward, char *serr);
/* finds time of next occultation globally */
DllImport int32 CALL_CONV_IMP swe_lun_occult_when_glob(double tjd_start, int32 ipl, char *starname, int32 ifl, int32 ifltype, double *tret, int32 backward, char *serr);
/* computes attributes of a lunar eclipse for given tjd */
DllImport int32 CALL_CONV_IMP swe_lun_eclipse_how(
double tjd_ut,
int32 ifl,
double *geopos,
double *attr,
char *serr);
DllImport int32 CALL_CONV_IMP swe_lun_eclipse_when(double tjd_start, int32 ifl, int32 ifltype, double *tret, int32 backward, char *serr);
DllImport int32 CALL_CONV_IMP swe_lun_eclipse_when_loc(double tjd_start, int32 ifl, double *geopos, double *tret, double *attr, int32 backward, char *serr);
/* planetary phenomena */
DllImport int32 CALL_CONV_IMP swe_pheno(double tjd, int32 ipl, int32 iflag, double *attr, char *serr);
DllImport int32 CALL_CONV_IMP swe_pheno_ut(double tjd_ut, int32 ipl, int32 iflag, double *attr, char *serr);
DllImport double CALL_CONV_IMP swe_refrac(double inalt, double atpress, double attemp, int32 calc_flag);
DllImport double CALL_CONV_IMP swe_refrac_extended(double inalt, double geoalt, double atpress, double attemp, double lapse_rate, int32 calc_flag, double *dret);
DllImport void CALL_CONV_IMP swe_set_lapse_rate(double lapse_rate);
DllImport void CALL_CONV_IMP swe_azalt(
double tjd_ut,
int32 calc_flag,
double *geopos,
double atpress,
double attemp,
double *xin,
double *xaz);
DllImport void CALL_CONV_IMP swe_azalt_rev(
double tjd_ut,
int32 calc_flag,
double *geopos,
double *xin,
double *xout);
DllImport int32 CALL_CONV_IMP swe_rise_trans(
double tjd_ut, int32 ipl, char *starname,
int32 epheflag, int32 rsmi,
double *geopos,
double atpress, double attemp,
double *tret,
char *serr);
DllImport int32 CALL_CONV_IMP swe_rise_trans_true_hor(
double tjd_ut, int32 ipl, char *starname,
int32 epheflag, int32 rsmi,
double *geopos,
double atpress, double attemp,
double horhgt,
double *tret,
char *serr);
DllImport int32 CALL_CONV_IMP swe_nod_aps(double tjd_et, int32 ipl, int32 iflag,
int32 method,
double *xnasc, double *xndsc,
double *xperi, double *xaphe,
char *serr);
DllImport int32 CALL_CONV_IMP swe_nod_aps_ut(double tjd_ut, int32 ipl, int32 iflag,
int32 method,
double *xnasc, double *xndsc,
double *xperi, double *xaphe,
char *serr);
/*******************************************************
* other functions from swephlib.c;
* they are not needed for Swiss Ephemeris,
* but may be useful to former Placalc users.
********************************************************/
/* normalize argument into interval [0..DEG360] */
DllImport centisec CALL_CONV_IMP swe_csnorm(centisec p);
/* distance in centisecs p1 - p2 normalized to [0..360[ */
DllImport centisec CALL_CONV_IMP swe_difcsn (centisec p1, centisec p2);
DllImport double CALL_CONV_IMP swe_difdegn (double p1, double p2);
/* distance in centisecs p1 - p2 normalized to [-180..180[ */
DllImport centisec CALL_CONV_IMP swe_difcs2n(centisec p1, centisec p2);
DllImport double CALL_CONV_IMP swe_difdeg2n(double p1, double p2);
DllImport double CALL_CONV_IMP swe_difdeg2n(double p1, double p2);
DllImport double CALL_CONV_IMP swe_difrad2n(double p1, double p2);
DllImport double CALL_CONV_IMP swe_rad_midp(double x1, double x0);
DllImport double CALL_CONV_IMP swe_deg_midp(double x1, double x0);
/* round second, but at 29.5959 always down */
DllImport centisec CALL_CONV_IMP swe_csroundsec(centisec x);
/* double to int32 with rounding, no overflow check */
DllImport int32 CALL_CONV_IMP swe_d2l(double x);
DllImport void CALL_CONV_IMP swe_split_deg(double ddeg, int32 roundflag, int32 *ideg, int32 *imin, int32 *isec, double *dsecfr, int32 *isgn);
/* monday = 0, ... sunday = 6 */
DllImport int CALL_CONV_IMP swe_day_of_week(double jd);
DllImport char * CALL_CONV_IMP swe_cs2timestr(CSEC t, int sep, AS_BOOL suppressZero, char *a);
DllImport char * CALL_CONV_IMP swe_cs2lonlatstr(CSEC t, char pchar, char mchar, char *s);
DllImport char * CALL_CONV_IMP swe_cs2degstr(CSEC t, char *a);
/* additional functions for antiquated GFA basic DLL interface.
* double -> double *
* char -> char *
* void -> int
*/
DllImport int32 CALL_CONV_IMP swe_calc_d(
double *tjd, int ipl, int32 iflag,
double *x,
char *serr);
DllImport int32 CALL_CONV_IMP swe_calc_ut_d(
double *tjd, int16 ipl, int32 iflag,
double *x,
char *serr);
DllImport int32 CALL_CONV_IMP swe_fixstar_d(
char *star, double *tjd, int32 iflag,
double *x,
char *serr);
DllImport int32 CALL_CONV_IMP swe_fixstar_ut_d(
char *star, double *tjd, int32 iflag,
double *x,
char *serr);
DllImport int CALL_CONV_IMP swe_close_d(int ivoid);
DllImport int CALL_CONV_IMP swe_set_ephe_path_d(char *path);
DllImport int CALL_CONV_IMP swe_set_jpl_file_d(char *fname);
DllImport char * CALL_CONV_IMP swe_get_planet_name_d(int ipl, char *spname);
DllImport int CALL_CONV_IMP swe_deltat_d(double *tjd, double *deltat);
DllImport int CALL_CONV_IMP swe_sidtime0_d(double *tjd_ut, double *eps,
double *nut, double *sidt);
DllImport int CALL_CONV_IMP swe_sidtime_d(double *tjd_ut, double *sidt);
DllImport int CALL_CONV_IMP swe_set_sid_mode_d(
int32 sid_mode, double *t0, double *ayan_t0);
DllImport int CALL_CONV_IMP swe_get_ayanamsa_d(double *tjd_et, double *ayan);
DllImport int CALL_CONV_IMP swe_get_ayanamsa_ut_d(double *tjd_et, double *ayan);
DllImport int CALL_CONV_IMP swe_cotrans_d(double *xpo, double *xpn, double *eps);
DllImport int CALL_CONV_IMP swe_cotrans_sp_d(double *xpo, double *xpn, double *eps);
DllImport int CALL_CONV_IMP swe_set_topo_d(double *geolon, double *geolat, double *height);
DllImport int CALL_CONV_IMP swe_get_tid_acc_d(double *t_acc);
DllImport int CALL_CONV_IMP swe_set_tid_acc_d(double *t_acc);
DllImport int CALL_CONV_IMP swe_degnorm_d(double *x);
DllImport int CALL_CONV_IMP swe_date_conversion_d(
int y , int m , int d , /* year, month, day */
double *utime, /* universal time in hours (decimal) */
char *c, /* calendar g[regorian]|j[ulian]|a[stro = greg] */
double *tjd);
DllImport int CALL_CONV_IMP swe_julday_d(
int year, int month, int day, double *hour,
int gregflag, double *tjd);
DllImport int CALL_CONV_IMP swe_revjul_d(
double *tjd,
int gregflag,
int *jyear, int *jmon, int *jday, double *jut);
DllImport int CALL_CONV_IMP swe_houses_d(
double *tjd, double *geolat, double *geolon, int hsys,
double *hcusps, double *ascmc);
DllImport int CALL_CONV_IMP swe_houses_ex_d(
double *tjd_ut, int32 iflag, double *geolat, double *geolon, int hsys,
double *hcusps, double *ascmc);
DllImport int CALL_CONV_IMP swe_houses_armc_d(
double *armc, double *geolat, double *eps, int hsys,
double *hcusps, double *ascmc);
DllImport int CALL_CONV_IMP swe_house_pos_d(
double *armc, double *geolon, double *eps, int hsys, double *xpin, double *hpos, char *serr);
/* normalize argument into interval [0..DEG360] */
DllImport centisec CALL_CONV_IMP swe_csnorm_d(centisec p);
/* distance in centisecs p1 - p2 normalized to [0..360[ */
DllImport centisec CALL_CONV_IMP swe_difcsn_d(centisec p1, centisec p2);
DllImport int CALL_CONV_IMP swe_difdegn_d(double *p1, double *p2, double *diff);
/* distance in centisecs p1 - p2 normalized to [-180..180[ */
DllImport centisec CALL_CONV_IMP swe_difcs2n_d(centisec p1, centisec p2);
DllImport int CALL_CONV_IMP swe_difdeg2n_d(double *p1, double *p2, double *diff);
/* round second, but at 29.5959 always down */
DllImport centisec CALL_CONV_IMP swe_csroundsec_d(centisec x);
/* double to int32 with rounding, no overflow check */
DllImport int32 CALL_CONV_IMP swe_d2l_d(double *x);
DllImport int CALL_CONV_IMP swe_split_deg_d(double *ddeg, int32 roundflag, int32 *ideg, int32 *imin, int32 *isec, double *dsecfr, int32 *isgn);
/* monday = 0, ... sunday = 6 */
DllImport int CALL_CONV_IMP swe_day_of_week_d(double *jd);
DllImport char * CALL_CONV_IMP swe_cs2timestr_d(CSEC t, int sep, AS_BOOL suppressZero, char *a);
DllImport char * CALL_CONV_IMP swe_cs2lonlatstr_d(CSEC t, char *pchar, char *mchar, char *s);
DllImport char * CALL_CONV_IMP swe_cs2degstr_d(CSEC t, char *a);
/****************************
* from swecl.c
****************************/
/* computes geographic location and attributes of solar
* eclipse at a given tjd */
DllImport int32 CALL_CONV_IMP swe_sol_eclipse_where_d(double *tjd_ut, int32 ifl, double *geopos, double *attr, char *serr);
/* computes attributes of a solar eclipse for given tjd, geolon, geolat */
DllImport int32 CALL_CONV_IMP swe_sol_eclipse_how_d(double *tjd_ut, int32 ifl, double geolon, double geolat, double geohgt, double *attr, char *serr);
/* finds time of next local eclipse */
DllImport int32 CALL_CONV_IMP swe_sol_eclipse_when_loc_d(double *tjd_start, int32 ifl, double *geopos, double *tret, double *attr, AS_BOOL backward, char *serr);
/* finds time of next eclipse globally */
DllImport int32 CALL_CONV_IMP swe_sol_eclipse_when_glob_d(double *tjd_start, int32 ifl, int32 ifltype,
double *tret, AS_BOOL backward, char *serr);
/* computes attributes of a lunar eclipse for given tjd */
DllImport int32 CALL_CONV_IMP swe_lun_eclipse_how_d(
double *tjd_ut,
int32 ifl,
double *attr,
char *serr);
DllImport int32 CALL_CONV_IMP swe_lun_eclipse_when_d(double *tjd_start, int32 ifl, int32 ifltype,
double *tret, AS_BOOL backward, char *serr);
DllImport int32 CALL_CONV_IMP swe_pheno_d(double *tjd, int32 ipl, int32 iflag,
double *attr, char *serr);
DllImport int32 CALL_CONV_IMP swe_pheno_ut_d(double *tjd_ut, int32 ipl, int32 iflag, double *attr, char *serr);
DllImport int CALL_CONV_IMP swe_refrac_d(double *inalt, double *atpress, double *attemp, int32 calc_flag, double *retalt);
DllImport int CALL_CONV_IMP swe_azalt_d(
double *tjd_ut,
int32 calc_flag,
double *geopos,
double *atpress,
double *attemp,
double *xin,
double *xaz);
DllImport int CALL_CONV_IMP swe_azalt_rev_d(
double *tjd_ut,
int32 calc_flag,
double *geopos,
double *xin,
double *xout);
DllImport int32 CALL_CONV_IMP swe_rise_trans_d(
double *tjd_ut, int32 ipl, char *starname,
int32 epheflag, int32 rsmi,
double *geopos,
double *atpress, double *attemp,
double *tret,
char *serr);
DllImport int32 CALL_CONV_IMP swe_nod_aps_d(double *tjd_et, int32 ipl, int32 iflag,
int32 method,
double *xnasc, double *xndsc,
double *xperi, double *xaphe,
char *serr);
DllImport int32 CALL_CONV_IMP swe_nod_aps_ut_d(double *tjd_ut, int32 ipl, int32 iflag,
int32 method,
double *xnasc, double *xndsc,
double *xperi, double *xaphe,
char *serr);
#endif /* !_SWEDLL_H */
#ifdef __cplusplus
} /* extern C */
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,85 +0,0 @@
/*******************************************************
$Header: /home/dieter/sweph/RCS/swehouse.h,v 1.74 2008/06/16 10:07:20 dieter Exp $
module swehouse.h
house and (simple) aspect calculation
*******************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
If the developer choses the Swiss Ephemeris Professional license,
he must follow the instructions as found in http://www.astro.com/swisseph/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
struct houses {
double cusp[37];
double ac;
double mc;
double vertex;
double equasc;
double coasc1;
double coasc2;
double polasc;
};
#define HOUSES struct houses
#define VERY_SMALL 1E-10
#define degtocs(x) (d2l((x) * DEG))
#define cstodeg(x) (double)((x) * CS2DEG)
#define sind(x) sin(x * DEGTORAD)
#define cosd(x) cos(x * DEGTORAD)
#define tand(x) tan(x * DEGTORAD)
#define asind(x) (asin(x) * RADTODEG)
#define acosd(x) (acos(x) * RADTODEG)
#define atand(x) (atan(x) * RADTODEG)
#define atan2d(y, x) (atan2(y, x) * RADTODEG)

View File

@ -1,931 +0,0 @@
/*
| $Header: /home/dieter/sweph/RCS/swejpl.c,v 1.76 2008/08/26 13:55:36 dieter Exp $
|
| Subroutines for reading JPL ephemerides.
| derived from testeph.f as contained in DE403 distribution July 1995.
| works with DE200, DE102, DE403, DE404, DE405, DE406, DE431
| (attention, these ephemerides do not have exactly the same reference frame)
Authors: Dieter Koch and Alois Treindl, Astrodienst Zurich
************************************************************/
/* Copyright (C) 1997 - 2008 Astrodienst AG, Switzerland. All rights reserved.
License conditions
------------------
This file is part of Swiss Ephemeris.
Swiss Ephemeris is distributed with NO WARRANTY OF ANY KIND. No author
or distributor accepts any responsibility for the consequences of using it,
or for whether it serves any particular purpose or works at all, unless he
or she says so in writing.
Swiss Ephemeris is made available by its authors under a dual licensing
system. The software developer, who uses any part of Swiss Ephemeris
in his or her software, must choose between one of the two license models,
which are
a) GNU public license version 2 or later
b) Swiss Ephemeris Professional License
The choice must be made before the software developer distributes software
containing parts of Swiss Ephemeris to others, and before any public
service using the developed software is activated.
If the developer choses the GNU GPL software license, he or she must fulfill
the conditions of that license, which includes the obligation to place his
or her whole software project under the GNU GPL or a compatible license.
See http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
If the developer choses the Swiss Ephemeris Professional license,
he must follow the instructions as found in http://www.astro.com/swisseph/
and purchase the Swiss Ephemeris Professional Edition from Astrodienst
and sign the corresponding license contract.
The License grants you the right to use, copy, modify and redistribute
Swiss Ephemeris, but only under certain conditions described in the License.
Among other things, the License requires that the copyright notices and
this notice be preserved on all copies.
Authors of the Swiss Ephemeris: Dieter Koch and Alois Treindl
The authors of Swiss Ephemeris have no control or influence over any of
the derived works, i.e. over software or services created by other
programmers which use Swiss Ephemeris functions.
The names of the authors or of the copyright holder (Astrodienst) must not
be used for promoting any software, product or service which uses or contains
the Swiss Ephemeris. This copyright notice is the ONLY place where the
names of the authors can legally appear, except in cases where they have
given special permission in writing.
The trademarks 'Swiss Ephemeris' and 'Swiss Ephemeris inside' may be used
for promoting such software, products or services.
*/
#if MSDOS
#else
#define _FILE_OFFSET_BITS 64
#endif
#include <string.h>
#include "swephexp.h"
#include "sweph.h"
#include "swejpl.h"
#if MSDOS
extern __int64 __cdecl _ftelli64(FILE *);
extern int __cdecl _fseeki64(FILE *, __int64, int);
typedef __int64 off_t;
#define FSEEK _fseeki64
#define FTELL _ftelli64
#else
#define FSEEK fseeko
#define FTELL ftello
#endif
#define DEBUG_DO_SHOW FALSE
/*
* local globals
*/
struct jpl_save {
char *jplfname;
char *jplfpath;
FILE *jplfptr;
short do_reorder;
double eh_cval[400];
double eh_ss[3], eh_au, eh_emrat;
int32 eh_denum, eh_ncon, eh_ipt[39];
char ch_cnam[6*400];
double pv[78];
double pvsun[6];
double buf[1500];
double pc[18], vc[18], ac[18], jc[18];
short do_km;
};
static TLS struct jpl_save *js;
static int state (double et, int32 *list, int do_bary,
double *pv, double *pvsun, double *nut, char *serr);
static int interp(double *buf, double t, double intv, int32 ncfin,
int32 ncmin, int32 nain, int32 ifl, double *pv);
static int32 fsizer(char *serr);
static void reorder(char *x, int size, int number);
static int read_const_jpl(double *ss, char *serr);
/* information about eh_ipt[] and buf[]
DE200 DE102 DE403
3 3 ipt[0] 3 body 0 (mercury) starts at buf[2]
12 15 ipt[1] 14 body 0, ncf = coefficients per component
4 2 ipt[2] 4 na = nintervals, tot 14*4*3=168
147 93 ipt[3] 171 body 1 (venus) starts at buf[170]
12 15 ipt[4] 10 ncf = coefficients per component
1 1 ipt[5] 2 total 10*2*3=60
183 138 ipt[6] 231 body 2 (earth) starts at buf[230]
15 15 ipt[7] 13 ncf = coefficients per component
2 2 ipt[8] 2 total 13*2*3=78
273 228 ipt[9] 309 body 3 (mars) starts at buf[308]
10 10 ipt[10] 11 ncf = coefficients per component
1 1 ipt[11] 1 total 11*1*3=33
303 258 ipt[12] 342 body 4 (jupiter) at buf[341]
9 9 ipt[13] 8 total 8 * 1 * 3 = 24
1 1 ipt[14] 1
330 285 ipt[15] 366 body 5 (saturn) at buf[365]
8 8 ipt[16] 7 total 7 * 1 * 3 = 21
1 1 ipt[17] 1
354 309 ipt[18] 387 body 6 (uranus) at buf[386]
8 8 ipt[19] 6 total 6 * 1 * 3 = 18
1 1 ipt[20] 1
378 333 ipt[21] 405 body 7 (neptune) at buf[404]
6 6 ipt[22] 6 total 18
1 1 ipt[23] 1
396 351 ipt[24] 423 body 8 (pluto) at buf[422]
6 6 ipt[25] 6 total 18
1 1 ipt[26] 1
414 369 ipt[27] 441 body 9 (moon) at buf[440]
12 15 ipt[28] 13 total 13 * 8 * 3 = 312
8 8 ipt[29] 8
702 729 ipt[30] 753 SBARY SUN, starts at buf[752]
15 15 ipt[31] 11 SBARY SUN, ncf = coeff per component
1 1 ipt[32] 2 total 11*2*3=66
747 774 ipt[33] 819 nutations, starts at buf[818]
10 0 ipt[34] 10 total 10 * 4 * 2 = 80
4 0 ipt[35] 4 (nutation only two coordinates)
0 0 ipt[36] 899 librations, start at buf[898]
0 0 ipt[37] 10 total 10 * 4 * 3 = 120
0 0 ipt[38] 4
last element of buf[1017]
buf[0] contains start jd and buf[1] end jd of segment;
each segment is 32 days in de403, 64 days in DE102, 32 days in DE200
Length of blocks: DE406 = 1456*4=5824 bytes = 728 double
DE405 = 2036*4=8144 bytes = 1018 double
DE404 = 1456*4=5824 bytes = 728 double
DE403 = 2036*4=8144 bytes = 1018 double
DE200 = 1652*4=6608 bytes = 826 double
DE102 = 1546*4=6184 bytes = 773 double
each DE102 record has 53*8=424 fill bytes so that
the records have the same length as DE200.
*/
/*
* This subroutine opens the file jplfname, with a phony record length,
* reads the first record, and uses the info to compute ksize,
* the number of single precision words in a record.
* RETURN: ksize (record size of ephemeris data)
* jplfptr is opened on return.
* note 26-aug-2008: now record size is computed by fsizer(), not
* set to a fixed value depending as in previous releases. The caller of
* fsizer() will verify by data comparison whether it computed correctly.
*/
static int32 fsizer(char *serr)
{
/* Local variables */
int32 ncon;
double emrat;
int32 numde;
double au, ss[3];
int i, kmx, khi, nd;
int32 ksize, lpt[3];
char ttl[6*14*3];
if ((js->jplfptr = swi_fopen(SEI_FILE_PLANET, js->jplfname, js->jplfpath, serr)) == NULL) {
return NOT_AVAILABLE;
}
/* ttl = ephemeris title, e.g.
* "JPL Planetary Ephemeris DE404/LE404
* Start Epoch: JED= 625296.5-3001 DEC 21 00:00:00
* Final Epoch: JED= 2817168.5 3001 JAN 17 00:00:00c */
fread((void *) &ttl[0], 1, 252, js->jplfptr);
/* cnam = names of constants */
fread((void *) js->ch_cnam, 1, 6*400, js->jplfptr);
/* ss[0] = start epoch of ephemeris
* ss[1] = end epoch
* ss[2] = segment size in days */
fread((void *) &ss[0], sizeof(double), 3, js->jplfptr);
/* reorder ? */
if (ss[2] < 1 || ss[2] > 200)
js->do_reorder = TRUE;
else
js->do_reorder = 0;
for (i = 0; i < 3; i++)
js->eh_ss[i] = ss[i];
if (js->do_reorder)
reorder((char *) &js->eh_ss[0], sizeof(double), 3);
/* plausibility test of these constants. Start and end date must be
* between -20000 and +20000, segment size >= 1 and <= 200 */
if (js->eh_ss[0] < -5583942 || js->eh_ss[1] > 9025909 || js->eh_ss[2] < 1 || js->eh_ss[2] > 200) {
if (serr != NULL) {
strcpy(serr, "alleged ephemeris file has invalid format.");
if (strlen(serr) + strlen(js->jplfname) + 3 < AS_MAXCH) {
sprintf(serr, "alleged ephemeris file (%s) has invalid format.", js->jplfname);
}
}
return(NOT_AVAILABLE);
}
/* ncon = number of constants */
fread((void *) &ncon, sizeof(int32), 1, js->jplfptr);
if (js->do_reorder)
reorder((char *) &ncon, sizeof(int32), 1);
/* au = astronomical unit */
fread((void *) &au, sizeof(double), 1, js->jplfptr);
if (js->do_reorder)
reorder((char *) &au, sizeof(double), 1);
/* emrat = earth moon mass ratio */
fread((void *) &emrat, sizeof(double), 1, js->jplfptr);
if (js->do_reorder)
reorder((char *) &emrat, sizeof(double), 1);
/* ipt[i+0]: coefficients of planet i start at buf[ipt[i+0]-1]
* ipt[i+1]: number of coefficients (interpolation order - 1)
* ipt[i+2]: number of intervals in segment */
fread((void *) &js->eh_ipt[0], sizeof(int32), 36, js->jplfptr);
if (js->do_reorder)
reorder((char *) &js->eh_ipt[0], sizeof(int32), 36);
/* numde = number of jpl ephemeris "404" with de404 */
fread((void *) &numde, sizeof(int32), 1, js->jplfptr);
if (js->do_reorder)
reorder((char *) &numde, sizeof(int32), 1);
/* read librations */
fread(&lpt[0], sizeof(int32), 3, js->jplfptr);
if (js->do_reorder)
reorder((char *) &lpt[0], sizeof(int32), 3);
/* fill librations into eh_ipt[36]..[38] */
for (i = 0; i < 3; ++i)
js->eh_ipt[i + 36] = lpt[i];
rewind(js->jplfptr);
/* find the number of ephemeris coefficients from the pointers */
/* re-activated this code on 26-aug-2008 */
kmx = 0;
khi = 0;
for (i = 0; i < 13; i++) {
if (js->eh_ipt[i * 3] > kmx) {
kmx = js->eh_ipt[i * 3];
khi = i + 1;
}
}
if (khi == 12)
nd = 2;
else
nd = 3;
ksize = (js->eh_ipt[khi * 3 - 3] + nd * js->eh_ipt[khi * 3 - 2] * js->eh_ipt[khi * 3 - 1] - 1L) * 2L;
/*
* de102 files give wrong ksize, because they contain 424 empty bytes
* per record. Fixed by hand!
*/
if (ksize == 1546)
ksize = 1652;
#if 0 /* we prefer to compute ksize to be comaptible
with new DE releases */
switch (numde) {
case 403:
case 405:
case 410:
case 413:
case 414:
case 418:
case 421:
ksize = 2036;
break;
case 404:
case 406:
ksize = 1456;
break;
case 200:
ksize = 1652;
break;
case 102:
ksize = 1652; /* de102 is filled with blanks to length of de200 */
break;
default:
if (serr != NULL)
sprintf(serr,"unknown numde value %d;", numde);
return ERR;
}
#endif
if (ksize < 1000 || ksize > 5000) {
if (serr != NULL)
sprintf(serr, "JPL ephemeris file does not provide valid ksize (%d)", ksize);/**/
return NOT_AVAILABLE;
}
return ksize;
}
/*
* This subroutine reads the jpl planetary ephemeris
* and gives the position and velocity of the point 'ntarg'
* with respect to 'ncent'.
* calling sequence parameters:
* et = d.p. julian ephemeris date at which interpolation
* is wanted.
* ** note the entry dpleph for a doubly-dimensioned time **
* the reason for this option is discussed in the
* subroutine state
* ntarg = integer number of 'target' point.
* ncent = integer number of center point.
* the numbering convention for 'ntarg' and 'ncent' is:
* 0 = mercury 7 = neptune
* 1 = venus 8 = pluto
* 2 = earth 9 = moon
* 3 = mars 10 = sun
* 4 = jupiter 11 = solar-system barycenter
* 5 = saturn 12 = earth-moon barycenter
* 6 = uranus 13 = nutations (longitude and obliq)
* 14 = librations, if on eph file
* (if nutations are wanted, set ntarg = 13. for librations,
* set ntarg = 14. set ncent=0.)
* rrd = output 6-word d.p. array containing position and velocity
* of point 'ntarg' relative to 'ncent'. the units are au and
* au/day. for librations the units are radians and radians
* per day. in the case of nutations the first four words of
* rrd will be set to nutations and rates, having units of
* radians and radians/day.
* The option is available to have the units in km and km/sec.
* For this, set do_km=TRUE (default FALSE).
*/
int swi_pleph(double et, int ntarg, int ncent, double *rrd, char *serr)
{
int i, retc;
int32 list[12];
double *pv = js->pv;
double *pvsun = js->pvsun;
for (i = 0; i < 6; ++i)
rrd[i] = 0.0;
if (ntarg == ncent)
return 0;
for (i = 0; i < 12; ++i)
list[i] = 0;
/* check for nutation call */
if (ntarg == J_NUT) {
if (js->eh_ipt[34] > 0) {
list[10] = 2;
return(state(et, list, FALSE, pv, pvsun, rrd, serr));
} else {
if (serr != NULL)
sprintf(serr,"No nutations on the JPL ephemeris file;");
return (NOT_AVAILABLE);
}
}
if (ntarg == J_LIB) {
if (js->eh_ipt[37] > 0) {
list[11] = 2;
if ((retc = state(et, list, FALSE, pv, pvsun, rrd, serr)) != OK)
return (retc);
for (i = 0; i < 6; ++i)
rrd[i] = pv[i + 60];
return 0;
} else {
if (serr != NULL)
sprintf(serr,"No librations on the ephemeris file;");
return (NOT_AVAILABLE);
}
}
/* set up proper entries in 'list' array for state call */
if (ntarg < J_SUN)
list[ntarg] = 2;
if (ntarg == J_MOON) /* Mooon needs Earth */
list[J_EARTH] = 2;
if (ntarg == J_EARTH) /* Earth needs Moon */
list[J_MOON] = 2;
if (ntarg == J_EMB) /* EMB needs Earth */
list[J_EARTH] = 2;
if (ncent < J_SUN)
list[ncent] = 2;
if (ncent == J_MOON) /* Mooon needs Earth */
list[J_EARTH] = 2;
if (ncent == J_EARTH) /* Earth needs Moon */
list[J_MOON] = 2;
if (ncent == J_EMB) /* EMB needs Earth */
list[J_EARTH] = 2;
if ((retc = state(et, list, TRUE, pv, pvsun, rrd, serr)) != OK)
return (retc);
if (ntarg == J_SUN || ncent == J_SUN) {
for (i = 0; i < 6; ++i)
pv[i + 6*J_SUN] = pvsun[i];
}
if (ntarg == J_SBARY || ncent == J_SBARY) {
for (i = 0; i < 6; ++i) {
pv[i + 6*J_SBARY] = 0.;
}
}
if (ntarg == J_EMB || ncent == J_EMB) {
for (i = 0; i < 6; ++i)
pv[i + 6*J_EMB] = pv[i + 6*J_EARTH];
}
if ((ntarg==J_EARTH && ncent==J_MOON) || (ntarg == J_MOON && ncent==J_EARTH)){
for (i = 0; i < 6; ++i)
pv[i + 6*J_EARTH] = 0.;
} else {
if (list[J_EARTH] == 2) {
for (i = 0; i < 6; ++i)
pv[i + 6*J_EARTH] -= pv[i + 6*J_MOON] / (js->eh_emrat + 1.);
}
if (list[J_MOON] == 2) {
for (i = 0; i < 6; ++i) {
pv[i + 6*J_MOON] += pv[i + 6*J_EARTH];
}
}
}
for (i = 0; i < 6; ++i)
rrd[i] = pv[i + ntarg * 6] - pv[i + ncent * 6];
return OK;
}
/*
* This subroutine differentiates and interpolates a
* set of chebyshev coefficients to give pos, vel, acc, and jerk
* calling sequence parameters:
* input:
* buf 1st location of array of d.p. chebyshev coefficients of position
* t is dp fractional time in interval covered by
* coefficients at which interpolation is wanted, 0 <= t <= 1
* intv is dp length of whole interval in input time units.
* ncf number of coefficients per component
* ncm number of components per set of coefficients
* na number of sets of coefficients in full array
* (i.e., number of sub-intervals in full interval)
* ifl int flag: =1 for positions only
* =2 for pos and vel
* =3 for pos, vel, and acc
* =4 for pos, vel, acc, and jerk
* output:
* pv d.p. interpolated quantities requested.
* assumed dimension is pv(ncm,fl).
*/
static int interp(double *buf, double t, double intv, int32 ncfin,
int32 ncmin, int32 nain, int32 ifl, double *pv)
{
/* Initialized data */
static TLS int np, nv;
static TLS int nac;
static TLS int njk;
static TLS double twot = 0.;
double *pc = js->pc;
double *vc = js->vc;
double *ac = js->ac;
double *jc = js->jc;
int ncf = (int) ncfin;
int ncm = (int) ncmin;
int na = (int) nain;
/* Local variables */
double temp;
int i, j, ni;
double tc;
double dt1, bma;
double bma2, bma3;
/*
| get correct sub-interval number for this set of coefficients and then
| get normalized chebyshev time within that subinterval.
*/
if (t >= 0)
dt1 = floor(t);
else
dt1 = -floor(-t);
temp = na * t;
ni = (int) (temp - dt1);
/* tc is the normalized chebyshev time (-1 <= tc <= 1) */
tc = (fmod(temp, 1.0) + dt1) * 2. - 1.;
/*
* check to see whether chebyshev time has changed,
* and compute new polynomial values if it has.
* (the element pc(2) is the value of t1(tc) and hence
* contains the value of tc on the previous call.)
*/
if (tc != pc[1]) {
np = 2;
nv = 3;
nac = 4;
njk = 5;
pc[1] = tc;
twot = tc + tc;
}
/*
* be sure that at least 'ncf' polynomials have been evaluated
* and are stored in the array 'pc'.
*/
if (np < ncf) {
for (i = np; i < ncf; ++i)
pc[i] = twot * pc[i - 1] - pc[i - 2];
np = ncf;
}
/* interpolate to get position for each component */
for (i = 0; i < ncm; ++i) {
pv[i] = 0.;
for (j = ncf-1; j >= 0; --j)
pv[i] += pc[j] * buf[j + (i + ni * ncm) * ncf];
}
if (ifl <= 1)
return 0;
/*
* if velocity interpolation is wanted, be sure enough
* derivative polynomials have been generated and stored.
*/
bma = (na + na) / intv;
vc[2] = twot + twot;
if (nv < ncf) {
for (i = nv; i < ncf; ++i)
vc[i] = twot * vc[i - 1] + pc[i - 1] + pc[i - 1] - vc[i - 2];
nv = ncf;
}
/* interpolate to get velocity for each component */
for (i = 0; i < ncm; ++i) {
pv[i + ncm] = 0.;
for (j = ncf-1; j >= 1; --j)
pv[i + ncm] += vc[j] * buf[j + (i + ni * ncm) * ncf];
pv[i + ncm] *= bma;
}
if (ifl == 2)
return 0;
/* check acceleration polynomial values, and */
/* re-do if necessary */
bma2 = bma * bma;
ac[3] = pc[1] * 24.;
if (nac < ncf) {
nac = ncf;
for (i = nac; i < ncf; ++i)
ac[i] = twot * ac[i - 1] + vc[i - 1] * 4. - ac[i - 2];
}
/* get acceleration for each component */
for (i = 0; i < ncm; ++i) {
pv[i + ncm * 2] = 0.;
for (j = ncf-1; j >= 2; --j)
pv[i + ncm * 2] += ac[j] * buf[j + (i + ni * ncm) * ncf];
pv[i + ncm * 2] *= bma2;
}
if (ifl == 3)
return 0;
/* check jerk polynomial values, and */
/* re-do if necessary */
bma3 = bma * bma2;
jc[4] = pc[1] * 192.;
if (njk < ncf) {
njk = ncf;
for (i = njk; i < ncf; ++i)
jc[i] = twot * jc[i - 1] + ac[i - 1] * 6. - jc[i - 2];
}
/* get jerk for each component */
for (i = 0; i < ncm; ++i) {
pv[i + ncm * 3] = 0.;
for (j = ncf-1; j >= 3; --j)
pv[i + ncm * 3] += jc[j] * buf[j + (i + ni * ncm) * ncf];
pv[i + ncm * 3] *= bma3;
}
return 0;
}
/*
| ********** state ********************
| this subroutine reads and interpolates the jpl planetary ephemeris file
| calling sequence parameters:
| input:
| et dp julian ephemeris epoch at which interpolation is wanted.
| list 12-word integer array specifying what interpolation
| is wanted for each of the bodies on the file.
| list(i)=0, no interpolation for body i
| =1, position only
| =2, position and velocity
| the designation of the astronomical bodies by i is:
| i = 0: mercury
| = 1: venus
| = 2: earth-moon barycenter, NOT earth!
| = 3: mars
| = 4: jupiter
| = 5: saturn
| = 6: uranus
| = 7: neptune
| = 8: pluto
| = 9: geocentric moon
| =10: nutations in longitude and obliquity
| =11: lunar librations (if on file)
| If called with list = NULL, only the header records are read and
| stored in the global areas.
| do_bary short, if true, barycentric, if false, heliocentric.
| only the 9 planets 0..8 are affected by it.
| output:
| pv dp 6 x 11 array that will contain requested interpolated
| quantities. the body specified by list(i) will have its
| state in the array starting at pv(1,i). (on any given
| call, only those words in 'pv' which are affected by the
| first 10 'list' entries (and by list(11) if librations are
| on the file) are set. the rest of the 'pv' array
| is untouched.) the order of components starting in
| pv is: x,y,z,dx,dy,dz.
| all output vectors are referenced to the earth mean
| equator and equinox of epoch. the moon state is always
| geocentric; the other nine states are either heliocentric
| or solar-system barycentric, depending on the setting of
| common flags (see below).
| lunar librations, if on file, are put into pv(k,10) if
| list(11) is 1 or 2.
| pvsun dp 6-word array containing the barycentric position and
| velocity of the sun.
| nut dp 4-word array that will contain nutations and rates,
| depending on the setting of list(10). the order of
| quantities in nut is:
| d psi (nutation in longitude)
| d epsilon (nutation in obliquity)
| d psi dot
| d epsilon dot
| globals used:
| do_km logical flag defining physical units of the output states.
| TRUE = return km and km/sec, FALSE = return au and au/day
| default value = FALSE (km determines time unit
| for nutations and librations. angle unit is always radians.)
*/
static int state(double et, int32 *list, int do_bary,
double *pv, double *pvsun, double *nut, char *serr)
{
int i, j, k;
int32 nseg;
off_t flen, nb;
double *buf = js->buf;
double aufac, s, t, intv, ts[4];
int32 nrecl, ksize;
int32 nr;
double et_mn, et_fr;
int32 *ipt = js->eh_ipt;
char ch_ttl[252];
static TLS int32 irecsz;
static TLS int32 nrl, lpt[3], ncoeffs;
if (js->jplfptr == NULL) {
ksize = fsizer(serr); /* the number of single precision words in a record */
nrecl = 4;
if (ksize == NOT_AVAILABLE)
return NOT_AVAILABLE;
irecsz = nrecl * ksize; /* record size in bytes */
ncoeffs = ksize / 2; /* # of coefficients, doubles */
/* ttl = ephemeris title, e.g.
* "JPL Planetary Ephemeris DE404/LE404
* Start Epoch: JED= 625296.5-3001 DEC 21 00:00:00
* Final Epoch: JED= 2817168.5 3001 JAN 17 00:00:00c */
fread((void *) ch_ttl, 1, 252, js->jplfptr);
/* cnam = names of constants */
fread((void *) js->ch_cnam, 1, 2400, js->jplfptr);
/* ss[0] = start epoch of ephemeris
* ss[1] = end epoch
* ss[2] = segment size in days */
fread((void *) &js->eh_ss[0], sizeof(double), 3, js->jplfptr);
if (js->do_reorder)
reorder((char *) &js->eh_ss[0], sizeof(double), 3);
/* ncon = number of constants */
fread((void *) &js->eh_ncon, sizeof(int32), 1, js->jplfptr);
if (js->do_reorder)
reorder((char *) &js->eh_ncon, sizeof(int32), 1);
/* au = astronomical unit */
fread((void *) &js->eh_au, sizeof(double), 1, js->jplfptr);
if (js->do_reorder)
reorder((char *) &js->eh_au, sizeof(double), 1);
/* emrat = earth moon mass ratio */
fread((void *) &js->eh_emrat, sizeof(double), 1, js->jplfptr);
if (js->do_reorder)
reorder((char *) &js->eh_emrat, sizeof(double), 1);
/* ipt[i+0]: coefficients of planet i start at buf[ipt[i+0]-1]
* ipt[i+1]: number of coefficients (interpolation order - 1)
* ipt[i+2]: number of intervals in segment */
fread((void *) &ipt[0], sizeof(int32), 36, js->jplfptr);
if (js->do_reorder)
reorder((char *) &ipt[0], sizeof(int32), 36);
/* numde = number of jpl ephemeris "404" with de404 */
fread((void *) &js->eh_denum, sizeof(int32), 1, js->jplfptr);
if (js->do_reorder)
reorder((char *) &js->eh_denum, sizeof(int32), 1);
fread((void *) &lpt[0], sizeof(int32), 3, js->jplfptr);
if (js->do_reorder)
reorder((char *) &lpt[0], sizeof(int32), 3);
/* cval[]: other constants in next record */
FSEEK(js->jplfptr, (off_t) (1L * irecsz), 0);
fread((void *) &js->eh_cval[0], sizeof(double), 400, js->jplfptr);
if (js->do_reorder)
reorder((char *) &js->eh_cval[0], sizeof(double), 400);
/* new 26-aug-2008: verify correct block size */
for (i = 0; i < 3; ++i)
ipt[i + 36] = lpt[i];
nrl = 0;
/* is file length correct? */
/* file length */
FSEEK(js->jplfptr, (off_t) 0L, SEEK_END);
flen = FTELL(js->jplfptr);
/* # of segments in file */
nseg = (int32) ((js->eh_ss[1] - js->eh_ss[0]) / js->eh_ss[2]);
/* sum of all cheby coeffs of all planets and segments */
for(i = 0, nb = 0; i < 13; i++) {
k = 3;
if (i == 11)
k = 2;
nb += (ipt[i*3+1] * ipt[i*3+2]) * k * nseg;
}
/* add start and end epochs of segments */
nb += 2 * nseg;
/* doubles to bytes */
nb *= 8;
/* add size of header and constants section */
nb += 2 * ksize * nrecl;
if (flen != nb
/* some of our files are one record too long */
&& flen - nb != ksize * nrecl
) {
if (serr != NULL) {
sprintf(serr, "JPL ephemeris file is mutilated; length = %d instead of %d.", (unsigned int) flen, (unsigned int) nb);
if (strlen(serr) + strlen(js->jplfname) < AS_MAXCH - 1) {
sprintf(serr, "JPL ephemeris file %s is mutilated; length = %d instead of %d.", js->jplfname, (unsigned int) flen, (unsigned int) nb);
}
}
return(NOT_AVAILABLE);
}
/* check if start and end dates in segments are the same as in
* file header */
FSEEK(js->jplfptr, (off_t) (2L * irecsz), 0);
fread((void *) &ts[0], sizeof(double), 2, js->jplfptr);
if (js->do_reorder)
reorder((char *) &ts[0], sizeof(double), 2);
FSEEK(js->jplfptr, (off_t) ((nseg + 2 - 1) * ((off_t) irecsz)), 0);
fread((void *) &ts[2], sizeof(double), 2, js->jplfptr);
if (js->do_reorder)
reorder((char *) &ts[2], sizeof(double), 2);
if (ts[0] != js->eh_ss[0] || ts[3] != js->eh_ss[1]) {
if (serr != NULL)
sprintf(serr, "JPL ephemeris file is corrupt; start/end date check failed. %.1f != %.1f || %.1f != %.1f", ts[0],js->eh_ss[0],ts[3],js->eh_ss[1]);
return NOT_AVAILABLE;
}
}
if (list == NULL)
return 0;
s = et - .5;
et_mn = floor(s);
et_fr = s - et_mn; /* fraction of days since previous midnight */
et_mn += .5; /* midnight before epoch */
/* error return for epoch out of range */
if (et < js->eh_ss[0] || et > js->eh_ss[1]) {
if (serr != NULL)
sprintf(serr,"jd %f outside JPL eph. range %.2f .. %.2f;", et, js->eh_ss[0], js->eh_ss[1]);
return BEYOND_EPH_LIMITS;
}
/* calculate record # and relative time in interval */
nr = (int32) ((et_mn - js->eh_ss[0]) / js->eh_ss[2]) + 2;
if (et_mn == js->eh_ss[1])
--nr; /* end point of ephemeris, use last record */
t = (et_mn - ((nr - 2) * js->eh_ss[2] + js->eh_ss[0]) + et_fr) / js->eh_ss[2];
/* read correct record if not in core */
if (nr != nrl) {
nrl = nr;
if (FSEEK(js->jplfptr, (off_t) (nr * ((off_t) irecsz)), 0) != 0) {
if (serr != NULL)
sprintf(serr, "Read error in JPL eph. at %f\n", et);
return NOT_AVAILABLE;
}
for (k = 1; k <= ncoeffs; ++k) {
if ( fread((void *) &buf[k - 1], sizeof(double), 1, js->jplfptr) != 1) {
if (serr != NULL)
sprintf(serr, "Read error in JPL eph. at %f\n", et);
return NOT_AVAILABLE;
}
if (js->do_reorder)
reorder((char *) &buf[k-1], sizeof(double), 1);
}
}
if (js->do_km) {
intv = js->eh_ss[2] * 86400.;
aufac = 1.;
} else {
intv = js->eh_ss[2];
aufac = 1. / js->eh_au;
}
/* interpolate ssbary sun */
interp(&buf[(int) ipt[30] - 1], t, intv, ipt[31], 3L, ipt[32], 2L, pvsun);
for (i = 0; i < 6; ++i) {
pvsun[i] *= aufac;
}
/* check and interpolate whichever bodies are requested */
for (i = 0; i < 10; ++i) {
if (list[i] > 0) {
interp(&buf[(int) ipt[i * 3] - 1], t, intv, ipt[i * 3 + 1], 3L,
ipt[i * 3 + 2], list[i], &pv[i * 6]);
for (j = 0; j < 6; ++j) {
if (i < 9 && ! do_bary) {
pv[j + i * 6] = pv[j + i * 6] * aufac - pvsun[j];
} else {
pv[j + i * 6] *= aufac;
}
}
}
}
/* do nutations if requested (and if on file) */
if (list[10] > 0 && ipt[34] > 0) {
interp(&buf[(int) ipt[33] - 1], t, intv, ipt[34], 2L, ipt[35],
list[10], nut);
}
/* get librations if requested (and if on file) */
if (list[11] > 0 && ipt[37] > 0) {
interp(&buf[(int) ipt[36] - 1], t, intv, ipt[37], 3L, ipt[38], list[1],
&pv[60]);
}
return OK;
}
/*
* this entry obtains the constants from the ephemeris file
* call state to initialize the ephemeris and read in the constants
*/
static int read_const_jpl(double *ss, char *serr)
{
int i, retc;
retc = state(0.0, NULL, FALSE, NULL, NULL, NULL, serr);
if (retc != OK)
return (retc);
for (i = 0; i < 3; i++)
ss[i] = js->eh_ss[i];
#if DEBUG_DO_SHOW
{
static const char *bname[] = {
"Mercury", "Venus", "EMB", "Mars", "Jupiter", "Saturn",
"Uranus", "Neptune", "Pluto", "Moon", "SunBary", "Nut", "Libr"};
int j, k;
int32 nb, nc;
printf(" JPL TEST-EPHEMERIS program. Version October 1995.\n");
for (i = 0; i < 13; i++) {
j = i * 3;
k = 3;
if (i == 11) k = 2;
nb = js->eh_ipt[j+1] * js->eh_ipt[j+2] * k;
nc = (int32) (nb * 36525L / js->eh_ss[2] * 8L);
printf("%s\t%d\tipt[%d]\t%3ld %2ld %2ld,\t",
bname[i], i, j, js->eh_ipt[j], js->eh_ipt[j+1], js->eh_ipt[j+2]);
printf("%3ld double, bytes per century = %6ld\n", nb, nc);
fflush(stdout);
}
printf("%16.2f %16.2f %16.2f\n", js->eh_ss[0], js->eh_ss[1], js->eh_ss[2]);
for (i = 0; i < js->eh_ncon; ++i)
printf("%.6s\t%24.16f\n", js->ch_cnam + i * 6, js->eh_cval[i]);
fflush(stdout);
}
#endif
return OK;
}
static void reorder(char *x, int size, int number)
{
int i, j;
char s[8];
char *sp1 = x;
char *sp2 = &s[0];
for (i = 0; i < number; i++) {
for (j = 0; j < size; j++)
*(sp2 + j) = *(sp1 + size - j - 1);
for (j = 0; j < size; j++)
*(sp1 + j) = *(sp2 + j);
sp1 += size;
}
}
void swi_close_jpl_file(void)
{
if (js != NULL) {
if (js->jplfptr != NULL)
fclose(js->jplfptr);
if (js->jplfname != NULL)
FREE((void *) js->jplfname);
if (js->jplfpath != NULL)
FREE((void *) js->jplfpath);
FREE((void *) js);
js = NULL;
}
}
int swi_open_jpl_file(double *ss, char *fname, char *fpath, char *serr)
{
int retc = OK;
/* if open, return */
if (js != NULL && js->jplfptr != NULL)
return OK;
if ((js = (struct jpl_save *) CALLOC(1, sizeof(struct jpl_save))) == NULL
|| (js->jplfname = MALLOC(strlen(fname)+1)) == NULL
|| (js->jplfpath = MALLOC(strlen(fpath)+1)) == NULL
) {
if (serr != NULL)
strcpy(serr, "error in malloc() with JPL ephemeris.");
return ERR;
}
strcpy(js->jplfname, fname);
strcpy(js->jplfpath, fpath);
retc = read_const_jpl(ss, serr);
if (retc != OK)
swi_close_jpl_file();
else {
/* intializations for function interpol() */
js->pc[0] = 1;
js->pc[1] = 2;
js->vc[1] = 1;
js->ac[2] = 4;
js->jc[3] = 24;
}
return retc;
}
int32 swi_get_jpl_denum()
{
return js->eh_denum;
}

Some files were not shown because too many files have changed in this diff Show More