-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
69 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#' Convert years BP from pastclim to lubridate date, or vice versa | ||
#' | ||
#' These functions convert between years BP as used by pastclim (negative | ||
#' numbers going into | ||
#' the past, positive into the future) and standard | ||
#' `POSIXct` date objects. | ||
#' @param x a time in years BP using the `pastclim` convention of | ||
#' negative numbers indicating years into the past, or a `POSIXct` date object | ||
#' @returns a `POSIXct` date object, or a vector | ||
#' @examples | ||
#' ybp2date(-10000) | ||
#' ybp2date(0) | ||
#' # back and forth | ||
#' date2ybp(ybp2date(-10000)) | ||
#' | ||
#' @export | ||
|
||
ybp2date <- function(x) { | ||
if (!is.numeric(x)) { | ||
stop("x should be numeric") | ||
} | ||
lubridate::date_decimal(x + 1950) | ||
} | ||
|
||
#' @rdname ybp2date | ||
#' @export | ||
date2ybp <- function(x) { | ||
if (!inherits(x, "POSIXct")) { | ||
stop("x should be a POSIXct object") | ||
} | ||
lubridate::year(x) - 1950 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -78,6 +78,7 @@ kyr | |
lai | ||
landmask | ||
longname | ||
lubridate | ||
mis | ||
nc | ||
netcdf | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.