/perl-sweph

perl module encapsulating the Swiss Ephemeris library

Primary LanguagePerlOtherNOASSERTION

SwissEph Perl module

version 2.10.03

Introduction

The README is used to introduce the module and provide instructions on how to install the module, any machine dependencies it may have (for example C compilers and installed libraries) and any other information that should be provided before the module is installed.

Documentation

Documentation is contained in file lib/SwissEph.pm in Perl's pod format.

It can be accessed with:

perldoc lib/SwissEph.pm

or, once the module is installed, with

perldoc -m SwissEph

Testing from command line

A Perl function can be easily tested from the command line. This makes it very easy to test Swiss Ephemeris functions.

Example: compute Sun position on a given date 7 August 2021, at 14h UT.

perl -e 'use SwissEph qw(:all); use Data::Dumper qw( Dumper ); swe_set_ephe_path("");
         $jd = swe_julday(2021, 8, 7, 14.0, SE_GREG_CAL); $r = swe_calc($jd,SE_SUN,SEFLG_SPEED);
	 print Dumper($jd,$r);'
$VAR1 = '2459434.08333333';
$VAR2 = {
  'retval' => 256,
  'xx' =>
  [
    '135.282856317952',
    '0.000158106543899277',
    '1.01411395214231',
    '0.958716911125739',
    '3.00874355692282e-05',
    '-0.000151345208862028'
  ]
};

You can do without swe_set_ephepath, and ignore the error message returned.

Installation

On Linux, with dynamical library libswe.so

The default iinstallation expects a dynamical library libswe.so to be installed, which has to be at leastof the same release version as the Perl module.

You should download the source code from its Github repo https://github.com/aloistr/swisseph or from the download directory https://www.astro.com/ftp/swisseph/ Download swe_unix_src_2.10.tar.gz or whatever the latest version is, or the one you want to use.

There will be a src directory in the unpacked files. Go there and run make libswe.so to build the shared library. Copy this file to /usr/local/lib64/swe

Usually, this will also require that you create a file (as root) /etc/ld.so.conf.d/swisseph.conf with the content line /usr/local/lib64/swe

Now run ldconfig(8) (as root) in order to generate the symbolic links required.

Now you can install the Perl module for the Swiss Ephemeris. Type the following:

perl Makefile.PL
make
make test
make install	(requires root)

On Linux, with statically linked Swiss Ephemeris libary

There exists the option to link statically with the library libswe.a wich you build on your system. Proceed as above regarding downloading and compiling Swiss Ephemeris source code.

Instead of 'make libswe.so' say 'make libswe.a'

Now you need to know the full path to the built library libswe.a, for example /home/myself/sweph/src/libswe.a

Run Makefile.PL with these arguments:

perl Makefile.PL LIBS='' MYEXTLIB='/home/myself/sweph/src/libswe.a'
make
make test
make install	(requires root)

On Windows:

Before installing this module, you have to install the following things on your computer:

After that you can install the Perl module. In the current directory (where you read this README file), open the file Makefile.PL and fix the LIBS parameter. It must contain the directory to the Swiss Ephemeris DLL. After that run:

perl Makefile.PL
nmake
nmake test
nmake install

COPYRIGHT AND LICENCE

Copyright (C) 2021 Astrodienst, Zurich, Switzerland.

The Perl module SwissEphe is work derived from the original release of the Astrodienst Swiss Ephemeris library. To use it, the licensing conditions imposed by Astrodienst for Swiss Ephemeris must be fulfilled. A copy of the license file is found in https://www.astro.com/ftp/swisseph/LICENSE.

Please note: since Swiss Ephemeris release 2.10.01 the GPL license has been replaced with the AGPL license, as one of the options in Astrodienst's dual licensing model.

History

The SwissEph perl module is based on earlier work up to 2008 by Rüdiger Plantiko, see http://www.astrotexte.ch/sources/swe_perl.html (in German)

Dieter Koch at Astrodienst took over in 2008 and maintained the module for Astrodienst's internal use, until 2020. It was made available for download since 2009, in https://www.astro.com/ftp/swisseph/src/

In July 2021, the module was migrated to Github by Alois Treindl, and it is now maintained on GitHub.