Skip to content

Commit

Permalink
continue updating documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
rfiorella committed Dec 24, 2024
1 parent 0811309 commit c98d7a8
Show file tree
Hide file tree
Showing 31 changed files with 229 additions and 317 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: NEONiso
Type: Package
Title: Tools to Calibrate and Work with NEON Atmospheric Isotope Data
Version: 0.7.0.9000
Version: 0.7.1.9000
Authors@R: c(person("Rich", "Fiorella", email = "[email protected]",
role = c("aut", "cre"), comment = c(ORCID = "0000-0002-0824-4777")))
Maintainer: Rich Fiorella <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion R/calibrate_ambient_carbon_Bowling2003.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#' @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
#' first calibration, using the first calibration? (default true)
#' first calibration, using the firs t calibration? (default true)
#' @param r2_thres Minimum r2 value for calibration to be considered "good" and
#' applied to ambient data.
#' @param gap_fill_parameters Should function attempt to 'gap-fill' across a
Expand Down
300 changes: 150 additions & 150 deletions R/excised.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,28 @@
#'
#' @return Nothing to the environment, but writes qfqm data to file.
#'
write_qfqm <- function(inname, outname, site, analyte) {

analyte <- validate_analyte(analyte)

print("Copying qfqm...")
# copy over ucrt and qfqm groups as well.
rhdf5::h5createGroup(outname, paste0("/", site, "/dp01/qfqm/"))
rhdf5::h5createGroup(outname, paste0("/", site, "/dp01/qfqm/iso", analyte))
qfqm <- rhdf5::h5read(inname, paste0("/", site, "/dp01/qfqm/iso", analyte))

lapply(names(qfqm),
function(x) {
copy_qfqm_group(data_list = qfqm[[x]],
outname = x,
file = outname,
site = site,
species = analyte)
})

rhdf5::h5closeAll()

}
# write_qfqm <- function(inname, outname, site, analyte) {
#
# analyte <- validate_analyte(analyte)
#
# print("Copying qfqm...")
# # copy over ucrt and qfqm groups as well.
# rhdf5::h5createGroup(outname, paste0("/", site, "/dp01/qfqm/"))
# rhdf5::h5createGroup(outname, paste0("/", site, "/dp01/qfqm/iso", analyte))
# qfqm <- rhdf5::h5read(inname, paste0("/", site, "/dp01/qfqm/iso", analyte))
#
# lapply(names(qfqm),
# function(x) {
# copy_qfqm_group(data_list = qfqm[[x]],
# outname = x,
# file = outname,
# site = site,
# species = analyte)
# })
#
# rhdf5::h5closeAll()
#
# }

#' write_ucrt
#'
Expand All @@ -51,28 +51,28 @@ write_qfqm <- function(inname, outname, site, analyte) {
#'
#' @return Nothing to the environment, but writes ucrt data to file.
#'
write_ucrt <- function(inname, outname, site, analyte) {

analyte <- validate_analyte(analyte)

print("Copying ucrt...")
# copy over ucrt and qfqm groups as well.
rhdf5::h5createGroup(outname, paste0("/", site, "/dp01/ucrt/"))
rhdf5::h5createGroup(outname, paste0("/", site, "/dp01/ucrt/iso", analyte))
ucrt <- rhdf5::h5read(inname, paste0("/", site, "/dp01/ucrt/iso", analyte))

lapply(names(ucrt),
function(x) {
copy_ucrt_group(data_list = ucrt[[x]],
outname = x,
file = outname,
site = site,
species = analyte)
})

rhdf5::h5closeAll()

}
# write_ucrt <- function(inname, outname, site, analyte) {
#
# analyte <- validate_analyte(analyte)
#
# print("Copying ucrt...")
# # copy over ucrt and qfqm groups as well.
# rhdf5::h5createGroup(outname, paste0("/", site, "/dp01/ucrt/"))
# rhdf5::h5createGroup(outname, paste0("/", site, "/dp01/ucrt/iso", analyte))
# ucrt <- rhdf5::h5read(inname, paste0("/", site, "/dp01/ucrt/iso", analyte))
#
# lapply(names(ucrt),
# function(x) {
# copy_ucrt_group(data_list = ucrt[[x]],
# outname = x,
# file = outname,
# site = site,
# species = analyte)
# })
#
# rhdf5::h5closeAll()
#
# }

#' copy_qfqm_group
#'
Expand All @@ -87,111 +87,111 @@ write_ucrt <- function(inname, outname, site, analyte) {
#' @return Nothing to the workspace, but copies qfqm group from input file to
#' output file.
#'
copy_qfqm_group <- function(data_list, outname, site, file, species) {

# create hdf5 structure for these variables.
fid <- rhdf5::H5Fopen(file)

if (species == "Co2") {
co2_data_outloc <- rhdf5::H5Gcreate(fid,
paste0("/",
site,
"/dp01/qfqm/isoCo2/",
outname))

# loop through each of the variables in list amb.data.list
# and write out as a dataframe.
lapply(names(data_list),
function(x) {
rhdf5::h5writeDataset(obj = data_list[[x]],
h5loc = co2_data_outloc,
name = x,
DataFrameAsCompound = TRUE)
})

} else if (species == "H2o") {

h2o_data_outloc <- rhdf5::H5Gcreate(fid,
paste0("/",
site,
"/dp01/qfqm/isoH2o/",
outname))

# loop through each of the variables in list amb.data.list
# and write out as a dataframe.
lapply(names(data_list),
function(x) {
rhdf5::h5writeDataset(obj = data_list[[x]],
h5loc = h2o_data_outloc,
name = x,
DataFrameAsCompound = TRUE)
})

}

# close all open handles.
rhdf5::h5closeAll()

}

#' copy_ucrt_group
#'
#' @author Rich Fiorella \email{rfiorella@@lanl.gov}
#'
#' @param outname Output file name.
#' @param site NEON 4-letter site code.
#' @param file Input file name.
#' @param data_list List of groups to retrieve ucrt data from.
#' @param species H2O or CO2.
#'
#' @return Nothing to the workspace, but copies ucrt group from input file to
#' output file.
#'
copy_ucrt_group <- function(data_list, outname, site, file, species) {

# create hdf5 structure for these variables.
fid <- rhdf5::H5Fopen(file)

if (species == "Co2") {

co2_data_outloc <- rhdf5::H5Gcreate(fid,
paste0("/",
site,
"/dp01/ucrt/isoCo2/",
outname))

# loop through each variable in amb.data.list and write out as a dataframe
lapply(names(data_list),
function(x) {
rhdf5::h5writeDataset(obj = data_list[[x]],
h5loc = co2_data_outloc,
name = x,
DataFrameAsCompound = TRUE)
})

} else if (species == "H2o") {

h2o_data_outloc <- rhdf5::H5Gcreate(fid,
paste0("/",
site,
"/dp01/ucrt/isoH2o/",
outname))

# loop through each variable in amb.data.list and write out as a dataframe.
lapply(names(data_list),
function(x) {
rhdf5::h5writeDataset(obj = data_list[[x]],
h5loc = h2o_data_outloc,
name = x,
DataFrameAsCompound = TRUE)
})


}

# close all open handles.
rhdf5::h5closeAll()

}
#' copy_qfqm_group <- function(data_list, outname, site, file, species) {
#'
#' # create hdf5 structure for these variables.
#' fid <- rhdf5::H5Fopen(file)
#'
#' if (species == "Co2") {
#' co2_data_outloc <- rhdf5::H5Gcreate(fid,
#' paste0("/",
#' site,
#' "/dp01/qfqm/isoCo2/",
#' outname))
#'
#' # loop through each of the variables in list amb.data.list
#' # and write out as a dataframe.
#' lapply(names(data_list),
#' function(x) {
#' rhdf5::h5writeDataset(obj = data_list[[x]],
#' h5loc = co2_data_outloc,
#' name = x,
#' DataFrameAsCompound = TRUE)
#' })
#'
#' } else if (species == "H2o") {
#'
#' h2o_data_outloc <- rhdf5::H5Gcreate(fid,
#' paste0("/",
#' site,
#' "/dp01/qfqm/isoH2o/",
#' outname))
#'
#' # loop through each of the variables in list amb.data.list
#' # and write out as a dataframe.
#' lapply(names(data_list),
#' function(x) {
#' rhdf5::h5writeDataset(obj = data_list[[x]],
#' h5loc = h2o_data_outloc,
#' name = x,
#' DataFrameAsCompound = TRUE)
#' })
#'
#' }
#'
#' # close all open handles.
#' rhdf5::h5closeAll()
#'
#' }
#'
#' #' copy_ucrt_group
#' #'
#' #' @author Rich Fiorella \email{rfiorella@@lanl.gov}
#' #'
#' #' @param outname Output file name.
#' #' @param site NEON 4-letter site code.
#' #' @param file Input file name.
#' #' @param data_list List of groups to retrieve ucrt data from.
#' #' @param species H2O or CO2.
#' #'
#' #' @return Nothing to the workspace, but copies ucrt group from input file to
#' #' output file.
#' #'
#' copy_ucrt_group <- function(data_list, outname, site, file, species) {
#'
#' # create hdf5 structure for these variables.
#' fid <- rhdf5::H5Fopen(file)
#'
#' if (species == "Co2") {
#'
#' co2_data_outloc <- rhdf5::H5Gcreate(fid,
#' paste0("/",
#' site,
#' "/dp01/ucrt/isoCo2/",
#' outname))
#'
#' # loop through each variable in amb.data.list and write out as a dataframe
#' lapply(names(data_list),
#' function(x) {
#' rhdf5::h5writeDataset(obj = data_list[[x]],
#' h5loc = co2_data_outloc,
#' name = x,
#' DataFrameAsCompound = TRUE)
#' })
#'
#' } else if (species == "H2o") {
#'
#' h2o_data_outloc <- rhdf5::H5Gcreate(fid,
#' paste0("/",
#' site,
#' "/dp01/ucrt/isoH2o/",
#' outname))
#'
#' # loop through each variable in amb.data.list and write out as a dataframe.
#' lapply(names(data_list),
#' function(x) {
#' rhdf5::h5writeDataset(obj = data_list[[x]],
#' h5loc = h2o_data_outloc,
#' name = x,
#' DataFrameAsCompound = TRUE)
#' })
#'
#'
#' }
#'
#' # close all open handles.
#' rhdf5::h5closeAll()
#'
#' }

# nocov end
14 changes: 8 additions & 6 deletions R/output_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#################################################
### FUNCTIONS THAT WORK FOR BOTH H2O AND CO2 ####
#################################################
#' setup_output_file
#' Structure a new HDF5 file
#'
#' Creates a skeleton hdf5 file for the calibrated data.
#' Creates a skeleton HDF5 file for the calibrated data,
#' essentially setting up the HDF5 groups at the /site/dp01/\{data,ucrt,qfqm\}
#' level.
#'
#' @author Rich Fiorella \email{rfiorella@@lanl.gov}
#'
Expand Down Expand Up @@ -56,7 +58,7 @@ setup_output_file <- function(inname, outname, site, analyte) {
#######################################
### FUNCTIONS THAT WORK ON ONLY CO2 ###
#######################################
#' write_carbon_calibration_data
#' Write carbon calibrations to file.
#'
#' @author Rich Fiorella \email{rfiorella@@lanl.gov}
#'
Expand Down Expand Up @@ -109,7 +111,7 @@ write_carbon_calibration_data <- function(outname,

}

#' write_carbon_ambient_data
#' Write calibrated carbon ambient data to file
#'
#' Write out ambient observations from the NEON EC
#' towers where the isotope data (either H2O or CO2)
Expand Down Expand Up @@ -169,7 +171,7 @@ write_carbon_ambient_data <- function(outname,
#######################################
### FUNCTIONS THAT WORK ON ONLY H2O ###
#######################################
#' write_water_calibration_data
#' Write carbon calibration parameters to file.
#'
#' @author Rich Fiorella \email{rfiorella@@lanl.gov}
#'
Expand Down Expand Up @@ -211,7 +213,7 @@ write_water_calibration_data <- function(outname, site, cal_df) {

}

#' write_water_ambient_data
#' Write calibrated ambient water isotope ratio observations to file.
#'
#' Write out ambient observations from the NEON EC
#' towers where the isotope data
Expand Down
5 changes: 4 additions & 1 deletion R/quality_control.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ validate_output_file <- function(inname, outname, site, analyte) {
#--------------------------------------------------------------------
# Diagnostic plots:::

#' carbon_regression_plots
#' Make plots of carbon calibration data for debugging
#'
#' Makes plots of carbon calibration data regressions, primarily for
#' debugging and validation purposes.
#'
#' @author Rich Fiorella \email{rfiorella@@lanl.gov}
#'
Expand Down
Loading

0 comments on commit c98d7a8

Please sign in to comment.