Mercurial > repos > ecology > srs_preprocess_s2
annotate prosail-master/R/Lib_PROSAIL.R @ 0:33a1e15f7252 draft default tip
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
| author | ecology | 
|---|---|
| date | Mon, 09 Jan 2023 13:37:05 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 0 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1 # ============================================================================= = | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 2 # prosail | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 3 # Lib_PROSAIL.R | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 4 # ============================================================================= = | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 5 # PROGRAMMERS: | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 6 # Jean-Baptiste FERET <jb.feret@teledetection.fr > | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 7 # Florian de BOISSIEU <fdeboiss@gmail.com > | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 8 # copyright 2019 / 11 Jean-Baptiste FERET | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 9 # ============================================================================= = | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 10 # This Library includes functions dedicated to PROSAIL simulation | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 11 # SAIL versions available are 4SAIL and 4SAIL2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 12 # ============================================================================= = | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 13 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 14 #" computes bidirectional reflectance factor based on outputs from PROSAIL and sun position | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 15 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 16 #" The direct and diffuse light are taken into account as proposed by: | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 17 #" Francois et al. (2002) conversion of 400-1100 nm vegetation albedo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 18 #" measurements into total shortwave broadband albedo using a canopy | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 19 #" radiative transfer model, Agronomie | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 20 #" Es = direct | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 21 #" Ed = diffuse | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 22 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 23 #" @param rdot numeric. Hemispherical-directional reflectance factor in viewing direction | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 24 #" @param rsot numeric. Bi-directional reflectance factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 25 #" @param tts numeric. Solar zenith angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 26 #" @param specatm_sensor list. direct and diffuse radiation for clear conditions | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 27 #" @return brf numeric. Bidirectional reflectance factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 28 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 29 compute_brf <- function(rdot, rsot, tts, specatm_sensor) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 30 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 31 ############################## # | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 32 ## direct / diffuse light ## | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 33 ############################## # | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 34 es <- specatm_sensor$Direct_Light | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 35 ed <- specatm_sensor$Diffuse_Light | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 36 rd <- pi / 180 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 37 skyl <- 0.847 - 1.61 * sin((90 - tts) * rd) + 1.04 * sin((90 - tts) * rd) * sin((90 - tts) * rd) # diffuse radiation (Francois et al., 2002) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 38 pardiro <- (1 - skyl) * es | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 39 pardifo <- skyl * ed | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 40 brf <- (rdot * pardifo + rsot * pardiro) / (pardiro + pardifo) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 41 return(brf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 42 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 43 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 44 #" Performs PROSAIL simulation based on a set of combinations of input parameters | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 45 #" @param spec_sensor list. Includes optical constants required for PROSPECT | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 46 #" refractive index, specific absorption coefficients and corresponding spectral bands | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 47 #" @param input_prospect list. PROSPECT input variables | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 48 #" @param n numeric. Leaf structure parameter | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 49 #" @param chl numeric. chlorophyll content (microg.cm-2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 50 #" @param car numeric. carotenoid content (microg.cm-2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 51 #" @param ant numeric. anthocyain content (microg.cm-2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 52 #" @param brown numeric. brown pigment content (Arbitrary units) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 53 #" @param ewt numeric. Equivalent Water Thickness (g.cm-2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 54 #" @param lma numeric. Leaf Mass per Area (g.cm-2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 55 #" @param prot numeric. protein content (g.cm-2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 56 #" @param cbc numeric. nonprotcarbon-based constituent content (g.cm-2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 57 #" @param alpha numeric. Solid angle for incident light at surface of leaf (simulation of roughness) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 58 #" @param typelidf numeric. Type of leaf inclination distribution function | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 59 #" @param lidfa numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 60 #" if typelidf == 1, controls the average leaf slope | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 61 #" if typelidf == 2, corresponds to average leaf angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 62 #" @param lidfb numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 63 #" if typelidf == 1, unused | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 64 #" if typelidf == 2, controls the distribution"s bimodality | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 65 #" @param lai numeric. Leaf Area Index | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 66 #" @param q numeric. Hot Spot parameter | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 67 #" @param tts numeric. Sun zeith angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 68 #" @param tto numeric. Observer zeith angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 69 #" @param psi numeric. Azimuth Sun / Observer | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 70 #" @param rsoil numeric. Soil reflectance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 71 #" @param fraction_brown numeric. Fraction of brown leaf area | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 72 #" @param diss numeric. Layer dissociation factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 73 #" @param cv numeric. vertical crown cover percentage | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 74 #" = % ground area covered with crowns as seen from nadir direction | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 75 #" @param zeta numeric. Tree shape factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 76 #" = ratio of crown diameter to crown height | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 77 #" @param sailversion character. choose between 4SAIL and 4SAIL2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 78 #" @param brownvegetation list. Defines optical properties for brown vegetation, if not nULL | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 79 #" - WVL, reflectance, Transmittance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 80 #" - Set to nULL if use PROSPECT to generate it | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 81 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 82 #" @return list. rdot, rsot, rddt, rsdt | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 83 #" rdot: hemispherical-directional reflectance factor in viewing direction | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 84 #" rsot: bi-directional reflectance factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 85 #" rsdt: directional-hemispherical reflectance factor for solar incident flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 86 #" rddt: bi-hemispherical reflectance factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 87 #" @import prospect | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 88 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 89 pro4sail <- function(spec_sensor, input_prospect = nULL, n = 1.5, chl = 40.0, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 90 car = 8.0, ant = 0.0, brown = 0.0, ewt = 0.01, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 91 lma = 0.008, prot = 0.0, cbc = 0.0, alpha = 40.0, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 92 typelidf = 2, lidfa = nULL, lidfb = nULL, lai = nULL, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 93 q = nULL, tts = nULL, tto = nULL, psi = nULL, rsoil = nULL, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 94 fraction_brown = 0.0, diss = 0.0, cv = 1, zeta = 1, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 95 sailversion = "4SAIL", brownvegetation = nULL) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 96 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 97 ############################ # | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 98 # LEAF OPTICAL PROPERTIES ## | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 99 ############################ # | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 100 if (is.null(input_prospect)) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 101 input_prospect <- data.frame("chl" = chl, "car" = car, "ant" = ant, "brown" = brown, "ewt" = ewt, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 102 "lma" = lma, "prot" = prot, "cbc" = cbc, "n" = n, "alpha" = alpha) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 103 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 104 greenvegetation <- prospect::PROSPECT(SpecPROSPECT = spec_sensor, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 105 n = input_prospect$n[1], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 106 chl = input_prospect$chl[1], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 107 car = input_prospect$car[1], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 108 ant = input_prospect$ant[1], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 109 brown = input_prospect$brown[1], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 110 ewt = input_prospect$ewt[1], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 111 lma = input_prospect$lma[1], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 112 prot = input_prospect$prot[1], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 113 cbc = input_prospect$cbc[1], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 114 alpha = input_prospect$alpha[1]) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 115 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 116 if (sailversion == "4SAIL2") { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 117 # 4SAIL2 requires one of the following combination of input parameters | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 118 # Case #1: valid optical properties for brown vegetation | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 119 if (!is.null(brownvegetation)) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 120 # need to define reflectance and Transmittance for brownvegetation | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 121 if (length(grep("reflectance", names(brownvegetation))) == 0 || length(grep("Transmittance", names(brownvegetation))) == 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 122 message("Please define brownvegetation as a list including reflectance and Transmittance") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 123 stop() | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 124 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 125 # check if spectral domain for optical properties of brown vegetation match | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 126 # with spectral domain for optical properties of green vegetation | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 127 if (length(setdiff(spec_sensor$lambda, brownvegetation$wvl)) > 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 128 message("Please define same spectral domain for brownvegetation and SpecPROSPECT") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 129 stop() | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 130 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 131 if (length(unique(lengths(input_prospect))) == 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 132 if (!unique(lengths(input_prospect)) == 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 133 message("brownvegetation defined along with multiple leaf chemical properties") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 134 message("Only first set of leaf chemical properties will be used to simulate green vegetation") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 135 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 136 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 137 # if no leaf optical properties brown vegetation defined | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 138 } else if (is.null(brownvegetation)) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 139 # if all PROSPECT input parameters have the same length | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 140 if (length(unique(lengths(input_prospect))) == 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 141 # if all PROSPECT input parameters are unique (no possibility to simulate 2 types of leaf optics) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 142 if (unique(lengths(input_prospect)) == 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 143 # if fraction_brown set to 0, then assign green vegetation optics to brown vegetation optics | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 144 if (fraction_brown == 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 145 brownvegetation <- greenvegetation | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 146 # else run 4SAIL | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 147 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 148 message("4SAIL2 needs two sets of optical properties for green and brown vegetation") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 149 message("Currently one set is defined. will run 4SAIL instead of 4SAIL2") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 150 sailversion <- "4SAIL" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 151 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 152 # if all PROSPECT parameters have at least 2 elements | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 153 } else if (unique(lengths(input_prospect)) >= 2) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 154 # compute leaf optical properties | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 155 brownvegetation <- prospect::PROSPECT(SpecPROSPECT = spec_sensor, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 156 n = input_prospect$n[2], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 157 chl = input_prospect$chl[2], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 158 car = input_prospect$car[2], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 159 ant = input_prospect$ant[2], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 160 brown = input_prospect$brown[2], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 161 ewt = input_prospect$ewt[2], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 162 lma = input_prospect$lma[2], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 163 prot = input_prospect$prot[2], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 164 cbc = input_prospect$cbc[2], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 165 alpha = input_prospect$alpha[2]) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 166 if (unique(lengths(input_prospect)) > 2) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 167 message("4SAIL2 needs two sets of optical properties for green and brown vegetation") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 168 message("Currently more than 2 sets are defined. will only use the first 2") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 169 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 170 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 171 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 172 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 173 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 174 if (sailversion == "4SAIL") { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 175 if (length(unique(lengths(input_prospect))) == 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 176 if (unique(lengths(input_prospect)) > 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 177 message("4SAIL needs only one set of optical properties") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 178 message("Currently more than one set of leaf chemical constituents is defined.") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 179 message("Will run 4SAIL with the first set of leaf chemical constituents") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 180 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 181 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 182 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 183 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 184 if (sailversion == "4SAIL") { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 185 # run 4SAIL | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 186 ref <- foursail(leafoptics = greenvegetation, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 187 typelidf, lidfa, lidfb, lai, q, tts, tto, psi, rsoil) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 188 } else if (sailversion == "4SAIL2") { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 189 # run 4SAIL2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 190 ref <- foursail2(leafgreen = greenvegetation, leafbrown = brownvegetation, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 191 typelidf, lidfa, lidfb, lai, q, tts, tto, psi, rsoil, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 192 fraction_brown, diss, cv, zeta) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 193 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 194 return(ref) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 195 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 196 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 197 #" Performs PROSAIL simulation based on a set of combinations of input parameters | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 198 #" @param leafoptics list. Includes leaf optical properties (reflectance and transmittance) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 199 #" and corresponding spectral bands | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 200 #" @param typelidf numeric. Type of leaf inclination distribution function | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 201 #" @param lidfa numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 202 #" if typelidf == 1, controls the average leaf slope | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 203 #" if typelidf == 2, corresponds to average leaf angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 204 #" @param lidfb numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 205 #" if typelidf == 1, unused | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 206 #" if typelidf == 2, controls the distribution"s bimodality | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 207 #" @param lai numeric. Leaf Area Index | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 208 #" @param q numeric. Hot Spot parameter | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 209 #" @param tts numeric. Sun zeith angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 210 #" @param tto numeric. Observer zeith angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 211 #" @param psi numeric. Azimuth Sun / Observer | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 212 #" @param rsoil numeric. Soil reflectance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 213 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 214 #" @return list. rdot, rsot, rddt, rsdt | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 215 #" rdot: hemispherical-directional reflectance factor in viewing direction | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 216 #" rsot: bi-directional reflectance factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 217 #" rsdt: directional-hemispherical reflectance factor for solar incident flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 218 #" rddt: bi-hemispherical reflectance factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 219 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 220 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 221 foursail <- function(leafoptics, typelidf = 2, lidfa = nULL, lidfb = nULL, lai = nULL, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 222 q = nULL, tts = nULL, tto = nULL, psi = nULL, rsoil = nULL) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 223 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 224 ############################## # | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 225 # LEAF OPTICAL PROPERTIES ## | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 226 ############################## # | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 227 rho <- leafoptics$Reflectance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 228 tau <- leafoptics$Transmittance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 229 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 230 # Geometric quantities | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 231 rd <- pi / 180 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 232 cts <- cos(rd * tts) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 233 cto <- cos(rd * tto) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 234 ctscto <- cts * cto | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 235 tants <- tan(rd * tts) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 236 tanto <- tan(rd * tto) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 237 cospsi <- cos(rd * psi) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 238 dso <- sqrt(tants * tants + tanto * tanto - 2. * tants * tanto * cospsi) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 239 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 240 # Generate leaf angle distribution from average leaf angle (ellipsoidal) or (a, b) parameters | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 241 if (typelidf == 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 242 foliar_distrib <- dladgen(lidfa, lidfb) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 243 lidf <- foliar_distrib$lidf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 244 litab <- foliar_distrib$litab | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 245 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 246 } else if (typelidf == 2) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 247 foliar_distrib <- campbell(lidfa) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 248 lidf <- foliar_distrib$lidf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 249 litab <- foliar_distrib$litab | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 250 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 251 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 252 # angular distance, compensation of shadow length | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 253 # Calculate geometric factors associated with extinction and scattering | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 254 # Initialise sums | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 255 ks <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 256 ko <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 257 bf <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 258 sob <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 259 sof <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 260 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 261 # Weighted sums over LIDF | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 262 na <- length(litab) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 263 for (i in 1:na) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 264 ttl <- litab[i] # leaf inclination discrete values | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 265 ctl <- cos(rd * ttl) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 266 # SAIL volume scattering phase function gives interception and portions to be | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 267 # multiplied by rho and tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 268 resvolscatt <- volscatt(tts, tto, psi, ttl) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 269 chi_s <- resvolscatt$chi_s | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 270 chi_o <- resvolscatt$chi_o | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 271 frho <- resvolscatt$frho | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 272 ftau <- resvolscatt$ftau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 273 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 274 #******************************************************************************** | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 275 #* SUITS SYSTEM coEFFICIEnTS | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 276 #* | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 277 #* ks : Extinction coefficient for direct solar flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 278 #* ko : Extinction coefficient for direct observed flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 279 #* att : Attenuation coefficient for diffuse flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 280 #* sigb : Backscattering coefficient of the diffuse downward flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 281 #* sigf : Forwardscattering coefficient of the diffuse upward flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 282 #* sf : Scattering coefficient of the direct solar flux for downward diffuse flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 283 #* sb : Scattering coefficient of the direct solar flux for upward diffuse flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 284 #* vf : Scattering coefficient of upward diffuse flux in the observed direction | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 285 #* vb : Scattering coefficient of downward diffuse flux in the observed direction | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 286 #* w : Bidirectional scattering coefficient | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 287 #******************************************************************************** | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 288 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 289 # Extinction coefficients | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 290 ksli <- chi_s / cts | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 291 koli <- chi_o / cto | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 292 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 293 # Area scattering coefficient fractions | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 294 sobli <- frho * pi / ctscto | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 295 sofli <- ftau * pi / ctscto | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 296 bfli <- ctl * ctl | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 297 ks <- ks + ksli * lidf[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 298 ko <- ko + koli * lidf[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 299 bf <- bf + bfli * lidf[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 300 sob <- sob + sobli * lidf[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 301 sof <- sof + sofli * lidf[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 302 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 303 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 304 # Geometric factors to be used later with rho and tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 305 sdb <- 0.5 * (ks + bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 306 sdf <- 0.5 * (ks - bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 307 dob <- 0.5 * (ko + bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 308 dof <- 0.5 * (ko - bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 309 ddb <- 0.5 * (1. + bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 310 ddf <- 0.5 * (1. - bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 311 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 312 # Here rho and tau come in | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 313 sigb <- ddb * rho + ddf * tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 314 sigf <- ddf * rho + ddb * tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 315 att <- 1 - sigf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 316 m2 <- (att + sigb) * (att - sigb) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 317 m2[which(m2 <= 0)] <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 318 m <- sqrt(m2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 319 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 320 sb <- sdb * rho + sdf * tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 321 sf <- sdf * rho + sdb * tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 322 vb <- dob * rho + dof * tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 323 vf <- dof * rho + dob * tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 324 w <- sob * rho + sof * tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 325 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 326 # Here the LAI comes in | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 327 # Outputs for the case LAI = 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 328 if (lai < 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 329 tss <- 1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 330 too <- 1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 331 tsstoo <- 1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 332 rdd <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 333 tdd <- 1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 334 rsd <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 335 tsd <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 336 rdo <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 337 tdo <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 338 rso <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 339 rsos <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 340 rsod <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 341 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 342 rddt <- rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 343 rsdt <- rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 344 rdot <- rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 345 rsodt <- 0 * rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 346 rsost <- rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 347 rsot <- rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 348 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 349 # Other cases (LAI > 0) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 350 e1 <- exp(-m * lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 351 e2 <- e1 * e1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 352 rinf <- (att - m) / sigb | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 353 rinf2 <- rinf * rinf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 354 re <- rinf * e1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 355 denom <- 1. - rinf2 * e2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 356 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 357 j1ks <- jfunc1(ks, m, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 358 j2ks <- jfunc2(ks, m, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 359 j1ko <- jfunc1(ko, m, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 360 j2ko <- jfunc2(ko, m, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 361 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 362 ps <- (sf + sb * rinf) * j1ks | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 363 qs <- (sf * rinf + sb) * j2ks | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 364 pv <- (vf + vb * rinf) * j1ko | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 365 qv <- (vf * rinf + vb) * j2ko | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 366 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 367 rdd <- rinf * (1. - e2) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 368 tdd <- (1. - rinf2) * e1 / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 369 tsd <- (ps - re * qs) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 370 rsd <- (qs - re * ps) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 371 tdo <- (pv - re * qv) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 372 rdo <- (qv - re * pv) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 373 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 374 tss <- exp(-ks * lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 375 too <- exp(-ko * lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 376 z <- jfunc3(ks, ko, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 377 g1 <- (z - j1ks * too) / (ko + m) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 378 g2 <- (z - j1ko * tss) / (ks + m) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 379 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 380 tv1 <- (vf * rinf + vb) * g1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 381 tv2 <- (vf + vb * rinf) * g2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 382 t1 <- tv1 * (sf + sb * rinf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 383 t2 <- tv2 * (sf * rinf + sb) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 384 t3 <- (rdo * qs + tdo * ps) * rinf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 385 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 386 # Multiple scattering contribution to bidirectional canopy reflectance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 387 rsod <- (t1 + t2 - t3) / (1. - rinf2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 388 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 389 # Treatment of the hotspot-effect | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 390 alf <- 1e6 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 391 # Apply correction 2 / (K + k) suggested by F.-M. Breon | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 392 if (q > 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 393 alf <- (dso / q) * 2. / (ks + ko) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 394 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 395 if (alf > 200) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 396 # inserted H. Bach 1 / 3 / 04 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 397 alf <- 200 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 398 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 399 if (alf == 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 400 # The pure hotspot - no shadow | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 401 tsstoo <- tss | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 402 sumint <- (1 - tss) / (ks * lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 403 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 404 # Outside the hotspot | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 405 fhot <- lai * sqrt(ko * ks) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 406 # Integrate by exponential Simpson method in 20 steps | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 407 # the steps are arranged according to equal partitioning | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 408 # of the slope of the joint probability function | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 409 x1 <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 410 y1 <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 411 f1 <- 1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 412 fint <- (1. - exp(-alf)) * 0.05 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 413 sumint <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 414 for (i in 1:20) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 415 if (i < 20) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 416 x2 <- -log(1. - i * fint) / alf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 417 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 418 x2 <- 1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 419 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 420 y2 <- -(ko + ks) * lai * x2 + fhot * (1. - exp(-alf * x2)) / alf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 421 f2 <- exp(y2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 422 sumint <- sumint + (f2 - f1) * (x2 - x1) / (y2 - y1) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 423 x1 <- x2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 424 y1 <- y2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 425 f1 <- f2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 426 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 427 tsstoo <- f1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 428 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 429 # Bidirectional reflectance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 430 # Single scattering contribution | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 431 rsos <- w * lai * sumint | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 432 # Total canopy contribution | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 433 rso <- rsos + rsod | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 434 # Interaction with the soil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 435 dn <- 1. - rsoil * rdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 436 # rddt: bi-hemispherical reflectance factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 437 rddt <- rdd + tdd * rsoil * tdd / dn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 438 # rsdt: directional-hemispherical reflectance factor for solar incident flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 439 rsdt <- rsd + (tsd + tss) * rsoil * tdd / dn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 440 # rdot: hemispherical-directional reflectance factor in viewing direction | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 441 rdot <- rdo + tdd * rsoil * (tdo + too) / dn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 442 # rsot: bi-directional reflectance factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 443 rsodt <- rsod + ((tss + tsd) * tdo + (tsd + tss * rsoil * rdd) * too) * rsoil / dn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 444 rsost <- rsos + tsstoo * rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 445 rsot <- rsost + rsodt | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 446 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 447 my_list <- list("rdot" = rdot, "rsot" = rsot, "rddt" = rddt, "rsdt" = rsdt) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 448 return(my_list) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 449 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 450 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 451 #" Performs pro4sail2 simulation based on a set of combinations of input parameters | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 452 #" @param leafgreen list. includes relfectance and transmittance for vegetation #1 (e.g. green vegetation) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 453 #" @param leafbrown list. includes relfectance and transmittance for vegetation #2 (e.g. brown vegetation) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 454 #" @param typelidf numeric. Type of leaf inclination distribution function | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 455 #" @param lidfa numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 456 #" if typelidf == 1, controls the average leaf slope | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 457 #" if typelidf == 2, corresponds to average leaf angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 458 #" @param lidfb numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 459 #" if typelidf == 1, unused | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 460 #" if typelidf == 2, controls the distribution"s bimodality | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 461 #" @param lai numeric. Leaf Area Index | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 462 #" @param hot numeric. Hot Spot parameter = ratio of the correlation length of leaf projections in the horizontal plane and the canopy height (doi:10.1016 / j.rse.2006.12.013) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 463 #" @param tts numeric. Sun zeith angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 464 #" @param tto numeric. Observer zeith angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 465 #" @param psi numeric. Azimuth Sun / Observer | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 466 #" @param rsoil numeric. Soil reflectance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 467 #" @param fraction_brown numeric. Fraction of brown leaf area | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 468 #" @param diss numeric. Layer dissociation factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 469 #" @param cv numeric. vertical crown cover percentage | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 470 #" = % ground area covered with crowns as seen from nadir direction | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 471 #" @param zeta numeric. Tree shape factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 472 #" = ratio of crown diameter to crown height | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 473 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 474 #" @return list. rdot, rsot, rddt, rsdt | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 475 #" rdot: hemispherical-directional reflectance factor in viewing direction | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 476 #" rsot: bi-directional reflectance factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 477 #" rsdt: directional-hemispherical reflectance factor for solar incident flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 478 #" rddt: bi-hemispherical reflectance factor | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 479 #" alfast: canopy absorptance for direct solar incident flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 480 #" alfadt: canopy absorptance for hemispherical diffuse incident flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 481 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 482 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 483 foursail2 <- function(leafgreen, leafbrown, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 484 typelidf = 2, lidfa = nULL, lidfb = nULL, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 485 lai = nULL, hot = nULL, tts = nULL, tto = nULL, psi = nULL, rsoil = nULL, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 486 fraction_brown = 0.5, diss = 0.5, cv = 1, zeta = 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 487 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 488 # This version does not include non-Lambertian soil properties. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 489 # original codes do, and only need to add the following variables as input | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 490 rddsoil <- rdosoil <- rsdsoil <- rsosoil <- rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 491 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 492 # Geometric quantities | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 493 rd <- pi / 180 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 494 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 495 # Generate leaf angle distribution from average leaf angle (ellipsoidal) or (a, b) parameters | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 496 if (typelidf == 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 497 foliar_distrib <- dladgen(lidfa, lidfb) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 498 lidf <- foliar_distrib$lidf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 499 litab <- foliar_distrib$litab | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 500 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 501 } else if (typelidf == 2) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 502 foliar_distrib <- campbell(lidfa) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 503 lidf <- foliar_distrib$lidf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 504 litab <- foliar_distrib$litab | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 505 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 506 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 507 if (lai < 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 508 message("Please define positive LAI value") | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 509 rddt <- rsdt <- rdot <- rsost <- rsot <- rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 510 alfast <- alfadt <- 0 * rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 511 } else if (lai == 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 512 tss <- too <- tsstoo <- tdd <- 1.0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 513 rdd <- rsd <- tsd <- rdo <- tdo <- 0.0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 514 rso <- rsos <- rsod <- rsodt <- 0.0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 515 rddt <- rsdt <- rdot <- rsost <- rsot <- rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 516 alfast <- alfadt <- 0 * rsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 517 } else if (lai > 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 518 cts <- cos(rd * tts) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 519 cto <- cos(rd * tto) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 520 ctscto <- cts * cto | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 521 tants <- tan(rd * tts) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 522 tanto <- tan(rd * tto) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 523 cospsi <- cos(rd * psi) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 524 dso <- sqrt(tants * tants + tanto * tanto - 2.0 * tants * tanto * cospsi) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 525 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 526 # Clumping effects | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 527 cs <- co <- 1.0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 528 if (cv <= 1.0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 529 cs <- 1.0 - (1.0 - cv)^(1.0 / cts) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 530 co <- 1.0 - (1.0 - cv)^(1.0 / cto) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 531 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 532 overlap <- 0.0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 533 if (zeta > 0.0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 534 overlap <- min(cs * (1.0 - co), co * (1.0 - cs)) * exp(-dso / zeta) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 535 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 536 fcd <- cs * co + overlap | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 537 fcs <- (1.0 - cs) * co - overlap | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 538 fod <- cs * (1.0 - co) - overlap | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 539 fos <- (1.0 - cs) * (1.0 - co) + overlap | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 540 fcdc <- 1.0 - (1.0 - fcd)^(0.5 / cts + 0.5 / cto) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 541 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 542 # Part depending on diss, fraction_brown, and leaf optical properties | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 543 # First save the input fraction_brown as the old fraction_brown, as the following change is only artificial | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 544 # Better define an fraction_brown that is actually used: fb, so that the input is not modified! | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 545 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 546 fb <- fraction_brown | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 547 # if only green leaves | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 548 if (fraction_brown == 0.0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 549 fb <- 0.5 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 550 leafbrown$Reflectance <- leafgreen$Reflectance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 551 leafbrown$Transmittance <- leafgreen$Transmittance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 552 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 553 if (fraction_brown == 1.0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 554 fb <- 0.5 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 555 leafgreen$Reflectance <- leafbrown$Reflectance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 556 leafgreen$Transmittance <- leafbrown$Transmittance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 557 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 558 s <- (1.0 - diss) * fb * (1.0 - fb) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 559 # rho1 && tau1 : green foliage | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 560 # rho2 && tau2 : brown foliage (bottom layer) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 561 rho1 <- ((1 - fb - s) * leafgreen$Reflectance + s * leafbrown$Reflectance) / (1 - fb) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 562 tau1 <- ((1 - fb - s) * leafgreen$Transmittance + s * leafbrown$Transmittance) / (1 - fb) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 563 rho2 <- (s * leafgreen$Reflectance + (fb - s) * leafbrown$Reflectance) / fb | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 564 tau2 <- (s * leafgreen$Transmittance + (fb - s) * leafbrown$Transmittance) / fb | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 565 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 566 # angular distance, compensation of shadow length | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 567 # Calculate geometric factors associated with extinction and scattering | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 568 # Initialise sums | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 569 ks <- ko <- bf <- sob <- sof <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 570 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 571 # Weighted sums over LIDF | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 572 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 573 for (i in 1:seq_along(litab)) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 574 ttl <- litab[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 575 ctl <- cos(rd * ttl) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 576 # SAIL volscatt function gives interception coefficients | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 577 # and two portions of the volume scattering phase function to be | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 578 # multiplied by rho and tau, respectively | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 579 resvolscatt <- volscatt(tts, tto, psi, ttl) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 580 chi_s <- resvolscatt$chi_s | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 581 chi_o <- resvolscatt$chi_o | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 582 frho <- resvolscatt$frho | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 583 ftau <- resvolscatt$ftau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 584 # Extinction coefficients | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 585 ksli <- chi_s / cts | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 586 koli <- chi_o / cto | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 587 # Area scattering coefficient fractions | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 588 sobli <- frho * pi / ctscto | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 589 sofli <- ftau * pi / ctscto | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 590 bfli <- ctl * ctl | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 591 ks <- ks + ksli * lidf[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 592 ko <- ko + koli * lidf[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 593 bf <- bf + bfli * lidf[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 594 sob <- sob + sobli * lidf[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 595 sof <- sof + sofli * lidf[i] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 596 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 597 # Geometric factors to be used later in combination with rho and tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 598 sdb <- 0.5 * (ks + bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 599 sdf <- 0.5 * (ks - bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 600 dob <- 0.5 * (ko + bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 601 dof <- 0.5 * (ko - bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 602 ddb <- 0.5 * (1. + bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 603 ddf <- 0.5 * (1. - bf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 604 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 605 # LAIs in two layers | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 606 lai1 <- (1 - fb) * lai | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 607 lai2 <- fb * lai | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 608 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 609 tss <- exp(-ks * lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 610 ck <- exp(-ks * lai1) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 611 alf <- 1e6 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 612 if (hot > 0.0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 613 alf <- (dso / hot) * 2.0 / (ks + ko) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 614 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 615 if (alf > 200.0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 616 alf <- 200.0 # inserted H. Bach 1 / 3 / 04 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 617 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 618 if (alf == 0.0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 619 # The pure hotspot | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 620 tsstoo <- tss | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 621 s1 <- (1 - ck) / (ks * lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 622 s2 <- (ck - tss) / (ks * lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 623 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 624 # Outside the hotspot | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 625 fhot <- lai * sqrt(ko * ks) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 626 # Integrate 2 layers by exponential simpson method in 20 steps | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 627 # the steps are arranged according to equal partitioning | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 628 # of the derivative of the joint probability function | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 629 x1 <- y1 <- 0.0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 630 f1 <- 1.0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 631 ca <- exp(alf * (fb - 1.0)) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 632 fint <- (1.0 - ca) * .05 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 633 s1 <- 0.0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 634 for (istep in 1:20) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 635 if (istep < 20) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 636 x2 <- -log(1. - istep * fint) / alf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 637 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 638 x2 <- 1. - fb | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 639 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 640 y2 <- -(ko + ks) * lai * x2 + fhot * (1.0 - exp(-alf * x2)) / alf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 641 f2 <- exp(y2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 642 s1 <- s1 + (f2 - f1) * (x2 - x1) / (y2 - y1) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 643 x1 <- x2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 644 y1 <- y2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 645 f1 <- f2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 646 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 647 fint <- (ca - exp(-alf)) * .05 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 648 s2 <- 0.0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 649 for (istep in 1:20) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 650 if (istep < 20) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 651 x2 <- -log(ca - istep * fint) / alf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 652 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 653 x2 <- 1.0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 654 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 655 y2 <- -(ko + ks) * lai * x2 + fhot * (1.0 - exp(-alf * x2)) / alf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 656 f2 <- exp(y2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 657 s2 <- s2 + (f2 - f1) * (x2 - x1) / (y2 - y1) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 658 x1 <- x2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 659 y1 <- y2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 660 f1 <- f2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 661 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 662 tsstoo <- f1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 663 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 664 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 665 # Calculate reflectances and transmittances | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 666 # Bottom layer | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 667 tss <- exp(-ks * lai2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 668 too <- exp(-ko * lai2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 669 sb <- sdb * rho2 + sdf * tau2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 670 sf <- sdf * rho2 + sdb * tau2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 671 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 672 vb <- dob * rho2 + dof * tau2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 673 vf <- dof * rho2 + dob * tau2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 674 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 675 w2 <- sob * rho2 + sof * tau2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 676 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 677 sigb <- ddb * rho2 + ddf * tau2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 678 sigf <- ddf * rho2 + ddb * tau2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 679 att <- 1.0 - sigf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 680 m2 <- (att + sigb) * (att - sigb) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 681 m2[m2 < 0] <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 682 m <- sqrt(m2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 683 which_ncs <- which(m > 0.01) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 684 which_cs <- which(m <= 0.01) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 685 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 686 tdd <- rdd <- tsd <- rsd <- tdo <- rdo <- 0 * m | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 687 rsod <- 0 * m | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 688 if (length(which_ncs) > 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 689 resncs <- nonconservativescattering(m[which_ncs], lai2, att[which_ncs], sigb[which_ncs], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 690 ks, ko, sf[which_ncs], sb[which_ncs], vf[which_ncs], vb[which_ncs], tss, too) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 691 tdd[which_ncs] <- resncs$tdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 692 rdd[which_ncs] <- resncs$rdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 693 tsd[which_ncs] <- resncs$tsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 694 rsd[which_ncs] <- resncs$rsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 695 tdo[which_ncs] <- resncs$tdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 696 rdo[which_ncs] <- resncs$rdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 697 rsod[which_ncs] <- resncs$rsod | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 698 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 699 if (length(which_cs) > 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 700 rescs <- conservativescattering(m[which_cs], lai2, att[which_cs], sigb[which_cs], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 701 ks, ko, sf[which_cs], sb[which_cs], vf[which_cs], vb[which_cs], tss, too) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 702 tdd[which_cs] <- rescs$tdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 703 rdd[which_cs] <- rescs$rdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 704 tsd[which_cs] <- rescs$tsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 705 rsd[which_cs] <- rescs$rsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 706 tdo[which_cs] <- rescs$tdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 707 rdo[which_cs] <- rescs$rdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 708 rsod[which_cs] <- rescs$rsod | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 709 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 710 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 711 # Set background properties equal to those of the bottom layer on a black soil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 712 rddb <- rdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 713 rsdb <- rsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 714 rdob <- rdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 715 rsodb <- rsod | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 716 tddb <- tdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 717 tsdb <- tsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 718 tdob <- tdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 719 toob <- too | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 720 tssb <- tss | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 721 # Top layer | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 722 tss <- exp(-ks * lai1) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 723 too <- exp(-ko * lai1) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 724 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 725 sb <- sdb * rho1 + sdf * tau1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 726 sf <- sdf * rho1 + sdb * tau1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 727 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 728 vb <- dob * rho1 + dof * tau1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 729 vf <- dof * rho1 + dob * tau1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 730 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 731 w1 <- sob * rho1 + sof * tau1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 732 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 733 sigb <- ddb * rho1 + ddf * tau1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 734 sigf <- ddf * rho1 + ddb * tau1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 735 att <- 1.0 - sigf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 736 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 737 m2 <- (att + sigb) * (att - sigb) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 738 m2[m2 < 0] <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 739 m <- sqrt(m2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 740 which_ncs <- which(m > 0.01) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 741 which_cs <- which(m <= 0.01) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 742 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 743 tdd <- rdd <- tsd <- rsd <- tdo <- rdo <- 0 * m | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 744 rsod <- 0 * m | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 745 if (length(which_ncs) > 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 746 resncs <- nonconservativescattering(m[which_ncs], lai1, att[which_ncs], sigb[which_ncs], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 747 ks, ko, sf[which_ncs], sb[which_ncs], vf[which_ncs], vb[which_ncs], tss, too) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 748 tdd[which_ncs] <- resncs$tdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 749 rdd[which_ncs] <- resncs$rdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 750 tsd[which_ncs] <- resncs$tsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 751 rsd[which_ncs] <- resncs$rsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 752 tdo[which_ncs] <- resncs$tdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 753 rdo[which_ncs] <- resncs$rdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 754 rsod[which_ncs] <- resncs$rsod | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 755 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 756 if (length(which_cs) > 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 757 rescs <- conservativescattering(m[which_cs], lai1, att[which_cs], sigb[which_cs], | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 758 ks, ko, sf[which_cs], sb[which_cs], vf[which_cs], vb[which_cs], tss, too) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 759 tdd[which_cs] <- rescs$tdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 760 rdd[which_cs] <- rescs$rdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 761 tsd[which_cs] <- rescs$tsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 762 rsd[which_cs] <- rescs$rsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 763 tdo[which_cs] <- rescs$tdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 764 rdo[which_cs] <- rescs$rdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 765 rsod[which_cs] <- rescs$rsod | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 766 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 767 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 768 # combine with bottom layer reflectances and transmittances (adding method) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 769 rn <- 1.0 - rdd * rddb | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 770 tup <- (tss * rsdb + tsd * rddb) / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 771 tdn <- (tsd + tss * rsdb * rdd) / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 772 rsdt <- rsd + tup * tdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 773 rdot <- rdo + tdd * (rddb * tdo + rdob * too) / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 774 rsodt <- rsod + (tss * rsodb + tdn * rdob) * too + tup * tdo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 775 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 776 rsost <- (w1 * s1 + w2 * s2) * lai | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 777 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 778 rsot <- rsost + rsodt | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 779 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 780 # Diffuse reflectances at the top and the bottom are now different | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 781 rddt_t <- rdd + tdd * rddb * tdd / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 782 rddt_b <- rddb + tddb * rdd * tddb / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 783 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 784 # Transmittances of the combined canopy layers | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 785 tsst <- tss * tssb | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 786 toot <- too * toob | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 787 tsdt <- tss * tsdb + tdn * tddb | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 788 tdot <- tdob * too + tddb * (tdo + rdd * rdob * too) / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 789 tddt <- tdd * tddb / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 790 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 791 # Apply clumping effects to vegetation layer | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 792 rddcb <- cv * rddt_b | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 793 rddct <- cv * rddt_t | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 794 tddc <- 1 - cv + cv * tddt | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 795 rsdc <- cs * rsdt | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 796 tsdc <- cs * tsdt | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 797 rdoc <- co * rdot | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 798 tdoc <- co * tdot | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 799 tssc <- 1 - cs + cs * tsst | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 800 tooc <- 1 - co + co * toot | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 801 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 802 # new weight function fcdc for crown contribution (W. Verhoef, 22-05-08) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 803 rsoc <- fcdc * rsot | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 804 tssooc <- fcd * tsstoo + fcs * toot + fod * tsst + fos | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 805 # Canopy absorptance for black background (W. Verhoef, 02-03-04) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 806 alfas <- 1. - tssc - tsdc - rsdc | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 807 alfad <- 1. - tddc - rddct | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 808 # Add the soil background | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 809 rn <- 1 - rddcb * rddsoil | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 810 tup <- (tssc * rsdsoil + tsdc * rddsoil) / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 811 tdn <- (tsdc + tssc * rsdsoil * rddcb) / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 812 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 813 rddt <- rddct + tddc * rddsoil * tddc / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 814 rsdt <- rsdc + tup * tddc | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 815 rdot <- rdoc + tddc * (rddsoil * tdoc + rdosoil * tooc) / rn | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 816 rsot <- rsoc + tssooc * rsosoil + tdn * rdosoil * tooc + tup * tdoc | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 817 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 818 # Effect of soil background on canopy absorptances (W. Verhoef, 02-03-04) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 819 alfast <- alfas + tup * alfad | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 820 alfadt <- alfad * (1. + tddc * rddsoil / rn) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 821 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 822 my_list <- list("rdot" = rdot, "rsot" = rsot, "rddt" = rddt, "rsdt" = rsdt, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 823 "alfast" = alfast, "alfadt" = alfadt) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 824 return(my_list) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 825 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 826 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 827 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 828 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 829 #" computes non conservative scattering conditions | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 830 #" @param m numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 831 #" @param lai numeric. Leaf Area Index | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 832 #" @param att numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 833 #" @param sigb numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 834 #" @param ks numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 835 #" @param ko numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 836 #" @param sf numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 837 #" @param sb numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 838 #" @param vf numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 839 #" @param vb numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 840 #" @param tss numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 841 #" @param too numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 842 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 843 #" @return list. tdd, rdd, tsd, rsd, tdo, rdo, rsod | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 844 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 845 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 846 nonconservativescattering <- function(m, lai, att, sigb, ks, ko, sf, sb, vf, vb, tss, too) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 847 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 848 e1 <- exp(-m * lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 849 e2 <- e1 * e1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 850 rinf <- (att - m) / sigb | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 851 rinf2 <- rinf * rinf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 852 re <- rinf * e1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 853 denom <- 1. - rinf2 * e2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 854 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 855 j1ks <- jfunc1(ks, m, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 856 j2ks <- jfunc2(ks, m, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 857 j1ko <- jfunc1(ko, m, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 858 j2ko <- jfunc2(ko, m, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 859 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 860 ps <- (sf + sb * rinf) * j1ks | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 861 qs <- (sf * rinf + sb) * j2ks | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 862 pv <- (vf + vb * rinf) * j1ko | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 863 qv <- (vf * rinf + vb) * j2ko | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 864 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 865 tdd <- (1. - rinf2) * e1 / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 866 rdd <- rinf * (1. - e2) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 867 tsd <- (ps - re * qs) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 868 rsd <- (qs - re * ps) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 869 tdo <- (pv - re * qv) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 870 rdo <- (qv - re * pv) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 871 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 872 z <- jfunc2(ks, ko, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 873 g1 <- (z - j1ks * too) / (ko + m) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 874 g2 <- (z - j1ko * tss) / (ks + m) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 875 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 876 tv1 <- (vf * rinf + vb) * g1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 877 tv2 <- (vf + vb * rinf) * g2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 878 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 879 t1 <- tv1 * (sf + sb * rinf) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 880 t2 <- tv2 * (sf * rinf + sb) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 881 t3 <- (rdo * qs + tdo * ps) * rinf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 882 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 883 # Multiple scattering contribution to bidirectional canopy reflectance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 884 rsod <- (t1 + t2 - t3) / (1. - rinf2) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 885 my_list <- list("tdd" = tdd, "rdd" = rdd, "tsd" = tsd, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 886 "rsd" = rsd, "tdo" = tdo, "rdo" = rdo, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 887 "rsod" = rsod) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 888 return(my_list) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 889 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 890 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 891 #" computes conservative scattering conditions | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 892 #" @param m numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 893 #" @param lai numeric. Leaf Area Index | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 894 #" @param att numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 895 #" @param sigb numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 896 #" @param ks numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 897 #" @param ko numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 898 #" @param sf numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 899 #" @param sb numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 900 #" @param vf numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 901 #" @param vb numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 902 #" @param tss numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 903 #" @param too numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 904 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 905 #" @return list. tdd, rdd, tsd, rsd, tdo, rdo, rsod | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 906 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 907 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 908 conservativescattering <- function(m, lai, att, sigb, ks, ko, sf, sb, vf, vb, tss, too) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 909 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 910 # near or complete conservative scattering | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 911 j4 <- jfunc4(m, lai) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 912 amsig <- att - sigb | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 913 apsig <- att + sigb | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 914 rtp <- (1 - amsig * j4) / (1 + amsig * j4) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 915 rtm <- (-1 + apsig * j4) / (1 + apsig * j4) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 916 rdd <- 0.5 * (rtp + rtm) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 917 tdd <- 0.5 * (rtp - rtm) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 918 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 919 dns <- ks * ks - m * m | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 920 dno <- ko * ko - m * m | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 921 cks <- (sb * (ks - att) - sf * sigb) / dns | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 922 cko <- (vb * (ko - att) - vf * sigb) / dno | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 923 dks <- (-sf * (ks + att) - sb * sigb) / dns | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 924 dko <- (-vf * (ko + att) - vb * sigb) / dno | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 925 ho <- (sf * cko + sb * dko) / (ko + ks) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 926 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 927 rsd <- cks * (1 - tss * tdd) - dks * rdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 928 rdo <- cko * (1 - too * tdd) - dko * rdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 929 tsd <- dks * (tss - tdd) - cks * tss * rdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 930 tdo <- dko * (too - tdd) - cko * too * rdd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 931 # Multiple scattering contribution to bidirectional canopy reflectance | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 932 rsod <- ho * (1 - tss * too) - cko * tsd * too - dko * rsd | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 933 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 934 my_list <- list("tdd" = tdd, "rdd" = rdd, "tsd" = tsd, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 935 "rsd" = rsd, "tdo" = tdo, "rdo" = rdo, | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 936 "rsod" = rsod) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 937 return(my_list) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 938 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 939 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 940 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 941 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 942 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 943 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 944 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 945 #" computes the leaf angle distribution function value (freq) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 946 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 947 #" Ellipsoidal distribution function characterised by the average leaf | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 948 #" inclination angle in degree (ala) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 949 #" Campbell 1986 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 950 #" @param ala average leaf angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 951 #" @return foliar_distrib list. lidf and litab | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 952 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 953 campbell <- function(ala) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 954 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 955 tx1 <- c(10., 20., 30., 40., 50., 60., 70., 80., 82., 84., 86., 88., 90.) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 956 tx2 <- c(0., 10., 20., 30., 40., 50., 60., 70., 80., 82., 84., 86., 88.) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 957 litab <- (tx2 + tx1) / 2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 958 n <- length(litab) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 959 tl1 <- tx1 * (pi / 180) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 960 tl2 <- tx2 * (pi / 180) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 961 excent <- exp(-1.6184e-5 * ala**3 + 2.1145e-3 * ala**2 - 1.2390e-1 * ala + 3.2491) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 962 sum0 <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 963 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 964 freq <- c() | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 965 for (i in 1:n) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 966 x1 <- excent / (sqrt(1. + excent**2. * tan(tl1[i])**2)) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 967 x2 <- excent / (sqrt(1. + excent**2. * tan(tl2[i])**2)) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 968 if (excent == 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 969 freq[i] <- abs(cos(tl1[i]) - cos(tl2[i])) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 970 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 971 alpha <- excent / sqrt(abs(1 - excent**2)) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 972 alpha2 <- alpha**2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 973 x12 <- x1**2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 974 x22 <- x2**2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 975 alpx1 <- 0 * alpha2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 976 alpx2 <- 0 * alpha2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 977 almx1 <- 0 * alpha2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 978 almx2 <- 0 * alpha2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 979 if (excent > 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 980 alpx1 <- sqrt(alpha2[excent > 1] + x12[excent > 1]) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 981 alpx2[excent > 1] <- sqrt(alpha2[excent > 1] + x22[excent > 1]) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 982 dum <- x1 * alpx1 + alpha2 * log(x1 + alpx1) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 983 freq[i] <- abs(dum - (x2 * alpx2 + alpha2 * log(x2 + alpx2))) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 984 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 985 almx1 <- sqrt(alpha2 - x12) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 986 almx2 <- sqrt(alpha2 - x22) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 987 dum <- x1 * almx1 + alpha2 * asin(x1 / alpha) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 988 freq[i] <- abs(dum - (x2 * almx2 + alpha2 * asin(x2 / alpha))) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 989 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 990 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 991 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 992 sum0 <- sum(freq) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 993 freq0 <- freq / sum0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 994 foliar_distrib <- list("lidf" = freq0, "litab" = litab) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 995 return(foliar_distrib) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 996 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 997 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 998 #" computes the leaf angle distribution function value (freq) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 999 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1000 #" Using the original bimodal distribution function initially proposed in SAIL | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1001 #" references | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1002 #" ---------- | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1003 #" (Verhoef1998) Verhoef, Wout. Theory of radiative transfer models applied | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1004 #" in optical remote sensing of vegetation canopies. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1005 #" nationaal Lucht en Ruimtevaartlaboratorium, 1998. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1006 #" http: / / library.wur.nl / WebQuery / clc / 945481. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1007 #" @param a controls the average leaf slope | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1008 #" @param b controls the distribution"s bimodality | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1009 #" LIDF type a b | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1010 #" Planophile 1 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1011 #" Erectophile -1 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1012 #" Plagiophile 0 -1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1013 #" Extremophile 0 1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1014 #" Spherical -0.35 -0.15 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1015 #" Uniform 0 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1016 #" requirement: ||lidfa|| + ||lidfb|| < 1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1017 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1018 #" @return foliar_distrib list. lidf and litab | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1019 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1020 dladgen <- function(a, b) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1021 litab <- c(5., 15., 25., 35., 45., 55., 65., 75., 81., 83., 85., 87., 89.) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1022 freq <- c() | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1023 for (i1 in 1:8) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1024 t <- i1 * 10 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1025 freq[i1] <- dcum(a, b, t) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1026 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1027 for (i2 in 9:12) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1028 t <- 80. + (i2 - 8) * 2. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1029 freq[i2] <- dcum(a, b, t) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1030 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1031 freq[13] <- 1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1032 for (i in 13:2) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1033 freq[i] <- freq[i] - freq[i - 1] | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1034 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1035 foliar_distrib <- list("lidf" = freq, "litab" = litab) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1036 return(foliar_distrib) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1037 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1038 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1039 #" dcum function | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1040 #" @param a numeric. controls the average leaf slope | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1041 #" @param b numeric. controls the distribution"s bimodality | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1042 #" @param t numeric. angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1043 #" @return f | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1044 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1045 dcum <- function(a, b, t) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1046 rd <- pi / 180 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1047 if (a >= 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1048 f <- 1 - cos(rd * t) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1049 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1050 eps <- 1e-8 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1051 delx <- 1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1052 x <- 2 * rd * t | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1053 p <- x | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1054 while (delx >= eps) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1055 y <- a * sin(x) + .5 * b * sin(2. * x) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1056 dx <- .5 * (y - x + p) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1057 x <- x + dx | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1058 delx <- abs(dx) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1059 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1060 f <- (2. * y + p) / pi | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1061 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1062 return(f) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1063 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1064 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1065 #" J1 function with avoidance of singularity problem | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1066 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1067 #" @param k numeric. Extinction coefficient for direct (solar or observer) flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1068 #" @param l numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1069 #" @param t numeric. Leaf Area Index | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1070 #" @return jout numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1071 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1072 jfunc1 <- function(k, l, t) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1073 # J1 function with avoidance of singularity problem | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1074 del <- (k - l) * t | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1075 jout <- 0 * l | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1076 jout[which(abs(del) > 1e-3)] <- (exp(-l[which(abs(del) > 1e-3)] * t) - exp(-k * t)) / (k - l[which(abs(del) > 1e-3)]) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1077 jout[which(abs(del) <= 1e-3)] <- 0.5 * t * (exp(-k * t) + exp(-l[which(abs(del) <= 1e-3)] * t)) * (1 - del[which(abs(del) <= 1e-3)] * del[which(abs(del) <= 1e-3)] / 12) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1078 return(jout) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1079 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1080 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1081 #" J2 function with avoidance of singularity problem | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1082 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1083 #" @param k numeric. Extinction coefficient for direct (solar or observer) flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1084 #" @param l numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1085 #" @param t numeric. Leaf Area Index | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1086 #" @return jout numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1087 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1088 jfunc2 <- function(k, l, t) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1089 # J2 function | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1090 jout <- (1. - exp(-(k + l) * t)) / (k + l) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1091 return(jout) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1092 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1093 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1094 #" J3 function with avoidance of singularity problem | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1095 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1096 #" @param k numeric. Extinction coefficient for direct (solar or observer) flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1097 #" @param l numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1098 #" @param t numeric. Leaf Area Index | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1099 #" @return jout numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1100 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1101 jfunc3 <- function(k, l, t) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1102 out <- (1. - exp(-(k + l) * t)) / (k + l) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1103 return(out) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1104 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1105 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1106 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1107 #" j4 function for treating (near) conservative scattering | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1108 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1109 #" @param m numeric. Extinction coefficient for direct (solar or observer) flux | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1110 #" @param t numeric. Leaf Area Index | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1111 #" @return jout numeric. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1112 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1113 jfunc4 <- function(m, t) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1114 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1115 del <- m * t | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1116 out <- 0 * del | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1117 out[del > 1e-3] <- (1 - exp(-del)) / (m * (1 + exp(-del))) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1118 out[del <= 1e-3] <- 0.5 * t * (1. - del * del / 12.) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1119 return(out) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1120 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1121 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1122 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1123 #" compute volume scattering functions and interception coefficients | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1124 #" for given solar zenith, viewing zenith, azimuth and leaf inclination angle. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1125 #" | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1126 #" @param tts numeric. solar zenith | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1127 #" @param tto numeric. viewing zenith | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1128 #" @param psi numeric. azimuth | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1129 #" @param ttl numeric. leaf inclination angle | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1130 #" @return res list. includes chi_s, chi_o, frho, ftau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1131 #" @export | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1132 volscatt <- function(tts, tto, psi, ttl) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1133 #******************************************************************************** | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1134 #* chi_s = interception functions | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1135 #* chi_o = interception functions | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1136 #* frho = function to be multiplied by leaf reflectance rho | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1137 #* ftau = functions to be multiplied by leaf transmittance tau | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1138 #******************************************************************************** | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1139 # Wout Verhoef, april 2001, for CROMA | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1140 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1141 rd <- pi / 180 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1142 costs <- cos(rd * tts) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1143 costo <- cos(rd * tto) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1144 sints <- sin(rd * tts) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1145 sinto <- sin(rd * tto) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1146 cospsi <- cos(rd * psi) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1147 psir <- rd * psi | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1148 costl <- cos(rd * ttl) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1149 sintl <- sin(rd * ttl) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1150 cs <- costl * costs | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1151 co <- costl * costo | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1152 ss <- sintl * sints | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1153 so <- sintl * sinto | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1154 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1155 #c .............................................................................. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1156 #c betas -bts- and betao -bto- computation | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1157 #c Transition angles (beta) for solar (betas) and view (betao) directions | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1158 #c if thetav + thetal > pi / 2, bottom side of the leaves is observed for leaf azimut | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1159 #c interval betao + phi<leaf azimut<2pi-betao + phi. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1160 #c if thetav + thetal<pi / 2, top side of the leaves is always observed, betao=pi | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1161 #c same consideration for solar direction to compute betas | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1162 #c .............................................................................. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1163 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1164 cosbts <- 5 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1165 if (abs(ss) > 1e-6) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1166 cosbts <- -cs / ss | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1167 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1168 cosbto <- 5 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1169 if (abs(so) > 1e-6) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1170 cosbto <- -co / so | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1171 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1172 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1173 if (abs(cosbts) < 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1174 bts <- acos(cosbts) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1175 ds <- ss | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1176 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1177 bts <- pi | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1178 ds <- cs | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1179 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1180 chi_s <- 2. / pi * ((bts - pi * .5) * cs + sin(bts) * ss) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1181 if (abs(cosbto) < 1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1182 bto <- acos(cosbto) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1183 doo <- so | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1184 } else if (tto < 90) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1185 bto <- pi | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1186 doo <- co | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1187 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1188 bto <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1189 doo <- -co | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1190 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1191 chi_o <- 2. / pi * ((bto - pi * .5) * co + sin(bto) * so) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1192 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1193 #c .............................................................................. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1194 #c computation of auxiliary azimut angles bt1, bt2, bt3 used | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1195 #c for the computation of the bidirectional scattering coefficient w | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1196 #c ............................................................................. | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1197 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1198 btran1 <- abs(bts - bto) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1199 btran2 <- pi - abs(bts + bto - pi) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1200 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1201 if (psir <= btran1) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1202 bt1 <- psir | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1203 bt2 <- btran1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1204 bt3 <- btran2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1205 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1206 bt1 <- btran1 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1207 if (psir <= btran2) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1208 bt2 <- psir | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1209 bt3 <- btran2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1210 } else { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1211 bt2 <- btran2 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1212 bt3 <- psir | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1213 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1214 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1215 t1 <- 2. * cs * co + ss * so * cospsi | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1216 t2 <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1217 if (bt2 > 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1218 t2 <- sin(bt2) * (2. * ds * doo + ss * so * cos(bt1) * cos(bt3)) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1219 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1220 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1221 denom <- 2. * pi * pi | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1222 frho <- ((pi - bt2) * t1 + t2) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1223 ftau <- (-bt2 * t1 + t2) / denom | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1224 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1225 if (frho < 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1226 frho <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1227 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1228 if (ftau < 0) { | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1229 ftau <- 0 | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1230 } | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1231 res <- list("chi_s" = chi_s, "chi_o" = chi_o, "frho" = frho, "ftau" = ftau) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1232 return(res) | 
| 
33a1e15f7252
planemo upload for repository https://github.com/Marie59/Sentinel_2A/srs_tools commit b32737c1642aa02cc672534e42c5cb4abe0cd3e7
 ecology parents: diff
changeset | 1233 } | 
