Skip to content

Commit

Permalink
speed/freq/wavelength
Browse files Browse the repository at this point in the history
  • Loading branch information
edwbaker committed Oct 2, 2019
1 parent 2ee8684 commit e06a699
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 0 deletions.
2 changes: 2 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export(defaultCluster)
export(dutyCycle)
export(entropyStats)
export(frequencyStats)
export(frequencyWS)
export(gs_transcribe)
export(labelPadding)
export(labelReduction)
Expand All @@ -22,6 +23,7 @@ export(rainfallDetection)
export(sDuration)
export(soundSpeed)
export(soundSpeedBMD)
export(soundSpeedWF)
export(soundSpeed_cramer1993)
export(ste)
export(tSamples)
Expand Down
12 changes: 12 additions & 0 deletions R/frequency.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#' Get the frequency from wavelength and speed of sound
#'
#' TODO: Description
#'
#' @param wl Wavelength
#' @param s Speed of sound
#' @export
#'
frequencyWS <- function(wl, s) {
f <- validateWavelength(wl) / validateSpeed(s)
return(validateFreqIsPossible(f))
}
13 changes: 13 additions & 0 deletions R/soundSpeed.R
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,19 @@ soundSpeed <- function(medium="air",
}
}

#' Get the speed of sound in a medium using wavelength and frequency
#'
#' TODO: Description
#'
#' @param wl Wavelength
#' @param f Frequency
#' @export
#'
soundSpeedWF <- function(wl, f) {
s <- validateWavelength(wl) * validateFreqIsPossible(f)
return(s)
}

#' Get the speed of sound in a medium using bulk modulus and density
#'
#' TODO: Description
Expand Down
17 changes: 17 additions & 0 deletions R/validationFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,23 @@ validateBulkModulus <- function(b) {
return(b)
}

validateSpeed <- function(b) {
if (!is.numeric(b)) {
stop("Speed must be numeric")
}
return(b)
}

validateWavelength <- function(b) {
if (!is.numeric(b)) {
stop("Wavelength must be numeric")
}
if (b < 0) {
stop("Wavelength must not be negative.")
}
return(b)
}

validateDensity<- function(b) {
if (!is.numeric(b)) {
stop("Density must be numeric")
Expand Down
16 changes: 16 additions & 0 deletions man/frequencyWS.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions man/soundSpeedWF.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e06a699

Please sign in to comment.