fit_annular | R Documentation |
Fits an exponential model to the radius cumulative integral of a PSF in annular geometry of a given scatter model, possibly with pressure dependency.
fit_annular(psfl, press = FALSE, norm = TRUE, nstart = 10)
press |
Pressure in mbar or NULL. See details. |
norm |
Logical. Should the PSF be normalized to sum to unity? |
nstart |
Number of random start positions for the multidimension function optimization. |
psfm |
A list of objects created by the function |
The function calculates the (normalized) cumulative integral of the annular PSF and fits the following model by optimization:
F(r) = c1' - (c2' * e^(c3' * r) + c4' * e^(c5' * r) + c6' * e^(c7' * r)),
c1,
c2 / p,
c3 / p,
(c1' - c2') * c4,
c5,
(c1' - c2') * (1 - c4),
c6,
press / 1013.25,
and c1 to c6 are fitted parameters. Note that c1 = total diffuse transmittance (or 1, if norm = TRUE) and that c2' + c4' + c6' = c1.
If there is no pressure dependency (e.g., aerosol only), 'press' does not
need to be specified. Internally, it will be set to 1013.25 mbar, p will
equal unity and the pressure flag will be set to FALSE in the fit object
metadata. The prediction function predict_annular
, will track
dependency on pressure and model domain.
Note that adding multiple models in the input list will only be meaningfull if they are simulations for the same scatter at different surface pressure levels. If psfm is a list with more than one component and press is specified, norm is automatically set to TRUE.
The cumulative annular integral PSF is as known as "environmental function". The optimization is made with mean absolute relative error (MARE) as the error function.
Note that 'PSF' in this package refers to the diffusely transmitted photons only. Photons from direct transmission are simulated and are part of the PSF, but not included in the fit calculations.
A list with the following components:
Type of the fitted model;
Named vector with the 6 coefficients;
The minimum mean absolute relative error of the model fit;
A sorted sequence of MARE of different random starts;
Convergence code from optim
;
Logical flag indicating if there was pressure dependency;
The range of pressure values if fitted with pressure dependency.
# Fitting continental aerosol annular APSF simulation:
data(asim)
psfl <- asim["con"] # Note that input to function must be a list!
opt <- fit_annular(psfl, norm = TRUE, nstart = 30)
opt
plot(opt$mare_seq, xlab = "Iteration", ylab = "MARE")
# Fitting Rayleigh annular APSF simulation with pressure dependence:
data(asim)
psfl <- asim[["ray"]] # A list of Rayleigh simulations at different pressures
opt <- fit_annular(psfl, press = TRUE, norm = TRUE, nstart = 30)
opt
par(mfcol = c(1, 2))
plot(opt$mare_seq, xlab = "Iteration", ylab = "MARE")
plot(NA, xlim = c(0, 10), ylim = c(0, 1), xaxs = "i", yaxs = "i",
xlab = "Radius (km)", ylab = "Normalized f(r)")
x <- asim[["ray"]][[1]]$bin_brks
cols <- rev(rainbow(1:length(asim[["ray"]]), start = 0, end = 0.8))
for(i in 1:length(asim[["ray"]])) {
points(x, cum_psf(asim[["ray"]][[i]], norm = TRUE), col = "grey")
}
for(i in 1:length(asim[["ray"]])) {
press <- asim[["ray"]][[i]]$metadata$press
lines(x, predict_annular(x, opt, type = "cumpsf", press = press))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.