runpointmodela: Runs point microclimate model over each grid cell of an array

View source: R/Cppwrappers.R

runpointmodelaR Documentation

Runs point microclimate model over each grid cell of an array

Description

The function 'runpointmodela' runs the point microclimate model for each grid cell of a climarray provided as an array

Usage

runpointmodela(
  climarrayr,
  tme,
  reqhgt = 0.05,
  dtm,
  vegp,
  soilc,
  matemp = NA,
  zref = 2,
  windhgt = 2,
  soilm = NA,
  dTmx = 25,
  maxiter = 20,
  yearG = TRUE
)

Arguments

climarrayr

a list of weather variables provided as SpatRasters (see details)

tme

POSIXlt object giving the dates and times for each weather variable stored in the array

reqhgt

height for which temperatures are needed (used only when reqhgt < 0 to calculate tmeperature below ground)

dtm

a SpatRaster of elevations for the study area

vegp

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

soilc

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

matemp

optionally a single numeric value of approximate mean annual temperatures averaged across study region. Only used for refining below-ground temperature estimates and calculate as the mean of weather data temperatures if not provided.

zref

height above ground (m) of temperature measurements in weather

windhgt

height above ground (m) of wind speed data in weather

soilm

optional vector of soil moisture values in upper 10 cm of the soil (calculated if not supplied)

dTmx

optional maximum amount by which canopy or ground surface temperatures can exceed air temperatures. Included to ensure model convergence

maxiter

optional integer indicating the maximum number of iterations (see details)

yearG

optional logical indicating whether or not to include annual ground heat flux cycle

lat

optional central latitude of study area (removes tile effects when running in tiles)

long

optional central longitude of study area (removes tile effects when running in tiles)

Details

The units of 'climarrayr' must follow those in the dataset 'climdata'. It must be a list with each component of the list a SpatRaster, named using the same names as the column headers in climdata (e.g. temp for temperature), excluding 'obs_time'. As not all wind measurements are at reference height, the height of the wind speed measurement must be specified if not 2 m. To enable calculation of below-canopy wind and temperature profiles in tall canopy, the wind speed and temperature data are adjusted to give values for a height at the maximum vegetation height if the tallest vegetation exceeds two metres. For doing so a stand vegetation surface typical of that in which a weather station would be located is assumed. The parameter 'maxiter' sets the maximum number of times the model is iterated to achieve convergence. Increasing this value improves accuracy at the expense of computation time.

Value

a list of point microclimate model outputs (as returned by runmicropoint) but for each grid cell

Examples

# ======== Create dummy array datasets ========= #
.ta<-function(x,dtm,xdim=5,ydim=5) {
   a<-array(rep(x,each=ydim*xdim),dim=c(ydim,xdim,length(x)))
   .rast(a,dtm)
}
dtm<-rast(dtmcaerth)
climarrayr<-list(temp=.ta(climdata$temp,dtm),
                 relhum=.ta(climdata$relhum,dtm),
                 pres=.ta(climdata$pres,dtm),
                 swdown=.ta(climdata$swdown,dtm),
                 difrad=.ta(climdata$difrad,dtm),
                 lwdown=.ta(climdata$lwdown,dtm),
                 windspeed=.ta(climdata$windspeed,dtm),
                 winddir=.ta(climdata$winddir,dtm),
                 precip=.ta(climdata$precip,dtm))
# Run model
tme<-as.POSIXlt(climdata$obs_time,tz="UTC")
# Takes ~15 seconds to run
pointmodela <- runpointmodela(climarrayr, tme, reqhgt = 0.05, dtm, vegp, soilc)

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