Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the output.path argument from fit_CWCurve() #209

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion NEWS.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ data frames as input (#200).
* The function computed the number of breaks for the histogram incorrectly
(#197, fixed with #198).

### `fit_CWCurve()`
* Argument `output.path` has been removed, and a warning is raised when
attempting to use it (#207, fixed in #209).

### `fit_EmissionSpectra()`
* Parameter `input_scale` was not correctly propagated when the function would
self-call (#160, @mcol).
Expand All @@ -56,13 +60,17 @@ self-call (#160, @mcol).
* The validation of the minimum dataset size didn't account for the use of
the `signal.range` argument (#182, fixed by #195, @mcol).


### `fit_SurfaceExposure()`
* Fix #162 to remove a dimension mismatch if the input data contained `NA`s,
which would generate unexpected warnings (#163, @mcol).
* The function doesn't stop anymore with an error if called on an
`RLum.Results` object (#165, @mcol).

### `plot_DetPlot()`
* Argument `signal.integral.max` is now enforced to be greater than
`signal.integral.min`, as otherwise the computation of the number of channels
would produce `Inf` (#203, fixed in #206).

### `plot_GrowthCurve()`
* The function now calculates the relative saturation (`n/N`) using the ration of the two integrates.
The values is part of the output table.
Expand Down
41 changes: 5 additions & 36 deletions R/fit_CWCurve.R
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,6 @@
#' @param sample_code [character] (*optional*):
#' sample code used for the plot and the optional output table (`mtext`).
#'
#' @param output.path [character] (*optional*):
#' output path for table output containing the results of the fit. The file
#' name is set automatically. If the file already exists in the directory,
#' the values are appended.
#'
#' @param output.terminal [logical] (*with default*):
#' terminal output with fitting results.
#'
Expand All @@ -106,12 +101,6 @@
#'
#' the fitted CW-OSL curves are returned as plot.
#'
#' **table (*optional*)**
#'
#' an output table (`*.csv`) with parameters of the fitted components is
#' provided if the `output.path` is set.
#'
#'
#' **RLum.Results**
#'
#' Beside the plot and table output options, an [RLum.Results-class] object is
Expand Down Expand Up @@ -171,7 +160,7 @@
#' The function **does not** ensure that the fitting procedure has reached a
#' global minimum rather than a local minimum!
#'
#' @section Function version: 0.5.2
#' @section Function version: 0.5.3
#'
#' @author
#' Sebastian Kreutzer, Institute of Geography, Heidelberg University (Germany)
Expand Down Expand Up @@ -215,15 +204,11 @@ fit_CWCurve<- function(
LED.wavelength = 470,
cex.global = 0.6,
sample_code = "Default",
output.path,
output.terminal = TRUE,
output.terminalAdvanced = TRUE,
plot = TRUE,
...
){
##TODO
##remove output.path

# INTEGRITY CHECKS --------------------------------------------------------

##INPUT OBJECTS
Expand Down Expand Up @@ -266,6 +251,8 @@ fit_CWCurve<- function(
ylab <- if("ylab" %in% names(extraArgs)) {extraArgs$ylab} else
{paste("OSL [cts/",round(max(x)/length(x), digits = 2)," s]",sep="")}

if ("output.path" %in% names(extraArgs))
.throw_warning("Argument 'output.path' no longer supported, ignored")

##============================================================================##
## FITTING
Expand Down Expand Up @@ -388,9 +375,7 @@ fit_CWCurve<- function(
))#end try

}else{

stop("[fit_CWCurve()] fit.method unknown.", call. = FALSE)

.throw_error("'fit.method' unknown")
}


Expand Down Expand Up @@ -533,7 +518,7 @@ fit_CWCurve<- function(
pR<-round(1-RSS/TSS,digits=4)

if(pR<0){
warning("pseudo-R^2 < 0!")
.throw_warning("pseudo-R^2 < 0!")
}

## ---------------------------------------------
Expand Down Expand Up @@ -635,22 +620,6 @@ fit_CWCurve<- function(
colnames(output.table)<-c("sample_code","n.components",
output.tableColNames,"pseudo-R^2")

if(missing(output.path)==FALSE){

##write file with just the header if the file not exists
if(file.exists(paste(output.path,"fit_CWCurve_Output_",sample_code,".csv",sep=""))==FALSE){
write.table(output.table,file=paste(output.path,"fit_CWCurve_Output_",
sample_code,".csv",sep=""), sep=";"
,row.names=FALSE)
}else{
write.table(output.table,file=paste(output.path,"fit_CWCurve_Output_",
sample_code,".csv",sep=""), sep=";"
,row.names=FALSE, append=TRUE, col.names=FALSE)

}#endif::for write option

}#endif::table output

##============================================================================##
## COMPONENT TO SUM CONTRIBUTION PLOT
##============================================================================##
Expand Down
13 changes: 1 addition & 12 deletions man/fit_CWCurve.Rd

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

11 changes: 4 additions & 7 deletions tests/testthat/test_fit_CWCurve.R
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@ test_that("check values from output example", {
# }

SW({
fit_CWCurve(ExampleData.CW_OSL_Curve,
fit.method = "LM", fit.calcError = TRUE,
output.path = tempdir())
fit_CWCurve(ExampleData.CW_OSL_Curve,
fit.method = "LM", fit.calcError = TRUE,
log = "xy",
output.path = tempdir())
expect_warning(fit_CWCurve(ExampleData.CW_OSL_Curve, fit.method = "LM",
fit.calcError = TRUE,
output.path = tempdir()),
"Argument 'output.path' no longer supported")
})
})