diff --git a/DESCRIPTION b/DESCRIPTION index d82e23a..40b761b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -23,7 +23,7 @@ URL: https://github.com/lanl/NEONiso, https://lanl.github.io/NEONiso/ Encoding: UTF-8 LazyData: true -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Imports: dplyr, zoo, diff --git a/NEONiso.Rproj b/NEONiso.Rproj index 8a36a70..a819e10 100644 --- a/NEONiso.Rproj +++ b/NEONiso.Rproj @@ -1,4 +1,5 @@ Version: 1.0 +ProjectId: 66dd6b57-a079-4675-8584-64aae38613ba RestoreWorkspace: No SaveWorkspace: No diff --git a/NEWS.md b/NEWS.md index 2105977..a00ce0a 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,4 +1,13 @@ -# NEONiso 0.7.0.9000 +# NEONiso 0.7.1 + +* Substantial upgrades to package documentation. +* The name "Bowling_2003" in methods and functions has been deprecated in +favor of "gainoffset." This change was made primarily to improve clarity of +what the methods actually do. Code that uses the old "Bowling_2003" nomenclature +will continue to work until at least version 0.8.0, but will issue a deprecation +warning. + +# NEONiso 0.7.0 * calibrate_carbon_bymonth and calibrate_water_bymonth have been removed. Use calibrate_carbon and calibrate_water instead. diff --git a/R/calibrate_ambient_carbon_Bowling2003.R b/R/calibrate_ambient_carbon_gainoffset.R similarity index 96% rename from R/calibrate_ambient_carbon_Bowling2003.R rename to R/calibrate_ambient_carbon_gainoffset.R index 38dfa30..49c3ee9 100644 --- a/R/calibrate_ambient_carbon_Bowling2003.R +++ b/R/calibrate_ambient_carbon_gainoffset.R @@ -1,3 +1,9 @@ +calibrate_ambient_carbon_Bowling2003 <- function(...) { + lifecycle::deprecate_soft("0.7.1","calibrate_ambient_carbon_Bowling2003()", + "calibrate_ambient_carbon_gainoffset()") + calibrate_ambient_carbon_gainoffset(...) +} + #' Calibrate ambient carbon isotope data using gain-and-offset method #' #' @author Rich Fiorella \email{rfiorella@@lanl.gov} @@ -14,8 +20,7 @@ #' 12C and 13C isotopologues. #' @param site Four-letter NEON code corresponding to site being processed. #' @param filter_data Apply median absolute deviation filter from Brock 86 to -#' remove impulse spikes? Inherited from -#' `calibrate_ambient_carbon_Bowling2003()` +#' remove impulse spikes? #' @param force_to_end In given month, calibrate ambient data later than last #' calibration, using the last calibration? (default true) #' @param force_to_beginning In given month, calibrate ambient data before than @@ -38,7 +43,7 @@ #' @importFrom magrittr %>% #' @importFrom lubridate %within% #' -calibrate_ambient_carbon_Bowling2003 <- function(amb_data_list, +calibrate_ambient_carbon_gainoffset <- function(amb_data_list, caldf, site, filter_data = TRUE, diff --git a/R/calibrate_carbon.R b/R/calibrate_carbon.R index 0a3415b..6adeeb5 100644 --- a/R/calibrate_carbon.R +++ b/R/calibrate_carbon.R @@ -147,6 +147,11 @@ calibrate_carbon <- function(inname, inname <- inname[!grepl("2019-07", inname)] } } + + if (method == "Bowling_2003") { + lifecycle::deprecate_warn("0.7.1","calibrate_carbon(method = 'Bowling_2003')", + "calibrate_carbon(method = 'gainoffset')") + } #----------------------------------------------------------- # Extract reference data from input HDF5 file. @@ -194,18 +199,18 @@ calibrate_carbon <- function(inname, ciso_subset <- c(ciso$ambient, ciso$reference) - if (method == "Bowling_2003") { + if (method == "gainoffset" | method == "Bowling_2003") { ciso_subset_cal <- lapply(names(ciso_subset), function(x) { - calibrate_ambient_carbon_Bowling2003(amb_data_list = ciso_subset[[x]], - caldf = cal_df, - site = site, - filter_data = filter_ambient, - force_to_end = force_cal_to_end, - force_to_beginning = force_cal_to_beginning, - r2_thres = r2_thres) + calibrate_ambient_carbon_gainoffset(amb_data_list = ciso_subset[[x]], + caldf = cal_df, + site = site, + filter_data = filter_ambient, + force_to_end = force_cal_to_end, + force_to_beginning = force_cal_to_beginning, + r2_thres = r2_thres) }) } else if (method == "linreg") { diff --git a/R/reference_data_regression.R b/R/reference_data_regression.R index 2876f60..b9278e8 100644 --- a/R/reference_data_regression.R +++ b/R/reference_data_regression.R @@ -59,7 +59,7 @@ estimate_calibration_error <- function(formula, data) { #' to define a peak. #' #' @return Returns a data.frame of calibration parameters. If -#' `method == "Bowling_2003"`, then data.frame includes +#' `method == "gainoffset"`, then data.frame includes #' gain and offset parameters for 12CO2 and 13CO2, and r^2 #' values for each regression. If `method == "linreg"`, #' then data.frame includes slope, intercept, and r^2 values @@ -87,7 +87,7 @@ fit_carbon_regression <- function(ref_data, method, calibration_half_width, analyte = "co2", min_nobs = min_nobs) - if (method == "Bowling_2003") { + if (method == "gainoffset" | method == "Bowling_2003") { # calculate mole fraction (12CO2 / 13CO2) for ref gases and observed values ref_data$conc12CCO2_ref <- calculate_12CO2(ref_data$rtioMoleDryCo2Refe.mean, diff --git a/man/calibrate_ambient_carbon_Bowling2003.Rd b/man/calibrate_ambient_carbon_gainoffset.Rd similarity index 87% rename from man/calibrate_ambient_carbon_Bowling2003.Rd rename to man/calibrate_ambient_carbon_gainoffset.Rd index e172694..fea91c9 100644 --- a/man/calibrate_ambient_carbon_Bowling2003.Rd +++ b/man/calibrate_ambient_carbon_gainoffset.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/calibrate_ambient_carbon_Bowling2003.R -\name{calibrate_ambient_carbon_Bowling2003} -\alias{calibrate_ambient_carbon_Bowling2003} +% Please edit documentation in R/calibrate_ambient_carbon_gainoffset.R +\name{calibrate_ambient_carbon_gainoffset} +\alias{calibrate_ambient_carbon_gainoffset} \title{Calibrate ambient carbon isotope data using gain-and-offset method} \usage{ -calibrate_ambient_carbon_Bowling2003( +calibrate_ambient_carbon_gainoffset( amb_data_list, caldf, site, @@ -25,8 +25,7 @@ Will include all variables in 000_0x0_xxm. (character)} \item{site}{Four-letter NEON code corresponding to site being processed.} \item{filter_data}{Apply median absolute deviation filter from Brock 86 to -remove impulse spikes? Inherited from -\code{calibrate_ambient_carbon_Bowling2003()}} +remove impulse spikes?} \item{force_to_end}{In given month, calibrate ambient data later than last calibration, using the last calibration? (default true)} diff --git a/man/fit_carbon_regression.Rd b/man/fit_carbon_regression.Rd index 1ab9aaf..ac81107 100644 --- a/man/fit_carbon_regression.Rd +++ b/man/fit_carbon_regression.Rd @@ -39,7 +39,7 @@ to define a peak.} } \value{ Returns a data.frame of calibration parameters. If -\code{method == "Bowling_2003"}, then data.frame includes +\code{method == "gainoffset"}, then data.frame includes gain and offset parameters for 12CO2 and 13CO2, and r^2 values for each regression. If \code{method == "linreg"}, then data.frame includes slope, intercept, and r^2 values diff --git a/tests/testthat/test-data_regression.R b/tests/testthat/test-data_regression.R index 21f3158..4681e23 100644 --- a/tests/testthat/test-data_regression.R +++ b/tests/testthat/test-data_regression.R @@ -59,13 +59,13 @@ test_that("carbon calibration data frames correct even when no input data", { # work through ambient calibrations # test carbon - bowling ambient calibration -temp <- calibrate_ambient_carbon_Bowling2003(co2test$ambient$`000_010_09m`, - caldf_b03, - site = "ONAQ") -temp_gf <- calibrate_ambient_carbon_Bowling2003(co2test$ambient$`000_010_09m`, - caldf_b03, - site = "ONAQ", - gap_fill_parameters = TRUE) +temp <- calibrate_ambient_carbon_gainoffset(co2test$ambient$`000_010_09m`, + caldf_b03, + site = "ONAQ") +temp_gf <- calibrate_ambient_carbon_gainoffset(co2test$ambient$`000_010_09m`, + caldf_b03, + site = "ONAQ", + gap_fill_parameters = TRUE) test_that("calibrate_ambient_carbon_Bowling2003 returns a list",{ skip_on_cran() diff --git a/tests/testthat/test-high_level_functions.R b/tests/testthat/test-high_level_functions.R index 61bbba2..e90647a 100644 --- a/tests/testthat/test-high_level_functions.R +++ b/tests/testthat/test-high_level_functions.R @@ -20,16 +20,27 @@ test_that("calibrate_carbon returns no error", { skip_on_cran() # these tests could probably be made more useful!! + expect_warning(calibrate_carbon(fin, fout1, "ONAQ", + method = "Bowling_2003", + calibration_half_width = 0.5, + force_cal_to_beginning = TRUE, + force_cal_to_end = TRUE, + gap_fill_parameters = FALSE, + filter_ambient = TRUE, + r2_thres = 0.95, + correct_ref_data = TRUE, + write_to_file = TRUE)) + expect_no_error(calibrate_carbon(fin, fout1, "ONAQ", - method = "Bowling_2003", - calibration_half_width = 0.5, - force_cal_to_beginning = TRUE, - force_cal_to_end = TRUE, - gap_fill_parameters = FALSE, - filter_ambient = TRUE, - r2_thres = 0.95, - correct_ref_data = TRUE, - write_to_file = TRUE)) + method = "gainoffset", + calibration_half_width = 0.5, + force_cal_to_beginning = TRUE, + force_cal_to_end = TRUE, + gap_fill_parameters = FALSE, + filter_ambient = TRUE, + r2_thres = 0.95, + correct_ref_data = TRUE, + write_to_file = TRUE)) expect_no_error(calibrate_carbon(fin, fout2, "ONAQ", method = "linreg", @@ -44,7 +55,7 @@ test_that("calibrate_carbon returns no error", { # these tests could probably be made more useful!! expect_no_error(calibrate_carbon(fin, "/dev/null", "ONAQ", - method = "Bowling_2003", + method = "gainoffset", calibration_half_width = 0.5, force_cal_to_beginning = TRUE, force_cal_to_end = TRUE, diff --git a/tests/testthat/test-output_values.R b/tests/testthat/test-output_values.R index 1e1a89b..bc7d9d4 100644 --- a/tests/testthat/test-output_values.R +++ b/tests/testthat/test-output_values.R @@ -24,13 +24,13 @@ ciso_subset <- co2test$ambient ciso_subset_cal <- lapply(names(ciso_subset), function(x) { - calibrate_ambient_carbon_Bowling2003(amb_data_list = ciso_subset[[x]], - caldf = caldf_b03, - site = "YELL", - filter_data = TRUE, - force_to_end = TRUE, - force_to_beginning = TRUE, - r2_thres = 0.9) + calibrate_ambient_carbon_gainoffset(amb_data_list = ciso_subset[[x]], + caldf = caldf_b03, + site = "YELL", + filter_data = TRUE, + force_to_end = TRUE, + force_to_beginning = TRUE, + r2_thres = 0.9) }) names(ciso_subset_cal) <- names(ciso_subset)