Skip to content

Commit

Permalink
Merge pull request #20 from sean-rohan-NOAA/main
Browse files Browse the repository at this point in the history
Correct tau_par() call, make internal CTD functions noRd, add CTD example to example script
  • Loading branch information
EmilyMarkowitz-NOAA authored Apr 4, 2024
2 parents f7d4eaa + 68acb43 commit 44f3b2f
Show file tree
Hide file tree
Showing 17 changed files with 78 additions and 388 deletions.
1 change: 1 addition & 0 deletions .github/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html
45 changes: 45 additions & 0 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions GAPsurvey.Rproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ StripTrailingWhitespace: Yes
BuildType: Package
PackageUseDevtools: Yes
PackageInstallArgs: --no-multiarch --with-keep.source
PackageRoxygenize: rd,collate,namespace
10 changes: 0 additions & 10 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
24 changes: 12 additions & 12 deletions R/hex_to_cnv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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*")
Expand Down Expand Up @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions inst/r/example_script.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
24 changes: 0 additions & 24 deletions man/convert_do_to_o2sat.Rd

This file was deleted.

17 changes: 0 additions & 17 deletions man/extract_calibration_xmlcon.Rd

This file was deleted.

31 changes: 0 additions & 31 deletions man/get_calibration_parameter.Rd

This file was deleted.

34 changes: 0 additions & 34 deletions man/hex_to_cnv.Rd

This file was deleted.

52 changes: 0 additions & 52 deletions man/integer_to_conductivity.Rd

This file was deleted.

Loading

0 comments on commit 44f3b2f

Please sign in to comment.