diff --git a/.github/.gitignore b/.github/.gitignore new file mode 100644 index 0000000..2d19fc7 --- /dev/null +++ b/.github/.gitignore @@ -0,0 +1 @@ +*.html diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml new file mode 100644 index 0000000..52b2c05 --- /dev/null +++ b/.github/workflows/R-CMD-check.yaml @@ -0,0 +1,45 @@ +# 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] + pull_request: + branches: [main] + +name: R-CMD-check + +jobs: + R-CMD-check: + runs-on: ${{ matrix.config.os }} + + name: ${{ matrix.config.os }} (${{ matrix.config.r }}) + + strategy: + fail-fast: false + matrix: + config: + - {os: windows-latest, r: 'release'} + + env: + GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes + + steps: + - uses: actions/checkout@v3 + + - uses: r-lib/actions/setup-pandoc@v2 + + - uses: r-lib/actions/setup-r@v2 + with: + r-version: ${{ matrix.config.r }} + http-user-agent: ${{ matrix.config.http-user-agent }} + 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: + upload-snapshots: true diff --git a/DESCRIPTION b/DESCRIPTION index 66ccd06..19d622b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -25,6 +25,7 @@ URL: https://github.com/afsc-gap-products/GAPsurvey Description: Provides at-sea data management tools for RACE GAP surveys. Encoding: UTF-8 LazyData: true +LazyDataCompression: xz Imports: stats, utils diff --git a/GAPsurvey.Rproj b/GAPsurvey.Rproj index 497f8bf..270314b 100644 --- a/GAPsurvey.Rproj +++ b/GAPsurvey.Rproj @@ -18,3 +18,4 @@ StripTrailingWhitespace: Yes BuildType: Package PackageUseDevtools: Yes PackageInstallArgs: --no-multiarch --with-keep.source +PackageRoxygenize: rd,collate,namespace diff --git a/NAMESPACE b/NAMESPACE index f13e80a..1cd051a 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,20 +3,10 @@ export(calc_net_spread) export(convert_bvdr_marp) export(convert_ctd_btd) -export(convert_do_to_o2sat) export(convert_log_gps) export(convert_ted_btd) -export(extract_calibration_xmlcon) export(fix_path) -export(get_calibration_parameter) export(get_catch_haul_history) export(get_sunrise_sunset) -export(hex_to_cnv) -export(integer_to_conductivity) -export(integer_to_ph) -export(integer_to_pressure) -export(integer_to_temperature) export(numbers0) -export(oxygen_saturation) -export(tau_par) export(text_list) diff --git a/R/hex_to_cnv.R b/R/hex_to_cnv.R index b371113..4dca4bd 100644 --- a/R/hex_to_cnv.R +++ b/R/hex_to_cnv.R @@ -218,7 +218,7 @@ calc_depth_from_pressure <- function(latitude, pressure, nsmall = 3) { #' @param sample_interval Sampling interval for scans; 0.25 for a typical SBE19plus V2 deployment. #' @param output_channels Optional. Named vector of output channels and their names. Do not use unless outputs are are not the defaults. #' @param output_sig_digits Optional. Significant digits after the decimal place for output channels. Only change if a subset of channels. Do not use unless outputs are are not the defaults. -#' @export +#' @noRd #' @author Sean Rohan hex_to_cnv <- function(hex_path, @@ -481,7 +481,7 @@ hex_to_cnv <- function(hex_path, #' @param par3 Temperature calibration parameter par3 #' @param par4 Temperature calibration parameter par4 #' @param par5 Temperature calibration parameter par5 -#' @export +#' @noRd #' @author Sean Rohan integer_to_temperature <- function(temperature_integer, @@ -536,7 +536,7 @@ integer_to_temperature <- function(temperature_integer, #' @param par0 tvoltage_integer conversion constant #' @param sig_figs number of significant digits to use for temperature (default = 3) #' @param convert_to_dbar Should pressure be returned in or decibars (TRUE) or pounds per square inch without offset (FALSE) -#' @export +#' @noRd #' @author Sean Rohan integer_to_pressure <- function(pressure_integer, @@ -598,7 +598,7 @@ integer_to_pressure <- function(pressure_integer, #' @param par0 Constant to convert integer to voltage #' @param par1 Constant to convert integer to voltage #' @param sig_figs number of significant digits to use for conductivity (default = 6) -#' @export +#' @noRd #' @author Sean Rohan integer_to_conductivity <- function(conductivity_integer, temperature, pressure, condg, condh, condi, condj, cpcor, ctcor, par0 = 256, par1 = 1000, sig_figs = 6) { @@ -623,7 +623,7 @@ integer_to_conductivity <- function(conductivity_integer, temperature, pressure, #' @param temperature temperature in degrees C #' @param sig_figs number of significant digits to use for conductivity (default = 3) #' @param par0 ph_integer conversion constant -#' @export +#' @noRd #' @author Sean Rohan integer_to_ph <- function(ph_integer, ph_offset, ph_slope, temperature, sig_figs = 3, par0 = 13107) { @@ -649,7 +649,7 @@ integer_to_ph <- function(ph_integer, ph_offset, ph_slope, temperature, sig_figs #' #' @param temperature Temperature (degrees Celsius). #' @param salinity Salinity (PSU, PSS-78). -#' @export +#' @noRd #' @references Garcia, H.E., Gordon, L.I., 1992. Oxygen solubility in seawater: Better fitting equations. Limnol. Oceanogr. 37, 1307–1312. https://doi.org/10.4319/lo.1992.37.6.1307 #' @author Sean Rohan @@ -689,7 +689,7 @@ oxygen_saturation <- function(temperature, salinity) { #' @param oxygen Dissolved oxygen in ml/l #' @param temperature Temperature (IPTS-68, degrees Celsius). #' @param salinity Salinity (PSU, PSS-78). -#' @export +#' @noRd #' @references Garcia, H.E., Gordon, L.I., 1992. Oxygen solubility in seawater: Better fitting equations. Limnol. Oceanogr. 37, 1307–1312. https://doi.org/10.4319/lo.1992.37.6.1307 #' @author Sean Rohan @@ -755,7 +755,7 @@ integer_to_dissolved_oxygen <- function(do_integer, dVdt <- c(0, diff(do_voltage)/sample_interval) if(tau_correction) { - tau <- DO_tau_correction(temperature, pressure, tau20, d0, d1, d2) + tau <- tau_par(temperature, pressure, tau20, d0, d1, d2) } temperature_K <- temperature + 273.15 @@ -781,7 +781,7 @@ integer_to_dissolved_oxygen <- function(do_integer, #' @param d1 Tau correction calibration parameter D1. #' @param d2 Tau correction calibration parameter D2. #' @param tau20 Tau correction calibration parameter Tau20. -#' @export +#' @noRd #' @references Edwards, B., Murphy, D., Janzen, C., Larson, A.N., 2010. Calibration, response, and hysteresis in deep-sea dissolved oxygen measurements. J. Atmos. Ocean. Technol. 27, 920–931. https://doi.org/10.1175/2009JTECHO693.1 #' @author Sean Rohan @@ -810,7 +810,7 @@ integer_to_ox_voltage <- function(ox_integer) { #' @param start_block starting index for lines of the header to search #' @param end_block ending index for lines of the leader to search #' @param make_numeric Logical. Should the tag value be forced to a numeric? -#' @export +#' @noRd #' @author Sean Rohan get_calibration_parameter <- function(header, cal_par, start_block = NULL, end_block = NULL, make_numeric = TRUE) { @@ -881,7 +881,7 @@ write_to_cnv <- function(data_list, output_path) { " [Instrument's time stamp, header]")) out <- c(out, paste0("# bad_flag = -9.990e-29")) out <- c(out, paste0("# gapctd_date = ", format(Sys.time(), "%b %d %Y %T"), - ", gapctd ", gsub(pattern = "'", replacement = "", x = packageVersion("gapctd")))) + ", GAPSurvey ", gsub(pattern = "[^0-9.-]", "", packageVersion("GAPSurvey")))) out <- c(out, paste0("# gapctd_in = ", dl$hex_path)) out <- c(out, paste0("# file_type = ascii")) out <- c(out, "*END*") @@ -913,7 +913,7 @@ write_to_cnv <- function(data_list, output_path) { #' Retrives calibration parameters for temperature, conductivity, pressure, oxygen, and pH sensors from an instrument configuration (.xmlcon) file. #' #' @param xmlcon_path Path to an xmlcon file. -#' @export +#' @noRd #' @author Sean Rohan extract_calibration_xmlcon <- function(xmlcon_path) { diff --git a/inst/r/example_script.R b/inst/r/example_script.R index a1852bf..aa5a007 100644 --- a/inst/r/example_script.R +++ b/inst/r/example_script.R @@ -49,3 +49,21 @@ get_sunrise_sunset(chosen_date = Sys.Date(), # get_sunrise_sunset(chosen_date = "2023-06-10", # latitude = 52.6, # longitude = -169.4364) + + +## Convert CTD data to BTD as a backup for SBE39 (aka 'the BT') ---------------- + +convert_ctd_btd( + filepath_hex = system.file(paste0("exdata/convert_ctd_btd/", + "SBE19plus_01908106_2023_06_18_0001.hex"), + package = "GAPsurvey"), + filepath_xmlcon = system.file(paste0("exdata/convert_ctd_btd/", + "SBE19plusV2_8106_ph_DO_leg2.xmlcon"), + package = "GAPsurvey"), + VESSEL = 162, + CRUISE = 202301, + HAUL = 97, + latitude = 59.01693, # Approximate - for depth estimation + MODEL_NUMBER = "", + VERSION_NUMBER = "", + SERIAL_NUMBER = 8106) diff --git a/man/convert_do_to_o2sat.Rd b/man/convert_do_to_o2sat.Rd deleted file mode 100644 index 90ed64b..0000000 --- a/man/convert_do_to_o2sat.Rd +++ /dev/null @@ -1,24 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hex_to_cnv.R -\name{convert_do_to_o2sat} -\alias{convert_do_to_o2sat} -\title{Calculate oxygen saturation (percent) from dissolved oxygen (ml/l)} -\usage{ -convert_do_to_o2sat(oxygen, temperature, salinity) -} -\arguments{ -\item{oxygen}{Dissolved oxygen in ml/l} - -\item{temperature}{Temperature (IPTS-68, degrees Celsius).} - -\item{salinity}{Salinity (PSU, PSS-78).} -} -\description{ -Dissolved oxygen divided by oxygen saturation calculated following Garcia and Gordon (1992) -} -\references{ -Garcia, H.E., Gordon, L.I., 1992. Oxygen solubility in seawater: Better fitting equations. Limnol. Oceanogr. 37, 1307–1312. https://doi.org/10.4319/lo.1992.37.6.1307 -} -\author{ -Sean Rohan -} diff --git a/man/extract_calibration_xmlcon.Rd b/man/extract_calibration_xmlcon.Rd deleted file mode 100644 index dda8ad4..0000000 --- a/man/extract_calibration_xmlcon.Rd +++ /dev/null @@ -1,17 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hex_to_cnv.R -\name{extract_calibration_xmlcon} -\alias{extract_calibration_xmlcon} -\title{Extract calibration parameters from xmlcon to a list} -\usage{ -extract_calibration_xmlcon(xmlcon_path) -} -\arguments{ -\item{xmlcon_path}{Path to an xmlcon file.} -} -\description{ -Retrives calibration parameters for temperature, conductivity, pressure, oxygen, and pH sensors from an instrument configuration (.xmlcon) file. -} -\author{ -Sean Rohan -} diff --git a/man/get_calibration_parameter.Rd b/man/get_calibration_parameter.Rd deleted file mode 100644 index 4323125..0000000 --- a/man/get_calibration_parameter.Rd +++ /dev/null @@ -1,31 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hex_to_cnv.R -\name{get_calibration_parameter} -\alias{get_calibration_parameter} -\title{Extract variable from xmlcon file text} -\usage{ -get_calibration_parameter( - header, - cal_par, - start_block = NULL, - end_block = NULL, - make_numeric = TRUE -) -} -\arguments{ -\item{header}{Character vector of lines from an xmlcon file} - -\item{cal_par}{Character vector of the xmlcon tag} - -\item{start_block}{starting index for lines of the header to search} - -\item{end_block}{ending index for lines of the leader to search} - -\item{make_numeric}{Logical. Should the tag value be forced to a numeric?} -} -\description{ -Extract variable from xmlcon file text -} -\author{ -Sean Rohan -} diff --git a/man/hex_to_cnv.Rd b/man/hex_to_cnv.Rd deleted file mode 100644 index 1d0b530..0000000 --- a/man/hex_to_cnv.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hex_to_cnv.R -\name{hex_to_cnv} -\alias{hex_to_cnv} -\title{Convert SBE19plus V2 hex files to cnv} -\usage{ -hex_to_cnv( - hex_path, - output_path, - xmlcon_path = NULL, - sample_interval = 0.25, - output_channels = NULL, - output_sig_digits = NULL -) -} -\arguments{ -\item{hex_path}{Path to a .hex file} - -\item{output_path}{Path to the output file location for a .cnv file} - -\item{xmlcon_path}{Optional. Path to config file. Must be provided if .hex file does not contain configuration file parameters.} - -\item{sample_interval}{Sampling interval for scans; 0.25 for a typical SBE19plus V2 deployment.} - -\item{output_channels}{Optional. Named vector of output channels and their names. Do not use unless outputs are are not the defaults.} - -\item{output_sig_digits}{Optional. Significant digits after the decimal place for output channels. Only change if a subset of channels. Do not use unless outputs are are not the defaults.} -} -\description{ -This function decodes hexadecimal-formatted Sea-Bird CTD files to cnv files. -} -\author{ -Sean Rohan -} diff --git a/man/integer_to_conductivity.Rd b/man/integer_to_conductivity.Rd deleted file mode 100644 index dcde56e..0000000 --- a/man/integer_to_conductivity.Rd +++ /dev/null @@ -1,52 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hex_to_cnv.R -\name{integer_to_conductivity} -\alias{integer_to_conductivity} -\title{Convert SBE integer to conductivity} -\usage{ -integer_to_conductivity( - conductivity_integer, - temperature, - pressure, - condg, - condh, - condi, - condj, - cpcor, - ctcor, - par0 = 256, - par1 = 1000, - sig_figs = 6 -) -} -\arguments{ -\item{conductivity_integer}{Conductivity voltage integer} - -\item{temperature}{Temperature in degrees C} - -\item{pressure}{Presssure in degrees C} - -\item{condg}{Conductivity calibration parameter condg} - -\item{condh}{Conductivity calibration parameter condh} - -\item{condi}{Conductivity calibration parameter condi} - -\item{condj}{Conductivity calibration parameter condj} - -\item{cpcor}{Conductivity calibration parameter cpcor} - -\item{ctcor}{Conductivity calibration parameter ctcor} - -\item{par0}{Constant to convert integer to voltage} - -\item{par1}{Constant to convert integer to voltage} - -\item{sig_figs}{number of significant digits to use for conductivity (default = 6)} -} -\description{ -Convert SBE integer to conductivity -} -\author{ -Sean Rohan -} diff --git a/man/integer_to_ph.Rd b/man/integer_to_ph.Rd deleted file mode 100644 index 651c7d6..0000000 --- a/man/integer_to_ph.Rd +++ /dev/null @@ -1,34 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hex_to_cnv.R -\name{integer_to_ph} -\alias{integer_to_ph} -\title{Convert SBE integer to pH} -\usage{ -integer_to_ph( - ph_integer, - ph_offset, - ph_slope, - temperature, - sig_figs = 3, - par0 = 13107 -) -} -\arguments{ -\item{ph_integer}{pH voltage integer} - -\item{ph_offset}{pH calibration parameter offset} - -\item{ph_slope}{pH calibration parameter slope} - -\item{temperature}{temperature in degrees C} - -\item{sig_figs}{number of significant digits to use for conductivity (default = 3)} - -\item{par0}{ph_integer conversion constant} -} -\description{ -Convert SBE integer to pH -} -\author{ -Sean Rohan -} diff --git a/man/integer_to_pressure.Rd b/man/integer_to_pressure.Rd deleted file mode 100644 index 180f305..0000000 --- a/man/integer_to_pressure.Rd +++ /dev/null @@ -1,67 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hex_to_cnv.R -\name{integer_to_pressure} -\alias{integer_to_pressure} -\title{Convert SBE integer to pressure} -\usage{ -integer_to_pressure( - pressure_integer, - tvoltage_integer, - ptempa0, - ptempa1, - ptempa2, - ptca0, - ptca1, - ptca2, - ptcb0, - ptcb1, - ptcb2, - pa0, - pa1, - pa2, - par0 = 13107, - sig_figs = 3, - convert_to_dbar = TRUE -) -} -\arguments{ -\item{pressure_integer}{Pressure voltage integer} - -\item{tvoltage_integer}{Temperature voltage integer} - -\item{ptempa0}{Pressure calibration parameter ptempa0} - -\item{ptempa1}{Pressure calibration parameter ptempa1} - -\item{ptempa2}{Pressure calibration parameter ptempa2} - -\item{ptca0}{Pressure calibration parameter ptca0} - -\item{ptca1}{Pressure calibration parameter ptca1} - -\item{ptca2}{Pressure calibration parameter ptca2} - -\item{ptcb0}{Pressure calibration parameter ptcb0} - -\item{ptcb1}{Pressure calibration parameter ptcb1} - -\item{ptcb2}{Pressure calibration parameter ptcb2} - -\item{pa0}{Pressure calibration parameter pa0} - -\item{pa1}{Pressure calibration parameter pa1} - -\item{pa2}{Pressure calibration parameter pa2} - -\item{par0}{tvoltage_integer conversion constant} - -\item{sig_figs}{number of significant digits to use for temperature (default = 3)} - -\item{convert_to_dbar}{Should pressure be returned in or decibars (TRUE) or pounds per square inch without offset (FALSE)} -} -\description{ -Convert SBE integer to pressure -} -\author{ -Sean Rohan -} diff --git a/man/integer_to_temperature.Rd b/man/integer_to_temperature.Rd deleted file mode 100644 index 5eded3b..0000000 --- a/man/integer_to_temperature.Rd +++ /dev/null @@ -1,55 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hex_to_cnv.R -\name{integer_to_temperature} -\alias{integer_to_temperature} -\title{Convert SBE integer to ITS-90 temperature} -\usage{ -integer_to_temperature( - temperature_integer, - sig_figs = NULL, - a0, - a1, - a2, - a3, - offset = 0, - par0 = 524288, - par1 = 1.6e+07, - par2 = 2.9e+09, - par3 = 102400000, - par4 = 20480, - par5 = 2e+05 -) -} -\arguments{ -\item{temperature_integer}{Temperature voltage integer} - -\item{sig_figs}{number of significant digits to use for temperature} - -\item{a0}{Temperature calibration parameter a0} - -\item{a1}{Temperature Calibration parameter a1} - -\item{a2}{Temperature calibration parameter a2} - -\item{a3}{Temperature calibration parameter a3} - -\item{offset}{Temperature calibration parameter offset} - -\item{par0}{Temperature calibration parameter par0} - -\item{par1}{Temperature calibration parameter par1} - -\item{par2}{Temperature calibration parameter par2} - -\item{par3}{Temperature calibration parameter par3} - -\item{par4}{Temperature calibration parameter par4} - -\item{par5}{Temperature calibration parameter par5} -} -\description{ -Convert SBE integer to ITS-90 temperature -} -\author{ -Sean Rohan -} diff --git a/man/oxygen_saturation.Rd b/man/oxygen_saturation.Rd deleted file mode 100644 index c4dcbc7..0000000 --- a/man/oxygen_saturation.Rd +++ /dev/null @@ -1,22 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hex_to_cnv.R -\name{oxygen_saturation} -\alias{oxygen_saturation} -\title{Calculate oxygen saturation (ml/l)} -\usage{ -oxygen_saturation(temperature, salinity) -} -\arguments{ -\item{temperature}{Temperature (degrees Celsius).} - -\item{salinity}{Salinity (PSU, PSS-78).} -} -\description{ -Calculate oxygen saturation as a function of temperature and salinity based on oxygen solubility from Garcia and Gordon (1992). -} -\references{ -Garcia, H.E., Gordon, L.I., 1992. Oxygen solubility in seawater: Better fitting equations. Limnol. Oceanogr. 37, 1307–1312. https://doi.org/10.4319/lo.1992.37.6.1307 -} -\author{ -Sean Rohan -} diff --git a/man/tau_par.Rd b/man/tau_par.Rd deleted file mode 100644 index 0ab76da..0000000 --- a/man/tau_par.Rd +++ /dev/null @@ -1,30 +0,0 @@ -% Generated by roxygen2: do not edit by hand -% Please edit documentation in R/hex_to_cnv.R -\name{tau_par} -\alias{tau_par} -\title{Tau correction for dissolved oxygen voltage} -\usage{ -tau_par(temperature, pressure, tau20, d0, d1, d2) -} -\arguments{ -\item{temperature}{Temperature in degrees C} - -\item{pressure}{Pressure in dbar} - -\item{tau20}{Tau correction calibration parameter Tau20.} - -\item{d0}{Tau correction calibration parameter D0.} - -\item{d1}{Tau correction calibration parameter D1.} - -\item{d2}{Tau correction calibration parameter D2.} -} -\description{ -Tau correction following Edwards et al. (2010). -} -\references{ -Edwards, B., Murphy, D., Janzen, C., Larson, A.N., 2010. Calibration, response, and hysteresis in deep-sea dissolved oxygen measurements. J. Atmos. Ocean. Technol. 27, 920–931. https://doi.org/10.1175/2009JTECHO693.1 -} -\author{ -Sean Rohan -}