-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME.Rmd
106 lines (81 loc) · 3.05 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
[![R build status](https://github.com/rstub/swephR/workflows/R-CMD-check/badge.svg)](https://github.com/rstub/swephR/actions)
[![Coverage status](https://codecov.io/gh/rstub/swephR/branch/master/graph/badge.svg)](https://app.codecov.io/github/rstub/swephR?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/swephR)](https://cran.r-project.org/package=swephR)
[![Downloads](https://cranlogs.r-pkg.org/badges/swephR?color=brightgreen)](https://www.r-pkg.org/pkg/swephR)
[![Dependencies](https://tinyverse.netlify.com/badge/swephR)](https://cran.r-project.org/package=swephR)
# swephR
The goal of swephR is to provide an R interface to the [Swiss
Ephemeris](https://www.astro.com/swisseph/). The Swiss Ephemeris is a
high precision ephemeris based upon the DE431 ephemeris from NASA's
JPL. It covers the time range 13201 BCE to 17191 CE.
## Installation
You can install the released version of swephR from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("swephR")
```
Intermediate releases can also be obtained from https://rstub.r-universe.dev/:
``` r
install.packages('swephR', repos = c('https://rstub.r-universe.dev', 'https://cloud.r-project.org'))
```
This package uses the semi-analytic theory by Steve Moshier. For
faster and more accurate calculations, the compressed Swiss Ephemeris
data is available in the `swephRdata` package. To access this data
package, run
``` r
install.packages("swephRdata", repos = "https://rstub.r-universe.dev", type = "source")
```
The size of the `swephRdata` package is approximately 115 MB. The user
can also use the original JPL DE431 data.
## Example
To compute the position of celestial body or star with SE (Swiss
Ephemeris), you do the following steps:
```{r}
library(swephR)
swe_version()
```
For a specific date, compute the Julian day number (in below example:
J2000.0, 1 January 2000 at 12:00 UT):
```{r}
year <- 2000
month <- 1
day <- 1
hour <- 12
jdut <- swe_julday(year, month, day, hour, SE$GREG_CAL)
jdut
```
Compute (using Moshier ephemeris) the positions (longitude, latitude,
distance, longitude speed and latitude speed) of a planet or other
celestial bodies (in below example: the Sun):
```{r}
ipl <- SE$SUN
iflag <- SE$FLG_MOSEPH + SE$FLG_SPEED
result <- swe_calc_ut(jdut, ipl, iflag)
result
```
or a fixed star (in below example: Sirius):
```{r}
starname = "sirius"
result <- swe_fixstar2_ut(starname, jdut, iflag)
result
```
The current R interface is modeled after the C interface. It is
therefore often helpful to consult the [general
documentation](https://www.astro.com/swisseph/swisseph.htm) and
[programmer's
documentation](https://www.astro.com/swisseph/swephprg.htm) for the
Swiss Ephemeris.
## Feedback
All feedback (bug reports, security issues, feature requests, ...) should be provided as
[issues](https://github.com/rstub/swephR/issues).