To compute the position of celestial body or star with SE (Swiss Ephemeris), you do the following steps:
swephR
:library(swephR)
swe_set_ephe_path("C:\\sweph\\ephe")
<- 2000
year <- 1
month <- 1
day <- 12
hour <- swe_julday(year, month, day, hour, SE$GREG_CAL)
jdut
jdut#> [1] 2451545
<- SE$SUN
ipl <- SE$FLG_MOSEPH + SE$FLG_SPEED
iflag <- swe_calc_ut(jdut, ipl, iflag)
result
result#> $return
#> [1] 260
#>
#> $xx
#> [1] 2.803689e+02 2.323265e-04 9.833276e-01 1.019432e+00 -8.922802e-07
#> [6] -7.339410e-06
#>
#> $serr
#> [1] ""
or a fixed star (in below example: Sirius):
= "sirius"
starname <- swe_fixstar2_ut(starname, jdut, iflag)
result
result#> $return
#> [1] 260
#>
#> $starname
#> [1] "Sirius,alCMa"
#>
#> $xx
#> [1] 1.040853e+02 -3.960507e+01 5.439322e+05 4.643164e-05 -7.119376e-05
#> [6] -4.130539e-03
#>
#> $serr
#> [1] ""
options(digits=15)
<- swe_heliacal_ut(jdut,c(0,50,10),c(1013.25,15,50,0.25),c(25,1,1,1,5,0.8),starname,
result $HELIACAL_RISING,SE$HELFLAG_HIGH_PRECISION+SE$FLG_MOSEPH)
SE
result#> $return
#> [1] 0
#>
#> $dret
#> [1] 2451779.67915537 2451779.68432898 2451779.69042851 0.00000000
#> [5] 0.00000000 0.00000000 0.00000000 0.00000000
#> [9] 0.00000000 0.00000000 0.00000000 0.00000000
#> [13] 0.00000000 0.00000000 0.00000000 0.00000000
#> [17] 0.00000000 0.00000000 0.00000000 0.00000000
#> [21] 0.00000000 0.00000000 0.00000000 0.00000000
#> [25] 0.00000000 0.00000000 0.00000000 0.00000000
#> [29] 0.00000000 0.00000000 0.00000000 0.00000000
#> [33] 0.00000000 0.00000000 0.00000000 0.00000000
#> [37] 0.00000000 0.00000000 0.00000000 0.00000000
#> [41] 0.00000000 0.00000000 0.00000000 0.00000000
#> [45] 0.00000000 0.00000000 0.00000000 0.00000000
#> [49] 0.00000000 0.00000000
#>
#> $serr
#> [1] ""
options(digits=6)
swe_set_ephe_path(NULL)
= SE$FLG_SPEED + SE$FLG_MOSEPH
iflag
{#get year
<- 2000
jyear #get month
<- 1
jmon #get day
<- 1
jday #get time
<- 12
jhour #determine julian day number (at 12:00 GMT)
<- swe_julday(jyear, jmon, jday, jhour, SE$GREG_CAL)
tjd_ut cat("Julian day number (UT) :", tjd_ut, "(",jyear,",",jmon,",",jday,"; proleptic Gregorian calendar)\n")
cat("planet :",
c("longitude", "latitude", "distance", "long. speed", "lat. speed"),
"\n")
cat("===========================================================\n")
# loop over all planets
for (p in SE$SUN:SE$OSCU_APOG) {
# get the name of the planet p
= swe_get_planet_name(p)
objectname # do the coordinate calculation for this planet p
= swe_calc_ut(tjd_ut, p, iflag)
i if (i$return < 0) {
cat("Error :", i$err, "(", objectname, ")\n")
}else
{# print data
cat (objectname, ":", i$xx[0:5], "\n")
}
}
}#> Julian day number (UT) : 2451545 ( 2000 , 1 , 1 ; proleptic Gregorian calendar)
#> planet : longitude latitude distance long. speed lat. speed
#> ===========================================================
#> Sun : 280.369 0.000232327 0.983328 1.01943 -8.9228e-07
#> Moon : 223.324 5.17082 0.00268998 12.0212 -0.178063
#> Mercury : 271.889 -0.994825 1.41547 1.55625 -0.0974918
#> Venus : 241.566 2.06635 1.13758 1.20904 -0.0280736
#> Mars : 327.963 -1.06778 1.84969 0.775673 0.0124755
#> Jupiter : 25.253 -1.26217 4.62118 0.0407613 0.00517336
#> Saturn : 40.3956 -2.44482 8.6528 -0.0199448 0.00474316
#> Uranus : 314.809 -0.658333 20.7272 0.0503436 0.000250014
#> Neptune : 303.193 0.234991 31.0245 0.0355701 -0.000223651
#> Pluto : 251.455 10.8552 31.0644 0.0351529 0.0014674
#> mean Node : 125.041 0 0.00256956 -0.0529518 0
#> true Node : 123.953 0 0.00244538 -0.0543822 0
#> mean Apogee : 263.464 3.41972 0.00271063 0.111328 -0.011021
#> osc. Apogee : 252.979 4.07551 0.00271384 1.64684 -0.0971172
swe_close()