Skip to content

Commit

Permalink
version 0.2-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel Lazaridis authored and cran-robot committed Jun 13, 2022
1 parent 64d35a4 commit 115e9f9
Show file tree
Hide file tree
Showing 18 changed files with 184 additions and 123 deletions.
21 changes: 11 additions & 10 deletions DESCRIPTION
@@ -1,20 +1,21 @@
Package: lunar
Type: Package
Title: Lunar Phase & Distance, Seasons and Other Environmental Factors
Title: Calculate Lunar Phase & Distance, Seasons and Related
Environmental Factors
Author: Emmanuel Lazaridis [aut, cre]
Maintainer: Emmanuel Lazaridis <emmanuel@lazaridis.eu>
Maintainer: Emmanuel Lazaridis <emmanuel@strategicarrow.com>
Depends: R (>= 2.10.0)
Description: Provides functions to calculate lunar and other environmental
covariates.
Description: Provides functions to calculate lunar and other related
environmental covariates.
License: MIT + file LICENSE
Encoding: UTF-8
LazyLoad: no
URL: http://statistics.lazaridis.eu
Authors@R: c(person(given = "Emmanuel", family = "Lazaridis",
email="emmanuel@lazaridis.eu", role = c("aut", "cre")))
Version: 0.1-04
Date: 2014-09-04
Packaged: 2014-09-04 14:50:09 UTC; james
email="emmanuel@strategicarrow.com", role = c("aut", "cre")))
Version: 0.2-1
Date: 2022-06-13
Packaged: 2022-06-13 13:48:40 UTC; emmanuel
RoxygenNote: 7.2.0
NeedsCompilation: no
Repository: CRAN
Date/Publication: 2014-09-08 10:59:14
Date/Publication: 2022-06-13 15:40:02 UTC
34 changes: 17 additions & 17 deletions MD5
@@ -1,18 +1,18 @@
fb344cbea4ce952af4c93a6487a186c8 *DESCRIPTION
4303935648df2260a08fe4f21e3d67b0 *DESCRIPTION
b6db64333651b3a18f87adcb5323b85f *LICENSE
94057278f33ebeddf40950fc6b1217ca *NAMESPACE
e99dae1191ff5a1e1f1940ab1ab0286f *R/lunar-package.R
fbd929486b2a53e3f76a463ffff1de54 *R/lunar.package.R
8fe944904788f54ffe6d3ff58d98b6bd *inst/CITATION
067cbe485dc49470227943445de06d8f *man/lunar-package.Rd
760cc7de56eb7d266ef4aab825859f83 *man/lunar.4phases.Rd
a936955c2a2b9b638c90b07571ab588f *man/lunar.8phases.Rd
6bbc7640f301641be7d9cc3333f26dda *man/lunar.distance.Rd
dffd78144a27fe3f716737e8bd0b901b *man/lunar.distance.mean.Rd
ce58a6251661e174b657353fec0e3bd4 *man/lunar.distances.Rd
3f6d9d0d4b456c5f9139bcefa02a7832 *man/lunar.illumination.Rd
2f4f0b1fbc2a7be3db6c5481f9667f6b *man/lunar.illumination.mean.Rd
a3efea5de0a877a98946a95485736289 *man/lunar.metric.mean.Rd
beb323667a0fed70421bcf27c3f849ff *man/lunar.phase.Rd
6a75c8aa2dc5d17536e3c2056f50986e *man/terrestrial.season.Rd
f863237bcdc27b096300212c170f5c12 *man/terrestrial.seasons.Rd
c26be89cefab16c7c2e3d46539240e11 *NAMESPACE
a33100588342ac0851c0cd72e133c3ff *R/lunar-package.R
d5e4ed8ef99a528a3c952e2b4e57e5fe *R/lunar.package.R
8c637ae8a837d1b54f60f4cf702cacd0 *inst/CITATION
5e3aa455671cd32e5dcfb447f4bad8db *man/lunar-package.Rd
70159dd3ca816c2bfdb4d436ede2ad6a *man/lunar.4phases.Rd
6d0027e486d9f61a969dd22c33e20556 *man/lunar.8phases.Rd
2e82c390758e3261c639ca27bece5deb *man/lunar.distance.Rd
7879730029239075c5db21438cdb4214 *man/lunar.distance.mean.Rd
f2fa4fce0903855b0f22607a50c6be78 *man/lunar.distances.Rd
a169d16e5fb4cb990a11a129c364c650 *man/lunar.illumination.Rd
31c326991dc36933cc51deccd51185a0 *man/lunar.illumination.mean.Rd
57b9cb46cdd409381edc104823c3064b *man/lunar.metric.mean.Rd
d289d86c8a85440f407a967f3329e980 *man/lunar.phase.Rd
61449e4e259f80a0ad59e6e72d0cca09 *man/terrestrial.season.Rd
474dccab2f25578f578986782d47893e *man/terrestrial.seasons.Rd
2 changes: 1 addition & 1 deletion NAMESPACE
@@ -1,4 +1,4 @@
# Generated by roxygen2 (4.0.1): do not edit by hand
# Generated by roxygen2: do not edit by hand

export(lunar.4phases)
export(lunar.8phases)
Expand Down
5 changes: 2 additions & 3 deletions R/lunar-package.R
Expand Up @@ -3,13 +3,12 @@
#' \tabular{ll}{
#' Package: \tab lunar\cr
#' Type: \tab Package\cr
#' Version: \tab 0.1-04\cr
#' Date: \tab 2014-09-04\cr
#' Version: \tab 0.2-1\cr
#' Date: \tab 2022-06-13\cr
#' Depends: \tab R (>= 2.10.0)\cr
#' Encoding: \tab UTF-8\cr
#' License: \tab MIT\cr
#' LazyLoad: \tab no\cr
#' URL: \tab http://statistics.lazaridis.eu\cr
#' }
#'
#' Provides functions to calculate lunar and other environmental covariates.
Expand Down
74 changes: 49 additions & 25 deletions R/lunar.package.R
Expand Up @@ -11,6 +11,12 @@
#' @details
#' This package is used by the author to calculate covariates
#' for studies of lunar effect on health and healthcare.
#' It is based on an astronomical calculation that considers
#' the moon's phase and its distance from the earth to calculate
#' theoretical relative amount of moonlight on any given night.
#' The package is not based on luminance data.
#' It does not consider local cloud cover, for example, so it
#' only provides maximum possible moonlight, not actual moonlight.
#'
#' References forthcoming.
NULL
Expand Down Expand Up @@ -122,11 +128,11 @@ terrestrial.seasons <- c("Winter",
#'
#' Code from project R4MFCL is distributed under the MIT License:
#'
#' \url{http://opensource.org/licenses/mit-license.php}
#' \url{https://opensource.org/licenses/mit-license.php}
#'
#' Here is a link to the R4MFCL project:
#'
#' \url{https://code.google.com/p/r4mfcl/}
#' \url{https://code.google.com/archive/p/r4mfcl/}
#'
#' The R4MFCL code was modified as follows:
#' \itemize{
Expand All @@ -151,7 +157,7 @@ terrestrial.seasons <- c("Winter",
#'
#' Adapted originally from Stephen R. Schmitt: Sky & Telescope,
#' Astronomical Computing, April 1994 and
#' \url{http://mysite.verizon.net/res148h4j/zenosamples/zs_lunarphasecalc.html},
#' \url{https://web.archive.org/web/20140716104947/http://mysite.verizon.net/res148h4j/zenosamples/zs_lunarphasecalc.html},
#' which references
#' Jean Meeus, Astronomical Algorithms. Willmann-Bell, Inc. (1991) 429p.
#' @param x
Expand Down Expand Up @@ -187,7 +193,7 @@ lunar.phase <- function(
## 0 => new; pi/2 => first quarter; pi => full; 3*pi/2 => last quarter.
## Adapted from Stephen R. Schmitt: Sky & Telescope, Astronomical
## Computing, April 1994 and
## http://mysite.verizon.net/res148h4j/zenosamples/zs_lunarphasecalc.html
## https://web.archive.org/web/20140716104947/http://mysite.verizon.net/res148h4j/zenosamples/zs_lunarphasecalc.html
## which refs.
## Jean Meeus. 1991. Astronomical Algorithms. Willmann-Bell, Inc. 429p.
##========================================================================
Expand All @@ -198,9 +204,9 @@ lunar.phase <- function(
## and Pierre Kleiber of the US National Marine Fisheries Service.
##
## Code from project R4MFCL is distributed under the MIT License:
## http://opensource.org/licenses/mit-license.php
## https://opensource.org/licenses/mit-license.php
## Here is a link to the R4MFCL project:
## https://code.google.com/p/r4mfcl/
## https://code.google.com/archive/p/r4mfcl/
##========================================================================
## Modified as follows:
## * changed function name from moonphase() to lunar.phase()
Expand Down Expand Up @@ -288,11 +294,11 @@ lunar.phase <- function(
#'
#' Code from project R4MFCL is distributed under the MIT License:
#'
#' \url{http://opensource.org/licenses/mit-license.php}
#' \url{https://opensource.org/licenses/mit-license.php}
#'
#' Here is a link to the R4MFCL project:
#'
#' \url{https://code.google.com/p/r4mfcl/}
#' \url{https://code.google.com/archive/p/r4mfcl/}
#' @param x
#' A vector of \code{\link[base]{Date}} values.
#' @param shift
Expand All @@ -302,6 +308,7 @@ lunar.phase <- function(
#' lunar.illumination(as.Date("2004-03-24"))
#' @keywords lunar moon illumination light
#' @seealso \code{\link{lunar.illumination.mean}}
#' @seealso \url{https://stackoverflow.com/questions/71757462/calculate-lunar-illumination-using-the-lunar-package-in-r}
#' @export
lunar.illumination <- function(
x,
Expand All @@ -318,9 +325,9 @@ lunar.illumination <- function(
## and Pierre Kleiber of the US National Marine Fisheries Service.
##
## Code from project R4MFCL is distributed under the MIT License:
## http://opensource.org/licenses/mit-license.php
## https://opensource.org/licenses/mit-license.php
## Here is a link to the R4MFCL project:
## https://code.google.com/p/r4mfcl/
## https://code.google.com/archive/p/r4mfcl/
##========================================================================

return((1-sin(pi/2-lunar.phase(x, shift = shift)))/2)
Expand All @@ -337,7 +344,7 @@ lunar.illumination <- function(
#' apogee (at about \eqn{63.8} earth radii).
#'
#' Adapted from Stephen R. Schmitt: Lunar Phase Computation:
#' \url{http://mysite.verizon.net/res148h4j/zenosamples/zs_lunarphasecalc.html}.
#' \url{https://web.archive.org/web/20140716104947/http://mysite.verizon.net/res148h4j/zenosamples/zs_lunarphasecalc.html},
#' Last accessed: 1 September 2014.
#' @param x
#' A vector of \code{\link[base]{Date}} values.
Expand Down Expand Up @@ -373,7 +380,7 @@ lunar.distance <- function(
## Returns the distance of the moon from the earth on a given date.
##========================================================================
## Adapted from Stephen R. Schmitt: Lunar Phase Computation:
## http://mysite.verizon.net/res148h4j/zenosamples/zs_lunarphasecalc.html
## https://web.archive.org/web/20140716104947/http://mysite.verizon.net/res148h4j/zenosamples/zs_lunarphasecalc.html
##========================================================================

Y <- as.numeric(format(x, "%Y"))
Expand Down Expand Up @@ -594,27 +601,44 @@ lunar.distance.mean <- function(
#' \item{Autumn:}{21 September through 20 December}
#' }
#' In leap years spring comes a day early!
#' Thanks to Mehis Rohtla for finding an error in the 0.1-04 version code.
#' @param x
#' A vector of \code{\link[base]{Date}} values.
#' @param cutoffs
#' A vector of numbers corresponding to days of the year when
#' season labels change.
#' @param southern.hemisphere
#' The season labels follow a northern hemisphere order unless
#' this option is set to TRUE.
#' @examples
#' terrestrial.season(as.Date("2004-03-24"))
#' terrestrial.season(as.Date("2017-03-21"))
#' terrestrial.season(as.Date("2017-03-22"))
#' terrestrial.season(as.Date("2017-12-20"), southern.hemisphere = TRUE)
#' terrestrial.season(as.Date("2017-12-21"), southern.hemisphere = TRUE)
#' @keywords earth season
#' @seealso \code{\link{terrestrial.seasons}}
#' @export
terrestrial.season <- function(
x
) {

terrestrial.season <- function (x, cutoffs = c(80, 172, 263, 354), southern.hemisphere = FALSE)
{
# Check that we have a proper Date
if(!is(x, "Date")) stop("Must provide a Date.")
if(!("Date" %in% class(x))) stop("Must provide a Date.")

# Check that we have four cutoffs to split the seasons
if (length(cutoffs) != 4) stop("Cutoffs must be a vector of length 4.")

# Code presumes northern hemisphere unless otherwise specified
my.terrestrial.seasons <- terrestrial.seasons
if(southern.hemisphere)
my.terrestrial.seasons <- c(terrestrial.seasons[3:4], terrestrial.seasons[1:2])

my.day <- as.POSIXlt(x)$yday

return(factor(
ifelse(my.day < 81, terrestrial.seasons[1],
ifelse(my.day < 173, terrestrial.seasons[2],
ifelse(my.day < 284, terrestrial.seasons[3],
ifelse(my.day < 355, terrestrial.seasons[4],
terrestrial.seasons[1])))),
levels = terrestrial.seasons))
ifelse(my.day < cutoffs[1], my.terrestrial.seasons[1],
ifelse(my.day < cutoffs[2], my.terrestrial.seasons[2],
ifelse(my.day < cutoffs[3], my.terrestrial.seasons[3],
ifelse(my.day < cutoffs[4], my.terrestrial.seasons[4],
my.terrestrial.seasons[1])))),
levels = my.terrestrial.seasons))
}

11 changes: 5 additions & 6 deletions inst/CITATION
@@ -1,14 +1,13 @@
bibentry("Manual",
title="lunar: Lunar Phase & Distance, Seasons and Other Environmental Factors",
author="Emmanuel Lazaridis",
year="2014",
note="(Version 0.1-04)",
url="http://statistics.lazaridis.eu",
year="2022",
note="(Version 0.2-01)",

textVersion =
paste("Lazaridis, E. (2014). ",
"lunar: Lunar Phase & Distance, Seasons and Other Environmental Factors (Version 0.1-04). ",
"Available from http://statistics.lazaridis.eu",
paste("Lazaridis, E. (2022). ",
"lunar: Lunar Phase & Distance, Seasons and Other Environmental Factors (version 0.2-01). ",
"Available from CRAN",
sep=""),

mheader = "To cite lunar in publications use:")
15 changes: 10 additions & 5 deletions man/lunar-package.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions man/lunar.4phases.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions man/lunar.8phases.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions man/lunar.distance.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 115e9f9

Please sign in to comment.