Skip to content
🌆Compute Sun Rise/Set Times, Start/End of Twilight, and the Length of the Day at Any Date and Latitude (example pkg for a forthcoming blog/bookdown series)
C R
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
R
inst/tinytest
man
src
tests
.Rbuildignore
.codecov.yml
.gitignore
.travis.yml
CONDUCT.md
DESCRIPTION
LICENSE
LICENSE.md
NAMESPACE
NEWS.md
README.Rmd
README.md
daybreak.Rproj

README.md

Project Status: Active – The project has reached a stable, usable state and is being actively developed. Signed by Signed commit % Linux build Status
Minimal R Version License

daybreak

Compute Sun Rise/Set Times, Start/End of Twilight, and the Length of the Day at Any Date and Latitude

Description

A wrapper for Paul Schlyter’s C-based library for computing sunrise, sunset, twilight start and end, plus the length of day for a given data and coordinates.

What’s Inside The Tin

The following functions are implemented:

  • astronomical_twilight: Astronomical twilight
  • civil_twilight: Civil twilight
  • day_astronomical_twilight_length: Length of astronomical twilight
  • day_civil_twilight_length: Length of civil twilight
  • day_length: Length of day
  • day_nautical_twilight_length: Length of nautical twilight
  • nautical_twilight: Nautical twilight
  • sun_rise_set: Sun rise/set times

Installation

install.packages("daybreak", repos = "https://cinc.rud.is")
# or
remotes::install_git("https://git.rud.is/hrbrmstr/daybreak.git")
# or
remotes::install_git("https://git.sr.ht/~hrbrmstr/daybreak")
# or
remotes::install_gitlab("hrbrmstr/daybreak")
# or
remotes::install_bitbucket("hrbrmstr/daybreak")
# or
remotes::install_github("hrbrmstr/daybreak")

NOTE: To use the ‘remotes’ install options you will need to have the {remotes} package installed.

Usage

library(daybreak)

# current version
packageVersion("daybreak")
## [1] '0.1.0'

Near me:

day_length("2019-12-31", -70.8636, 43.2683)
## [1] 9.031444
day_civil_twilight_length("2019-12-31", -70.8636, 43.2683)
## [1] 10.10834
day_nautical_twilight_length("2019-12-31", -70.8636, 43.2683)
## [1] 11.30569
day_astronomical_twilight_length("2019-12-31", -70.8636, 43.2683)
## [1] 12.45998
sun_rise_set("2019-12-31", -70.8636, 43.2683)
## $rise
## [1] 12.25761
## 
## $set
## [1] 21.28906
civil_twilight("2019-12-31", -70.8636, 43.2683)
## $start
## [1] 11.71917
## 
## $end
## [1] 21.82751
nautical_twilight("2019-12-31", -70.8636, 43.2683)
## $start
## [1] 11.12049
## 
## $end
## [1] 22.42618
astronomical_twilight("2019-12-31", -70.8636, 43.2683)
## $start
## [1] 10.54335
## 
## $end
## [1] 23.00332

Tromsø, Norway (Winter)

day_length("2019-12-31", 18.9553, 69.6492)
## [1] 0
day_civil_twilight_length("2019-12-31", 18.9553, 69.6492)
## [1] 4.613116
day_nautical_twilight_length("2019-12-31", 18.9553, 69.6492)
## [1] 8.000323
day_astronomical_twilight_length("2019-12-31", 18.9553, 69.6492)
## [1] 10.5871
sun_rise_set("2019-12-31", 18.9553, 69.6492)
## $rise
## [1] NA
## 
## $set
## [1] NA
civil_twilight("2019-12-31", 18.9553, 69.6492)
## $start
## [1] 8.476866
## 
## $end
## [1] 13.08998
nautical_twilight("2019-12-31", 18.9553, 69.6492)
## $start
## [1] 6.783262
## 
## $end
## [1] 14.78359
astronomical_twilight("2019-12-31", 18.9553, 69.6492)
## $start
## [1] 5.489872
## 
## $end
## [1] 16.07698

Tromsø, Norway (Summer)

day_length("2019-06-01", 18.9553, 69.6492)
## [1] 24
day_civil_twilight_length("2019-06-01", 18.9553, 69.6492)
## [1] 24
day_nautical_twilight_length("2019-06-01", 18.9553, 69.6492)
## [1] 24
day_astronomical_twilight_length("2019-06-01", 18.9553, 69.6492)
## [1] 24
sun_rise_set("2019-06-01", 18.9553, 69.6492)
## $rise
## [1] NA
## 
## $set
## [1] NA
civil_twilight("2019-06-01", 18.9553, 69.6492)
## $start
## [1] NA
## 
## $end
## [1] NA
nautical_twilight("2019-06-01", 18.9553, 69.6492)
## $start
## [1] NA
## 
## $end
## [1] NA
astronomical_twilight("2019-06-01", 18.9553, 69.6492)
## $start
## [1] NA
## 
## $end
## [1] NA

daybreak Metrics

Lang # Files (%) LoC (%) Blank lines (%) # Lines (%)
C 3 0.33 267 0.66 110 0.60 245 0.60
R 4 0.44 65 0.16 16 0.09 84 0.20
C/C++ Header 1 0.11 39 0.10 35 0.19 44 0.11
Rmd 1 0.11 32 0.08 21 0.12 37 0.09

Code of Conduct

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

You can’t perform that action at this time.