suncalcmeeus

R package 'photobiologySunCalc'

https://github.com/aphalo/suncalcmeeus

Science Score: 39.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 7 DOI reference(s) in README
  • Academic publication links
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.7%) to scientific vocabulary
Last synced: 10 months ago · JSON representation

Repository

R package 'photobiologySunCalc'

Basic Info
  • Host: GitHub
  • Owner: aphalo
  • Language: R
  • Default Branch: main
  • Size: 392 KB
Statistics
  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • Open Issues: 0
  • Releases: 0
Created almost 2 years ago · Last pushed about 1 year ago
Metadata Files
Readme Changelog

README.Rmd

---
output:
  github_document:
    html_preview: TRUE
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
  fig.asp = 2/3,
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-"
)
```

# SunCalcMeeus 


[![CRAN version](https://www.r-pkg.org/badges/version-last-release/SunCalcMeeus)](https://cran.r-project.org/package=SunCalcMeeus) [![cran checks](https://badges.cranchecks.info/worst/SunCalcMeeus.svg)](https://cran.r-project.org/web/checks/check_results_SunCalcMeeus.html) [![SunCalcMeeus status badge](https://aphalo.r-universe.dev/badges/SunCalcMeeus)](https://aphalo.r-universe.dev/SunCalcMeeus)
[![R-CMD-check](https://github.com/aphalo/SunCalcMeeus/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/aphalo/SunCalcMeeus/actions/workflows/R-CMD-check.yaml)
[![Documentation](https://img.shields.io/badge/documentation-SunCalcMeeus-informational.svg)](https://docs.r4photobiology.info/SunCalcMeeus/) [![doi](https://img.shields.io/badge/doi-10.32614/CRAN.package.SunCalcMeeus-blue.svg)](https://doi.org/10.32614/CRAN.package.SunCalcMeeus)


## Purpose

Package 'SunCalcMeeus' implements Meeus' accurate algorithms for the computation of the position of the sun, usable far into the past and future. It also implements the computation of local solar time, day length, night length and times of sunset and sunrise, based on accepted and arbitrary sun elevation angles for twilight. Atmospheric refraction makes the apparent sun elevation, as seen be an observer on Earth, slightly different to the true astronomical sun elevation. The apparent sun elevation differs from the true astronomical position because the solar light beam changes its direction when travelling through the atmosphere. At low sun elevations at high latitudes a rather small difference expressed as an elevation angle becomes important for the apparent sunrise and sunset times. The exact value is difficult to compute with high accuracy as it depends on the water content in the atmosphere. The correction applied here assumes a "normal" water vapour column. Thus even if estimates of the true sun angles based on Meeus' algorithm are reported to be accurate to 0.001 degrees, the estimates of the apparent sun elevation can be in error by as much as 1 degree.

The 'SunCalcMeeus' package also implements Kasten and Young’s (1989) approximation formula for optical air mass (AM) as a function of the apparent sun elevation and Young's (1994) follow-up approximate formula as a function of the true sun elevation. In the first case the correction for atmospheric refraction must be included in the computation of the apparent elevation angle, in the second case this correction is applied when computing AM.

Estimation of extraterrestrial irradiance (shortwave incoming radiation at the top of the atmosphere) above a geographic location at the Earth surface at a given instant in time is implemented in function `irrad_extraterrestrial()`.

Class `tod_time` is defined and used to store time-of-day values based on time zones. Classes `solar_time` and `solar_date` are defined and used to store local solar times and dates, i.e., astronomical time coordinates.

The same algorithms from Meeus' book are used  in the [NOAA Solar Calculator](https://gml.noaa.gov/grad/solcalc/) of the United States National Oceanic and Atmospheric Administration (NOAA), Global Monitoring Laboratory. The version of the algorithm implemented in 'SunCalcMeeus' is not the simplified one used in the [worksheets available from NOAA](https://gml.noaa.gov/grad/solcalc/calcdetails.html) but instead nearly identical to that used in the on line calculator and assumed to be accurate enough to be used confidently for times between years 1000 BC to 3000 AC and with decreased accuracy even outside this range.

The functions provided are vectorised, and the best performance per computed value is achieved when long vectors of instants in time are passed as arguments, as the equation of time is in this case generated only once for each geographic location.

## History

This package is part of a suite of R packages for photobiological calculations described at the [r4photobiology](https://www.r4photobiology.info) web site and in the vignette [The R for Photobiology Suite](https://docs.r4photobiology.info/SunCalcMeeus/articles/userguide-0-r4p-introduction.html).

The functions now in 'SunCalcMeeus' were previously included in package 'photobiology'. As they are being used also in other contexts, they are now published separately in this R package to increase their visibility, and facilitate their use and maintenance.

## Examples

Example of simple astronomical calculations for the sun.

```{r example1}
library(SunCalcMeeus)
library(lubridate)

# using times
geocode <- data.frame(lon = 0, lat = 55)
date <- lubridate::today(tzone = "UTC")

sunrise_time(date, geocode = geocode)

dates <- ymd("2024-09-21") + months(0:11)
sunrise_time(dates, geocode = geocode)
```

```{r example2}
day_length(dates, geocode = geocode)
```
```{r example3}
times <- ymd_hms("2024-09-21 12:00:00") + minutes(seq(from = 0, to = 60, by = 10))
data.frame(time = times, elevation = sun_elevation(times, geocode = geocode))
```

```{r example4}
sun_angles(times, geocode = geocode)
```

## Installation

Installation of the most recent stable version from CRAN:

```{r, eval=FALSE}
# not yet in CRAN!
# install.packages("SunCalcMeeus")
```

Installation of the current unstable version from R-Universe CRAN-like repository:

```{r, eval=FALSE}
install.packages('SunCalcMeeus', 
                 repos = c('https://aphalo.r-universe.dev', 
                           'https://cloud.r-project.org'))
```

Installation of the current unstable version from GitHub:

```{r, eval=FALSE}
# install.packages("devtools")
devtools::install_github("aphalo/SunCalcMeeus")
```

## Documentation

HTML documentation is available at (), including an *User Guide*.

News on updates to the different packages of the 'r4photobiology' suite are posted at ().

Two articles introduce the basic ideas behind the design of the suite and describe its use: Aphalo P. J. (2015) () and Aphalo P. J. (2016) ().

A book is under preparation, and the draft is currently available at ().

## Contributing

Pull requests, bug reports, and feature requests are welcome at ().

## Citation

If you use this package to produce scientific or commercial publications, please cite according to:

```{r}
citation("SunCalcMeeus")
```

## License

© 2012-2025 Pedro J. Aphalo ([pedro.aphalo\@helsinki.fi](mailto:pedro.aphalo@helsinki.fi){.email}). Released under the GPL, version 2 or greater. This software carries no warranty of any kind.

Owner

  • Name: Pedro Aphalo
  • Login: aphalo
  • Kind: user
  • Location: Helsinki, Finland
  • Company: University of Helsinki, Organismal and Evolutionary Biology (OEB)

Senior University Lecturer, Principal Investigator (Sensory Ecology of Plants, Photobiology, Crops, Forest trees, Data Analysis, Data Visualization)

GitHub Events

Total
  • Watch event: 1
  • Push event: 18
  • Pull request review event: 1
  • Pull request event: 2
  • Fork event: 1
Last Year
  • Watch event: 1
  • Push event: 18
  • Pull request review event: 1
  • Pull request event: 2
  • Fork event: 1

Issues and Pull Requests

Last synced: 11 months ago

All Time
  • Total issues: 0
  • Total pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: about 23 hours
  • Total issue authors: 0
  • Total pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 0
  • Pull requests: 1
  • Average time to close issues: N/A
  • Average time to close pull requests: about 23 hours
  • Issue authors: 0
  • Pull request authors: 1
  • Average comments per issue: 0
  • Average comments per pull request: 0.0
  • Merged pull requests: 1
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
  • srearl (2)
Top Labels
Issue Labels
Pull Request Labels

Packages

  • Total packages: 1
  • Total downloads:
    • cran 463 last-month
  • Total dependent packages: 0
  • Total dependent repositories: 0
  • Total versions: 2
  • Total maintainers: 1
cran.r-project.org: SunCalcMeeus

Sun Position and Daylight Calculations

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 463 Last month
Rankings
Dependent packages count: 27.6%
Dependent repos count: 34.0%
Average: 49.5%
Downloads: 86.9%
Maintainers (1)
Last synced: 11 months ago

Dependencies

.github/workflows/R-CMD-check.yaml actions
  • actions/checkout v4 composite
  • r-lib/actions/check-r-package v2 composite
  • r-lib/actions/setup-pandoc v2 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
DESCRIPTION cran
  • R >= 4.0.0 depends
  • dplyr >= 1.0.9 imports
  • lubridate >= 1.9.0 imports
  • stats * imports
  • tibble >= 3.1.6 imports
  • covr * suggests
  • knitr >= 1.41 suggests
  • lutz >= 0.3.1 suggests
  • rmarkdown >= 2.18 suggests
  • roxygen2 >= 7.2.0 suggests
  • testthat >= 3.1.4 suggests