pschmidtwalter / LWFBrook90R

Run the LWF-Brook90 hydrological model within R.
https://pschmidtwalter.github.io/LWFBrook90R/
10 stars 7 forks source link

Define LAI as Input Value #71

Open yjaguilara opened 2 months ago

yjaguilara commented 2 months ago

I would like to be able to initially define LAI for each of the days I am going to analyze, in the same way that I defined SAI, densef, Age, height. However, the code I have found only gives me the option to calculate LAI with the available methods using make_seasLAI. What function or variable input could I use to define specific LAI values for each of the days I will analyze? Thanks in advance for your help.

pschmidtwalter commented 2 months ago

Do you also estimate LAI from a function and few parameters? We could implement it as a new lai-method into the package.

Otherwise, you can use the low-level function that calls the model kernel (see below), or adjust the run_LWFB90() function directly.

Let me know if that works for you.

Best regards, Paul

library(LWFBrook90R)
library(data.table)

parms <- set_paramLWFB90()
opts <- set_optionsLWFB90()
soil <- cbind(slb1_soil, hydpar_wessolek_tab(slb1_soil$texture))

# create an input list without running the model
input <- run_LWFB90(options_b90 = opts, 
           param_b90 = parms,
           climate = slb1_meteo,
           soil = soil,
           run = F)

# prepare climate
climate = data.table(slb1_meteo)
climate[,`:=`(yr=year(dates), mo = month(dates), da = mday(dates), mesfl = 0)]
climate <- climate[between(dates, opts$startdate,opts$enddate),]

# put your lai series into standprop_daily data.frame 
input$standprop_daily 

# run model using low-level function (call copied and adjusted from run_LWFB90).  
simout <- with(input, 
               r_lwfbrook90(
                 siteparam = data.frame(as.integer(format(options_b90$startdate, "%Y")),
                                        as.integer(format(options_b90$startdate, "%j")),
                                        param_b90$coords_y, param_b90$snowini, param_b90$gwatini,
                                        options_b90$prec_interval),
                 climveg = cbind(climate[, c("yr", "mo", "da","globrad","tmax","tmin",
                                             "vappres","windspeed","prec","mesfl")],
                                 standprop_daily[, c("densef", "height", "lai", "sai", "age")]),
                 precdat = NULL,
                 param = param_to_rlwfbrook90(param_b90, options_b90$imodel),
                 pdur = param_b90$pdur,
                 soil_materials = param_b90$soil_materials,
                 soil_nodes = param_b90$soil_nodes[,c("layer","midpoint", "thick", "mat", "psiini", "rootden")],
                 output_log = F,
                 chk_input = F
                 )
)

str(simout)