From 6f99f1317269a63f148aced3209c5fda25debf27 Mon Sep 17 00:00:00 2001 From: yijianzeng Date: Wed, 24 May 2023 15:22:44 +0200 Subject: [PATCH 1/4] refactor_global_as_function_inputs --- src/+equations/calc_rssrbs.m | 16 ++++++++++++---- src/+io/select_input.m | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/+equations/calc_rssrbs.m b/src/+equations/calc_rssrbs.m index 6be64a5d..45d27d52 100644 --- a/src/+equations/calc_rssrbs.m +++ b/src/+equations/calc_rssrbs.m @@ -1,5 +1,13 @@ -function [rss, rbs] = calc_rssrbs(SMC, LAI, rbs) - global SaturatedMC ResidualMC fieldMC +function [rss, rbs] = calc_rssrbs(SMC, LAI, rbs, ResidualMC, fieldMC) +%{ +This function is to calculate surface resistance, following C. van der Tol +et al. 2014 (BG). The emperical parameters "aa, 4.1, and 4.3" are +user-defined. And these parameters can be calibrated during winter season +when LAI is low. +%} aa = 3.8; - rss = exp((aa + 4.1) - aa * (SMC - ResidualMC(1)) / (fieldMC(1) - ResidualMC(1))); - rbs = rbs * LAI / 4.3; + bb = 4.1; + cc = 4.3; + + rss = exp((aa + bb) - aa * (SMC - ResidualMC) / (fieldMC - ResidualMC)); + rbs = rbs * LAI / cc; diff --git a/src/+io/select_input.m b/src/+io/select_input.m index b5ac6713..36658839 100644 --- a/src/+io/select_input.m +++ b/src/+io/select_input.m @@ -82,7 +82,7 @@ SoilProperties.GAM = equations.Soil_Inertia0(SoilProperties.cs, SoilProperties.rhos, SoilProperties.lambdas); end if options.calc_rss_rbs - [SoilProperties.rss, SoilProperties.rbs] = equations.calc_rssrbs(SoilProperties.SMC, canopy.LAI, SoilProperties.rbs); + [SoilProperties.rss, SoilProperties.rbs] = equations.calc_rssrbs(SoilProperties.SMC, canopy.LAI, SoilProperties.rbs,SoilProperties.ResidualMC, SoilProperties.fieldMC); end if leafbio.Type From 15ba5faecbad1ae3c88dc9e1bc4c6901ca5a96cc Mon Sep 17 00:00:00 2001 From: yijianzeng Date: Wed, 24 May 2023 16:10:49 +0200 Subject: [PATCH 2/4] select_input_last_two_options_swap --- src/+io/select_input.m | 2 +- src/STEMMUS_SCOPE.m | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/+io/select_input.m b/src/+io/select_input.m index 36658839..cdf4a1d2 100644 --- a/src/+io/select_input.m +++ b/src/+io/select_input.m @@ -1,4 +1,4 @@ -function [SoilProperties, leafbio, canopy, meteo, angles, SpaceTimeInfo] = select_input(ScopeParameters, digitsVector, canopy, options, SpaceTimeInfo, SoilProperties) +function [SoilProperties, leafbio, canopy, meteo, angles, SpaceTimeInfo] = select_input(ScopeParameters, digitsVector, canopy, options, SoilProperties, SpaceTimeInfo) global Theta_LL theta_s0 SoilProperties.spectrum = ScopeParameters.spectrum(digitsVector(16)); SoilProperties.rss = ScopeParameters.rss(digitsVector(17)); diff --git a/src/STEMMUS_SCOPE.m b/src/STEMMUS_SCOPE.m index bbdefc04..d0919576 100644 --- a/src/STEMMUS_SCOPE.m +++ b/src/STEMMUS_SCOPE.m @@ -212,7 +212,7 @@ ScopeParametersNames = fieldnames(ScopeParameters); if options.simulation == 1 vi = ones(length(ScopeParametersNames), 1); - [soil, leafbio, canopy, meteo, angles, xyt] = io.select_input(ScopeParameters, vi, canopy, options); + [soil, leafbio, canopy, meteo, angles, xyt] = io.select_input(ScopeParameters, vi, canopy, options, SoilProperties); [ScopeParameters, xyt, canopy] = io.loadTimeSeries(ScopeParameters, leafbio, soil, canopy, meteo, constants, F, xyt, path_input, options); else soil = struct; @@ -512,7 +512,7 @@ if options.simulation == 0 vi(vmax == telmax) = k; end - [soil, leafbio, canopy, meteo, angles, xyt] = io.select_input(ScopeParameters, vi, canopy, options, xyt, soil); + [soil, leafbio, canopy, meteo, angles, xyt] = io.select_input(ScopeParameters, vi, canopy, options, soil, xyt); if options.simulation ~= 1 fprintf('simulation %i ', k); fprintf('of %i \n', telmax); From accf75488af8ff93bcd455fce6c8d9e3758c80fe Mon Sep 17 00:00:00 2001 From: yijianzeng Date: Wed, 24 May 2023 16:18:19 +0200 Subject: [PATCH 3/4] Fix_Style_Issue --- src/+equations/calc_rssrbs.m | 14 +++++++------- src/+io/select_input.m | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/+equations/calc_rssrbs.m b/src/+equations/calc_rssrbs.m index 45d27d52..2785ab93 100644 --- a/src/+equations/calc_rssrbs.m +++ b/src/+equations/calc_rssrbs.m @@ -1,13 +1,13 @@ function [rss, rbs] = calc_rssrbs(SMC, LAI, rbs, ResidualMC, fieldMC) -%{ -This function is to calculate surface resistance, following C. van der Tol -et al. 2014 (BG). The emperical parameters "aa, 4.1, and 4.3" are -user-defined. And these parameters can be calibrated during winter season -when LAI is low. -%} + %{ + This function is to calculate surface resistance, following C. van der Tol + et al. 2014 (BG). The emperical parameters "aa, 4.1, and 4.3" are + user-defined. And these parameters can be calibrated during winter season + when LAI is low. + %} aa = 3.8; bb = 4.1; cc = 4.3; - + rss = exp((aa + bb) - aa * (SMC - ResidualMC) / (fieldMC - ResidualMC)); rbs = rbs * LAI / cc; diff --git a/src/+io/select_input.m b/src/+io/select_input.m index cdf4a1d2..967cebbf 100644 --- a/src/+io/select_input.m +++ b/src/+io/select_input.m @@ -82,7 +82,7 @@ SoilProperties.GAM = equations.Soil_Inertia0(SoilProperties.cs, SoilProperties.rhos, SoilProperties.lambdas); end if options.calc_rss_rbs - [SoilProperties.rss, SoilProperties.rbs] = equations.calc_rssrbs(SoilProperties.SMC, canopy.LAI, SoilProperties.rbs,SoilProperties.ResidualMC, SoilProperties.fieldMC); + [SoilProperties.rss, SoilProperties.rbs] = equations.calc_rssrbs(SoilProperties.SMC, canopy.LAI, SoilProperties.rbs, SoilProperties.ResidualMC, SoilProperties.fieldMC); end if leafbio.Type From 64ee60991ffb5c552b00ff9046739f9b355489fb Mon Sep 17 00:00:00 2001 From: yijianzeng Date: Tue, 30 May 2023 13:00:23 +0200 Subject: [PATCH 4/4] ResidualMC(1)_index_needed/added --- src/+equations/calc_rssrbs.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/+equations/calc_rssrbs.m b/src/+equations/calc_rssrbs.m index 2785ab93..8d4ed93d 100644 --- a/src/+equations/calc_rssrbs.m +++ b/src/+equations/calc_rssrbs.m @@ -9,5 +9,5 @@ bb = 4.1; cc = 4.3; - rss = exp((aa + bb) - aa * (SMC - ResidualMC) / (fieldMC - ResidualMC)); + rss = exp((aa + bb) - aa * (SMC - ResidualMC(1)) / (fieldMC(1) - ResidualMC(1))); rbs = rbs * LAI / cc;