Skip to content

Commit

Permalink
Merge pull request #19 from jmzobitz/fix/invalid-html5
Browse files Browse the repository at this point in the history
Fix/invalid html5
  • Loading branch information
jmzobitz committed May 23, 2024
2 parents f26f1d0 + bbf3a23 commit b2743a1
Show file tree
Hide file tree
Showing 27 changed files with 259 additions and 153 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
^LICENSE\.md$
^swc-corrections$
^data-raw$
^\.github$
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
42 changes: 42 additions & 0 deletions .github/workflows/R-CMD-check-HTML5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
pull_request:
branches: [main, master]

name: R-CMD-check-HTML5

jobs:
R-CMD-check:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes
_R_CHECK_RD_VALIDATE_RD2HTML_: TRUE
steps:
- uses: actions/checkout@v2

- name: Install pdflatex
run: sudo apt-get install texlive-latex-base texlive-fonts-recommended texlive-fonts-extra texlive-latex-extra

- name: Install tidy
run: sudo apt install tidy

- uses: r-lib/actions/setup-r@v2
with:
r-version: 'devel'
http-user-agent: 'release'
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
args: '"--as-cran"'
build_args: 'character()'
error-on: '"note"'
21 changes: 12 additions & 9 deletions R/acquire_neon_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@
#' @export


# changelog and author contributions / copyrights
# John Zobitz (2021-07-22)
# original creation
# update to fix auto download (2021-07-25)
# 2022-06-10: update to correct flags on swc
# 2024-04-08: update to get namespaces correct
# 2024-04-10: update to get the swc depths corrected
# 2024-04-23: update to allow provisional data
# 2024-05-23: update to prepare for CRAN submission


acquire_neon_data <- function(site_name,
download_date,
time_frequency = "30_minute",
provisional = FALSE) {


# changelog and author contributions / copyrights
# John Zobitz (2021-07-22)
# original creation
# update to fix auto download (2021-07-25)
# 2022-06-10: update to correct flags on swc
# 2024-04-08: update to get namespaces correct
# 2024-04-10: update to get the swc depths corrected
# 2024-04-23: update to allow provisional data
# 2024-05-23: update to prepare for CRAN submission

.data = NULL # Appease R CMD Check

# Define the columns that we are plucking from each dataset:
Expand Down
10 changes: 6 additions & 4 deletions R/check_qf_flags.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
#'
#' @return A data frame of startDateTime, horizontalPosition, and the associated QF flag.

#'
#' # changelog and author contributions / copyrights
# John Zobitz (2024-05-08)
# original creation



check_qf_flags <- function(measurement_name,data) {

#'
#' # changelog and author contributions / copyrights
# John Zobitz (2024-05-08)
# original creation

.data = NULL # Appease R CMD Check
## Function takes data and the measurement, checks to see if there are more than 2 measurements for swc, temperature, and co2 at a given spatial location and time.
## For atmospheric pressure, just checks to see if we have a measurement
Expand Down
16 changes: 10 additions & 6 deletions R/co2_to_umol.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@

#' @export

# changelog and author contributions / copyrights
# John Zobitz (2021-07-21)
# original creation
# 2023-07-18: Included experimental uncertainty in the mix.
# 2024-04-08: update to get namespaces correct
# 2024-04-15: update to fix error in calculation of partial derivative of pressure (from Yang song)



co2_to_umol <- function(temperature, pressure, co2, temperature_err, pressure_err, co2_err, zOffset) {

# changelog and author contributions / copyrights
# John Zobitz (2021-07-21)
# original creation
# 2023-07-18: Included experimental uncertainty in the mix.
# 2024-04-08: update to get namespaces correct
# 2024-04-15: update to fix error in calculation of partial derivative of pressure (from Yang song)


# Since pressure is a single value, make it equal to all the other lengths
pressure <- rep(pressure, length(temperature))
pressure_err <- rep(pressure_err, length(temperature_err))
Expand Down
17 changes: 9 additions & 8 deletions R/compute_monthly_mean.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,20 @@

#' @export

# changelog and author contributions / copyrights
# Zoey Werbin (@zoey-rw): original author https://github.com/zoey-rw/microbialForecasts/blob/caa7b1a8aa8a131a5ff9340f1562cd3a3cb6667b/data_construction/covariate_prep/soil_moisture/clean_NEON_sensor_moisture_data.r
# John Zobitz (2024-01-17)
# modified to also compute the depth (zOffset) from the max of all zOffsets that month
# John Zobitz (2024-01-10)
# original creation
# 2024-04-08: update to get namespaces correct

#' @references
#' Zoey Werbin (@zoey-rw): original author https://github.com/zoey-rw/microbialForecasts/blob/caa7b1a8aa8a131a5ff9340f1562cd3a3cb6667b/data_construction/covariate_prep/soil_moisture/clean_NEON_sensor_moisture_data.r

compute_monthly_mean <- function(NEON_data, position_columns = c("horizontalPosition", "verticalPosition")) {

# changelog and author contributions / copyrights
# Zoey Werbin (@zoey-rw): original author https://github.com/zoey-rw/microbialForecasts/blob/caa7b1a8aa8a131a5ff9340f1562cd3a3cb6667b/data_construction/covariate_prep/soil_moisture/clean_NEON_sensor_moisture_data.r
# John Zobitz (2024-01-17)
# modified to also compute the depth (zOffset) from the max of all zOffsets that month
# John Zobitz (2024-01-10)
# original creation
# 2024-04-08: update to get namespaces correct


.data = NULL # Appease R CMD Check

out_mean <- NEON_data |>
Expand Down
27 changes: 15 additions & 12 deletions R/compute_neon_flux.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,19 @@
#' @param input_site_megapit Required. Input list of environmental soil data. Usually given from acquire_neon_data
#'
#' @examples
#'
#' \donttest{
#' # First acquire the NEON data at a given NEON site
#' out_env_data <- acquire_neon_data("SJER","2020-05")
#'
#' # Then process and compute the fluxes:
#' out_flux <- compute_neon_flux(out_env_data$site_data,out_env_data$site_megapit)
#'
#' out_flux <- compute_neon_flux(input_site_env = sjer_env_data_2022_06,
#' input_site_megapit = sjer_megapit_data_2022_06)
#' }
#' @return Data frame of fluxes and gradient from the timeperiod


#' @export
#'
# changelog and author contributions / copyrights
# John Zobitz (2021-07-22)
# original creation
# 2023-07-16: Update to take advantage of nested structures to improve / decrease computational time, allowing for multiple measurements to compute the flux.
# 2023-10-23: Update to exit computing a flux if there are no half-hourly measurements.
# 2024-04-08: update to get namespaces correct






Expand All @@ -47,6 +39,17 @@ compute_neon_flux <- function(input_site_env,
.data = NULL # Appease R CMD Check


# changelog and author contributions / copyrights
# John Zobitz (2021-07-22)
# original creation
# 2023-07-16: Update to take advantage of nested structures to improve / decrease computational time, allowing for multiple measurements to compute the flux.
# 2023-10-23: Update to exit computing a flux if there are no half-hourly measurements.
# 2024-04-08: update to get namespaces correct





################
# 1) Load up the data (this may take a while) Will be two data frames:
# site_megapit: a nested file containing specific information about the site (for bulk density calculations, etc)
Expand Down
26 changes: 15 additions & 11 deletions R/compute_surface_flux.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@

#' @return A value of the surface CO2 flux (umol m-2 s-1)

# changelog and author contributions / copyrights
# John Zobitz (2021-07-21)
# original creation
# John Zobitz (2022-06-21)
# revision to account for correct directionality when computing fluxes
# John Zobitz (2023-07-14)
# revision to include value of gradient at surface and computation of quadrature errors
# John Zobitz (2024-01-20)
# revision to simplify code - fluxes are calculated via different approaches with the measurements


compute_surface_flux <- function(input_data) {
.data = NULL # Appease R CMD Check

# changelog and author contributions / copyrights
# John Zobitz (2021-07-21)
# original creation
# John Zobitz (2022-06-21)
# revision to account for correct directionality when computing fluxes
# John Zobitz (2023-07-14)
# revision to include value of gradient at surface and computation of quadrature errors
# John Zobitz (2024-01-20)
# revision to simplify code - fluxes are calculated via different approaches with the measurements




.data = NULL # Appease R CMD Check

# Compute the flux between the two different layers

Expand Down
10 changes: 7 additions & 3 deletions R/correct_env_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,25 @@
#' @param input_data Required. Nested data frame from acquire_neon_data.
#'
#' @examples
#' \donttest{
#' # Note: you may need to first aqcuire the NEON data using acquire_neon_data
#' # Now correct existing environmental data:
#' corrected_data <- correct_env_data(sjer_env_data_2022_06)
#' }



#' @return List of all QF flags over time period and Data frame of environmental measurements for flux computation

# changelog and author contributions / copyrights
# John Zobitz (2024-05-07)
# original creation


correct_env_data <- function(input_data) {

# changelog and author contributions / copyrights
# John Zobitz (2024-05-07)
# original creation


.data = NULL # Appease R CMD Check
################

Expand Down
13 changes: 8 additions & 5 deletions R/dejong_shappert_flux.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,17 @@
#'
#' Maier, M., and H. Schack-Kirchner. 2014. “Using the Gradient Method to Determine Soil Gas Flux: A Review.” Agricultural and Forest Meteorology 192–193 (July):78–95. https://doi.org/10.1016/j.agrformet.2014.03.006.

# changelog and author contributions / copyrights
# John Zobitz (2023-01-20)
# original creation
# 2024-04-08: update to get namespaces correct


dejong_shappert_flux <- function(zOffset, co2, co2_err, diffusive, diffusive_err) {
# Define the output vector:

# changelog and author contributions / copyrights
# John Zobitz (2023-01-20)
# original creation
# 2024-04-08: update to get namespaces correct


# Define the output vector:
out_flux <- tibble::tibble(flux = NA, flux_err = NA, method = "dejong_shappert_1972")

if (any(is.na(co2)) | any(is.na(co2_err)) | any(is.na(diffusive)) | any(is.na(diffusive_err))) {
Expand Down
23 changes: 13 additions & 10 deletions R/depth_interpolate.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,24 @@
#' @return A nested data frame with interpolated measurements.


# changelog and author contributions / copyrights
# John Zobitz (2021-07-20)
# original creation
# 2022-06-06: Modification of the interpolation to accelerate computation
# 2022-06-11: Modification to improve fitting
# 2023-07-14: Extensive modification to improve interpolation of multiple columns of data.
# This now includes all the input data, but only interpolates measurements
# 2024-04-08: update to get namespaces correct
##############################################################################################


depth_interpolate <- function(input_measurements,
measurement_name,
measurement_interpolate) {



# changelog and author contributions / copyrights
# John Zobitz (2021-07-20)
# original creation
# 2022-06-06: Modification of the interpolation to accelerate computation
# 2022-06-11: Modification to improve fitting
# 2023-07-14: Extensive modification to improve interpolation of multiple columns of data.
# This now includes all the input data, but only interpolates measurements
# 2024-04-08: update to get namespaces correct
##############################################################################################


.data = NULL # Appease R CMD Check

# Get out the depths to which we will interpolate, make it into a nested data frame
Expand Down
11 changes: 7 additions & 4 deletions R/determine_position.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@


#' @return A data frame that reports the measurement depth for and associated environmental measurement.
# changelog and author contributions / copyrights
# John Zobitz (2024-01-17)
# original creation



determine_position <- function(input_positions, input_measurement) {

# changelog and author contributions / copyrights
# John Zobitz (2024-01-17)
# original creation



.data = NULL # Appease R CMD Check

# Define %within% so we can use here
Expand Down
16 changes: 10 additions & 6 deletions R/diffusivity.R
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,18 @@

#' @export

# changelog and author contributions / copyrights
# John Zobitz (2021-07-21)
# original creation
# John Zobitz (2024-01-20)
# modified to account if soil water > porosity - just set to 0


diffusivity <- function(temperature, soil_water, pressure, temperature_err, soil_water_err, pressure_err, zOffset, porVol2To20) {

# changelog and author contributions / copyrights
# John Zobitz (2021-07-21)
# original creation
# John Zobitz (2024-01-20)
# modified to account if soil water > porosity - just set to 0




# Since pressure is a single value, make it equal to all the other lengths
pressure <- rep(pressure, length(temperature))
pressure_err <- rep(pressure_err, length(temperature_err))
Expand Down
Loading

0 comments on commit b2743a1

Please sign in to comment.