Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #42

Merged
merged 8 commits into from
Aug 30, 2024
Merged

Dev #42

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
S3method(condensation,adm)
S3method(condensation,multiadm)
S3method(get_L_tp,adm)
S3method(get_L_tp,multiadm)
S3method(get_L_tp,sac)
S3method(get_L_unit,adm)
S3method(get_L_unit,multiadm)
S3method(get_L_unit,sac)
S3method(get_T_tp,adm)
S3method(get_T_tp,multiadm)
S3method(get_T_tp,sac)
S3method(get_T_unit,adm)
S3method(get_T_unit,multiadm)
Expand All @@ -30,14 +32,20 @@ S3method(get_time,adm)
S3method(get_time,multiadm)
S3method(get_total_duration,adm)
S3method(get_total_duration,multiadm)
S3method(get_total_duration,sac)
S3method(get_total_thickness,adm)
S3method(get_total_thickness,multiadm)
S3method(get_total_thickness,sac)
S3method(is_destructive,adm)
S3method(is_destructive,multiadm)
S3method(max_height,adm)
S3method(max_height,sac)
S3method(max_time,adm)
S3method(max_time,sac)
S3method(min_height,adm)
S3method(min_height,sac)
S3method(min_time,adm)
S3method(min_time,sac)
S3method(plot,adm)
S3method(plot,multiadm)
S3method(plot,sac)
Expand All @@ -61,6 +69,7 @@ S3method(strat_to_time,numeric)
S3method(strat_to_time,phylo)
S3method(summary,adm)
S3method(summary,multiadm)
S3method(summary,sac)
S3method(time_to_strat,list)
S3method(time_to_strat,numeric)
S3method(time_to_strat,phylo)
Expand Down
4 changes: 3 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@

* abstracted exctraction of tie points

* added utility functions for S3 class `sac`

# admtools 0.3.0

* removed dependency from `ape` package

* defined S3 class `timelist` and `stratlist` for data assiciated with time/height
* defined S3 class `timelist` and `stratlist` for data associated with time/height

* unified syntax for time-depth transformation

Expand Down
8 changes: 7 additions & 1 deletion R/get_L_tp.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ get_L_tp = function(x, ...){
#'
#' @title get height/length tie point
#'
#' @param x age-depth model (adm) or sediment accumulation curve (sac)
#' @param x age-depth model (adm/multiadm) or sediment accumulation curve (sac)
#' @param ... other options, currently not used
#'
#' @description
Expand All @@ -26,4 +26,10 @@ get_L_tp.sac = function(x, ...){
#' @export
#'
return(x$h)
}

get_L_tp.multiadm = function(x, ...){
#' @export
#'
return(x$h)
}
7 changes: 6 additions & 1 deletion R/get_T_tp.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ get_T_tp = function(x, ...){
#'
#' @title extract time tie points
#'
#' @param x age-depth model (adm) or sediment accumulation curve (sac)
#' @param x age-depth model (adm/multiadm) or sediment accumulation curve (sac)
#' @param ... other options, currently unused
#'
#' @description
Expand All @@ -24,4 +24,9 @@ get_T_tp.adm = function(x, ...){
get_T_tp.sac = function(x, ...){
#' @export
return(x$t)
}

get_T_tp.multiadm = function(x, ...){
#' @export
return(x$t)
}
37 changes: 34 additions & 3 deletions R/get_total_duration.R
Original file line number Diff line number Diff line change
@@ -1,14 +1,45 @@
get_total_duration = function(x){
get_total_duration = function(x, ...){

#' @export
#'
#' @title Total duration covered
#'
#' @param x an adm object
#' @param x age-depth model (adm/multiadm) or sediment accumulation curve (sac)
#' @param ... other options, currently unused
#'
#' @returns numeric vector, total duration covered by the age-depth models
#' @returns numeric, total duration covered by the age-depth models/sediment accumulation curve
#'
#' @seealso [min_time()] and [max_time()] to extract the first/last tie point in time
#'
UseMethod("get_total_duration")
}

get_total_duration.adm = function(x, ...){

#'
#' @export
#'
adm = x
return(diff(range(adm$t)))
}

get_total_duration.multiadm = function(x, ...){
#'
#' @export
#'

multiadm = x

adm_list = split_multiadm(multiadm)

durations = sapply(adm_list, function(x) get_total_duration(x))
return(durations)

}

get_total_duration.sac = function(x, ...){
#' @export
#'
t = get_T_tp(x)
return(diff(range(t)))
}
8 changes: 0 additions & 8 deletions R/get_total_duration.adm.R

This file was deleted.

13 changes: 0 additions & 13 deletions R/get_total_duration.multiadm.R

This file was deleted.

50 changes: 45 additions & 5 deletions R/get_total_thickness.R
Original file line number Diff line number Diff line change
@@ -1,16 +1,56 @@
get_total_thickness = function(x){
get_total_thickness = function(x, ...){

#'
#'
#' @export
#'
#' @title get thickness
#' @title get total thickness
#'
#' @param x an adm object
#' @param x an age-depth model (adm/multiadm) or a sediment accumulation curve (sac)
#' @param ... other options, currently unused
#'
#' @returns numeric vector containing total sediment thickness accumulated
#' @returns numeric, total sediment thickness accumulated
#'
#' @description
#' for sediment accumulation curves, returns the difference between the highest and lowest point of the curve. For age-depth models, returns the total thickness of sediment accumulated.
#'
#'
#' @seealso [max_height()] and [min_height()] to extract the highest/lowest stratigraphic point
#'
UseMethod("get_total_thickness")
}
}

get_total_thickness.multiadm = function(x, ...){

#'
#' @export
#'

multiadm = x

adm_list = split_multiadm(multiadm)

thicknesses = sapply(adm_list, function(x) get_total_thickness(x))
return(thicknesses)


}


get_total_thickness.adm = function(x, ...){

#'
#' @export
#'
#'

adm = x
return(diff(range(adm$h)))
}

get_total_thickness.sac = function(x, ...){
#' @export
#'
h = get_L_tp(x)
return(diff(range(h)))
}
10 changes: 0 additions & 10 deletions R/get_total_thickness.adm.R

This file was deleted.

15 changes: 0 additions & 15 deletions R/get_total_thickness.multiadm.R

This file was deleted.

17 changes: 12 additions & 5 deletions R/max_heigth.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
max_height = function(x){
#' @export
#'
#' @title get highest stratigraphic position in an adm
#' @title get highest stratigraphic tie point
#'
#' @param x an age-depth model
#' @param x age-depth model (adm) or sediment accumulation curve (sac)
#'
#' @returns a scalar
#' @returns number, stratigraphic position of the highest stratigraphic tie point
#'
#' @seealso [min_height()], [get_total_thickness()]
#'
Expand All @@ -14,6 +14,13 @@ max_height = function(x){

max_height.adm = function(x){
#' @export

return(max(x$h))
h = get_L_tp.adm(x)
return(max(h))
}

max_height.sac = function(x){
#' @export
#'
h = get_L_tp.sac(x)
return(max(h))
}
15 changes: 11 additions & 4 deletions R/max_time.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
max_time = function(x){
#' @export
#'
#' @title extract earliest time from adm
#' @title last time tie point
#'
#' @param x age-depth model
#' @param x age-depth model (adm) or sediment accumulation curve (sac)
#'
#' @returns a scalar, timing of earliest tie point in the adm
#' @returns number, last time tie point of the age-depth model/sediment accumulation curve
#'
#' @seealso [min_time()], [get_total_duration()]
#'
Expand All @@ -15,5 +15,12 @@ max_time = function(x){
max_time.adm = function(x){
#' @export
#'
return(max(x$t))
t = get_T_tp.adm(x)
return(max(t))
}

max_time.sac = function(x){
#' @export
t = get_T_tp.sac(x)
return(max(t))
}
16 changes: 12 additions & 4 deletions R/min_height.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ min_height = function(x){

#' @export
#'
#' @title get lowest stratigraphic position in an adm
#' @title get lowest stratigraphic tie point
#'
#' @param x an age-depth model
#' @param x an age-depth model (adm) or sediment accumulation curve (sac)
#'
#' @returns number, stratigraphic position of lowest tie poin
#'
#' @seealso [get_total_thickness()], [max_height()]
#'
Expand All @@ -15,6 +17,12 @@ min_height = function(x){
min_height.adm = function(x){

#' @export

return(min(x$h))
h = get_L_tp.adm(x)
return(min(h))
}

min_height.sac = function(x){
#' @export
h = get_L_tp.sac(x)
return(min(h))
}
16 changes: 12 additions & 4 deletions R/min_time.R
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
min_time = function(x){
#' @export
#'
#' @title extract last time from adm
#' @title first time tie point
#'
#' @param x age-depth model
#' @param x age-depth model (adm) or sediment accumulation curve (sac)
#'
#' @returns a scalar, timing of last tie point in the adm
#' @returns number, timing of first tie point of the age-depth model/sediment accumulation curve
#'
#' @seealso [max_time()], [get_total_duration()]
#'
Expand All @@ -15,5 +15,13 @@ min_time = function(x){
min_time.adm = function(x){
#' @export
#'
return(min(x$t))
t = get_T_tp.adm(x)
return(min(t))
}

min_time.sac = function(x){
#' @export
#'
t = get_T_tp.sac(x)
return(min(t))
}
Loading