Skip to content

Commit 2253bd9

Browse files
authored
Merge pull request #86 from boshek/master
Some general updates and housekeeping
2 parents 4f91ff9 + 240b730 commit 2253bd9

File tree

88 files changed

+3147
-1298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+3147
-1298
lines changed

.Rbuildignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ changelog.txt
55
^\.Rproj\.user$
66
README.md
77

8+
^README\.Rmd$
9+
^README-.*\.png$

DESCRIPTION

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: rLakeAnalyzer
22
Title: Lake Physics Tools
33
Maintainer: Luke Winslow <lawinslow@gmail.com>
4-
Version: 1.10.0
4+
Version: 1.11.0
55
Author: Luke Winslow, Jordan Read, Richard Woolway, Jennifer Brentrup, Taylor
66
Leach, Jake Zwart, Sam Albers, Doug Collinge
77
Description: Standardized methods for calculating common important derived
@@ -10,13 +10,19 @@ Description: Standardized methods for calculating common important derived
1010
number, Schmidt stability and others.
1111
Depends: R (>= 2.10)
1212
Imports:
13-
plyr
13+
plyr,
14+
stats,
15+
graphics,
16+
utils,
17+
grDevices
1418
Suggests:
1519
testthat,
1620
knitr,
1721
rmarkdown
1822
License: GPL (>= 2)
1923
Packaged: 2014-07-06 09:09:24 UTC; Luke
2024
Repository: https://github.com/GLEON/rLakeAnalyzer
25+
BugReports: https://github.com/GLEON/rLakeAnalyzer/issues
2126
Date/Publication: 2015-04-02 12:00:00
2227
RoxygenNote: 6.0.1
28+
VignetteBuilder: knitr

NAMESPACE

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,39 @@
1-
export(wedderburn.number, layer.density, lake.number, uStar, water.density,
2-
thermo.depth, meta.depths, schmidt.stability, ts.meta.depths,
3-
ts.thermo.depth, load.bathy, load.ts, get.offsets, ts.schmidt.stability,
4-
ts.meta.depths, ts.thermo.depth, ts.lake.number, ts.uStar, ts.layer.temperature,
5-
ts.wedderburn.number, ts.buoyancy.freq, buoyancy.freq, layer.temperature,
6-
wtr.heat.map, wtr.lineseries, wtr.heatmap.layers, wtr.plot.temp, lake.number.plot,
7-
schmidt.plot, center.buoyancy, ts.center.buoyancy, internal.energy,
8-
ts.internal.energy, epi.temperature, hypo.temperature, whole.lake.temperature,
9-
approx.bathy)
1+
# Generated by roxygen2: do not edit by hand
2+
3+
export(approx.bathy)
4+
export(buoyancy.freq)
5+
export(center.buoyancy)
106
export(depth.filter)
7+
export(epi.temperature)
8+
export(get.offsets)
9+
export(hypo.temperature)
10+
export(internal.energy)
11+
export(lake.number)
12+
export(lake.number.plot)
13+
export(layer.density)
14+
export(layer.temperature)
15+
export(load.bathy)
16+
export(load.ts)
17+
export(meta.depths)
18+
export(schmidt.plot)
19+
export(schmidt.stability)
20+
export(thermo.depth)
21+
export(ts.buoyancy.freq)
22+
export(ts.center.buoyancy)
23+
export(ts.internal.energy)
24+
export(ts.lake.number)
25+
export(ts.layer.temperature)
26+
export(ts.meta.depths)
27+
export(ts.schmidt.stability)
28+
export(ts.thermo.depth)
29+
export(ts.uStar)
30+
export(ts.wedderburn.number)
31+
export(uStar)
32+
export(water.density)
33+
export(wedderburn.number)
34+
export(whole.lake.temperature)
35+
export(wtr.heat.map)
36+
export(wtr.heatmap.layers)
1137
export(wtr.layer)
12-
13-
import("plyr")
14-
importFrom("grDevices", "colorRampPalette")
15-
importFrom("graphics", "abline", "axis", "filled.contour", "legend",
16-
"lines", "plot", "segments", "title")
17-
importFrom("stats", "approx")
18-
importFrom("utils", "read.table")
19-
20-
21-
38+
export(wtr.lineseries)
39+
export(wtr.plot.temp)

NEWS.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# rLakeAnalyzer 1.11.0
2+
* Added a `NEWS.md` file to track changes to the package.
3+
* revamp README with more detail
4+
* convert all documentation to roxygen2 (#44)
5+
* Add top level documentation file (#22)
6+
* Add split and merge vignette
7+
8+
# rLakeAnalyzer 1.10.0
9+
10+
11+
* Added split and merge algorithm to package which enable auto detection of clines (e.g thermoclines)
12+
13+
14+

R/approx.bathy.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
#' @title Estimate hypsography curve
32
#'
43
#' @description Estimates a depth-area curve for a lake using lake surface area,
@@ -40,7 +39,7 @@
4039
approx.bathy <- function(Zmax, lkeArea, Zmean = NULL, method = "cone", zinterval = 1, depths = seq(0, Zmax, by = zinterval)){
4140
Area = c()
4241
if(method == "cone"){
43-
area <- approx(c(0, Zmax), c(lkeArea, 0), depths)$y
42+
area <- stats::approx(c(0, Zmax), c(lkeArea, 0), depths)$y
4443
Area = data.frame(depths = depths, Area.at.z = area)
4544
} #end of "cone"
4645

R/buoyancy.freq.R

Lines changed: 73 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,34 @@
1-
#
2-
# Buoyancy Frequency
3-
# Author: Luke Winslow <lawinslow@gmail.com>
4-
#
1+
#' @title Calculates buoyancy frequency.
2+
#'
3+
#' @description Calculate the buoyancy frequency (Brunt-Vaisala frequency) for a temperature
4+
#' profile.
5+
#'
6+
#'
7+
#' @param wtr a numeric vector of water temperature in degrees C
8+
#' @param depths a numeric vector corresponding to the depths (in m) of the wtr
9+
#' measurements
10+
#' @return Returns a vector of buoyancy frequency in units \code{sec^-2}.
11+
#' Return value has attribute "depths" which define buoyancy frequency depths
12+
#' (which differ from supplied depths).
13+
#' @seealso \code{thermo.depth}, \code{ts.buoyancy.freq}
14+
#' @keywords arith
15+
#' @examples
16+
#'
17+
#'
18+
#' # A vector of water temperatures
19+
#' wtr = c(22.51, 22.42, 22.4, 22.4, 22.4, 22.36, 22.3, 22.21, 22.11, 21.23, 16.42,
20+
#' 15.15, 14.24, 13.35, 10.94, 10.43, 10.36, 9.94, 9.45, 9.1, 8.91, 8.58, 8.43)
21+
#'
22+
#' #A vector defining the depths
23+
#' depths = c(0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
24+
#' 17, 18, 19, 20)
25+
#'
26+
#' b.f = buoyancy.freq(wtr, depths)
27+
#'
28+
#' plot(b.f, attr(b.f, 'depths'), type='b',
29+
#' ylab='Depth', xlab='Buoyancy Frequency', ylim=c(max(depths), min(depths)))
30+
#'
31+
#' @export
532
buoyancy.freq <- function(wtr, depths){
633

734
rhoVar = water.density(wtr)
@@ -22,6 +49,48 @@ buoyancy.freq <- function(wtr, depths){
2249

2350
}
2451

52+
53+
54+
#' @title Calculate the buoyancy (Brunt-Vaisala) frequency for a temperature profile.
55+
#'
56+
#' @description Function for simplifying the calculation of buoyancy frequency. Can usually
57+
#' be called directly on data loaded directly using \code{\link{load.ts}} and
58+
#' \code{\link{load.bathy}}.
59+
#'
60+
#'
61+
#' @param wtr A data frame of water temperatures (in Celsius). Loaded using
62+
#' \code{\link{load.ts}}
63+
#' @param at.thermo Boolean indicating if only buoyancy frequency at the
64+
#' thermocline should be returned. If false, full profile is returned.
65+
#' @param na.rm Boolean indicated if step-by-step removal of NA's should be
66+
#' tried. If false, a timestep with any NA values will likely return an NA
67+
#' value. If true, best effort will be made to calculate indices despite NA
68+
#' values.
69+
#' @param ... Additional parameters will be passed on to \code{thermo.depth}
70+
#' function when extracting buoyancy frequency at only the thermocline. Common
71+
#' parameters to supply would be \code{seasonal} and \code{slope}.
72+
#' @return Returns a data frame with the timeseries of buoyancy frequency in
73+
#' units \code{sec^-2}. Includes a \sQuote{datetime} column.
74+
#' @seealso \code{buoyancy.freq}
75+
#' @references Imberger, J., Patterson, J.C., 1990. \emph{Physical limnology}.
76+
#' Advances in Applied Mechanics 27, 353-370.
77+
#' @keywords arith
78+
#' @examples
79+
#'
80+
#'
81+
#' #Get the path for the package example file included
82+
#' wtr.path <- system.file('extdata', 'Sparkling.daily.wtr', package="rLakeAnalyzer")
83+
#'
84+
#' #Load data for example lake, Sparkilng Lake, Wisconsin.
85+
#' sp.wtr = load.ts(wtr.path)
86+
#'
87+
#' N2 = ts.buoyancy.freq(sp.wtr, seasonal=FALSE)
88+
#' SN2 = ts.buoyancy.freq(sp.wtr, seasonal=TRUE)
89+
#'
90+
#' plot(N2, type='l', ylab='Buoyancy Frequency', xlab='Date')
91+
#' lines(SN2, col='red')
92+
#'
93+
#' @export
2594
ts.buoyancy.freq <- function(wtr, at.thermo=TRUE, na.rm=FALSE, ...){
2695

2796
depths = get.offsets(wtr)

R/center.buoyancy.R

Lines changed: 71 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,32 @@
1-
#
2-
# Center of Buoyancy Frequency
3-
# Author: Jordan S Read <jread@usgs.gov>
4-
#
1+
#' @title Calculates the center of buoyancy.
2+
#'
3+
#' @description Calculate the center of buoyancy using buoyancy frequency with a center of
4+
#' mass analysis. Brunt-Vaisala frequency is used for a temperature profile.
5+
#' Negative values for N2 are set to 0 (as they represent transient
6+
#' instabilities or sensor calibration issues) for this calculation.
7+
#'
8+
#'
9+
#' @param wtr a numeric vector of water temperature in degrees C
10+
#' @param depths a numeric vector corresponding to the depths (in m) of the wtr
11+
#' measurements
12+
#' @return Returns a value for the center of buoyancy.
13+
#' @seealso \code{buoyancy.freq}, \code{ts.buoyancy.freq},
14+
#' \code{center.buoyancy}
15+
#' @keywords arith
16+
#' @examples
17+
#'
18+
#'
19+
#' # A vector of water temperatures
20+
#' wtr = c(22.51, 22.42, 22.4, 22.4, 22.4, 22.36, 22.3, 22.21, 22.11, 21.23, 16.42,
21+
#' 15.15, 14.24, 13.35, 10.94, 10.43, 10.36, 9.94, 9.45, 9.1, 8.91, 8.58, 8.43)
22+
#'
23+
#' #A vector defining the depths
24+
#' depths = c(0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
25+
#' 17, 18, 19, 20)
26+
#'
27+
#' c.b = center.buoyancy(wtr, depths)
28+
#'
29+
#' @export
530
center.buoyancy <- function(wtr, depths){
631

732
if (depths[2] - depths[1] < 0 ){stop('depths must be in descending order')}
@@ -23,6 +48,48 @@ center.buoyancy <- function(wtr, depths){
2348
}
2449

2550

51+
52+
53+
#' @title Calculates the center of buoyancy for multiple temperature profiles.
54+
#'
55+
#' @description Function for simplifying the calculation of the center of buoyancy. Can
56+
#' usually be called directly on data loaded directly using
57+
#' \code{\link{load.ts}} and \code{\link{load.bathy}}.
58+
#'
59+
#'
60+
#' @param wtr A data frame of water temperatures (in Celsius). Loaded using
61+
#' \code{\link{load.ts}}
62+
#' @param na.rm Boolean indicated if step-by-step removal of NA's should be
63+
#' tried. If false, a timestep with any NA values will return an NA value. If
64+
#' true, best effort will be made to calculate indices despite NA values.
65+
#' @return Returns a data frame with the timeseries of the center of buoyancy
66+
#' frequency. Includes a \sQuote{datetime} column.
67+
#' @seealso \code{center.buoyancy}, \code{load.bathy}, \code{load.ts}
68+
#' @references Imberger, J., Patterson, J.C., 1990. \emph{Physical limnology}.
69+
#' Advances in Applied Mechanics 27, 353-370.
70+
#' @keywords arith
71+
#' @examples
72+
#'
73+
#'
74+
#' #Get the path for the package example file included
75+
#' wtr.path <- system.file('extdata', 'Sparkling.daily.wtr', package="rLakeAnalyzer")
76+
#'
77+
#' #Load data for example lake, Sparkilng Lake, Wisconsin.
78+
#' sp.wtr = load.ts(wtr.path)
79+
#'
80+
#' #calculate and plot the thermocline depth
81+
#' t.d = ts.thermo.depth(sp.wtr)
82+
#'
83+
#' center.N2 = ts.center.buoyancy(sp.wtr)
84+
#'
85+
#' plot(center.N2, type='l', ylab='Depth (m)', xlab='Date', ylim=c(19,0), lwd = 1.5)
86+
#' lines(t.d, type='l', col='red', lwd = 1.5)
87+
#' legend(x = t.d[3,1], y = .25,
88+
#' c('center of buoyancy','thermocline depth'),
89+
#' lty=c(1,1),
90+
#' lwd=c(1.5,1.5),col=c("black","red"), bty = "n")
91+
#'
92+
#' @export
2693
ts.center.buoyancy <- function(wtr, na.rm=FALSE){
2794

2895
depths = get.offsets(wtr)

R/data.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
#' Late Summer Profile
1+
#' @title Late Summer Profile
22
#'
3-
#' Late summer water profile taken from Quesnel Lake, British Columbia, Canada. Profile taken with Sea-Bird
3+
#' @description Late summer water profile taken from Quesnel Lake, British Columbia, Canada. Profile taken with Sea-Bird
44
#' SBE19plus.
55
#'
66
#' \describe{

R/epi.temperature.R

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
#' @title Get volumetrically averaged epilimnion temp
22
#'
3-
#' @description Calculates volumetrically weighted average epilimnetic temperature using
4-
#' the supplied water temperature timeseries. If the lake is not stratified, the bottom
5-
#' of the epilimnion is calculated as the full depth of the lake.
6-
#'
7-
#' @param wtr a numeric vector of water temperature in degrees C.
8-
#' @param depths a numeric vector corresponding to the depths (in m) of the wtr measurements
9-
#' @param bthA a numeric vector of cross sectional areas (m^2) corresponding to bthD depths
10-
#' @param bthD a numeric vector of depths (m) which correspond to areal measures in bthA
3+
#' @description Calculates volumetrically weighted average epilimnetic temperature using the
4+
#' supplied water temperature timeseries. If the lake is not stratified, the
5+
#' bottom of the epilimnion is calculated as the full depth of the lake.
116
#'
127
#'
13-
#' @seealso \code{\link{hypo.temperature}}, \code{\link{whole.lake.temperature}}
14-
#'
8+
#' @param wtr a numeric vector of water temperature in degrees C.
9+
#' @param depths a numeric vector corresponding to the depths (in m) of the wtr
10+
#' measurements
11+
#' @param bthA a numeric vector of cross sectional areas (m^2) corresponding to
12+
#' bthD depths
13+
#' @param bthD a numeric vector of depths (m) which correspond to areal
14+
#' measures in bthA
15+
#' @seealso \code{\link{hypo.temperature}} \code{\link{whole.lake.temperature}}
1516
#' @export
1617
epi.temperature <- function(wtr, depths, bthA, bthD){
1718

0 commit comments

Comments
 (0)