Find the equatorial and horizontal position of a celestial body

Description

Locate a Solar System body in equatorial coordinates at a specified instant, or determine where it appears in the observer's sky.

Usage

body.position(
  time,
  obj = "sun",
  loc = NULL,
  timezone,
  calendar,
  dec,
  refraction,
  atm,
  temp,
  verbose = T
)

Arguments

time

Either a string containing the date and time in the format "YYYY/MM/DD HH:MM:SS" (see timestring), or a numeric containing the julian date (see time2jd).

obj

String containing name of the solar system body of interest. Can be any of the planets (inc. Pluto), the Moon, the Sun or the Ecliptic. Defaults to 'sun'.

loc

Observer location: a numeric vector containing latitude and longitude in degrees and elevation in metres, in that order, or a skyscapeR.horizon object whose metadata supplies those coordinates. Required for topocentric coordinates and for horizontal output in either frame. With no location, only geocentric equatorial coordinates are returned.

timezone

Timezone for civil timestamps. Use UTC or a fixed offset for dates before 1900. See time2jd for named zones and offsets.

calendar

Calendar for civil dates. Use "G" for Gregorian or "J" for Julian.

dec

Output declination: geo for the geocentric, or topo for the topocentric frame of reference. If not given the value set by skyscapeR.vars will be used instead.

refraction

Logical. Apply atmospheric refraction. Defaults to the session setting in skyscapeR.vars.

atm

Atmospheric pressure in mbar. Defaults to the session setting in skyscapeR.vars.

temp

Air temperature in degrees Celsius. Defaults to the session setting in skyscapeR.vars.

verbose

Logical. Display progress or informational messages. Default TRUE.

Details

An alignment comparison needs an epoch, a reference frame and, for a local sightline, a site. Character times are converted to UT Julian dates using the selected calendar and timezone; numeric times are already UT Julian dates. Swiss Ephemeris supplies right ascension and declination. Without a site the function uses the geocentric frame. With a site it can use a topocentric position and convert to local azimuth and altitude. A vector of times is evaluated one instant at a time and returned in input order.

Only the horizon object's location is used; its altitude profile is not used to determine whether the body is visible above the terrain. With a location, horizontal altitude is apparent when refraction is TRUE and geometric when FALSE. Azimuth is measured clockwise from north.

The Swiss Ephemeris manual documents planetary coordinates and reference frames.

Astronomical positions require Swiss Ephemeris files covering the epoch. We recommend installing swephRdata; see skyscapeR-package for setup.

Value

A list containing an equatorial data frame with columns RA and Dec, in degrees. When loc is supplied, the list also contains a horizontal data frame with columns az and alt, in degrees. Each data frame has one row per input time.

Validation

In A02, file-backed geocentric directions for ten bodies agreed with their matching JPL parent to within 0.0065 arcseconds across 1,080 comparisons. At the sampled prehistoric epochs the public topocentric convention differed from JPL Horizons by up to 0.70 degrees in local sky direction at a specified instant. See the A02 study in the skyscapeR technical manual.

Provenance

Structured results carry a provenance attribute. Read it with attr(result, "provenance"); its packages entry records the loaded skyscapeR and swephR versions, with NA when a namespace version is unavailable. This attribute adds no list entries or table columns. Ordinary subsetting or transformations may discard attributes; save the original result for reference. It does not identify ephemeris files, catalogue revisions or a development commit. Retain those and the analysis script separately for exact reproduction.

Scientific checks

References

Astrodienst. Swiss Ephemeris programmer's manual. https://www.astro.com/swisseph/swephprg.htm.

See Also

swe_calc_ut, timestring, time2jd

Examples

if (requireNamespace("swephRdata", quietly = TRUE)) {
  # Position of the sun at noon GMT on Christmas day 2018:
  body.position(obj='sun', time='2018/12/25 12:00:00', timezone='GMT')
  
  # Declination of the moon at same time
  body.position(obj='moon', time='2018/12/25 12:00:00', timezone='GMT')$equatorial$Dec
  
  # Geometric position using a horizon object's observer location:
  hor <- createHor(az=c(0,360), alt=c(2,2), loc=c(51.5,-0.1,25))
  body.position(obj='sun', time='2018/12/25 12:00:00', timezone='UTC',
  loc=hor, refraction=FALSE)$horizontal
}