ootb_sky_cie | R Documentation |
Fit and validate a CIE general sky model from a canopy photograph without manual parameter tuning, and return the predicted raster.
ootb_sky_cie(
r,
z,
a,
m,
bin,
gs,
min_spherical_dist = seq(0, 12, 3),
method = c("Nelder-Mead", "BFGS", "CG", "SANN"),
custom_sky_coef = NULL,
parallel = TRUE
)
r |
numeric terra::SpatRaster of one layer. Typically, the blue
band of a a canopy photograph. Digital numbers should be linearly related
to radiance. See |
z |
terra::SpatRaster generated with |
a |
terra::SpatRaster generated with |
m |
logical terra::SpatRaster with one layer. A binary mask with
|
bin |
logical terra::SpatRaster with one layer. A binarized
hemispherical image. See |
gs |
|
min_spherical_dist |
numeric vector. Values passed to
|
method |
character vector. Optimization methods for |
custom_sky_coef |
optional numeric vector of length five. If |
parallel |
logical vector of length one. If |
Runs a full pipeline to fit a CIE sky model to radiance from a canopy image:
a preliminary estimate of sky digital numbers is attempted using the
two-corner method aiming to start with a comprehensive sampling of the sky
vault (see method = "detect_bg_dn"
of apply_by_direction()
).
sky point extraction is performed with extract_sky_points()
, using
information from a binary mask (bin
) and post-filtering with
rem_nearby_points()
and rem_outliers()
.
relative radiance is computed with extract_rr()
and fitted to CIE
sky models using fit_cie_model()
, selecting the best among different
initial conditions and optimization methods.
model validation is performed via validate_cie_model()
.
raster prediction with cie_image()
.
List with:
rr_raster
numeric terra::SpatRaster. Predicted relative radiance.
model
list returned by fit_cie_model()
. The optimal fit.
model_validation
list returned by validate_cie_model()
.
dist_to_black
Value of dist_to_black
used in extract_sky_points()
for the optimal fit.
use_window
logical
. Whether a window was used in extract_rr()
for the optimal fit.
min_spherical_dist
Value of min_dist
used in
rem_nearby_points(space = "spherical")
for the optimal fit.
sky_points
data.frame
with columns row
and col
. Locations of
sky points.
sun_row_col
data.frame
with the estimated sun‑disk position in
image coordinates.
g
Sky grid used for the optimal fit (as returned by sky_grid_segmentation()
).
tested_grids
character vector describing the tested grid configurations.
tested_distances
character vector of tested min_dist
values in
rem_nearby_points(space = "spherical")
.
tested_methods
character vector of optimization methods tested in
fit_cie_model()
.
optimal_start
starting parameters selected after testing the 15 CIE skies.
model_up
model fitted to relative radiance detected with the
two‑corner method, if that step succeeded; otherwise NULL
.
This function is part of a paper under preparation.
## Not run:
caim <- read_caim()
r <- caim$Blue
z <- zenith_image(ncol(caim), lens())
a <- azimuth_image(z)
m <- !is.na(z)
bin <- ootb_bin(caim, z, a, m, TRUE)
set.seed(7)
gs <- list(
#high res
sky_grid_segmentation(z, a, 2.25, first_ring_different = TRUE),
sky_grid_segmentation(z, a, 2.8125, first_ring_different = TRUE),
#medium res
sky_grid_segmentation(z, a, 9, first_ring_different = TRUE),
sky_grid_segmentation(z, a, 10, first_ring_different = TRUE),
#low res
sky_grid_segmentation(z, a, 15, first_ring_different = FALSE),
sky_grid_segmentation(z, a, 18, first_ring_different = FALSE)
)
sky_cie <- ootb_sky_cie(r, z, a, m, bin, gs,
method = c("Nelder-Mead", "BFGS", "CG", "SANN"),
min_spherical_dist = seq(0, 12, 3),
parallel = TRUE)
sky_cie$rr_raster
plot(sky_cie$rr_raster)
sky_cie$model_validation$rmse
plot(sky_cie$model_validation$pred, sky_cie$model_validation$obs)
abline(0,1)
ratio <- r/sky_cie$rr_raster/sky_cie$model$rr$zenith_dn
plot(ratio)
plot(select_sky_region(ratio, 0.95, 1.05))
plot(select_sky_region(ratio, 1.15, max(ratio[], na.rm = TRUE)))
plot(bin)
points(sky_cie$sky_points$col,
nrow(caim) - sky_cie$sky_points$row, col = 2, pch = 10)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.