-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFigure_13.R
More file actions
61 lines (56 loc) · 1.22 KB
/
Copy pathFigure_13.R
File metadata and controls
61 lines (56 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#Fit CW-IRSL data with KP-CW equation
rm(list = ls(all=T))
##load packages and FSF
library("plot3D")
library("FNN")
library("khroma")
library("minpack.lm")
source("Functions_FSFpaper.R")
##set color space for color blind persons
col <- khroma::color("bright")()
## load data
mydata <- read.table("ph300s0IR.asc", sep = ",")[,c(1,3)]
colnames(mydata) <- c("t", "y")
## fitting
fit_data <- mydata
fit <-
suppressWarnings(minpack.lm::nlsLM(
formula = y ~ imax * exp (-rho * (log(1 + A * t)) ^ 3) *
(log(1 + A * t) ^ 2) / (1 + t * A) + bgd,
data = fit_data,
start = list(
imax = 3,
A = 1.1,
rho = 0.03,
bgd = min(mydata$y)
)
))
imax_fit <- coef(fit)[1]
A_fit <- coef(fit)[2]
rho_fit <- coef(fit)[3]
bgd_fit <- coef(fit)[4]
## plotting
par(mfrow = c(1, 1))
plot(
mydata,
log = "xy",
xlab = "Time [s]",
ylab = "CW-IRSL [cts/s]",
col = rgb(0,0,0,0.5),
main = "CW-OSL of KST4 feldspar"
)
## plot analytical solution
lines(
predict(fit),
col = col[2],
lwd = 2
)
legend(
"topright",
bty = "n",
pch = c(1, NA),
lwd = 1,
lty = c(NA, "solid"),
legend = c('Experiment', 'KP-CW equation'),
col = c("black", col[2])
)