You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
189 lines
4.6 KiB
189 lines
4.6 KiB
3 years ago
|
|
||
|
[](https://www.repostatus.org/#active)
|
||
|
[](https://keybase.io/hrbrmstr)
|
||
|

|
||
|
[](https://travis-ci.org/hrbrmstr/daybreak)
|
||
|

|
||
|

|
||
|
|
||
|
# 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
|
||
|
|
||
|
``` r
|
||
|
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")
|
||
|
```
|
||
|
|
||
|
NOTE: To use the ‘remotes’ install options you will need to have the
|
||
|
[{remotes} package](https://github.com/r-lib/remotes) installed.
|
||
|
|
||
|
## Usage
|
||
|
|
||
|
``` r
|
||
|
library(daybreak)
|
||
|
|
||
|
# current version
|
||
|
packageVersion("daybreak")
|
||
|
## [1] '0.1.0'
|
||
|
```
|
||
|
|
||
|
Near me:
|
||
|
|
||
|
``` r
|
||
|
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)
|
||
|
|
||
|
``` r
|
||
|
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)
|
||
|
|
||
|
``` r
|
||
|
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.
|