Capture and step through the Stellarium sky above a horizon

Description

Capture an equirectangular sky panorama at the observing site and display it behind a horizon.

Usage

stellariumSky(
  hor,
  jd = NULL,
  screenshot.dir = getOption("skyscapeR.screenshot.dir", "~/Pictures/Stellarium"),
  port = 8090L,
  timeout = 60,
  time = NULL,
  timezone,
  calendar,
  display = c(landscape = FALSE, fog = FALSE),
  width = NULL
)

skyStep(hor, sky, minutes = 1, ...)

Arguments

hor

Site horizon with latitude, longitude and elevation in metres.

jd

Numeric UT Julian day. Supply either jd or time.

screenshot.dir

Existing local directory where Stellarium writes screenshots.

port

Local Remote Control server port.

timeout

Maximum wait for the capture in seconds.

time

A date and clock time such as "2026/12/21 16:00", or a POSIXct or POSIXlt instant.

timezone

For character time, a zone name or fixed UTC offset as in time2jd(). Defaults to the package setting.

calendar

For character time, the Gregorian or Julian calendar as in time2jd(). Defaults to the package setting.

display

Named logical switches: atmosphere, landscape, fog, cardinals, compass.marks (numbered horizon bearings), azimuthal.grid, equatorial.grid, constellation.lines, constellation.labels (names) and constellation.art. Use galactic.equator to toggle the Galactic equator independently of the equatorial grid. Use ecliptic and equator for the lines of date, poles for the celestial poles and zenith for the Stellarium zenith/nadir markers. Older Stellarium versions may require the Compass Marks plugin to be loaded to show the bearings. Landscape and fog default to FALSE so the site horizon supplies the foreground. Other omitted switches use the current Stellarium setting.

width

Even screenshot width in pixels, up to 8192. The default NULL uses the size configured in Stellarium. Try 4096 if a larger capture fails. For a narrow sector, sketchSky gives scalable vector detail.

sky

A background returned by sketchSky(), stellariumSky() or skyStep().

minutes

Signed elapsed minutes from the captured instant. Fractions are allowed.

...

Arguments passed to plot(hor, sky=...), such as xrange.

Details

Enable Remote Control under Configuration > Plugins in Stellarium Desktop, select Load at startup and restart if needed. Enable the server in the plugin settings. Use the local server without a password and install the R packages httr2 and png. Close dialogs and use a normal rectangular viewport. Point screenshot.dir at the directory configured in Stellarium.

The script freezes time and takes one full-sphere Cylinder Fill screenshot. The centre is south, the seam is north, and the horizon is halfway up. Choose width for more pixels per degree. R keeps the native pixels for each plotted sector. For a 30-degree sector a width of 8192 supplies about 683 source pixels. The physical plot size and graphics device determine the displayed resolution. If the script times out, check the screenshot path and that your Stellarium version offers Cylinder Fill.

Capture restores the requested display switches, location, time and time rate after taking the picture. The GUI is shown again. Each capture leaves one PNG in the screenshot directory. Replot an existing sky to inspect another bearing without recapturing.

To move through time, pass either kind of sky to skyStep(). For a natural sketchSky background, each step retains the Sun and Moon display settings and recalculates illumination from the enabled sources. Positive minutes advance the clock and negative minutes rewind it. Assign the result back to the sky variable to continue from the new instant. Repeat xrange and any other plot limits to keep the framing. A sketch is recalculated locally with its style, display switches, constellations and magnitude limit. Older sketches without saved catalogue or calendar settings use the defaults. A Stellarium step takes a fresh screenshot using the saved capture settings.

Value

stellariumSky() returns a skyscapeR.sky object with the native raster, PNG path, Julian day, observer location and capture settings. skyStep() invisibly returns the updated sky of the same kind.

Reproducibility and stepping

A Stellarium capture reflects the installed Stellarium version, its catalogues, selected sky culture and current settings for switches not explicitly supplied. It is an external rendered image, not the package's twilight or extinction model. Record those settings when comparing it with sketchSky. The external application and a working local Remote Control connection are required for every new capture, but not for replotting a saved raster.

Atmospheric settings when using skyStep

For a sketch, skyStep retains calendar, max.mag, k, style and display selections. Refraction, pressure and temperature are read again from skyscapeR.vars; the previous object's atmosphere is not restored automatically. Changing these session settings between the original sketch and a step changes the atmosphere as well as the time. Keep them fixed for a time-only comparison, including when resuming a saved sketch in another R session. This behaviour is intentional. Stellarium captures instead use the external application's atmospheric settings. Each call draws immediately and returns the new object invisibly. Save it with sky <- skyStep(hor, sky, minutes = 10) before taking the next step.

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. For Stellarium captures, these are the R package versions, not the external Stellarium engine version. Record that version and its settings separately. A stepped sky carries the package versions from the new calculation or capture.

Scientific checks

See Also

time2jd, plot.skyscapeR.horizon

Examples

## Not run: 
hor <- malta_horizons[[1]]
sector <- c(220, 240)
sky <- stellariumSky(hor, time = "2026/12/21 16:00", timezone = "UTC",
                    display = c(atmosphere = TRUE, cardinals = FALSE))
plot(hor, sky = sky, xrange = sector)
sky <- skyStep(hor, sky, minutes = 2, xrange = sector)
sky <- skyStep(hor, sky, minutes = -0.5, xrange = sector)

## End(Not run)