runmicro: Runs the grid microclimate model

View source: R/Cppwrappers.R

runmicroR Documentation

Runs the grid microclimate model

Description

The function 'runmicro' runs the grid version of the microclimate model

Usage

runmicro(
  micropoint,
  reqhgt,
  vegp,
  soilc,
  dtm,
  dtmc = NA,
  altcorrect = 0,
  snow = FALSE,
  snowmod = NA,
  runchecks = TRUE,
  pai_a = NA,
  tfact = 1.5,
  out = rep(TRUE, 10),
  slr = NA,
  apr = NA,
  hor = NA,
  twi = NA,
  wsa = NA,
  svf = NA,
  method = "Cpp"
)

Arguments

micropoint

an object of class micropoint or a list of objects of class micropoint as returned by [runpointmodel()], [runpointmodela()], [subsetpointmodel()] or [subsetpointmodela()]

reqhgt

height above (postive) or below (negative) ground for which microclimate variables are required (m)

vegp

an object of class vegparams as returned by [vegpfromhab()] (see details)

soilc

an object of class soilcharac as returned by [soilcfromtype()]

dtm

a SpatRaster object of elevations in metres (see details)

dtmc

a SpatRaster object giving the resolution, spatial extent, and projection of the climate data used when running [micropointa()]. Ignored if climate data used for running the point model are provided as a data.frame. Must give elevations in metres if 'altcorrect' > 0 or if setting runchecks to TRUE.

altcorrect

a single numeric value indicating whether to apply an elevational lapse rate correction to temperatures (0 = no correction, 1 = fixed lapse rate correction, 2 = humidity-dependent variable lapse rate correction, see details)

snow

optional logical indicating whether to account for snow (TRUE = yes)

snowmod

optional list of snow model outputs as returned by [runsnowmodel()]. Only required if 'snow' set to TRUE. Must match entries in 'micropoint'.

runchecks

optional logical indicating whether to call [checkinputs()] to run

pai_a

an array of plant area index values above 'reqhgt'. Determined from total 'pai' if not supplied.

tfact

coefficient determining sensitivity of soil moisture to variation in topographic wetness (see [soilmdistribute()]).

out

optional vector of logicals indicating which variables to return ordered as for the listed outputs when ‘rehgt > 0’' (e.g. 'out[1] = TRUE' indicates that 'Tz' is returned, 'out[2]' that 'tleaf' is returned etc). By default all variables are returned.

slr

an optional SpatRaster object of slope values (degrees). Calculated from the dtm in micro if not supplied, but outer cells assumed flat.

apr

an optional SpatRaster object of aspect values (degrees). Calculated from the dtm ion micro if not supplied, but outer cells assumed flat.

hor

an optional array of the tangent of the angle to the horizon in 24 directions. Calculated from the dtm in micro if not supplied, but edge effects not accounted for.

twi

optional SpatRast object of topographic wetness index values. Calculated from the dtm in micro if not supplied, , but edge effects not accounted for.

wsa

an optional array of wind shelter coefficients in 8 directions. Calculated from the dtm in micro if not supplied, , but edge effects not accounted for.

method

on of 'R' or 'Cpp' (see details)

sva

optional SpatRaster object of the skyview factor. Calculated from the dtm in micro if not supplied, but cannot account for edge effects.

Details

'pai_a' is used to calculate the radiation intercepted by leaves at 'reqhgt' if below canopy. If not supplied it is calculated from total plant area index by assuming a realistic shape to the vertical profile foliage within the canopy. If supplied, 'pai_a' must have the same dimensions as micro$pai. I.e. with the same x and y dims as the the supplied dtm and values for each hour as the z dimension. The parameter 'surfwet' determines how much of the canopy should be treated as wet surface when calculating latent heat fluxes. The units of dtmc must match dtm and must be elevation data if an altitude correction is applied. If 'altcorrect'>0, the elevation difference between each pixel of dtm and dtmc is calculated and an elevation lapse rate correction is applied to the temperature and pressure data to account for these elevation differences. If 'altcorrect'= 1, a fixed lapse rate of 5 degrees per 100m is applied to the temperature data. If 'altcorrect'= 2, humidity-dependent lapse rates are calculated and applied.

Value

If 'reqhgt > 0':

Tz

Air temperatures at height 'reqhgt' (deg C)

tleaf

Leaf temperatures at height 'reqhgt' (deg C)

relhum

Relative humidities at height 'reqhgt' (percentage)

soilm

Volumtric water fraction in 10 cm of soil (m^3/m^3)

windspeed

Wind speeds at height 'reqhgt' (m/s)

Rdirdown

Flux density of downward direct radiation at 'reqhgt' (W/m^2 - on the horizontal

Rdifdown

Flux density of downward diffuse radiation at 'reqhgt' (W/m^2)

Rlwdown

Flux density of downward longwave radiation at 'reqhgt' (W/m^2)

Rswup

Flux density of upward shorwtave radiation at 'reqhgt' (W/m^2), assumed diffuse

Rlwup

Flux density of downward longwave radiation at 'reqhgt' (W/m^2)

If 'reqhgt == 0':

Tz

Soil surface temperatures (deg C)

soilm

Volumtric water fraction in 10 cm of soil (m^3/m^3)

Rdirdown

Flux density of downward direct radiation at 'reqhgt' (W/m^2 - on the horizontal

Rdirdown

Flux density of downward diffuse radiation at 'reqhgt' (W/m^2)

Rlwdown

Flux density of downward longwave radiation at 'reqhgt' (W/m^2)

Rswup

Flux density of upward shorwtave radiation at 'reqhgt' (W/m^2), assumed diffuse

Rlwup

Flux density of downward longwave radiation at 'reqhgt' (W/m^2)

If 'reqhgt < 0':

Tz

Soil temperatures at depth '-reqhgt' (deg C)

soilm

Volumtric water fraction in 10 cm of soil (m^3/m^3)

Returned variables are also contingent on 'out'.

Examples

library(terra)
# ** First run point model setting reqhgt to 5 cm above ground using inbuilt datasets
micropoint <- runpointmodel(climdata, 0.05, dtmcaerth, vegp, soilc)
# ** Subset inbuilt point model to get hottest and coldest days in each month
micropoint_mx <- subsetpointmodel(micropoint, tstep = "month", what = "tmax")
micropoint_mn <- subsetpointmodel(micropoint, tstep = "month", what = "tmin")
# ** Run grid model for hottest and coldest days (takes ~20 seconds to run)
mout_mx <- runmicro(micropoint_mx, 0.05, vegp, soilc, dtmcaerth)
mout_mn <- runmicro(micropoint_mn, 0.05, vegp, soilc, dtmcaerth)
# Plot air temperatures on hottest hour
mypal <- colorRampPalette(c("darkblue", "blue", "green", "yellow",
"orange", "red"))(255)
plot(rast(mout_mx$Tz[,,134]), col = mypal)
# Plot mean of monthly max and min
mairt<-apply((mout_mn$Tz + mout_mx$Tz) / 2, c(1,2),mean)
plot(rast(mairt), col = mypal)
# Remove vegetation effects and run again for one cm above ground
vegp2 <- vegp
vegp2$pai <- rast(vegp2$pai) * 0
vegp2$hgt <- rast(vegp2$hgt) * 0
mout_mx <- runmicro(micropoint_mx, 0.005, vegp2, soilc, dtmcaerth)
plot(rast(mout_mx$Tz[,,134]), col = mypal)

ilyamaclean/microclimf documentation built on Sept. 28, 2024, 4:55 p.m.