run_SCOPE: run_SCOPE

View source: R/run_SCOPE.R

run_SCOPER Documentation

run_SCOPE

Description

This is a function to run SCOPE/Matlab simulations from r changing model inputs and setting. It will open automatic Matlab, run SCOPE and close when the simulation finish.

Usage

run_SCOPE(
  csv_inputs,
  SCOPE_dir = "D:/SCOPE-master/",
  filenames = filenames,
  Simulation_Name,
  soil_file = "soilnew.txt",
  t = NA,
  Rin = NA,
  Rli = NA,
  p = NA,
  Ta = NA,
  RH = NA,
  ea = NA,
  VPD = NA,
  u = NA,
  tts = NA,
  tto = NA,
  psi = NA,
  z = NA,
  Ca = NA,
  SMC = NA,
  BSMBrightnes = NA,
  BSMlat = NA,
  BSMlon = NA,
  LAI = NA,
  hc = NA,
  Cab = NA,
  Cca = NA,
  Cdm = NA,
  Cw = NA,
  Cs = NA,
  Cant = NA,
  LIDFa = NA,
  LIDFb = NA,
  Vcmax25 = NA,
  BallBerrySlope = NA,
  input_data_default = input_data_default,
  PROSPECT = NA,
  Cab_c = 40,
  Cca_c = 10,
  Cdm_c = 0.012,
  Cw_c = 0.009,
  Cs_c = 0,
  Cant_c = 1,
  cp = 0,
  Cbc = 0,
  Cp = 0,
  N = 1.5,
  rho_thermal = 0.01,
  tau_thermal = 0.01,
  Leaf_Biochemical = NA,
  Vcmax25_c = 60,
  BallBerrySlope_c = 8,
  BallBerry0 = 0.01,
  Type = 0,
  kV = 0.64,
  Rdparam = 0.015,
  Kn0 = 2.48,
  Knalpha = 2.83,
  Knbeta = 0.114,
  Leaf_Biochemical_magnani = NA,
  Tyear = 15,
  beta = 0.51,
  kNPQs = 0,
  qLs = 1,
  stressfactor = 1,
  Fluorescence = NA,
  fqe = 0.01,
  Soil = NA,
  spectrum = 1,
  rss = 500,
  rs_thermal = 0.06,
  cs = 1180,
  rhos = 1800,
  lambdas = 1.55,
  SMC_c = 25,
  BSMBrightness_c = 0.5,
  BSMlat_c = 25,
  BSMlon_c = 45,
  Canopy = NA,
  LAI_c = 3,
  hc_c = 2,
  LIDFa_c = -0.35,
  LIDFb_c = -0.15,
  leafwidth = 0.1,
  Cv = 1,
  crowndiameter = 1,
  Meteo = NA,
  z_c = NA,
  Rin_c = 600,
  Ta_c = 20,
  Rli_c = 300,
  p_c = 970,
  ea_c = 15,
  u_c = 2,
  Ca_c = 410,
  Oa = 209,
  Aerodynamic = NA,
  zo = 0.25,
  d = 1.34,
  Cd = 0.3,
  rb = 10,
  CR = 0.35,
  CD1 = 20.6,
  Psicor = 0.2,
  CSSOIL = 0.01,
  rbs = 10,
  rwc = 0,
  timeseries = NA,
  startDOY = 20190101,
  endDOY = 20191231,
  LAT = 52,
  LON = 13,
  timezn = 0,
  Angles = NA,
  tts_c = 30,
  tto_c = 0,
  psi_c = 0,
  setoptions = setoptions,
  lite = 1,
  verify = 0,
  saveCSV = 1,
  mSCOPE = 0,
  simulation = 1,
  save_spectral = 0,
  calc_fluor = 0,
  calc_planck = 0,
  calc_xanthophyllabs = 0,
  Fluorescence_model = 0,
  calc_directional = 0,
  calc_vert_profiles = 0,
  soilspectrum = 1,
  applTcorr = 1,
  soil_heat_method = 2,
  calc_rss_rbs = 0,
  MoninObukhov = 1,
  set_parameter_filenames = set_parameter_filenames,
  split = FALSE,
  col_split = "",
  split_values
)

Arguments

csv_inputs

a data.frame with a datetime variable required to SCOPE (BerkeleyJulianDate) and all the model input variables.

SCOPE_dir

the patch to the SCOPE directory.

Simulation_Name

the name of the files start with

t

the variable name in the df for the BerkeleyJulianDate, e.g. "t".

Rin, Rin

the variables Rin (shortwave solar radiation), Rli (longwave radiation).

p, Ta, RH, ea, VPD

the variables p (air pressure), Ta (air temperature), RH (relative humidity), ea (vapour pressure) and VPD (vapour pressure deficit).

u

the variable (wind speed).

psi

the variables psi (relative angle), tts (zenith solar angle), tto (observed angle).

SMC, LAI, hc

the variables (soil moisture content at the root deep), LAI (Leaf Area Index), hc (canopy height).

hc_c, LAI_c, Cab_c

e.g. default hc is 2 but it can be changed by including in the formula hc_c = 10 or other value.

z_c

the tower height. Al the constant from a SCOPE can be changed from the default values,

simulation

= 1 as default, but any SCOPE model setting can be changed by inform the name and the value,

soilspectrum

e.g. instance, soilspectrum = 1 to use a spectra file for the soil model.

split

default = FALSE

col_split

for instance "week_" dataset_for_verification

split_values

split_pixels[i] or split_week[i] from 1:53 then the result is like "week_52"

Value

It return a message "done!". A set of files from the simulation will be save on the SCOPE directory/output/simulation_name

Examples

Examples of uses of the run_SCOPE function
#########
run one file in the environment that will be saved on the SCOPE directory

run_SCOPE(SCOPE_dir = "D:/SCOPE-master/", # SCOPE directory patch
         csv_inputs = Inputs_pixels_ROTH, # file name with all inputs (variables)
         Simulation_Name = "ROTH",
         # variables
         t = "t", # time BerkeleyJulianDate
         Rin = "Rin", Rli = "Rli",
         p = "p", Ta = "Ta", RH = "RH", ea = "ea", VPD = NA,
         u = "ws",
         tts = "tts", tto = NA, psi = "psi", # geometry
         SMC = "SMC_40", # soil
         LAI = "LAI", hc = "hc",# vegetation
         # constants values (non-default)
         hc_c = 20,
         z_c = 40,
         startDOY = 20190101, endDOY =20191231,  # timestamp preiod
         LAT = 52.00, LON = 13.00, timezn = 0,   # Lat/long and time zone
         # settings values (non-default)
         soilspectrum = 1,
         soil_file = "soilROTH.txt", # soil spectrum file (save at "D:\SCOPE-master\input\soil_spectra")
         applTcorr = 1,
         soil_heat_method = 2,
         MoninObukhov = 1)

run divided/spit by pixel

run_SCOPE(csv_inputs = Inputs_Berlin_masked,
         Simulation_Name = "Pixel_",
         split = TRUE,
         col_split = "id_pixel",
         split_values = c(1169),
         # variable names
         SMC = "SMC_60",
         LAI = "LAI",
         hc = "hc_1m",
         # constants values (non-default)
         hc_c = 19,
        z_c = 40, # measurements height
         # settings values (non-default)
         soilspectrum = 1,
         applTcorr = 1,
         soil_heat_method = 2,
         MoninObukhov = 1)

split by pixel and with time delay in seconds
library("svMisc")

split_pixels <- c(1169, 882)
zm_pixels <- c(40,56)
n = 2

for (i in 1:n) {
 run_SCOPE(csv_inputs = Inputs_Berlin_masked,
           Simulation_Name = paste0("pixel_", i),
           split = TRUE,
           col_split = "id_pixel", #dataset_for_verification
           split_values = split_pixels[i],
          # variable names
           t = "t", # time BerkeleyJulianDate
           Rin = "Rin", Rli = "Rli",
           p = "p", Ta = "Ta", RH = "RH", ea = "ea", u = "ws",
           tts = "tts", tto = NA, psi = "psi",
           SMC = "SMC60",
           LAI = "LAI",
           hc = "hc_1m",
           # constants values (non-default)
           hc_c = 20,
          z_c = zm_pixels[i],
           # settings values (non-default)
           soilspectrum = 1,
           applTcorr = 1,
           soil_heat_method = 2,
           MoninObukhov = 0)
 # time delay
 progress(i, n, progress.bar = TRUE, init = T)
 Sys.sleep(360) #time delay in seconds
 if (i == n) message("Done!")
}

split by pixel and with time delay in seconds
library("svMisc")

SMC_i <- c("SMC60","SMC60","SMC60","SMC60", "SMC60","SMC60","SMC60","SMC60",
          "SMC40","SMC40","SMC40","SMC40", "SMC60","SMC60","SMC60","SMC60",
          "SMC20","SMC20","SMC20","SMC20", "SMC60","SMC60","SMC60","SMC60")
LAI_i <- c("LAI","LAI_mean","LAI_max",NA, "LAI","LAI_mean","LAI_max",NA,
          "LAI","LAI_mean","LAI_max",NA, "LAI","LAI_mean","LAI_max",NA,
         "LAI","LAI_mean","LAI_max",NA, "LAI","LAI_mean","LAI_max",NA)
hc_i <- c("hc_1m","hc_1m","hc_1m","hc_1m", "hc_vh","hc_vh","hc_vh","hc_vh",
         "hc_1m","hc_1m","hc_1m","hc_1m", "hc_bf","hc_bf","hc_bf","hc_bf",
         "hc_1m","hc_1m","hc_1m","hc_1m",  NA,     NA,    NA,    NA)
hc_c_i <- c(NA,     NA,    NA,    NA,       NA,     NA,    NA,    NA,
           NA,     NA,    NA,    NA,       NA,     NA,    NA,    NA,
           NA,     NA,    NA,    NA,       10,     2,    10,    10)

for (i in 1:length(SMC_i)) {
 run_SCOPE(csv_inputs = Inputs_Berlin_masked,
           Simulation_Name = paste0("pixel_882_", i),
           split = TRUE,
           col_split = "id_pixel", #dataset_for_verification
           split_values = 882, #1169,
           # variable names
           t = "t", # time BerkeleyJulianDate
           Rin = "Rin", Rli = "Rli",
           p = "p", Ta = "Ta", RH = "RH", ea = "ea", u = "ws",
           tts = "tts", tto = NA, psi = "psi", # geometry
           # variables calibration
           SMC = SMC_i[i], # soil
           LAI = LAI_i[i],
           hc = hc_i[i], # vegetation
           # constants values (non-default)
           hc_c = hc_c_i[i],
           z_c =  56, #40,
           startDOY = 20181201, endDOY =20200130,  # timestamp period
           LAT = 52.00, LON = 13.00, timezn = 0,   # Lat/long and time zone
           # settings values (non-default)
           soilspectrum = 1,
           soil_file = "soilROTH.txt", # soil spectrum file (save at "D:\SCOPE-master\input\soil_spectra")
           applTcorr = 1,
           soil_heat_method = 2,
          MoninObukhov = 1)
# time delay
 progress(i, length(SMC_i), progress.bar = TRUE, init = T)
 Sys.sleep(360) #time delay in seconds
 if (i == length(SMC_i)) message("Done!")
}

split by week and with time delay in seconds

split_week <- 1:53
n2 = 12
for (i in 9:n2) {
  run_SCOPE(csv_inputs = Inputs_Berlin_masked,
            Simulation_Name = paste0("week_", i, "_SMC60_LAI_hc"),
            split = TRUE,
            col_split = "week", #dataset_for_verification
            split_values = split_week[i],
            t = "t", # time BerkeleyJulianDate
            Rin = "Rin", Rli = "Rli",
            p = "p", Ta = "Ta", RH = "RH", ea = "ea", u = "ws",
            tts = "tts", tto = NA, psi = "psi",
            SMC_var = "SMC60",
            LAI_var = "LAI",
            hc_var = "hc",
            hc_fix = 20,
            zm = 40,
            soilspectrum = 1,
            applTcorr = 1,
            soil_heat_method = 2,
            calc_rss_rbs = 0,
            MoninObukhov = 1)
  progress(i, n2, progress.bar = TRUE, init = T)
  Sys.sleep(3600) # time delay in seconds - 1 hour
  if (i == n2) message("Done!")
}


AlbyDR/rSCOPE documentation built on Dec. 19, 2024, 7:29 p.m.