Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jbferet committed Jan 4, 2024
2 parents ee11293 + eb05c5b commit 228a104
Show file tree
Hide file tree
Showing 23 changed files with 144 additions and 124 deletions.
14 changes: 7 additions & 7 deletions R/Lib_PROSPECT.R
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,14 @@ check_version_prospect <- function(LMA, PROT, CBC){
#' This function adapts SpecPROSPECT accordingly to experimental data
#' or to a spectral domain defined by UserDomain
#' @param lambda numeric. Spectral bands corresponding to experimental data
#' @param SpecPROSPECT list. Includes optical constants
#' refractive index, specific absorption coefficients and corresponding spectral bands
#' @param SpecPROSPECT list. Includes optical constants: refractive index,
#' specific absorption coefficients and corresponding spectral bands
#' @param Refl numeric. Measured reflectance data
#' @param Tran numeric. Measured Transmittance data
#' @param UserDomain numeric. either Lower and upper bounds for domain of interest (optional)
#' or list of spectral bands of interest
#' @param UL_Bounds boolean. set to TRUE if UserDomain only includes lower and upper band,
#' set to FALSE if UserDomain is a list of spectral bands (in nm)
#' @param UserDomain numeric. either Lower and upper bounds for domain of
#' interest (optional) or list of spectral bands of interest
#' @param UL_Bounds boolean. set to TRUE if UserDomain only includes lower and
#' upper band, set to FALSE if UserDomain is a list of spectral bands (in nm)
#'
#' @return list including spectral properties at the new resolution
#' @import dplyr
Expand Down Expand Up @@ -248,9 +248,9 @@ FitSpectralData <- function(lambda, SpecPROSPECT = NULL,
#' computation of a LUT of leaf optical properties using a set of
#' leaf chemical & structural parameters
#'
#' @param Input_PROSPECT dataframe. list of PROSPECT input parameters.
#' @param SpecPROSPECT list. spectral constants
#' refractive index, specific absorption coefficients & spectral bands
#' @param Input_PROSPECT dataframe. full list of PROSPECT input parameters. Default = Set to NULL
#'
#' @return list. LUT including leaf reflectance and transmittance
#' @export
Expand Down
101 changes: 52 additions & 49 deletions R/Lib_PROSPECT_Inversion.R

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions R/SpecPROSPECT_FullRange-data.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
#' - *SAC_LMA*: specific absorption coefficient for dry matter (Leaf Mass per Area)
#' - *SAC_PROT*: specific absorption coefficient for proteins
#' - *SAC_CBC*: specific absorption coefficient for carbon-base constituents
#' - *calctav_90*: transmissivity of a dielectric plane surface, averaged over all directions of incidence and over all polarizations for solid angle of 90 degrees
#' - *calctav_40*: transmissivity of a dielectric plane surface, averaged over all directions of incidence and over all polarizations for solid angle of 40 degrees
#' - *calctav_90*: transmissivity of a dielectric plane surface, averaged over
#' all directions of incidence & all polarizations for solid angle of 90 deg
#' - *calctav_40*: transmissivity of a dielectric plane surface, averaged over
#' all directions of incidence & all polarizations for solid angle of 40 deg
"SpecPROSPECT_FullRange"
3 changes: 2 additions & 1 deletion data-raw/DATASET.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ ANT <- 2*runif(10)
EWT <- 0.04*runif(10)
LMA <- 0.02*runif(10)
N <- 1+2*runif(10)
Input_PROSPECT <- data.frame('CHL'=CHL,'CAR'=CAR,'ANT'=ANT,'EWT'=EWT,'LMA'=LMA,'N'=N)
Input_PROSPECT <- data.frame('CHL'=CHL,'CAR'=CAR,'ANT'=ANT,
'EWT'=EWT,'LMA'=LMA,'N'=N)

2 changes: 1 addition & 1 deletion man/CostVal_RMSE.Rd

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

12 changes: 6 additions & 6 deletions man/FitSpectralData.Rd

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

6 changes: 3 additions & 3 deletions man/Get_Nprior.Rd

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

36 changes: 18 additions & 18 deletions man/Invert_PROSPECT.Rd

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

4 changes: 2 additions & 2 deletions man/Merit_RMSE_PROSPECT.Rd

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

2 changes: 1 addition & 1 deletion man/PROSPECT_LUT.Rd

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

2 changes: 1 addition & 1 deletion man/SetInitParm.Rd

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

2 changes: 1 addition & 1 deletion man/SetNValues.Rd

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

6 changes: 4 additions & 2 deletions man/SpecPROSPECT_FullRange.Rd

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

15 changes: 7 additions & 8 deletions man/check_prospect_parms.Rd

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

9 changes: 5 additions & 4 deletions man/tryInversion.Rd

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

13 changes: 9 additions & 4 deletions paper/paper.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ spectroscopy [@jay_physically-based_2016] and PROSAIL for canopy reflectance mod
Note that PROSPECT is also available in packages written in [python](https://github.com/jgomezdans/prosail),
[Julia](https://github.com/RemoteSensingTools/CanopyOptics.jl) and [R](https://github.com/ashiklom/rrtm).

The R package `prospect` includes recent versions of PROSPECT, and aims
at providing up-to-date developments in terms of model version and inversion strategies.
PROSPECT versions 4 and 5 developed by [@feret2008] are deprecated.
Therefore PROSPECT-D and PROSPECT-PRO are recommended versions.
The R package `prospect` includes recent versions of PROSPECT (D and PRO),
and aims at providing up-to-date developments in terms of future model version
and inversion strategies.
This includes parameterizable inversion routines, to ease physical model inversion
for beginners, and to help advanced users in designing and testing their own
inversion strategy.
inversion strategy.


# Overview
Expand Down Expand Up @@ -116,6 +119,8 @@ LMA: leaf mass per area; PROT: proteins; CBC: carbon based constituents).\label{
As PROSPECT is a relatively simple and computationally efficient model,
iterative optimization is the most widespread method to invert PROSPECT
and assess leaf chemistry and structure from their optical properties.
It usually takes less than 1 second to perform PROSPECT inversion, which is acceptable
when processing experimental datasets of leaf optical properties including 100-1000 samples.
Iterative optimization aims at minimizing a cost function comparing
measured and simulated leaf optical properties.
This procedure is based on the function `fmincon` included in the package `pracma`.
Expand Down Expand Up @@ -350,4 +355,4 @@ the initial version of the PROSPECT model.
We also warmly thank Luc Bidel, Christophe François and Gabriel Pavan who
collected the ANGERS data set.

# References
# References
6 changes: 4 additions & 2 deletions tests/testthat/test-Invert_PROSPECT.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ test_that("PROSPECT-D inversion produces accurate biophysical assessment", {
expect_true(abs(leafBP$EWT-BPinit$EWT)<1e-6)
expect_true(abs(leafBP$LMA-BPinit$LMA)<1e-6)

lrt$Reflectance <- lrt$Reflectance*(1+rnorm(length(lrt$Reflectance),0,0.01))
lrt$Transmittance <- lrt$Transmittance*(1+rnorm(length(lrt$Transmittance),0,0.01))
lrt$Reflectance <- lrt$Reflectance*(1+rnorm(length(lrt$Reflectance),
0,0.01))
lrt$Transmittance <- lrt$Transmittance*(1+rnorm(length(lrt$Transmittance),
0,0.01))

leafBP <- Invert_PROSPECT(Refl = lrt$Reflectance,
Tran = lrt$Transmittance)
Expand Down
9 changes: 6 additions & 3 deletions tests/testthat/test-Invert_PROSPECT_OPT.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ test_that("PROSPECT-D inversion over optimal domains produces accurate biophysic
expect_true(abs(leafBP$EWT-BPinit$EWT)<1e-7)
expect_true(abs(leafBP$LMA-BPinit$LMA)<1e-7)

lrt$Reflectance <- lrt$Reflectance*(1+rnorm(length(lrt$Reflectance),0,0.01))
lrt$Transmittance <- lrt$Transmittance*(1+rnorm(length(lrt$Transmittance),0,0.01))
lrt$Reflectance <- lrt$Reflectance*(1+rnorm(length(lrt$Reflectance),
0,0.01))
lrt$Transmittance <- lrt$Transmittance*(1+rnorm(length(lrt$Transmittance),
0,0.01))
leafBPopt <- Invert_PROSPECT_OPT(lambda = lrt$wvl,
Refl = lrt$Reflectance,
Tran = lrt$Transmittance,
Parms2Estimate = c('CHL', 'CAR', 'EWT', 'LMA'))
Parms2Estimate = c('CHL', 'CAR',
'EWT', 'LMA'))
expect_true(abs(leafBPopt$CHL-BPinit$CHL)<1e-0)
expect_true(abs(leafBPopt$CAR-BPinit$CAR)<1e-0)
expect_true(abs(leafBPopt$EWT-BPinit$EWT)<1e-4)
Expand Down
2 changes: 1 addition & 1 deletion vignettes/prospect1.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ When run without input parameters, `PROSPECT` is run with default values:
```{r prospect direct mode default}
library(prospect)
LRT_default <- PROSPECT()
# the following command is equivalent for simulation over the full spectral domain
# the following command is equivalent when simulating over the full spectral domain
LRT_default <- PROSPECT(SpecPROSPECT = prospect::SpecPROSPECT_FullRange)
```
Expand Down
7 changes: 4 additions & 3 deletions vignettes/prospect2.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ SubData <- FitSpectralData(lambda = LRT_D$wvl,
Tran = LRT_D$Transmittance,
UserDomain = SpectralSubDomain)
# Note that FitSpectralData can also run with UserDomain defining upper and lower bounds
# Then you will need to set UL_Bounds = TRUE
# Note that FitSpectralData can also run with UserDomain defining
# upper and lower bounds when setting input argument 'UL_Bounds = TRUE'
ULBounds <- c(400,800)
SubData <- FitSpectralData(lambda = LRT_D$wvl,
Refl = LRT_D$Reflectance,
Expand Down Expand Up @@ -189,7 +189,8 @@ Parms2Estimate <- c('CHL','CAR','ANT','EWT','LMA')
# define initial values for the inversion
InitValues <- data.frame(CHL = 40, CAR = 8, ANT = 0.1, BROWN = 0,
EWT = 0.01, LMA = 0.01, N = 1.5)
# call Invert_PROSPECT_OPT in order to automaticall get optimal estimation of leaf parameters following latest published results
# call Invert_PROSPECT_OPT to get optimal estimation of leaf parameters
# using optimal spectral domains
ParmEst <- Invert_PROSPECT_OPT(lambda = LRT_D$wvl,
Refl = LRT_D$Reflectance,
Tran = LRT_D$Transmittance,
Expand Down
4 changes: 2 additions & 2 deletions vignettes/prospect3.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fileName <- list('DataBioch.txt','ReflectanceData.txt','TransmittanceData.txt')
DataBioch <- fread(file.path(gitlab_Rep,dbName,fileName[[1]]))
Refl <- fread(file.path(gitlab_Rep,dbName,fileName[[2]]))
Tran <- fread(file.path(gitlab_Rep,dbName,fileName[[3]]))
# Get the wavelengths corresponding to the reflectance and transmittance measurements
# Get wavelengths corresponding to the reflectance & transmittance measurements
lambda <- Refl$wavelength
Refl$wavelength <- NULL
Tran$wavelength <- NULL
Expand All @@ -69,7 +69,7 @@ Experimental leaf optics and optical constants of PROSPECT need to be adjusted b
Parms2Estimate <- 'ALL'
InitValues <- data.frame(CHL = 40, CAR = 10, ANT = 0.1, BROWN = 0,
EWT = 0.01, LMA = 0.01, N = 1.5)
# adjust PROSPECT optical constants and experimental leaf optics before inversion
# adjust PROSPECT optical constants & experimental leaf optics before inversion
SubData <- FitSpectralData(lambda = lambda,
Refl = Refl,
Tran = Tran)
Expand Down
Loading

0 comments on commit 228a104

Please sign in to comment.