Find rising and setting times and bearings at a site

Description

Find when and where a star or Solar System body first rises above or sets below the horizon at an observing site.

Usage

riseset(
  loc,
  date,
  jd,
  obj = "sun",
  alt = 0,
  timezone,
  calendar,
  dec,
  refraction,
  atm,
  temp,
  verbose = TRUE
)

Arguments

loc

Location, either a skyscapeR.horizon or a vector containing the latitude, longitude and elevation of location, in this order.

date

Either a string containing the date in the format "YYYY/MM/DD" (see timestring), or a numeric containing the julian date (see time2jd). Can also be a single year ("YYYY") or a month ("YYYY/MM") to calculate risings and settings for every day in the year or month, respectively. Not necessary if jd is given.

jd

A numeric containing the julian date (see time2jd) for which to calculate rising and settings. Only needed if date is not given.

obj

Solar System body, Western star name or fixed-star catalogue identifier (including M 45). Defaults to 'sun'.

alt

The altitude of the horizon to consider. Defaults to zero degrees.

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

The event is a crossing of the local horizon by the body's centre. A raised ridge can delay the first visible rise and an uneven horizon can give several appearances or disappearances. Choose the horizon model, atmosphere, calendar and time convention to match the observation.

Events refer to the centre of the disc. For a Solar System body with a coordinate vector, alt is one constant horizon altitude and the Swiss Ephemeris rise/set solver is used. For stars, the daily track is evaluated against the supplied constant altitude or site skyline. With a horizon object, its profile is linearly interpolated in azimuth and compared with the body's topocentric altitude; do not supply alt as well. Refraction TRUE uses apparent altitude; FALSE uses geometric altitude. The constant-altitude solver likewise disables refraction only when FALSE. For a profile, search the 48 hours after each requested local midnight and return the first upward and first downward crossing separately. They need not enclose one continuous visibility interval or occur on the requested day. Missing crossings return NA fields. A one-minute base grid, quarter-step samples, azimuth turning points and recursively subdivided rapid azimuth motion bracket visits to the profile's corners. Each smooth segment is also searched for an interior altitude extremum, so short emergence/reoccultation pairs need not straddle time samples. A pure tangency without a sign change is not a rise or set. Horizon altitudes at 0 and 360 degrees must agree. Root tolerance is 0.01 seconds; interior optimization uses relative seconds to avoid precision loss from large Julian dates. These settings are not a physical accuracy guarantee: finite precision, unresolved terrain and near-zenith azimuth singularities limit numerical completeness. The dec argument controls returned declination, not the topocentric event search.

The Swiss Ephemeris manual documents the fixed-altitude rise/set calculation.

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

Value

A list containing object, rise and set; rise/set are data frames with date, time, azimuth and declination columns. Missing events have NA fields.

Validation

A02 tested sensitivity to ephemeris conventions using a separate solver on airless lunar-centre trajectories. Across 177 prehistoric skyline crossings, default azimuths differed from JPL Horizons by a median of 0.059 degrees and a maximum of 0.322 degrees. Matching delta T reduced the maximum to 0.027 degrees. See the A02 study in the skyscapeR technical manual.

A04 recovered the expected crossing counts and order on synthetic ridges, notches and grazing tracks; solar and lunar centre crossings at the Malta test site agreed with JPL Horizons within 0.85 seconds and 0.0041 degrees. See the A04 check in the technical manual.

H07 verified that a partial panorama is rejected before searching for solar or stellar crossings on an unobserved skyline. See the H07 check in the technical manual.

Crossing is not first visibility

The result supplies geometry and time. It applies neither atmospheric extinction nor a twilight detection threshold and does not test whether the star can be seen. A centre exactly at the skyline can remain obscured in a plot or too faint to detect. Use star.phases to select a candidate season, then inspect moments after the crossing with sketchSky and skyStep. The extra time needed for clearance depends on track slope, latitude and terrain; a universal minute offset is inappropriate.

A numerical root tolerance describes the solver, not observational timing accuracy. Uncertain terrain height, refraction and ancient Earth-rotation models can dominate it. Saved output contains formatted civil times rather than a complete record of the input atmosphere and horizon. Preserve the original call and convert date/time back with matching calendar and timezone.

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, swe_azalt, body.position, star.phases

Examples

if (requireNamespace("swephRdata", quietly = TRUE)) {
  # Rising and setting of the sun on june solstice 2018, from the location of London
  riseset(obj='sun', date='2018/06/21', loc=c(51.5, 0.11, 100))
  
  ## Not run: 
  # Horizon searches and multi-date calculations can exceed five seconds.
  # Rising and setting of the moon on june solstice 2018, using a horizon profile
  hor <- malta_horizons[[1]]
  riseset(obj='moon', date='2018/06/21', loc=hor)
  
  # Rising and setting of the sun throughout February 1999, from the location of London
  riseset(obj='sun', date='1999/02', loc=c(51.5, 0.11, 100))
  
  # Rising and setting of the sun throughout 3001 BC, from the location of London
  riseset(obj='sun', date=-3000, loc=c(51.5, 0.11, 100))
  
## End(Not run)
}