Skip to content

Commit

Permalink
Merge pull request #23 from MindTheGap-ERC/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
NiklasHohmann authored Mar 1, 2024
2 parents aa9d5c3 + 8e8028a commit a74fede
Show file tree
Hide file tree
Showing 33 changed files with 1,204 additions and 320 deletions.
7 changes: 4 additions & 3 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ identifiers:
value: 10.5281/zenodo.10213587
description: Archived version on Zenodo
repository-code: 'https://github.com/MindTheGap-ERC/admtools'
url: 'https://mindthegap-erc.github.io/admtools/'
abstract: >-
R package to estimate age-depth models and transform data
between the time domain and the stratigraphic domain.
Expand All @@ -26,6 +27,6 @@ keywords:
- Age-depth modeling
- Stratigraphy
- Sedimentology
license: Apache-2.0
version: 0.1.0
date-released: '2023-12-05'
license: GPL-3.0
version: 0.2.0
date-released: '2024-03-03'
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: admtools
Title: Estimate and Manipulate Age-Depth Models
Version: 0.1.0.9000
Version: 0.2.0
Authors@R:
person("Niklas", "Hohmann", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-1559-1838"))
Expand Down
10 changes: 9 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ S3method(condensation,adm)
S3method(condensation,multiadm)
S3method(get_L_unit,adm)
S3method(get_L_unit,multiadm)
S3method(get_L_unit,sac)
S3method(get_T_unit,adm)
S3method(get_T_unit,multiadm)
S3method(get_T_unit,sac)
S3method(get_completeness,adm)
S3method(get_completeness,multiadm)
S3method(get_height,adm)
Expand Down Expand Up @@ -40,8 +42,10 @@ S3method(sed_rate_t,adm)
S3method(sed_rate_t,multiadm)
S3method(set_L_unit,adm)
S3method(set_L_unit,multiadm)
S3method(set_L_unit,sac)
S3method(set_T_unit,adm)
S3method(set_T_unit,multiadm)
S3method(set_T_unit,sac)
S3method(strat_to_time,list)
S3method(strat_to_time,phylo)
S3method(summary,adm)
Expand All @@ -59,6 +63,7 @@ export(flux_quad)
export(get_L_unit)
export(get_T_unit)
export(get_completeness)
export(get_data_from_eTimeOpt)
export(get_height)
export(get_hiat_duration)
export(get_hiat_list)
Expand All @@ -70,6 +75,7 @@ export(get_total_duration)
export(get_total_thickness)
export(is_adm)
export(is_destructive)
export(is_sac)
export(make_legend)
export(merge_adm_to_multiadm)
export(merge_multiadm)
Expand All @@ -78,6 +84,8 @@ export(plot_erosive_intervals)
export(plot_sed_rate_l)
export(plot_sed_rate_t)
export(sac_to_adm)
export(sed_rate_from_matrix)
export(sed_rate_gen_from_bounds)
export(sed_rate_l)
export(sed_rate_l_fun)
export(sed_rate_t)
Expand All @@ -86,7 +94,7 @@ export(sedrate_to_multiadm)
export(set_L_unit)
export(set_T_unit)
export(split_multiadm)
export(strat_cont_gen_from_proxy)
export(strat_cont_gen_from_tracer)
export(strat_cont_to_multiadm)
export(strat_to_time)
export(time_to_strat)
Expand Down
16 changes: 15 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
# admtools (development version)

# admtools 0.2.0

* expanded documentation of defined S3 classes

* added S3 class `sac` for sediment accumulation curves

* methods for objects of class `phylo` and `list`

* expanded estimation procedures to multiple tie points

* improved plotting

* estimation of sedimentation rates

# admtools 0.1.0

* Updated vignettes

* Added generics `time_to_strat` and `strat_to_time` to transfrom objects between time and stratigraphic domain
* Added generics `time_to_strat` and `strat_to_time` to transform objects between time and stratigraphic domain

* Added package help

Expand Down
31 changes: 31 additions & 0 deletions R/T_and_L_unit_handling.R
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ get_L_unit.multiadm = function(x, ...){
return(x$L_unit)
}

get_L_unit.sac = function(x, ...){

#' @export

return(x$L_unit)
}


set_L_unit = function(x, L_unit, ...){

#'
Expand Down Expand Up @@ -72,6 +80,14 @@ set_L_unit.multiadm = function(x, L_unit, ...){
return(x)
}

set_L_unit.sac = function(x, L_unit, ...){

#' @export
#'
x$L_unit = L_unit
return(x)
}

get_T_unit = function(x, ...){

#'
Expand Down Expand Up @@ -106,6 +122,13 @@ get_T_unit.multiadm = function(x, ...){
return(x$T_unit)
}

get_T_unit.sac = function(x, ...){

#' @export

return(x$T_unit)
}

set_T_unit = function(x, T_unit, ...){

#'
Expand Down Expand Up @@ -139,6 +162,14 @@ set_T_unit.adm = function(x, T_unit, ...){

set_T_unit.multiadm = function(x, T_unit, ...){

#' @export
#'
x$T_unit = T_unit
return(x)
}

set_T_unit.sac = function(x, T_unit, ...){

#' @export
#'
x$T_unit = T_unit
Expand Down
27 changes: 27 additions & 0 deletions R/eTimeOpt_functionality.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
get_data_from_eTimeOpt = function(res, index = 1){
#' @export
#' @title extract data from eTimeOpt results
#'
#' @param res results generated by eTimeOpt
#' @param index which output should be extracted? See description for details
#'
#' @description
#' Extracts data from eTimeOpt. The type of data extractecd dependes on the `output` setting used for eTimeOpt. If you want ot extract specific data, adjust the output parameter in eTimeOpt to return the correct data (e.g. 2 for r^2 envelope). See eTimeOpt documentation for details on this. Then call this function on the return variable.
#'
#'
#' @seealso [sed_rate_from_matrix()] to use define sedimentation rates based on this functions outputs, [sedrate_to_multiadm()] to estimate age-depth models from the outputs.
#'
#' @returns a list with three entries
#' "sed_rate" : numeric vector, sedimentation rates
#' "height" : numeric vector, heights
#' "results" : matrix with length(height) rows and length(sed_rate) columns. results of eTimeOpt
r = res[[index]]
sedrate = r$sedrates
r = r[, colnames(r) != "sedrates"]
heights = as.numeric(sub(".", "", colnames(r)))
results = data.matrix(r)

return(list("sed_rate" = sedrate,
"heights" = heights,
"results" = results))
}
31 changes: 21 additions & 10 deletions R/flux_helpers.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
flux_const = function(){
#' @export
#'
#' @title constant deterministic proxy flux
#' @title constant deterministic tracer flux
#'
#' @description
#' For usage with _strat_cont_to_multiadm_; defines constant proxy flux in the time domain
#' @returns a functional
#' For usage with _strat_cont_to_multiadm_; defines constant tracer flux in the time domain
#' @returns a function factory that takes no arguments
#'
#' @examples
#' \dontrun{
#' # see this vignette for an example
#' vignette("adm_from_trace_cont")
#' }
#'
#' @seealso [flux_linear()], [flux_quad()], [strat_cont_gen_from_tracer()]
f = function() {stats::approxfun(x = c(0,1),
y = c(1,1),
rule = 2)}
Expand All @@ -15,18 +23,19 @@ flux_const = function(){
flux_linear = function(x0 = 0, y0 = 1, x1 = 1, y1 = 2){
#' @export
#'
#' @title linear deterministic proxy flux
#' @title linear deterministic tracer flux
#'
#' @description
#' For usage with _strat_cont_to_multiadm_ : defines linear proxy flux in the time domain
#' Proxy flux is the linear function passing thrpugh the points (x0, y0) and (x1, y1)
#' For usage with _strat_cont_to_multiadm_ : defines linear tracer flux in the time domain
#' Tracer flux is the linear function passing through the points (x0, y0) and (x1, y1)
#' @param x0 numeric, abscissa
#' @param y0 numeric, ordinate
#' @param x1 numeric, abscissa
#' @param y1 numeric, ordinate
#'
#' @returns a functional that takes no arguments. Upon each evaluation, it returns a linear function passing thrpugh the points (x0, y0) and (x1, y1)
#' @returns a function factory that takes no arguments. Upon each evaluation, it returns a linear function passing through the points (x0, y0) and (x1, y1)
#'
#' @seealso [flux_const()], [flux_quad()], [strat_cont_gen_from_tracer()]
f = function(x){
m = (y1 - y0)/(x1 - x0)
return( m * (x - x0) + y0 )
Expand All @@ -37,16 +46,18 @@ flux_linear = function(x0 = 0, y0 = 1, x1 = 1, y1 = 2){
flux_quad = function(a = 1, b = 1, c = 1){
#' @export
#'
#' @title quadratic deterministix proxy flux
#' @title quadratic deterministic tracer flux
#'
#' @description
#' For usage with _strat_cont_to_multiadm_ : defines quadratic proxy flux in the time domain
#' For usage with _strat_cont_to_multiadm_ : defines quadratic tracer flux in the time domain
#' defined by the function f(x) = ax^2 + bx + c
#' @param a numeric
#' @param b numeric
#' @param c numeric
#'
#' @returns a functional that takes no arguments. Upon each evaluation, it returns the quadratic function f(x) = ax^2 + bx + c
#' @seealso [flux_linear()], [flux_const()], [strat_cont_gen_from_tracer()]
#'
#' @returns a function factory that takes no arguments. Upon each evaluation, it returns the quadratic function f(x) = ax^2 + bx + c

f = function(x){
return(a*x^2 + b*x +c)
Expand Down
28 changes: 28 additions & 0 deletions R/is_sac.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
is_sac = function(x){
#' @export
#'
#' @title is valid sac objects
#'
#' @description
#' checks if the object is a valid sac object
#'
#' @param x the object to check
#'
#' @returns logical. Is x a valid `sac` object?

if ( ! inherits(x, "sac")) { return(FALSE) }

if (! all(names(x) %in% c("t","h","T_unit","L_unit"))) { return(FALSE) }

if (length(x$t) != length(x$h)) { return(FALSE) }

if (length(x$t) < 2 ) { return(FALSE) }

if ( !(is.null(x$T_unit) | is.character(x$T_unit))) { return(FALSE) }
if ( !(is.null(x$L_unit) | is.character(x$L_unit))) { return(FALSE) }

if (is.unsorted(x$t, strictly = TRUE)) {return(FALSE)}

return(TRUE)

}
Loading

0 comments on commit a74fede

Please sign in to comment.