Skip to content

Commit 7a10787

Browse files
committed
Merge changes
Merge branch 'master' of https://github.com/SPATIAL-Lab/isoWater # Conflicts: # DESCRIPTION # NEWS.md # R/watercomp.R
2 parents 451f01e + e6d5235 commit 7a10787

File tree

18 files changed

+162
-18
lines changed

18 files changed

+162
-18
lines changed

CRAN-RELEASE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This package was submitted to CRAN on 2021-06-09.
2+
Once it is accepted, delete this file and tag the release (commit c39aa1c).

DESCRIPTION

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,8 @@ VignetteBuilder: knitr
2525
License: GPL-3
2626
Language: en-US
2727
Encoding: UTF-8
28+
<<<<<<< HEAD
29+
=======
30+
RoxygenNote: 7.1.1
31+
LazyData: true
32+
>>>>>>> e6d52351033c444a64b33464ce03712ac211b21f

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export(iso)
55
export(wiDB_sites)
66
export(wiDB_data)
77
export(wiDB_values)
8+
export(dex)
89
importFrom(httr, GET, content, user_agent)
910
importFrom(jsonlite, fromJSON)
1011
importFrom(doParallel, registerDoParallel, stopImplicitCluster)
@@ -14,4 +15,4 @@ importFrom(R2WinBUGS, monitor)
1415
importFrom(stats, sd, var)
1516
importFrom(graphics, abline, lines, par, points)
1617
importFrom(abind, abind)
17-
importFrom(utils, read.csv, unzip)
18+
importFrom(utils, read.csv, unzip, data)

NEWS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
# isoWater news
22

33
## isoWater 1.0.1.9000
4+
<<<<<<< HEAD
45
* iso function now checks for and removes data with missing values
56
* Bug fixes
7+
=======
8+
* Add dex function
9+
* Bug and spelling fixes
10+
>>>>>>> e6d52351033c444a64b33464ce03712ac211b21f
611
712
## isoWater 1.0.1
813
* Bug fixes

R/constructors.R

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,41 @@ mwl = function(HO, plot = TRUE){
7373
class(mwl) = "mwl"
7474
return(mwl)
7575
}
76+
77+
#####
78+
#--- deuterium excess ----
79+
#calculate dex for one or more samples
80+
#####
81+
82+
dex = function(HO, form = "dex", MWL = NULL){
83+
if(!inherits(HO, "data.frame")){
84+
stop("HO must be a data.frame")
85+
}
86+
if(!is.numeric(HO[,1]) | !is.numeric(HO[,2])){
87+
stop("Non-numeric values in HO")
88+
}
89+
90+
if(is.null(MWL)){
91+
data("GMWL", envir = environment())
92+
GMWL = GMWL
93+
MWL = GMWL
94+
}
95+
96+
if(!is.numeric(MWL) | length(MWL) < 2){
97+
stop("MWL must be mwl object or numeric vector with slope, intercept")
98+
}
99+
100+
if(!(form %in% c("dex", "lcex", "both"))){
101+
stop("form must be dex, lcex, or both")
102+
}
103+
104+
if(form %in% c("dex", "both")){
105+
HO$dex = HO[,1] - 8 * HO[,2]
106+
}
107+
108+
if(form %in% c("lcex", "both")){
109+
HO$lcex = HO[,1] - MWL[1] * HO[,2] - MWL[2]
110+
}
111+
112+
return(HO)
113+
}

R/watercomp.R

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@
44

55
#takes values of observed water (type 'iso'), MWL (see below), hypothesized EL slope value
66
#and number of parameter draws
7-
mwlSource = function(obs, MWL=c(8.01, 9.57, -8.096, 2564532.2, 5.76, 80672),
8-
slope, stype = 1, ngens=1e4, ncores = 1){
7+
mwlSource = function(obs, MWL = NULL, slope, stype = 1, ngens=1e4, ncores = 1){
98

9+
if(is.null(MWL)){
10+
data("GMWL", envir = environment())
11+
GMWL = GMWL
12+
MWL = GMWL
13+
}
14+
1015
if(MWL[6] == 80672 & stype == 2){
1116
warning("Using stype=2 and GMWL is inappropriate for most applications; see man")
1217
}
18+
<<<<<<< HEAD
1319
if(!(inherits(obs, "iso"))){
20+
=======
21+
22+
if(!inherits(obs, "iso")){
23+
>>>>>>> e6d52351033c444a64b33464ce03712ac211b21f
1424
warning("Expecting iso object for obs, this argument may be formatted incorrectly")
1525
}
1626
if(!(stype %in% c(1, 2))){
@@ -100,8 +110,14 @@ mwlSource = function(obs, MWL=c(8.01, 9.57, -8.096, 2564532.2, 5.76, 80672),
100110
mixSource = function(obs, sources, slope, prior=rep(1,nrow(sources)),
101111
shp=1, ngens=1e5, ncores = 1){
102112

113+
<<<<<<< HEAD
103114
if(!(inherits(obs, "iso"))){
104115
warning("Expecting iso object for obs, this argument may be formatted incorrectly")
116+
=======
117+
if(!inherits(obs, "iso")){
118+
warning("Expecting iso object for obs, this argument may be
119+
formatted incorrectly")
120+
>>>>>>> e6d52351033c444a64b33464ce03712ac211b21f
105121
}
106122

107123
#get number of observations
@@ -116,7 +132,7 @@ mixSource = function(obs, sources, slope, prior=rep(1,nrow(sources)),
116132
obs.vcov[2 + (i - 1) * 2, 2] = obs[i, 4] ^ 2
117133
}
118134

119-
if(length(class(sources)) < 2 | class(sources)[2] != "iso"){
135+
if(!inherits(sources, "iso")){
120136
warning("Expecting iso object for sources, this argument may be
121137
formatted incorrectly")
122138
}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ Putman, A. L., & Bowen, G. J. (2019) A global database of the stable isotopic ra
1616

1717
<!-- badges: start -->
1818
[![Build status](https://github.com/SPATIAL-Lab/isoWater/actions/workflows/r.yml/badge.svg)](https://github.com/SPATIAL-Lab/isoWater/actions)
19-
[![codecov](https://codecov.io/gh/SPATIAL-Lab/isoWater/branch/master/graph/badge.svg)](https://codecov.io/gh/SPATIAL-Lab/isoWater)
19+
[![codecov](https://codecov.io/gh/SPATIAL-Lab/isoWater/branch/master/graph/badge.svg)](https://app.codecov.io/gh/SPATIAL-Lab/isoWater)
2020
<!-- badges: end -->

data-raw/prepData.R

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,6 @@ mixModel = "model{
5353
}"
5454

5555
use_data(mwlModel, mixModel, internal = TRUE, overwrite = TRUE)
56+
57+
GMWL = c(8.01, 9.57, -8.096, 2564532.2, 5.76, 80672)
58+
use_data(GMWL, overwrite = TRUE)

data/GMWL.rda

138 Bytes
Binary file not shown.

man/GMWL.Rd

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
\name{GMWL}
2+
\alias{GMWL}
3+
\docType{data}
4+
\title{
5+
Global Meteoric Water Line
6+
}
7+
\description{
8+
Parameters for the Global Meteoric Water Line fit to a global precipitation compilation in Bowen, et al. (2019).
9+
}
10+
\usage{data("GMWL")}
11+
\format{
12+
The format is:
13+
num [1:6] slope, intercept, average d18O, sum of squares in d18O, root mean square error, number of samples
14+
}
15+
\source{
16+
Bowen et al. (2019) Isotopes in the water cycle: Regional- to global-Scale patterns and applications. \emph{Annual Review of Earth and Planetary Sciences} \strong{47} 453--479. \doi{10.1146/annurev-earth-053018-060220}.
17+
}
18+
\examples{
19+
data(GMWL)
20+
}
21+
\keyword{datasets}

0 commit comments

Comments
 (0)